Jump to content

[RELEASE] Vehicle Patrols on missions


Recommended Posts

/*
	Medical Supply Camp by lazyink (Full credit for original code to TheSzerdi & TAW_Tonic)
	Updated to New Mission Format by Vampire
*/

private ["_missName","_coords","_base1","_base2","_base3","_base4","_base5","_base6","_base7","_base8","_base9","_base10","_base11","_base12","_base13","_base14","_base15","_base16","_base17","_veh1","_vehicle","_crate","_patrol"];

//Name of the Mission
_missName = "Bandit Medical Camp";

//DZMSFindPos loops BIS_fnc_findSafePos until it gets a valid result
_coords = call DZMSFindPos;

[nil,nil,rTitleText,"Bandits have Opened a Medical Camp!\nStop Them from Re-Supplying the Region!", "PLAIN",10] call RE;

//DZMSAddMajMarker is a simple script that adds a marker to the location
[_coords,_missname] ExecVM DZMSAddMajMarker;

//Create the scenery
_base1 = createVehicle ["Land_fort_artillery_nest",[(_coords select 0) - 5.939,(_coords select 1) + 10.0459,0],[], 0, "CAN_COLLIDE"];
_base1 setDir -31.158424;
[_base1] call DZMSProtectObj;
_base1 setVehicleLock "LOCKED";
_base1 setPos [(_coords select 0) - 5.939,(_coords select 1) + 10.0459,0];

_base2 = createVehicle ["Land_fort_artillery_nest",[(_coords select 0) + 6.3374, (_coords select 1) - 11.1944,0],[], 0, "CAN_COLLIDE"];
_base2 setDir -211.14516;
[_base2] call DZMSProtectObj;
_base2 setVehicleLock "LOCKED";
_base2 setPos [(_coords select 0) + 6.3374, (_coords select 1) - 11.1944,0];

_base3 = createVehicle ["Land_fort_rampart",[(_coords select 0) + 12.2456, (_coords select 1) + 6.249,0],[], 0, "CAN_COLLIDE"];
_base3 setDir -120.93051;
[_base3] call DZMSProtectObj;
_base3 setVehicleLock "LOCKED";
_base3 setPos [(_coords select 0) + 12.2456, (_coords select 1) + 6.249,0];

_base4 = createVehicle ["Land_fort_rampart",[(_coords select 0) - 11.4253, (_coords select 1) - 7.628,0],[], 0, "CAN_COLLIDE"];
_base4 setDir 59.42643;
[_base4] call DZMSProtectObj;
_base4 setVehicleLock "LOCKED";
_base4 setPos [(_coords select 0) - 11.4253, (_coords select 1) - 7.628,0];

_base5 = createVehicle ["MedBox0",[(_coords select 0) - 7.1519, (_coords select 1) + 1.8144,0],[], 0, "CAN_COLLIDE"];
_base5 setDir -29.851013;
[_base5] call DZMSProtectObj;

_base6 = createVehicle ["MedBox0",[(_coords select 0) - 7.4116, (_coords select 1) + 2.5244,0],[], 0, "CAN_COLLIDE"];
[_base6] call DZMSProtectObj;

_base7 = createVehicle ["WeaponHolder_ItemToolbox",[(_coords select 0) - 7.7041, (_coords select 1) + 3.332,0],[], 0, "CAN_COLLIDE"];
_base7 setDir -106.46461;
[_base7] call DZMSProtectObj;

_base8 = createVehicle ["Land_CamoNetVar_EAST",[(_coords select 0) + 4.1738, (_coords select 1) - 7.9112],[], 0, "CAN_COLLIDE"];
_base8 setDir -27.004126;
[_base8] call DZMSProtectObj;
_base8 setVehicleLock "LOCKED";
_base8 setPos [(_coords select 0) + 4.1738, (_coords select 1) - 7.9112];

_base9 = createVehicle ["PowGen_Big",[(_coords select 0) - 0.8936, (_coords select 1) + 8.1582,0],[], 0, "CAN_COLLIDE"];
_base9 setDir -56.044361;
[_base9] call DZMSProtectObj;

_base10 = createVehicle ["Barrel5",[(_coords select 0) - 2.5074, (_coords select 1) + 7.3466,0],[], 0, "CAN_COLLIDE"];
[_base10] call DZMSProtectObj;

_base11 = createVehicle ["Barrel5",[(_coords select 0) - 3.293, (_coords select 1) + 7.9179,0],[], 0, "CAN_COLLIDE"];
[_base11] call DZMSProtectObj;

_base12 = createVehicle ["Land_Campfire_burning",[(_coords select 0) + 3.1367, (_coords select 1) - 5.087,0],[], 0, "CAN_COLLIDE"];
[_base12] call DZMSProtectObj;

_base13 = createVehicle ["FoldChair",[(_coords select 0) + 0.8589, (_coords select 1) - 6.2676,0],[], 0, "CAN_COLLIDE"];
_base13 setDir -132.43658;
[_base13] call DZMSProtectObj;

_base14 = createVehicle ["FoldChair",[(_coords select 0) + 2.6909, (_coords select 1) - 7.4805,0],[], 0, "CAN_COLLIDE"];
_base14 setDir -184.45828;
[_base14] call DZMSProtectObj;

_base15 = createVehicle ["FoldChair",[(_coords select 0) + 5.4175, (_coords select 1) - 5.4903,0],[], 0, "CAN_COLLIDE"];
_base15 setDir 96.993355;
[_base15] call DZMSProtectObj;

_base16 = createVehicle ["FoldChair",[(_coords select 0) + 4.5722, (_coords select 1) - 7.2305,0],[], 0, "CAN_COLLIDE"];
_base16 setDir 142.91867;
[_base16] call DZMSProtectObj;

_base17 = createVehicle ["FoldChair",[(_coords select 0) + 5.0542, (_coords select 1) - 3.4649,0],[], 0, "CAN_COLLIDE"];
_base17 setDir 55.969147;
[_base17] call DZMSProtectObj;

//Create the vehicles
_veh1 = ["small"] call DZMSGetVeh;
_vehicle = createVehicle [_veh1,[(_coords select 0) - 17.5078, (_coords select 1) + 5.2578,0],[], 0, "CAN_COLLIDE"];
[_vehicle] call DZMSSetupVehicle;

//Create the loot
_crate = createVehicle ["USLaunchersBox",[(_coords select 0) - 6.8277, (_coords select 1) + 5.6748,0],[], 0, "CAN_COLLIDE"];
[_crate,"medical"] ExecVM DZMSBoxSetup;

//Spawn patrol
_patrol = ["patrol"] call DZMSGetVeh;
[[_coords],   //Position to patrol
[_coords], // Position to spawn
75, //Radius of patrol
10,                     //Number of waypoints to give
_patrol, //Classname of vehicle (make sure it has driver and gunner)
1 //Skill level of units 
] call DZMSVehiclePatrol;

//DZMSAISpawn spawns AI to the mission.
//Usage: [_coords, count, skillLevel, unitArray]
[[(_coords select 0) - 0.5635,(_coords select 1) + 0.3173,0],3,1,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
[[(_coords select 0) - 0.5635,(_coords select 1) + 0.3173,0],3,1,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
[[(_coords select 0) - 0.5635,(_coords select 1) + 0.3173,0],3,1,"DZMSUnitsMajor"] call DZMSAISpawn;
sleep 5;
[[(_coords select 0) - 0.5635,(_coords select 1) + 0.3173,0],3,1,"DZMSUnitsMajor"] call DZMSAISpawn;


//Wait until the player is within 30 meters and also meets the kill req
[_coords,"DZMSUnitsMajor"] call DZMSWaitMissionComp;

//Call DZMSSaveVeh to attempt to save the vehicles to the database
//If saving is off, the script will exit.
[_vehicle] ExecVM DZMSSaveVeh;

//Let everyone know the mission is over
[nil,nil,rTitleText,"Survivors have Taken Control of the Camp and Medical Supplies.", "PLAIN",6] call RE;
diag_log text format["[DZMS]: Major SM3 Medical Camp Mission has Ended."];
deleteMarker "DZMSMajMarker";
deleteMarker "DZMSMajDot";

//Let the timer know the mission is over
DZMSMajDone = true;

No RTP errors

Link to comment
Share on other sites

  On 4/21/2014 at 4:26 AM, insertcoins said:
//Spawn patrol
_patrol = ["patrol"] call DZMSGetVeh;
[[_coords],   //Position to patrol
[_coords], // Position to spawn
75, //Radius of patrol
10,                     //Number of waypoints to give
_patrol, //Classname of vehicle (make sure it has driver and gunner)
1 //Skill level of units 
] call DZMSVehiclePatrol;

 

When I was testing this, I was using fixed coordinates. It's possible that [_coords], needs to be replaced with _coords, 

 

In other words:

//Spawn patrol
_patrol = ["patrol"] call DZMSGetVeh;
[_coords, //Position to patrol
_coords, // Position to spawn
75, //Radius of patrol
10, //Number of waypoints to give
_patrol, //Classname of vehicle (make sure it has driver and gunner)
1 //Skill level of units
] call DZMSVehiclePatrol;

Please try that and let me know and if that fixes it, then I'll change the original post.

Link to comment
Share on other sites

I apologize for the problems people have had with this. When I was testing, I was using set coordinates and I used the variable _veh instead of _patrol, so when I went to post this, I didn't make all the proper edits. I've now fixed the original post one more time. I've changed [_coords] to just _coords without the []. I've tested it on my server and it's working properly now.

 

If anyone has an issue with it not working, then go back and make sure your code is exactly like the example. If it still doesn't work, post you mission through a pastebin.com link and post any error that appears in your RPT file.

Link to comment
Share on other sites

This code is completely untested right now, but is my first attempt to clean it up and match code from other parts of DZMS.

  Reveal hidden contents

I give no guarantees about any of this as I don't have a test server to work on, so errors/fixes are gladly welcomed. The one change is that you no longer pass the classname of the patrol vehicle as that is already taken care. Still need to find a way to arm a DZE vehicle and remove any ammo on the gunner's death. I'm not familiar enough with BIS to know if you can stack the same kind of event handlers.

P.S. Update to include the unitArray.

Edited by TheFarix
Link to comment
Share on other sites

Thanks for this, it's got potential for more creativity with DZMS.

 

One question, if I have different missions in mind to write, and I have a few different vehicle arrays I want to use for seperate missions, how do I implement them into the actual mission code? Say at most missions I'd like a PK pickup or a DSHkM, but at one particular mission I'd want a HMMWV M240 or a Armored SUV? The default array for the first pair obviously are in "patrol", the second pair I want are currently in "convoy" just for example.

//Spawn patrol
_patrol = ["convoy"] call DZMSGetVeh;

This doesn't bring up a HMMWV or SUV, in my case. It spawns in a DSHkM or PK. How do I make it right with this system?

		case "convoy": {_vehArray = DZMSConvoy;};

and

DZMSConvoy = ["HMMWV_Armored","Armored_SUV_PMC"];

are both set up in their correct places.

 

Thanks.

Link to comment
Share on other sites

  On 4/22/2014 at 2:09 AM, chipsandcheese said:

Thanks for this, it's got potential for more creativity with DZMS.

 

One question, if I have different missions in mind to write, and I have a few different vehicle arrays I want to use for seperate missions, how do I implement them into the actual mission code? Say at most missions I'd like a PK pickup or a DSHkM, but at one particular mission I'd want a HMMWV M240 or a Armored SUV? The default array for the first pair obviously are in "patrol", the second pair I want are currently in "convoy" just for example.

//Spawn patrol
_patrol = ["convoy"] call DZMSGetVeh;

This doesn't bring up a HMMWV or SUV, in my case. It spawns in a DSHkM or PK. How do I make it right with this system?

		case "convoy": {_vehArray = DZMSConvoy;};

and

DZMSConvoy = ["HMMWV_Armored","Armored_SUV_PMC"];

are both set up in their correct places.

 

Thanks.

 

Is DZMSConvoy = ["HMMWV_Armored","Armored_SUV_PMC"]; in the DZMSConfig.sqf file? Also, are those the right classnames for those vehicles?

Link to comment
Share on other sites

  On 4/22/2014 at 4:17 AM, TheFarix said:

The classes you are looking for are HMMWV_M1151_M2_CZ_DES_EP1_DZ and ArmoredSUV_PMC_DZ.

 

  On 4/22/2014 at 2:38 AM, BetterDeadThanZed said:

Is DZMSConvoy = ["HMMWV_Armored","Armored_SUV_PMC"]; in the DZMSConfig.sqf file? Also, are those the right classnames for those vehicles?

Hello and thanks. The classnames were examples. I tried with HMMWV_M1151_M2_CZ_DES_EP1_DZ & some other specific Epoch-class vehicles before posting my query. And yes, the line below is in DZMSConfig.sqf. I've made other arrays in there already that work fine for regular missions that I wrote or edited, before ever trying your patrols code.

DZMSConvoy = ["classname","classname"];

EDIT:

I suppose the part that makes the "patrol" class vehicles spawn is in DZMSVehiclePatrol.sqf

_patrol = ["patrol"] call DZMSGetVeh;

I've tried changing that to the line below but that doesn't make a difference.

_patrol = ["patrol","convoy"] call DZMSGetVeh;

Is there an alternative way to just spawn in one particular vehicle for a patrol on one particular mission? Such as using createvehicle or something?

Link to comment
Share on other sites

The problem is that DZMSVehiclePatrol itself calls DZMSGetVeh to get a classname and any classname you passed to it is ignored. One other issues is that vehicles created by DZMSVehiclePatrol will not be saved into the database regardless of whether DZMSSaveVehicles is set to true or not. Maybe these can be addressed by rethinking how DZMSVehiclePatrol is invoked.

Link to comment
Share on other sites

  On 4/22/2014 at 3:09 PM, TheFarix said:

The problem is that DZMSVehiclePatrol itself calls DZMSGetVeh to get a classname and any classname you passed to it is ignored. One other issues is that vehicles created by DZMSVehiclePatrol will not be saved into the database regardless of whether DZMSSaveVehicles is set to true or not. Maybe these can be addressed by rethinking how DZMSVehiclePatrol is invoked.

 

This should work: Just comment out "_patrol = ["patrol"] call DZMSGetVeh;" in DZMSVehiclePatrol.sqf since _patrol is defined in the mission. I'm not real sure why I even have that in the DZMSVehiclePatrol.sqf.  

 

The problem of not being able to save the vehicles that are spawning was addressed in the first post. Due to my limited knowledge, I can't make it so the vehicles can be saved. I'm sure someone can expand on that, though, and fix it.

Link to comment
Share on other sites

Just to add, the only way to add a second vehicle array was to have a second "install" of the add-on, and rename everything to have a 2 on the end or something similar.

 

i.e.

_patrol --> _patrol2

"patrol" --> "patrol2"

DZMSVehiclePatrol.sqf --> DZMSVehiclePatrol2.sqf

 

And so on. I wanted lower-end armed vehicles for most missions, and then higher-end vehicles for the biggest two missions. With this I now can. Thanks again.

Link to comment
Share on other sites

AI not spawning at missions only at the vehicle portal ones

Do I use this one or the other one?
 

//Spawn patrol
_patrol = ["patrol"] call DZMSGetVeh;
[_coords,   //Position to patrol
_coords, // Position to spawn
75, //Radius of patrol
10,                     //Number of waypoints to give
_patrol, //Classname of vehicle (make sure it has driver and gunner)
1 //Skill level of units 
] call DZMSVehiclePatrol;
Link to comment
Share on other sites

Getting this error
 

5:31:45 Error in expression <= ["patrol"] call DZMSGetVeh;
_patrol = createVehicle [_patrol, [(_startingpos s>
5:31:45 Error position: <createVehicle [_patrol, [(_startingpos s>
5:31:45 Error Type Any, expected String
5:31:45 File z\addons\dayz_server\DZMS\Scripts\DZMSVehiclePatrol.sqf, line 17

Mission.sqf file

  Reveal hidden contents

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
×
×
  • Create New...