Jump to content
Sign in to follow this  
s13ep

Random Respawn

Recommended Posts

http://i.imgur.com/IgODXJ6.png (268 kB)

I want to know how to make a random respawn occur when I click the mission button on a dialog, below I have presented my script for 4 objectives I have created: I would like one to spawn randomly. How would I do this?

//mission1

//mission2
_mission2patrol = [(getMarkerPos "mission2_patrol"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2patrol1 = [(getMarkerPos "mission2_patrol_1"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2inf = [(getMarkerPos "mission2_inf"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2inf1 = [(getMarkerPos "mission2_inf_1"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2inf2 = [(getMarkerPos "mission2_inf_2"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2inf3 = [(getMarkerPos "mission2_inf_3"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2ifrit = [(getMarkerPos "mission2_ifrit"), 180, "O_MRAP_02_hmg_F", EAST] call BIS_fnc_spawnVehicle;

//mission3
_mission3patrol = [(getMarkerPos "mission3_patrol"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3patrol = [(getMarkerPos "mission3_patrol_1"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3inf = [(getMarkerPos "mission3_inf"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3inf1 = [(getMarkerPos "mission3_inf_1"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3inf2 = [(getMarkerPos "mission3_inf_2"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3inf3 = [(getMarkerPos "mission3_inf_3"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3tigris = [(getMarkerPos "mission3_tigris"), 180, "O_APC_Tracked_02_AA_F", EAST] call BIS_fnc_spawnVehicle;

//mission4
_mission4patrol = [(getMarkerPos "mission4_patrol"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4patrol1 = [(getMarkerPos "mission4_patrol_1"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4inf = [(getMarkerPos "mission4_inf"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4inf1 = [(getMarkerPos "mission4_inf_1"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4inf2 = [(getMarkerPos "mission4_inf_2"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4inf3 = [(getMarkerPos "mission4_inf_3"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4hellcat = [(getMarkerPos "mission4_hellcat"), 180, "O_Heli_Attack_02_F", EAST] call BIS_fnc_spawnVehicle;

//mission5
_mission5patrol = [(getMarkerPos "mission5_patrol"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5patrol = [(getMarkerPos "mission5_patrol_1"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5inf = [(getMarkerPos "mission5_inf"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5inf1 = [(getMarkerPos "mission5_inf_1"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5inf2 = [(getMarkerPos "mission5_inf_2"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5inf3 = [(getMarkerPos "mission5_inf_3"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5ifrit = [(getMarkerPos "mission5_ifrit"), 180, "O_MRAP_02_gmg_F", EAST] call BIS_fnc_spawnVehicle;
_mission5ifrit = [(getMarkerPos "mission5_ifrit_1"), 180, "O_MRAP_02_hmg_F", EAST] call BIS_fnc_spawnVehicle;
_mission5ifrit = [(getMarkerPos "mission5_ifrit_2"), 180, "O_MRAP_02_hmg_F", EAST] call BIS_fnc_spawnVehicle;
_mission5tigris = [(getMarkerPos "mission5_tigris"), 180, "O_APC_Tracked_02_AA_F", EAST] call BIS_fnc_spawnVehicle;

Share this post


Link to post
Share on other sites

easiest way would be to create an addaction somewhere like on the flagpole and have it call an script where you use a randomnize function.

something like

flag1 addaction ["mission generator",["missionrandomgen.sqf"]];

missionrandomgen.sqf

_mission = ["Mission1","Mission2","Mission3","Mission4","Mission5"] call BIS_fnc_selectRandom;

_mission setTaskState "assigned";

not sure if this will work as I'm not on my pc at the moment to test it but this seems to be the easiest way

Share this post


Link to post
Share on other sites

I'm quite new to editing in general, so I kind of see where your coming from but it doesn't yet translate.

How would I group the entire set of spawns for each mission as "Mission1", "Mission2", etc?

Share this post


Link to post
Share on other sites

You really should use different scripts for different missions. Just as an extra question does it need to be MP compatible?

mission2.sqf

_mission2patrol = [(getMarkerPos "mission2_patrol"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2patrol1 = [(getMarkerPos "mission2_patrol_1"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2inf = [(getMarkerPos "mission2_inf"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2inf1 = [(getMarkerPos "mission2_inf_1"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2inf2 = [(getMarkerPos "mission2_inf_2"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2inf3 = [(getMarkerPos "mission2_inf_3"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission2ifrit = [(getMarkerPos "mission2_ifrit"), 180, "O_MRAP_02_hmg_F", EAST] call BIS_fnc_spawnVehicle;

mission3.sqf

_mission3patrol = [(getMarkerPos "mission3_patrol"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3patrol = [(getMarkerPos "mission3_patrol_1"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3inf = [(getMarkerPos "mission3_inf"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3inf1 = [(getMarkerPos "mission3_inf_1"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3inf2 = [(getMarkerPos "mission3_inf_2"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3inf3 = [(getMarkerPos "mission3_inf_3"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission3tigris = [(getMarkerPos "mission3_tigris"), 180, "O_APC_Tracked_02_AA_F", EAST] call BIS_fnc_spawnVehicle;

mission4.sqf

_mission4patrol = [(getMarkerPos "mission4_patrol"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4patrol1 = [(getMarkerPos "mission4_patrol_1"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4inf = [(getMarkerPos "mission4_inf"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4inf1 = [(getMarkerPos "mission4_inf_1"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4inf2 = [(getMarkerPos "mission4_inf_2"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4inf3 = [(getMarkerPos "mission4_inf_3"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission4hellcat = [(getMarkerPos "mission4_hellcat"), 180, "O_Heli_Attack_02_F", EAST] call BIS_fnc_spawnVehicle;

mission5.sqf

_mission5patrol = [(getMarkerPos "mission5_patrol"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5patrol = [(getMarkerPos "mission5_patrol_1"), EAST, ["O_recon_TL_F" ,"O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_exp_F", "O_recon_medic_F", "O_recon_LAT_F", "O_recon_M_F", "O_recon_F", "O_recon_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5inf = [(getMarkerPos "mission5_inf"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5inf1 = [(getMarkerPos "mission5_inf_1"), EAST, ["O_recon_TL_F", "O_recon_LAT_F", "O_recon_medic_F", "O_recon_JTAC_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5inf2 = [(getMarkerPos "mission5_inf_2"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5inf3 = [(getMarkerPos "mission5_inf_3"), EAST, ["O_recon_TL_F", "O_recon_JTAC_F", "O_recon_JTAC_F", "O_recon_M_F"], [], [], [], [], [], 180] call BIS_fnc_spawnGroup;
_mission5ifrit = [(getMarkerPos "mission5_ifrit"), 180, "O_MRAP_02_gmg_F", EAST] call BIS_fnc_spawnVehicle;
_mission5ifrit = [(getMarkerPos "mission5_ifrit_1"), 180, "O_MRAP_02_hmg_F", EAST] call BIS_fnc_spawnVehicle;
_mission5ifrit = [(getMarkerPos "mission5_ifrit_2"), 180, "O_MRAP_02_hmg_F", EAST] call BIS_fnc_spawnVehicle;
_mission5tigris = [(getMarkerPos "mission5_tigris"), 180, "O_APC_Tracked_02_AA_F", EAST] call BIS_fnc_spawnVehicle;

init.sqf

myMission = (["mission1","mission2","mission3","mission4","mission5"]) call BIS_fnc_selectRandom;
switch(myMission) do
{
case "mission1": {execVM "mission1.sqf";}; //no mission 1 code was posted, if thats the case then remove it from here and the above array
case "mission2": {execVM "mission2.sqf";};
case "mission3": {execVM "mission3.sqf";};
case "mission4": {execVM "mission4.sqf";};
case "mission5": {execVM "mission5.sqf";};
};

Share this post


Link to post
Share on other sites

Yes it does and thanks for the information. ^

Share this post


Link to post
Share on other sites

as an extension you can use something like this to create tasks:

["tsk2",west,["describe your task","Do something","DO SOMETHING"],(getMarkerPos "mission2_inf_1"),"ASSIGNED",1,False,True] spawn BIS_fnc_setTask; //task identity, side to receive task, [task name description and waypoint name,position-object-or-marker-positon,"task-state",task priority,show notifcation?, send to all clients in MP?] call BIS_fnc_setTask;

to complete simply change the task state string to SUCCEEDED.

Share this post


Link to post
Share on other sites

It worked great, thank you.

I will now like to make it so that, upon spawning randomly a group, another group cannot be spawned for a short-delay.

This will prevent players spamming the "Accept" button and spawning multiple groups.

And how would I add a timer to missions?

Here is my dialogs.hpp

class SXDialog
{
   idd = 1;
   movingenable = false;


   class Controls
   {

////////////////////////////////////////////////////////
// GUI EDITOR OUTPUT START (by Shannon, v1.063, #Gecoha)
////////////////////////////////////////////////////////

class Back1: IGUIBack
{
idc = 2200;
x = 0.298906 * safezoneW + safezoneX;
y = 0.236 * safezoneH + safezoneY;
w = 0.402187 * safezoneW;
h = 0.506 * safezoneH;
};
class Frame1: RscFrame
{
idc = 1800;
x = 0.298906 * safezoneW + safezoneX;
y = 0.236 * safezoneH + safezoneY;
w = 0.402187 * safezoneW;
h = 0.506 * safezoneH;
};
class Button1: RscButton
{
idc = 1600;
text = "Accept"; //--- ToDo: Localize;
x = 0.298906 * safezoneW + safezoneX;
y = 0.753 * safezoneH + safezoneY;
w = 0.0670312 * safezoneW;
h = 0.022 * safezoneH;
action = execVM "randommission.sqf" //MY OWN ATTEMPT
};
class Button2: RscButton
{
idc = 1601;
text = "Decline"; //--- ToDo: Localize;
x = 0.634062 * safezoneW + safezoneX;
y = 0.753 * safezoneH + safezoneY;
w = 0.0670312 * safezoneW;
h = 0.022 * safezoneH;
};
class Text1: RscStructuredText
{
idc = 1100;
text = "Hello Soldier. Do you accept Random Mission?"; //--- ToDo: Localize;
x = 0.298906 * safezoneW + safezoneX;
y = 0.236 * safezoneH + safezoneY;
w = 0.201094 * safezoneW;
h = 0.022 * safezoneH;
};
class Text2: RscStructuredText
{
idc = 1101;
text = "Accept or Decline?"; //--- ToDo: Localize;
x = 0.298906 * safezoneW + safezoneX;
y = 0.72 * safezoneH + safezoneY;
w = 0.0876563 * safezoneW;
h = 0.022 * safezoneH;
};
////////////////////////////////////////////////////////
// GUI EDITOR OUTPUT END
////////////////////////////////////////////////////////


}
}

myMission = (["mission2","mission3","mission4","mission5"]) call BIS_fnc_selectRandom;
switch(myMission) do
{
case "mission2": {execVM "mission2.sqf";};
case "mission3": {execVM "mission3.sqf";};
case "mission4": {execVM "mission4.sqf";};
case "mission5": {execVM "mission5.sqf";};
};

Edited by s13ep

Share this post


Link to post
Share on other sites

If it needs to work in MP as well. Then make the server do the random and spawning. Client(s) should only "order" a mission from the server. Once a client orders and accepts a new mission, the server would either disable ordering until the current is done or for a predefined amount of time.

Oh and that switch is not needed.

execvm (["mission2.sqf","mission3.sqf","mission4.sqf","mission5.sqf"] call BIS_fnc_selectRandom);

Share this post


Link to post
Share on other sites

http://i.imgur.com/BzSoXN0.jpg (151 kB)

I'm lost, though you probably described it perfectly ~my lack of experience.

At the moment I have RADIO BRAVO trigger allowing access to a dialog [ presented above ]; when a client clicks "Accept" a mission is given.

It works well in editor, will this not carry on into multiplayer?

How would I make the server do the random and spawning, and clients order it?

Share this post


Link to post
Share on other sites
http://i.imgur.com/BzSoXN0.jpg (151 kB)

I'm lost, though you probably described it perfectly ~my lack of experience.

At the moment I have RADIO BRAVO trigger allowing access to a dialog [ presented above ]; when a client clicks "Accept" a mission is given.

It works well in editor, will this not carry on into multiplayer?

How would I make the server do the random and spawning, and clients order it?

simply drop what would be in init.sqf and put it into a new file called initServer.sqf, anything in here will only run on the server, which is fine since many commands have their effects broadcast across the network. To make clients order it you will need to use BIS_fnc_MP to tell the server to give you a mission, in the end, the server will do all the 'building' and the client simply will see a mission appear on the map for them to go do.

no time to do code

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  

×