]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/tracing.qc
Merge branch 'terencehill/eventchase_tweaks'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / tracing.qc
index 5d35166aa6167d27e4af3bf0e519b52221f4a222..506bb43c408b847393bd13216a0e79c066130db6 100644 (file)
@@ -26,7 +26,6 @@
 void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range, int deathtype)
 {
        TC(Sound, snd);
-       float nudge = 1; // added to traceline target and subtracted from result  TOOD(divVerent): do we still need this? Doesn't the engine do this now for us?
        float oldsolid = ent.dphitcontentsmask;
        Weapon wep = DEATH_WEAPONOF(deathtype);
        if(!IS_CLIENT(ent))
@@ -57,7 +56,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect
 
        // track max damage
        if (IS_PLAYER(ent) && accuracy_canbegooddamage(ent))
-               accuracy_add(ent, wep.m_id, maxdamage, 0);
+               accuracy_add(ent, wep, maxdamage, 0);
 
        if(IS_PLAYER(ent))
                W_HitPlotAnalysis(ent, wep, v_forward, v_right, v_up);
@@ -65,20 +64,20 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect
        vector md = ent.(weaponentity).movedir;
        vector vecs = ((md.x > 0) ? md : '0 0 0');
 
-       vector dv = v_right * -vecs.y + v_up * vecs.z;
-       w_shotorg = ent.origin + ent.view_ofs + dv;
+       vector dv = v_forward * vecs.x + v_right * -vecs.y + v_up * vecs.z;
+       w_shotorg = ent.origin + ent.view_ofs;
 
        // now move the shotorg forward as much as requested if possible
        if(antilag)
        {
                if(CS(ent).antilag_debug)
-                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + v_forward * (vecs.x + nudge), MOVE_NORMAL, ent, CS(ent).antilag_debug);
+                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + dv, MOVE_NORMAL, ent, CS(ent).antilag_debug);
                else
-                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + v_forward * (vecs.x + nudge), MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
+                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + dv, MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
        }
        else
-               tracebox(w_shotorg, mi, ma, w_shotorg + v_forward * (vecs.x + nudge), MOVE_NORMAL, ent);
-       w_shotorg = trace_endpos - v_forward * nudge;
+               tracebox(w_shotorg, mi, ma, w_shotorg + dv, MOVE_NORMAL, ent);
+       w_shotorg = trace_endpos;
        // calculate the shotdir from the chosen shotorg
        if(W_DualWielding(ent))
                w_shotdir = s_forward;
@@ -138,12 +137,12 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect
                ent.punchangle_x = recoil * -1;
 
        if (snd != SND_Null) {
-               sound (ent, chan, snd, (W_DualWielding(ent) ? VOL_BASE * 0.7 : VOL_BASE), ATTN_NORM);
+               sound(ent, chan, snd, (W_DualWielding(ent) ? VOL_BASE * 0.7 : VOL_BASE), ATTN_NORM);
                W_PlayStrengthSound(ent);
        }
 
        // nudge w_shotend so a trace to w_shotend hits
-       w_shotend = w_shotend + normalize(w_shotend - w_shotorg) * nudge;
+       w_shotend = w_shotend + normalize(w_shotend - w_shotorg);
        //if(w_shotend != prevend) { printf("SERVER: shotEND differs: %s - %s\n", vtos(w_shotend), vtos(prevend)); }
        //if(w_shotorg != prevorg) { printf("SERVER: shotORG differs: %s - %s\n", vtos(w_shotorg), vtos(prevorg)); }
        //if(w_shotdir != prevdir) { printf("SERVER: shotDIR differs: %s - %s\n", vtos(w_shotdir), vtos(prevdir)); }
@@ -266,7 +265,7 @@ void FireRailgunBullet (entity this, .entity weaponentity, vector start, vector
        //explosion = spawn();
 
        // Find all non-hit players the beam passed close by
-       if(deathtype == WEP_VAPORIZER.m_id || deathtype == WEP_VORTEX.m_id)
+       if(deathtype == WEP_VAPORIZER.m_id || deathtype == WEP_VORTEX.m_id) // WEAPONTODO
        {
                FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != this, {
                        if(!it.railgunhit)
@@ -321,7 +320,8 @@ void FireRailgunBullet (entity this, .entity weaponentity, vector start, vector
        IL_CLEAR(g_railgunhit);
 
        // calculate hits and fired shots for hitscan
-       accuracy_add(this, this.(weaponentity).m_weapon.m_id, 0, min(bdamage, totaldmg));
+       if(this.(weaponentity))
+               accuracy_add(this, this.(weaponentity).m_weapon, 0, min(bdamage, totaldmg));
 
        trace_endpos = endpoint;
        trace_ent = endent;
@@ -336,7 +336,7 @@ void fireBullet_trace_callback(vector start, vector hit, vector end)
        fireBullet_last_hit = NULL;
 }
 
-void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effects)
+void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect)
 {
        vector  end;
 
@@ -344,7 +344,7 @@ void fireBullet(entity this, .entity weaponentity, vector start, vector dir, flo
        end = start + dir * max_shot_distance;
 
        fireBullet_last_hit = NULL;
-       fireBullet_trace_callback_eff = tracer_effects;
+       fireBullet_trace_callback_eff = tracer_effect;
 
        float solid_penetration_left = 1;
        float total_damage = 0;
@@ -421,7 +421,7 @@ void fireBullet(entity this, .entity weaponentity, vector start, vector dir, flo
                                // do not exceed 100%
                                float added_damage = min(damage - total_damage, damage * solid_penetration_left);
                                total_damage += damage * solid_penetration_left;
-                               accuracy_add(this, this.(weaponentity).m_weapon.m_id, 0, added_damage);
+                               accuracy_add(this, this.(weaponentity).m_weapon, 0, added_damage);
                        }
                }