logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Exalt: SetTrapCreator

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
sificvoid



Joined: 01 Dec 2008
Posts: 9

PostPosted: Mon Dec 08, 2008 23:34    Post subject: Exalt: SetTrapCreator Reply with quote

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
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Tue Dec 09, 2008 6:30    Post subject: Reply with quote

You need to use SetTrapCreator on the trap trigger, not on the item.

Acaos
Back to top
View user's profile Send private message
sificvoid



Joined: 01 Dec 2008
Posts: 9

PostPosted: Tue Dec 09, 2008 7:26    Post subject: Reply with quote

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
View user's profile Send private message
Disco



Joined: 06 Dec 2006
Posts: 152

PostPosted: Tue Dec 09, 2008 11:35    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group