Artillery barrages with or without AI artillery

Party-approved programming
Post Reply
User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Artillery barrages with or without AI artillery

Post by wolfenswan »

Artillery is a great way to create immersion and put pressure on players. Both scripts can be used to either bombard a set area or in a more dynamic fashion.

Having AI controlled mortar fire on designated targets:

Tip: Placing and naming the "H (Invisible)" (under Empty>Objects) is a good way to create targets for the mortars. You can also move them to the player positions with getPos/attachTo or randomize them by increasing their placement radius or group them to a selection of markers.

Code: Select all

// AI Mortar shelling mini script
// By Wolfenswan: wolfenswanarps@gmail.com 
//
// Feature: 
// Have AI mortar groups fire at a fixed target
//
// Usage: 
// 1. Paste Code in file named ws_AImortars.sqf and copy the file in a folder named scripts in your mission folder
// 2. Create a group of AI mortars and put Groupname = group this; in their leader's init. 
// 3. Place the objects you wan't to be targeted (e.g. invis. Helipads) and name them target1, target 2 etc.
// 4. Call: [target,groupName,3] execVM "scripts\ws_AImortars.sqf" during the mission
//
// First parameter is the target you want to be hit.
// Second parameter is the name of the mortar group
// Third parameter is the number of barrages (make sure they have enough ammo)

cutText ["Incoming!","PLAIN",1]; 

if (isServer) then {
private ["_target","_grp","_barrages"];

_target = _this select 0;
_grp = _this select 1;
_barrages = _this select 2;

for "_i" from 0 to _barrages do {
{_x doTarget _target;} forEach units _grp; 
{_x doFire _target} forEach units _grp; 
{_x fireAtTarget [_target];} forEach units _grp; 
sleep 10; 
};};
mortar shells spawned without existing mortar batteries:

A simple but effective script to emulate artillery barrages without the need for placing actual units. It's highly customizable and all possible options are explained in the script itself further below. Make sure the functions module is placed in the editor.

ws_mortars.sqf on github

Post Reply