Jump to content
Sign in to follow this  
chok3cha1n

Simple Defend Mission

Recommended Posts

I'm looking to create a simple defend mission for a couple friends and myself. I have been playing arma for about 2 years now, as far as the editor goes I can do most simple things although I have never made a complete mission. I have some trouble with end mission parameters and other sorts of odds and ends. Basically I want to create a Ghost Recon style defend scenario, but I would like to make it simple as possible. After the mission is finished I would like to be able to go in and change certain aspects of the mission without screwing things up. (Adding more players, more enemies, moving defend area. Etc.) I have searched through the forums and haven't found exactly what I need so I've decided to ask for help. I've seen what a great community this is over the years, so any help would be great!

So this is my big idea:

1. Defend certain area (that I could open in editor and change location) for a timed period. (Also be able to change time length)

2. Win/Lose conditions: Win- Any amount of BLUFOR present at end of time limit. Lose- BLUFOR dead and OPFOR present in defend area.

3. Enemies- I would like to be able to put "waves" of enemies. These waves would get bigger as they are defeated, eventually bringing in vehicles and helicopters to support them.

The 3rd point is the one I have the most trouble with. Ideally I would like each wave to spawn in instead of all being placed at once. (Not sure if possible)

I really hope someone out there can help me it would be much appreciated!!

Share this post


Link to post
Share on other sites

Well, you've basically written the triggers for 1 and 2 here already. Just translate that to in game syntax. :)

3 isn't terribly difficult. Here's an example from ArmA2. Would need a little tweaking to work in A3 but should show you one way of doing things.

Share this post


Link to post
Share on other sites

Yeah, like I said I can do some simple things in the editor I think I could get away with 1 and 2, thank you for posting the link i'm checking it out now. But as you say it needs some tweaking for A3 I would have absolutely no idea where to start. Also I'm not sure I know how to set a marker on the map for the area to defend.

Share this post


Link to post
Share on other sites

Start small then. One wave on demand.

So place a marker.

Write a simple script to spawn a group at the marker. (hint: BIS_fnc_spawnGroup)

Add a waypoint to the group to attack the player.

Run the script from a Radio Alpha trigger.

Once you have that down you should be able to add in extra things like two markers and having it choose between them (hint: BIS_fnc_selectRandom) and so on.

Give that a try and let us know if you stumble on any of it.

Share this post


Link to post
Share on other sites

Well as far as scripting goes I know how to implement an already written script but I wouldn't know where to start writing my own script. I'm not trying to make excuses I'm just a busy father of two and I enjoy sitting down and playing some arma in what little free time I have, I'm not against learning but really I just want to play lol. So any ideas or tutorials on how to start writing my own script would be great, as I said I've really enjoyed this community over the last couple of years and I learned most of everything I can do from searching forums I only have 7 or 8 posts over 3 years so I really do use the search function I just wanna get this up and running as soon as possible defend is my favorite and I love A3 and want to play with all the new explosives and such! Thanks you guys you all are really a great help

---------- Post added at 12:41 PM ---------- Previous post was at 12:30 PM ----------

http://community.bistudio.com/wiki/Category:Arma_3:_New_Scripting_Commands_List I found this now can these all be used within a script? I'm not finding the BIS_fnc_selectRandom command that you posted? or are these just for use in the editor itself?

  • Thanks 1

Share this post


Link to post
Share on other sites

The functions I'm mentioning are both in game in the Functions browser, or at the website you found here for ArmA2 and here for ArmA3.

Here's a very simple method of spawning three rifleman to attack you. Just put down a Marker named "spawnpoint" then put this code in the onAct of a radio alpha repeatable trigger:

grp = [getMarkerPos "spawnpoint", opfor, ["O_Soldier_F","O_Soldier_F","O_Soldier_F"]] call BIS_fnc_spawnGroup;
null = [grp, (getPos player)] call BIS_fnc_taskAttack; 

Edited by kylania

Share this post


Link to post
Share on other sites

Okay thank you, so where it says getPos player i would need to name my my character player or change that to what ever my character name is correct? also do I just need to point them to myself or include all players in the game and will they come at me anywhere i am since this is getting my character position?

Share this post


Link to post
Share on other sites

"player" is a special variable that means "the player", so you don't need to put your name or anything, that's just the game's way of saying "you!". You'd replace getPos player with perhaps a getMarkerPos "whereToAttack" or something similar if you want them to attack a specific place marked by a rather than where you are. Leaving it how it is will just send the enemy units to your current location to look for you.

To make them randomly attack other players wherever they are would be a lot more tricky. :)

Share this post


Link to post
Share on other sites

Okay so instead of pointing them towards me could I point them towards the defend area? also I could use a trigger to spawn them when we walk into the defense area instead of a radio alpha trigger correct?

Share this post


Link to post
Share on other sites

Sure. In that case place a marker in the defend area called "defendArea" then change the (getPos player) to read (getMarkerPos "defendArea")

Share this post


Link to post
Share on other sites

Okay excellent I understand everything so far to mess around with it. Now say this first wave of 3 soldiers is killed, can i create another trigger that would spawn another set of soldiers at another marker to spawn when these guys are dead?

Share this post


Link to post
Share on other sites

You would only need a simple !alive unit check and then rerun your spawn trigger. Or if they are the only enemies you could run a trigger set to repeatedly that checks to see if Opfor is present - if not, would activate spawn script.

Share this post


Link to post
Share on other sites

or something like this, once the group is dead it will spawn them again forever until you turn SpawnEnemies to false..............

just place a Spawnmarker & a patrol marker to defend

Untested but should work

if (! isServer) exitWith{};  // /on server only

SpawnEnemies=true; ///set to false to stop
while {SpawnEnemies} do {
_randomsquad=["OIA_InfSquad","OIA_InfTeam"]call BIS_fnc_selectRandom;  // random squad add more as you like
_grp1 = [getmarkerpos "SpawnMarker", EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> _randomsquad)] call BIS_fnc_spawnGroup;
[_grp1,getmarkerpos "myPatrolMarker",180] call bis_fnc_taskPatrol;  // patrol  to marker
waitUntil {{alive _x} count (units _Grp1) == 0};  

};

Edited by 1PARA{God-Father}
script error

Share this post


Link to post
Share on other sites

Well my idea with multiple ones were so that after say the first "wave" is done the second wave could spawn more and say after they were gone even more with a support vehicle basically the defend mission getting a little more difficult as it goes or is there a way to set that up without multiple spawn markers?

---------- Post added at 05:11 PM ---------- Previous post was at 05:09 PM ----------

@1PARA thanks for that man so that is a script correct? copy and paste that into a wordpad and save it in my mission file? and basically that will spawn a random patrol and i would put the patrol marker in my defend area and thats where they would patrol to?

Share this post


Link to post
Share on other sites

Yes just save it to a .sqf i.e Spawnchok3cha1n.sqf then call it via trigger or INT or what ever you like, and add more Groups as required like vehicles etc....

Call it:-

 nul=[] execvm "Spawnchok3cha1n.sqf";

Remember when you want to stop the spawn set

SpawnEnemies=False

Share this post


Link to post
Share on other sites

if (! isServer) exitWith{};  

SpawnEnemies=true; 
_moar = 0;
while {SpawnEnemies} do {
   _randomsquad=["OIA_InfSquad","OIA_InfTeam"]call BIS_fnc_selectRandom;  
   _grp1 = [getmarkerpos "SpawnMarker", EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> _randomsquad)] call BIS_fnc_spawnGroup;
   null = [_grp1, (getMarkerPos "attack")] call BIS_fnc_taskAttack;
   waitUntil {{alive _x} count (units _grp1) == 0};  
_moar = _moar + 1;
if (_moar < 3) then {SpawnEnemies = True} else {SpawnEnemies = False}; 
};  

I totally do not know the functions yet. This works amazing for Infantry, loving it! How would I go about changing this to spawn Ifrits and Marids?

Essentially the mission I'm making will be a "Hold The Line" type of mission against enemy infantry and vehicles for our light armor unit while we have our infantry units completing objectives which will eventually set the condition to false. Ignore the _moar loop, it's just for testing 3 waves atm every time Radio Alpha is triggered.

Share this post


Link to post
Share on other sites

You just need to change / add new CfgGroups to _randomsquad add what you like find them all find them in the editor......... editor -> Config viewer -> CfgGroups

Sorry do not have access to A3 atm to give a list but they are all there in the Config Viewer, any issue PM me

Share this post


Link to post
Share on other sites

@1PARA okay so I've done everything you've mention I activate my trigger and the group spawns but they just stand there they aren't moving to the patrol marker. I have a regular marker set called "myPatrolMarker" which is same as in script. am i doing something wrong??

---------- Post added at 02:45 PM ---------- Previous post was at 01:33 PM ----------

i added _ in front of grp1 in the script and they seem to be following the waypoint now. thats great now where do i find the classnames for "oia_infsquad" and such? to add more groups to attack?

Share this post


Link to post
Share on other sites


// configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> _randomInfSquad
_randomInfSquad=["OIA_InfSquad", "OIA_InfSquad_Weapons", "OIA_InfTeam", "OIA_InfTeam_AT"]call BIS_fnc_selectRandom;

// configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Motorized_MTP" >> _randomMotorizedSquad
_randomMotorizedSquad=["OIA_MotInf_AT", "OIA_MotInf_Team"]call BIS_fnc_selectRandom;

// configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "SpecOps" >> _randomSpecOpsSquad
_randomSpecOpsSquad=["OI_diverTeam", "OI_diverTeam_Boat"]call BIS_fnc_selectRandom;

// configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Support" >> _randomSupportSquad
_randomSupportSquad=["OI_support_CLS", "OI_support_ENG", "OI_support_EOD"]call BIS_fnc_selectRandom;

Those are the current beta options for opfor. Found under:

configfile >> "CfgGroups" >> "East" >> "OPF_F" in the Config Viewer in the editor.

Share this post


Link to post
Share on other sites

oh wow thanks i didn't know all that was available in the editor lol. also would you happen to know if in that script above posted by 1para where it tells grp1 to getmarkerpos if i had "spawnmarker","spawnmarker2" would it randomly select a marker to spawn at each time or do i have to tell the script to randomly select a spawnmarker

Share this post


Link to post
Share on other sites

Bam.

if (!isServer) exitWith{};  // /on server only
private ["_type", "_randomSquad"];
/*
Examples:
[string, string]
[string or array, array (string or array of strings)]
[string, array, string(optional)]

// Spawns random infantry squad at mySpawnMarker and moves them to myPatrolMarker
nul = ["mySpawnMarker", "myPatrolMarker"] execVM "spawnRandomGroup.sqf";

// Spawns random infantry squad at mySpawnMarker or myOtherSpawnMarker and moves them to myPatrolMarker
nul = [["mySpawnMarker", "myOtherSpawnMarker"], myPatrolMarker"] execVM "spawnRandomGroup.sqf";

// Spawns a random motorized infantry squad at mySpawnMarker and moves to either myFirstPatrolMarker or mySecondPatrolMarker
nul = ["mySpawnMarker", ["myFirstPatrolMarker", "mySecondPatrolMarker"], "mot"] execVM "spawnRandomGroup.sqf";

*/

_spawnMarkers = _this select 0;
_spawnMarker = if (typeName _spawnMarkers == "STRING") then [{_spawnMarkers}, {_spawnMarkers call BIS_fnc_selectRandom}];

_patrolMarkers = _this select 1;
_patrolMarker = if (typeName _patrolMarkers == "STRING") then [{_patrolMarkers}, {_patrolMarkers call BIS_fnc_selectRandom}];

// Types = inf, mot, div, sup
_spawnType = if (count _this > 2) then {_this select 2} else {"inf"};
_type = "";
_randomSquad = "";

// We'll set this elsewhere on map maybe.
SpawnEnemies=true; ///set to false to stop

switch (_spawnType) do {

case "inf": {
// configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> _randomInfSquad
_randomSquad = ["OIA_InfSquad", "OIA_InfSquad_Weapons", "OIA_InfTeam", "OIA_InfTeam_AT"] call BIS_fnc_selectRandom;
_type = "Infantry";
};

case "mot": {
// configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Motorized_MTP" >> _randomMotorizedSquad
_randomSquad = ["OIA_MotInf_AT", "OIA_MotInf_Team"] call BIS_fnc_selectRandom;
_type = "Motorized_MTP";
};

case "div": {
// configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "SpecOps" >> _randomSpecOpsSquad
_randomSquad = ["OI_diverTeam", "OI_diverTeam_Boat"] call BIS_fnc_selectRandom;
_type = "SpecOps";
};

case "sup": {
// configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Support" >> _randomSupportSquad
_randomSquad = ["OI_support_CLS", "OI_support_ENG", "OI_support_EOD"] call BIS_fnc_selectRandom;
_type = "Support";
};
};    

while {SpawnEnemies} do {

   _grp1 = [getMarkerPos _spawnMarker, EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> _type >> _randomSquad)] call BIS_fnc_spawnGroup;
[_grp1, getMarkerPos _patrolMarker, 180] call bis_fnc_taskPatrol;  // patrol  to marker
   waitUntil {{alive _x} count (units _grp1) == 0};  
	//hint format["Group %1 is dead", _grp1];
};  

Optional any type of groups and random patrols or not. So spawn or patrol markers can be a single string, a single marker, or an array of markers and it'll randomly pick one.

Edited by kylania

Share this post


Link to post
Share on other sites

thanks thats awsome i'm gonna give it a shot i had a friend over last night and we tried the other code on a lan and we got it working pretty well I was impressed. I'm gonna try this one too I figure if you guys can take the time to post these codes for me I'll give every one of them a shot and see which one works best for me... also I'm the same person as the chok3cha1n account but that password reset i couldn't get into my old email address so i used this new account. thanks guys so much!

Share this post


Link to post
Share on other sites

You should email support @ bistudio.com to have your old account email fixed. It's more than just a forum account now it's linked to anything you bought from the store as well. Should be painless.

Also that most recent code I posted is the same code from Para, I just added some options to it. :)

Share this post


Link to post
Share on other sites

well actually this is the account that I bought my arma 3 alpha with lol the other account was just saved in my browser so i always used it.

Share this post


Link to post
Share on other sites
You should email support @ bistudio.com to have your old account email fixed. It's more than just a forum account now it's linked to anything you bought from the store as well. Should be painless.

Also that most recent code I posted is the same code from Para, I just added some options to it. :)

Nice feature Kylania,

I stripped it down to make it easy, But love your additions ! :)

I normally use a Random placement with it to make it more interesting , that way you never know where they come from.

So just change the spawn bit to this


while {SpawnEnemies} do {
    _RandomPlacment= [getmarkerpos _spawnMarker,random 360,[150,200],false,2] call SHK_pos; // spawn them min150 max 200 out in random direction
   _grp1 = [_RandomPlacment, EAST, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> _type >> _randomSquad)] call BIS_fnc_spawnGroup;
   [_grp1, getMarkerPos _patrolMarker, 180] call bis_fnc_taskPatrol;  // patrol  to marker
   waitUntil {{alive _x} count (units _grp1) == 0};  
    //hint format["Group %1 is dead", _grp1];
};  


You then need the following in your INIT so add the following to your init.sqf

SHK_pos = compile preprocessfile "SHK_pos.sqf";

This is Shuko Random Positions generator works great still for A3

SHK_pos.sqf

/*
 SHK_pos - Random position generator for Arma 2
 Author: Shuko (IRC: shuko@quakenet, Email: miika@miikajarvinen.fi)
 Version: 0.1

 Parameters for marker area based position:
   Area              String              Marker to define area from which the position is taken.
   Water             Boolean             Allow position on water? Optional, default is false.

 Usage examples:
   myPos = ["markerName"] execvm "SHK_pos.sqf";
   myPos = ["myMarker1",true] execvm "SHK_pos.sqf";

 Parameters for relative position:
   Point of Origin   Position array      The position from which direction and distance is calculated from.
   Direction         Number              Compass direction (0-359) from Point of Origin.
                     Array               Array can be used to give minimum and maximum directions.
   Distance          Number              Distance in meters from Point of Origin.
                     Array               Array can be used to give minimum and maximum distance.
   Water             Boolean             Allow position on water? Optional, default is false.
   Water solution    Integer             Water positions not allowed, what to do?
     0: Do nothing, do not return any position. An empty array is returned.
     1: Find closest land. Search is done with increasing radius until land is found, thus the resulting
        position might not be exactly in the given direction and distance.
     2: Decrease distance until land is found. Direction is kept the same.
     3: Increase distance until land is found. Direction is kept the same.
     4: Decrease direction (counter clock-wise) until land is found. Distance is kept the same.
     5: Increase direction (clock-wise) until land is found. Distance is kept the same.

     If no integer is given, solution 1 is used by default.

 Usage examples:
   myPos = [getpos player,random 360,200,true] execvm "SHK_pos.sqf";
   myPos = [getmarkerpos "myMarker",125,random 500] execvm "SHK_pos.sqf";
   myPos = [getpos player,random 360,[200,500],false,2] execvm "SHK_pos.sqf";

 Example of creating multiple positions:
   SHK_pos = compile preprocessfile "SHK_pos.sqf";
   for "_i" from 0 to 500 do {
     _p = [getpos player,random 360,random 1000] call SHK_pos;
     if (count _p > 0) then {
       call compile format ["
       _m%1 = createMarker[""mySpot%1"",[_p select 0,_p select 1]];
       _m%1 setMarkerShape ""ICON"";
       _m%1 setMarkerType ""DOT"";
       _m%1 setmarkercolor ""colorred"";
     ",_i];
     };
   };
*/
private "_getpos";
_getpos = {
 private ["_origo","_dir","_dist"];
 _origo = _this select 0;
 _dir = _this select 1;
 _dist = _this select 2;
 if (typename _dir == typename []) then {
   if ((_dir select 0) > (_dir select 1)) then { _dir set [1,((_dir select 1) + 360)] };
   _dir = ((_dir select 0) + random((_dir select 1)-(_dir select 0)))
 };
 if (typename _dist == typename []) then {
   _dist = ((_dist select 0) + random((_dist select 1)-(_dist select 0)));
 };
 [((_origo select 0) + (_dist * sin _dir)),((_origo select 1) + (_dist * cos _dir)),0];
};

private "_water";
if (typename (_this select 0) == typename "") then {
 private ["_pos","_area","_cp","_cx","_cy","_as","_rx","_ry","_ad","_cd","_sd","_xo","_yo","_loop"];
 _area = _this select 0;
 if (count _this > 1) then {_water = _this select 1} else {_water = false};
 _cp = getMarkerPos _area;
 _cx = abs(_cp select 0);
 _cy = abs(_cp select 1);
 _as = getMarkerSize _area;
 _rx = _as select 0;
 _ry = _as select 1;
 _ad = (markerDir _area) * -1;
 _cd = cos _ad;
 _sd = sin _ad;
 _loop = true;
 while {_loop} do {
   _tx = (random (_rx*2))-_rx;
   _ty = (random (_ry*2))-_ry;
   _xo = if (_ad!=0) then {_cx+ (_cd*_tx - _sd*_ty)} else {_cx+_tx};
   _yo = if (_ad!=0) then {_cy+ (_sd*_tx + _cd*_ty)} else {_cy+_ty};
   _pos = [_xo,_yo,0];
   if (_water) then {
     _loop = false;
   } else {
     if (!surfaceIsWater [_pos select 0,_pos select 1]) then {_loop = false};
   };
 };
 _pos
} else {
 private ["_origo","_dir","_dist","_pos","_loop","_watersolution"];
 _origo = _this select 0;
 _dir = _this select 1;
 _dist = _this select 2;
 if (count _this > 3) then {_water = _this select 3} else {_water = false};
 if (count _this > 4) then {_watersolution = _this select 4} else {_watersolution = 1};
 _pos = [_origo,_dir,_dist] call _getpos;
 if (!_water) then {
   private ["_d","_l","_p"];
   _l = true;
   switch _watersolution do {
     case 0: {
       if (surfaceIsWater [_pos select 0,_pos select 1]) then {
         _pos = +[];
       };
     };
     case 1: {
       _d = 10; _l = true;
       while {_l} do {
         for "_i" from 0 to 350 do {
           _p = [_pos,_i,_d] call _getpos;
           if (!surfaceIsWater [_p select 0,_p select 1]) exitwith {_l = false};
         };
         _d = _d + 10;
       };
       _pos = _p;
     };
     case 2: {
       _d = _pos distance _origo;
       while {_d = _d - 10; _l} do {
         _pos = [_pos,_dir,_d] call _getpos;
         if (!surfaceIsWater [_pos select 0,_pos select 1]) then {_l = false};
         if (_d < 10) then {_l = false; _pos = + []};
       };
     };
     case 3: {
       _d = _pos distance _origo;
       while {_d = _d + 10; _l} do {
         _pos = [_pos,_dir,_d] call _getpos;
         if (!surfaceIsWater [_pos select 0,_pos select 1]) then {_l = false};
         if (_d > 10000) then {_l = false; _pos = + []};
       };
     };
     case 4: {
       if (typename _dir == typename []) then {
         _d = _dir select 0;
         _dir = _dir select 0;
       } else {
         _d = _dir;
       };
       while {_l} do {
         _p = [_pos,_d,_dist] call _getpos;
         if (!surfaceIsWater [_p select 0,_p select 1]) exitwith {_l = false};
         if (_d < (_dir - 360)) then {_l = false};
         _d = _d - 10;
       };
       _pos = _p;
     };
     case 5: {
       if (typename _dir == typename []) then {
         _d = _dir select 1;
         _dir = _dir select 1;
       } else {
         _d = _dir;
       };
       while {_l} do {
         _p = [_pos,_d,_dist] call _getpos;
         if (!surfaceIsWater [_p select 0,_p select 1]) exitwith {_l = false};
         if (_d > (_dir + 360)) then {_l = false};
         _d = _d + 10;
       };
       _pos = _p;
     };
   };
 };
 _pos
};

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  

×