Counterbattery artillery system

Workshop for all Mission Engineer Comrades. Home of the FA Mission Making Template.
Post Reply
User avatar
Posts: 312
Joined: Wed Nov 27, 2013 1:29 pm
Location: India/US West

Counterbattery artillery system

Post by SuicideKing »

Comrade engineers! :science101:

I present to you a script based counter-battery artillery system. Source code: ... test.Altis
Yes, it's literally just the mission folder. The instructions for the setup are in the readme file, and the code is well documented and explained, along with examples. The mission itself is setup such that it should just work out of the box.

The motivation is to make artillery gameplay more dynamic and interesting. This could be applied to say, a defence scenario or spec ops mission. Or have a defence scenario with a spec ops team or UAV recon trying to find the enemy arty piece(s).

While the mission only has the script handle one enemy piece, it should be easy to scale up by simply running the script multiple times and passing each unit as a param. As such you can pass any enemy vehicle to the script and it will work. Similarly, the script can handle multiple player artillery pieces already (explained later below). It should also be possible to make it PvP compatible without too much trouble, however that is not done at the moment (side specific variants of existing variables, markers, messages would be needed).

While it works on a localhosted server, i have not tried on a dedicated server! And it hasn't been tested with multiple players present. I am somewhat unsure about the EH localities etc. (e.g. how many times will it get triggered if a player fires? i think it should be just once). So definitely needs testing. Unfortunately I ran out of time to test further before i had to move to the US.
So what is it? It's a semi-modular system that consists of 4 parts: an AI "brain" that calls fire missions and controls waypoints (both rearm and fire points) for an AI artillery unit, a fire mission script that actually implements the fire missions, a "CBRadar" script that run when the AI arty unit fires, and an EH attached to player arty unit that tracks where the player fired from (this is the enemy's CB radar). initServer.sqf initialises the player EHs and provides an easy way to set up resupply vehicles for the AI.

The AI is given a target and a set of waypoints to fire from. It will drive to each WP and fire at the target. If it could fire successfully, it will drive to the next ammo vehicle or box (this can literally be anything, since the actual rearming happens in script). If the AI cannot fire (e.g. it doesn't like the slope) then it will proceed to the next fire WP, and so on. The WPs should follow numerical order by default, as should the rearm point selection. This can be made random as well (see enemy brain script params).

Upon reaching a fire point, the fire mission script will fire a volley in a certain radius around the target by default. You can set up safe zones, ripple fire, etc. The script attaches an EH to the artillery piece which is triggered when it fires teh first rocket, and then removed. This EH launches the CBRadar script. Players will receive a hint stating that there is incoming artillery fire. After the shell is in mid flight, the script will reveal time to impact, the origin grid and the destination grid. The origin grid will also be highlighted on the map.

Player artillery can use this grid to return fire. However, upon doing so, the position will be revealed to the AI. If the AI sees a player has fired and it's relatively recent, it will fire at that grid square. Otherwise, it will continue to fire at the original target. Since it only sees the last player who fired, it should pretty simply be able to work with multiple player units.

There are a few sleeps in the AI routines to "simulate" deployment and reload times. These will need to be changed in script as per your mission design goals.
It's semi-modular, and can probably be made properly modular with some more work. If you don't sync a player vehicle to the in-editor "sk_playerArty_EH_logic", it will simply not add any EH. The AI unit will just keep firing at the original target and moving around. The CBRadar runs almost independently of the fire mission script, it currently requires the target of the fire mission, and some way would need to be found around that in case of PvP (or removed entirely). However the marker names are unique to the vehicle, as are the variables it shares with fire mission, so multiple AI units should be possible without conflict. Maybe you'll have to use sidechat instead of hints for that. Finally, the fire script is independent of the AI brain as long as you give it input params. The AI brain can be tested independently of the fire mission but you'll need to edit the script.

And that's it. Let me know what y'all think, give it a spin, fork it, contribute to the repo, whatever you like.

p.s. should it be called CBAS? :coolbert:


Post Reply