Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: captive and dead!

  1. #1

    Angry

    Condition (?): (! (alive unit) && (captive unit))

    Doesnt seem to work together.. i have a unit that is setcaptive true in his init field, after he reaches a waypoint he is setcaptive false..

    I want an objective to fail only if the unit is killed while being captive (not alive and captive), after he is setcaptive false nothing should happen..
    But it doesnt work! I cant use those 2 conditions together.
    Im thinking that after he dies his captive status changes to false..

    I could use a diferent way but now i just want to know... .

  2. #2
    Master Gunnery Sergeant
    Join Date
    Dec 13 2003
    Location
    Melbourne, Australia
    Posts
    1,362
    why do brackets?

    shouldnt it be this:

    !alive unit && captive unit

    Australian Armed Forces - Dedicated Tactical Coop Squad for ArmA2

  3. #3
    /post edited after correction/

    ye it seems that when he dies after 0.5 second captive status is gone.

    this works though; put in the init field of that guy:

    this addEventHandler ["Killed",{if (captive (_this select 0)) then {hint "you failed"}}]

    edit: change the part after "then" to however you want it to react; maybe have a (end)trigger that checks for a condition for example
    condition: fail1

    and you could make it like this:
    this addEventHandler ["Killed",{if (captive (_this select 0)) then {fail1 = true}}]




  4. #4
    Thanks sevenBEF, if the guy dies his captive status automaticaly changes to false. Like:
    A guy setcaptive true and a trigger that activates if he is not captive (condition), you kill him it activates so you dont need to check if he's alive, seems strange and not very practical .

  5. #5
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">&#91;/Killed
    Triggered when the unit is killed.

    Local.

    Passed array&#58; &#91;unit, killer&#93;

    unit&#58; Object - Object the event handler is assigned to

    killer&#58; Object - Object that killed the unit[/QUOTE]

    So it should be :

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler &#91;&#34;Killed&#34;,{if &#40;captive &#40;_this select 0&#41;&#41; then {fail1 = true}}&#93;[/QUOTE]

    _this select 1 would check the killer and not the killed.

  6. #6
    Quote Originally Posted by (ProfTournesol @ Sep. 09 2006,10:11)
    So it should be :

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler &#91;&#34;Killed&#34;,{if &#40;captive &#40;_this select 0&#41;&#41; then {fail1 = true}}&#93;
    _this select 1 would check the killer and not the killed.[/QUOTE]
    Ooops ehm like often just awaken when I wrote that post
    Thx for the correction indeed


    EDIT: Arf this doesn&#39;t work




  7. #7
    And can the eventhandler be split and used has a trigger condition (without needing the variable?)

    Like this?
    Condition: unitname addEventHandler ["Killed",if (captive (_this select 0))]

    On activation: hint "oh no&#33; the captive is dead&#33;"

    The syntax is problably all wrong .
    But the eventhandler is still an if/then statement, yes?
    .

    Edit:

    Quote Originally Posted by (SevenBEF @ Sep. 09 2006,09:33)
    EDIT: Arf this doesn&#39;t work
    No it doesnt, problably for the same reason alive doesnt, i will have to change it wich is a pitty but not a big problem, thanks guys .




  8. #8
    Ok tested thisone before posting:

    Have a trigger set to true on the map with:
    activation: cap1 = false

    When setting the unit captive, in its condition add:
    unit setcaptive true; cap1 = true;

    same for setting to false:
    unit setcaptive false; cap1 = false;

    in the unit&#39;s initfield:
    this addEventHandler ["Killed",{if (cap1) then {hint "you failed"}}]

    this seems to work

  9. #9
    The variable way is the way .
    Should i also declare those variables in the init file?

    edit:
    How about spliting the eventhandler in a trigger? .

    edit2:
    If it works using the variable workaround it should also work without the event handler? &#33;alive && cap1 ??

    If not im confused and out for a coffee .




  10. #10
    Quote Originally Posted by (Heatseeker @ Sep. 09 2006,12:00)
    The variable way is the way .
    Should i also declare those variables in the init file?

    edit:
    How about spliting the eventhandler in a trigger? .

    edit2:
    If it works using the variable workaround it should also work without the event handler? &#33;alive && cap1 ??

    If not im confused and out for a coffee .
    Perhaps;
    Seems that first solutions didn&#39;t work since the check on the captive status is slower than the status "captive" to be gone when the unit dies.
    So if the check takes time, so does assigning the variable. that&#39;s how I came to it. Guess a trigger would also do, but I don&#39;t see why you wouldn&#39;t use the EH since you can launch any script or whatever you want from the "then {.....}

    I&#39;m sure there are some real pro&#39;s (that didn&#39;t reply yet) here who would recommend you to use the EH I think

Page 1 of 2 12 LastLast

Posting Permissions

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