BetterDeadThanZed Posted April 18, 2014 Report Share Posted April 18, 2014 By following these directions, you can add a vehicle patrol to any mission. Please note that the code to spawn the AI vehicle comes from Wicked AI (WAI). I made small changes to make it work with DZMS because that's my skill level when it comes to modding right now. Step 1: Download DZMSVehiclePatrol.sqf and put it in your DZMS\Scripts folder: https://www.dropbox.com/s/8kg5c5v360zijz0/DZMSVehiclePatrol.sqf Step 2: Open DZMSConfig.sqf and find this: //Large Vehicles (Urals) DZMSLargeVic = ["Ural_TK_CIV_EP1"]; Underneath that, put this: //Patrol Vehicles DZMSPatrolVeh = ["Offroad_DSHKM_Gue_DZ","Pickup_PK_GUE_DZ","Pickup_PK_INS","Pickup_PK_TK_GUE_EP1"]; Feel free to add the classnames of the vehicles you wish to patrol a mission. Step 3: Open DZMSFunctions.sqf and find this: DZMSAISpawn = compile preprocessFileLineNumbers "\z\addons\dayz_server\DZMS\Scripts\DZMSAISpawn.sqf"; Below that, add this: DZMSVehiclePatrol = compile preprocessFileLineNumbers "\z\addons\dayz_server\DZMS\Scripts\DZMSVehiclePatrol.sqf"; Further down, find this: case "large": {_vehArray = DZMSLargeVic;}; }; Replace it with this: case "large": {_vehArray = DZMSLargeVic;}; case "patrol": {_vehArray = DZMSPatrolVeh;}; }; Step 4. You are now ready to add a patrol to your mission. Find the line that looks similar to this: private ["_missName","_coords","_vehicle","_patrol"]; Insert "_patrol" in the line so it looks like this: private ["_missName","_coords","_vehicle","_patrol","_patrol"]; The actual contents of that line will vary according to the mission, so just insert it at the end. To insert a patrol, use this sample code and place it below the section that spawns the "scenery" or other non-AI items: //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; The difference between "Position to patrol" and "Position to spawn" is that if you create a different spawn point for "Position to spawn", the vehicle will start at that location and make it's way to it's patrol area. For example, if you have a bandit base located at 2684.03, 5621.7349, 0, then you could change the second line line this: //Spawn patrol _patrol = ["patrol"] call DZMSGetVeh; [_coords, //Position to patrol [2684.03, 5621.7349, 0], // 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; For most players, it probably isn't neccessary to have different starting and patrol coordinates. As a matter of fact, AI vehicles tend to get caught up on stuff so it might not even make it to the mission if you spawn it far away. The radius of patrol is how far out the vehicle will patrol. Waypoints can be adjusted. I haven't played with that setting too much. More way points might make it more agile. Sample code from a mission: /* Bandit Hunting Party by lazyink (Full credit to TheSzerdi & TAW_Tonic for the code) Updated to new format by Vampire */ private ["_missName","_coords","_vehicle","_patrol"]; //Name of the Mission _missName = "Bandit Squad"; //DZMSFindPos loops BIS_fnc_findSafePos until it gets a valid result _coords = call DZMSFindPos; [nil,nil,rTitleText,"A Bandit Squad has been spotted!\nStop them from completing their patrol!", "PLAIN",10] call RE; //DZMSAddMinMarker is a simple script that adds a marker to the location [_coords,_missName] ExecVM DZMSAddMinMarker; //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,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 5; [_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 5; [_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 5; [_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 1; //Wait until the player is within 30 meters and also meets the kill req [_coords,"DZMSUnitsMinor"] call DZMSWaitMissionComp; //Let everyone know the mission is over [nil,nil,rTitleText,"The Bandit Squad has been Wiped Out!", "PLAIN",6] call RE; diag_log text format["[DZMS]: Minor SM1 Bandit Squad Mission has Ended."]; deleteMarker "DZMSMinMarker"; deleteMarker "DZMSMinDot"; //Let the timer know the mission is over DZMSMinDone = true; I will try to answer whatever questions I can. I suspect there's some extra code in there that I don't need, so for those of you with more coding experience than me, please chime in on how I can improve this. http://www.youtube.com/watch?v=SM65RX1YwsI Triage 1 Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 18, 2014 Author Report Share Posted April 18, 2014 Left something out on the initial post. New directions after the "DZMSVehiclePatrol" section added. Link to comment Share on other sites More sharing options...
Achmed Posted April 18, 2014 Report Share Posted April 18, 2014 By following these directions, you can add a vehicle patrol to any mission. Please note that the code to spawn the AI vehicle comes from Wicked AI (WAI). May be a silly question, but is WAI required for this to work? Link to comment Share on other sites More sharing options...
insertcoins Posted April 18, 2014 Report Share Posted April 18, 2014 May be a silly question, but is WAI required for this to work? Think not, DZMS only uses relations set up by other ai mods, not the actual units Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 18, 2014 Author Report Share Posted April 18, 2014 May be a silly question, but is WAI required for this to work? No. It's not. I took the vehicle patrol script from WAI and converted it to work with DZMS. Link to comment Share on other sites More sharing options...
Triage Posted April 18, 2014 Report Share Posted April 18, 2014 Nice work zed Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 18, 2014 Author Report Share Posted April 18, 2014 Added a video to the first post. At the end, you see me shoot the gunner and the vehicle blows up. That no longer happens. Link to comment Share on other sites More sharing options...
insertcoins Posted April 18, 2014 Report Share Posted April 18, 2014 Added a video to the first post. At the end, you see me shoot the gunner and the vehicle blows up. That no longer happens. great, now how am I supposed to impress my date? Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 18, 2014 Author Report Share Posted April 18, 2014 Maybe someone can help me out here. Any way to make it so one of the mission AI would take over in the case of the gunner being shot? Link to comment Share on other sites More sharing options...
ThaThing Posted April 19, 2014 Report Share Posted April 19, 2014 Hey there Nice work. Tried to get it to work earlier today, but for some reason it didn't work. Followed the instructions as you wrote and I added the sample code just above: //DZMSAISpawn spawns AI to the mission. But when i started the server and went to the missions it didn't spawn any ai's and the supply drop plane don't drop the crate. Hope you have any idea why, would love to get it in my missions. Link to comment Share on other sites More sharing options...
OSMOX Posted April 19, 2014 Report Share Posted April 19, 2014 Hello if you have a moment mind chatting about something that is possible but not sure how to do it. Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 19, 2014 Author Report Share Posted April 19, 2014 Hey there Nice work. Tried to get it to work earlier today, but for some reason it didn't work. Followed the instructions as you wrote and I added the sample code just above: //DZMSAISpawn spawns AI to the mission. But when i started the server and went to the missions it didn't spawn any ai's and the supply drop plane don't drop the crate. Hope you have any idea why, would love to get it in my missions. Post your SMX.sqf mission file and I'll have a look. Link to comment Share on other sites More sharing options...
Asian Kid Posted April 19, 2014 Report Share Posted April 19, 2014 Can you post your one of your missions? Link to comment Share on other sites More sharing options...
TheFarix Posted April 20, 2014 Report Share Posted April 20, 2014 Just a curious question. Why name the patrol vehicle array DZMSPatrolVeh instead of DZMSPatrolVic? I would think that consistency among the array names would be beneficial for those modifying the script later. Not that it really maters. Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 20, 2014 Author Report Share Posted April 20, 2014 Just a curious question. Why name the patrol vehicle array DZMSPatrolVeh instead of DZMSPatrolVic? I would think that consistency among the array names would be beneficial for those modifying the script later. Not that it really maters. I guess because I have no idea what "Vic" is supposed to mean. "Veh" is more identifiable as "Vehicle". Feel free to name it what you want when you install it on your server. :) Link to comment Share on other sites More sharing options...
OSMOX Posted April 20, 2014 Report Share Posted April 20, 2014 For some reason this wont work or breaks my missions. Mind looking at my mission if so i gave you my ts . Thx Link to comment Share on other sites More sharing options...
TheFarix Posted April 20, 2014 Report Share Posted April 20, 2014 I noticed a couple of mistakes in the examples. First, you are missing an opening bracket for the function call to DZMSVehiclePatrol. So it should be as follows: //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; Second, you need to make sure that _veh is declared as a private value. Using the example for the minor mission SM1, it should look like this: /* Bandit Hunting Party by lazyink (Full credit to TheSzerdi & TAW_Tonic for the code) Updated to new format by Vampire */ private ["_missName","_coords","_patrol"]; //Name of the Mission _missName = "Bandit Squad"; //DZMSFindPos loops BIS_fnc_findSafePos until it gets a valid result _coords = call DZMSFindPos; [nil,nil,rTitleText,"A Bandit Squad has been spotted!\nStop them from completing their patrol!", "PLAIN",10] call RE; //DZMSAddMinMarker is a simple script that adds a marker to the location [_coords,_missName] ExecVM DZMSAddMinMarker; //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,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 5; [_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 5; [_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 5; [_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 1; //Wait until the player is within 30 meters and also meets the kill req [_coords,"DZMSUnitsMinor"] call DZMSWaitMissionComp; //Let everyone know the mission is over [nil,nil,rTitleText,"The Bandit Squad has been Wiped Out!", "PLAIN",6] call RE; diag_log text format["[DZMS]: Minor SM1 Bandit Squad Mission has Ended."]; deleteMarker "DZMSMinMarker"; deleteMarker "DZMSMinDot"; //Let the timer know the mission is over DZMSMinDone = true; I haven't tested this yet, but these were two of the obvious errors that stuck out at me. P.S. Since many missions uses vehicles as scenery and declares a _veh or a _veh1, you may be better off using _patrol as the variable. I've updated the examples to reflect that. Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 20, 2014 Author Report Share Posted April 20, 2014 I noticed a couple of mistakes in the examples. First, you are missing an opening bracket for the function call to DZMSVehiclePatrol. So it should be as follows: //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; Second, you need to make sure that _veh is declared as a private value. Using the example for the minor mission SM1, it should look like this: /* Bandit Hunting Party by lazyink (Full credit to TheSzerdi & TAW_Tonic for the code) Updated to new format by Vampire */ private ["_missName","_coords","_patrol"]; //Name of the Mission _missName = "Bandit Squad"; //DZMSFindPos loops BIS_fnc_findSafePos until it gets a valid result _coords = call DZMSFindPos; [nil,nil,rTitleText,"A Bandit Squad has been spotted!\nStop them from completing their patrol!", "PLAIN",10] call RE; //DZMSAddMinMarker is a simple script that adds a marker to the location [_coords,_missName] ExecVM DZMSAddMinMarker; //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,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 5; [_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 5; [_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 5; [_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn; sleep 1; //Wait until the player is within 30 meters and also meets the kill req [_coords,"DZMSUnitsMinor"] call DZMSWaitMissionComp; //Let everyone know the mission is over [nil,nil,rTitleText,"The Bandit Squad has been Wiped Out!", "PLAIN",6] call RE; diag_log text format["[DZMS]: Minor SM1 Bandit Squad Mission has Ended."]; deleteMarker "DZMSMinMarker"; deleteMarker "DZMSMinDot"; //Let the timer know the mission is over DZMSMinDone = true; I haven't tested this yet, but these were two of the obvious errors that stuck out at me. P.S. Since many missions uses vehicles as scenery and declares a _veh or a _veh1, you may be better off using _patrol as the variable. I've updated the examples to reflect that. _patrol is already used but in the examples, I apparently only put it in one of the examples though. _patrol is defined. Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 20, 2014 Author Report Share Posted April 20, 2014 I've updated the original post. I made some mistakes. I forgot to change some of the _veh to _patrol in my example and I didn't mention the "private" line. I already fixed that in my own file because I initially used _veh but since that's used for spawning items in the missions, I switched it to _patrol, but didn't put that in this post. Look for "You are now ready to add a patrol to your mission." in the instructions. There are new steps there. If you tried this and had a problem, please start over from the first step and set it up as per the updated instructions. If you are having a problem, feel free to post a pastebin link to your mission. Link to comment Share on other sites More sharing options...
TheFarix Posted April 20, 2014 Report Share Posted April 20, 2014 What about the opening bracket for the DZMSVehiclePatrol call? You have a closing one, but no opening bracket. Wouldn't this produce an error? Another question is whether you need the brackets around _coords at all. I am currently looking through the DZMSVehiclePatrol function and seeing of there are ways to simplify/clean it up. I'm already seeing some things that don't need to be done (as they are taken care of in other places. I'm also wondering if there is a way to use the DZE vehicles and still load them with ammo. That way, the players can sell them to a trader if they capture the vehicles. It's just that my programing experience is 20 years rusty and I'm not that well versed in BI's scripting. Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 20, 2014 Author Report Share Posted April 20, 2014 What about the opening bracket for the DZMSVehiclePatrol call? You have a closing one, but no opening bracket. Wouldn't this produce an error? Another question is whether you need the brackets around _coords at all. I am currently looking through the DZMSVehiclePatrol function and seeing of there are ways to simplify/clean it up. I'm already seeing some things that don't need to be done (as they are taken care of in other places. I'm also wondering if there is a way to use the DZE vehicles and still load them with ammo. That way, the players can sell them to a trader if they capture the vehicles. It's just that my programing experience is 20 years rusty and I'm not that well versed in BI's scripting. Show me what you are talking about with the opening bracket. It works for me, so I guess it's not needed. If you can clean up the DZMSVehiclePatrol, I'm open for suggestions. As I've said, I simply took the code and modified it a little, so I'm sure there's stuff in there that doesn't need to be. Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 20, 2014 Author Report Share Posted April 20, 2014 I don't know how I messed up posting in this thread when I had everything correct on my server... anyway, fixed another problem: [_coords], //Position to patrol Should be: [[_coords], //Position to patrol insertcoins 1 Link to comment Share on other sites More sharing options...
TheFarix Posted April 20, 2014 Report Share Posted April 20, 2014 Show me what you are talking about with the opening bracket. It works for me, so I guess it's not needed.You've already caught it.If you can clean up the DZMSVehiclePatrol, I'm open for suggestions. As I've said, I simply took the code and modified it a little, so I'm sure there's stuff in there that doesn't need to be.Basically, I'm looking through DZMSFunctions.sqf and DZMSAISpawn.sqf to see what/how they do/format things and altering DZMSVehiclePatrol.sqf to match. Things such as increasing PVDZE_serverObjectMonitor by 1 is already taken care of by the DZMSSetupVehicle call, so that don't need to be in DZMSVehiclePatrol. I'm also wondering if the patrol radius, vehicle class, no. of waypoints, and both coords need to be sent or can these be more streamlined/hardcoded to mimic DZMSAISpawn. I'm also wondering if you want to give the vehicles a full fuel tank when spawned, or if it should remain the random value that DZMSSetupVehicle sets it to. Link to comment Share on other sites More sharing options...
BetterDeadThanZed Posted April 20, 2014 Author Report Share Posted April 20, 2014 You've already caught it. Basically, I'm looking through DZMSFunctions.sqf and DZMSAISpawn.sqf to see what/how they do/format things and altering DZMSVehiclePatrol.sqf to match. Things such as increasing PVDZE_serverObjectMonitor by 1 is already taken care of by the DZMSSetupVehicle call, so that don't need to be in DZMSVehiclePatrol. I'm also wondering if the patrol radius, vehicle class, no. of waypoints, and both coords need to be sent or can these be more streamlined/hardcoded to mimic DZMSAISpawn. I'm also wondering if you want to give the vehicles a full fuel tank when spawned, or if it should remain the random value that DZMSSetupVehicle sets it to. The vehicle class is pulled from the DZMS config and the other settings probably should be set in the mission itself in case admins want different radiuses or waypoints depending on the mission. As it stands, you can't enter the patrol vehicle, which is why I didn't mind using non-Epoch vehicles. If you can work it out where the vehicle is an Epoch vehicle and the ammo is filled when it spawns, that would be good as long as you can also work out how to make it so players can use the vehicle after killing the AI. The problem I had was my limited knowledge with scripting. The WAI file I modified made it so you can't enter and after all the testing I did, I ran out of steam trying to get it so it acts like other vehicles spawned in DZMS. Link to comment Share on other sites More sharing options...
insertcoins Posted April 20, 2014 Report Share Posted April 20, 2014 missions spawn without AI BetterDeadThanZed 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now