more fixes of accuracy new system
authorRudolf Polzer <divVerent@xonotic.org>
Mon, 22 Nov 2010 16:12:08 +0000 (17:12 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Mon, 22 Nov 2010 16:12:08 +0000 (17:12 +0100)
qcsrc/server/accuracy.qc
qcsrc/server/accuracy.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/g_damage.qc
qcsrc/server/w_common.qc
qcsrc/server/w_electro.qc
qcsrc/server/w_fireball.qc
qcsrc/server/w_laser.qc
qcsrc/server/w_shotgun.qc

index db5dc6cc5130ac7c17dca8a7993a83a0a3775293..d48f714973ff0700b79926f659814ba19b847fb7 100644 (file)
@@ -79,11 +79,13 @@ void accuracy_add(entity e, float w, float hit, float fired)
 {
        entity a;
        a = e.accuracy;
-       if(!a)
+       if(!a || !(hit || fired))
                return;
        w -= WEP_FIRST;
-       a.(accuracy_hit[w]) += hit;
-       a.(accuracy_fired[w]) += fired;
+       if(hit)
+               a.(accuracy_hit[w]) += hit;
+       if(fired)
+               a.(accuracy_fired[w]) += fired;
        w = pow(2, w);
        a.SendFlags |= w;
        FOR_EACH_CLIENT(a)
@@ -91,3 +93,20 @@ void accuracy_add(entity e, float w, float hit, float fired)
                        if(a.enemy == e)
                                a.SendFlags |= w;
 }
+
+float accuracy_isgooddamage(entity attacker, entity targ)
+{
+       if(!inWarmupStage)
+       if(targ.flags & FL_CLIENT)
+       if(targ.deadflag == DEAD_NO)
+       if(IsDifferentTeam(attacker, targ))
+               return TRUE;
+       return FALSE;
+}
+
+float accuracy_canbegooddamage(entity attacker)
+{
+       if(!inWarmupStage)
+               return TRUE;
+       return FALSE;
+}
index 07257da48fa32e429ace7d6660ba8dbc3ea1466e..afdc46a5acc8a56f2a81746a1618c37f7c45c556 100644 (file)
@@ -11,3 +11,7 @@ void accuracy_resend(entity e);
 // update accuracy stats
 void accuracy_set(entity e, float w, float hit, float fired);
 void accuracy_add(entity e, float w, float hit, float fired);
+
+// helper
+float accuracy_isgooddamage(entity attacker, entity targ);
+float accuracy_canbegooddamage(entity attacker);
index 7c1d6bd97f168a9d2a9820b3332de417d569bcb4..2985b45b41262b4f9ac4ed51749d34323203a639 100644 (file)
@@ -1500,7 +1500,7 @@ void ClientConnect (void)
 
        PlayerScore_Attach(self);
        ClientData_Attach();
-       accuracy_init();
+       accuracy_init(self);
 
        bot_clientconnect();
 
@@ -1779,7 +1779,7 @@ void ClientDisconnect (void)
                Spawnqueue_Remove(self);
        }
 
-       accuracy_free();
+       accuracy_free(self);
        ClientData_Detach();
        PlayerScore_Detach(self);
 
index 14618cadf8e96e65c013b709d9066c923d73b938..2770d43147a09eb400fc21cc3155f4b2f9bc6863 100644 (file)
@@ -159,9 +159,8 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
        v_up = vu;
 
        // track max damage
-       if not(inWarmupStage) {
+       if(accuracy_canbegooddamage(ent))
                accuracy_add(ent, ent.weapon, maxdamage, 0);
-       }
 
        W_HitPlotAnalysis(ent, v_forward, v_right, v_up);
 
index 673bf5688a57720dcb44a5fb4db2505225b51158..387514be45194dabb3d9337de29da5a30f45f295 100644 (file)
@@ -844,16 +844,6 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
        }
 }
 
-void Damage_RecordDamage(entity attacker, float deathtype, float damage)
-{
-       float weaponid;
-       weaponid = DEATH_WEAPONOF(deathtype);
-
-       if not(inWarmupStage)
-       if (weaponid)
-               accuracy_add(attacker, weaponid, 0, damage);
-}
-
 float RadiusDamage_running;
 float RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype, entity directhitentity)
 // Returns total damage applies to creatures
@@ -1026,10 +1016,7 @@ float RadiusDamage (entity inflictor, entity attacker, float coredamage, float e
                                                        {
                                                                total_damage_to_creatures += finaldmg;
 
-                                                               if(targ.flags & FL_CLIENT)
-                                                               if(targ.deadflag == DEAD_NO)
-                                                               if(targ != attacker)
-                                                               if(!teamplay || targ.team != attacker.team)
+                                                               if(accuracy_isgooddamage(attacker, targ))
                                                                        stat_damagedone += finaldmg;
                                                        }
 
@@ -1046,7 +1033,8 @@ float RadiusDamage (entity inflictor, entity attacker, float coredamage, float e
 
        RadiusDamage_running = 0;
 
-       Damage_RecordDamage(attacker, deathtype, min(coredamage, stat_damagedone));
+       if(!DEATH_ISSPECIAL(deathtype))
+               accuracy_add(attacker, DEATH_WEAPONOFWEAPONDEATH(deathtype), 0, min(coredamage, stat_damagedone));
 
        return total_damage_to_creatures;
 }
@@ -1149,6 +1137,8 @@ float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
                                        e.fire_hitsound = FALSE;
                                }
                        }
+                       if(accuracy_isgooddamage(o, e))
+                               accuracy_add(o, DEATH_WEAPONOFWEAPONDEATH(dt), 0, max(0, totaldamage - mindamage));
                        return max(0, totaldamage - mindamage); // can never be negative, but to make sure
                }
                else
@@ -1161,6 +1151,8 @@ float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
                e.fire_deathtype = dt;
                e.fire_owner = o;
                e.fire_hitsound = FALSE;
+               if(accuracy_isgooddamage(o, e))
+                       accuracy_add(o, DEATH_WEAPONOFWEAPONDEATH(dt), 0, d);
                return d;
        }
 }
@@ -1195,8 +1187,6 @@ void Fire_ApplyDamage(entity e)
        }
        e.fire_hitsound = TRUE;
 
-       Damage_RecordDamage(e.fire_owner, e.fire_deathtype, d);
-
        if not(IS_INDEPENDENT_PLAYER(e))
        FOR_EACH_PLAYER(other) if(e != other)
        {
index 378cab4de50b51ea503de794350f162f46558486..25ca2f5c6225058f2e410bdf8382f35d160c216e 100644 (file)
@@ -125,9 +125,7 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
                f = ExponentialFalloff(mindist, maxdist, halflifedist, ent.railgundistance);
                ffs = ExponentialFalloff(mindist, maxdist, forcehalflifedist, ent.railgundistance);
 
-               if(ent.flags & FL_CLIENT)
-               if(ent.deadflag == DEAD_NO)
-               if(!teamplay || ent.team != self.team)
+               if(accuracy_isgooddamage(self.owner, ent))
                        totaldmg += bdamage * f;
 
                // apply the damage
@@ -148,8 +146,7 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
        }
 
        // calculate hits and fired shots for hitscan
-       if not(inWarmupStage)
-               accuracy_add(self, self.weapon, 0, min(bdamage, totaldmg));
+       accuracy_add(self, self.weapon, 0, min(bdamage, totaldmg));
 
        trace_endpos = endpoint;
        trace_ent = endent;
@@ -195,10 +192,7 @@ void W_BallisticBullet_Hit (void)
                        AnnounceTo(self.owner, "awesome");
 
                // calculate hits for ballistic weapons
-               if (other.flags & FL_CLIENT)  // is the player a client
-               if (other.deadflag == DEAD_NO)  // is the victim a corpse
-               if ((!(teamplay)) | (other.team != self.owner.team))  // not teamplay (ctf, kh, tdm etc) or the victim is in the same team
-               if not(inWarmupStage)  // not in warm up stage
+               if(accuracy_isgooddamage(self.owner, other))
                {
                        // do not exceed 100%
                        q = min(self.dmg * q, self.dmg_total + f * self.dmg) - self.dmg_total;
index 1600a1c9a1fe7f8b860743d9b556a1b07f11bd06..f64e4ca8dcecf8e38134cd28a300c82e74ee0200 100644 (file)
@@ -265,8 +265,9 @@ void lgbeam_think()
 
                f = ExponentialFalloff(cvar("g_balance_electro_primary_falloff_mindist"), cvar("g_balance_electro_primary_falloff_maxdist"), cvar("g_balance_electro_primary_falloff_halflifedist"), vlen(WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos) - w_shotorg));
 
+               if(accuracy_isgooddamage(self.owner, trace_ent))
+                       accuracy_add(self.owner, WEP_ELECTRO, 0, cvar("g_balance_electro_primary_damage") * dt * f);
                Damage (trace_ent, self.owner, self.owner, cvar("g_balance_electro_primary_damage") * dt * f, WEP_ELECTRO, trace_endpos, force * dt);
-               Damage_RecordDamage(self.owner, WEP_ELECTRO, cvar("g_balance_electro_primary_damage") * dt * f);
        }
        W_Plasma_TriggerCombo(trace_endpos, cvar("g_balance_electro_primary_comboradius"), self.owner);
 
index e78bb2bbc3b1c03ace99f72afcf8f9b280b8430c..3905ac95f37ae9e6c7245f83832b912dec4412e2 100644 (file)
@@ -44,10 +44,12 @@ void W_Fireball_Explode (void)
                        if(points <= 0)
                                continue;
                        dir = normalize(e.origin + e.view_ofs - self.origin);
+
+                       if(accuracy_isgooddamage(self.realowner, e))
+                               accuracy_add(self.realowner, WEP_FIREBALL, 0, cvar("g_balance_fireball_primary_bfgdamage") * points);
+
                        Damage(e, self, self.realowner, cvar("g_balance_fireball_primary_bfgdamage") * points, self.projectiledeathtype | HITTYPE_BOUNCE | HITTYPE_SPLASH, e.origin + e.view_ofs, cvar("g_balance_fireball_primary_bfgforce") * dir);
                        pointparticles(particleeffectnum("fireball_bfgdamage"), e.origin, -1 * dir, 1);
-
-                       Damage_RecordDamage(self.owner, self.projectiledeathtype, cvar("g_balance_fireball_primary_bfgdamage") * points);
                }
        }
 
index db11eb395c3a370dce30aa21749e6a4199662702..79d782c95ce51a9af4ff579e276ac96a9b01b27c 100644 (file)
@@ -147,8 +147,9 @@ void gauntletbeam_think()
        {
                vector force;
                force = w_shotdir * myforce;
+               if(accuracy_isgooddamage(self.owner, trace_ent))
+                       accuracy_add(self.owner, WEP_LASER, 0, damage * dt);
                Damage (trace_ent, self.owner, self.owner, damage * dt, WEP_LASER | HITTYPE_SECONDARY, trace_endpos, force * dt);
-               Damage_RecordDamage(self.owner, WEP_LASER | HITTYPE_SECONDARY, damage * dt);
        }
 
        // draw effect
index c5f1ed12c02143b993bb15d92e7c3d27c7c4d5b1..3efb0e97320a278571a5c672c6528bc93c212eb9 100644 (file)
@@ -69,8 +69,9 @@ void shotgun_meleethink (void)
        {
                vector force;
                force = angle * cvar("g_balance_shotgun_secondary_force");
+               if(accuracy_isgooddamage(self.owner, trace_ent))
+                       accuracy_add(self.owner, WEP_SHOTGUN, 0, cvar("g_balance_shotgun_secondary_damage") * min(1, f + 1));
                Damage (trace_ent, self.owner, self.owner, cvar("g_balance_shotgun_secondary_damage") * min(1, f + 1), WEP_SHOTGUN | HITTYPE_SECONDARY , self.owner.origin + self.owner.view_ofs, force);
-               Damage_RecordDamage(self.owner, WEP_SHOTGUN | HITTYPE_SECONDARY, cvar("g_balance_shotgun_secondary_damage") * min(1, f + 1));
                remove(self);
        }
        else if(time >= self.cnt + cvar("g_balance_shotgun_secondary_melee_time")) // missed, remove ent