Jump to content
Sign in to follow this  
Domceck

Trigger when task is completed

Recommended Posts

Hello,

I was working on a single player mission in the editor when I came across a problem. I wanted to end the mission in an extraction area which is accessible from the beginning. I want to end the mission only after a certain task is completed to avoid ending it too early by just walking on it by accident. I tried it with "triggerActivated", but I need it to be the task itself, not the trigger which sets the task as succeeded. I tried solutions from these posts but as there are now modules for setting a task as completed I am not sure how to do it. taskstate didn't seem to do the trick but I don't exactly know why.

http://forums.bistudio.com/showthread.php?137869-Check-if-task-succeeded

http://forums.bistudio.com/showthread.php?136762-Task-completes-only-if-other-task-complete

For testing purposes I set up three triggers with activation by walking on them. First one creates a task with a module. Second one sets task as succeeded with a module. Third one is supposed to end the mission, only if player is present and the task is succeeded. Unfortunately it either triggers with and without the task or not at all. Can somebody tell me a set up for this scenario? I am sure I can then integrate it in my mission.

Thanks a lot!

Share this post


Link to post
Share on other sites

Thanks for your quick answer. I tried that but I have two problems now.

1. The game starts with an error box saying that the task does not exist (until I walk on the trigger to create it).

2. I can't set up the third trigger to fire when both the task is completed and the player is present.

I tried something like:

Bluefor, present

Cond: this && ["taskID"] call BIS_fnc_taskCompleted

But that doesn't work at all.

Share this post


Link to post
Share on other sites

Did you try this:

this && (["taskID"] call BIS_fnc_taskCompleted)

If that doesn't work, try this:

(([getPos player, getPos *triggerName*] call BIS_fnc_distance2D) < *desiredTriggerRadius*) && (["taskID"] call BIS_fnc_taskCompleted)

Replace: *triggerName* - name of your trigger, *desiredTriggerRadius* - numerical value of trigger's radius.

Share this post


Link to post
Share on other sites

I tried something else and now the trigger three ends the mission when I activated trigger two (which sets the task as "completed") but even without me triggering number one, whichs creates the task in the first place.

It now works with trigger 1, then 2, then 3 and with 2, then 3. Not 3 alone, which was my main concern.

SilentSpike, I tried your first version and it gives me the stated result of working with 1,2,3 and 2,3.

But I still get the message saying that the function taskCompleted needs the task, which does not exist as soon as I load up the mission.

---------- Post added at 16:09 ---------- Previous post was at 15:21 ----------

Ok, I think I finally made it. There are still some minor issues but the main concept works now. I have to create the task first, then activate the second trigger to set task as completed, then walk on the third to end the mission (which only ends when the task was created and then completed). And as a bonus I don't get the code error for the BIS_fnc_taskCompleted.

For anyone else wondering, here is my code:

 
Trigger 3, supposed to end the game in its area for extraction

TYPE: End#1
ACTIVATION: Bluefor present, once,

CONDITION:
this && triggerActivated T1 &&   if ( ["tsk1"] call BIS_fnc_taskExists ) then {    ["tsk1"] call BIS_fnc_taskCompleted   }else{    false   };  

T1 is the trigger to create the task, named tsk1. With the if(...) I remove the error for it saying there is no task when I start the mission.

It is probably not the most elegant solution but it does what it is supposed to.

Thanks for the help with this! :)

PS: My minor issue is, when I walk in trigger two, which sets task as completed, then in trigger one, then back in two it does not complete the task. But I just hope no player will ever wander around the map and trigger everything in this particular order... :p

Edited by Domceck

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  

×