Jump to content
Sign in to follow this  
Nice_Boat

Nice_Boat Tank Damage System

Recommended Posts

Thanks again, Sickboy. I found all, what needed.

Share this post


Link to post
Share on other sites

OK, so once again, same presentation as before, but with new NBTank2.sqs this time. Changes: balance of default Arma 2 vehicles and weapons taken from ACE configs. Currently, T90 has thicker armor than M1A2 and almost equal to Abrams penetration ability of his gun. By the way added missing vehicles: MRLS and Vodnik. I was surprised very high value "ace_hit" for ammunition Sh_120_HE (HE penetrates 580 mm RHA?) but perhaps that is good for some reason. To all units added seven variables defining exact proportions between armor side, rear, top or bottom and front (KE and CE, only KE for bottom). There is no visible script slowdown, as it seems.

TDS_test3b2

Edited by Rydygier

Share this post


Link to post
Share on other sites

Cool ... will test.

Is the plan to have an addon (server only or server/client) eventually that will apply to all tested vehicles, instead of a script version ?

Further, I notice that the tank tends to turn it's front to the closest vehicle, whereas sometimes the threat is a lot farther away in a different direction. Is there a way to scan for main threat and turn to that ?

Share this post


Link to post
Share on other sites

Addon instead script would be great, but I have no idea how to do addons at all, and how to convert to addon this particular script. It is therefore a request for someone better in these matters, to which I join enthusiastically. Second issue is an interesting challenge. And not easy. Assessment of risks is sometimes very complex and not necessarily rational thought processes. It seems to me that game is used for AI purposes a parameter of risk degree, but I'm not sure where I saw it and whether it can be applied here. I'll think about it.

Share this post


Link to post
Share on other sites

Unfortunately, this command appears only in the OA, which I do not have, so I can not try. However, I see a similar command, simpler, "setvelocity". Perhaps it is useful. Thanks for the clue.

EDIT: "setvelocity" changes only motion vector, not affect orientation, so can't use them, but try in editor to put yourself as car driver, and put this into its init field: "this setVelocity [-5, 20, 10]" or "this setVelocity [120, 120, 120]". Enjoy. I really have to find some use for this wonderful command. :)

Edited by Rydygier

Share this post


Link to post
Share on other sites

I've seen a problem with the latest version in that, when an enemy is detected the hull turns as expected, and the turret turns as well. The moment that that tank is hit (or fires) the turret returns to its original position (in demo side on to enemy) and tank invariably dies.

Any idea why this snapping back happens? Could it be to do with the latest BIS beta ?

EDIT2: I have not yet had a battle when West has won! Damn Refleks are too good :)

Edited by Kremator

Share this post


Link to post
Share on other sites

Turret I did not notice this, but removed two lines from the script: "_target doTarget _attacker" and "_target doWatch _attacker". Here is:

TDS_test3b3

Is there any difference in behaviour?

Reflex is easy to adjust, if needed. :)

Share this post


Link to post
Share on other sites

Testing now :)

EDIT: Seems like some of the problem rests with the newest beta, the rest is a conflict with one of my normal addons (sorry!) With 1.59 patch the tanks turn as they should, with the newest OA beta, although they turn and engage, they do like to return their turrets to the original direction ! Wierd !

Edited by Kremator

Share this post


Link to post
Share on other sites

In Arma 2 1.10 M1A2 usually just turns towards enemies and shoots. Without "dowatch" and "dotarget" script in no way affects behavior of turrets. Well, it's BETA patch...

Share this post


Link to post
Share on other sites

Added to "towardA.sqs" this code:

#start
_enemies = []
~1

? ((_tank countenemy [_tank findnearestenemy _tank]) == 0) : goto "exit"
_neartanks = nearestObjects [_tank, ["Tank"], 1500]

_j = -1

#scanloop
_j = _j + 1
? ((_j+1) > (count _neartanks)) : goto "exitscan"
_tankJ = _neartanks select _j
? (((side _tankJ) getFriend (side _tank)) >= 0.6) or ((_tank knowsabout _tankJ) < 0.5) or (str (gunner _tankJ) == "<NULL-OBJECT>") or !(canFire _tankJ) : goto "scanloop"
_enemies = _enemies + [_tankJ]

~0.01
goto "scanloop"
#exitscan

? ((count _enemies) == 0) : goto "exit"

_Cenem = count _enemies

_rndm = (round (random _Cenem)) - 1
? (_rndm < 0) : _rndm = 0

_enemyT = _enemies select _rndm 

Here's how it now works:

- is created list of all tanks within a radius of 1500 meters;

- Are removed from this list those vehicles, of which crew does not know or know too little, those that are not hostile, and those in which gunner place is empty (eg immobilised, therefore abandoned, or when gunner get killed) and those, whose gun and/or turret is disabled (i don't know, if it works, if MG's are still operational);

- Other vehicles are added to list of "_enemies", in order from nearest, containing potential threats known to the crew

- An element of that "_enemies" list, toward which tank hull will turn is randomized (irrational factor, variant with some predominance of choice nearest enemy, eg for two enemies on list, three times in four attempts (75%) to be selected closest enemy, if I am not mistaken, for 3 foes on list 50% and so on)

- Irrespective of this, tank also rotates toward vehicle, that hit him.

- "doWatch" and "doTarget" are back, this time in "towardsA.sqs", but script still does not affect, that to what tank shoots

Here is demonstration, such as before and second, requiring "Duala Isle" map, but better presenting, how script works on a vast plain:

TDS_test4 Utes & Duala

Tested on Arma 2 1.10 without addons and with Duala Isle addon.

(On duala BLUFOR propably loses, is outnumbered)

EDIT: I suppose that because of circumstances of command "knowsabout" (KnowsAbout) tank stops rotating towards enemies after two minutes from death of commander because of loss of knowledge about enemies. Unless something has changed since commented on this command in the wiki.

Edited by Rydygier

Share this post


Link to post
Share on other sites

Thanks to knowledge derived here:

http://forums.bistudio.com/showthread.php?t=124589

I've prepared an addon version of TDS (requires CBA). This is a test version, I will be grateful if anyone will test, how it works with some tank battle scenario. Addon doesn't contain component "towards" which at this stage does not work well enough because of the above-mentioned problems with rotating tanks. It contains file "NBTank2.sqs" with debug (sidechat). If after hitting tank debug didn't appear, it means that addon is not working (for me it works). TDS addon needs some (5-7) seconds to initialize.

"NBT_TDS" currently support tanks and other armored vehicles from original game, vehicles from "Duala Isle" addon (both afrenian and molatian army) and from addon "Modern Polish Army and Police" by Vilas.

There isn't a ".bisign" file, because procedure described here ("step nine"):

http://community.bistudio.com/wiki/Mondkalb%27s_Addon_Tutorial

for me not working. Maybe it's some OS (Vista 64-bit) issue.

Here it is:

NBT_TDS

Share this post


Link to post
Share on other sites

Excellent news. Will try this out and get back to you mate.

Thanks for your hard work on this.

Share this post


Link to post
Share on other sites

Also recently explored SQF syntax enough to prepare, probably crude, version SQF (NBTank.sqf, CrewDS.sqf, NBRandomizer.sqf, "towards" wait until "turning problems" are resolved, and I have no idea, what else can I do with that... :/ There is no respose in my forum topic about this problem). This is mission with two tanks, for illustrative purposes and for testing. If will not be detected any errors, finally version of "addon" will be based on these files in place of SQS.

TDS_test5.utes

Beneath code:

NBTank.sqf:

/*
Sqf version of Nice_Boat's Tank Damage System by Rydygier

Init for each armored vehicle, for which TDS should to handle damage: 

this addEventHandler ["handledamage", {null = _this execVM "NBTank.sqf"}]

Also needed initialized NBRandomizer.sqf (crucial) and, for best effect, CrewDS.sqf.
*/
_selection = _this select 1;

if not ((_selection == "") or (_selection == "PAS_P") or (_selection == "PAS_L") or (_selection == "wheel_1_1_steering") or (_selection == "wheel_1_2_steering") or (_selection == "wheel_1_3_steering") or (_selection == "wheel_1_4_steering") or (_selection == "wheel_2_1_steering") or (_selection == "wheel_2_2_steering") or (_selection == "wheel_2_3_steering") or (_selection == "wheel_2_4_steering") or (_selection == "VEZ") or (_selection == "ZBRAN")) exitwith {}; 

_target = _this select 0;
_damage = _this select 2;
_attacker = _this select 3;
_ammo = _this select 4;

_comm = commander _target;
_drvr = driver _target;
_gunn = gunner _target;

_commH = damage _comm;
_drvrH = damage _drvr;
_gunnH = damage _gunn;

_varcomp = str (_target);

if (_target getvariable ("GCheck" + _varcomp) != 1) then 
{
_target setvariable [("PAUSE" + _varcomp),0,true];
_target setvariable [("TRL" + _varcomp),0,true];
_target setvariable [("TRP" + _varcomp),0,true];
_target setvariable [("TUR" + _varcomp),0,true];
_target setvariable [("GUN" + _varcomp),0,true];

_target setvariable [("WL11" + _varcomp),0,true];
_target setvariable [("WL12" + _varcomp),0,true];
_target setvariable [("WL13" + _varcomp),0,true];
_target setvariable [("WL14" + _varcomp),0,true];

_target setvariable [("WL21" + _varcomp),0,true];
_target setvariable [("WL22" + _varcomp),0,true];
_target setvariable [("WL23" + _varcomp),0,true];
_target setvariable [("WL24" + _varcomp),0,true];

_target setvariable [("GCheck" + _varcomp),1,true]
};

_top = 0;
_DT = damage _target;
_weapon = currentWeapon _attacker;

if ((_damage > 0.7) and (_selection == "PAS_P") and (NBRand100 > 90)) then {_target setHit ["PAS_P", 1];_target setvariable [("TRP" + _varcomp),1,true]};
if ((_damage > 0.7) and (_selection == "PAS_L") and (NBRand100B > 90)) then {_target setHit ["PAS_L", 1];_target setvariable [("TRL" + _varcomp),1,true]} else
{if ((_damage > 0.6) and (_selection == "wheel_1_1_steering") and (NBRand100 > 80)) then {_target setHit ["wheel_1_1_steering", 1];_target setvariable [("WL11" + _varcomp),1,true]};
if ((_damage > 0.6) and (_selection == "wheel_1_2_steering") and (NBRand100 > 80)) then {_target setHit ["wheel_1_2_steering", 1];_target setvariable [("WL12" + _varcomp),1,true]};
if ((_damage > 0.6) and (_selection == "wheel_1_3_steering") and (NBRand100 > 80)) then {_target setHit ["wheel_1_3_steering", 1];_target setvariable [("WL13" + _varcomp),1,true]};
if ((_damage > 0.6) and (_selection == "wheel_1_4_steering") and (NBRand100 > 80)) then {_target setHit ["wheel_1_4_steering", 1];_target setvariable [("WL14" + _varcomp),1,true]};
if ((_damage > 0.6) and (_selection == "wheel_2_1_steering") and (NBRand100 > 80)) then {_target setHit ["wheel_2_1_steering", 1];_target setvariable [("WL21" + _varcomp),1,true]};
if ((_damage > 0.6) and (_selection == "wheel_2_2_steering") and (NBRand100 > 80)) then {_target setHit ["wheel_2_2_steering", 1];_target setvariable [("WL22" + _varcomp),1,true]};
if ((_damage > 0.6) and (_selection == "wheel_2_3_steering") and (NBRand100 > 80)) then {_target setHit ["wheel_2_3_steering", 1];_target setvariable [("WL23" + _varcomp),1,true]};
if ((_damage > 0.6) and (_selection == "wheel_2_4_steering") and (NBRand100 > 80)) then {_target setHit ["wheel_2_4_steering", 1];_target setvariable [("WL24" + _varcomp),1,true]}};

_bullexc = ["B_30mmA10_AP","B_20mm_AP","B_20mm_AA","B_23mm_AA","B_23mm_HE","B_23mm_AP","B_23mm_APHE","B_25mm_HE","B_25mm_HEI","B_25mm_APDS","B_30mm_AP","B_30mm_HE","B_30mm_AA","G_40mm_HE","VIL_B_30mm_ros","ibr_aden30_gunpods"];
{if (_ammo isKindof _x) exitwith {_except = 1}} foreach _bullexc;
if ((_ammo isKindof "BulletCore") and (_except != 1)) exitwith {};

_bullexc = nil;

_highadv = ((getposASL _attacker) select 2) - ((getposASL _target) select 2);
if (damage _target >= 1) then {_highadv = 1};
_distF = [(position _attacker) select 0,(position _attacker) select 1,(getposASL _target) select 2] distance (getposASL _target);
_Tpitch = ((vectordir _target) select 2);
_Tbank = vectorUP  _target;
_DHatan = _highadv atan2 _distF;
if (_DHatan == -1) then {_DHatan = 0};
_TcheckA = 9/(1+ _DHatan);
_dX = ((getPos _attacker) select 0) - ((getPos _target) select 0);
_dY = ((getPos _attacker) select 1) - ((getPos _target) select 1);
if (_dX == 0) then {_dX = 1};
if (_dY == 0) then {_dY = 1};
if (_highadv == 0) then {_highadv = 1};
_EWroll = _Tbank select 0;
_NSroll = _Tbank select 1;

if (((abs _dX) > (abs _dY)) and (_dX > 0)) then {_TcheckL = -_EWroll} else
{if (((abs _dX) <= (abs _dY)) and (_dY > 0)) then {_TcheckL = -_NSroll} else
	{if (((abs _dX) > (abs _dY)) and (_dX <= 0)) then {_TcheckL = _EWroll} else
		{if (((abs _dX) <= (abs _dY)) and (_dY <= 0)) then {_TcheckL = _NSroll}}}};

_ang = _dX atan2 _dY;
_dif = (_ang - getDir _target);

//if (_selection == "") and ((_target getvariable ("PAUSE" + _varcomp)) != 1) and ((driver _target) != player) then {[_ang, _target,_attacker,_varcomp] exec "towards.sqs"};

if (_dif < 0) then {_dif = 360 + _dif};
if (_dif > 180) then {_dif = _dif - 360};
_difA = abs _dif;
_armorCE = 0; _armorKE = 0; _surviv = 0; _sidePKE = 0;_sidePCE = 0;_rearPKE = 0;_rearPCE = 0;_topPKE = 0;_topPCE = 0;_bottomPKE = 0;
if (_target isKindOf "ibr_T55") then {_armorCE = 215; _armorKE = 215; _surviv = 17; _sidePKE = 0.53;_sidePCE = 0.53;_rearPKE = 0.28;_rearPCE = 0.28;_topPKE = 0.14;_topPCE = 0.14;_bottomPKE = 0.25} else
{if (_target isKindOf "M1A2_TUSK_MG") then {_armorCE = 1035; _armorKE = 720; _surviv = 30;_sidePKE = 0.54;_sidePCE = 0.62;_rearPKE = 0.11;_rearPCE = 0.17;_topPKE = 0.06;_topPCE = 0.04;_bottomPKE = 0.42} else
{if (_target isKindOf "M1A1") then {_armorCE = 1035; _armorKE = 720; _surviv = 26; _sidePKE = 0.44;_sidePCE = 0.43;_rearPKE = 0.1;_rearPCE = 0.08;_topPKE = 0.06;_topPCE = 0.04;_bottomPKE = 0.28} else
{if (_target isKindOf "ZSU_Base") then {_armorCE = 9.5; _armorKE = 9.5; _surviv = 10; _sidePKE = 1;_sidePCE = 1;_rearPKE = 1;_rearPCE = 1;_topPKE = 1;_topPCE = 1;_bottomPKE = 0.74} else
{if (_target isKindOf "2S6M_Tunguska") then {_armorCE = 15; _armorKE = 15; _surviv = 10; _sidePKE = 0.93;_sidePCE = 0.93;_rearPKE = 0.93;_rearPCE = 0.93;_topPKE = 0.73;_topPCE = 0.73;_bottomPKE = 0.93} else
{if (_target isKindOf "T34") then {_armorCE = 85; _armorKE = 75; _surviv = 16; _sidePKE = 0.63;_sidePCE = 0.56;_rearPKE = 0.27;_rearPCE = 0.24;_topPKE = 0.27;_topPCE = 0.24;_bottomPKE = 0.53} else
{if (_target isKindOf "T72_Base") then {_armorCE = 490; _armorKE = 390; _surviv = 20; _sidePKE = 0.24;_sidePCE = 0.38;_rearPKE = 0.18;_rearPCE = 0.16;_topPKE = 0.1;_topPCE = 0.08;_bottomPKE = 0.51} else
{if (_target isKindOf "T90") then {_armorCE = 1165; _armorKE = 815; _surviv = 24; _sidePKE = 0.48;_sidePCE = 0.73;_rearPKE = 0.11;_rearPCE = 0.08;_topPKE = 0.11;_topPCE = 0.21;_bottomPKE = 0.25} else
{if (_target isKindOf "AAV") then {_armorCE = 27.5; _armorKE = 27.5; _surviv = 12; _sidePKE = 1.16;_sidePCE = 1.16;_rearPKE = 0.82;_rearPCE = 0.82;_topPKE = 0.91;_topPCE = 0.91;_bottomPKE = 1.1} else
{if (_target isKindOf "BMP2_Base") then {_armorCE = 36.5; _armorKE = 36.5; _surviv = 12; _sidePKE = 0.51;_sidePCE = 0.51;_rearPKE = 0.48;_rearPCE = 0.48;_topPKE = 0.44;_topPCE = 0.44;_bottomPKE = 0.82} else
{if (_target isKindOf "BMP3") then {_armorCE = 41.5; _armorKE = 41.5; _surviv = 13; _sidePKE = 0.61;_sidePCE = 0.61;_rearPKE = 0.45;_rearPCE = 0.45;_topPKE = 0.39;_topPCE = 0.39;_bottomPKE = 1.2} else
{if ((_target isKindOf "BRDM2_Base") or (_target isKindOf "BRDM2_ATGM_base") or (_target isKindOf "VIL_brdm_m96d")) then {_armorCE = 10.5; _armorKE = 10.5; _surviv = 11; _sidePKE = 0.67;_sidePCE = 0.67;_rearPKE = 0.67;_rearPCE = 0.67;_topPKE = 0.67;_topPCE = 0.67;_bottomPKE = 0.67} else
{if (_target isKindOf "BTR90_Base") then {_armorCE = 34; _armorKE = 34; _surviv = 12; _sidePKE = 0.6;_sidePCE = 0.6;_rearPKE = 0.6;_rearPCE = 0.6;_topPKE = 0.6;_topPCE = 0.6;_bottomPKE = 0.59} else
{if (_target isKindOf "LAV25_Base") then {_armorCE = 32.5; _armorKE = 32.5; _surviv = 11; _sidePKE = 0.62;_sidePCE = 0.62;_rearPKE = 0.55;_rearPCE = 0.55;_topPKE = 0.62;_topPCE = 0.62;_bottomPKE = 0.62} else
{if (_target isKindOf "VIL_LEO2A4") then {_armorCE = 905; _armorKE = 620; _surviv = 26; _sidePKE = 0.27;_sidePCE = 0.46;_rearPKE = 0.13;_rearPCE = 0.22;_topPKE = 0.08;_topPCE = 0.13;_bottomPKE = 0.4} else
{if (_target isKindOf "VIL_new_PT91") then {_armorCE = 915; _armorKE = 625; _surviv = 24; _sidePKE = 0.47;_sidePCE = 0.4;_rearPKE = 0.17;_rearPCE = 0.17;_topPKE = 0.1;_topPCE = 0.1;_bottomPKE = 0.4} else
{if (_target isKindOf "VIL_t72M1_wp") then {_armorCE = 515; _armorKE = 415; _surviv = 20; _sidePKE = 0.45;_sidePCE = 0.51;_rearPKE = 0.21;_rearPCE = 0.17;_topPKE = 0.12;_topPCE = 0.1;_bottomPKE = 0.4} else
{if (_target isKindOf "VIL_rosomak") then {_armorCE = 150; _armorKE = 70; _surviv = 12; _sidePKE = 0.8;_sidePCE = 0.67;_rearPKE = 0.7;_rearPCE = 0.5;_topPKE = 0.4;_topPCE = 0.13;_bottomPKE = 0.8} else
{if (_target isKindOf "VIL_OSA_PLOT") then {_armorCE = 10; _armorKE = 10; _surviv = 10; _sidePKE = 1;_sidePCE = 1;_rearPKE = 1;_rearPCE = 1;_topPKE = 1;_topPCE = 1;_bottomPKE = 1} else
{if (_target isKindOf "VIL_DANA") then {_armorCE = 35; _armorKE = 35; _surviv = 8; _sidePKE = 0.57;_sidePCE = 0.57;_rearPKE = 0.57;_rearPCE = 0.57;_topPKE = 0.57;_topPCE = 0.57;_bottomPKE = 0.57} else
{if (_target isKindOf "VIL_2s1_PL") then {_armorCE = 30; _armorKE = 30; _surviv = 8; _sidePKE = 0.67;_sidePCE = 0.67;_rearPKE = 0.33;_rearPCE = 0.33;_topPKE = 0.33;_topPCE = 0.33;_bottomPKE = 0.5} else
{if (_target isKindOf "VIL_bmp1_wp") then {_armorCE = 35; _armorKE = 35; _surviv = 10; _sidePKE = 0.71;_sidePCE = 0.71;_rearPKE = 0.57;_rearPCE = 0.57;_topPKE = 0.29;_topPCE = 0.29;_bottomPKE = 1} else
{if (_target isKindOf "VIL_bwp2000_wp") then {_armorCE = 55; _armorKE = 55; _surviv = 13; _sidePKE = 0.5;_sidePCE = 0.5;_rearPKE = 0.1;_rearPCE = 0.1;_topPKE = 0.1;_topPCE = 0.1;_bottomPKE = 0.4} else
{if (_target isKindOf "ibr_LEO1A5") then {_armorCE = 380; _armorKE = 335; _surviv = 18; _sidePKE = 0.3;_sidePCE = 0.42;_rearPKE = 0.21;_rearPCE = 0.17;_topPKE = 0.09;_topPCE = 0.08;_bottomPKE = 0.3} else
{if (_target isKindOf "MLRS") then {_armorCE = 17.5; _armorKE = 17.5; _surviv = 8; _sidePKE = 0.57;_sidePCE = 0.57;_rearPKE = 0.57;_rearPCE = 0.57;_topPKE = 0.57;_topPCE = 0.57;_bottomPKE = 0.57} else
{if (_target isKindOf "GAZ_Vodnik") then {_armorCE = 10.5; _armorKE = 10.5; _surviv = 10; _sidePKE = 0.67;_sidePCE = 0.67;_rearPKE = 0.67;_rearPCE = 0.67;_topPKE = 0.67;_topPCE = 0.67;_bottomPKE = 0.95} else
{if (_target isKindOf "GAZ_Vodnik_HMG") then {_armorCE = 10.5; _armorKE = 10.5; _surviv = 10; _sidePKE = 0.67;_sidePCE = 0.67;_rearPKE = 0.67;_rearPCE = 0.67;_topPKE = 0.67;_topPCE = 0.67;_bottomPKE = 0.95}}}}}}}}}}}}}}}}}}}}}}}}}}};

_kinetic = false;
_chemical = false;
_explosive = false;
_penetration = 0;
switch true do
{
case (_ammo isKindOf "shellCore") :
	{
	if (_ammo isKindOf "Sh_105_HE") exitwith {_penetration = 62.5 + NBRand25; _explosive = true};
	if (_ammo isKindOf "Sh_100_HE") exitwith {_penetration = 70 + NBRand10; _explosive = true};
	if (_ammo isKindOf "Sh_120_HE") exitwith {_penetration = 567.5 + NBRand25; _explosive = true};
	if (_ammo isKindOf "Sh_120_SABOT") exitwith {_penetration = 805 + NBRand50; _kinetic = true};
	if (_ammo isKindOf "Sh_122_HE") exitwith {_penetration = 30 + NBRand25; _explosive = true};
	if (_ammo isKindOf "Sh_125_HE") exitwith {_penetration = 81.5 + NBRand50; _explosive = true};
	if ((_ammo isKindOf "Sh_125_SABOT") and (_weapon == "D81")) exitwith {_penetration = 515 + NBRand50; _kinetic = true};
	if ((_ammo isKindOf "Sh_125_SABOT") and (_weapon == "2A46M")) exitwith {_penetration = 785 + NBRand50; _kinetic = true};
	if (_ammo isKindOf "Sh_85_HE") exitwith {_penetration = 35 + NBRand10; _explosive = true};
	if (_ammo isKindOf "Sh_85_AP") exitwith {_penetration = 82.5 + NBRand25; _kinetic = true};
	if (_ammo isKindOf "VIL_NPL_AP120mm") exitwith {_penetration = 575 + NBRand50; _chemical = true};
	if (_ammo isKindOf "VIL_NPL_SB120mm") exitwith {_penetration = 835 + NBRand50; _kinetic = true};
	if (_ammo isKindOf "VIL_NPL_HE120mm") exitwith {_penetration = 87.5 + NBRand25; _explosive = true};
	if ((_ammo isKindOf "VIL_NPL_SB125mm") and (_attacker isKindOf "VIL_tankERA")) exitwith {_penetration = 645 + NBRand50; _kinetic = true};
	if ((_ammo isKindOf "VIL_NPL_AP125mm") and (_attacker isKindOf "VIL_tankERA")) exitwith {_penetration = 775 + NBRand50; _chemical = true};
	if (_ammo isKindOf "VIL_NPL_HE125mm") exitwith {_penetration = 97.5 + NBRand25; _explosive = true};
	if (_ammo isKindOf "VIL_NPL_SB125mm") exitwith {_penetration = 405 + NBRand50; _kinetic = true};
	if (_ammo isKindOf "VIL_NPL_AP125mm") exitwith {_penetration = 475 + NBRand50; _chemical = true};
	//if (_ammo isKindOf "VIL_NPL_AP125mm") exitwith {_penetration = 500 + NBRand50; _chemical = true};
	if (_ammo isKindOf "VIL_HE152mm") exitwith {_penetration = 112.5 + NBRand25; _explosive = true};
	if (_ammo isKindOf "VIL_HE122mm") exitwith {_penetration = 102.5 + NBRand25; _explosive = true};
	if (_ammo isKindOf "VIL_HEAT122mm") exitwith {_penetration = 435 + NBRand50; _chemical = true};
	if (_ammo isKindOf "vilas_AP73mm") exitwith {_penetration = 375.5 + NBRand25; _chemical = true};
	if (_ammo isKindOf "vilas_HE73mm") exitwith {_penetration = 55 + NBRand10; _explosive = true};
	if (_ammo isKindOf "VIL_NPL_sb60mm") exitwith {_penetration = 107.5 + NBRand25; _kinetic = true};
	if (_ammo isKindOf "VIL_NPL_he60mm") exitwith {_penetration = 15 + NBRand10; _explosive = true};
	if (_ammo isKindOf "VIL_NPL_Uni60mm") exitwith {_penetration = 80 + NBRand10; _chemical = true};
	if (_ammo isKindOf "VIL_NPL_ap60mm") exitwith {_penetration = 132.5 + NBRand25; _chemical = true};
	if (_ammo isKindOf "ibr_Sh_105_SABOT_leo") exitwith {_penetration = 505 + NBRand50; _kinetic = true};
	if (_ammo isKindOf "ibr_BM_8_100mm_HVAPDS") exitwith {_penetration = 207.5 + NBRand25; _kinetic = true};
	if (_ammo isKindOf "ibr_BK_17_100mm_HEAT") exitwith {_penetration = 275 + NBRand10; _chemical = true};
	if (_ammo isKindOf "ibr_OF_32_100mm_HE") exitwith {_penetration = 70 + NBRand10; _explosive = true}
	};

case (_ammo isKindOf "rocketCore") :
	{
	if (_ammo isKindOf "R_Hydra_HE") exitwith {_penetration = 15 + NBRand10; _explosive = true};
	if (_ammo isKindOf "R_57mm_HE") exitwith {_penetration = 5 + NBRand10; _explosive = true};
	if (_ammo isKindOf "R_80mm_HE") exitwith {_penetration = 25 + NBRand10; _explosive = true};
	if (_ammo isKindOf "R_S8T_AT") exitwith {_penetration = 405 + NBRand50; _chemical = true};
	if (_ammo isKindOf "R_M136_AT") exitwith {_penetration = 395 + NBRand50; _chemical = true};
	if (_ammo isKindOf "R_RPG18_AT") exitwith {_penetration = 350 + NBRand50; _chemical = true};
	if (_ammo isKindOf "R_PG7VR_AT") exitwith {_penetration = 625 + NBRand50; _chemical = true};
	if ((_ammo isKindOf "R_PG7VL_AT") or (_ammo isKindOf "VIL_PG7M_ammo")) exitwith {_penetration = 475 + NBRand50; _chemical = true};
	if ((_ammo isKindOf "R_PG7V_AT") or (_ammo isKindOf "VIL_PG7KO_ammo")) exitwith {_penetration = 305 + NBRand50; _chemical = true};
	if (_ammo isKindOf "R_OG7_AT") exitwith {_penetration = 5 + NBRand10; _explosive = true};
	if (_ammo isKindOf "R_PG9_AT") exitwith {_penetration = 275 + NBRand50; _chemical = true};
	if (_ammo isKindOf "R_OG9_HE") exitwith {_penetration = 19 + NBRand10; _explosive = true};
	if (_ammo isKindOf "R_SMAW_HEAA") exitwith {_penetration = 505 + NBRand50; _chemical = true};
	if (_ammo isKindOf "R_SMAW_HEDP") exitwith {_penetration = 55 + NBRand10; _chemical = true};
	if (_ammo isKindOf "R_GRAD") exitwith {_penetration = 20 + NBRand100; _explosive = true};
	if (_ammo isKindOf "R_MLRS") exitwith {_penetration = 550 + NBRand100; _explosive = true}
	};

case (_ammo isKindOf "missileCore") :
	{
	if (_ammo isKindOf "M_Javelin_AT") exitwith {_penetration = 775 + NBRand50; _chemical = true};
	if (_ammo isKindOf "M_Stinger_AA") exitwith {_penetration = 25 + NBRand10; _explosive = true};
	if (_ammo isKindOf "vil_Sidewinder_OSA") exitwith {_penetration = 207.5 + NBRand25; _explosive = true};
	if ((_ammo isKindOf "M_Sidewinder_AA") or (_ammo isKindOf "ibr_AIM9M_AA")) exitwith {_penetration = 85 + NBRand10; _explosive = true};
	if ((_ammo isKindOf "M_Strela_AA") or (_ammo isKindOf "VIL_grom_AA")) exitwith {_penetration = 15 + NBRand10; _explosive = true};
	if (_ammo isKindOf "M_Igla_AA") exitwith {_penetration = 20 + NBRand10; _explosive = true};
	if (_ammo isKindOf "M_AT5_AT") exitwith {_penetration = 625 + NBRand50; _chemical = true};
	if (_ammo isKindOf "M_AT13_AT") exitwith {_penetration = 925 + NBRand50; _chemical = true};
	if (_ammo isKindOf "M_TOW_AT") exitwith {_penetration = 775 + NBRand50; _chemical = true};
	if (_ammo isKindOf "M_TOW2_AT") exitwith {_penetration = 950 + NBRand100; _chemical = true};
	if (_ammo isKindOf "M_AT10_AT") exitwith {_penetration = 625 + NBRand50; _chemical = true};
	if (_ammo isKindOf "M_AT11_AT") exitwith {_penetration = 875 + NBRand50; _chemical = true};
	if (_ammo isKindOf "M_Hellfire_AT") exitwith {_penetration = 1350 + NBRand100; _chemical = true};
	if (_ammo isKindOf "M_Vikhr_AT") exitwith {_penetration = 950 + NBRand100; _chemical = true};
	if ((_ammo isKindOf "M_Maverick_AT") or (_ammo isKindOf "ibr_AGM65_AG")) exitwith {_penetration = 1750 + NBRand100; _chemical = true};
	if (_ammo isKindOf "M_R73_AA") exitwith {_penetration = 85 + NBRand10; _explosive = true};
	if (_ammo isKindOf "M_Ch29_AT") exitwith {_penetration = 4150 + NBRand100; _explosive = true};
	if (_ammo isKindOf "M_AT2_AT") exitwith {_penetration = 450 + NBRand100; _chemical = true};
	if (_ammo isKindOf "M_AT6_AT") exitwith {_penetration = 535 + NBRand50; _chemical = true};
	if (_ammo isKindOf "M_AT9_AT") exitwith {_penetration = 895 + NBRand50; _chemical = true};
	if (_ammo isKindOf "M_9M311_AA") exitwith {_penetration = 137.5 + NBRand25; _explosive = true};
	if (_ammo isKindOf "VILNPL_at3_sagger") exitwith {_penetration = 495 + NBRand50; _chemical = true}
	};

case (_ammo isKindOf "laserbombCore") :
	{
	if (_damage < 0.6) exitwith {};
	if (_damage > 1) then {_top = 1};
	if (_ammo isKindOf "ibr_GBU12_LGB") exitwith {_penetration = 2950 + NBRand100; _explosive = true};
	if (_ammo isKindOf "Bo_FAB_250") exitwith {_penetration = 3350 + NBRand100; _explosive = true}
	};

default 
	{
	if (_ammo == "mine") exitwith {_penetration = 687.5 + NBRand25; _explosive = true};
	if (_ammo == "mineE") exitwith {_penetration = 245 + NBRand10; _explosive = true};
	if ((_ammo == "pipebomb") or (_ammo == "timebomb")) exitwith { _penetration = 100 + NBRand100; _explosive = true};
	if (_ammo isKindOf "B_20mm_AP") exitwith { _penetration = 20 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_20mm_AA") exitwith { _penetration = 20 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_23mm_AA") exitwith { _penetration = 24 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_23mm_HE") exitwith { _penetration = 12 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_23mm_AP") exitwith { _penetration = 24 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_23mm_APHE") exitwith { _penetration = 18 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_25mm_HE") exitwith { _penetration = 13 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_25mm_HEI") exitwith { _penetration = 13 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_25mm_APDS") exitwith { _penetration = 23 + NBRand10; _kinetic = true};
	if ((_ammo isKindOf "B_30mm_AP") and (_weapon == "2A42")) exitwith { _penetration = 57 + NBRand10; _kinetic = true};
	if ((_ammo isKindOf "B_30mm_AP") and (_weapon == "2A72")) exitwith { _penetration = 80 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_30mmA10_AP") exitwith { _penetration = 64 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_30mm_HE") exitwith { _penetration = 16 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "B_30mm_AA") exitwith { _penetration = 16 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "G_30mm_HE") exitwith { _penetration = 5 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "G_40mm_HE") exitwith { _penetration = 6 + NBRand10; _kinetic = true};
	if (_ammo isKindOf "VIL_B_30mm_ros") exitwith {_penetration = 10 + NBRand10; _chemical = true};
	if (_ammo isKindOf "ibr_aden30_gunpods") exitwith {_penetration = 50 + NBRand10; _kinetic = true}
	}
};
switch true do
{
case (_kinetic) :
	{
	_penetration = _penetration + ((((1000 - (_attacker distance _target))/100) * 0.02) * _penetration);
	if ((_selection == "VEZ") and (_penetration > (_armorKE * NBRand50*0.03)) and (NBRand100 > 90)) then {_target setvariable [("TUR" + _varcomp),1,true]};
	if ((_selection == "ZBRAN") and (_penetration > (_armorKE * NBRand50B*0.03)) and (NBRand100B > 90)) then  {_target setvariable [("GUN" + _varcomp),1,true]};
	if not (_selection == "") exitwith {};
	_commH = _commH + _damage * NBrand100/70;
	_drvrH = _drvrH + _damage * NBrand100B/70;
	_gunnH = _gunnH + _damage * NBrand100C/70;
	_armorKE = _armorKE + (NBrand25 * (_armorKE/20) - NBrand10 * (_armorKE/20));
	if ((_dif >= -45) and (_dif < 45) and (_Dhatan > 20) and (_Tpitch < (_DHatan/120)) and (NBRand100C > 1)) then {_top = 1} else
		{if ((((_dif > -180) and (_dif <= -135)) or ((_dif > 135) and (_dif <= 180))) and (_Dhatan > 20) and (_Tpitch > -(_DHatan/120)) and (NBRand100C > 20)) then {_top = 1} else
			{if ((((_dif >= 45) and (_dif < 135)) or ((_dif > -135) and (_dif <= -45))) and (_Dhatan > 20) and (_TcheckL < (_DHatan/120)) and (NBRand100C > 20)) then {_top = 1}}};
	if (_top == 1) then {_armorKE = _armorKE * _topPKE};
	if ((_top != 1) and (_difA > 45) and (_difA <= 135)) then {_armorKE = _armorKE * _sidePKE};
	if ((_top != 1) and (_difA > 135)) then {_armorKE = _armorKE * _rearPKE};
	if (((_penetration > _armorKE) and (NBRand100 > 50)) or (NBRand100 > 95)) then {commander _target setdamage _commH;driver _target setdamage _drvrH;gunner _target setdamage _gunnH};
	if ((_penetration < _armorKE) and (NBRand100 < 99)) exitwith 
		{
		player sideChat format["TRG: %1 Arm: KE %2 Pen: SABOT %3 Dmg: %5",_target,_armorKE,_penetration,_damage,_DT];
		_commH = damage _comm;
		_drvrH = damage _drvr;
		_gunnH = damage _gunn
		};
	_target setDamage _DT + _damage*(_penetration/_armorKE)*(NBRand50/(3*_Surviv));
	if (_target getvariable ("TRP" + _varcomp) == 1) then { _target setHit ["PAS_P", 1]};
	if (_target getvariable ("TRL" + _varcomp) == 1) then { _target setHit ["PAS_L", 1]};

	if (_target getvariable ("TUR" + _varcomp) == 1) then { _target setHit ["VEZ", 1]};
	if (_target getvariable ("GUN" + _varcomp) == 1) then { _target setHit ["ZBRAN", 1]};

	if (_target getvariable ("WL11" + _varcomp) == 1) then { _target setHit ["wheel_1_1_steering", 1]};
	if (_target getvariable ("WL12" + _varcomp) == 1) then { _target setHit ["wheel_1_2_steering", 1]};
	if (_target getvariable ("WL13" + _varcomp) == 1) then { _target setHit ["wheel_1_3_steering", 1]};
	if (_target getvariable ("WL14" + _varcomp) == 1) then { _target setHit ["wheel_1_4_steering", 1]};
	if (_target getvariable ("WL21" + _varcomp) == 1) then { _target setHit ["wheel_2_1_steering", 1]};
	if (_target getvariable ("WL22" + _varcomp) == 1) then { _target setHit ["wheel_2_2_steering", 1]};
	if (_target getvariable ("WL23" + _varcomp) == 1) then { _target setHit ["wheel_2_3_steering", 1]};
	if (_target getvariable ("WL24" + _varcomp) == 1) then { _target setHit ["wheel_2_4_steering", 1]};
	_DT = damage _target;
	if true exitwith 
		{
		player sideChat format["TRG: %1 Arm: KE %2 Pen: SABOT %3 Dmg: %5",_target,_armorKE,_penetration,_damage,_DT];
		_commH = damage _comm;
		_drvrH = damage _drvr;
		_gunnH = damage _gunn
		}
	};

case (_chemical) :
	{
	if ((_selection == "VEZ") and (_penetration > (_armorCE * NBRand50*0.03)) and (NBRand100 > 90)) then {_target setvariable [("TUR" + _varcomp),1,true]};
	if ((_selection == "ZBRAN") and (_penetration > (_armorCE * NBRand50B*0.03)) and (NBRand100B > 90)) then  {_target setvariable [("GUN" + _varcomp),1,true]};
	if not (_selection == "") exitwith {};
	_commH = _commH + _damage * NBrand100/70;
	_drvrH = _drvrH + _damage * NBrand100B/70;
	_gunnH = _gunnH + _damage * NBrand100C/70;
	_armorCE = _armorCE + (NBrand25 * (_armorCE/20) - NBrand10 * (_armorCE/20));
	if ((_dif >= -45) and (_dif < 45) and (_Dhatan > 20) and (_Tpitch < (_DHatan/120)) and (NBRand100C > 1)) then {_top = 1} else
		{if ((((_dif > -180) and (_dif <= -135)) or ((_dif > 135) and (_dif <= 180))) and (_Dhatan > 20) and (_Tpitch > -(_DHatan/120)) and (NBRand100C > 20)) then {_top = 1} else
			{if ((((_dif >= 45) and (_dif < 135)) or ((_dif > -135) and (_dif <= -45))) and (_Dhatan > 20) and (_TcheckL < (_DHatan/120)) and (NBRand100C > 20)) then {_top = 1}}};
	if (_ammo isKindOf "M_Javelin_AT") then {_top = 1};
	if (_top == 1) then {_armorCE = _armorCE * _topPCE};
	if ((_top != 1) and (_difA > 45) and (_difA <= 135)) then {_armorCE = _armorCE * _sidePCE};
	if ((_top != 1) and (_difA > 135)) then {_armorCE = _armorCE * _rearPCE};
	if (((_penetration > _armorCE) and (NBRand100 > 50)) or (NBRand100 > 95)) then {commander _target setdamage _commH;driver _target setdamage _drvrH;gunner _target setdamage _gunnH};
	if ((_penetration < _armorCE) and (NBRand100 < 99)) exitwith 
		{
		player sideChat format["TRG: %1 Arm: CE %2 Pen: HEAT %3 Dmg: %5",_target,_armorCE,_penetration,_damage,_DT];
		_commH = damage _comm;
		_drvrH = damage _drvr;
		_gunnH = damage _gunn
		};
	_target setDamage _DT + _damage*(_penetration/_armorCE)*(NBRand50/(3*_Surviv));
	if (_target getvariable ("TRP" + _varcomp) == 1) then { _target setHit ["PAS_P", 1]};
	if (_target getvariable ("TRL" + _varcomp) == 1) then { _target setHit ["PAS_L", 1]};

	if (_target getvariable ("TUR" + _varcomp) == 1) then { _target setHit ["VEZ", 1]};
	if (_target getvariable ("GUN" + _varcomp) == 1) then { _target setHit ["ZBRAN", 1]};

	if (_target getvariable ("WL11" + _varcomp) == 1) then { _target setHit ["wheel_1_1_steering", 1]};
	if (_target getvariable ("WL12" + _varcomp) == 1) then { _target setHit ["wheel_1_2_steering", 1]};
	if (_target getvariable ("WL13" + _varcomp) == 1) then { _target setHit ["wheel_1_3_steering", 1]};
	if (_target getvariable ("WL14" + _varcomp) == 1) then { _target setHit ["wheel_1_4_steering", 1]};
	if (_target getvariable ("WL21" + _varcomp) == 1) then { _target setHit ["wheel_2_1_steering", 1]};
	if (_target getvariable ("WL22" + _varcomp) == 1) then { _target setHit ["wheel_2_2_steering", 1]};
	if (_target getvariable ("WL23" + _varcomp) == 1) then { _target setHit ["wheel_2_3_steering", 1]};
	if (_target getvariable ("WL24" + _varcomp) == 1) then { _target setHit ["wheel_2_4_steering", 1]};
	_DT = damage _target;
	if true exitwith 
		{
		player sideChat format["TRG: %1 Arm: CE %2 Pen: HEAT %3 Dmg: %5",_target,_armorCE,_penetration,_damage,_DT];
		_commH = damage _comm;
		_drvrH = damage _drvr;
		_gunnH = damage _gunn
		}
	};

case (_explosive) :
	{
	if ((_selection == "VEZ") and (_penetration > (_armorKE * NBRand50*0.03)) and (NBRand100 > 90)) then {_target setvariable [("TUR" + _varcomp),1,true]};
	if ((_selection == "ZBRAN") and (_penetration > (_armorKE * NBRand50B*0.03)) and (NBRand100B > 90)) then  {_target setvariable [("GUN" + _varcomp),1,true]};

	if ((_ammo == "mine") and (_selection == "PAS_P") and (NBRand100 > 20)) then {_target setHit ["PAS_P", 1]; _target setHit ["PAS_P", 1];_target setvariable [("TRP" + _varcomp),1,true]};
	if ((_ammo == "mine") and (_selection == "PAS_L") and (NBRand100B > 20)) then {_target setHit ["PAS_L", 1]; _target setHit ["PAS_L", 1];_target setvariable [("TRL" + _varcomp),1,true]} else

		{if ((_ammo == "mine") and (_selection == "wheel_1_1_steering") and (NBRand100 > 10)) then {_target setHit ["wheel_1_1_steering", 1];_target setvariable [("WL11" + _varcomp),1,true]};
		if ((_ammo == "mine") and (_selection == "wheel_1_2_steering") and (NBRand100 > 10)) then {_target setHit ["wheel_1_2_steering", 1];_target setvariable [("WL12" + _varcomp),1,true]};
		if ((_ammo == "mine") and (_selection == "wheel_1_3_steering") and (NBRand100 > 10)) then {_target setHit ["wheel_1_3_steering", 1];_target setvariable [("WL13" + _varcomp),1,true]};
		if ((_ammo == "mine") and (_selection == "wheel_1_4_steering") and (NBRand100 > 10)) then {_target setHit ["wheel_1_4_steering", 1];_target setvariable [("WL14" + _varcomp),1,true]};
		if ((_ammo == "mine") and (_selection == "wheel_2_1_steering") and (NBRand100 > 10)) then {_target setHit ["wheel_2_1_steering", 1];_target setvariable [("WL21" + _varcomp),1,true]};
		if ((_ammo == "mine") and (_selection == "wheel_2_2_steering") and (NBRand100 > 10)) then {_target setHit ["wheel_2_2_steering", 1];_target setvariable [("WL22" + _varcomp),1,true]};
		if ((_ammo == "mine") and (_selection == "wheel_2_3_steering") and (NBRand100 > 10)) then {_target setHit ["wheel_2_3_steering", 1];_target setvariable [("WL23" + _varcomp),1,true]};
		if ((_ammo == "mine") and (_selection == "wheel_2_4_steering") and (NBRand100 > 10)) then {_target setHit ["wheel_2_4_steering", 1];_target setvariable [("WL24" + _varcomp),1,true]}};

	if ((_ammo == "mineE") and (_selection == "PAS_P") and (NBRand100 > 25)) then {_target setHit ["PAS_P", 1]; _target setHit ["PAS_P", 1];_target setvariable [("TRP" + _varcomp),1,true]};
	if ((_ammo == "mineE") and (_selection == "PAS_L") and (NBRand100B > 25)) then {_target setHit ["PAS_L", 1]; _target setHit ["PAS_L", 1];_target setvariable [("TRL" + _varcomp),1,true]} else

		{if ((_ammo == "mineE") and (_selection == "wheel_1_1_steering") and (NBRand100 > 15)) then {_target setHit ["wheel_1_1_steering", 1];_target setvariable [("WL11" + _varcomp),1,true]};
		if ((_ammo == "mineE") and (_selection == "wheel_1_2_steering") and (NBRand100 > 15)) then {_target setHit ["wheel_1_2_steering", 1];_target setvariable [("WL12" + _varcomp),1,true]};
		if ((_ammo == "mineE") and (_selection == "wheel_1_3_steering") and (NBRand100 > 15)) then {_target setHit ["wheel_1_3_steering", 1];_target setvariable [("WL13" + _varcomp),1,true]};
		if ((_ammo == "mineE") and (_selection == "wheel_1_4_steering") and (NBRand100 > 15)) then {_target setHit ["wheel_1_4_steering", 1];_target setvariable [("WL14" + _varcomp),1,true]};
		if ((_ammo == "mineE") and (_selection == "wheel_2_1_steering") and (NBRand100 > 15)) then {_target setHit ["wheel_2_1_steering", 1];_target setvariable [("WL21" + _varcomp),1,true]};
		if ((_ammo == "mineE") and (_selection == "wheel_2_2_steering") and (NBRand100 > 15)) then {_target setHit ["wheel_2_2_steering", 1];_target setvariable [("WL22" + _varcomp),1,true]};
		if ((_ammo == "mineE") and (_selection == "wheel_2_3_steering") and (NBRand100 > 15)) then {_target setHit ["wheel_2_3_steering", 1];_target setvariable [("WL23" + _varcomp),1,true]};
		if ((_ammo == "mineE") and (_selection == "wheel_2_4_steering") and (NBRand100 > 15)) then {_target setHit ["wheel_2_4_steering", 1];_target setvariable [("WL24" + _varcomp),1,true]}};
	if not (_selection == "") exitwith {};
	_armorKE = _armorKE + (NBrand25 * (_armorKE/20) - NBrand10 * (_armorKE/20));

	if ((_dif >= -45) and (_dif < 45) and (_Dhatan > 20) and (_Tpitch < (_DHatan/120)) and (NBRand100C > 1)) then {_top = 1};
	if ((((_dif > -180) and (_dif <= -135)) or ((_dif > 135) and (_dif <= 180))) and (_Dhatan > 20) and (_Tpitch > -(_DHatan/120)) and (NBRand100C > 20)) then {_top = 1};
	if ((((_dif >= 45) and (_dif < 135)) or ((_dif > -135) and (_dif <= -45))) and (_Dhatan > 20) and (_TcheckL < (_DHatan/120)) and (NBRand100C > 20)) then {_top = 1};
	if ((_top != 1) and (_difA > 45) and (_difA <= 135)) then {_armorKE = _armorKE * _sidePKE};
	if ((_top != 1) and (_difA > 135)) then {_armorKE = _armorKE * _rearPKE};
	if ((_ammo == "mine") or (_ammo == "mineE")) then {_armorKE = _armorKE * _bottomPKE};
	if ((_top == 1) and not ((_ammo == "mine") or (_ammo == "mineE") or (_ammo == "pipebomb") or (_ammo == "timebomb"))) then {_armorKE = _armorKE * _topPKE};

	_commH = _commH + _damage * NBrand100/70;
	_drvrH = _drvrH + _damage * NBrand100B/70;
	_gunnH = _gunnH + _damage * NBrand100C/70;
	if (((_penetration > _armorKE) and (NBRand100 > 50)) or (NBRand100 > 95)) then {commander _target setdamage _commH;driver _target setdamage _drvrH;gunner _target setdamage _gunnH};
	if ((_penetration < _armorKE) and (NBRand100 < 99)) exitwith 
		{
		player sideChat format["TRG: %1 Arm: KE %2 Pen: EXPL %3 Dmg: %5",_target,_armorKE,_penetration,_damage,_DT];
		_commH = damage _comm;
		_drvrH = damage _drvr;
		_gunnH = damage _gunn
		};
	_target setDamage _DT + _damage*(_penetration/_armorKE)*(NBRand50/(3*_Surviv));
	if (_target getvariable ("TRP" + _varcomp) == 1) then { _target setHit ["PAS_P", 1]};
	if (_target getvariable ("TRL" + _varcomp) == 1) then { _target setHit ["PAS_L", 1]};

	if (_target getvariable ("TUR" + _varcomp) == 1) then { _target setHit ["VEZ", 1]};
	if (_target getvariable ("GUN" + _varcomp) == 1) then { _target setHit ["ZBRAN", 1]};

	if (_target getvariable ("WL11" + _varcomp) == 1) then { _target setHit ["wheel_1_1_steering", 1]};
	if (_target getvariable ("WL12" + _varcomp) == 1) then { _target setHit ["wheel_1_2_steering", 1]};
	if (_target getvariable ("WL13" + _varcomp) == 1) then { _target setHit ["wheel_1_3_steering", 1]};
	if (_target getvariable ("WL14" + _varcomp) == 1) then { _target setHit ["wheel_1_4_steering", 1]};
	if (_target getvariable ("WL21" + _varcomp) == 1) then { _target setHit ["wheel_2_1_steering", 1]};
	if (_target getvariable ("WL22" + _varcomp) == 1) then { _target setHit ["wheel_2_2_steering", 1]};
	if (_target getvariable ("WL23" + _varcomp) == 1) then { _target setHit ["wheel_2_3_steering", 1]};
	if (_target getvariable ("WL24" + _varcomp) == 1) then { _target setHit ["wheel_2_4_steering", 1]};
	_DT = damage _target;
	if true exitwith 
		{
		player sideChat format["TRG: %1 Arm: KE %2 Pen: EXPL %3 Dmg: %5",_target,_armorKE,_penetration,_damage,_DT];
		_commH = damage _comm;
		_drvrH = damage _drvr;
		_gunnH = damage _gunn
		}
	};
default {if true exitwith {}};
};

NBRandomizer.sqf:

/*
sqf version of Nice_boat's NBRandomizer by Rydygier

init (to initialize only once, at the beginning): 
null = [] execVM "NBRandomizer.sqf";
*/
while {true} do
{
NBRand10 = random 10;
NBRand25 = random 25;
NBRand50 = random 50;
NBRand50B = random 50;
NBRand100 = random 100;
NBRand100B = random 100;
NBRand100C = random 100;
sleep 0.01
};

and CrewDS.sqf:

/*
sqf version of Crew Damage System by Rydygier

init (to initialize only once, at the beginning): 
null = [] execVM "CrewDS.sqf";
*/


_i = 0;

while {true} do
{
_tcount = ("tank" counttype vehicles);
_tanks = []; 
_ix = 0;
for [{_i = 0},{(_i <= _tcount-1)},{_i = _i + 1}] do
	{
	if ((vehicles select _i) isKindOf "tank") then {_tanks = _tanks + [vehicles select _i]}
	};

{{_x removeallEventHandlers "Handledamage"} foreach crew _x} foreach allunits;
{{_x removeallEventHandlers "Handledamage";_ix = _x addEventHandler ["Handledamage", ""]} foreach crew _x} foreach _tanks;
sleep 0.5
};

As you can see, there is a problem. Do not invent better way to protect crew from injury, which has received even without armor penetration ("allowdamage false" here fails, so script checks two times per second, who is currently sitting in vehicle and gives him an empty EH "handledamage", which makes it immune to normal damage, but instead wound "assigns" to the crew NBtank.sqf). CrewDS.sqf must also remove EH's from all those who got out of vehicle. Unfortunately, this removes EH along with all other "handledamage" type EH's. Maybe someone knows way to remove only chosen EH of specific type from unit, even though index of EH is not constant?

Edited by Rydygier

Share this post


Link to post
Share on other sites

I did some tests, it looks like that SQF scripts work fine. So here's version of addon based on SQF files:

NBT_TDS

In addition to folder "addons" there are two more: "lessoneshotkill" and "moreoneshotkill". Each of them contains .pbo of the same name (so be careful to not mix them, I suggest simply copy preferred file to folder "addons" overwriting previous one), but in the second case has been greatly increased chance of destroying a tank after first armor penetration (reduced chance for non-killing penetration by tripling average final damage in case of succesful armor penetration). It seems to me that this version is more realistic, but case that someone preferred previous one, in folder "lessoneshotkill" I left a file with old values. By default in folder "addons" is version "more". I think this is enough for now. Must sometimes play this game, not only write scripts for it...

For now wish you good fun with this addon. Report here, please, any comments and ideas.

Share this post


Link to post
Share on other sites

Think I succeeded somewhat overcome problems with "Towards Enemy System". This time used waypoints dynamically placed about 6 meters from vehicle towards enemy. As waypoints are assigned to the group, system works good for ungrouped tanks. For missions with tanks grouped eg. in platoons recommended first version, without "TES". It does not replace waypoints designated by the AI, so if AI chooses to relocate tank, it will not rotate towards enemy until fills this order, so can still happen that a sensitive sides or back will be under fire. Also removed some minor problems from main file. It contains debug and no-debug versions.

Here are two versions of addon in one package:

NBT_TDS

TDS differs from TDS2 only that is not equipped with "Towards Enemy System". It is, I think, final version of Nice_Boat's TDS, unless show up any new bug reports, comments or ideas. Was tested on Arma 2 1.10. Addon requires CBA.

Thanks for help and testing. Have a nice tanking.

Edited by Rydygier
bug fix

Share this post


Link to post
Share on other sites

Sure:

NBT_TDS

It's been a long time since I looked in this code, I remember that remained a problem with lag when tank is under rapid fire (because each hit fires an eventhandler), there is also no support for ARTY_ amunition used with BIS_ARTY module. There is some chance, that I will return to this project, now I have some new knowledge, that may helps with these lags a bit, although seems, that only a few people are interested in this addon.

Edited by Rydygier

Share this post


Link to post
Share on other sites
Talking as a noob - can this be preprocessed ? Would that reduce lag ?

Seems, that I'm equally noobish, because you said exactly what I mean. :) Preprocess and compile then only spawn instead of execVM.

Share this post


Link to post
Share on other sites

I will likely keep the battles smaller in size in order to reduce the performace hit.

1v1 tank platoons ect.

Thanks for posting it again!.

Share this post


Link to post
Share on other sites

Well. Found some time, so...

Nice_Boat's Tank Damage System 2

News:

- lags reduced or even removed (I hope so);

- no more juggling with pbo versions: see readme to know, how to on/off debug and Towards Enemy System (TES is based on temporary waypoint assigment, so effects may be imperfect, when tank already has waypoint assigned) with two simply config variables;

- script version added (see readme, how to init);

- added handling of ARTY module ammo, but untested, so effects unknown.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×