Jump to content
Sign in to follow this  
BoltboxerPro

Make objectives random?

Recommended Posts

I've been searching around for this but there appears to be almost nothing on it. I'm wondering how do you make objectives random?

For example, I have five different target around the map, but I want them to spawn separately, so at the beginning of the mission you get one of the several targets as your objectives, then once that objective is done you get another one, but in random order? Does anyone have any insight on how that would work? Thanks!

Share this post


Link to post
Share on other sites

Maybe open up Domination and see how the side missions are done? The relevant subfolder is "x_missions", I think.

Share this post


Link to post
Share on other sites

I have a mission with 40 objectives and it randomly picks one until they are all done.

First make a script called random1.sqf

the code within:

if ((count missions) == 0) then {hint "No more missions"};
_mission = missions select (floor(random(count missions)));

if (_mission == 1) then {[] execVM "mission1.sqf"};
if (_mission == 2) then {[] execVM "mission2.sqf"};
if (_mission == 3) then {[] execVM "mission3.sqf"};
if (_mission == 4) then {[] execVM "mission4.sqf"};
if (_mission == 5) then {[] execVM "mission5.sqf"};
if (_mission == 6) then {[] execVM "mission6.sqf"};
if (_mission == 7) then {[] execVM "mission7.sqf"};
if (_mission == 8) then {[] execVM "mission8.sqf"};
if (_mission == 9) then {[] execVM "mission9.sqf"};
if (_mission == 10) then {[] execVM "mission10.sqf"};
if (_mission == 11) then {[] execVM "mission11.sqf"};
if (_mission == 12) then {[] execVM "mission12.sqf"};
if (_mission == 13) then {[] execVM "mission13.sqf"};
if (_mission == 14) then {[] execVM "mission14.sqf"};
if (_mission == 15) then {[] execVM "mission15.sqf"};
if (_mission == 16) then {[] execVM "mission16.sqf"};
if (_mission == 17) then {[] execVM "mission17.sqf"};
if (_mission == 18) then {[] execVM "mission18.sqf"};
if (_mission == 19) then {[] execVM "mission19.sqf"};
if (_mission == 20) then {[] execVM "mission20.sqf"};
if (_mission == 21) then {[] execVM "mission21.sqf"};
if (_mission == 22) then {[] execVM "mission22.sqf"};
if (_mission == 23) then {[] execVM "mission23.sqf"};
if (_mission == 24) then {[] execVM "mission24.sqf"};
if (_mission == 25) then {[] execVM "mission25.sqf"};
if (_mission == 26) then {[] execVM "mission26.sqf"};
if (_mission == 27) then {[] execVM "mission27.sqf"};
if (_mission == 28) then {[] execVM "mission28.sqf"};
if (_mission == 29) then {[] execVM "mission29.sqf"};
if (_mission == 30) then {[] execVM "mission30.sqf"};
if (_mission == 31) then {[] execVM "mission31.sqf"};
if (_mission == 32) then {[] execVM "mission32.sqf"};
if (_mission == 33) then {[] execVM "mission33.sqf"};
if (_mission == 34) then {[] execVM "mission34.sqf"};
if (_mission == 35) then {[] execVM "mission35.sqf"};
if (_mission == 36) then {[] execVM "mission36.sqf"};
if (_mission == 37) then {[] execVM "mission37.sqf"};
if (_mission == 38) then {[] execVM "mission38.sqf"};
if (_mission == 39) then {[] execVM "mission39.sqf"};
if (_mission == 40) then {[] execVM "mission40.sqf"};

missions = missions - [_mission];


In the init.sqf

missions = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40];

Now in the editor create a trigger

in its condition put: missiondone

in its activation put: missiondone=false; nul = [] execvm "random1.sqf";

You will also need a trigger to call the random1 script when the objective is complete

its activation: missiondone=true

you will also need a trigger to start the whole thing off. in its activation: _null = [] execVM "random1.sqf";

you could put this in the init.sqf

BTW I forgot to mention that all the objective info etc should be called within each mission script.

I can post an example of one of these if you need it...

Edited by LockJaw-65-

Share this post


Link to post
Share on other sites

Thanks LockJaw, that's going to be work well for a Police-style mission. Thanks for the help.

Share this post


Link to post
Share on other sites

Simplistic concept:

_missions = [0,1,2,3,4]; // This is just numbers, if you want to use it in conjunction with anything else use different things.
_mission = _missions select (floor(random(count _missions)));

switch (_mission) do {
case 0:
 { player createSimpleTask ["blowshitup"]; };
case 1:
 { player createSimpleTask ["defendstuff"]; };
case 2: 
 { player createSimpleTask ["attackstuff"]; };
case 3:
 { player createSimpleTask ["escortstuff"]; };
case 5:
 { player createSimpleTask ["insertstuff"]; };
};

Edit however you like. If you want to use the _missions in another way you can do so but remember to change things accordingly.

And please don't use if statements for random selections, it just makes stuff overly complicated and slow.

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  

×