AI Air Patrols

orcthrasher

Well-Known Member
Heyoo all.

I've got a chopper with a squad of soldiers that patrols around the major coastal cities, taking pot shots at zeds and such.

I'm manually loading a bunch of waypoints to the group, but for some reason the chopper will randomly land and a clutch of soldiers will leap out, and then it will take off again.

What the heck?

I have

setCombatMode "YELLOW";
setBehaviour "SAFE";

in the script so they shouldn't be engaging enemies.

Do I need to have non-MOVE waypoints?

EDIT:

I got it working!!

>>>>>>>>> UPDATES <<<<<<<<<<
 
Try setting your waypoints so they are in the air. Have just tested this and all works ok.
Code:
FirstWayPoint = [13101.4,10339.1,200];
. I used 200, am sure I read somewhere that under a certain height (maybe 100m) will cause them to land.

You could also try using assignAsDriver and assignAsCargo to see if that helps with them disembarking. Though, my test passenger I just did a moveInCargo for him..
 
Heyoo all.

I've got a chopper with a squad of soldiers that patrols around the major coastal cities, taking pot shots at zeds and such.

I'm manually loading a bunch of waypoints to the group, but for some reason the chopper will randomly land and a clutch of soldiers will leap out, and then it will take off again.

What the heck?

I have

setCombatMode "YELLOW";
setBehaviour "SAFE";

in the script so they shouldn't be engaging enemies.

Do I need to have non-MOVE waypoints?

Care to share this? - what map are you running this on & is it easy to implement?

Thanks in advance
 
First off, I hate Arma 2 and everyone who had a hand in it's development.

This is what i've got. I'd really, really like to add code to the script to get the dudes to hang out for 30 seconds or so before taking off, but I can't get the setWaypointStatements condition to behave. I can write a script to make everything work AWESOME, but, when you cycle through a second time, it all goes to hell, because all of the logic is executed at that point and all the AI is left with is waypoint data to index through.
 

Attachments

  • Chopper Patrol.sqf
    10.9 KB · Views: 84
The way it works now is that 8 or so soldiers jump out of the chopper when it lands, and jump back in and take off. It's enough time to get in if you're waiting there - but they wont help shooting zeds like I want them to.
 
IT WORKS! I FUCKING DID IT!

I ended up having to use public variables to pass information to the waypoint conditions.

Choose how many soldiers you want to spawn with the chopper (8 - 10 seems about right).

Chopper goes to waypoint, lands and unloads, soldiers bail out and shoot zeds for ~ 30 - 40 seconds. You can change that by changing how often the VehicleRearm script sleeps.

The soldiers pile back into the chopper and take off.

Right now it goes Balota > Cherno > electro > NEAF > NWAF

I broke the code into descreet blocks, so if you want to add /remove a destination, just find and replace the location with what you want it to do.

There are still some bugs - for instance, if you assign soldiers to gun, they'll shoot zeds THROUGH the guys getting out, so I have them load as cargo, not as gunner. For some reason, rather than going back to spawn and hitting balota on the cycle, they go to 0,0 - which isn't that far from Balota anyway, so who cares.

Change the FlyIn height to lower if you want it to go faster, but if you go lower you run the risk of hitting shit, or people using the choppers to scout the entire map. I want to set it high enough that you can't really see the ground from the chopper between WPs.

YMMV.

just call it from your init like such:
Code:
//[[Position], Number of Soldiers, Flying Height]
[[32.562645, 1589.6631, 0],6,85] ExecVM "units\Chopper Patrol.sqf"; //Patroling Chopper


You need to add change your server_update.sqf in the DayZ_Server.PBO file

Code:
if ((typeName _objectID != "string") || (typeName _uid != "string")) then {
    diag_log format ["DEBUG: Non string object: ID %1, UID %2", _objectID, _uid];
    _objectID = "0";
    _uid = "0";
};
if (!_parachuteWest) then
{
if (_objectID == "0" && _uid == "0") then
{
_object_position = getPosATL _object;
_ApproveState = _Object GetVariable "ApprovedVeh";
//diag_log format ["DEBUG: Object %1 Approve State", _ApproveState];
 
If (_ApproveState == 1) Then
{
_isNotOk = false;
diag_log format ["DEBUG: Object %1 detected at [%2,%3,%4], and classified as approved", typeOf _Object, _object_position select 0, _object_position select 1, _object_position select 2]];
 
} else {
diag_log format ["DEBUG: Deleting object %1 with invalid ID at [%2,%3,%4]", typeOf _object, _object_position select 0, _object_position select 1, _object_position select 2];
_isNotOk = true;
};
 
};
};


It should be right near the top of the list.

Also, look for the part of your server_cleanup.fsm file in the DayZ_Server.PBO and get rid of the hacker check - it will blow the vehicle up. It should look somewhat like this:

Code:
init = /*%FSM<STATEINIT""">*/"//Check for hackers" \n
      " {" \n
      "//if(vehicle _x != _x) then {" \n
      "//if  (!(vehicle _x in _safety) && ((typeOf vehicle _x) != ""ParachuteWest"")) then {" \n
      "//diag_log (""CLEANUP: KILLING A HACKER "" + (name _x) + "" "" + str(_x) + "" IN "" + (typeOf vehicle _x));" \n
      "//(vehicle _x) setDamage 1;" \n
      "//_x setDamage 1;" \n
      "//};" \n
      "//};" \n
      " } forEach allUnits;" \n
      ""/*%FSM</STATEINIT""">*/;


Code:
//[[Position], Number of soldiers]
ChopperPatrol1 = [[32.562645, 1589.6631, 0],10] ExecVM "units\Chopper Patrol.sqf"; //Patroling Chopper

Edit - v1.0 (2013-03-12)

Added respawn ability, checking for the chopper stuck on the ground, and stuck hovering. Killing/shooting the chopper or any of the troops will instantly agro them, and will lower the attackers humanity. All weapons are removed from the AI on death, and their bodies are deleted 30 seconds after being killed.


FAQ:

Q: My chopper explodes when I climb in it!
A: Make sure you get rid of the hacker check in the fsm file!

Q: My chopper just disappears right after it spawns!
A: Make sure you make the changes to your server_objectupdate.sqf!

Q: I'm getting more than one chopper at a time!
A: This is a bit more tricky - clear out your scripts.log and see if you're getting battleye errors - oddly enough, I've seen battleye scripts.txt make the thing spawn multiple choppers. Crazy!

Q: The AI crashes the chopper!
A: Yeah, I've seen it happen too. The AI is fucking dumb. You can try playing with the height variable; too high seems to cause issues, and too low does too. The latest version contains a respawn provision that will restart the taxi if it asplodes.

Q: People are shooting my troops, they're bitches!
A: You can try adding more soldiers; they're already set to max AI intelligence (without using 3rd party AI addons, like SARGE's excellent framework here - http://opendayz.net/index.php?threads/sarge-ai-framework-public-release.8391/
I'm also thinking about a script that will send in reinforcements when the chopper is attacked, but that hasn't happened yet.
 

Attachments

  • ChopperReaction.sqf
    753 bytes · Views: 110
  • init.sqf
    1.1 KB · Views: 125
  • NPC_AlertZombies.sqf
    714 bytes · Views: 98
  • VehicleRearm.sqf
    1.3 KB · Views: 95
  • zombie_generate.sqf
    3 KB · Views: 88
  • server_objectUpdate.sqf
    4.9 KB · Views: 102
  • Chopper Patrol.sqf
    17.9 KB · Views: 109
Congrats man. So what's your server IP so I can see it first hand? Also you think you could do a little step by step on how to get this working for me and any others that want to use this?
 
Sure - the server owner didn't get the script updated tonight, so it's running the old version (chopper patrols, but pretty much lands for 5 seconds and then dusts off).

173.76.120.107:2302

I'll try and put together a guide tomorrow after work.
 
lol, awesome work, I know that feeling after days of battling against the engine and then it all seems to fall together and work.. definitely will be adding this to my server.

I suspect the 0,0 worldspace is the game dealing with an invalid position, check there isn't a building or hill there..
 
the 0,0 is no bug ... Check out how arma sets a waypoint list. 0/0 is always the first waypoint of a waypoint list (although it is not well documented, i agree ).

Try to remove the index 0 waypoint from that list, it might help.

cheers

Sarge
 
Script restriction 81. On my antihacks it showed a createvehicle error, but even editing the scripts to allow the chopper file didnt help.
 
then your edit was wrong. EVERY battleeye filter can be circumvented by adding the correct exception.
 
Agreed. It was correct, but there must be more that I am not seeing. My actual code line in the script was !"units\Chopper Patrol.sqf" added to the end of the createvehicle.
 
I had to disable the code in my server overhead that destroyed vehicles that it didn't find in the database. As I've never used SQL before, I'm at a loss as to how to prevent this while still preventing hackers from injecting vehicles. I may have to add some code where it checks for vehicles that are public variables or something. Not sure yet.
 
IT WORKS! I FUCKING DID IT!

I ended up having to use public variables to pass information to the waypoint conditions.

Choose how many soldiers you want to spawn with the chopper (8 - 10 seems about right).

Chopper goes to waypoint, lands and unloads, soldiers bail out and shoot zeds for ~ 30 - 40 seconds. You can change that by changing how often the VehicleRearm script sleeps.

The soldiers pile back into the chopper and take off.

Right now it goes Balota > Cherno > electro > NEAF > NWAF

I broke the code into descreet blocks, so if you want to add /remove a destination, just find and replace the location with what you want it to do.

There are still some bugs - for instance, if you assign soldiers to gun, they'll shoot zeds THROUGH the guys getting out, so I have them load as cargo, not as gunner. For some reason, rather than going back to spawn and hitting balota on the cycle, they go to 0,0 - which isn't that far from Balota anyway, so who cares.

Change the FlyIn height to lower if you want it to go faster, but if you go lower you run the risk of hitting shit, or people using the choppers to scout the entire map. I want to set it high enough that you can't really see the ground from the chopper between WPs.

YMMV.

just call it from your init like such:

Code:
//[[Position], Number of soldiers]
ChopperPatrol1 = [[32.562645, 1589.6631, 0],10] ExecVM "units\Chopper Patrol.sqf"; //Patroling Chopper



The rest of the event handlers can be removed, but you NEED this script.

Code:
//VehicleRearm.sqf
 
private ["_object","_SleepTime"];
 
 
 
_object = _this select 0;
_sleeptime = _this select 1;
PublicVariable "Chop1Alt";
PublicVariable "Chop1DT";
Chop1DT = 0;
While {alive _object} do
{
 
If ((Fuel _object) < 0.5) Then {
diag_log format ["Patrol: Chopper %1 fuel is %2, and is being refilled",_object,Fuel _object];
_object setFuel 1;
_object SetDamage 0;
};
 
Chop1Alt = (getPosATL _object) Select 2;
PublicVariable "Chop1Alt";
 
IF (Chop1Alt < 3) Then {
Chop1DT = Chop1DT + 1;
PublicVariable "Chop1DT";
};
IF (Chop1Alt > 3) Then {
Chop1DT = 0;
PublicVariable "Chop1DT";
};
 
diag_log format ["Patrol: %1 Altitude is %2 meters, DT is %3",_object,Chop1Alt,Chop1DT];
 
Sleep _sleeptime;
 
};

Should i to declare all scripts like this VehicleRearm.sqf , NPC_AngryZombies.sqf,NPC_AlertZombies.sqf or only Chopper Patrol.sqf in init.sqf file?
 
Back
Top