UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

need help with a little scripting

broken avatar :(
Created 11 years ago
by gamer9294
0 Members and 1 Guest are viewing this topic.
1,703 views
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 22 September 2013
Last active: 6 months ago
Posts
326
Respect
Forum Rank
Perk Hacker
Primary Group
Mapper
My Groups
More
Personal Quote
Zombie Mapper and Gamer
Signature
My Custom Zombie Maps:

- Nazi zombie Legion
- City of Hell
- The Abandoned Mine
- The Last Undead House (Finished)

more custom zombie maps coming soon
×
gamer9294's Groups
Mapper Has released one or more maps to the UGX-Mods community.
gamer9294's Contact & Social Links
hello guys,

I have a question ?


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:

Code Snippet
Plaintext
if((Distance2D(zombies[i].origin, dmg_trig.origin) < self.spike_dmg_radius) && self.spike_traps_active > 0) 
{


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
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
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 );
}
}

}
Timer(timer){
timer = int(timer);
while(timer>0){
timer = timer - 1;
wait(1);
}
self notify("times_up");
}

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.
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 22 September 2013
Last active: 6 months ago
Posts
326
Respect
Forum Rank
Perk Hacker
Primary Group
Mapper
My Groups
More
Personal Quote
Zombie Mapper and Gamer
×
gamer9294's Groups
Mapper Has released one or more maps to the UGX-Mods community.
gamer9294's Contact & Social Links
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 );
}
}

}
Timer(timer){
timer = int(timer);
while(timer>0){
timer = timer - 1;
wait(1);
}
self notify("times_up");
}

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.



best regards,
Gamer9294

 
Loading ...