Jump to content
Sign in to follow this  
*NOB* Džou

Help with tasks

Recommended Posts

I have a pretty good mission almost finished, but i need help with tasks...

I found that topic about tasks and i created every one of them, but as i am pretty new to scripting (i got used to Dragon Rising's scripting model, but this looks slightly different) i don't know how to make them recognise when the aa battery is destroyed.

The task is to destroy AA Igla pod, and marker is there, but i have no variable that would recognise the state of Igla pod (is it really destroyed or not)

I would really be thankful if somebody could write or copy-paste the model, so i could adjust it for my mission...

Thanks in advance

Edited by *NOB* Džou

Share this post


Link to post
Share on other sites

I haven't used tasks much myself ... do you know how to tell the game the task is complete, and all you need now is to find out how to react to the pod being destroyed in order to mark the task as complete?

If so, there's two ways: a loop that continuously checks to see if the pod is destroyed, or an event handler script which gets run when it's killed. The second way is more efficient, I think, since you're not continually polling its state.

First way would be to do something like this in a script file run with execVM:

waitUntil { not alive name_of_aapod };
// code here to mark task as complete

Alternatively if you already have code elsewhere, the "alive name_of_unit" is the check you need. However: you might also want to consider the pod destroyed if the man inside it is killed. So that would be different.

The other way is to use an event handler, e.g. in the unit's init:

nul = this addEventHandler ["Killed", "aa_pod_is_dead = true;"];

The code it runs (in this case, setting a global variable) can be anything you want, so you can put the commands to mark the task as complete there instead. You can either use single-quotes instead of double-quotes within the command, or double up the double-quotes, e.g.

nul = this addEventHandler ["Killed", "kill_aa_task setTaskState 'Succeeded'"];

Share this post


Link to post
Share on other sites

If you name the AA Pod "Igla", and then create a trigger with axis a & b as 0, activation as none. Leave the other options and put in condition

!(alive Igla)

that will activate the trigger when 'Igla' is NOT alive. Then on the activation you can just set the taks complete by doing:

TASKNAME setTaskState "SUCCEEDED";

Share this post


Link to post
Share on other sites

Oh yes, a trigger is probably the easiest way for a newie! Yes, do it like that. :)

Share this post


Link to post
Share on other sites
If you name the AA Pod "Igla", and then create a trigger with axis a & b as 0, activation as none. Leave the other options and put in condition
!(alive Igla)

that will activate the trigger when 'Igla' is NOT alive. Then on the activation you can just set the taks complete by doing:

TASKNAME setTaskState "SUCCEEDED";

one more question... in which line do i have to write

TASKNAME setTaskState "SUCCEEDED";

is that written in briefing.sqf or in game?

and how to connect the fact that the igla is destroyed with execution of that trigger

in OFP: DR i would write something like

when triggerActivated("triggername") than setTaskState "SUCCEEDED";

Edited by *NOB* Džou
Added last question

Share this post


Link to post
Share on other sites

Re-read Andy455's post a bit more carefully...

When you create the trigger, there are 3 text fields you can enter scripts: the "condition" (where you put the "not alive igla" check), "on activation" (where you put code to be run when the trigger is activated), and the "on deactivation" (where you put code to be run when the trigger is no longer activated, only relevant to repeating triggers).

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  

×