Announcement

Collapse
No announcement yet.

Mission Generator

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [GUIDE] Mission Generator

    this script generates 4 different kinds of missions (air assault missions, {CAP,SEAD,CAS,Surgical Strike}).

    for this to work, you need to have some markers down on the map. it can be any amount and they can be named anything, and you also need to declare their array to the variable _locs and set _locs = locs_old, and _tasknum = 0. you will pass these into the .sqf when you run it. i will also have all the vehicle class names in pre-declared arrays.

    heres the init (with example _locs, change it to your marker names):
    Code:
    airfields = ["1","2","3","4","5"];
    _locs = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
    _stan_o_veh = ["O_APC_Tracked_02_cannon_F","O_MRAP_02_hmg_F","O_MRAP_02_gmg_F","O_Truck_02_Ammo_F","O_Truck_02_medical_F","O_MBT_02_cannon_F"];
    _aa_o_veh = ["O_APC_Tracked_02_AA_F","O_static_AA_F","O_MRAP_02_hmg_F"];
    _jet_o_veh = ["I_Plane_Fighter_03_CAS_F","I_Plane_Fighter_03_AA_F"];
    _heli_o_veh = ["O_Heli_Light_02_F","O_Heli_Attack_02_F"];
    _inf_o_stan = ["O_Soldier_F","O_Soldier_TL_F","O_medic_F","O_Soldier_AA_F","O_Soldier_AA_F","O_Soldier_sniper_base_F","O_Soldier_AT_F","O_engineer_F"];
    _inf_o_crewman = "O_crew_F";
    _active_o_vehs = [ ];
    _tasknum = 0;
    0 setRainbow 1;
    //cas, sead, surgical, cap,
    list1 = [_locs,_active_o_vehs,_tasknum,_inf_o_crewman,_inf_o_stan,_jet_o_veh,_stan_o_veh,_aa_o_veh];
    
    
    fnc_task_start_yink =
    	{
    	_tasknum = _this select 3;
    	_task = player createSimpleTask [format["Mission %1:%2",_tasknum,(_this select 0)]];
    	_task setSimpleTaskDestination (getmarkerpos (_this select 2));
    	_task setSimpleTaskDescription [(_this select 1), format["Mission %1:%2",_tasknum,(_this select 0)],(_this select 0)];
    	task = _task;
    	hint format["Next Mission:%1",(_this select 0)];
    	//[["CAS","Destroy all ground vehicles"], "fnc_tas_start_yink", true, false] spawn BIS_fnc_MP;
    	};
    
    fnc_task_end_yink = 
    	{
    	_tasknum = _this select 3;
    	(_this select 0) setMarkerColor "colorgreen";
    	(_this select 0) setMarkerText format["Mission %1:Complete",_tasknum];
    	hint format["mission %1 complete! Await new orders...",count (_this select 0)];
    	(_this select 1) setTaskState "Succeeded";
    	//[[_marker,_task,_vehs], "fnc_task_end_yink", true, false] spawn BIS_fnc_MP;
    	};
    	
    	
    	
    if (!(isserver)) exitwith {};
    execVM "resupply.sqf";
    hint "resupply.sqf started";
    sleep 3;
    _nul = list1 execVM "missions.sqf";
    hint "missions.sqf started";
    heres the main code (forewarning: I changed the code to only use local variables to lessen my dependency on globals, but it doesnt change it THAT much...):
    Code:
    //missions.sqf
    
    _ran1 =round(random 3);
    _locs = _this select 0;
    _active_o_vehs = _this select 1;
    _tasknum = _this select 2;
    _inf_o_crewman = _this select 3;
    _inf_o_stan = _this select 4;
    _jet_o_veh = _this select 5;
    _stan_o_veh = _this select 6;
    _aa_o_veh = _this select 7;
    
    
    
    
    if (_ran1==0) then {
    hint "Next Mission:CAS";
    	_tasknum = _tasknum + 1;
    	publicvariable "_tasknum";
    	_active_o_vehs = [];
    	_ran1 = round(random (count _locs)-1);
    	_current_obj = _locs select _ran1;
    	[["CAS","Destroy all ground vehicles",_current_obj,_tasknum], "fnc_task_start_yink", true, false] spawn BIS_fnc_MP;
    	_marker = createmarker [format["Mission%1CAS",_tasknum],(getmarkerpos _current_obj)];
    	_marker setMarkerShape "icon";
    	_marker setMarkerType "mil_dot";
    	_marker setMarkerText format["Mission %1:CAS",_tasknum];
    	_marker setMarkerColor "colorred";
    	_locs = _locs - [_current_obj];
    	_task = task;
    	publicvariable "_locs";
    	_east = creategroup east;
    	_bool = 1;
    	_ran1 = 5 + round(random 8);
    	_vehs = [];
    	_move = "patrol";
    		if ((round(random 1))==0) then
    		{
    		_move = "station";
    		};
    	
    	_amount_inf = round(random 6);
    	_groupinf = creategroup east;
    	_amount_inf = _amount_inf + 8;
    
    	while {_ran1>0} do
    		{
    		_ranpos1 = round(random 300);
    		_ranpos2 = round(random 300);
    		_ran2 = round(random (count _stan_o_veh)-1);
    		_veh = (_stan_o_veh select _ran2) createvehicle (getmarkerpos _current_obj);
    		_vehs = _vehs + [_veh];
    		_inf_o_crewman createunit [getmarkerpos _current_obj, _east,"this moveindriver _veh",(ceil(random 10)*.1), "corporal"];
    		_inf_o_crewman createunit [getmarkerpos _current_obj, _east,"this moveingunner _veh",(ceil(random 10)*.1), "corporal"];	
    		_ran1 = _ran1 - 1;	
    		};
    		
    		while {_amount_inf>0} do 
    			{
    			_ran1 = round(random (count _inf_o_stan)-1);
    			(_inf_o_stan select _ran1) createunit [getmarkerpos _current_obj, _groupinf,"",(ceil(random 10)*.1), "corporal"];
    			_amount_inf = _amount_inf - 1;
    			};
    		_inf_g = units _groupinf;
    		
    		_active_o_vehs = _vehs + _active_o_vehs;
    		_vehs2 = _vehs;
    		
    	if (_move == "patrol") then {
    		hint "patrol";
    				_loc1 = _locs select (round (random (count _locs)-1));
    		
    		(units _east) domove (getmarkerpos (_loc1));
    
    			while {_bool==1} do
    			{
    				{if ((!alive _x)||((count(crew _x))==0)) then
    					{
    					_vehs = _vehs - [_x];
    					};
    				} foreach _vehs;
    			if ((count _vehs)<2) then 
    			{_bool = 0};
    			};
    			};
    						
    	if (_move == "station") then {
    	hint "station";
    			{
    			_ranpos1 = round(random 300);
    			_ranpos2 = round(random 300);
    			_ranvar1 = round(random 1);
    			_ranvar2 = round(random 1);
    			_pos_x = 1;
    			_pos_y = 1;
    			if (_ranvar1 == 0) then {_pos_x = -1};
    			if (_ranvar2 == 0) then {_pos_y = -1};
    			_ranpos1 = _pos_x * _ranpos1;
    			_ranpos2 = _pos_y * _ranpos2;
    			_x domove [((getmarkerpos _current_obj) select 0) + _ranpos1,((getmarkerpos _current_obj) select 1) + _ranpos2];
    			} foreach _vehs;
    			while {_bool==1} do
    			{
    				{if ((!alive _x)||((count(crew _x))==0)) then
    					{
    					_vehs = _vehs - [_x];
    					};
    				} foreach _vehs;
    			if ((count _vehs)<2) then 
    			{_bool = 0};
    			};
    			};
    	waituntil {_bool == 0};
    	[[_marker,_task], "fnc_task_end_yink", true, false] spawn BIS_fnc_MP;
    	{deletevehicle _x} foreach (_vehs2 + _inf_g);
    	};
    
    
    	
    if (_ran1==1) then {
    
    	_tasknum = _tasknum + 1;
    	
    	publicvariable "_tasknum";
    	_active_o_vehs = [];
    	_ran1 = round(random (count _locs)-1);
    	_current_obj = _locs select _ran1;
    	[["SEAD","Destroy all anti-air vehicles",_current_obj,_tasknum], "fnc_task_start_yink", true, false] spawn BIS_fnc_MP;
    	_marker = createmarker [format["Mission%1SEAD",_tasknum],(getmarkerpos _current_obj)];
    	_marker setMarkerShape "icon";
    	_marker setMarkerType "mil_dot";
    	_marker setMarkerText format["Mission %1:SEAD",_tasknum];
    	_marker setMarkerColor "colorred";
    	_locs = _locs - [_current_obj];
    	publicvariable "_locs";
    	_amount = round(random 8);
    	_amount = _amount + 3;
    	_amount_inf = round(random 6);
    	_amount_inf = _amount_inf + 8;
    	_vehs = [];
    	_groupinf = creategroup east;
    	_groupveh = creategroup east;
    	
    	while {_amount>0} do
    		{
    		_ran1 = round(random (count _aa_o_veh)-1);
    		_veh = (_aa_o_veh select _ran1) createvehicle (getmarkerpos _current_obj);
    		
    		_inf_o_crewman createunit [(getmarkerpos _current_obj), _groupveh,"this moveindriver _veh",0.7, "corporal"];
    		_inf_o_crewman createunit [(getmarkerpos _current_obj), _groupveh,"this moveingunner _veh",0.7, "corporal"];
    		
    		_vehs = _vehs + [_veh];
    		_amount = _amount - 1;
    		};
    		
    	while {_amount_inf<0} do 
    			{
    			_ran1 = round(random (count _inf_o_stan)-1);
    			(_inf_o_stan select _ran1) createunit [(getmarkerpos _current_obj), _groupinf,"",0.7, "corporal"];
    			_amount_inf = _amount_inf - 1;
    			};
    		
    	_active_o_vehs = _vehs + _active_o_vehs;
    	_bool = 1;
    	
    			{
    			_ranpos1 = round(random 300);
    			_ranpos2 = round(random 300);
    			_ranvar1 = round(random 1);
    			_ranvar2 = round(random 1);
    			_pos_x = 1;
    			_pos_y = 1;
    			if (_ranvar1 == 0) then {_pos_x = -1};
    			if (_ranvar2 == 0) then {_pos_y = -1};
    			_ranpos1 = _pos_x * _ranpos1;
    			_ranpos2 = _pos_y * _ranpos2;
    			_x domove [((getmarkerpos _current_obj) select 0) + _ranpos1,((getmarkerpos _current_obj) select 1) + _ranpos2];
    			} foreach _vehs;
    	
    			_vehs2 = _vehs;
    	
    			while {_bool==1} do
    			{
    				{
    				if ((!alive _x)||((count(crew _x))==0)) then
    					{
    					_active_o_vehs = _active_o_vehs - [_x];
    					_vehs = _vehs - [_x];
    					};
    				} foreach _vehs;
    				
    			if ((count _vehs)==0) then 
    			{_bool = 0};
    			};
    	
    	waituntil {_bool == 0};
     
    	[[_marker,_task,_vehs], "fnc_task_end_yink", true, false] spawn BIS_fnc_MP;
    	{deletevehicle _x} foreach (_vehs2 + _inf);
    	};
    
    	
    	
    if (_ran1==2) then {
    	_tasknum = _tasknum + 1;
    	publicvariable "_tasknum";
    	hint "Next Mission:CAP";
    	_active_o_vehs = [ ];
    	_ran1 = round(random (count _locs)-1);
    	_current_obj = _locs select _ran1;
    	[["CAP","Destroy all Air vehicles",_current_obj,_tasknum], "fnc_task_start_yink", true, false] spawn BIS_fnc_MP;
    	_marker = createmarker [format["Mission%1CAP",_tasknum],(getmarkerpos _current_obj)];
    	_marker setMarkerShape "icon";
    	_marker setMarkerType "mil_dot";
    	_marker setMarkerText format["Mission %1:CAP",_tasknum];
    	_marker setMarkerColor "colorred";
    	_locs = _locs - [_current_obj];
    	publicvariable "_locs";
    	_amount = round(random 4);
    	_amount = _amount + 6;
    	_array = _jet_o_veh;
    	_groupveh = creategroup east;
    	_vehs = [ ];
    		_move = "patrol";
    		if ((round(random 1))==0) then
    		{
    		_move = "station";
    		};
    		
    	while {_amount>0} do
    		{
    		_ran1 = round(random (count _array)-1);
    		_veh = createvehicle [(_array select _ran1),(getmarkerpos _current_obj),[],200,"FLY"];
    		_veh setpos [(getpos _veh select 0),(getpos _veh select 1),2000];
    		//(_array select _ran1) createvehicle [(getmarkerpos _current_obj) select 0,(getmarkerpos _current_obj) select 1,200];
    		_veh flyinheight 400;
    		_veh setdir (round (random 360));
    		_inf_o_crewman createunit [getmarkerpos _current_obj, _groupveh,"this moveindriver _veh",(ceil(random 10)*.1), "corporal"];
    		if (_veh iskindof "Helicopter") then {
    		_inf_o_crewman createunit [getmarkerpos _current_obj, _groupveh,"this moveingunner _veh",(ceil(random 10)*.1), "corporal"];
    
    		};
    		_vehs = _vehs + [_veh];
    		_amount = _amount - 1;
    		};
    		_active_o_vehs = _vehs + _active_o_vehs;
    		_loc1 = _locs select (round (random (count _locs)-1));
    		_vehs2 = _vehs;
    		_bool = 1;
    		if (_move == "patrol") then {
    		(units _groupveh) domove (getmarkerpos (_loc1));
    		while {_bool==1} do
    			{
    				{
    				if ((!alive _x)||((count(crew _x))==0)) then
    					{
    					_vehs = _vehs - [_x];
    					}
    				} foreach _vehs;
    				
    			if ((count _vehs)==0) then 
    			{_bool = 0};
    			};
    			};
    		if (_move == "station") then {
    			{
    			_ranpos1 = round(random 300);
    			_ranpos2 = round(random 300);
    			_ranvar1 = round(random 1);
    			_ranvar2 = round(random 1);
    			_pos_x = 1;
    			_pos_y = 1;
    			if (_ranvar1 == 0) then {_pos_x = -1};
    			if (_ranvar2 == 0) then {_pos_y = -1};
    			_ranpos1 = _pos_x * _ranpos1;
    			_ranpos2 = _pos_y * _ranpos2;
    			_x domove [((getmarkerpos _current_obj) select 0) + _ranpos1,((getmarkerpos _current_obj) select 1) + _ranpos2];
    			} foreach _vehs;
    			while {_bool==1} do
    			{
    				{
    				if ((!alive _x)||((count(crew _x))==0)) then
    					{
    					_vehs = _vehs - [_x];
    					_active_o_vehs = _active_o_vehs - [_x];
    					};
    				} foreach _vehs;
    			
    			if ((count _vehs)==0) then 
    			{_bool = 0};
    			};
    			};
    			waituntil {_bool==0};
    			[[_marker,_task,_vehs], "fnc_task_end_yink", true, false] spawn BIS_fnc_MP;
    	{deletevehicle _x} foreach (_vehs2);
    	};
    
    	
    	
    if (_ran1==3) then {
    _tasknum = _tasknum + 1;
    	publicvariable "_tasknum";
    	hint "Next Mission:SURGICAL STRIKE";
    	_active_o_vehs = [];
    	_ran1 = round(random (count _locs)-1);
    	_current_obj = _locs select _ran1;
    	[["SURGICAL","Destroy the Radio Tower",_current_obj,_tasknum], "fnc_task_start_yink", true, false] spawn BIS_fnc_MP;
    	_marker = createmarker [format["Mission%1SURG",_tasknum],(getmarkerpos _current_obj)];
    	_marker setMarkerShape "icon";
    	_marker setMarkerType "mil_dot";
    	_marker setMarkerText format["Mission %1:SURG",_tasknum];
    	_marker setMarkerColor "colorred";
    	_locs = _locs - [_current_obj];
    	publicvariable "_locs";
    	_east = creategroup east;
    	_ran1 = 5 + round(random 8);
    	_vehs = [];
    	_tower = "Land_TTowerBig_2_F" createvehicle [(getmarkerpos _current_obj) select 0,(getmarkerpos _current_obj) select 1,5];
    	hint format["%1", damage _tower];
    	_move = "patrol";
    		if ((round(random 1))==0) then
    		{
    		_move = "station";
    		};
    	
    	_amount_inf = round(random 6);
    	_groupinf = creategroup east;
    	_amount_inf = _amount_inf + 8;
    
    	while {_ran1>0} do
    		{
    		_ranpos1 = round(random 50);
    		_ranpos2 = round(random 50);
    		_ran2 = round(random (count _stan_o_veh)-1);
    		_veh = (_stan_o_veh select _ran2) createvehicle (getmarkerpos _current_obj);
    		_vehs = _vehs + [_veh];
    		_inf_o_crewman createunit [getmarkerpos _current_obj, _east,"this moveindriver _veh",(ceil(random 10)*.1), "corporal"];
    		_inf_o_crewman createunit [getmarkerpos _current_obj, _east,"this moveingunner _veh",(ceil(random 10)*.1), "corporal"];
    		_ran1 = _ran1 - 1;
    		};
    		
    		while {_amount_inf>0} do 
    			{
    			_ran1 = round(random (count _inf_o_stan)-1);
    			(_inf_o_stan select _ran1) createunit [getmarkerpos _current_obj, _groupinf,"",(ceil(random 10)*.1), "corporal"];
    			_amount_inf = _amount_inf - 1;
    			};
    		
    		_active_o_vehs = _vehs + _active_o_vehs;
    		_vehs2 = _vehs;
    			
    
    			{
    			_ranpos1 = round(random 300);
    			_ranpos2 = round(random 300);
    			_ranvar1 = round(random 1);
    			_ranvar2 = round(random 1);
    			_pos_x = 1;
    			_pos_y = 1;
    			if (_ranvar1 == 0) then {_pos_x = -1};
    			if (_ranvar2 == 0) then {_pos_y = -1};
    			_ranpos1 = _pos_x * _ranpos1;
    			_ranpos2 = _pos_y * _ranpos2;
    			_x domove [((getmarkerpos _current_obj) select 0) + _ranpos1,((getmarkerpos _current_obj) select 1) + _ranpos2];
    			} foreach _vehs;
    	waituntil {!alive _tower};
    	[[_marker,_task,_vehs,_tasknum], "fnc_task_end_yink", true, false] spawn BIS_fnc_MP;
    
    	{deletevehicle _x} foreach _vehs2;	
    	};
    
    list1 = [_locs,_active_o_vehs,_tasknum,_inf_o_crewman,_inf_o_stan,_jet_o_veh,_stan_o_veh,_aa_o_veh];
    	
    	
    if ((count _locs)<=0) then {_locs = locs_old};
    now, each mission will have have to be generated 1 by 1 (they wont start if you complete one).
    you could put them on a timer like this:

    timer.sqf
    Code:
    _yink = 58;
    _awesome = 58;
    while {_yink==_awesome} do
    {
    sleep 600;
    nul = list1 execVM "missions.sqf";
    };
    or you could do an addaction on a box:
    Code:
    this addaction ["Mission Start","missionstart.sqf"];
    the reason we use another script to start the missions.sqf is because if you pass arguments from addaction they are stored in _this select 3 (argument array). you would have to rewrite missions.sqf (and we wouldnt want to do that)

    here is missionstart.sqf:
    Code:
    _nul = list1 execVM "missions.sqf";
    any questions will be answered, and script modifications will be honored.
    Last edited by Yink; 01-18-2014, 06:34 PM.
    Yink | Vanilla Pilot | Killer of Stirling | CS GOD | Projects Team

Connect

Collapse

TeamSpeak 3 Server

Collapse

Advertisement

Collapse

Twitter Feed

Collapse

Working...
X