Jump to content
Sign in to follow this  
ColeMinor

Need help running a script in a loop (to trigger tasks)

Recommended Posts

Hey guys I tried to find this via search but it wasn't very helpful this time. I do think I need to put all this in a script and run it on a loop but i'll give you the whole story incase you have better ideas. Basically the EOS thread has a lot of things going on and my posts don't seem to be getting answered on this so I thought I'd change my approach. I don't want to totally flood that thread and my problem is pretty elaborate so I figured I'd lay it all out here and maybe someone can help me sort this out.

I am using EOS, I was at first putting triggers over the EOS zones set to when there are no opfor left the trigger should play this script:

["TaskSucceeded", ["Front Line Secured"]] call bis_fnc_showNotification;task1 setTaskState "Succeeded";;;task2 = player createSimpleTask ["taskName2"]; task2 setSimpleTaskDescription ["Take LZ Connor","LZ Connor",""]; task2 setTaskState "assigned"; task2 setsimpletaskdestination [2965, 1860]; player setCurrentTask task2;task3 = player createSimpleTask ["taskName3"]; task3 setSimpleTaskDescription ["Take Agios Ionnis","Agios Ionnis",""]; task3 setTaskState "assigned"; task3 setsimpletaskdestination [3073, 2139];

What I found was the trigger would sometimes go off (notifying you that task1 is complete, and assigning the next 2 tasks while making task2 your current task) and the EOS zone would still be red, or the EOS zone would go green and the trigger would not go off.. I'm not sure the proper terminology to explain everything but basically I want that script above to run when the zone turns green.

So I next tried to use script to say: when the marker turns green then run this script.

if (getMarkerColor "FrontLine" == "ColorGreen") then { Hint "Front Line Secured. Proceed to next objective.";["TaskSucceeded", ["Front Line Secured"]] call bis_fnc_showNotification;task1 setTaskState "Succeeded";;;task2 = player createSimpleTask ["taskName2"]; task2 setSimpleTaskDescription ["Take LZ Connor","LZ Connor",""]; task2 setTaskState "assigned"; task2 setsimpletaskdestination [2965, 1860]; player setCurrentTask task2;task3 = player createSimpleTask ["taskName3"]; task3 setSimpleTaskDescription ["Take Agios Ionnis","Agios Ionnis",""]; task3 setTaskState "assigned"; task3 setsimpletaskdestination [3073, 2139];};  

I put this all in a trigger that was set to 0 size, anybody not present run this script. So, the thing is it DOES work at the beginning of the mission. For example if I set the EOS to have no enemies, and place myself inside the EOS zone it will immediately change to green after it realizes I'm the only unit in the zone, this will run the script saying task complete and here's your next task. BUT, if I wait a few seconds at the beginning of the mission before I move into that zone it will turn green but it wont run the script... which tells me those triggers only work at the beginning of the mission, even if set to repeatedly.

This tells me I need to put all that into a script file which I run via some exec command on a loop, but I don't know how to do that.

Can anyone help me out on this? I've been at this for days now.

thanks!

Share this post


Link to post
Share on other sites

The quickest and easiest way to do that would be via a while-loop, imo.

I'm not going to pretend I know stuff I don't, but a quick look at the following link should help you a bit. It's not too hard to implement, if it's what you need/want.

http://community.bistudio.com/wiki/Control_Structures#while-Loop

EDIT: Oh, to put it in a script just call

null = [] execVM "scriptnamehere.sqf"

in the On Act of a trigger. Then, create your script file in the mission directory under the same name.

Share this post


Link to post
Share on other sites

You can replace all your task stuff with:

_null = [west, "taskName2", ["Take LZ Connor", "LZ Connor", "TAKE"], [2965, 1860, 0], true] spawn BIS_fnc_taskCreate;  
_null = [west, "taskName3", ["Take Agios Ionnis", "Agios Ionnis", "TAKE"], [3073, 2139, 0], true] spawn BIS_fnc_taskCreate;  

Share this post


Link to post
Share on other sites

Wasn't there a bug where animals triggered ANYBODY for triggers? Might've been fixed now

Anyway, if I understand this correctly, the condition would be

(getMarkerColor "FrontLine" == "ColorGreen") 

not the on activation

Share this post


Link to post
Share on other sites
Wasn't there a bug where animals triggered ANYBODY for triggers? Might've been fixed now

Anyway, if I understand this correctly, the condition would be

(getMarkerColor "FrontLine" == "ColorGreen") 

not the on activation

The trigger is set to 0 by 0 size so no one could be in it, its set to 'anybody not present' so its always on.

Actually, reflecting back on the thread, you may be able to redo the stuff via the modules?

I had the impression the modules were still bugged in arma3.

Thanks for the replies guys I'll get back with an update.

Edited by Drow09

Share this post


Link to post
Share on other sites

Ok guys heres the situation

When this script is run from the on act field in a trigger it Works,, but only if triggered at the beginning of the mission:

if (getMarkerColor "FrontLine" == "ColorRed") then { Hint "Front Line Secured. Proceed to next objective.";["TaskSucceeded", ["Front Line Secured"]] call bis_fnc_showNotification;task1 setTaskState "Succeeded";;;task2 = player createSimpleTask ["taskName2"]; task2 setSimpleTaskDescription ["Take LZ Connor","LZ Connor",""]; task2 setTaskState "assigned"; task2 setsimpletaskdestination [2965, 1860]; player setCurrentTask task2;task3 = player createSimpleTask ["taskName3"]; task3 setSimpleTaskDescription ["Take Agios Ionnis","Agios Ionnis",""]; task3 setTaskState "assigned"; task3 setsimpletaskdestination [3073, 2139];};

If i try to run it from a script with this it doesn't work.

null = [] execVM "taskcentral.sqf"

Thing is it is the exact same script in the taskcentral.sqf, and i know that taskcentral.sqf works because it can play a hint with this script:

if (getMarkerColor "FrontLine" == "ColorGreen") then { Hint "Front Line Secured. Proceed to next objective.";};

but none of the task based stuff seems to work when you try to run it from the script this way.

Any ideas?

I also need an example of a loop script please someone, I tried a few from that link with no luck.

Share this post


Link to post
Share on other sites

As mentioned before "if" stuff belongs in/as the condition of a trigger, not the onAct. That whole thing is a trigger.

Trigger Condition:

getMarkerColor "FrontLine" == "ColorRed"

Trigger OnAct:

hint "Front Line Secured. Proceed to next objective.";
["TaskSucceeded", ["Front Line Secured"]] call bis_fnc_showNotification;
_null = ["taskName1", "SUCCEEDED"] spawn BIS_fnc_taskSetState;  
_null = [west, "taskName2", ["Take LZ Connor", "LZ Connor", "TAKE"], [2965, 1860, 0], true] spawn BIS_fnc_taskCreate;  
_null = [west, "taskName3", ["Take Agios Ionnis", "Agios Ionnis", "TAKE"], [3073, 2139, 0], true] spawn BIS_fnc_taskCreate;  

As for looping, what exactly are you trying to loop?

Share this post


Link to post
Share on other sites

As a note (you seem to be fairly set on scripting ;)) Task modules aren't bugged afaik, I used them a lot in my missions and it was very simple.

Share this post


Link to post
Share on other sites

yea I've been making missions for years but when I started with arma3 I decided to try to learn more complex things. I've implemented virtual ammo boxes, respawning vehicles, some ghetto mobile respawn I figured out myself because I couldnt get the revive mod to work without bugs. I've added a recruitment system, the realistic jump, and EOS (I do have a couple error msgs from eos still) and then I have such a hard time just getting some tasks to work lol..

So yea I'll have a look at those modules but I've been at this problem for three days and I'd like to solve it.

I'm very new to all this and I'm struggling to learn it, I need to find some info on scripting to learn the basics. My brother has taken some programming courses (learning arma scripting now too but cant help me yet) and he said you guys probably think I know more about this than I really do because this is on the advanced sided of editing, I barely know what I'm doing but maybe that's how everyone starts out.

Kylania I need to loop the script about the tasks because if its run from a trigger it only goes off at the beginning of the mission, I need it to go off when the zone is cleared. So I think I need it to run in a loop until that marker changes? If there's a way to make it so the triggers work later in the mission that's probably the easiest way to solve this, but even set to repeatedly it only seems to work if the settings go off at the beginning of the mission.

I might need to rethink the whole approach so I'm totally open to any advice.

thanks guys.

Edited by Drow09

Share this post


Link to post
Share on other sites

Triggers runs in a loop until their condition is fulfilled - that's why they are called triggers. Basically they want until their condition is true. See it as a gate that requires a keycode and the gate won't open and let you have all goodies until you enter the correct password (condition).

Read more about them here:

https://community.bistudio.com/wiki/Mission_Editor:_Triggers

I'm guessing EOS turns the marker green and when that happens, you want to run your on activation code.

Share this post


Link to post
Share on other sites

yea I was thinking after i posted maybe it will work if I tried the first part in condition and the rest in act (like u guys hinted at), my bro said that part looked weird to him, my answer was But it does work!

not well tho, and only at mission start.

I'll try that tonight and let ya know how it goes.

Share this post


Link to post
Share on other sites

What color does your marker start out as? Are you placing it as green, then letting the EOS script change it to red and back again or something?

Share this post


Link to post
Share on other sites

The markers are all red at start. I have tested the script with colorRed and it works, it also works (when set to colorGreen) if I set eos to spawn no enemies and place myself inside a zone at mission start, zone turns green automatically and sets off the trigger.

I'm thinking now it might work if I use the condition field as mentioned above.

I actually learned a lot from that link, I thought I knew all about triggers but most of my experience is from ofpresisance era (I totally missed arma and only dabbled in arma2 a bit, I was busy with life atm) where there wasn't much documentation and you just kinda figured things out by trial and error.

edit - Thanks for the link cuel, I'm going to read up on scripting basics there and maybe I wont have to ask so many dumb questions! :)

Edited by Drow09

Share this post


Link to post
Share on other sites

Thanks dudes that was it! I appreciate the help.

For EOS Zones:

Trigger)

Condition:

getMarkerColor "Camp Rogain" == "ColorGreen"

On Act:

Hint "Camp Rogain Secured. Proceed to next objective.";["TaskSucceeded", ["Camp Rogain Secured"]] call bis_fnc_showNotification;task6 setTaskState "Succeeded"; task7 = player createSimpleTask ["taskName7"]; task7 setSimpleTaskDescription ["Take Agia Marina","Agia Marina",""]; task7 setTaskState "assigned"; task7 setsimpletaskdestination [2984, 6027]; player setCurrentTask task7;

in description.ext of your mission: (runs task notifications)


class CfgNotifications { 

   class TaskSucceeded 
   { 
       title = "TASK COMPLETED"; 
       iconPicture = "\A3\ui_f\data\map\MapControl\taskicondone_ca.paa"; 
       description = "%1"; 
       color[]={0,255,0,1};
   }; 
   class TaskFailed 
   { 
       title = "TASK FAILED"; 
       iconPicture = "\A3\ui_f\data\map\MapControl\taskiconfailed_ca.paa"; 
       description = "%1"; 
       color[]={255,0,0,1};

   }; 
   class TaskCanceled { 
       title = "TASK CANCELED"; 
       iconPicture = "\A3\ui_f\data\map\MapControl\taskiconcanceled_ca.paa"; 
       description = "%1";
       color[]={255,0,0,1};

   }; 
   class TaskAssigned  { 
       title = "TASK ASSIGNED"; 
       iconPicture = "\A3\ui_f\data\map\Mapcontrol\taskIcon_ca.paa"; 
       description = "%1"; 

   }; 

  class TaskCreated  { 
       title = "TASK CREATED"; 
       iconPicture = "\A3\ui_f\data\map\MapControl\taskiconcreated_ca.paa"; 
       description = "%1"; 

   }; 
};


For a trigger that ends the mission when all zones are completed:

Condition:

(getMarkerColor "frontline" == "ColorGreen") && (getMarkerColor "airfield" == "ColorGreen") && (getMarkerColor "AgiosIoannis" == "ColorGreen") && (getMarkerColor "LZConnor" == "ColorGreen") && (getMarkerColor "airfield" == "ColorGreen") && (getMarkerColor "CampRogain" == "ColorGreen") && (getMarkerColor "Mike-26" == "ColorGreen") && (getMarkerColor "CampMaxwell" == "ColorGreen") && (getMarkerColor "airbase" == "ColorGreen") && (getMarkerColor "AgiaMarina" == "ColorGreen")

On Act:

endMission "END1"

Edited by Drow09

Share this post


Link to post
Share on other sites

I'm happy it's working for you but still sad you refuse to use functions and instead of using 1 line of code you use 6 for every task. :)

Share this post


Link to post
Share on other sites

lol! functions you say? I'll look into them! :)

Edited by Drow09

Share this post


Link to post
Share on other sites
I'm happy it's working for you but still sad you refuse to use functions and instead of using 1 line of code you use 6 for every task. :)

Not everyone can be a guru like you kylania ;D

Share this post


Link to post
Share on other sites
Not everyone can be a guru like you kylania ;D

I've included two examples of what I'm talking about in this thread. Don't have to be a guru just be able to copy paste and read. Heh

Share this post


Link to post
Share on other sites
I've included two examples of what I'm talking about in this thread. Don't have to be a guru just be able to copy paste and read. Heh

I'm sure it helps :p

Baby steps!

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  

×