]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/turret/tesla_weapon.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / turret / tesla_weapon.qc
index 88ca4db9702f491d237edd4adade82a526b0c9af..d9ec07c662e2503326b8a8dbde5c6d9cfb4fd8db 100644 (file)
@@ -4,81 +4,78 @@
 
 entity toast(entity actor, entity from, float range, float damage);
 SOUND(TeslaCoilTurretAttack_FIRE, W_Sound("electro_fire"));
-METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
-    bool isPlayer = IS_PLAYER(actor);
-    if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
-        if (isPlayer) {
-            turret_initparams(actor);
-            W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_TeslaCoilTurretAttack_FIRE, CH_WEAPON_B, 0);
-            actor.tur_shotdir_updated = w_shotdir;
-            actor.tur_shotorg = w_shotorg;
-            actor.tur_head = actor;
-            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
-        }
-
-        float d = actor.shot_dmg;
-        float r = actor.target_range;
-        entity e = spawn();
-        setorigin(e, actor.tur_shotorg);
+METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
+{
+       bool isPlayer = IS_PLAYER(actor);
+       if (fire & 1) {
+               if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire))) {
+                       if (isPlayer) {
+                               turret_initparams(actor);
+                               W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_TeslaCoilTurretAttack_FIRE, CH_WEAPON_B, 0);
+                               actor.tur_shotdir_updated = w_shotdir;
+                               actor.tur_shotorg = w_shotorg;
+                               actor.tur_head = actor;
+                               weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+                       }
 
-        actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
+                       float d = actor.shot_dmg;
+                       float r = actor.target_range;
+                       entity e = spawn();
+                       setorigin(e, actor.tur_shotorg);
 
-        entity t = toast(actor, e,r,d);
-        delete(e);
+                       actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK;
 
-        if (t == NULL) return;
+                       entity t = toast(actor, e, r, d);
+                       delete(e);
 
-        actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_TEAMCHECK;
+                       if (t == NULL) { return; }
 
-        actor.attack_finished_single[0] = time + actor.shot_refire;
-        for (int i = 0; i < 10; ++i) {
-            d *= 0.75;
-            r *= 0.85;
-            t = toast(actor, t, r, d);
-            if (t == NULL) break;
+                       actor.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_TEAMCHECK;
 
-        }
+                       actor.attack_finished_single[0] = time + actor.shot_refire;
+                       for (int i = 0; i < 10; ++i) {
+                               d *= 0.75;
+                               r *= 0.85;
+                               t = toast(actor, t, r, d);
+                               if (t == NULL) { break; }
+                       }
 
-        IL_EACH(g_railgunhit, it.railgunhit,
-        {
-            it.railgunhit = false;
-        });
-        IL_CLEAR(g_railgunhit);
-    }
+                       IL_EACH(g_railgunhit, it.railgunhit,
+                       {
+                               it.railgunhit = false;
+                       });
+                       IL_CLEAR(g_railgunhit);
+               }
+       }
 }
 
 entity toast(entity actor, entity from, float range, float damage)
 {
-    float dd = range + 1;
-    entity etarget = NULL;
-    FOREACH_ENTITY_RADIUS(from.origin, range, it != from && !it.railgunhit,
-    {
-        float r = turret_validate_target(actor, it, actor.target_validate_flags);
-        if(r > 0)
-        {
-            traceline(from.origin, 0.5 * (it.absmin + it.absmax), MOVE_WORLDONLY, from);
-            if(trace_fraction == 1.0)
-            {
-                float d = vlen(it.origin - from.origin);
-                if(d < dd)
-                {
-                    dd = d;
-                    etarget = it;
-                }
-            }
-        }
-    });
+       float dd = range + 1;
+       entity etarget = NULL;
+       FOREACH_ENTITY_RADIUS(from.origin, range, it != from && !it.railgunhit,
+       {
+               float r = turret_validate_target(actor, it, actor.target_validate_flags);
+               if (r > 0) {
+                       traceline(from.origin, 0.5 * (it.absmin + it.absmax), MOVE_WORLDONLY, from);
+                       if (trace_fraction == 1.0) {
+                               float d = vlen(it.origin - from.origin);
+                               if (d < dd) {
+                                       dd = d;
+                                       etarget = it;
+                               }
+                       }
+               }
+       });
 
-    if (etarget)
-    {
-        te_csqc_lightningarc(from.origin, etarget.origin);
-        Damage(etarget, actor, actor, damage, DEATH_TURRET_TESLA.m_id, etarget.origin, '0 0 0');
-        etarget.railgunhit = true;
-        IL_PUSH(g_railgunhit, etarget);
-    }
+       if (etarget) {
+               te_csqc_lightningarc(from.origin, etarget.origin);
+               Damage(etarget, actor, actor, damage, DEATH_TURRET_TESLA.m_id, etarget.origin, '0 0 0');
+               etarget.railgunhit = true;
+               IL_PUSH(g_railgunhit, etarget);
+       }
 
-    return etarget;
+       return etarget;
 }
 
 #endif