Results 1 to 7 of 7

Thread: Trigger identifying a triggering unit

  1. #1

    Trigger identifying a triggering unit

    Helo,

    I need help with a silly problem, I cannot resolve myself.
    How can I pass identity of an unit activating a trigger to a script executed by this trigger on activation?

    For example - I want to place a trigger set to, let's say, civilian/repeatedly. I want this trigger - when activated by any civilian unit (unit, not group) - to launch a script ordering this unit to do something, to go somewhere etc.

    E.g. I want any civilian unit activating the trigger to go to a marker named "destinationmarker".
    And so I place something like this in the trigger's on activation field:

    [???] exec "myscript.sqs"

    And then in myscript.sqs...

    ??? = _unit
    _unit domove position destinationmarker
    exit


    What should I place instead of ???s to have this script working?

    Kind regards

    Chemnitzer

  2. #2
    Try this:

    {[_x] exec "myscript.sqs"} forEach thisList

  3. #3
    Thank you!

    But how should I define this unit inside the script then?

    Would it be _unit = this select 0?

    Regards

    Chemnitzer

  4. #4
    Yes, but with an underscore before 'this', like this:

    _unit = _this select 0

  5. #5
    OK, thank you very much!

    EDIT

    My script is generally working, almost perfect.
    Just one more question and a problem.

    What should I add to the {[_x] exec "myscript.sqs"} forEach thisList line to pass trigger's name to the script too?

    And my problem is, that even if the units are commanded to go with these lines:

    _unit SetBehaviour "CARELESS"
    _unit SetSpeedMode "LIMITED"
    _unit domove position _destination


    ...some of them are still running, as if they were in the "normal" speed mode. Let's say some 80 per cent of units are walking, but the rest are running. I use standard OFP civilians and some Farmland ones - but this running issue appears in both cases. What's wrong here?

    Kind regards

    Chemnitzer
    Last edited by Chemnitzer; Apr 5 2012 at 17:45.

  6. #6
    How large is the trigger area? Trigger doesn't activate again until it deactivates, so units staying inside could prevent units coming later from having the trigger activate on them.

  7. #7
    Hi all.
    My first post here.

    Quote Originally Posted by Chemnitzer
    And my problem is, that even if the units are commanded to go with these lines:
    _unit SetBehaviour "CARELESS"
    _unit SetSpeedMode "LIMITED"
    _unit domove position _destination

    ...some of them are still running, [..]. What's wrong here?
    As correctly suggested by Pulverizer, you must consider another way to catch the units inside (and still entering) the trigger.
    Forget the method {[_x] exec "myscript.sqs"} forEach thisList.
    Why?
    I'll simulate a typical chain of events in which the above approach fails to satisfy your expectations:
    a- mission starts: the trigger status is OFF (no units present by design);
    b- some units enter, at the same time, the area of the trigger: the trigger meets the condition and the event "On Activation" is called, so your script too (since the use of "ForEach", you'll have multiple calls);
    c- each istance of your script will contain an unit as parameter;
    d- one unit is still inside the trigger area: the trigger status is still ACTIVATED;
    e- a new unit enter the trigger area: nothing happens;
    f- both unit of "d" and "e" points leave the trigger area: the trigger status is now OFF, the condition is no more met and the event "On Deactivation" is called.
    Go to "b" point.

    The good way for you.
    In the field "On Activation" put: trigger_name Exec "myscript.sqs".
    Your script will be called once (one istance) and will parse continuosly (loop) the array "List _THIS", where "_THIS" is the reference to the object trigger named "trigger_name".
    As soon the array "List _THIS" is empty, the script exits.

    A debug sample of the script "myscript.sqs":
    Code:
    _list_old=[]
    
    #LoopTrig
    _list_now=(List _THIS)
    
    @((Count _list_now)!=(Count _list_old))
    
    Player GlobalChat Format ["§ %1",_list_now]
    
    ;Parses the array.
    _t=(Count _list_now)
    
    ;Did all units leave the trigger area?
    ?_t<1:Player GlobalChat "§ Bye!";Exit
    
    _i=0
    #LoopNewUns
    _un=(_list_now Select _i)
    
    ;Look for new units.
    ?(_un In _list_old):GoTo "NextNewUns"
    
    ;Here your code to apply to the unit "_un".
    Player GlobalChat Format ["§ _un=%1 entered",_un]
    
    #NextNewUns
    _i=_i+1
    ?_i<_t:GoTo "LoopNewUns"
    
    ;Note the "=+": duplicates the array in memory.
    _list_old=+_list_now
    GoTo "LoopTrig"
    Try it and the report us if the units are seen as you expect.

    Regards,
    j0e

Similar Threads

  1. Triggering a trigger. Does not work in Arma 2?
    By Joona in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 11
    Last Post: Jun 22 2011, 10:40
  2. Player triggering a trigger in a vehicle
    By Koni in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 4
    Last Post: Feb 3 2011, 15:55
  3. All units triggering a trigger
    By Benny Moore in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 13
    Last Post: Mar 22 2006, 15:25
  4. Triggering a trigger or however to get to my goal
    By OldGrandad in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 3
    Last Post: Apr 13 2004, 08:49
  5. Trigger still triggering
    By in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 10
    Last Post: Mar 30 2003, 16:46

Posting Permissions

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