Page 1 of 1
GetLastKiller and Monks
Posted: Thu Dec 22, 2005 4:45 pm
by Deider
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

Posted: Thu Dec 22, 2005 5:53 pm
by Themicles
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.
}
Posted: Thu Dec 22, 2005 6:02 pm
by dougnoel
I wonder if PCs have a slam attack. If they do, that might get returned...
Posted: Thu Dec 22, 2005 6:12 pm
by Aloro
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
Posted: Thu Dec 22, 2005 6:50 pm
by IAkrai
To check for gloves, you can do:
Code: Select all
object oObject = GetItemInSlot(INVENTORY_SLOT_ARMS, oTarget);
if (GetBaseItemType(oObject) == BASE_ITEM_GLOVES)
Posted: Thu Dec 22, 2005 7:21 pm
by Themicles
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.

Posted: Thu Dec 22, 2005 10:40 pm
by frogmella
You know all this type of coding could go to make a pretty good detective character.
Just a thought!
Posted: Fri Dec 23, 2005 4:25 am
by Deider
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.
Posted: Fri Dec 23, 2005 4:50 am
by Themicles
Ignore spell casting classes, and say forget the multi-classers?
Seriously though... I'm not sure. I'll think about it.
Posted: Fri Dec 23, 2005 4:58 am
by Beary666
Make said NPC immune to all spells...... <.< >.>....
Posted: Fri Dec 23, 2005 4:17 pm
by dougnoel
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.
Posted: Fri Dec 23, 2005 6:18 pm
by Deider
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
Seriously, thanks for all the help folks - I think I have my answer
