Script:Files:script/vehicles/parts/base.script

From Mod Wiki
Revision as of 10:04, 5 November 2007 by Wizz (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
object vehicle_part_destructable {
    void            OnPostDamage( entity attacker, float oldHealth, float newHealth );
    float            damageEffectLevel;    
};

void vehicle_part_destructable::OnPostDamage( entity attacker, float oldHealth, float newHealth ) {
    float newDamageEffectLevel;    

    if ( newHealth < 10 ) {
        newDamageEffectLevel = 1;
    } else {
        newDamageEffectLevel = 0;
    }

    if ( newDamageEffectLevel != damageEffectLevel ) {
        entity parent = getParent();
        parent.playEffect( "fx_damage_level1", getJoint(), 1 );
        damageEffectLevel = newDamageEffectLevel;
    }
}