Jump to content
Sign in to follow this  
wickedstigma

Triggers and Unit Detection

Recommended Posts

Hi! Im trying to make a trigger the detects the unit name of any unit inside the trigger are, so I can setDamage to that unit if he stays inside that area for x time elapsed where x is a random number between 1 seconds and 10 seconds. I have managed to set damage to a specific unit but not to anyone who enters the trigger area. I also tried making different triggers in the same area but only one works and the others don't. And it doesn't matter what values set in the Min Mid Max boxes they die instantly when the place a foot inside the trigger area... Thanks for all the help in advance!

Share this post


Link to post
Share on other sites

To damage anyone in the trigger area, set the following in the On Activation field:

{_x setDamage X} forEach thisList; where X is how much damage you want to do. thisList is an arraying containing all (by trigger setting eligible to activate?) units in the trigger area.

I don't really know why the timeout doesn't work though. Tried setting Min=1, Mid=5.5 and Max=10, and the timer method to Timeout?

Share this post


Link to post
Share on other sites

If setting a timeout / countdown on the trigger doesn't work, you could try making a small script that handled the damage.

Put this in the Activation field of the trigger:

[this] execVM "damage.sqf";

Next, we'll create a small script that'll handle the damage.

Let's call it damage.sqf, and put the following code in:

While {(player in thisList)} do {
sleep (1 + random(9));
{_x setDamage 1} forEach thisList;
};

Now, when the trigger is activated, it will execute the script 'damage.sqf'. 'damage.sqf' contains a loop which will run ~100 times per second. What it'll do is what it says on the tin.

  1. While the Player is inside the trigger, do:
  2. Wait for 1 second (plus a random of addition of up to 9 seconds)
  3. Kill all players still in the list

Because the script is in a loop, if the condition of the loop is ever broken, it will end the loop and immediately go to the end. This means that if the player moves away from the trigger, the loop will stop running and therefore NOT kill the player.

Should work anyway. Not tested because I am lazy.

:yay::torture:

Edited by Fuzzy Bandit

Share this post


Link to post
Share on other sites
To damage anyone in the trigger area, set the following in the On Activation field:

{_x setDamage X} forEach thisList; where X is how much damage you want to do. thisList is an arraying containing all (by trigger setting eligible to activate?) units in the trigger area.

I don't really know why the timeout doesn't work though. Tried setting Min=1, Mid=5.5 and Max=10, and the timer method to Timeout?

It worked, thanks a lot! it was so simple and tried a lot of different codes. Thanks again.

---------- Post added at 08:26 PM ---------- Previous post was at 08:23 PM ----------

If setting a timeout / countdown on the trigger doesn't work, you could try making a small script that handled the damage.

Put this in the Activation field of the trigger:

[this] execVM "damage.sqf";

Next, we'll create a small script that'll handle the damage.

Let's call it damage.sqf, and put the following code in:

While {(player in thisList)} do {
sleep (1 + random(9));
{_x setDamage 1} forEach thisList;
};

Now, when the trigger is activated, it will execute the script 'damage.sqf'. 'damage.sqf' contains a loop which will run ~100 times per second. What it'll do is what it says on the tin.

  1. While the Player is inside the trigger, do:
  2. Wait for 1 second (plus a random of addition of up to 9 seconds)
  3. Kill all players still in the list

Because the script is in a loop, if the condition of the loop is ever broken, it will end the loop and immediately go to the end. This means that if the player moves away from the trigger, the loop will stop running and therefore NOT kill the player.

Should work anyway. Not tested because I am lazy.

:yay::torture:

The code that Inkompetent gave me worked but I am going to try later your code since I want to learn how to use the .sqf becuase I havent been able to use not even 1 code of this kind. Will report what happens later.

Share this post


Link to post
Share on other sites

The downside with my code is that it in no way tracks an individual unit's presence. It simply damages anyone that happens to be in the zone, 1-10 seconds after the first person enters the zone. So it is quite unreliable in that manner.

To make it track individuals you'd rather need a script that instantly upon entering it fires a script for the new individual, and that script tracks the person's presence in the 'danger zone' and wounds him if he's in there for too long, which is easier said than done.

Edited by Inkompetent

Share this post


Link to post
Share on other sites
The downside with my code is that it in no way tracks an individual unit's presence. It simply damages anyone that happens to be in the zone, 1-10 seconds after the first person enters the zone. So it is quite unreliable in that manner.

To make it track individuals you'd rather need a script that instantly upon entering it fires a script for the new individual, and that script tracks the person's presence in the 'danger zone' and wounds him if he's in there for too long, which is easier said than done.

Yes I get it. But as you said, its easier said than done. I think it could be done by setting the trigger to "Repeatedly" and with getPos keep tack of the unit for every second. Maybe I'll try it later. The thing is I made a trigger that will kill anyone inside the trigger are in a few seconds to simulate snipers in the zone. Im going to put a couple of snipers in an adjacent zone so you can get them from other angles but not from where they are supposed to be watching. If you take a glance, you can get killed. Understand? Also I might add CAS or LGB support to that mission.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×