I'm working on a new trap for the zombies but I get a problem when I turn on the trap everywhere where the zombies are they gonna die, but not any zombies are in the trigger (I used different: trigger, damage_trigger, radius_trigger) .
the trigger where the zombies most going into it that is the damage trigger.
I hope that any could help me with this?
here is the function about the damage on the zombies when they are in the trigger:
Code Snippet
Plaintext
spike_trap_do( dmg_trig ) { while(1) { zombies = getaiarray("axis"); for(i=0;i<zombies.size;i++) { if(Distance2D(zombies[i].origin, dmg_trig.origin) && self.spike_traps_active > 0) { zombies[i] enable_pain(); //to make a little animation zombies[i] dodamage( 40, zombies[i].origin ); //do the real damage } } wait 0.5; //1 sec } }
I have also tried the
Code Snippet
Plaintext
IsTouching()
but that does not working (because the playble_area trigger)
I have also tried with this: with a radius on script:
UPDATE: at the moment, I get one working but now only the 2 other traps checking if it works
UPDATE: now I get it working but when one trap getting offline and the other are online (working) then the the trap that is offline that does also damage on the zombies
example:
trap1 = offline - does working to but it is disabled trap2 = online - working trap3 = online - working
maybe some one has a idea how I could fix that ?
best regards, Gamer9294
Last Edit: February 01, 2015, 06:17:31 pm by gamer9294
When I do traps I set up a trigger multiple. They have a waittill("trigger",who) that starts the get all the zombies and see who is touching the active area if need be, but it isn't. You can just set up the trigger_multiple to be triggered by anything and then once triggered thread the function that handles damaging the thing that triggered it. Like this:
Code Snippet
Plaintext
SpikeTrap(){ traps = getentarray("spike_trap", "targetname");//targetname of trigger_use to start trap would be spike_trap for(i=0;i<traps.size;i++){ traps UseTriggerRequireLookAt(); traps setCursorHint("HINT_NOICON"); traps setHintString("Engage Trap!"); traps thread WaitForOn(); } } WaitForOn(){ cost = 1250; while(1){ for(;;wait(.1)){ self waittill("trigger",player); if( player.score >= cost ){ if(cost>0){ player maps\_zombiemode_score::minus_to_player_score( cost ); play_sound_at_pos( "cha_ching", player.origin ); } break; }else{ play_sound_at_pos( "no_cha_ching", player.origin ); } } damageTrig = getent(self.target,"targetname");//target of trig to start trap would be targetname of trigger_multiple damageTrig thread HurtThem(); } } HurtThem(){ self endon("times_up"); self thread Timer(60); while(1){ self waittill("trigger", who); if(isplayer(who)){ if(who.health > 41){ who dodamage( 40, who.origin ); }else{ if(!who maps\_laststand::player_is_in_laststand()){ radiusdamage(who.origin,40,who.health + 100,who.health + 100); } } }else{ who dodamage( 40, zombies[i].origin ); } }
I haven't tested this, I just kind of threw it together, but it should work for any trap where you want to hurt something that touches a certain area.
Your issue with your script could have had to do with this:
Code Snippet
Plaintext
Distance2D(zombies[i].origin, dmg_trig.origin)
You were not comparing that to anything, then you did, but to self? So you would want to:
Code Snippet
Plaintext
spike_trap_do( dmg_trig ) { while(1) { zombies = getaiarray("axis"); for(i=0;i<zombies.size;i++) { if(Distance2D(zombies[i].origin, dmg_trig.origin) < 200 && level.spike_traps_active > 0) //add distance traps reach and check a level variable? { zombies[i] enable_pain(); //to make a little animation zombies[i] dodamage( 40, zombies[i].origin ); //do the real damage } } wait 0.5; //1 sec //no way to stop? } }
And I don't know what self.spike_traps_active is, do you mean level.spike_traps_active? The script you made will hurt zombies that are near the dmg_trig you pass to that function and I don't see how it ever ends.
When I do traps I set up a trigger multiple. They have a waittill("trigger",who) that starts the get all the zombies and see who is touching the active area if need be, but it isn't. You can just set up the trigger_multiple to be triggered by anything and then once triggered thread the function that handles damaging the thing that triggered it. Like this:
Code Snippet
Plaintext
SpikeTrap(){ traps = getentarray("spike_trap", "targetname");//targetname of trigger_use to start trap would be spike_trap for(i=0;i<traps.size;i++){ traps UseTriggerRequireLookAt(); traps setCursorHint("HINT_NOICON"); traps setHintString("Engage Trap!"); traps thread WaitForOn(); } } WaitForOn(){ cost = 1250; while(1){ for(;;wait(.1)){ self waittill("trigger",player); if( player.score >= cost ){ if(cost>0){ player maps\_zombiemode_score::minus_to_player_score( cost ); play_sound_at_pos( "cha_ching", player.origin ); } break; }else{ play_sound_at_pos( "no_cha_ching", player.origin ); } } damageTrig = getent(self.target,"targetname");//target of trig to start trap would be targetname of trigger_multiple damageTrig thread HurtThem(); } } HurtThem(){ self endon("times_up"); self thread Timer(60); while(1){ self waittill("trigger", who); if(isplayer(who)){ if(who.health > 41){ who dodamage( 40, who.origin ); }else{ if(!who maps\_laststand::player_is_in_laststand()){ radiusdamage(who.origin,40,who.health + 100,who.health + 100); } } }else{ who dodamage( 40, zombies[i].origin ); } }
I haven't tested this, I just kind of threw it together, but it should work for any trap where you want to hurt something that touches a certain area.
Your issue with your script could have had to do with this:
Code Snippet
Plaintext
Distance2D(zombies[i].origin, dmg_trig.origin)
You were not comparing that to anything, then you did, but to self? So you would want to:
Code Snippet
Plaintext
spike_trap_do( dmg_trig ) { while(1) { zombies = getaiarray("axis"); for(i=0;i<zombies.size;i++) { if(Distance2D(zombies[i].origin, dmg_trig.origin) < 200 && level.spike_traps_active > 0) //add distance traps reach and check a level variable? { zombies[i] enable_pain(); //to make a little animation zombies[i] dodamage( 40, zombies[i].origin ); //do the real damage } } wait 0.5; //1 sec //no way to stop? } }
And I don't know what self.spike_traps_active is, do you mean level.spike_traps_active? The script you made will hurt zombies that are near the dmg_trig you pass to that function and I don't see how it ever ends.
Thank you for reply back on the topic
yes my first time to create a script was with using the "notify" and the "endon" function but then I get it not good working because multiple traps.
I used the self.spiketraps_active because I use more then one trap and maybe count it for own trap.
but not
but I have now the script edited and changes some stuff that also want but I will send you a PM about the script.