Jump to content
Sign in to follow this  
lockjaw-65-

Random tasks by radio

Recommended Posts

Hi all. I am hoping that somebody can help with this? I have a mission with about 10 different tasks, these are all visible on the radio and at the moment you select one to activate that mission. I am wanting to call on the radio and recieve one of these missions randomly. the other missions will not be visible on the radio until the last one is complete then it will give another upon a radio call. Has anybody got a script to do this or can any help Thanks...

Share this post


Link to post
Share on other sites

You can use:

1 setRadioMsg "NULL";

When you want to show the radio again:

1 setRadioMsg "Radio Text";

Share this post


Link to post
Share on other sites

missions =[mission1,mission2,mission3,mission4,mission5]
?(count missions) == 0: Hint "No more missions"; Exit
_mission = missions select (floor random count missions)

?_mission == mission1:[] exec "mission1.sqs"
?_mission == mission2:[] exec "mission2.sqs"
?_mission == mission3:[] exec "mission3.sqs"
?_mission == mission4:[] exec "mission4.sqs"
?_mission == mission5:[] exec "mission5.sqs"
missions=missions-[_mission]

Thats shooting from the hip, but it should work. Just have the trigger with the radio action set on repeatedly, and itll execute until theres no more missions left

Edited by Combat-Agent

Share this post


Link to post
Share on other sites

Write in sqf! it's better!

Anyway there is an error:

_mission = missions select (floor random (count missions - 1))

Because the command "count missions" returns 5 but select 5 of the array doesn't exist ;)

Share this post


Link to post
Share on other sites

info on floor count command:

_array = [1,2,3,4,5];

count _array will return 5.

random count _array will return a number between 0.0000 - 0,49999

if you use floor on any decimal number it will always take the downward whole number, 3,99 will be 3, 2,1 will be 2 etc.

floor random count _array will return one of these: 0,1,2,3,4

meaning that you can properly use select command on the array floor random count.

proper execution:

_array = [1,2,3,4,5];
_selector = (floor(random(count _array)));
_myNumber = _array select _selector;

Share this post


Link to post
Share on other sites

Wow! thanks guys for your replys, I have been very busy since I posted and not had chance to check forum. Going to play around now and I will get back to you Thanks :)

---------- Post added at 08:28 AM ---------- Previous post was at 08:05 AM ----------

@ Demonized, is that code to replace the beginning of the script or is that the call from radio trigger. Sorry but im a bit confused with the different posts?

Share this post


Link to post
Share on other sites

@LockJaw-65-

No it was directed at Giallustio who used -1 in his select, wich would exclude the last mission everytime, you would never see it.

what Combat-Agent posted was correct, i use paranteces to seperate but i dont think you have to.

but as he also said, its better to use sqf, but sqs works fine to, here is a sqf version of what Combat-Agent posted, it does the ecxact same thing just in another format, .sqf:

missions = [1,2,3,4,5]
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"};  // this is how .sqf is executed with execVM
if (_mission == 5) then {[] exec "mission5.sqs"};  // this is how sqs is executed with exec
missions = missions - [_mission];

note that you can use both sqs and sqf in your missions, sqs is the old, sqf is the new, some small differences but both work.

also note i changed mission1 to number 1, it makes no difference (other than shorter script) since we check for number 1 instead of mission1, you can use dogPoo1 and check for that too, and it will work ;)

Edited by Demonized

Share this post


Link to post
Share on other sites

Just posted as you replied, thanks I am trying it now :)

Edited by LockJaw-65-

Share this post


Link to post
Share on other sites

then your missions have something wrong in them probably, here is to test what would work:

create 5 .sqf scripts, call them mission1.sqf, mission2.sqf, mission3.sqf, mission4.sqf, mission5.sqf

in each put the coresponding number:

hint "this is mission 1";

repeat for 2 to 5 with their number.

now make a 6th script and save it as random.sqf

put this in it:

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"};
missions = missions - [_mission];

and in a repeated radio trigger with 1 second delay place this:

_null = [] execVM "random.sqf";

and in your unit initline or init.sqf place this:

missions = [1,2,3,4,5]

now activate the radio trigger and you should get the hint with the number until no more missions are available.

edit: did not see your reply when i made this post.

Share this post


Link to post
Share on other sites

Thanks to you all, I have it working now althought there was a missing ; after missions = [1,2,3,4,5]

But I worked it out.

I have the radio trigger set to once to call the mission script, I presume that when the first mission is complete it will automatically call the next?

Thanks.

@Demonized lol I have done it again posted before I have seen your reply. Many thanks for your help with this, I am going to spend a bit of time trying all this out now in my actual mission before I post again

Edited by LockJaw-65-

Share this post


Link to post
Share on other sites
Thanks to you all, I have it working now althought there was a missing ; after missions = [1,2,3,4,5]

But I worked it out.

I have the radio trigger set to once to call the mission script, I presume that when the first mission is complete it will automatically call the next?

Thanks

lol, no, you have to call the mission again when you need one, most likely would be wise to do it in the creation of your mission, add a end condition or check and then when that is completed, create a new one again (sam as running the trigger).

the trigger thing was just to demo it or you, it would be bad in a mission to actually have to start them yourselves, unless thats the intent and what you are going for ofc..

Share this post


Link to post
Share on other sites

@Demonized

You're right :) My fault, sorry guys...I read round instead floor

Edited by Giallustio

Share this post


Link to post
Share on other sites

Hi, this all works great but I do have one more question that has arisen. when I have completed one of the random missions I have a trigger which ececutes the next random mission. In the activation field I have this:

Obj1 setTaskState "SUCCEEDED"; hint "Objective Complete, the AA Battery is destroyed"; "objmk1" setMarkerAlpha 0; nul = [] execvm "missions.sqf";

What I need is a delay after the mission ends and before it executes the mission.sqf.

I know this is proberbly a simple thing but I cant work it out?

Share this post


Link to post
Share on other sites

easy... add:

missiondone=true; publicvariable "missiondone";

add new trigger with 60|60|60 sec timeout and init line should state only missiondone instead of this. When 60 seconds is reached on Act should be:

nul = [] execvm "missions.sqf";

Share this post


Link to post
Share on other sites

IceBreakr thanks very much, did just what you said and it works perfect :)

Share this post


Link to post
Share on other sites

just got to stage where my mission is complete but I have come across a problem. I have a trigger that activates the first mission when game starts. when i complete the first random task everything works ok, the 60 second delay works fine and the next random mission shows and that all works fine. The problem is after completeing the second mission nothing else happens??

Share this post


Link to post
Share on other sites

make the trigger repeated and reset the missiondone variable:

condition of trigger:

missiondone

on act:

missiondone=false; nul = [] execvm "missions.sqf";

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  

×