Jump to content
greywolf907

Random tasks\objectives

Recommended Posts

Helps I was working on a similar idea (privately) a couple months back but got tired of working on it, now I just share some of the knowledge obtained from that :). It actually is where my garrison script was born as well as my two code snippets in my signature :p.

Share this post


Link to post
Share on other sites

Yeah my unit has run a Invade map I modified as our default public server mission for a long time but its gotten repetitive and boring I have made many missions for my unit to play on op days but never tried to make a large scale dynamic co op map so I thought I would give it a try and the outcome was my <advanced operations> mission. But can't have the same AO at every start so then I have to get my head around this scripting stuff to make it all come together like I want it to be. Plan on releasing it on Armaholic when I get the finished product. Thanks for your contributions your the man.

Share this post


Link to post
Share on other sites

So jShock how can I make a opfor unit spawn in with the tower at these locations? Also do you know what condition line I can use in a trigger to make it fire when opfor unit is detected in trigger area? I tried your adjusted script above everything seems to be working as you wrote it but since I have no Idea how to fire of the DAC zone in each objective script and have units spawn in with the objective and tower its hard to test fully, I posted in the DAC thread to see if someone can tell me how to fire the zones along with the random objectives.

Share this post


Link to post
Share on other sites

Here is my way to create a mission like this.Not the best but at-least working.

- In game editor, put Gamelogic location anywhere you want to have AO area and name them: city1, city2, ...

perhaps over on towns

now,you need some scripts.

- SHK_pos for find random position

- SHK_Taskmaster for task hint

- Shock's Building Garrison Function for fill houses at AO

***Example for 5 side missions***

init.sqf

if ((!isServer) && (player != player)) then {waitUntil {player == player};}; // Player sync

// disable radio and saving
enablesaving [false, false];
enableSentences false;

// use this code to control side missions call, later remove called mission from missions list
if (isNil "side1") then { side1 = true;};
if (isNil "side2") then { side2 = true;};
if (isNil "side3") then { side3 = true;};
if (isNil "side4") then { side4 = true;};
if (isNil "side5") then { side5 = true;};

// call taskmaster and find position functions
call compile preprocessfilelinenumbers "shk_pos\shk_pos_init.sqf";
call compile preprocessfile "shk_taskmaster.sqf";

// call side finer to select a mission and execute it
if (isserver) then { null=[]execVM "side_finder.sqf"; };

Description.ext

onLoadIntroTime=false;
onLoadMissionTime=false;
disabledAI=1;
debriefing=1;

RESPAWN = 3;
respawnDelay = 30;
respawnTemplates[] = {"Counter"};

joinUnassigned = 0;
enableDebugConsole = 0;
allowFunctionsLog = 0;

showGPS = 1;
showCompass = 1;
showMap = 1;
showPad = 1;
showWatch = 1;



class CfgFunctions
{
   #include "SBGF\cfgfunctions.hpp"  

};



class Header
{
gameType = coop;
minPlayers = 1;
maxPlayers = 30;
};

side_finer.sqf

if (!isServer) exitWith {}; // Server only

// create missions list array 
_allMissions = [];

// check if the mission hasn't executed yet, so add it to missions list array...
if ((side1)) then {
_allMissions pushBack 1;  
};
if ((side2)) then {
_allMissions pushBack 2;  
};
if ((side3)) then {
_allMissions pushBack 3;  
};
if ((side4)) then {
_allMissions pushBack 4;  
};
if ((side5)) then {
_allMissions pushBack 5;  
};

// find random a mission from missions list array
_mission = (_allMissions call BIS_fnc_selectRandom); 

// execute the selected mission...
if (_mission == 1) then { [] execVM "sidemissions\side1.sqf"; };
if (_mission == 2) then { [] execVM "sidemissions\side2.sqf"; };
if (_mission == 3) then { [] execVM "sidemissions\side3.sqf"; };
if (_mission == 4) then { [] execVM "sidemissions\side4.sqf"; };
if (_mission == 5) then { [] execVM "sidemissions\side5.sqf"; };

- Create a folder and name it: sidemissions

create side missions inside this folder and name it like: side1, side2, side3, side 4, side5, ...

Example a side mission:

side1.sqf

//if (!isServer) exitWith {}; // Server only

// set false the side1 so side finder will not execute this mission again
side1 = false;

sleep 200;

// find center of AO...looking for gamelogic location which created before in editor
_sidepos = [city1, city2, city3, city4, city5, city6, city7, city8, city9, city10] call BIS_fnc_selectRandom;

// add marker on AO/target
_marker = createMarker ["side_area", _sidepos];
_marker setMarkerType "hd_destroy";
_marker setMarkerColor "ColorRed";
_marker setMarkerText " Destroy jet";
_marker setMarkerSize [1,1];

// spawn target
jet = createVehicle ["RHS_A10", _sidepos, [], 0, "CAN_COLLIDE"]; 
jet lock true;
jet setdir 140;

// Add task
//Task ID-Task name-Task description and some other options
["Task1","Destroy jet","Seek and destroy NATO <marker name='side_area'>Jet</marker> at the airbase.",true,["Destroy jet",getmarkerpos "side_area"]] call SHK_Taskmaster_add ;


// spawn enemy

// find position to spawn infantry NATO
//_pos = [<marker>,<radios>,<direct>,<if false, no water>
_pos = [getmarkerpos "side_area", random 50, random 360, false, [0,0]] call SHK_pos;

// create random units in a group and spawn it ... [3,0.2] means 100% 3 first classname will spawn and 20% possibility for rest classnames
_grp1 = [(_pos), West,[
"B_Soldier_SL_F","B_soldier_AT_F","B_soldier_AR_F","B_Soldier_A_F","B_medic_F","B_RangeMaster_F",
"B_Competitor_F","B_engineer_F","B_soldier_exp_F","B_Soldier_GL_F","B_soldier_M_F","B_soldier_AA_F",
"B_soldier_PG_F","B_soldier_repair_F","B_Soldier_F","B_soldier_LAT_F","B_Soldier_lite_F","B_soldier_UAV_F",
"B_sniper_F","B_spotter_F"
],[],[],[],[],[3,0.2]] call bis_fnc_spawngroup;

// Give order to group to start patrol at AO marker area, radios 100 meter
[_grp1, (getmarkerPos "side_area"), 100] call bis_fnc_taskPatrol;


// units in house
if (isserver) then {
_units = ["side_area",West,200,0.1,[
"B_Soldier_SL_F","B_soldier_AT_F","B_soldier_AR_F","B_Soldier_A_F","B_medic_F","B_RangeMaster_F",
"B_Competitor_F","B_engineer_F","B_soldier_exp_F","B_Soldier_GL_F","B_soldier_M_F","B_soldier_AA_F",
"B_soldier_PG_F","B_soldier_repair_F","B_Soldier_F","B_soldier_LAT_F","B_Soldier_lite_F","B_soldier_UAV_F",
"B_sniper_F","B_spotter_F"
],-1] spawn SBGF_fnc_garrison;

};


// spawn car at AO area and patrol
_grp2 = createGroup West;
_pos = [ (getmarkerPos "side_area"), random 300, random 359, false, [1, 300]] call SHK_pos;
_carlist = ["rhsusf_m1025_d_m2","rhsusf_m1025_d_Mk19","B_MRAP_01_gmg_F","B_MRAP_01_hmg_F"] call BIS_fnc_selectRandom;
_car1 = createVehicle [_carlist, _pos, [], 0, "CAN_COLLIDE"]; 
"B_Soldier_GL_F" createUnit [_pos, _grp2, " this MoveinGunner _car1",0.8,"SEARGENT"];
"B_Soldier_GL_F" createUnit [_pos, _grp2, " this MoveinDriver _car1",0.6,"PRIVATE"];
[_grp2, (getmarkerPos "side_area"), 1000] call bis_fnc_taskPatrol;


// Spawn tank/apc at AO area and patrol
_grp3 = createGroup West;
_pos = [ (getmarkerPos "side_area"), random 300, random 359, false, [0,0]] call SHK_pos;
_apclist = [
"B_APC_Tracked_01_rcws_F","B_APC_Wheeled_01_cannon_F","B_APC_Tracked_01_rcws_F","B_APC_Wheeled_01_cannon_F"
] call BIS_fnc_selectRandom;
_apc1 = createVehicle [_apclist, _pos, [], 0, "CAN_COLLIDE"];
"B_crew_F" createUnit [_pos, _grp3, " this MoveinCommander _apc1",0.8,"SEARGENT"];
"B_crew_F" createUnit [_pos, _grp3, " this MoveinGunner _apc1",0.6,"PRIVATE"];
"B_crew_F" createUnit [_pos, _grp3, " this MoveinDriver _apc1",0.6,"PRIVATE"];
[_grp3, (getmarkerPos "side_area"), 1000] call bis_fnc_taskPatrol;


// WAIT UNTIL objective destroy
waitUntil { (!alive jet) };

// task complete hint
["Task1","succeeded"] call SHK_Taskmaster_upd;

// delete AO marker and target
deleteMarker "side_area";
sleep 10;
deletevehicle jet;

// remove mans/vehicles/air/static "optional"
sleep 30;
{if (!(isplayer _x)) then {deleteVehicle _x;};} foreach nearestobjects [_sidepos,[
"air","StaticWeapon","Landvehicle"
],2000]; 
sleep 10;
{if (!(isplayer _x)) then {deleteVehicle _x;};} foreach nearestobjects [_sidepos,[
"man"
],2000]; 

sleep 5;

// go for next side mission
if (isserver) then { null=[]execVM "side_finder.sqf"; };

if(true)exitWith{};

and add more side missions like this.

Note that i used mods classnames for some units and vehicles in example, you have to change classnames to arma vanilla classnames

Edited by Persian MO

Share this post


Link to post
Share on other sites

I also have a patrol thing I've got hiding somewhere on my computer that I wouldn't mind sharing (on my phone currently).

Share this post


Link to post
Share on other sites
Same type of objectives to start but trying to get the basics down then I will change them up. Invade and Annex has way to much crap in it and all the restrictions they love to put in causes a bunch of lag for people kind of takes the fun out of it, my mission is challenging and yet still enjoyable to play by simplifying it to where only one AO is active at a time and not all the rest of the junk put into the mission cuts out a bunch of chop for people. I already have the mission made but with task modules to fire the DAC zones so to eliminate all the sync lines on the map and streamline it I would like all the tasks and objectives to fire within scripts. Lucky for me jShock has been patiently guiding me through how to do some things.

Not to take away from your project, But you can always edit the invade and annex stuff. Its basically what every group does to have a run and gun type mission to put up on server to run, you can add / subtract / edit / whatever. its really easy.

Also, Invade and annex is using DAC to spawn their zones too, check their latest version may be you could use their method to spawn. I forget how DAC does it but I known EOS spawns AI when players are within certain distance, perhaps that would help, check out AISSP too. Both are good AI spawners.

---------- Post added at 15:14 ---------- Previous post was at 15:12 ----------

Helps I was working on a similar idea (privately) a couple months back but got tired of working on it, now I just share some of the knowledge obtained from that :). It actually is where my garrison script was born as well as my two code snippets in my signature :p.

I would like to see your stuff. As you know you've help thousands if not millions of members here.... ok may be a smaller % but, you have good skills and I would be willing to help you were I could, testing, whatever if you ever interested in opening that can again.

Edited by JAndrews1

Share this post


Link to post
Share on other sites

Yup have edited many of Domi and Invade maps trying to create a new co op mission from the ground up a bit different from whats out there we need some more variety Arma has endless mission scenario possibility's as far as good large scale co op missions we need more in my opinion. JShock I would be interested in trying out your patrol script if you want I'm not stuck on DAC as the AI create script just a method that works and can hide the inactive AO'S and cache units to save on lag for the players. Thanks for the examples Persian I will try it out.

Share this post


Link to post
Share on other sites
JShock I would be interested in trying out your patrol script if you want I'm not stuck on DAC as the AI create script just a method that works and can hide the inactive AO'S and cache units to save on lag for the players.

Yea in my private little project I wasn't going to worry about caching units as they would spawn into the AO be killed and so forth, then once the objective was completed, have some sort of lag time between the end and creation of the next AO, then delete all the old AO's units that are still alive.

And for the patrol script:

/* //////////////////////////////////////////////
Author: J.Shock

File: fn_patrols.sqf

Description: Creates randomly positioned and sized patrols throughout a defined radius of an AO
		 using a marker as the center position.

Parameters: 
	1- Marker for center position: (string) (default: empty string)
	2- Radius to spawn units: (integer) (default: 300)
	3- Number of patrol groups: (integer) (default: 5)
	4- Side: (side) (default: EAST)

Return: Spawned units.

Example Call line: ["mrkName",200,5,EAST] execVM "JSHK_patrols.sqf";

*///////////////////////////////////////////////
private ["_configGrps","_AOmarker","_radius","_numPatrols","_units"];

_AOmarker = [_this, 0, "", [""]] call BIS_fnc_param;
_radius = [_this, 1, 300, [0]] call BIS_fnc_param;
_numPatrols = [_this, 2, 5, [0]] call BIS_fnc_param;
_side = [_this, 3, EAST, [WEST]] call BIS_fnc_param;

_units = [];

for "_i" from 1 to (_numPatrols) step 1 do 
{
_configGrp = ["OIA_InfSentry", "OIA_InfTeam", "OIA_InfTeam_AT", "OIA_InfTeam_AA"] call BIS_fnc_selectRandom;
_rndPos = [[[getMarkerPos _AOmarker, _radius], []], ["water", "out"]] call BIS_fnc_randomPos;
_grp = [_rndPos, _side, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> (_configGrp))] call BIS_fnc_spawnGroup;
[_grp, (getMarkerPos _AOmarker), (random(50)+75)] call BIS_fnc_taskPatrol;
{_units pushBack _x} count units (group _grp) > 0;
sleep 0.05;
};

_units;

Where you see the "_configGrp =" line in the for loop, you can change up/add to the classes there from the following page: https://community.bistudio.com/wiki/CfgGroups#ArmA_3

Share this post


Link to post
Share on other sites

Looks good going to try this when I get home. So in the line _AOmarker in between the first set of "" I would add marker name right? And the second set off "" what go's there?

Share this post


Link to post
Share on other sites

No, read the parameters and other info all commented out above the code, there is an example call line in there as well. For each of the parameters coming into the script I have it where it only accepts certain data, and sets a default for each parameter (in case you leave it blank and what have you).

So you would pass your marker into the script along with the radius of the patrols, the number of groups patrolling and the side of those units:

["mrkName",200,5,EAST] execVM "JSHK_patrols.sqf";
//would have a center at "mrkName", a patrol radius of 200m, it would spawn 5 groups, and they would be EAST/OPFOR

Share this post


Link to post
Share on other sites

Ah I see thank you. Now can we implement this into the random objective script along with the secondary task? Some how I would need it to fire only one AO at a time and the rest are not present until called up by the random objective script. Prob easier said than done though right :)

Share this post


Link to post
Share on other sites

I mean if you would want a random objective with a random secondary objective it would be the same basic setup, just another randomizer for the secondary objective, and with the way I have it setup currently it only fires one AO at a time until the objective is completed, then it goes back in and does another random objective, spawns it at the AO, makes a task, and waits again until the task is completed, etc etc.

Share this post


Link to post
Share on other sites

K so for test purposes how would I call the script with the line ["mrkName",200,5,EAST] execVM "JSHK_patrols.sqf"; on the tasks mission you threw together so they are linked and fire with the objectives?

Share this post


Link to post
Share on other sites

Like so:

//example objective0Create.sqf
//call line being: [(getMarkerPos _rndLoc)] execVM "objective0Create.sqf";

_centerPos = (_this select 0);

[_centerPos,200,5,EAST] execVM "JSHK_patrols.sqf";//<< here

_clearTask =
[
   "ClearID",
   true,
   ["Clear the area by any means necessary.","Primary: Clear Area","Clear Area"],
   _centerPos,
   "AUTOASSIGNED",
   6,
   true,
   true
] call BIS_fnc_setTask;

_trigger = createTrigger ["EmptyDetector",_centerPos];
_trigger setTriggerActivation ["EAST","NOT PRESENT",false];
_trigger setTriggerArea [300,300,0,false];
_trigger setTriggerStatements ["this",format ["[%1,'Succeeded'] call BIS_fnc_taskSetState",_clearTask],""];


_tower = createVehicle ["Land_TTowerBig_2_F", _centerPos, [], 0, "NONE"];
_towerTask = 
[
  "RadioTowerID",
  true,
  ["Destroy the tower by any means necessary.","Secondary: Destroy Tower","Destroy Tower"],
  getPos _tower,
  "AUTOASSIGNED",
  5,
  true,
  true
] call BIS_fnc_setTask; 

_towerCompleted = [_tower,_towerTask] spawn 
{
   waitUntil {!alive (_this select 0)}; 
   [(_this select 1),"Succeeded"] call BIS_fnc_taskSetState;
};

waitUntil {([_clearTask] call BIS_fnc_taskState isEqualTo "Succeeded") && {scriptDone _towerCompleted}};

0 = [] execVM "objectiveInit.sqf";  

And a slight change the the patrol script to suit the variable being passed to it:

/* //////////////////////////////////////////////
Author: J.Shock

File: fn_patrols.sqf

Description: Creates randomly positioned and sized patrols throughout a defined radius of an AO
            using a marker as the center position.

Parameters: 
       1- Marker for center position: (string) (default: empty string)
       2- Radius to spawn units: (integer) (default: 300)
       3- Number of patrol groups: (integer) (default: 5)
       4- Side: (side) (default: EAST)

Return: Spawned units.

Example Call line: ["mrkName",200,5,EAST] execVM "JSHK_patrols.sqf";

*///////////////////////////////////////////////
private ["_configGrps","_AOmarker","_radius","_numPatrols","_units"];

_AOmarker = [_this, 0, [0,0,0], [[]]] call BIS_fnc_param;
_radius = [_this, 1, 300, [0]] call BIS_fnc_param;
_numPatrols = [_this, 2, 5, [0]] call BIS_fnc_param;
_side = [_this, 3, EAST, [WEST]] call BIS_fnc_param;
_center = createCenter _side;

_units = [];

for "_i" from 1 to (_numPatrols) step 1 do 
{
   _configGrp = ["OIA_InfSentry", "OIA_InfTeam", "OIA_InfTeam_AT", "OIA_InfTeam_AA"] call BIS_fnc_selectRandom;
   _rndPos = [[[_AOmarker, _radius], []], ["water", "out"]] call BIS_fnc_randomPos;
   _grp = [_rndPos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> (_configGrp))] call BIS_fnc_spawnGroup;
   [_grp, (_AOmarker), (random(50)+75)] call BIS_fnc_taskPatrol;
   {_units pushBack _x} count units (_grp) > 0;
   sleep 0.05;
};

_units;  

Edited by JShock

Share this post


Link to post
Share on other sites

K so changed the objective0create through objective2create with the modified script lines and added the patrol script with the change you made to it preview in editor towers spawn but no enemy units what am I missing?

---------- Post added at 05:38 PM ---------- Previous post was at 05:14 PM ----------

Ok figured it out I thought your name of the patrol script was fn_patrols.sqf instead of JSHK_patrols.sqf once changed it tried to fire but got error here is a link to the screenshot sorry about the res I have tripple monitor setup just zoom in to read. https://drive.google.com/file/d/0B3aP4n_r-2_xSnVkSEliS1lwNWc/view?usp=sharing

Share this post


Link to post
Share on other sites
Ok figured it out I thought your name of the patrol script was fn_patrols.sqf instead of JSHK_patrols.sqf once changed it tried to fire but got error here is a link to the screenshot sorry about the res I have tripple monitor setup just zoom in to read. https://drive.google.com/file/d/0B3aP4n_r-2_xSnVkSEliS1lwNWc/view?usp=sharing

Yea sorry my fault, it did come from a file originally name fn_patrols, just forgot to change it :p. Ok and other thing is my mistake as well take "group" out of that, leaving "count units _grp >0;"

Share this post


Link to post
Share on other sites

K so that line should look like this {_units pushBack _x} count units (_grp) > 0; Or like this {_units pushBack _x} "count units _grp > 0;"

---------- Post added at 06:04 PM ---------- Previous post was at 05:58 PM ----------

Oh looks like you adjusted it in your script above changed to {_units pushBack _x} count units (_grp) > 0; no error but no units spawn?

Share this post


Link to post
Share on other sites
Yup have edited many of Domi and Invade maps trying to create a new co op mission from the ground up a bit different from whats out there we need some more variety Arma has endless mission scenario possibility's as far as good large scale co op missions we need more in my opinion. JShock I would be interested in trying out your patrol script if you want I'm not stuck on DAC as the AI create script just a method that works and can hide the inactive AO'S and cache units to save on lag for the players. Thanks for the examples Persian I will try it out.

hey good luck.... trust me I know the headaches... I shelved my so called project a while back... I need to burn that bitch up..... anyways look forward to seeing how it comes out.... keep in mind adding zeus with something like VCOMAI can add some cool stuff too without the headaches.

JShock is the man :notworthy:

Share this post


Link to post
Share on other sites

Try the above (altered post #41 again), I think it's BIS_fnc_spawnGroup, because I think it needs a center to spawn stuff off of if no units from that side exist on the map.

Share this post


Link to post
Share on other sites

K replaced scripts with above no errors no AI spawns? Do you want me to upload my test mission and give you a link to trouble shoot? Thanks jAndrews1 yeah Arma best and worse game ever nothings ever easy but after I work out a few kinks I will edit my full mission it won't take long just got to get these basic spawn issues figured out.

Share this post


Link to post
Share on other sites
but, you have good skills

You say this, and I make stupid mistakes that make this damn patrol function not work :p, okay after some starring, TV throwing (out of window), and lots of "wtfs", the issue was that I was of course missing something simple like the last inherited class for the config directory line for the group spawn......

Fixed....:

/* //////////////////////////////////////////////
Author: J.Shock

File: fn_patrols.sqf

Description: Creates randomly positioned and sized patrols throughout a defined radius of an AO
            using a marker as the center position.

Parameters: 
       1- Marker for center position: (string) (default: empty string)
       2- Radius to spawn units: (integer) (default: 300)
       3- Number of patrol groups: (integer) (default: 5)
       4- Side: (side) (default: EAST)

Return: Spawned units.

Example Call line: ["mrkName",200,5,EAST] execVM "JSHK_patrols.sqf";

*///////////////////////////////////////////////
private ["_configGrps","_AOmarker","_radius","_numPatrols","_units","_center"];

_AOmarker = [_this, 0, [], [[]]] call BIS_fnc_param;
_radius = [_this, 1, 300, [0]] call BIS_fnc_param;
_numPatrols = [_this, 2, 5, [0]] call BIS_fnc_param;
_side = [_this, 3, EAST, [WEST]] call BIS_fnc_param;
_center = createCenter _side;

_units = [];

for "_i" from 1 to (_numPatrols) step 1 do 
{
   _configGrp = ["OIA_InfSentry", "OIA_InfTeam", "OIA_InfTeam_AT", "OIA_InfTeam_AA"] call BIS_fnc_selectRandom;
   _rndPos = [[[_AOmarker, _radius], []], ["water", "out"]] call BIS_fnc_randomPos;
   _grp = [_rndPos, _center, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> (_configGrp))] call BIS_fnc_spawnGroup;
   [_grp, (_AOmarker), (random(50)+75)] call BIS_fnc_taskPatrol;
   {_units pushBack _x} forEach units _grp;
   sleep 0.05;
};

_units;

Why it didn't error out in the first place....I don't know....

Share this post


Link to post
Share on other sites

F**k yeah buddy that did the trick enemy at the markers thanks. I will be testing this and if all is well using it in my mission for sure, If you have some time I would like to hook up with you in TS or e mail about creating some unique secondary objectives for the mission. Thanks again script wizard:yay:

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

×