ios 10 Posted March 26, 2011 Here my question, I want to do a mission with a system of random target system, but once the first goal was accomplished, I will like the following random takes into account what was the first target, cause I have one chance in four that The second objective be the first. here the script i actually use : if (! isServer) exitwith {}; // NOTE: in multiplayer, only server should create random numbers. // Pick Location /////////////////////////////////////////////////////////////////////// n1 = round ((random 13) + 0.5); // generates random number from 1 to 1" if (n1 == 1) then { target2 = "RU_WarfareBAntiAirRadar" createVehicle (getMarkerPos "t_14"); task2 = player createSimpleTask ["Cible Principal : Grishino"]; task2 setSimpleTaskDescription ["*Reprener Grishino*", "*Cible Principal : Grishino*", "*Cible Principal : Grishino*"]; task2 SetSimpleTaskDestination (getMarkerPos "x_14"); player setCurrentTask task2; [task2] call mk_fTaskHint; playsound "mission"; execVM "Random\Main_14\Random_Next_1.sqf"; execVM "Trigger\Trigger_Grish.sqf"; }; if (n1 == 2) then { target1 = "RU_WarfareBAntiAirRadar" createVehicle (getMarkerPos "t_2"); task1 = player createSimpleTask ["Cible Principal : Elektrozavodsk"]; task1 setSimpleTaskDescription ["*Reprener Elektrozavodsk*", "*Cible Principal : Elektrozavodsk*", "*Cible Principal : Elektrozavodsk*"]; task1 SetSimpleTaskDestination (getMarkerPos "x_2"); player setCurrentTask task1; [task1] call mk_fTaskHint; playsound "mission"; execVM "Random\Main_2\Random_Next_1.sqf"; execVM "Trigger\Trigger_Elek.sqf"; }; if (n1 == 3) then { target1 = "RU_WarfareBAntiAirRadar" createVehicle (getMarkerPos "t_3"); task1 = player createSimpleTask ["Cible Principal : Tchernogorsk"]; task1 setSimpleTaskDescription ["*Reprener Tchernogorsk*", "*Cible Principal : Tchernogorsk*", "*Cible Principal : Tchernogorsk*"]; task1 SetSimpleTaskDestination (getMarkerPos "x_3"); player setCurrentTask task1; [task1] call mk_fTaskHint; playsound "mission"; execVM "Random\Main_3\Random_Next_1.sqf"; execVM "Trigger\Trigger_Tcherno.sqf"; }; if (n1 == 4) then { target1 = "RU_WarfareBAntiAirRadar" createVehicle (getMarkerPos "t_4"); task1 = player createSimpleTask ["Cible Principal : Komarovo"]; task1 setSimpleTaskDescription ["*Reprener Komarovo*", "*Cible Principal : Komarovo*", "*Cible Principal : Komarovo*"]; task1 SetSimpleTaskDestination (getMarkerPos "x_4"); player setCurrentTask task1; [task1] call mk_fTaskHint; playsound "mission"; execVM "Random\Main_4\Random_Next_1.sqf"; execVM "Trigger\Trigger_Koma.sqf"; }; i hope someone can help ! thanks in advance. Share this post Link to post Share on other sites
Melmarkian 11 Posted March 27, 2011 This is how I would do it. Don´t know if it is good way but it works: It just chooses the tasks that are not set to true. In your .sqf which include the mission you can set the variable to true. It will then begin to search for a new one. if (! isServer) exitwith {}; // NOTE: in multiplayer, only server should create random numbers. taskscompletedcount = 0; firsttask = false; secondtask = false; thirdtask = false; fourthtask = false; // Pick Location /////////////////////////////////////////////////////////////////////// while {taskscompletedcount < 4} do { n1 = round ((random 13) + 0.5); // generates random number from 1 to 1" if (n1 == 1 AND !firsttask) then { hint "Task 1 is now active"; sleep 10; waitUntil {firsttask}; hint "Task1 completed"; taskscompletedcount = taskscompletedcount + 1; }; if (n1 == 2 AND !secondtask) then { hint "Task 2 is now active"; sleep 10; waitUntil {secondtask}; hint "Task2 completed"; taskscompletedcount = taskscompletedcount + 1; }; if (n1 == 3 AND !thirdtask) then { hint "Task 3 is now active"; sleep 10; waitUntil {thirdtask}; hint "Task3 completed"; taskscompletedcount = taskscompletedcount + 1; }; if (n1 == 4 AND !fourthtask) then { hint "Task 4 is now active"; sleep 10; waitUntil {fourthtask}; hint "Task4 completed"; taskscompletedcount = taskscompletedcount + 1; }; }; hint "All done"; Share this post Link to post Share on other sites
igneous01 19 Posted March 27, 2011 you could use an FSM by getting a random number in a trigger or init, and link the react with condition nl == 1 or 2, and create all the tasks and objectives in that. Might be easier for you later on, in case you want to reward/punish a player and give dynamic choices in the future. Share this post Link to post Share on other sites
ios 10 Posted March 27, 2011 a big thank you to you both! my problem is solved thanks to you! Share this post Link to post Share on other sites