From ca7828d63ca7878f31e92f1829bbeb48f20163ce Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 16 Jul 2017 08:15:40 +1000 Subject: [PATCH] Port killcount to ClientState --- qcsrc/common/mutators/mutator/nades/nades.qc | 8 ++--- qcsrc/server/client.qc | 8 ++--- qcsrc/server/client.qh | 1 + qcsrc/server/command/vote.qc | 4 +-- qcsrc/server/g_damage.qc | 30 +++++++++---------- qcsrc/server/mutators/mutator/gamemode_ca.qc | 2 +- qcsrc/server/mutators/mutator/gamemode_cts.qc | 2 +- .../mutators/mutator/gamemode_freezetag.qc | 2 +- qcsrc/server/mutators/mutator/gamemode_lms.qc | 2 +- .../server/mutators/mutator/gamemode_race.qc | 2 +- 10 files changed, 31 insertions(+), 30 deletions(-) diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 052a132b9..9447ba395 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -1373,19 +1373,19 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST) if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade) toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05)); - float killcount_bonus = ((frag_attacker.killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * frag_attacker.killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor); - if(IS_PLAYER(frag_attacker)) { + float killcount_bonus = ((CS(frag_attacker).killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * CS(frag_attacker).killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor); + if (SAME_TEAM(frag_attacker, frag_target) || frag_attacker == frag_target) nades_RemoveBonus(frag_attacker); else if(frag_target.flagcarried) nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_medium); - else if(autocvar_g_nades_bonus_score_spree && frag_attacker.killcount > 1) + else if(autocvar_g_nades_bonus_score_spree && CS(frag_attacker).killcount > 1) { #define SPREE_ITEM(counta,countb,center,normal,gentle) \ case counta: { nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_spree); break; } - switch(frag_attacker.killcount) + switch(CS(frag_attacker).killcount) { KILL_SPREE_LIST default: nades_GiveBonus(frag_attacker, autocvar_g_nades_bonus_score_minor); break; diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 9f138abd1..58d15b31c 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -274,7 +274,7 @@ void PutObserverInServer(entity this) PlayerScore_Clear(this); // clear scores when needed } - if (this.killcount != FRAGS_SPECTATOR) + if (CS(this).killcount != FRAGS_SPECTATOR) { Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, this.netname); if(!game_stopped) @@ -345,7 +345,7 @@ void PutObserverInServer(entity this) this.weaponentities[slot] = NULL; } this.exteriorweaponentity = NULL; - this.killcount = FRAGS_SPECTATOR; + CS(this).killcount = FRAGS_SPECTATOR; this.velocity = '0 0 0'; this.avelocity = '0 0 0'; this.punchangle = '0 0 0'; @@ -641,9 +641,9 @@ void PutPlayerInServer(entity this) PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false; - if (this.killcount == FRAGS_SPECTATOR) { + if (CS(this).killcount == FRAGS_SPECTATOR) { PlayerScore_Clear(this); - this.killcount = 0; + CS(this).killcount = 0; } for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index b8131d86b..532bf899b 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -88,6 +88,7 @@ CLASS(Client, Object) ATTRIB(Client, allowed_timeouts, int, this.allowed_timeouts); ATTRIB(Client, active_minigame, entity, this.active_minigame); ATTRIB(Client, taunt_soundtime, float, this.taunt_soundtime); + ATTRIB(Client, killcount, int, this.killcount); METHOD(Client, m_unwind, bool(Client this)); diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index fda3adc40..5f96334dd 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -382,7 +382,7 @@ void reset_map(bool dorespawn) */ // NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players // PlayerScore_Clear(it); - it.killcount = 0; + CS(it).killcount = 0; // stop the player from moving so that he stands still once he gets respawned it.velocity = '0 0 0'; it.avelocity = '0 0 0'; @@ -424,7 +424,7 @@ void ReadyRestart_force() // clear player attributes FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( it.alivetime = 0; - it.killcount = 0; + CS(it).killcount = 0; PS_GR_P_ADDVAL(it, PLAYERSTATS_ALIVETIME, -PS_GR_P_ADDVAL(it, PLAYERSTATS_ALIVETIME, 0)); )); diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 4c294f6ff..eb0376928 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -326,19 +326,19 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) { case DEATH_MIRRORDAMAGE: { - Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", targ.killcount, 0, 0); + Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0); break; } default: { - Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", targ.killcount, 0, 0); + Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0); break; } } } } - else if (!Obituary_WeaponDeath(targ, false, deathtype, targ.netname, deathlocation, "", targ.killcount, 0)) + else if (!Obituary_WeaponDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0)) { backtrace("SUICIDE: what the hell happened here?\n"); return; @@ -358,11 +358,11 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) LogDeath("tk", deathtype, attacker, targ); GiveFrags(attacker, targ, -1, deathtype); - attacker.killcount = 0; + CS(attacker).killcount = 0; Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAG, targ.netname); Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAGGED, attacker.netname); - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(targ.team, INFO_DEATH_TEAMKILL), targ.netname, attacker.netname, deathlocation, targ.killcount); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(targ.team, INFO_DEATH_TEAMKILL), targ.netname, attacker.netname, deathlocation, CS(targ).killcount); // In this case, the death message will ALWAYS be "foo was betrayed by bar" // No need for specific death/weapon messages... @@ -373,7 +373,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) GiveFrags(attacker, targ, 1, deathtype); CS(attacker).taunt_soundtime = time + 1; - attacker.killcount = attacker.killcount + 1; + CS(attacker).killcount = CS(attacker).killcount + 1; attacker.killsound += 1; @@ -384,7 +384,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) PS_GR_P_ADDVAL(attacker, PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_##counta, 1); \ break; \ } - switch(attacker.killcount) + switch(CS(attacker).killcount) { KILL_SPREE_LIST default: break; @@ -404,7 +404,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) } else { - kill_count_to_attacker = attacker.killcount; + kill_count_to_attacker = CS(attacker).killcount; kill_count_to_target = 0; } @@ -459,8 +459,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) if(deathtype == DEATH_BUFF.m_id) f3 = buff_FirstFromFlags(attacker.buffs).m_id; - if (!Obituary_WeaponDeath(targ, true, deathtype, targ.netname, attacker.netname, deathlocation, targ.killcount, kill_count_to_attacker)) - Obituary_SpecialDeath(targ, true, deathtype, targ.netname, attacker.netname, deathlocation, targ.killcount, kill_count_to_attacker, f3); + if (!Obituary_WeaponDeath(targ, true, deathtype, targ.netname, attacker.netname, deathlocation, CS(targ).killcount, kill_count_to_attacker)) + Obituary_SpecialDeath(targ, true, deathtype, targ.netname, attacker.netname, deathlocation, CS(targ).killcount, kill_count_to_attacker, f3); } } @@ -480,7 +480,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) targ.netname, inflictor.message, deathlocation, - targ.killcount, + CS(targ).killcount, 0, 0); break; @@ -492,7 +492,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) targ.netname, ((strstrofs(deathmessage, "%", 0) < 0) ? strcat("%s ", deathmessage) : deathmessage), deathlocation, - targ.killcount, + CS(targ).killcount, 0, 0); break; @@ -500,7 +500,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) default: { - Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", targ.killcount, 0, 0); + Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0); break; } } @@ -516,7 +516,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) } // reset target kill count - if(targ.killcount) { targ.killcount = 0; } + CS(targ).killcount = 0; } void Ice_Think(entity this) @@ -622,7 +622,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d float mirrordamage = 0; float mirrorforce = 0; - if (game_stopped || targ.killcount == FRAGS_SPECTATOR) + if (game_stopped || (IS_CLIENT(targ) && CS(targ).killcount == FRAGS_SPECTATOR)) return; entity attacker_save = attacker; diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 6fe4e74e3..e46b22de2 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -199,7 +199,7 @@ MUTATOR_HOOKFUNCTION(ca, PutClientInServer) MUTATOR_HOOKFUNCTION(ca, reset_map_players) { FOREACH_CLIENT(true, { - it.killcount = 0; + CS(it).killcount = 0; if (!it.caplayer && IS_BOT_CLIENT(it)) { it.team = -1; diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index b08436354..8e7512eb6 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -238,7 +238,7 @@ MUTATOR_HOOKFUNCTION(cts, PutClientInServer) if(IS_PLAYER(player)) if(!game_stopped) { - if(player.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn + if(CS(player).killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn race_PreparePlayer(player); else // respawn race_RetractPlayer(player); diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index 64539f46b..811614c21 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -417,7 +417,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerSpawn) MUTATOR_HOOKFUNCTION(ft, reset_map_players) { FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( - it.killcount = 0; + CS(it).killcount = 0; it.freezetag_frozen_timeout = -1; PutClientInServer(it); it.freezetag_frozen_timeout = 0; diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qc b/qcsrc/server/mutators/mutator/gamemode_lms.qc index c3c24559e..fbe6b0c1d 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qc +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qc @@ -212,7 +212,7 @@ void lms_RemovePlayer(entity player) lms_lowest_lives = 0; // end the game now! } - if(player.killcount != FRAGS_SPECTATOR) + if(CS(player).killcount != FRAGS_SPECTATOR) if(PlayerScore_Add(player, SP_LMS_RANK, 0) > 0 && player.lms_spectate_warning != 2) Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_NOLIVES, player.netname); else diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index 1fa07d7cc..357ed226f 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -283,7 +283,7 @@ MUTATOR_HOOKFUNCTION(rc, PutClientInServer) if(IS_PLAYER(player)) if(!game_stopped) { - if(player.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn + if(CS(player).killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn race_PreparePlayer(player); else // respawn race_RetractPlayer(player); -- 2.39.2