]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/shockwave.qc
Give W_SetupShot a deathtype parameter, fixes some ugly hacks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / shockwave.qc
index bc9e94767a45177e35b3dd788f283f3beeeb7c00..7c775be2fdc39431ba18bdbb3188b4d513bc2c86 100644 (file)
@@ -3,16 +3,14 @@
 REGISTER_NET_TEMP(TE_CSQC_SHOCKWAVEPARTICLE)
 
 #ifdef SVQC
-spawnfunc(weapon_shockwave)
+METHOD(Shockwave, m_spawnfunc_hookreplace, Weapon(Shockwave this, entity e))
 {
        //if(autocvar_sv_q3acompat_machineshockwaveswap) // WEAPONTODO
-       if(autocvar_sv_q3acompat_machineshotgunswap)
-       if(this.classname != "droppedweapon")
+       if (autocvar_sv_q3acompat_machineshotgunswap && !Item_IsLoot(e))
        {
-               weapon_defaultspawnfunc(this, WEP_MACHINEGUN);
-               return;
+               return WEP_MACHINEGUN;
        }
-       weapon_defaultspawnfunc(this, WEP_SHOCKWAVE);
+       return this;
 }
 
 const float MAX_SHOCKWAVE_HITS = 10;
@@ -101,6 +99,7 @@ void W_Shockwave_Melee_Think(entity this)
                                this.realowner,
                                swing_damage,
                                (WEP_SHOCKWAVE.m_id | HITTYPE_SECONDARY),
+                               this.weaponentity_fld,
                                (this.realowner.origin + this.realowner.view_ofs),
                                (v_forward * WEP_CVAR(shockwave, melee_force))
                        );
@@ -157,7 +156,8 @@ void W_Shockwave_Melee(Weapon thiswep, entity actor, .entity weaponentity, int f
        meleetemp.owner = meleetemp.realowner = actor;
        setthink(meleetemp, W_Shockwave_Melee_Think);
        meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor(actor);
-       W_SetupShot_Range(actor, weaponentity, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range));
+       meleetemp.weaponentity_fld = weaponentity;
+       W_SetupShot_Range(actor, weaponentity, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range), WEP_SHOCKWAVE.m_id | HITTYPE_SECONDARY);
 }
 
 // SHOCKWAVE ATTACK MODE
@@ -280,7 +280,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity)
        float i, queue = 0;
 
        // set up the shot direction
-       W_SetupShot(actor, weaponentity, true, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage));
+       W_SetupShot(actor, weaponentity, true, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, WEP_CVAR(shockwave, blast_damage), WEP_SHOCKWAVE.m_id);
        vector attack_endpos = (w_shotorg + (w_shotdir * WEP_CVAR(shockwave, blast_distance)));
        WarpZone_TraceLine(w_shotorg, attack_endpos, MOVE_NOMONSTERS, actor);
        vector attack_hitpos = trace_endpos;
@@ -318,13 +318,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity)
        if(autocvar_g_antilag == 0 || noantilag)
                lag = 0; // only do hitscan, but no antilag
        if(lag)
-       {
-               FOREACH_CLIENT(IS_PLAYER(it) && it != actor, antilag_takeback(it, CS(it), time - lag));
-               IL_EACH(g_monsters, it != actor,
-               {
-                       antilag_takeback(it, it, time - lag);
-               });
-       }
+               antilag_takeback_all(actor, lag);
 
        while(head)
        {
@@ -392,6 +386,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity)
                                        actor,
                                        final_damage,
                                        WEP_SHOCKWAVE.m_id,
+                                       weaponentity,
                                        head.origin,
                                        final_force
                                );
@@ -576,6 +571,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity)
                        actor,
                        final_damage,
                        WEP_SHOCKWAVE.m_id,
+                       weaponentity,
                        head.origin,
                        final_force
                );
@@ -598,13 +594,7 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity)
        }
 
        if(lag)
-       {
-               FOREACH_CLIENT(IS_PLAYER(it) && it != actor, antilag_restore(it, CS(it)));
-               IL_EACH(g_monsters, it != actor,
-               {
-                       antilag_restore(it, it);
-               });
-       }
+               antilag_restore_all(actor);
 }
 
 METHOD(Shockwave, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))