Jump to content
Sign in to follow this  
Kolmain

Custom Dynamic Side Missions

Recommended Posts

So i've got a system that runs every 10 minutes that either execVM's a side mission, nothing, or a new vehicle (each different scripts). The nothing script works, but the others dont. Any ideas?

// rtd.sqf
// select random script
_source = centermarker select 0; //centermarker is in center of zargabad
_radius = 800;
_mission = switch (floor random(3)) do {
// radio tower stuff 
case 0: {"missions\nothing.sqf"};
// scud launcher stuff
case 1: {"spawnVehicle.sqf"};
// suicide bomber stuff
case 2: {"pickMission.sqf"};
};
_nul = [_source, _radius] execVM _mission

this random part works, its the actual mission/vehicle scripts that dont.

// spawnVehicle.sqf
_airlist =["AH64D_EP1","AH6J_EP1","CH_47F_EP1","MH6J_EP1","UH60M_EP1","UH60M_MEV_EP1"];
_groundlist = ["HMMWV_DES_EP1","HMMWV_MK19_DES_EP1","HMMWV_TOW_DES_EP1","HMMWV_M998_crows_M2_DES_EP1","HMMWV_M998_crows_MK19_DES_EP1","HMMWV_M1151_M2_DES_EP1","HMMWV_Avenger_DES_EP1","MTVR_DES_EP1","M1A1_US_DES_EP1","M1A2_US_TUSK_MG_EP1","MLRS_DES_EP1","M2A2_EP1","M2A3_EP1","M6_EP1","M1135_ATGMV_EP1","M1130_CV_EP1","M1126_ICV_M2_EP1","M1126_ICV_mk19_EP1","M1129_MC_EP1","M1128_MGS_EP1"];
hint "New Vehicle Enroute";
if (isServer) then {

if (floor (random 3) == 2) then {nul0
 _veh = (_airlist select (floor random count _airlist - 1) );
} else {
 _veh = (_groundlist select (floor random count _groundlist - 1) );
};

_newveh = [position "spawnVehicle", 180, _veh, WEST] call bis_fnc_spawnvehicle;
_wp = _newveh addWaypoint [position "newVehicle", 0]
[group _newveh, 1] setWPPos position "newVehicle";
[group _newveh, 1] setWaypointType "GETOUT";

waitUntil{{_x in _newveh} count units group _newveh == 0};
{deleteVehicle _x} foreach units group _newveh;
hint "New Vehicle Arrived";

//pickMission.sqf
_source = centermarker select 0;
_radius = 800;
_mission = switch (floor random(3)) do {
// radio tower stuff 
case 0: {"missions\nothing.sqf"};
// scud launcher stuff
case 1: {"spawnVehicle.sqf"};
// suicide bomber stuff
case 2: {"pickMission.sqf"};
};
_nul = [_source, _radius] execVM _mission

//Counterattack.sqf
if (isServer) then {
// Inform the team
cmdhq sideChat "UAV picks up a large amount of OPFOR foot mobiles converging on OP Rascal, we need units defending ASAP!";
// Create Defenses
_possibletargets=[counter,counter_1,counter_2,counter_3];
_target = (_possibletargets select (floor random count _possibletargets - 1) );
_spawnc = [1,position _target,3,[basezone, "move"]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
// Create a task to destroy the tower.
};
_sideMissionTask = player createSimpleTask ["Defend OP Rascal"];
_sideMissionTask setSimpleTaskDescription ["Defend OP Rascal.", "Defend OP Rascal", "Defend the base."];
_sideMissionTask setSimpleTaskDestination (getMarkerPos Start);
_sideMissionTask setTaskState "Assigned";
update = [_sideMissionTask] execVM "fTaskHint.sqf"; 
waitUntil {!alive _spawnc};

sleep 5;
_sideMissionTask setTaskState "Completed";
update = [_sideMissionTask] execVM "fTaskHint.sqf"; 
missionActive = false;
publicVariable "missionActive";

//Emplacement.sqf
//////////////////////////////////////////////////////////////////
// Function file for Armed Assault II
// Created by: [97thRR]Kolmain
//////////////////////////////////////////////////////////////////
// get starting spot and range
_marker = _this select 0;
_radius = _this select 1;
_pos = getmarkerpos _marker;
if (isServer) then {
// Find a good spot for the spawn (open area, not in trees)
_exp = "(1 + meadow) * (1 - forest) * (1 - trees)";
_prec = 100;
_bestplace = selectBestPlaces [_pos,_radius,_exp,_prec,1];
_spot = _bestplace select 0;
_spot2 = _spot select 0;
_possibletargets=["TK_GUE_WarfareBAircraftFactory_EP1","TK_GUE_WarfareBBarracks_Base_EP1","TK_GUE_WarfareBFieldhHospital_EP1","TK_GUE_WarfareBHeavyFactory_Base_EP1","TK_GUE_WarfareBLightFactory_EP1","TK_GUE_WarfareBUAVterminal_Base_EP1","TK_GUE_WarfareBVehicleServicePoint_EP1",
"TK_WarfareBBarracks_EP1","WarfareBMGNest_PK_TK_GUE_EP1","2b14_82mm_TK_GUE_EP1","ZU23_TK_EP1"];
_target = (_possibletargets select (floor random count _possibletargets - 1) );
hint "Mission Initialized";
sleep 30;
_name = _target createVehicle _spot2;
// Name it randomly "radar_87" for example.
_unitname = format["tgt_%1", floor(random 100)];
_name setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];
processInitCommands;
// Create a marker at the tower.
_marker = createMarker[format["marker%1",_name],getPos _name];
_marker setMarkerPos getPos _name;
_marker setMarkerShape "ICON";
_marker setMarkerType "DESTROY";
_marker setMarkerText "Objective";
_marker setMarkerSize [1, 1];
// Inform the team
cmdhq sideChat "Theres some kind of OPFOR structure in the city, I've sent your GPS the grid coordinates, take a look and eliminate if possible.";
// Create Defenses
spawng = [1,position _name,1,[_marker, "fortify"]] execVM "SCRIPTS\UPSMON\MON_SPAWN.SQF";
// Create a task to destroy the tower.
};
_sideMissionTask = player createSimpleTask ["Destroy OPFOR Emplacement"];
_sideMissionTask setSimpleTaskDescription ["Destroy the OPFOR Emplacement.", "Destroy the OPFOR Emplacement", "Destroy the OPFOR Emplacement"];
_sideMissionTask setSimpleTaskDestination (getMarkerPos _marker);
_sideMissionTask setTaskState "Assigned";
update = [_sideMissionTask] execVM "fTaskHint.sqf"; 
waitUntil {!alive _name};

sleep 5;
_sideMissionTask setTaskState "Completed";
update = [_sideMissionTask] execVM "fTaskHint.sqf"; 
missionActive = false;
publicVariable "missionActive";

Share this post


Link to post
Share on other sites

_mission = switch (floor random(3)) do {

this looks incorrect?? i may be wrong but shouldnt it be:

_mission = switch (floor(random 3)) do {

Share this post


Link to post
Share on other sites

Will try it when I get home, any other clues? Although, the scripts dont work if I run them by themselves either :/

Share this post


Link to post
Share on other sites

The random script is working.

I get the "New Vehicle Enroute" message appear so it gets that far.

There does seem to be an error a couple of lines after that

if (floor (random 3) == 2) then {nul0

What is nul0

As I don't have two PC's I can't test any further.

Share this post


Link to post
Share on other sites

Thats odd, didnt catch that... I took it out and will test asap! Thanks!

Share this post


Link to post
Share on other sites

I did manage to get the spawnvehicle script working.

// spawnVehicle.sqf
private "_veh";
_airlist =["AH64D_EP1","AH6J_EP1","CH_47F_EP1","MH6J_EP1","UH60M_EP1","UH60M_MEV_EP1"];
_groundlist = ["HMMWV_DES_EP1","HMMWV_MK19_DES_EP1","HMMWV_TOW_DES_EP1","HMMWV_M998_crows_M2_DES_EP1","HMMWV_M998_crows_MK19_DES_EP1","HMMWV_M1151_M2_DES_EP1","HMMWV_Avenger_DES_EP1","MTVR_DES_EP1","M1A1_US_DES_EP1","M1A2_US_TUSK_MG_EP1","MLRS_DES_EP1","M2A2_EP1","M2A3_EP1","M6_EP1","M1135_ATGMV_EP1","M1130_CV_EP1","M1126_ICV_M2_EP1","M1126_ICV_mk19_EP1","M1129_MC_EP1","M1128_MGS_EP1"];
hint "New Vehicle Enroute";
// if (isServer) then {

if (floor (random 3) == 2) then {
 _veh = (_airlist select (floor random count _airlist - 1) );
} else {
 _veh = (_groundlist select (floor random count _groundlist - 1) );
};
_newveh = createGroup West;

_newveh = [getmarkerpos "spawnVehicle", 180, _veh, WEST] call bis_fnc_spawnvehicle;
_grpveh = _newveh select 0;
_vehgroup = _newveh select 2;
_wp =  _vehgroup addWaypoint [getmarkerpos "newVehicle", 0];
[_vehgroup, 1] setWPPos getmarkerpos "newVehicle";
[_vehgroup, 1] setWaypointType "GETOUT";

waitUntil{{_x in _grpveh} count units _vehgroup == 0};
{deleteVehicle _x} foreach units  _vehgroup;
hint "New Vehicle Arrived";

I disabled the server script or I could test it you, yo will have to enabe it and make sure there is a }; to match.

I'm assuming your using two makers for the spawn and arrival area.

You also needed to declare the _veh variable as private.

The random part will also need looking at as it occasionally reports division by zero error.

As for the last two scripts I don't see anything calling them..

Edited by F2k Sel

Share this post


Link to post
Share on other sites

So thats working but I need to fix the server side issues. Anything on the others?

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  

×