fn_damageHandlerAI2.sqf how damage is assigned to AI

Rixsaw

New Member
I found the AI Dmg Handler its fn_damageHandlerAI2.sqf.

It appears that this is a damage handler dedicated to AI damage..

Reading through it appears that I see an issue which bears out in testing for me. I have had AI take 4 shots to the chest and then 3 shots to the head before dieing from a DMR. Some of it my be my misreading what is going on at the crosshairs, but after several instances I decided to dig a bit deeper.

Code:
if ((group _unit) == (group _source)) then {_damage = (_damage/5)};    //Reduce friendly fire and collision damage.

I'd like to turn on some debugs to see how much dmg the AI are taking, and what groups it thinks the player and the AI are in.

I thought we just had East / West / Neutral, so maybe the AI are aligned to the same "Group" as me and therefore taking dmg/5.

Or it could be that the function call is not passing or allowing those variables to be read properly.

Also it appears that shots are either Head, Legs, or Other, which means if I hit the AI with an AS50 in the chest the damage scale is 300 + 800(player source) + 200(for the size bullet) = 1300* (0.1-1.0) So max damage shot to the chest is 1300 dmg? Seems like they have a Zero missing, a max damage shot to the chest should be a 1 shot kill from an AS50 or something.
 
A group is a squad in Arma. This squad can view eachother on the map, and the entire squad takes commands from the squad leader.

In the case of a damage handler, _unit is referring to the AI being shot, and _source being who fired the shot.
Only the group of 3(ish) AI will be in a group together, and you will never be in that group unless you use join or joinSilent to force yourself into their group.

Two separate "squads" of AI could fire on each other with full damage, which is how it's intended.

There may be a bug with the code, but it is not with the quoted line.

As for damage, you can add a line into the script to report the damage taken each hit to the RPT.
 
Vampire covered the group explanation pretty much. The effect of the damage reduction is to
  • 1) Prevent physics-related damage (ie: so players have a bit of difficulty running AI over to kill them)
  • 2) Reduce friendly fire damage when grouped units position themselves in a group member's line of fire.
This damage reduction will never be applied to any player unless you do some specific scripting as Vampire described.

You have to keep in mind how a "HandleDamage" eventhandler works. Each instance of damage (ie: each bullet that hits) causes the eventhandler to fire 5 times, one for each part of the unit's body:

  1. Overall health
  2. Head
  3. Torso
  4. Arms
  5. Legs
Whenever damage is dealt to a unit, the full amount is spread out across any of these 5 parts. So, you can't calculate blood damage per bullet based just on the head, or torso, etc, you have to add up all 5 amounts of damage. In my testing with STANAG and AKM rounds, the numbers came up very close to the numbers you'd find on a site like DayZDB - About 3700 blood with STANAG and 4500 blood with AKM. The exact blood damage isn't a fixed number and depends on a variety of factors such as distance and parts damaged.

The calculations that DZAI uses for blood damage are identical to the ones that DayZ uses. Compare the code in fn_damageHandlerAI2.sqf against Epoch's fn_damageHandler.sqf. The parts that deal with blood damage in Epoch are here:

Code:
//PVP Damage
_scale = 200;
if (_damage > 0.4) then {
    if (_ammo != "zombie") then {
        _scale = _scale + 50;
    };
    if (_isHeadHit) then {
        _scale = _scale + 500;
    };
    if ((isPlayer _source) && !(player == _source)) then {
        _scale = _scale + 800;
        if (_isHeadHit) then {
            _scale = _scale + 500;
        };
    };
    switch (_type) do {
        case 1: {_scale = _scale + 200};
        case 2: {_scale = _scale + 200};
    };
    if (_unitIsPlayer) then {
        //Cause blood loss
        //Log Damage
        /*
        if (DZE_Debug_Damage) then {
            diag_log ("DAMAGE: player hit by " + typeOf _source + " in " + _hit + " with " + _ammo + " for " + str(_damage) + " scaled " + str(_damage * _scale));
        };
        */
        r_player_blood = r_player_blood - (_damage * _scale);
    };
};

Compare this with DZAI's damage handler and you'll find the calculations are nearly identical. The difference is that DZAI multiplies the scaling factor from headshot damage by 6x and adds 500 blood damage while Epoch simply adds a flat 500 blood damage without the scaling factor increase.

Also, the value for _damage isn't limited to a maximum of 1.0. For high-damaging weapons like sniper rifles and .50 cals, the value could be in the ballpark of 2.0-4.0, or even higher.

(Edit): A Google search showed a few examples of damage values from high-cal sniper rifles:

M107 : 6.19 dmg
KSVK : 8.25 dmg
AS50 : 34.89 dmg


In my own testing, I'm frequently able to 1-hit kill AI with badly-aimed Lee Enfield body shots (meaning aimed at the body, I don't know where they're actually landing), so I can't personally confirm anything wrong with the blood damage calculations.
 
This is a damage log sample of an AI unit with 10400 starting blood shot once in the torso with a Lee Enfield at a distance of about 75-100m:


Code:
19:19:20 "DEBUG :: Unit O 1-1-A:1 took 2515.59 blood damage in part  by ammo B_303_Ball (Blood level: 7905.86)."
19:19:20 "DEBUG :: Unit O 1-1-A:1 took 5443.87 blood damage in part body by ammo B_303_Ball (Blood level: 2461.99)."
19:19:20 "DEBUG :: Unit O 1-1-A:1 took 4212.87 blood damage in part hands by ammo B_303_Ball (Blood level: -1750.88)."

If you do the math:

Total blood damage dealt by 1 Lee Enfield round: 12,172. Note that the AI damage eventhandler is disabled once the AI takes lethal blood damage, so you only see 3 instances of damage.
 
Yeah I turned on the debug, and an AR 15 was doing 800 dmg. Sometime the debug never fired, it certainly didn't fire 3 times. This is on a test server, where I am testing sheeps repack, so there may be other issues, I'm planning to add some code to the debug to see what body part is hit and what affects beyond blood dmg are applied, the test team reports unkillable ai...


Sent from my iPhone using Tapatalk
 
Back
Top