Results 1 to 6 of 6

Thread: Triggers and Unit Detection

  1. #1

    Exclamation Triggers and Unit Detection

    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!

  2. #2
    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?

  3. #3
    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:
    Code:
    [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:
    Code:
    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.

    Last edited by Fuzzy Bandit; May 25 2010 at 07:51.

  4. #4
    Sergeant
    Join Date
    May 3 2010
    Location
    Puerto Rico
    Posts
    151
    Author of the Thread
    Quote Originally Posted by Inkompetent View Post
    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 ----------

    Quote Originally Posted by Fuzzy Bandit View Post
    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:
    Code:
    [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:
    Code:
    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.

    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.

  5. #5
    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.
    Last edited by Inkompetent; May 26 2010 at 02:45.

  6. #6
    Sergeant
    Join Date
    May 3 2010
    Location
    Puerto Rico
    Posts
    151
    Author of the Thread
    Quote Originally Posted by Inkompetent View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •