Jump to content
Sign in to follow this  
Heatseeker

captive and dead!

Recommended Posts

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... confused_o.gif .

Share this post


Link to post
Share on other sites

why do brackets?

shouldnt it be this:

!alive unit && captive unit

Share this post


Link to post
Share on other sites

/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}}]

Share this post


Link to post
Share on other sites

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 confused_o.gif .

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[/Killed

Triggered when the unit is killed.

Local.

Passed array: [unit, killer]

unit: Object - Object the event handler is assigned to

killer: Object - Object that killed the unit

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 ["Killed",{if (captive (_this select 0)) then {fail1 = true}}]

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

Share this post


Link to post
Share on other sites
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 ["Killed",{if (captive (_this select 0)) then {fail1 = true}}]

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

Ooops ehm like often just awaken when I wrote that post smile_o.gif

Thx for the correction indeed smile_o.gif

EDIT: Arf this doesn't work confused_o.gif

Share this post


Link to post
Share on other sites

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! the captive is dead!"

The syntax is problably all wrong pistols.gif .

But the eventhandler is still an if/then statement, yes?

smile_o.gif .

Edit:

EDIT: Arf this doesn't work confused_o.gif

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 smile_o.gif .

Share this post


Link to post
Share on other sites

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's initfield:

this addEventHandler ["Killed",{if (cap1) then {hint "you failed"}}]

this seems to work

wink_o.gif

Share this post


Link to post
Share on other sites

The variable way is the way biggrin_o.gif .

Should i also declare those variables in the init file?

edit:

How about spliting the eventhandler in a trigger? wink_o.gif .

edit2:

If it works using the variable workaround it should also work without the event handler? !alive && cap1 ??

If not im confused and out for a coffee inlove.gif .

Share this post


Link to post
Share on other sites
The variable way is the way biggrin_o.gif .

Should i also declare those variables in the init file?

edit:

How about spliting the eventhandler in a trigger? wink_o.gif .

edit2:

If it works using the variable workaround it should also work without the event handler? !alive && cap1 ??

If not im confused and out for a coffee inlove.gif .

Perhaps;

Seems that first solutions didn'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's how I came to it. Guess a trigger would also do, but I don't see why you wouldn't use the EH since you can launch any script or whatever you want from the "then {.....} wink_o.gif

I'm sure there are some real pro's (that didn't reply yet) here who would recommend you to use the EH I think firefoxlover.gif

Share this post


Link to post
Share on other sites

You don't need any variables or even the captive condition, just have:

1. a trigger that fails the objective when the unit is not alive

2. on the waypoint that has setcaptive false, deletevehicle said trigger

Share this post


Link to post
Share on other sites

Actually i dont even need the captive status has a condition (its only there to prevent friendly a.i. from failing the obj wink_o.gif .), its all working fine, just wanted to know a workaround for the not alive/captive situation since it might come in handy. Thanks smile_o.gif .

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  

×