Forum Jump :

Author Message


Posts: 87
Rank:


Level: Member

Country: in
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-11-09 23:16        
     
Hello , this script adds new addaction commands to commanders position in heavy tanks, this script enables the PLAYER as commander of the tank to target any position on ground or any vehicle/structure/fortifications by issuing commands to the tanks gunner crew . It is similar to using tab lock to get target lock.This script allows the tank to fire while moving.

This script supports tanks such as T-34,T-55,T-72,T-90,M1A2,M1A2 TUSK etc.Tanks featured in mods as well as WWII tanks in mods are also supported.This script does not work for APC type vehicles.

To enable these addaction commands in all heavy tanks place code in init of every heavy tank-
tankcontrols = [this] execVM "tankcommands.sqf";

place the sqf files described below in mission folder.

tankcommands.sqf
_tank = _this select 0;
waitUntil {player in _tank};
hint "tank gunner commands enabled in tank!";

sleep 2;
hint "Switch to commander seat in tank to access command menu.";

sleep 3;

watchPosition = _tank addaction ["Watch Position","tankTargets.sqf",["watch position"],1,false,true,"","commander _target == _this"];

FireMainGun = _tank addaction ["Fire Main Gun","tankTargets.sqf",["fire main 
gun"],1,false,true,"","commander _target == _this"];

fireMG = _tank addaction ["Fire coaxial MG","tanktargets.sqf",["fire coaxial 
mg"],1,false,true,"","commander _target == _this"];

NoTarget = _tank addaction ["No target","tanktargets.sqf",["no target"],1,false,true,"","commander _target == _this"];

exit;

tanktargets.sqf
_tank = _this select 0;
_commander = _this select 1;
_TankGunnerCommands = (_this select 3) select 0;

sleep 0.1;
_tank setcombatmode "YELLOW";
_tank setbehaviour "COMBAT";

sleep 1;
switch (_TankGunnerCommands) do {

case "watch position"://Watch cursor position.
{
//Check if unit is in tank.
if (!(gunner _tank in _tank)) exitwith {
hintsilent "tank gunner position empty!";
sleep 2;
hintsilent "";
};

_commander sideChat "Gunner, watch this position";

sleep 1;
_target = cursortarget;
_targetpos = screenToWorld [0.5,0.5];

//Searching target/position.

sleep 1;
if (isnull _target) then {
gunner _tank dowatch _targetPos;
hintsilent "Target position found!";
gunner _tank sidechat "Watching target position!";
}
else
{
hintsilent "Target found!";
gunner _tank dowatch _target;
gunner _tank dotarget _target;
gunner _tank sidechat "Watching target position!";
};

};
case "fire main gun": //Fire main gun at target position.
{
//Check if unit is in tank.
if (!(gunner _tank in _tank)) exitwith {
hintsilent "tank gunner position empty!";
sleep 2;
hintsilent "";
};

_target = cursortarget;
_targetpos = screenToWorld [0.5,0.5];

//Check target side.
sleep 1;
if ((side _target == playerside)) exitwith {hintsilent "Cannot engage targets of same side!"};

//Searching target/position.
sleep 1;
if (isnull _target) then {
gunner _tank dowatch _targetPos;
hintsilent "Target position found!";
}
else
{
hintsilent "Target found!";
gunner _tank dowatch _target;
gunner _tank dotarget _target;
};

sleep 1;

_commander sidechat "Gunner, fire at this position!";

sleep 1;
gunner _tank sidechat "Firing!";
waitUntil {unitready gunner _tank};

sleep 2;
_tank action ["useWeapon",_tank,gunner _tank,0];

sleep 1;
hintsilent "reloading rounds!";

sleep 7;
hintsilent "";

};
case "fire coaxial mg": // Fire coaxial mg at target position.
{
//Check if unit is in tank.
if (!(gunner _tank in _tank)) exitwith {
hintsilent "tank gunner position empty!";
sleep 2;
hintsilent "";
};

_target = cursortarget;
_targetpos = screenToWorld [0.5,0.5];

//Check target side.
sleep 1;
if ((side _target == playerside)) exitwith {hintsilent "Cannot engage targets of same side!"};

//Searching target/position.
sleep 1;
if (isnull _target) then {
gunner _tank dowatch _targetPos;
hintsilent "Target position found!";
}
else
{
hintsilent "Target found!";
gunner _tank dowatch _target;
gunner _tank dotarget _target;
};

sleep 1;
_commander sideChat "Gunner, fire MG at this Position!";

sleep 1;
gunner _tank sideChat "Engaging!";
waitUntil {unitready gunner _tank};

sleep 2;
for "_i" from 0 to 3 do {
for "_i" from 0 to 10 do {sleep 0.1;
_tank action ["useWeapon",_tank,gunner _tank,2];};
};

};
case "no target": //stop ai from watching target position.
{
//Check if unit is in tank.
if (!(gunner _tank in _tank)) exitwith {
hintsilent "tank gunner position empty!";
sleep 2;
hintsilent "";
};

_commander sideChat "Cancel target!";

sleep 1;
gunner _tank doWatch _tank;
gunner _tank doTarget objNull;
gunner _tank sidechat "Disengaging!";
};
};

Select the commands with scroll option-
watch position - this will order the tanks gunner to rotate turret to watch position the commander is observing.
fire main gun - this will order the tank to turn turret and fire its main gun at position/target the commander is observing/targeting.
fire coaxial MG - this will order the tank fire its coaxial MG at position/target at which the commander is targeting.
No target - this will order the tanks gunner to stop engaging any target or position.

If anyone finds errors or have ideas to improve this script can post replies.

This post was edited by warbird (2017-04-06 01:08, 256 days ago)


Author Message


Posts: 87
Rank:


Level: Member

Country: in
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2017-03-30 00:45        
     
AI Tank fire support script

This script enables the player to select any heavy main battle tank (MBT) for fire support during mission.
(1) The infantry unit (Player) can order the tank to move on map,assign the AI tank targets to fire at enemy units or fortifications with main gun or coaxial mg fire.
(2) This script also enables player to command tanks without adding them to player group.The player can order the AI tank to engage long range targets with this script.This script supports WWII heavy tanks as well.

For this script place on map-
invisible helipad named as tanktarget2
player unit and many AI tanks (not grouped to player).

In init of player -
selectarmor = this addaction ["select heavy tank","armorscript\selectarmor.sqf"];

Select addaction "select heavy tank" using scroll action and look at AI tank using cursor to select it.Once selected hint is displayed player will get addaction commands-

"move to Position" - move tank with map click.
"fire Main gun" - watch target position or enemy unit with binoculars or cursor to find/designate target within 5 seconds and order tank to fire at target with its main gun.

"fire coaxial Mg" - Same as above tank will fire its coaxial MG at target.
"close Commands" - This deselects the tank and closes addaction scroll menu.

Create a folder named as armorscript and place it in mission folder.

Place all the .sqf described below in armorscript folder and save mission.

selectarmor.sqf
hintSilent "Use cursor to select heavy tank for fire support!";

sleep 5;
tank = cursorTarget;
if (!alive tank) exitwith {hintsilent "Tank has been destroyed or heavily damaged"};
if (isNull tank) exitWith {hintSilent "unit not found!"};
if (!(tank isKindOf "TANK")) exitwith {hintsilent "selected vehicle not a tank!"};
if (count (crew tank) == 0) exitwith {hintsilent "Selected armor is empty!";};
if (!(side tank == playerside)) exitwith {hintsilent "selected armor not of player side!"};

sleep 2;
hintSilent "heavy tank selected!";

sleep 1;
hintSilent "";

tank setcombatmode "YELLOW";
tank setbehaviour "COMBAT";

MovePos = player addaction ["Move To Position","armorscript\movetank.sqf",tank];
FireMainGun = player addaction ["Fire Main Gun","armorscript\fireMain.sqf",tank];
fireMG = player addaction ["Fire coaxial MG","armorscript\firecoaxial.sqf",tank];
closeCommands = player addaction ["Close Commands","armorscript\closemenu.sqf",tank];

sleep 0.1;
commander tank sideChat "Ready for combat orders!"; 

sleep 0.1;
player removeaction selectarmor;

exit;


movetank.sqf
tank = _this select 3;

//check status of tank.
if (!alive tank) exitwith {
hintsilent "Tank has been destroyed or heavily damaged";
sleep 1;
player removeaction MovePos;
player removeaction FireMainGun;
player removeaction fireMG;
player removeaction closeCommands;
selectarmor = player addaction ["select heavy tank","armorscript\selectarmor.sqf"];
};

sleep 1;
titleText ["Click on map position to move tank on map!","plain down"];
sleep 0.1;
mapclick = true;
onMapSingleClick "tank move _pos;mapclick = false;
onMapSingleClick ''; true;";
waitUntil {!mapClick};

sleep 1;
commander tank sidechat "Roger that!, moving to new position!";

exit;

fireMain.sqf
tank = _this select 3;

//check status of tank.
if (!alive tank) exitwith {
hintsilent "Tank has been destroyed or heavily damaged";
sleep 1;
player removeaction MovePos;
player removeaction FireMainGun;
player removeaction fireMG;
player removeaction closeCommands;
selectarmor = player addaction ["select heavy tank","armorscript\selectarmor.sqf"];
};

hintsilent "watch target position using binoculars or use cursor!";

sleep 1;
player sidechat "Searching target!";
hintSilent "searching target in 5 seconds!";
sleep 1;
hintSilent "searching target in 4 seconds!";
sleep 1;
hintSilent "searching target in 3 seconds!";
sleep 1;
hintSilent "searching target in 2 seconds!";
sleep 1;
hintSilent "searching target in 1 seconds!";
sleep 1;
hintSilent "";

sleep 1;
//Creating target.
tanktarget1 = cursorTarget;

//Check target side.
sleep 1;
if ((side tanktarget1 == playerside)) exitwith {hintsilent "Cannot engage targets of same side!"};

sleep 1;
if (isnull tanktarget1) then {
hintsilent "Target position found!";
tanktarget2 setPos (screenToWorld [0.5,0.5]);
tanktarget2 setPos [(getPos tanktarget2) select 0,(getPos tanktarget2) select 1,-0.45];
gunner tank lookAt tanktarget2;
gunner tank dowatch tanktarget2;
gunner tank doTarget tanktarget2;
}
else
{
hintsilent "Target found!";
gunner tank lookAt tanktarget1;
gunner tank dowatch tanktarget1;
gunner tank doTarget tanktarget1;
tanktarget2 setPos [0,0,0];
};

sleep 1;
player sidechat "Fire cannon at this position!";

sleep 1;
commander tank sidechat "Gunner, fire at this position!";

sleep 1;
gunner tank sidechat "Firing!";
waitUntil {unitready gunner tank};

sleep 3;
tank action ["useWeapon",tank,gunner tank,0];

sleep 1;
hintsilent "tank is reloading rounds!";
gunner tank sidechat "reloading rounds!";
tanktarget2 setPos [0,0,0];;

sleep 7;
hintsilent "";

sleep 1;
gunner tank doWatch tank;
gunner tank doTarget objNull;
commander tank sidechat "No target!";

exit;

fireCoaxial.sqf
tank = _this select 3;

//check status of tank.
if (!alive tank) exitwith {
hintsilent "Tank has been destroyed or heavily damaged";
sleep 1;
player removeaction MovePos;
player removeaction FireMainGun;
player removeaction fireMG;
player removeaction closeCommands;
selectarmor = player addaction ["select heavy tank","armorscript\selectarmor.sqf"];
};

hintsilent "watch target position using binoculars or use cursor!";

sleep 1;
player sidechat "Searching target!";
hintSilent "searching target in 5 seconds!";
sleep 1;
hintSilent "searching target in 4 seconds!";
sleep 1;
hintSilent "searching target in 3 seconds!";
sleep 1;
hintSilent "searching target in 2 seconds!";
sleep 1;
hintSilent "searching target in 1 seconds!";
sleep 1;
hintSilent "";

sleep 1;
//Creating target.
tanktarget1 = cursorTarget;

//Check if target is friendly or civilian.
sleep 1;
if ((side tanktarget1 == playerside)) exitwith {hintsilent "Cannot engage targets of same side!"};

sleep 1;
if (isnull tanktarget1) then {
hintsilent "Target position found!";
tanktarget2 setPos (screenToWorld [0.5,0.5]);
tanktarget2 setPos [(getPos tanktarget2) select 0,(getPos tanktarget2) select 1,-0.45];
gunner tank lookAt tanktarget2;
gunner tank dowatch tanktarget2;
gunner tank doTarget tanktarget2;
}
else
{
hintsilent "Target found!";
gunner tank lookAt tanktarget1;
gunner tank dowatch tanktarget1;
gunner tank doTarget tanktarget1;
tanktarget2 setPos [0,0,0];
};

sleep 1;
player sidechat "Fire MG at this position!";

sleep 1;
commander tank sideChat "Gunner, fire MG at this Position!";

sleep 1;
gunner tank sideChat "Engaging!";
waitUntil {unitready gunner tank};

sleep 3;
for "_i" from 0 to 3 do {
for "_i" from 0 to 10 do {sleep 0.1;
tank action ["useWeapon",tank,gunner tank,2];};
};

sleep 3;
tanktarget2 setPos [0,0,0];
gunner tank doWatch tank;
gunner tank doTarget objNull;
commander tank sidechat "No target!";

exit;

closemenu.sqf
tank = _this select 3;

selectarmor = player addaction ["select heavy tank","armorscript\selectarmor.sqf"];

sleep 1;
hintsilent "command menu closed!";
gunner tank doWatch tank;
gunner tank doTarget objNull;
tank setcombatmode "YELLOW";
tank setbehaviour "AWARE";

sleep 0.1;
player removeaction MovePos;
player removeaction FireMainGun;
player removeaction fireMG;
player removeaction closeCommands;

hintsilent "select other tank!";

exit;

This post was edited by warbird (2017-04-17 04:39, 245 days ago)