Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

script : give item to a NPC in the right slot

Page: 1 of 1
 jrc24
06-30-2004, 3:32 AM
#1
Hi

with script,

How can I give item to a NPC and put this item in the right slot (hand, head or arm...) ?

I know :

int nSlot = (number_of_slot)
object oNPC=GetObjectByTag("npc_name");
object oItem=GetObjectByTag("item_name");

I try CreateItemOnObject and ActionEquipItem with no success

Please can you tell me how must I use this functions if it is the right functions

thanks
 tk102
06-30-2004, 9:43 AM
#2
The functions that start with "Action" do not have a parameter of oNPC in them (they are assumed to work on OBJECT_SELF). So to get them to work on oNPC you have to use the AssignCommand function.

It sounds like you were very close though.

void main() {
int nSlot = INVENTORY_SLOT_RIGHTWEAPON;
object oNPC=GetObjectByTag("npc_name");
object oItem=GetObjectByTag("item_name");
CreateItemOnObject("item_name",oNPC);
AssignCommand(oNPC,ActionEquipItem(oItem, nSlot));
}
 jrc24
06-30-2004, 7:14 PM
#3
ok I write that :

void main() {
int nSlot = (4);
object oNPC=GetObjectByTag("Zaalbar");
object oItem=GetObjectByTag("my_item_name");
CreateItemOnObject("my_item_name", oNPC);
AssignCommand(oNPC, ActionEquipItem(oItem, nSlot));
}

result :

I get my item in general inventory but not in Zaalbar hand

if you see what could be the problem, thanks
 Darth333
06-30-2004, 7:31 PM
#4
Make sure you use: "int nSlot = INVENTORY_SLOT_RIGHTWEAPON;" instead of "int nSlot = (4);"

TK102's script should respond to 99.9% of the needs. However, depending on what you want to do, this can be another possibility:
If your npc is already equipped with an item that you want to replace definitely (you will loose the old item), try:

void main()
{
object oNPC=GetObjectByTag("npc_name");
object oOldobject = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON,OBJECT_SE LF);
object oNewobject = CreateItemOnObject("my_item_name",OBJECT_SELF);
if (GetIsObjectValid (oOldobject))
{
DestroyObject(oOldobject);
}

AssignCommand(oNPC,ActionEquipItem(oNewobject,INVE NTORY_SLOT_RIGHTWEAPON,TRUE));

}
 jrc24
06-30-2004, 8:06 PM
#5
NOW IT S WORK VERY WELL !!!!!!!!!!!!!!

thank you tk102 and darth333

:D :D :D :D :D :D
Page: 1 of 1