|
hmmm triggeractions okeeee
1. we start with a short description
Triggeraction is used to use code in another Players weapon or an NPC when it's at the position u trigger at... it's normally easier to use then callnpc or callweapon and pretty nice for interactions between players
2. example:
the player has a weapon with following code in it:
if(actionspin){
freezeplayer 1;
setani spin,;
}
there is an NPC in the level with following ode in it:
if(playerenters){
triggeraction playerx+1.5,playery+2,spin,;
}
what it does:
when the player enters the level and he has a weapon with the first code in it, the player will do a spin move
how?:
oke when the player enters there is a triggeration with the name "spin" on the playerx and playery (there are 1.5 and 2 added because this will be the middle of the player and the triggeraction will work better)
there are no parameters with it thats why there is nothing behind the last ,
so if the weapon gets an action with the name
spin (there is alwas the word action before the command so gscript knows that is something it has to do when there is an triggeraction) the player will do this spin-move
now another example like the copnet on NM
there is a weapon for 2 players both must have these weapon if the script should work
the script:
if(playertouchsme){
toweapons Net;
}
//The part while using the weapon
if(weaponfired){
setani jaxe,;
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,catch,;
}
//if u are catched
if(actioncatch){
setani dead,;
freezeplayer 3;
}
so what it does:
when u fire the weapon it will set the players ani to jaxe then trigger in front of the player (at this place u don't need to know how to use vecx and vecy here u just have to know that the x and y of the triggeraction are in front of the player).
The triggername is catch...
if there is another player in front of the one using the net-weapon his weapon will get the name of the triggeraction so he is "triggered"... so the part
if(actioncatch){
setani dead,;
freezeplayer 3;
}
will be run...
his ani is set to dead and he can't move for 3 seconds....
now something like the hat-giving-NPC
both players have a weapon like this:
the first player wears a hat with the name "hat1.png"
codepart:
if(playertouchsme){
toweapons Gievhat;
}
//Giving the hat
if(weaponfired){
setani jaxe,;
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,givehat,#P(1);
}
//Getting the hat
if(actiongivehat){
setplayerprop #P(1),#p(0);
}
what happens:
if the first player wears a hat and uses the weapon in front of another player this other player will wear the hat too.
how?:
when the player fires his hatgiving weapon it will trigger in front of this player with the with the name "givehat" and the parameter #P(1) (Hat of the player)
if there is another player in front of the player using the weapon he is triggered with the triggeractionname givehat
then the code in if(actiongivehat){ runs.
and the player gets the hat...
setplayerprop #P(1),#p(0);
so how to use parameters
if u trigger a player u can giveout paramters with the triggeraction:
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,givehat,#P(1);
here it is #P(1) thats the hat of the player
these action can be read with
#p(number)
for the first paramter the number is 0 for the 2. one its 1 for the 3. its 2 etc.
so u can give many things to the triggered player...
for example:
if(playertouchsme){
toweapons Gievhat;
}
//Giving the hat
if(weaponfired){
setani jaxe,;
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,givehat,#P(1),#n;
}
//Getting the hat
if(actiongivehat){
setplayerprop #P(1),#p(0);
setplayerprop #c,Thanx for the hat #p(1);
}
here the triggered player will get the hat of the first player then he will say
Thanx for the hat <here the nickname of the hat giver>
so triggeraction is usefull for interactions...
I hope this helped... |