Jump to content
Sign in to follow this  
infiltrator_2k

Ending Mission When All Tasks Are Complete?

Recommended Posts

As the title suggests I'm trying to find a way of ending the mission when all of the tasks have been completed. I'm a complete noob when it comes to scripting, and although I understand the logic behind the editing, the scripting language is too much for me ATM. My question is what's the most practical way of successfully ending the mission when the player(s) have completed the tasks? I've named the triggers to the tasks, so I'm guessing a final trigger to end the mission has to be met when all of the task's triggers have been activated.

I dug out this thread although it's not that friendly to someone who's as novice as me.

http://www.armaholic.com/forums.php?m=posts&q=22736

Apologies if this has been asked before, but I've searched and can't seem to find anything, although I'm sure there's some post somewhere

Cheers

Share this post


Link to post
Share on other sites

So, that example you posted is saying when your (trigger?) completing the task is fired you also want to put this in the triggers Onact feild:

obj1 = true;

publicVariable "obj1"

The variables are then made public (snyced to all clients so everyone knows about then). You can just do the same for each objective when objective two is done have another variable its triggers on act:

obj2 = true;

publicVariable "obj2"

Now we have some variables that everyone knows about that we can end the mission. You now create a trigger that ends the mission when both task in this example are done. The condition for that trigger would be as follows:

obj2 AND obj1

*(obviously this needs to be an end mission trigger)*

Note that obj1 and obj2 are just names it does not matter what you call them the important thing is that they can be used in your trigger that ends the mission. Also note what this is doing is separate and in addition to you setting your tasks state.

Edited by Big_Wilk

Share this post


Link to post
Share on other sites
So, that example you posted is saying when your (trigger?) completing the task is fired you also want to put this in the triggers Onact feild:

obj1 = true;

publicVariable "obj1"

The variables are then made public (snyced to all clients so everyone knows about then). You can just do the same for each objective when objective two is done have another variable its triggers on act:

obj2 = true;

publicVariable "obj2"

Now we have some variables that everyone knows about that we can end the mission. You now create a trigger that ends the mission when both task in this example are done. The condition for that trigger would be as follows:

obj2 AND obj1

*(obviously this needs to be an end mission trigger)*

Note that obj1 and obj2 are just names it does not matter what you call them the important thing is that they can be used in your trigger that ends the mission. Also note what this is doing is separate and in addition to you setting your tasks state.

I've tried that, or at leat I think I've tried that and it doesn't work :/

Share this post


Link to post
Share on other sites

You could use a gamelogic for this, i dont see them used this way that often but this is a good place to implement it.

Place a gamelogic,

Give the gamelogic a waypoint of type AND

In the OnAct of the waypoint place

["end1"] call bis_fnc_endmission;

Then sync all of your mission/task triggers to this waypoint

done

GL_WP.png

When all of your mission triggers are activated (tasks are complete) the gamelogic's waypoint will fire calling endmission.

Share this post


Link to post
Share on other sites

Thank you Big_Wilk. I'm away at work now until Friday, although when I get back I'll try it and report back. I'm a little disappointed there isn't an easier and a more cleaner way of doing this. A simple trigger with the conditions of each task met for example like the !alive player1 && !alive player2 etc...

Share this post


Link to post
Share on other sites

There are lots of ways to accomplish this task,

If Big_Wilk's is to much by adding all the variables in and checking them

or my one gamelogic and a waypoint doesnt suit your needs

you can

{
   if ( [_x] call bis_fnc_taskExists ) then {
       [_x] call bis_fnc_taskCompleted
   }else{
       false
   };
} count ["task1","task2","task3"] == 3

In a trigger condition will fire when the tasks are completed.

OR

{
   if ( [_x] call bis_fnc_taskExists ) then {
       [_x] call bis_fnc_taskState == "SUCCEEDED"
   }else{
       false
   };
} count ["task1","task2","task3"] == 3

In a trigger condition will fire when the tasks are succeeded (As the previous one for completed, completed is true if a tasks state is one of "SUCCEEDED", "FAILED" or "CANCELED")

You need the taskExists check just to make sure the trigger does not throw an error at mission start before the task is actually created or just in case one of your task is created during the mission.

Share this post


Link to post
Share on other sites
There are lots of ways to accomplish this task,

If Big_Wilk's is to much by adding all the variables in and checking them

or my one gamelogic and a waypoint doesnt suit your needs

you can

{
   if ( [_x] call bis_fnc_taskExists ) then {
       [_x] call bis_fnc_taskCompleted
   }else{
       false
   };
} count ["task1","task2","task3"] == 3

In a trigger condition will fire when the tasks are completed.

OR

{
   if ( [_x] call bis_fnc_taskExists ) then {
       [_x] call bis_fnc_taskState == "SUCCEEDED"
   }else{
       false
   };
} count ["task1","task2","task3"] == 3

In a trigger condition will fire when the tasks are succeeded (As the previous one for completed, completed is true if a tasks state is one of "SUCCEEDED", "FAILED" or "CANCELED")

You need the taskExists check just to make sure the trigger does not throw an error at mission start before the task is actually created or just in case one of your task is created during the mission.

Cheers. That's definitely a method I'd personally prefer to use. Not that I'm not grateful for the first method of course, and I appreciate Big_Wilk going to the trouble of explaining the first method (much appreciated). It's just my mission is forever growing in size and complexity, and if there's a way of executing commands to perform a task that doesn't require a visual aids for reference, then I'd prefer to script it as it minimises my mission layout becoming cluttered with icons/waypoins etc..

But I think it is personal preference and others reading this may prefer to use the game logic and waypoint method. Still, a good post that's helped me and will no doubt many others in the future wanting to achieve the same thing.

Cheers guys ;)

Share this post


Link to post
Share on other sites

Think you guys are making things a bit more complicated than they need to be. If you have triggers set up and named for each task, simply set up another trigger and use 'triggeractivated' and all the other trigger names. So, say for example you have 3 triggers named trig1, trig2 and trig3, that all need to be completed first, set up a fourth "End" trigger with the condition of:

triggeractivated trig1 and triggeractivated trig2 and triggeractivated trig3

Edited by Meatball

Share this post


Link to post
Share on other sites
Think you guys are making things a bit more complicated than they need to be. If you have triggers set up and named for each task, simply set up another trigger and use 'triggeractivated' and all the other trigger names. So, say for example you have 3 triggers named trig1, trig2 and trig3, that all need to be completed first, set up a fourth "End" trigger with the condition of:

triggeractivated trig1 and triggeractivated trig2 and triggeractivated trig3

Good shout if it works. I'm not able to clarify as I'm away working until Friday. It seems a lot more practical to have some thing as simple and what I would have expected from the editor.

If using EHs give better performance, I wonder if the same could be achieved using the event handler?... Just a thought.

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  

×