GetLastKiller and Monks

Moderator: Event DM

Post Reply
User avatar
Deider
Demigod of Posts
Posts: 13259
Joined: Sun May 11, 2003 12:33 pm
Timezone: GMT -8
Location: California

GetLastKiller and Monks

Post by 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
Themicles
CoPaP Ambassador
Posts: 2673
Joined: Wed Jan 29, 2003 10:45 pm
Location: Wolverine Lake, MI
Contact:

Post by 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. :)
dougnoel
Team Member; Retired with Honors
Posts: 6261
Joined: Fri May 14, 2004 4:59 pm
Location: VA (GMT -4)
Contact:

Post by dougnoel » Thu Dec 22, 2005 6:02 pm

I wonder if PCs have a slam attack. If they do, that might get returned...
User avatar
Aloro
Team Member; Retired with Honors
Posts: 12805
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End
Contact:

Post by 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
IAkrai
Team Member; Retired with Honors
Posts: 487
Joined: Tue Aug 17, 2004 3:05 pm
Location: Israel
Contact:

Post by 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
Themicles
CoPaP Ambassador
Posts: 2673
Joined: Wed Jan 29, 2003 10:45 pm
Location: Wolverine Lake, MI
Contact:

Post by 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
frogmella
Apprentice Scholar
Posts: 816
Joined: Wed Sep 18, 2002 12:35 pm
Location: London, UK -- GMT

Post by 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
Deider
Demigod of Posts
Posts: 13259
Joined: Sun May 11, 2003 12:33 pm
Timezone: GMT -8
Location: California

Post by 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
Themicles
CoPaP Ambassador
Posts: 2673
Joined: Wed Jan 29, 2003 10:45 pm
Location: Wolverine Lake, MI
Contact:

Post by 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
Beary666
Elder Sage
Posts: 3400
Joined: Fri Dec 27, 2002 1:29 am
Timezone: GMT -8

Post by Beary666 » Fri Dec 23, 2005 4:58 am

Make said NPC immune to all spells...... <.< >.>....
dougnoel
Team Member; Retired with Honors
Posts: 6261
Joined: Fri May 14, 2004 4:59 pm
Location: VA (GMT -4)
Contact:

Post by 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.
User avatar
Deider
Demigod of Posts
Posts: 13259
Joined: Sun May 11, 2003 12:33 pm
Timezone: GMT -8
Location: California

Post by 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
Post Reply