Server Totals
Wilderness - (2)
Le'Or - (0)
Ferrell - (0)
Elysia - (0)
M'Chek - (0)
Deglos - (0)
Visimontium - (0)
Underdark - (0)
Mikona - (0)
Total players: 2
Gallery

Links Menu

GetLastKiller and Monks

Moderators: Nighthawk4, Dungeon Masters

GetLastKiller and Monks

PostAuthor: Deider » Thu Dec 22, 2005 4:45 pm

Okay, I can use GetLastKiller and GetLastWeaponUsed to find out what weapon a PC used to kill an NPC.

But what about in the case of monks? Will GetLastWeaponUsed return the monk's gloves if he is wearing any? Or will it return OBJECT_INVALID?

I'm looking for a way to determine if a PC killed an NPC with his fists, and if he did, to see what gloves he was wearing, if any. Anybody know how to do this? Thanks :D
User avatar
Deider
Uber Posting Whor3
 
Posts: 8014
Images: 3
Joined: Sun May 11, 2003 12:33 pm
Location: California
Timezone: GMT -8

PostAuthor: Themicles » Thu Dec 22, 2005 5:53 pm

If GetLastWeaponUsed returns OBJECT_INVALID, get inventory slot item gloves. My code below wont be exact, as I don't know how you are getting/recording who oKiller is. So I'm assuming oKiller is already defined. Potential problem: Gloves and bracers both go in INVENTORY_SLOT_ARMS. Filter by base item type?

This code filters by base item type, if you need to differentiate between bracers and gloves.
Code: Select all
object oWeapon = GetLastWeaponUsed(oKiller);

if(!GetIsObjectValid(oWeapon))
{
    //Object was, indeed, invalid. Check for gloves.
    object oGloves = GetItemInSlot(INVENTORY_SLOT_ARMS, oKiller);
    if(!GetIsObjectValid(oGloves))
    {
        //oKiller used bare hands, no gloves.
    }
    else
    {
        //oKiller was wearing gloves or bracers
        if(GetBaseItemType(oGloves) == BASE_ITEM_BRACER)
        {
            //Item was a set of bracers, not gloves. Run whatever code here.
        }
        else
        {
            //string sGloveID = X;
            //Replace X above with either GetTag(oGloves) or some other
            //function to get the desired identifier from the glvoes and then
            //uncomment that line.
        }
    }   
}
else
{
    //Object was a weapon. Run whatever code here.
}


This code does not differentiate between gloves and bracers.
Code: Select all
object oWeapon = GetLastWeaponUsed(oKiller);

if(!GetIsObjectValid(oWeapon))
{
    //Object was, indeed, invalid. Check for gloves.
    object oGloves = GetItemInSlot(INVENTORY_SLOT_ARMS, oKiller);
    if(!GetIsObjectValid(oGloves))
    {
        //oKiller used bare hands, no gloves.
    }
    else
    {
        //oKiller was wearing gloves or bracers

        //string sGloveID = X;
        //Replace X above with either GetTag(oGloves) or some other
        //function to get the desired identifier from the glvoes and then
        //uncomment that line.
    }   
}
else
{
    //Object was a weapon. Run whatever code here.
}
A wise man does not dwell on his past. He learns from it, he grows from it, and then moves ahead into his future.

And some wise words from a wise man. :P
Orleron wrote:You have to excuse Themi. Tact, diplomacy, and softness are not his best traits, but he does not mean anything by his writing. He's a nice guy. You just get used to it after a while because he doesn't seem to learn. :)
User avatar
Themicles
CoPaP Ambassador
 
Posts: 2677
Joined: Wed Jan 29, 2003 10:45 pm
Location: Wolverine Lake, MI

PostAuthor: dougnoel » Thu Dec 22, 2005 6:02 pm

I wonder if PCs have a slam attack. If they do, that might get returned...

dougnoel
Team Member; Retired with Honors
 
Posts: 6265
Joined: Fri May 14, 2004 4:59 pm
Location: VA (GMT -4)

PostAuthor: Aloro » Thu Dec 22, 2005 6:12 pm

Themicles wrote:If GetLastWeaponUsed returns OBJECT_INVALID, get inventory slot item gloves.


Won't GetLastWeaponUsed return OBJECT_INVALID if a spell was used, too?

- Aloro
Aleksandr Solzhenitsyn wrote:The meaning of earthly existence lies, not as we have grown used to thinking, in prosperity, but in the development of the soul.
User avatar
Aloro
Team Member; Retired with Honors
 
Posts: 12810
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End

PostAuthor: IAkrai » Thu Dec 22, 2005 6:50 pm

To check for gloves, you can do:
Code: Select all
object oObject = GetItemInSlot(INVENTORY_SLOT_ARMS, oTarget);
if (GetBaseItemType(oObject) == BASE_ITEM_GLOVES)
 
User avatar
IAkrai
Team Member; Retired with Honors
 
Posts: 487
Joined: Tue Aug 17, 2004 3:05 pm
Location: Israel

PostAuthor: Themicles » Thu Dec 22, 2005 7:21 pm

IAkrai wrote:To check for gloves, you can do:
Code: Select all
object oObject = GetItemInSlot(INVENTORY_SLOT_ARMS, oTarget);
if (GetBaseItemType(oObject) == BASE_ITEM_GLOVES)
 


Yes, but my code above does the same thing, because the only two possible items in slot Arms are Gloves and Bracers.
My code checks for bracers, and if not, the only other thing it could be is gloves. I was always taught to check for the negative before the positive, unless there were multiple possible positives. ;)
A wise man does not dwell on his past. He learns from it, he grows from it, and then moves ahead into his future.

And some wise words from a wise man. :P
Orleron wrote:You have to excuse Themi. Tact, diplomacy, and softness are not his best traits, but he does not mean anything by his writing. He's a nice guy. You just get used to it after a while because he doesn't seem to learn. :)
User avatar
Themicles
CoPaP Ambassador
 
Posts: 2677
Joined: Wed Jan 29, 2003 10:45 pm
Location: Wolverine Lake, MI

PostAuthor: frogmella » Thu Dec 22, 2005 10:40 pm

You know all this type of coding could go to make a pretty good detective character.

Just a thought!
= = = =
"In all my experience I have never been in any accident. I never saw a wreck and have never been wrecked nor was I in any predicament that threatened to end in disaster of any sort."
~ EJ Smith, Captain of the Titanic.
User avatar
frogmella
Apprentice Scholar
 
Posts: 818
Joined: Wed Sep 18, 2002 12:35 pm
Location: London, UK -- GMT

PostAuthor: Deider » Fri Dec 23, 2005 4:25 am

Aloro wrote:
Themicles wrote:If GetLastWeaponUsed returns OBJECT_INVALID, get inventory slot item gloves.


Won't GetLastWeaponUsed return OBJECT_INVALID if a spell was used, too?

- Aloro


This is also my main concern.
User avatar
Deider
Uber Posting Whor3
 
Posts: 8014
Images: 3
Joined: Sun May 11, 2003 12:33 pm
Location: California
Timezone: GMT -8

PostAuthor: Themicles » Fri Dec 23, 2005 4:50 am

Ignore spell casting classes, and say forget the multi-classers? :twisted:

Seriously though... I'm not sure. I'll think about it.
A wise man does not dwell on his past. He learns from it, he grows from it, and then moves ahead into his future.

And some wise words from a wise man. :P
Orleron wrote:You have to excuse Themi. Tact, diplomacy, and softness are not his best traits, but he does not mean anything by his writing. He's a nice guy. You just get used to it after a while because he doesn't seem to learn. :)
User avatar
Themicles
CoPaP Ambassador
 
Posts: 2677
Joined: Wed Jan 29, 2003 10:45 pm
Location: Wolverine Lake, MI

PostAuthor: Beary666 » Fri Dec 23, 2005 4:58 am

Make said NPC immune to all spells...... <.< >.>....
User avatar
Beary666
Elder Sage
 
Posts: 3265
Joined: Fri Dec 27, 2002 1:29 am
Location: Edmonton, Alberta , Canada
Timezone: GMT -7

PostAuthor: dougnoel » Fri Dec 23, 2005 4:17 pm

Create an NPC in the toolset. Give it the combat dummy model, make it's speed 0, and give it 40 levels of fighter, then pump up it's hit points. In the OnHit script, write a custom script that does a SendToAllPlayers() the value of Get Last Attacker and GetLastWeapon used.

Thi will answer all your questions.

To get the last spell cast at you is a different function, but I'm not sure how the two interact.

dougnoel
Team Member; Retired with Honors
 
Posts: 6265
Joined: Fri May 14, 2004 4:59 pm
Location: VA (GMT -4)

PostAuthor: Deider » Fri Dec 23, 2005 6:18 pm

dougnoel wrote:Create an NPC in the toolset. Give it the combat dummy model, make it's speed 0, and give it 40 levels of fighter, then pump up it's hit points. In the OnHit script, write a custom script that does a SendToAllPlayers() the value of Get Last Attacker and GetLastWeapon used.


If I weren't too lazy to do all that, I wouldn't have asked here :wink:

Seriously, thanks for all the help folks - I think I have my answer :D
User avatar
Deider
Uber Posting Whor3
 
Posts: 8014
Images: 3
Joined: Sun May 11, 2003 12:33 pm
Location: California
Timezone: GMT -8


Return to NWN Scripting

Who is online

Registered users: Bing [Bot]