View previous topic :: View next topic |
Author |
Message |
sificvoid
Joined: 01 Dec 2008 Posts: 9
|
Posted: Mon Dec 08, 2008 23:34 Post subject: Exalt: SetTrapCreator |
|
|
Our server has a bounty system with kill shouts and such, but we have always had a problem getting traps to identify the killer properly. I came across this function, SetTrapCreator, in exalt, but I think I might not be using it correctly. I used the events plugin to hook this function to the Use Item Event. Here's what I came up with there:
Code: |
case EVENT_USE_ITEM:
{
oPC = OBJECT_SELF;
oTarget = GetActionTarget();
oItem = GetEventItem();
string sItem = GetTag ( oItem );
if (GetBaseItemType(oItem) == BASE_ITEM_TRAPKIT) {
SetTrapCreator(oItem, oPC);
FloatingTextStringOnCreature("Your trap has been set!", oPC); // test string
}
break;
} |
And then to retrieve the trap creator, I have placed this in our OnDeath module event script:
Code: |
object oKillerObject = GetLastHostileActor(oDead); // not might be a PC, ie traps, summons, familiars, etc.
object oKiller = oKillerObject; // temporary; will be set as PC later
if (GetBaseItemType(oKiller) == BASE_ITEM_TRAPKIT) {
oKiller = GetTrapCreator(oKiller);
} else {
while(GetIsObjectValid(GetMaster(oKiller))) { // get the highest master
oKiller = GetMaster(oKiller);
}
} |
I tested this out with a few players and it's still failing to reward points to the killer. It does, however, report the player if a familiar makes a kill. I've omitted parts of the above samples so that just what is relevant is included.
Any advice would be helpful, thanks. |
|
Back to top |
|
|
acaos
Joined: 08 May 2007 Posts: 153
|
Posted: Tue Dec 09, 2008 6:30 Post subject: |
|
|
You need to use SetTrapCreator on the trap trigger, not on the item.
Acaos |
|
Back to top |
|
|
sificvoid
Joined: 01 Dec 2008 Posts: 9
|
Posted: Tue Dec 09, 2008 7:26 Post subject: |
|
|
So would the above work if I were to use SetTrapCreator(oTarget, oPC); ?
Since oTarget would be the trigger for the trap after you set it up? |
|
Back to top |
|
|
Disco
Joined: 06 Dec 2006 Posts: 152
|
Posted: Tue Dec 09, 2008 11:35 Post subject: |
|
|
Working with traps is a pain. You can't do a lot with the trigger as it disappears before you can read any variables from it in the death/damage scripts. GetCreator is flaky on a PW because traps often persist longer than their creator. You have two options, afaik:
1. Spawn a waypoint with the trap, and load you data on that. You can reach that by using GetNearestObject. Drawback: fails when tehre are many traps laid by many people in a small area.
2. Add functionality to all the trap scripts. Drawback: there's quite a few of them, but with an include you can keep updating issues to a minimum. |
|
Back to top |
|
|
|