Welcome to the Iron Front Fan Forums!
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
Tayuk

Avatar / Picture

Retired Admin/IFR
Registered:
Posts: 456
Reply with quote  #1 
Here is method shown to me by [EVO] Dan on the official forums to call missions randomly in single player.

Open the editor, place a player and 3 other units, should be friendly units for the purpose of this example, ungroup all the units. Then name the 3 non playable units Dave, John and Peter.
This code can be put in your init.sqf to select the 1st mission. This example is based on 3 missions.
init.sqf
myMissions = ["missions\mission1.sqf", "missions\mission2.sqf", "missions\mission3.sqf"];
curMission = myMissions select floor random count myMissions; //this selects a mission from the array pool
[] execVM curMission; //executes the chosen mission
myMissions = myMissions - [curMission];
curMission = 0;


Then just for tidyness create a folder within your mission folder called missions, this is where the 3 mission script files will go as well as this script called "NewMissionCall.sqf".
NewMissionCall.sqf
curMission = myMissions select floor random count myMissions; //this selects a mission from the array pool
[] execVM curMission; //executes the chosen mission
myMissions = myMissions - [curMission];
curMission = 0;


Then the 3 mission files:-
Mission1.sqf
waitUntil { !isNil {player} };
waitUntil { player == player };


HINT "Mission Kill Dave has been Accepted. Check your tasks for briefing.";
task1 = player createSimpleTask["Task1"];
task1 setSimpleTaskDescription["Kill <marker name='task1'>Dave</marker> now.<br/><br/>", "Dave", "Dave"];
task1 setSimpleTaskDestination (getPos Dave);


Mission2.sqf
waitUntil { !isNil {player} };
waitUntil { player == player };


HINT "Mission Kill John has been Accepted. Check your tasks for briefing.";
task2 = player createSimpleTask["Task2"];
task2 setSimpleTaskDescription["Kill <marker name='task2'>John</marker> now.<br/><br/>", "John", "John"];
task2 setSimpleTaskDestination (getPos John);


Mission3.sqf
waitUntil { !isNil {player} };
waitUntil { player == player };


HINT "Mission Kill Peter has been Accepted. Check your tasks for briefing.";
task3 = player createSimpleTask["Task3"];
task3 setSimpleTaskDescription["Kill <marker name='task3'>Peter</marker> now.<br/><br/>", "Peter", "Peter"];
task3 setSimpleTaskDestination (getPos Peter);


You will also need 3 triggers all 3 triggers can be size 0, 0.
trigger1
Condition
not alive dave

OnActivation
task1 setTaskState "SUCCEEDED"; taskhint ["Mission completed, you have killed Dave.", [0, 1, 0, 1], "taskDone"]; nul=[this] execVM "Missions\NewMissioncall.sqf"


trigger2
Condition
not alive John

OnActivation
task2 setTaskState "SUCCEEDED"; taskhint ["Mission completed, you have killed John.", [0, 1, 0, 1], "taskDone"]; nul=[this] execVM "Missions\NewMissioncall.sqf"


trigger3
Condition
not alive peter

OnActivation
task3 setTaskState "SUCCEEDED"; taskhint ["Mission completed, you have killed Peter.", [0, 1, 0, 1], "taskDone"]; nul=[this] execVM "Missions\NewMissioncall.sqf"



When the 1st randomly selected mission is complete the next mission will be randomly selected from whats left. More missions can be added in the same way the above 3 are. The same mission isn't called twice as its removed from the mission list [array in the init.sqf] after completion.
0
[EVO] Dan

Sergeant
Registered:
Posts: 85
Reply with quote  #2 

It is also worth mentioning that this may not work in multiplayer mission Tay. (or rather it will, but with random results) You have no way in that of syncing the current mission with the client, so everyone will make the decision independantly, and of course you might end up with multiple spawns of each thing.

0
Tayuk

Avatar / Picture

Retired Admin/IFR
Registered:
Posts: 456
Reply with quote  #3 
Well you just have and I have edited the original post too, thanks. But since your here, how would we go about sorting it for mutiplayer?

And also another question on the same. say for instance we had 10 missions and to complete a session so to speak we had to do 3 of them, could a mission end trigger be created to end the mission after 3 out of the 10 had been completed?
0
[EVO] Dan

Sergeant
Registered:
Posts: 85
Reply with quote  #4 

I had a mission made up that could show you the basic's of mp sync.

https://dl.dropbox.com/u/28062918/schwerepunkt_0_2.Baranow.rar

Inside of that mission should be an explaination roughly the same as yours, but with MP sync included. Feel free to ask if you get stuck.

On the second one, I will have to get back to you about it for a proper explanation but basicly you could get the size of the array, and when it was less then 7 (so you start with 10, complete 3), and then have it tirgger of the end via scripting commands once this condition is true.

0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.