Brick icon

A3 Handle Damage

Brick | PRO | 09/20/16 03:23:05 AM UTC | 0 ⭐ | 233 👁️ | Never ⏰ | []
SQF |

4.08 KB

|

None

|

0 👍

/

0 👎

comment
"
    Name            | Source        | Projectile    | Instigator
                    |               |               |
    VDM             | Driver        | Null          | Null
    Vehicle Gun     | Vehicle       | Bullet        | Gunner
    From Vehicle    | Player        | Bullet        | Player
    On Foot         | Player        | Bullet        | Player
    Fall Damage     | Player        | Null          | Null
    Crashing        | Null          | Null          | Null
    Fire            | Null          | Null          | Null
    Explosion       | Null          | Explosion     | Null
";
 
cursorTarget addEventHandler
[
    "HandleDamage",
    {
        private _unit           = param [0];
        private _selectionName  = param [1];
        private _damage         = param [2];
        private _source         = param [3];
        private _projectile     = param [4];
        private _hitPartIndex   = param [5];
        private _instigator     = param [6];
 
        private _oldDamage =
        if (_hitPartIndex isEqualTo -1) then
        {
            damage _unit;
        }
        else
        {
            _unit getHitIndex _hitPartIndex;
        };
 
        private _newDamage = call
        {
            comment "Ignore 0 Damage";
            if (_damage isEqualTo _oldDamage) exitWith
            {
                _damage;
            };
 
            comment "Crashing, Fire, Explosion";
            if (isNull _source) exitWith
            {
                _damage;
            };
 
            comment "Fall Damage"
            if (_source isEqualTo _unit) exitWith
            {
                _damage;
            };
 
            private _sourceParent = objectParent _source;
 
            comment "VDM";
            if (_projectile isEqualTo "") exitWith
            {
                comment "Check the source is in a vehicle";
                if !(isNull _sourceParent) then
                {
                    hint format ["You were VDM'd by %1", name _source];
                };
 
                _oldDamage;
            };
 
            comment "Source is not on foot, shooting a vehicle's gun, or shooting from a vehicle that isn't a car / boat";
            if !(isNull _sourceParent || { _sourceParent isKindOf "Car" } || { _sourceParent isKindOf "Boat" }) exitWith
            {
                _oldDamage;
            };
 
            comment "Being shot by player";
            private _sourceSide     = side _source;
            private _sourceWeapon   = currentWeapon _source;
 
            private _unitParent     = objectParent _unit;
 
            comment "Player is Cop";
            if (_sourceSide isEqualTo west) then
            {
                comment "Tazer: P07 Silenced, Rook-40 Silenced - Green Tracer 9mm";
                if (_sourceWeapon in ["hgun_P07_snds_F", "hgun_Rook40_snds_F"] && { _projectile in ["B_9x21_Ball_Tracer_Green"] }) exitWith
                {
                    comment "Only play animation if they are on foot";
                    if (isNull _unitParent) then
                    {
                        _unit switchMove "AinjPfalMstpSnonWnonDf_carried_fallwc";
                    };
 
                    _oldDamage;
                };
 
                comment "Rubber Bullet: MK20, MK20C, SDAR - Green Tracer 556, Dual Purpose 556";
                if (_sourceWeapon in ["arifle_Mk20_plain_F", "arifle_Mk20C_plain_F", "arifle_SDAR_F"] && { _projectile in ["B_556x45_Ball_Tracer_Green", "B_556x45_dual"] }) exitWith
                {
                    comment "Only play animation if they are on foot";
                    if (isNull _unitParent) then
                    {
                        _unit switchMove "AcinPercMstpSnonWnonDnon_agony";
                    };
 
                    _oldDamage;
                };
            };
        };
 
        comment "Default";
        if (isNil "_newDamage") then
        {
            ["Invalid Damage: %1", _this] call BIS_fnc_error;
 
            _newDamage = _damage;
        };
 
        _newDamage;
    }
];

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎