Server Totals
Wilderness - (4)
Mikona - (3)
Visimontium - (1)
Deglos - (1)
Le'Or - (1)
Elysia - (0)
M'Chek - (0)
Ferrell - (0)
Underdark - (0)
Total players: 10
Gallery
  • Helbyssia Final Battle
    Album name: DM Events
    Uploaded by: krackq
    Uploaded: Mon Aug 18, 2014 4:59 am

Links Menu

Equipping items

Moderators: Nighthawk4, Dungeon Masters

Equipping items

PostAuthor: Jeffi0 » Mon Jul 28, 2003 2:38 am

Should be simple. ActionEquipItem(oItem, INVENTORY_SLOT_CHEST);. But it doesn't work for me, for clothes, helmets, anything. I must be missing something really simple here, but I can't figure it out- I have the object, why won't it equip? I'll go try using AssignCommand(OBJECT_SELF, ActionEquipItem), I havent tried that yet, not that I have much hope...
User avatar
Jeffi0
Apprentice Scholar
 
Posts: 567
Joined: Fri Apr 04, 2003 12:57 am

PostAuthor: maxinion » Mon Jul 28, 2003 3:09 pm

Poor Jeff...

Think, man. ActionEquipItem(object oItem, int iSlot); Where does it refer to the creature there? Nowhere. You're just telling air to equip oItem into iSlot. There's no default creature to assign it to, even if you're running it off of some handle attached to the creature. You have to assign this command to the creature, then you might get something. So yeah, go do what you were doing.

:P
User avatar
maxinion
Team Member; Retired with Honors
 
Posts: 2779
Joined: Mon Mar 17, 2003 7:44 pm
Location: Bay Area, CA
DM Avatar: Andrinor

PostAuthor: Jeffi0 » Mon Jul 28, 2003 3:24 pm

I figured it'd automatically be the object that called it- that's what most are. Like ActionAttack, ActionMoveToObject, etc. I thought ActionEquipItem wouldn't be any different. Oh well, thanks. :D
User avatar
Jeffi0
Apprentice Scholar
 
Posts: 567
Joined: Fri Apr 04, 2003 12:57 am

PostAuthor: Jeffi0 » Mon Jul 28, 2003 4:41 pm

Still doesn't work. :(
User avatar
Jeffi0
Apprentice Scholar
 
Posts: 567
Joined: Fri Apr 04, 2003 12:57 am

PostAuthor: Jordicus » Mon Jul 28, 2003 5:04 pm

you sure it should be OBJECT_SELF that is referred to? if an item is firing the script, the OBJECT_SELF refers to the item, not the holder
User avatar
Jordicus
Team Member; Retired with Honors
 
Posts: 8048
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)

PostAuthor: Aloro » Mon Jul 28, 2003 5:27 pm

OK, let's back up a step here... we don't have enough information to answer your questions. ;)

First, when and where is this script fired? Is it e.g. off a trigger, off a conversation, off the OnEnter of an area, or what?

Second, what are you trying to equip, and on whom? Is it a PC or NPC?

- Aloro
User avatar
Aloro
Team Member; Retired with Honors
 
Posts: 12810
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End

PostAuthor: Jeffi0 » Mon Jul 28, 2003 9:30 pm

It's in the OnSpawn of an NPC. It is supposed to equip a random commoner's tunic so that the commoners spawn with different tunics. Getting the tag of the random tunic is simple and works, but it doesn't get equipped. The exact line is EquipItem(oTunic, INVENTORY_SLOT_CHEST);. Chest is the inventory slot right? I think so. Besides, I tried it with head and a helmet and that didnt work either. :(
User avatar
Jeffi0
Apprentice Scholar
 
Posts: 567
Joined: Fri Apr 04, 2003 12:57 am

PostAuthor: Aloro » Mon Jul 28, 2003 9:41 pm

Something like this should work:

Code: Select all
AssignCommand(oNPC, ActionEquipItem(oTunic, INVENTORY_SLOT_CHEST));


Check to make sure that oTunic isn't OBJECT_INVALID (Tag error). Depending on what else you have going on in the OnSpawn, you might also need to send a ClearAllActions() call to the NPC with AssignCommand.

- Aloro
User avatar
Aloro
Team Member; Retired with Honors
 
Posts: 12810
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End

PostAuthor: Jeffi0 » Mon Jul 28, 2003 10:14 pm

Thanks! I'll try that. I dont get why it should need an AssignCommand though, cause its for the NPC thats calling it anyway. Does this happen with other commands? I havent seen this happen befor, but there are a LOT of commands I havent used yet. :)
User avatar
Jeffi0
Apprentice Scholar
 
Posts: 567
Joined: Fri Apr 04, 2003 12:57 am

PostAuthor: Aloro » Mon Jul 28, 2003 10:22 pm

I always manually insert the subject of any script. Sometimes OBJECT_SELF is implicit, and sometimes it isn't. I just make a habit of always specifying, so I'm never susprised by it not working. ;)

- Aloro
User avatar
Aloro
Team Member; Retired with Honors
 
Posts: 12810
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End

PostAuthor: Jeffi0 » Mon Jul 28, 2003 11:31 pm

Still doesn't work. I'll post my exact code here. At least I think it's the exact code, as NWN is tempermental and sometimes doesnt work, such as right now.

int iNum=Random(4)+1;
string sNum=IntToString(iNum);
string sTag="CommonersTunic"+sNum;
object oTunic=GetObjectByTag(sTag);
ClearAllActions();
object oNPC=OBJECT_SELF;
AssignCommand(oNPC, ActionEquipItem(oTunic, INVENTORY_SLOT_CHEST);

I'm fairly sure thats the exact code. Originally, I didnt have the ClearAllActions or AssignCommand, not that it really matters. Can you please tell me whats wrong with it? The only other option is to have blueprints for about twenty commoners of each race, but I'd like to avoid that if possible, especially since I'll probably add in more clothes later on.
User avatar
Jeffi0
Apprentice Scholar
 
Posts: 567
Joined: Fri Apr 04, 2003 12:57 am

PostAuthor: pitched_black » Mon Jul 28, 2003 11:41 pm

You missed a round thing ')' on the end of CHEST. It might of just been a typo in the post because I don't think it would let you compile without that.
The Island(s) of Hala
http://www.hala-world.org

pitched_black
Prince of Bloated Discourse
 
Posts: 186
Joined: Thu Feb 06, 2003 8:49 pm
Location: Nova Scotia (GMT - 4)

PostAuthor: Jeffi0 » Tue Jul 29, 2003 12:03 am

Yeah, that was a typo. Can you see anything else wrong with it?
User avatar
Jeffi0
Apprentice Scholar
 
Posts: 567
Joined: Fri Apr 04, 2003 12:57 am

PostAuthor: Aloro » Tue Jul 29, 2003 12:04 am

OK, I see a few things here I'd suggest changing...

1) You should just use a CreateObject instead of GetObjectByTag. If there exist more than one such tunic in the world, you're most likely telling the commoner to put on a tunic that he doesn't even have in his possession.

2) You need to use the resrefs to create objects. Make SURE you have entered the right ones, because a typo will cause everything to fail - and can crash your computer (ActionEquipItem gets screwy sometimes).

3) Instead of int iNum=Random(4)+1;, why not use d4(1)? Same result.

So I'd suggest something like this:

Code: Select all
void main()
{
    int iNum=d4(1);
    string sNum=IntToString(iNum);
    string sTunicRR="nw_cloth024"; //"commonerstunic"+sNum;
    object oTunic=CreateItemOnObject(sTunicRR, OBJECT_SELF, 1);
    AssignCommand(OBJECT_SELF, ActionEquipItem(oTunic, INVENTORY_SLOT_CHEST));
}


Replace "nw_cloth024" with the resref of your tunics. This script works fine - I just tested it, and it successfully creates the clothing and makes the commoner equip it.

- Aloro
User avatar
Aloro
Team Member; Retired with Honors
 
Posts: 12810
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End

PostAuthor: Jeffi0 » Tue Jul 29, 2003 1:48 am

Thanks Aloro, I'll use that. :)
User avatar
Jeffi0
Apprentice Scholar
 
Posts: 567
Joined: Fri Apr 04, 2003 12:57 am

PostAuthor: Myk D'vor » Tue Jul 29, 2003 2:42 am

Little quibble... Random(4)+1 is not the same as d4()+1. Random(4) generates a number between 0 and 3, then add 1 and it becomes the same as d4(), which generates a number from 1 to 4.

Myk D'Vor

Myk D'vor
Lord of Blithering Idiots
 
Posts: 111
Joined: Mon Feb 24, 2003 9:05 am

PostAuthor: Falkin » Tue Jul 29, 2003 2:47 am

Ummm.... I think they already said that...
"Don't worry, I'll have it all figured out by the time we reach the Frontier..."
"So what's that over there?"
"The Frontier..."
modified from The Last Starfighter

Falkin
Scholar of Fools
 
Posts: 311
Joined: Thu Apr 03, 2003 1:16 pm
Location: Currently, NAS Whidbey Island, Washington State

PostAuthor: Aloro » Tue Jul 29, 2003 4:00 am

Myk D'vor wrote:Little quibble... Random(4)+1 is not the same as d4()+1. Random(4) generates a number between 0 and 3, then add 1 and it becomes the same as d4(), which generates a number from 1 to 4.

Myk D'Vor


Errr... I suggested he replace Random(4)+1 with d4(1), as they are identical in output. ;)

- Aloro
User avatar
Aloro
Team Member; Retired with Honors
 
Posts: 12810
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End

PostAuthor: Falkin » Tue Jul 29, 2003 4:02 am

Yes, those of us with the ability to do simple math without a calculator can see that... as can those of us who also grew up playing PnP, and learning how to use a calculator's random function when dice were in short supply...
"Don't worry, I'll have it all figured out by the time we reach the Frontier..."
"So what's that over there?"
"The Frontier..."
modified from The Last Starfighter

Falkin
Scholar of Fools
 
Posts: 311
Joined: Thu Apr 03, 2003 1:16 pm
Location: Currently, NAS Whidbey Island, Washington State


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Blue Wolfy, Google [Bot]