Jump to content
Sign in to follow this  
igneous01

Dynamically spawned mission - how to check for local variables

Recommended Posts

Ok, so ive hit a bump here in my mission. I have managed to successfully script a simple sidemission that activates when you talk to an NPC, everything spawns and the tasks show up.

However, I want to keep all my variables local, because i will have many more of these sidemissions come up from other NPC's.

So the problem I am having now is this: How do I check for tasks to complete (in a cpu friendly way)

so far i tried by creating triggers inside the script and checking inside them - no go since they dont recognize local variables

I also tried to use an FSM to check for the tasks, same thing

I did try using a while loop, however it wont work either:

while {!_finishmission} do {
if (!alive _exStash1 && !alive _exStash2 && !alive _exStash3) then {
_obj1 settaskstate "SUCCEEDED";
};

if (!alive HVT) then {
_obj2 settaskstate "SUCCEEDED";
};

if ((taskstate _obj1) == "SUCCEEDED" && (taskstate _obj2) == "SUCCEEDED") then {
_finishmission = true;
};
};

the problem here being that it will continously loop and reset the tasks to succeeded after they are completed - its redundant and waste's cpu resources.

I dont want to get cryptic with this, so surely i must have forgot a simple method to check for these obj's once? I want the script to continue as I am deleting all the units, triggers, markers and variables at the end of the script (when the player gets out of range of the area)

so what can I do? any suggestions please?

thanks

Share this post


Link to post
Share on other sites

maybe use spawn and waitUntil for each "side" mission instead?

[_obj1,_exStash1,_exStash2,_exStash3] spawn {
  _obj1 = _this select 0;
  _exStash1 = _this select 1;
  _exStash2 = _this select 2;
  _exStash3 = _this select 3;
  waitUntil {!alive _exStash1 && !alive _exStash2 && !alive _exStash3};
  _obj1 settaskstate "SUCCEEDED";
};

Edit: spawn only if you have every side mission in same script ofc..

Edited by Demonized
added missing ; in waituntil

Share this post


Link to post
Share on other sites

Thanks again Demonized, thats something i missed, works perfectly now and without issues.

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  

×