Script:Files:script/projectiles/emp.script

From Mod Wiki
Revision as of 09:53, 5 November 2007 by Wizz (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/***********************************************************************

projectile_emp.script

***********************************************************************/

object projectile_emp : projectile_grenade {
    void            init();
    void            preinit();

    void            DoExplodeEffect( entity collisionEnt );

    float            empRadius;
    float            empTime;
    float            weaponEmpTime;
};

void projectile_emp::init() {
    SetupContents();
    setState( "Idle" );
}

void projectile_emp::preinit() {
    empRadius        = getFloatKey( "emp_radius" );
    empTime            = getFloatKey( "emp_time" );
    weaponEmpTime    = getFloatKey( "emp_weapon_time" );
}

void projectile_emp::DoExplodeEffect( entity collisionEnt ) {
    float removeDelay;
    SetRadiusDamageIgnoreEntity( collisionEnt );
    removeDelay = getFloatKeyWithDefault( "removedelay", 0.5 );

    DoRadiusDamage();




    entitiesOfCollection( "emp" );
    filterEntitiesByRadius( getWorldOrigin(), empRadius, true );
    filterEntitiesByAllegiance( TA_FLAG_ENEMY, 1 );

    entity owner = getOwner();

    float count = getBoundsCacheCount();
    float i;
    for ( i = 0; i < count; i++ ) {
        entity ent = getBoundsCacheEntity( i );
        ent.vApplyEmpDamage( owner, empTime, weaponEmpTime );
    }

    ScheduleRemoval( removeDelay );
}