Jump to content
  • 0

How do you go about adding custom AI Missions?


duncajcb

Question

So ive been playing around with 

 

http://opendayz.net/threads/release-dayzchernarus-mission-system.12169/

 

and it has gotten me more interested in adding full AI missions to the server.  For example, a convoy traveling from one end of the map to another, with AI defense and lootable cargo trucks.  Or adding a simple static spawn point for a bandit camp.  The problem is, no where can I find a tutorial on the subject without downloading a ton of mods to addon to the server which really are not configurable.

 

I have been studying the mission system code above and will likely start a trial and error process using it.  But I am hoping there is a tutorial or anything to point me in the right direction.

 

Any thoughts?

Link to comment
Share on other sites

23 answers to this question

Recommended Posts

  • 0

The original AI code that mission is based on is also on open dayz as is the bus code which deals with ai driving.

Google arma2 ai convoy for tips on getting troops driving. There's not much in the way of all out tutorials.

It is very much trial and error, am currently working on just this sort of thing and the AI are as dumb as a bag of spanners when behind the wheel :)

Good luck.

Link to comment
Share on other sites

  • 0

Im not sure how much you understand or how much you are trying to accomplish.  But so far I have had great success taking Sarge AI and modifying it.  In the process of playing with it I have developed a meager understanding of how the AI system works along with the predefined functions arma has implemented within.

 

The best resource I have found is the BI Studios Wiki...has everything about the games architecture pretty well defined and explained.

http://community.bistudio.com/wiki/Main_Page

Link to comment
Share on other sites

  • 0

This is actually what I have been using so far in the events.  I have it set to run on the 16th minute of every hour.

 

 

 

diag_log format["SAR_AI:  Mission Skalitsy Started"];
 
WaitUntil {SkalitsyGO == 1};
 
 x=floor (random 4);
     if (x  == 0) then
          {
SkalitsyGO = 0;
 
//spawn buildings
 
 
_skalitsyrunover = createVehicle ["Land_Fort_Watchtower_EP1",[13679.783, 2934.7036, -0.00023651123],[], 0, "CAN_COLLIDE"];
_skalitsyrunover1 = createVehicle ["M1130_HQ_unfolded_Base_EP1",[13716.168, 2918.2166, -0.28262553],[], 0, "CAN_COLLIDE"];
_skalitsyrunover2 = createVehicle ["WarfareBCamp",[13742.401, 2895.6536, -0.44364271],[], 0, "CAN_COLLIDE"];
_skalitsyrunover3 = createVehicle ["WarfareBDepot",[13709.222, 2896.3152, -0.42108104],[], 0, "CAN_COLLIDE"];
_skalitsyrunover4 = createVehicle ["Land_Fort_Watchtower_EP1",[13674.55, 2865.021, -3.8146973e-005],[], 0, "CAN_COLLIDE"];
 
_skalitsyrunover setVariable ["Sarge",1,true];
_skalitsyrunover1 setVariable ["Sarge",1,true];
_skalitsyrunover2 setVariable ["Sarge",1,true];
_skalitsyrunover3 setVariable ["Sarge",1,true];
_skalitsyrunover4 setVariable ["Sarge",1,true];
 
_skalitsyrunover setDir 41;
_skalitsyrunover1 setDir 78;
_skalitsyrunover2 setDir -86;
_skalitsyrunover4 setDir -34;
 
//set markers
_this = createMarker ["SAR_marker_Skalitsy", [13679.783, 2934.7036,0]];
_this setMarkerShape "RECTANGLE";
_this setMarkeralpha 0;
_this setMarkerType "Flag";
_this setMarkerBrush "Solid";
_this setMarkerSize [500, 500];
_this setMarkerDir 120.050;
SAR_marker_Skalitsy = _this;
//spawn troops
[sAR_marker_Skalitsy,3,4,4,"fortify",false] call SAR_AI;
[sAR_marker_Skalitsy,3,4,4,"fortify",false] call SAR_AI;
[sAR_marker_Skalitsy,3,0,4,"patrol",true,21600] call SAR_AI;
[sAR_marker_Skalitsy,3,1,3,"patrol",true,21600] call SAR_AI;
[sAR_marker_Skalitsy,3,0,5,"patrol",true,21600] call SAR_AI;
 
// Heli Patrol
_this = createMarker ["SAR_marker_skalitsy_mission_heli", [13679, 2934,0]];
_this setMarkerShape "RECTANGLE";
_this setMarkeralpha 0;
_this setMarkerType "Flag";
_this setMarkerBrush "Solid";
_this setMarkerSize [1000, 1000];
_this setMarkerDir 120.050;
SAR_marker_skalitsy_mission_heli = _this;
 
[sAR_marker_skalitsy_mission_heli,3] call SAR_AI_heli;
 
 
  
//spawn loots     
_crate4 = createVehicle ["USVehicleBox",[13727.629, 2893.939,0],[], 0, "CAN_COLLIDE"];
[_crate4] execVM "\z\addons\dayz_server\missions\misc\fillBoxesmilitary.sqf";
 
_crate4 setVariable ["Sarge",1,true];
 
_crate3 = createVehicle ["USVehicleBox",[6899, 11433,0],[], 0, "CAN_COLLIDE"];
[_crate3] execVM "\z\addons\dayz_server\missions\misc\fillBoxesH.sqf";
 
_crate3 setVariable ["Sarge",1,true];
 
 
 
//reports   
[nil,nil,"per",rTITLETEXT,"Bandits have made a base on Skalitsy Island!","PLAIN",10] call RE;
  
waitUntil{{isPlayer _x && _x distance _crate4 < 10  } count playableunits > 0}; 
 
[nil,nil,rTitleText,"Skalitsy Island is under survivor control!", "PLAIN",6] call RE;
 
diag_log format["SAR_AI: Mission Skalitsy Finished"];
 
deletemarker 'SAR_marker_Skalitsy';
deletemarker 'SAR_marker_skalitsy_mission_heli';
 
SkalitsyGo = 1;
 
 
};
 

 
 
This brings up two questions.
 
Ive been using setdir to complete the facing, but that does not seem to work for me.  how do i go about setting the facing for the vehicles?
 
The second question:  with the epoch event system, I cant seem to figure out which time it runs on.
 

EpochEvents = [[year,month, day, hour, minute,"hello_word"]];
 
I cant seem to figure out which time the event scheduler uses.
Is it using GMT, the 'SetDate' time, or some other time?
Link to comment
Share on other sites

  • 0

so this ---->

 

_skalitsyrunover = createVehicle ["Land_Fort_Watchtower_EP1",[13679.783, 2934.7036, -0.00023651123],[], 0, "CAN_COLLIDE"];

 

would look like this? --->

 

this and (isNil "_skalitsyrunover "_skalitsyrunover = createVehicle ["Land_Fort_Watchtower_EP1",[13679.783, 2934.7036, -0.00023651123],[], 0, "CAN_COLLIDE"];

Link to comment
Share on other sites

  • 0

which would mean that...

 

//spawn loots     
if (isnil "_crate4 ") then {
                                      _crate4 = createVehicle ["USVehicleBox",[13727.629, 2893.939,0],[], 0, "CAN_COLLIDE"];
 
                                      [_crate4] execVM "\z\addons\dayz_server\missions\misc\fillBoxesmilitary.sqf";
                                      _crate4 setVariable ["Sarge",1,true];
                                     }
                             else {[_crate4] execVM "\z\addons\dayz_server\missions\misc\fillBoxesmilitary.sqf";};
 
would check to see if crate4 exists...if it does not then it spawns as normal.  but if it does exist then it would call "fillboxesmilitary.sqf" (which fills the box with the appropriate loot).
 
 
On a side note Axeman...thank you for pointing me in the right direction through this process...your guidance has greatly improved my understanding of scripting.
Link to comment
Share on other sites

  • 0

So I implemented the concept above but now when the players approach the loot boxes the mission does not deactivate and continue through to remove the markers and allow for further missions.

 

diag_log format["Mission Military SMA1 supply point Started"];
 
 
private ["_coords","_wait","_MainMarker100"];
[] execVM "\z\addons\dayz_server\Missions\SMGoMilitary.sqf";
WaitUntil {MissionGoMilitary == 1};
 
[nil,nil,rTitleText,"The military has setup a supply point! Check your map for the location!", "PLAIN",10] call RE;
 
XCoords = [3643.7451, 10311.222, 0];
publicVariable "XCoords";
[] execVM "debug\addmarkers100.sqf";
 
 
// if (MissionSMA1Ran == 0) then 
// {
// MissionSMA1Ran = 1;
 
_baserunoverX1 = createVehicle ["WarfareBDepot",[3668.3704, 10313.976, -0.46294877],[], 0, "CAN_COLLIDE"];
_baserunoverX2 = createVehicle ["USMC_WarfareBVehicleServicePoint",[3639.135, 10324.632, 0],[], 0, "CAN_COLLIDE"];
_baserunoverX3 = createVehicle ["Fort_Barracks_USMC",[3635.5115, 10277.292, 3.0517578e-005],[], 0, "CAN_COLLIDE"];
 
_baserunoverX1 setVariable ["Sarge",1,true];
_baserunoverX2 setVariable ["Sarge",1,true];
_baserunoverX3 setVariable ["Sarge",1,true];
 
_baserunoverX2 setdir -138;
_baserunoverX3 setdir 125;
 
 
// _hummerX1 = createVehicle ["HMMWV_DZ",[3645.9202, 10271.602, -6.1035156e-005],[], 0, "CAN_COLLIDE"];
// _hummerX2 = createVehicle ["KamazRefuel_DZ",[3670.7649, 10296.663, -3.0517578e-005],[], 0, "CAN_COLLIDE"];
// _hummerX3 = createVehicle ["V3S_Supply_TK_GUE_EP1",[3672.2231, 10290.687, 0],[], 0, "CAN_COLLIDE"];
 
// _hummerX1 setVariable ["Sarge",1,true];
// _hummerX2 setVariable ["Sarge",1,true];
// _hummerX3 setVariable ["Sarge",1,true];
 
 
_cratesma1 = createVehicle ["USSpecialWeaponsBox",[3643.7451, 10311.222, -3.0517578e-005],[], 0, "CAN_COLLIDE"];
[_cratesma1] execVM "\z\addons\dayz_server\missions\misc\fillBoxesMilitary.sqf";
 
_cratesma1 setVariable ["Sarge",1,true];
// }
// else 
// {
// [_cratesma1] execVM "\z\addons\dayz_server\missions\misc\fillBoxesMilitary.sqf";
// };
 
 
 
//set markers
_this = createMarker ["SAR_marker_sma1", [3643.7451, 10311.222, 0]];
_this setMarkerShape "RECTANGLE";
_this setMarkeralpha 0;
_this setMarkerType "Flag";
_this setMarkerBrush "Solid";
_this setMarkerSize [250, 250];
_this setMarkerDir 120.050;
SAR_marker_sma1 = _this;
 
//spawn troops
[sAR_marker_sma1,1,3,10,"fortify",false] call SAR_AI;
[sAR_marker_sma1,1,0,4,"patrol",false] call SAR_AI;
[sAR_marker_sma1,1,0,4,"patrol",false] call SAR_AI;
 
 
//Vehicles
_this = createMarker ["SAR_marker_sma1v", [3643.7451, 10311.222, 0]];
_this setMarkerShape "RECTANGLE";
_this setMarkeralpha 0;
_this setMarkerType "Flag";
_this setMarkerBrush "Solid";
_this setMarkerSize [350, 350];
_this setMarkerDir 120.050;
SAR_marker_sma1v = _this;
 
[sAR_marker_sma1v,1,["HMMWV_Armored"],[[1,0,2]],false] call SAR_AI_land;
 
 
waitUntil{{isPlayer _x && _x distance _cratesma1 < 10  } count playableunits > 0}; 
 
[nil,nil,rTitleText,"The military supply point is under survivor control!", "PLAIN",6] call RE;
 
[] execVM "debug\remmarkers100.sqf";
MissionGoMilitary = 0;
publicVariable "MissionGoMilitary";
XCoords = 0;
publicVariable "XCoords";
deletemarker 'SAR_marker_sma1';
deletemarker 'SAR_marker_sma1v';
 
SM1 = 1;
[0] execVM "\z\addons\dayz_server\missions\military\SMfinder.sqf";
 

 
I have commented out the sections involving the check for a previously ran mission as a temporary fix since this is a live server.  
 
Red indicates the check to see if they exist.
Blue Indicates the two possibilities dependant upon whether or not the mission has previously been executed.
Green indicates the trigger for the end of mission which causes the markers to be deleted and the next mission to activate.
 
The issue indicates that there is an error somewhere in the script but I cannot seem to find it.  Hopefully a second pair of eyes can spot it. 
 
Would there be a better method for this approach?
Link to comment
Share on other sites

  • 0

Hey Duncajcb, this is a snip of one of the mission files... and there's spacing in this that I didn't find in yours there

waitUntil{{isPlayer _x && _x distance _baserunover < 5  } count playableunits > 0};

Would that be the problem there???

 

Soz if I'm wasting your time there, still learning aobut the code... I can follow a tut/instructions on it...

 

still learning to modify it myself..

 

Bags

 

p.s. After reading the mission file again..I'll post the whole thing... might make more sense

//Medical Outpost by lazyink (Full credit for code to TheSzerdi & TAW_Tonic)

private ["_coords","_wait","_MainMarker75"];
[] execVM "\z\addons\dayz_server\Missions\SMGoMinor.sqf";
WaitUntil {MissionGoMinor == 1};


_coords =  [getMarkerPos "center",0,5500,10,0,20,0] call BIS_fnc_findSafePos;

[nil,nil,rTitleText,"A group of bandits have taken over a Medical Outpost! Check your map for the location!", "PLAIN",10] call RE;

MCoords = _coords;
publicVariable "MCoords";
[] execVM "debug\addmarkers75.sqf";

_baserunover = createVehicle ["US_WarfareBFieldhHospital_Base_EP1",[(_coords select 0) +2, (_coords select 1)+5,-0.3],[], 0, "CAN_COLLIDE"];
_baserunover1 = createVehicle ["MASH_EP1",[(_coords select 0) - 24, (_coords select 1) - 5,0],[], 0, "CAN_COLLIDE"];
_baserunover2 = createVehicle ["MASH_EP1",[(_coords select 0) - 17, (_coords select 1) - 5,0],[], 0, "CAN_COLLIDE"];
_baserunover3 = createVehicle ["MASH_EP1",[(_coords select 0) - 10, (_coords select 1) - 5,0],[], 0, "CAN_COLLIDE"];
_baserunover4 = createVehicle ["UAZ_Unarmed_UN_EP1",[(_coords select 0) + 10, (_coords select 1) - 5,0],[], 0, "CAN_COLLIDE"];
_baserunover5 = createVehicle ["HMMWV_DZ",[(_coords select 0) + 15, (_coords select 1) - 5,0],[], 0, "CAN_COLLIDE"];
_baserunover6 = createVehicle ["SUV_DZ",[(_coords select 0) + 25, (_coords select 1) - 15,0],[], 0, "CAN_COLLIDE"];

_baserunover setVariable ["Mission",1,true];
_baserunover1 setVariable ["Mission",1,true];
_baserunover2 setVariable ["Mission",1,true];
_baserunover3 setVariable ["Mission",1,true];
_baserunover4 setVariable ["Mission",1,true];
_baserunover5 setVariable ["Mission",1,true];
_baserunover6 setVariable ["Mission",1,true];


_crate = createVehicle ["USVehicleBox",[(_coords select 0) - 3, _coords select 1,0],[], 0, "CAN_COLLIDE"];
[_crate] execVM "\z\addons\dayz_server\missions\misc\fillBoxesM.sqf";
_crate setVariable ["Mission",1,true];

_crate2 = createVehicle ["USLaunchersBox",[(_coords select 0) - 8, _coords select 1,0],[], 0, "CAN_COLLIDE"];
[_crate2] execVM "\z\addons\dayz_server\missions\misc\fillBoxesS.sqf";
_crate2 setVariable ["Mission",1,true];


[[(_coords select 0) - 20, (_coords select 1) - 15,0],40,4,2,0] execVM "\z\addons\dayz_server\missions\add_unit_server2.sqf";//AI Guards
sleep 3;
[[(_coords select 0) + 10, (_coords select 1) + 15,0],40,4,2,0] execVM "\z\addons\dayz_server\missions\add_unit_server2.sqf";//AI Guards
sleep 3;
[[(_coords select 0) - 10, (_coords select 1) - 15,0],40,4,2,0] execVM "\z\addons\dayz_server\missions\add_unit_server2.sqf";//AI Guards
sleep 3;
[[(_coords select 0) + 20, (_coords select 1) + 15,0],40,4,2,0] execVM "\z\addons\dayz_server\missions\add_unit_server2.sqf";//AI Guards
sleep 3;


waitUntil{{isPlayer _x && _x distance _baserunover < 5  } count playableunits > 0}; 

[nil,nil,rTitleText,"The Medical Outpost is under survivor control!", "PLAIN",6] call RE;

[] execVM "debug\remmarkers75.sqf";
MissionGoMinor = 0;
MCoords = 0;
publicVariable "MCoords";



SM1 = 1;
[0] execVM "\z\addons\dayz_server\missions\minor\SMfinder.sqf";

Link to comment
Share on other sites

  • 0

 

Hey Duncajcb, this is a snip of one of the mission files... and there's spacing in this that I didn't find in yours there

waitUntil{{isPlayer _x && _x distance _baserunover < 5  } count playableunits > 0};

Would that be the problem there???

 

 

im not seeing any difference in spacing between the two examples

 

waitUntil{{isPlayer _x && _x distance _cratesma1 < 10  } count playableunits > 0}; 
waitUntil{{isPlayer _x && _x distance _baserunover < 5  } count playableunits > 0};
Link to comment
Share on other sites

  • 0

an update to the trouble shooting...

after commenting the above sections in red out I no longer have an issue with the mission deactivation trigger.  so im fairly confident the issue is specific to the check.

 

I will be trying :

 

if (isnil (_cratesma1)) then {} else {};

 

and a simplified

 

if (isnil (_cratesma1)) then {};

 

hopefully one of these options will work as I have yet to find an error in the script.

 

could it be that the script is getting hung on the "else" portion?

Link to comment
Share on other sites

  • 0

i dont have an issue with the same mission running two times in a row.  the way its setup, on the 16 minute of every hour the script is run.  and then there is a 1 in 6 chance the script will spawn the mission itself.  If the mission activates and the AI/loot is spawned, then the mission cannot run a second time.  If in the unlikely scenario (1 in 36) where the mission double triggers, there is a 30 minute delay before the mission can run immediately after.

 

Currently the primary issue is with double spawning vehicles which can glitch the mission ever so slightly.  Hence the check using either isnil, isnull, or a predefined variable.  with these checks working properly, a duplicate mission would only refill the loot boxes and spawn new AI.

 

Ultimately I am attempting to provide an unpredictable environment.  So that players who play at different times will receive a similar experience.

 

Ive actually got about 18 similar missions operating on the server with limiters preventing more than 3 being available at one time. I am just using this one as an example.

Link to comment
Share on other sites

  • 0

I've got a question I'd like to add to this thread because it kind of ties in nicely with the overall learning aspect of things :D

 

How do you check for the presence of players and preventing the event from spawning until the players have moved out of bounds? I always thought that the BIS_fnc_findSafePos took care of that, but evidently not as the other day one of my players was taking off from a previous mission he'd just looted when another one spawned directly below him and he was nailed on the spot (I have my AI set to 89% minimum on all settings) ... 

 

Any ideas on this problem ? 

Link to comment
Share on other sites

  • 0

&nbsp;

I've got a question I'd like to add to this thread because it kind of ties in nicely with the overall learning aspect of things :D

&nbsp;

How do you check for the presence of players and preventing the event from spawning until the players have moved out of bounds? I always thought that the BIS_fnc_findSafePos took care of that, but evidently not as the other day one of my players was taking off from a previous mission he'd just looted when another one spawned directly below him and he was nailed on the spot (I have my AI set to 89% minimum on all settings) ...&nbsp;

&nbsp;

Any ideas on this problem ?&nbsp;

&nbsp;

I would think this would work...

waitUntil{{isPlayer _x && _x distance _lootbox < 10 } count playableunits > 0};

waitUntil{{isPlayer _x && _x distance _lootbox > 200 } count playableunits > 0};

the first check would make it so that a player would have to go to the loot box to pass the first check. then a player would have to be 200 meters from the loot box to pass the second check.

and i thought this through...would only really work if there was 1 player on server or they were all together...so we would need to find a way to tag the player who went next to the loot box.

Link to comment
Share on other sites

  • 0

&nbsp; &nbsp;

I would think this would work...

waitUntil{{isPlayer _x && _x distance _lootbox < 10 } count playableunits > 0};

waitUntil{{isPlayer _x && _x distance _lootbox > 200 } count playableunits > 0};

the first check would make it so that a player would have to go to the loot box to pass the first check. then a player would have to be 200 meters from the loot box to pass the second check.

and i thought this through...would only really work if there was 1 player on server or they were all together...so we would need to find a way to tag the player who went next to the loot box.

 

Yeah I tried that already.  I'm thinking that a trigger or marker needs to be created first, then if a player is within that marker the script just waits.. when no players are inside the marker, it runs.  But my arma coding knowledge doesn't stretch that far, I have the concept and ideas in my head but no way of putting onto paper lol :(

Link to comment
Share on other sites

  • 0

Here is what I used on my mission script to check if a player had entered the area.


waitUntil
{
    sleep 1;
    _playerPresent = false;
    {if((isPlayer _x) AND (_x distance wpbox3 <= 30)) then {_playerPresent = true};}forEach playableUnits;
    (_playerPresent)
};

wpbox3 is a ammo box spawned by the mission that get deleted later after a set amount of time.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...