Today I’m going to share a neat script hack which turns Mk6 mortar into a single man operation weapon and adds some sensible 3rd person view to it. By hack I mean that it could be done in a mission and you do not need to make a mod to change mortar behaviour. My goal was to make Mk6 mortar practical and simple to use. Whether I have achieved it or not, judge for yourself. Features:

  • A simple function call will add mortar bag to a player (will remove existing bag).
  • Action for mortar assembly is added to action menu and also gets bound to User1 action. So if you go to controls and define User1 shortcut key you can set up mortar without scrolling mouse wheel. I set User1 as left Ctrl+Shift for myself.
  • Language of custom added action is localised.
  • You can exit mortar as you exit a vehicle (with “V”) and player will pack the mortar automatically.
  • You can drop mortar bag then pick it up later it will still work (the bag has to be added first with function call).
  • The 3rd person view allows to use freelook, but not too good for aiming.
  • If you get killed while on the mortar, it will get destroyed as well.
  • You won’t be able to set it up while in vehicle.
  • Artillery computer noob option is removed. If you need to know how to aim Mk6 like a man check this post.
  • Finally, the type of the mortar bag added will correspond to player’s faction (currently only works with BLUFOR, since BETA is missing mortar bags for the other 2 classes. For the same reason it will not work with civilians).

I have designed it to work with my mission while still trying to keep it universal. If you use my script for your mission, please give the credit where it is due. To define the function:

KK_playerAddMortarBag = { removeBackpack player; KK_mortarBag = toString [ (toArray faction player) select 0 ] + "_Mortar_01_weapon_F"; player addBackpack KK_mortarBag; player addAction [ format [ localize "STR_ACTION_ASSEMBLE", localize "str_a3_cfgvehicles_mortar_01_base0" ], { player action ["Assemble", unitBackpack player]; player removeAction (_this select 2); }, [], 0, false, true, "User1", " !isNull unitBackpack player && {backpack player == KK_mortarBag} && {player == vehicle player} " ]; KK_mortarAssembled_EH = player addEventHandler ["WeaponAssembled", { if ((_this select 1) isKindOf "StaticMortar") then { player removeEventHandler ["WeaponAssembled", KK_mortarAssembled_EH]; enableEngineArtillery false; (_this select 1) addEventHandler ["GetOut", { if (alive player) then { player setDir (direction (_this select 0)); player setPos ((_this select 0) modelToWorld [0,-2,-0.7]); player playActionNow "PutDown"; (_this select 0) spawn { sleep 0.5; deleteVehicle _this; call KK_playerAddMortarBag; } } else { (_this select 0) setDamage 1; } }]; (_this select 1) spawn { sleep 0.9; if (isNull _this || {!alive _this}) exitWith {}; if (player distance _this > 3.5) exitWith { deleteVehicle _this; call KK_playerAddMortarBag; }; if (lineIntersects [ getPosASL player, getPosASL _this, player, _this ]) exitWith { deleteVehicle _this; call KK_playerAddMortarBag; }; player moveInGunner _this; if (gunner _this != player) exitWith { deleteVehicle _this; call KK_playerAddMortarBag; }; } } }] };

To call the function:

call KK_playerAddMortarBag;


EDIT1: Added handling for when player cannot enter mortar.
EDIT2: Added handling for when player is too far from the mortar.
EDIT3: Added handling for when created mortar is immediately destroyed.
EDIT4: Added handling for when there is an object between the player and the mortar.
EDIT5: Removed action id variable, no need as it passed back to script in param array.
EDIT6: Changed action script from string to code since it is also supported.

EDIT7: Great news! Dev branch finally had missing mortar bags added so you can now use it with opfor and independent units too.

EDIT8: For some reason BIS decided to create Mortar further away from the player and it broke my script. So I’ve changed the distance from 2.5 to 3.5 metres and updated the script.
EDIT9: New DEV branch update fixed 3rd person view, so some redundant code is removed.