From c99856eaa4e6d46384a2eab5ab90be1dcc66c906 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Mon, 22 Nov 2010 17:12:08 +0100 Subject: [PATCH] more fixes of accuracy new system --- qcsrc/server/accuracy.qc | 25 ++++++++++++++++++++++--- qcsrc/server/accuracy.qh | 4 ++++ qcsrc/server/cl_client.qc | 4 ++-- qcsrc/server/cl_weaponsystem.qc | 3 +-- qcsrc/server/g_damage.qc | 24 +++++++----------------- qcsrc/server/w_common.qc | 12 +++--------- qcsrc/server/w_electro.qc | 3 ++- qcsrc/server/w_fireball.qc | 6 ++++-- qcsrc/server/w_laser.qc | 3 ++- qcsrc/server/w_shotgun.qc | 3 ++- 10 files changed, 49 insertions(+), 38 deletions(-) diff --git a/qcsrc/server/accuracy.qc b/qcsrc/server/accuracy.qc index db5dc6cc5..d48f71497 100644 --- a/qcsrc/server/accuracy.qc +++ b/qcsrc/server/accuracy.qc @@ -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; +} diff --git a/qcsrc/server/accuracy.qh b/qcsrc/server/accuracy.qh index 07257da48..afdc46a5a 100644 --- a/qcsrc/server/accuracy.qh +++ b/qcsrc/server/accuracy.qh @@ -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); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 7c1d6bd97..2985b45b4 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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); diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 14618cadf..2770d4314 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -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); diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 673bf5688..387514be4 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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) { diff --git a/qcsrc/server/w_common.qc b/qcsrc/server/w_common.qc index 378cab4de..25ca2f5c6 100644 --- a/qcsrc/server/w_common.qc +++ b/qcsrc/server/w_common.qc @@ -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; diff --git a/qcsrc/server/w_electro.qc b/qcsrc/server/w_electro.qc index 1600a1c9a..f64e4ca8d 100644 --- a/qcsrc/server/w_electro.qc +++ b/qcsrc/server/w_electro.qc @@ -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); diff --git a/qcsrc/server/w_fireball.qc b/qcsrc/server/w_fireball.qc index e78bb2bbc..3905ac95f 100644 --- a/qcsrc/server/w_fireball.qc +++ b/qcsrc/server/w_fireball.qc @@ -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); } } diff --git a/qcsrc/server/w_laser.qc b/qcsrc/server/w_laser.qc index db11eb395..79d782c95 100644 --- a/qcsrc/server/w_laser.qc +++ b/qcsrc/server/w_laser.qc @@ -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 diff --git a/qcsrc/server/w_shotgun.qc b/qcsrc/server/w_shotgun.qc index c5f1ed12c..3efb0e973 100644 --- a/qcsrc/server/w_shotgun.qc +++ b/qcsrc/server/w_shotgun.qc @@ -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 -- 2.39.2