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

Spawning a trigger radius.

HOT
broken avatar :(
Created 12 years ago
by Ege115
0 Members and 1 Guest are viewing this topic.
11,986 views
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Are there any console command that makes so you can see the invisible trigger_radius ingame?

I need it because I made a function were you throw a grenade, and then I spawn a trigger_radius in the origin of the grenade. And then I used this,
Code Snippet
Plaintext
zombs = getaispeciesarray("axis","all");

for(k=0;k<zombs.size;k++)
{
center = spawn("trigger_radius",grenade.origin,1,200,200);
if(DistanceSquared(zombs[k].origin, center.origin, "trigger_radius") < 50 * 50)
                 }
To check if the zombies are touching the trigger_radius, I don't know if this is what you need to check if the zombies are touching it. But yea, this is what I am using.
And then the function continues on what will happen to the zombies if they are touching the trigger_radius, bla bla bla.

However, when I throw the grenade and spawn the radius, it seems like the zombies are not touching the trigger because I can throw the grenade far away, and the zombies still get effected even if they are outside the trigger.

So this is why I am wondering if there is a console command I can type that makes so I can see the trigger_radius. In that way I can properly see if the zombies are touching the trigger_radius.

Or am I using the wrong method to check if the zombies are touching the trigger?

Thanks in advance.
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
If the trigger radius spawns correctly, you could use this to check if the zombs are touching it

Code Snippet
Plaintext
	if( zombs[k] IsTouching( center ) )
        {
        code here
        }

---edit---

btw if you do the code like this, you're spawning a trigger for every zombie.. Keep the spawn out of the loop i guess

Code Snippet
Plaintext
zombs = getaispeciesarray("axis","all");

center = spawn("trigger_radius",grenade.origin,1,200,200);
for(k=0;k<zombs.size;k++)
{
                if( zombs[k] IsTouching( center ) )
                       {
                       code here
                       }
                }
Last Edit: April 19, 2014, 12:21:56 pm by BluntStuffy
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
If the trigger radius spawns correctly, you could use this to check if the zombs are touching it

Code Snippet
Plaintext
	if( zombs[k] IsTouching( center ) )
        {
        code here
        }

---edit---

btw if you do the code like this, you're spawning a trigger for every zombie.. Keep the spawn out of the loop i guess

Code Snippet
Plaintext
zombs = getaispeciesarray("axis","all");

center = spawn("trigger_radius",grenade.origin,1,200,200);
for(k=0;k<zombs.size;k++)
{
                if( zombs[k] IsTouching( center ) )
                       {
                       code here
                       }
                }
Wasn't it impossible to call istouching on an array?

Edit: Do I also have to link the center virable to the grenade so the trigger radius is following the grenade when it spawns?
Last Edit: April 19, 2014, 12:33:48 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
Yes it's not working on an array, but it's not being called on an array.
The array is 'zombs' but  'zombs[k]' is an entity in that array so that should work fine..

You can also use the distancequared() but there's not really a reason to spawn a trigger then i think..

I dont think you can link a trigger radius, not sure..
Last Edit: April 19, 2014, 12:44:08 pm by BluntStuffy
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
I dont think you can link a trigger radius, not sure..
You can.

- Phil.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Don't I also have to make so it checks if the zombie is touching the trigger of the entity like this?
Code Snippet
Plaintext
if (zombs[k] istouching(center, "trigger_radius"))
You know so the script is more specific on what exactly it should touch in the entity?

Also, was there are console command that made so I can see the radius or not?
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Don't I also have to make so it checks if the zombie is touching the trigger of the entity like this?
Code Snippet
Plaintext
if (zombs[k] istouching(center, "trigger_radius"))
You know so the script is more specific on what exactly it should touch in the entity?
No, your code won't even run. It works the way BluntStuffy posted...

Also, was there are console command that made so I can see the radius or not?
Haven't seen a console command for that.

- Phil.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I am back.

Well, I tested to add istouching, instead of distancesquered()
I did the way Bluntstuffy did, but the zombies still get the effects even if they are not touching the trigger_radius.
This is getting as wierd as when I tried to play fx's.
Last Edit: April 19, 2014, 09:25:51 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
I am back.

Well, I tested to add istouching, instead of distancesquered()
I did the way Bluntstuffy did, but the zombies still get the effects even if they are not touching the trigger_radius.
This is getting as wierd as when I tried to play fx's.

I don't know how you set up the rest of your code, but you could try checking if 'grenade.origin' actually returns a valid value by making it print on the screen with an iprintln()
If that doesn't happen, the trigger prob won't spawn (correctly)
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I can show what I did in the rest of the code.

Code Snippet
Plaintext
zombs = getaispeciesarray("axis","all");

center = spawn("trigger_radius",grenade.origin,1,200,200);
for(k=0;k<zombs.size;k++)
{
                if( zombs[k] IsTouching( center ) )
                       {
                 
                        //wait( 0.1 + RandomFloat( 0.4 ) );
zombs[k].shock = false;
//old_origin = zombs[k].origin;
rand = randomint(3);
shock = level._zombie_tesla_death["zombie"][3];
zombs[k] animscripted("zombie_tesla_death",zombs[k].origin, zombs[k].angles, shock);
zombs[k].shock = true;
wait(getanimlength(shock));
zombs[k].shock = false;
//playfxontag(level._effect["elec_eye_fx"], zombs[k], "j_spine4");
//playfxontag(level._effect["shock_fx"], zombs[k], "j_spine4");
zombs[k] DoDamage( zombs[k].health + 666, zombs[k].origin );
                        }
}
Last Edit: April 19, 2014, 10:06:33 pm by Ege115
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
ok, but that still doesn't tell me how you got the 'grenade.origin' value?
That's somewhere in the code above i assume?

Try adding this line under the 'zombs = getaispec.....' line and see if the print show up and what it says.

Code Snippet
Plaintext
iprintln( " ["+ grenade.origin +"] " );
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
ok, but that still doesn't tell me how you got the 'grenade.origin' value?
That's somewhere in the code above i assume?

Try adding this line under the 'zombs = getaispec.....' line and see if the print show up and what it says.

Code Snippet
Plaintext
iprintln( " ["+ grenade.origin +"] " );

Yes, the grenade is defined above this code. But the Iprintin didn't show up ingame when I throw the grenade. Hmm, what would it say?
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
it should display the origin, so there's prob no value stored in that variable.. (i guess)

In general: you want to set it up like this i think, otherwise the second zombie won't be affected until the for loop for the first zombie has ended. That's just a side comment, try changing the print to this i'm not 100% sure if the iprintln() works like shown before (think it does). If still no print shows up for the grenade origin, but the tekst "special grenade test" is being printed, something is prob wrong with the grenade.origin value..

Code Snippet
Plaintext
zombs = getaispeciesarray("axis","all");

center = spawn("trigger_radius",grenade.origin,1,200,200);

print1 = grenade.origin;
iprintln( "Special grenade test" );
iprintln( "Grenade origin: ["+ print1 +"] " );

for(k=0;k<zombs.size;k++)
{
if( zombs[k] IsTouching( center ) )
{
zombs[k] thread nade_effect();
}
wait 0.05;
}

nade_effect()
{
//wait( 0.1 + RandomFloat( 0.4 ) );
self.shock = false;
//old_origin = self.origin;
rand = randomint(3);
shock = level._zombie_tesla_death["zombie"][3];
self animscripted("zombie_tesla_death",self.origin, self.angles, shock);
self.shock = true;
wait(getanimlength(shock));
self.shock = false;
//playfxontag(level._effect["elec_eye_fx"], self, "j_spine4");
//playfxontag(level._effect["shock_fx"], self, "j_spine4");
self DoDamage( self.health + 666, self.origin );
}
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I tried it out, and it only printed out "special grenade test" But not the other.

BUT, I tried an another thing. I added a 4 lines that looked like this,
Code Snippet
Plaintext
forward = player geteye(); 
vec = anglestoforward(player getPlayerAngles());
end = (vec[0] * 100000000, vec[1] * 100000000, vec[2] * 100000000);
hammertrace = BulletTrace( forward, end, 0, player )[ "position" ];
And this makes the radius to spawn where you throw the grenade, and I noticed that because I spawned a script_model and set the model to a tag origin and played a fx, and with those three lines, it made the fx to play at the place you threw the grenade. In this way, I don't need to link the radius to the grenade.

So I spawned a trigger radius in this way as well to see what happens. Now the zombies didn't get the effects at all even if they are touching or not touching the trigger.

But I did do what you said but not with the grenade, I printed the line that says "hammertrace" Because this is were the radius will spawn. And this is what showed up ingame.

Marked as best answer by Ege115 12 years ago
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 2 years ago
Posts
1,186
Respect
1,332Add +1
Forum Rank
Zombie Colossus
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntStuffyBluntstuffy@BluntZombieStuffyZombie
Well, now at least you know there's something stored in that variable. So the trigger should spawn at that position.
Maybe it's the code after that. Try adding another iprintln() somewhere to tell you if the code is being executed, and maybe for a test just change the whole effect function to only do damage for now. So maybe something like this:

Code Snippet
Plaintext
zombs = getaispeciesarray("axis","all");

center = spawn("trigger_radius",grenade.origin,1,200,200);

print1 = grenade.origin;
iprintln( "Special grenade test" );
iprintln( "Grenade origin: ["+ print1 +"] " );

for(k=0;k<zombs.size;k++)
{
if( zombs[k] IsTouching( center ) )
{
iprintln( "zomb in radius" );
zombs[k] thread nade_effect();
}
wait 0.05;
}

nade_effect()
{
//wait( 0.1 + RandomFloat( 0.4 ) );
// self.shock = false;
//old_origin = self.origin;
// rand = randomint(3);
// shock = level._zombie_tesla_death["zombie"][3];
// self animscripted("zombie_tesla_death",self.origin, self.angles, shock);
// self.shock = true;
// wait(getanimlength(shock));
// self.shock = false;
//playfxontag(level._effect["elec_eye_fx"], self, "j_spine4");
//playfxontag(level._effect["shock_fx"], self, "j_spine4");
iprintln( "Killing zombie.." );
self DoDamage( self.health + 666, self.origin );
}

 
Loading ...