From: LegendaryGuard Date: Mon, 26 Apr 2021 02:53:19 +0000 (+0200) Subject: Fix karma scoreboard visualization, programmer's wtf moment in the code is here! X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f25995a309ec19d0b5a53c555aea3b1e4814ed3e;p=xonotic%2Fxonotic-data.pk3dir.git Fix karma scoreboard visualization, programmer's wtf moment in the code is here! --- diff --git a/qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qc b/qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qc index e232c7fcd..c970f6335 100644 --- a/qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qc +++ b/qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qc @@ -1,7 +1,7 @@ #include "sv_mmm.qh" //set g_mmm_sleuth_count 0.125 "number of players who will become sleuths, set between 0 and 0.9 to use a multiplier of the current players, or 1 and above to specify an exact number of players" -//float autocvar_g_mmm_sleuth_count = 0.125; //I don't think that it won't be used... +//float autocvar_g_mmm_sleuth_count = 0.125; //I don't think that it'll be used... float autocvar_g_mmm_civilian_count = 0.625; //float autocvar_g_mmm_murderer_count = 0.25; float autocvar_g_mmm_round_timelimit = 180; @@ -11,13 +11,20 @@ bool autocvar_g_mmm_reward_civilian = true; bool autocvar_g_mmm_reward_sleuth = true; //sleuth reward if investigated corpses float autocvar_g_mmm_max_karma_points = 1000; //LegendGuard sets Karma points 21-02-2021 float autocvar_g_mmm_min_karma_points = 400; -int autocvar_g_mmm_karma_bankick_tool = 0; //LegendGuard sets a ban tool for server admins 11-03-2021 +int autocvar_g_mmm_karma_bankick_tool = 1; //LegendGuard sets a ban tool for server admins 11-03-2021 float autocvar_g_mmm_karma_bantime = 1800; //karma ban seconds bool autocvar_g_mmm_karma_damageactive = true; //LegendGuard sets Karma damage setting if active 20-03-2021 float autocvar_g_mmm_karma_severity = 0.25; float autocvar_g_mmm_karma_damagepunishmentdeal = 20; //LegendGuard sets Karma punishment damage setting if player kills an ally 28-03-2021 // Sleuth is a created team, this team is added inside Civilians team +/*scoreboard.qc method +void KarmaScore_GetField(entity pl, PlayerScoreField field) +{ + if (field == SP_MMM_KARMA) + float karmap = pl.(scores(SP_MMM_KARMA)); +}*/ + void mmm_FakeTimeLimit(entity e, float t) { if(!IS_REAL_CLIENT(e)) @@ -52,13 +59,14 @@ void karma_Control(entity it) { switch (autocvar_g_mmm_karma_bankick_tool) { + //do nothing + case 0: return; //force to spec - case 0: PutObserverInServer(it); return; + case 1: PutObserverInServer(it); return; //kick - case 1: dropclient(it); return; + case 2: dropclient(it); return; //ban and kick - case 2: Ban_KickBanClient(it, bantime, masksize, "Too low karma"); return; - //force to spec + case 3: Ban_KickBanClient(it, bantime, masksize, "Too low karma"); return; default: PutObserverInServer(it); return; } } @@ -384,15 +392,8 @@ bool mmm_CheckPlayers() int playercount = 0; FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), - { + { //PrintToChatAll(sprintf("it.karmapoints ^5begin: ^3%f",it.karmapoints)); - //Karma points start - if (it.karmastarted != true) - { - GameRules_scoring_add(it, MMM_KARMA, autocvar_g_mmm_max_karma_points - it.karmapoints); - it.karmapoints = autocvar_g_mmm_max_karma_points; - it.karmastarted = true; - } karma_Control(it); ++playercount; //PrintToChatAll(sprintf("it.karmapoints ^6end: ^3%f",it.karmapoints)); @@ -683,6 +684,12 @@ MUTATOR_HOOKFUNCTION(mmm, PlayerPreThink) if(IS_PLAYER(player) || player.caplayer) { + if (player.karmaspectated != true) + { + if (CS(player).scorekeeper.(scores(SP_MMM_KARMA)) <= 0) //wtf? Visualization works 100% correct? + GameRules_scoring_add(player, MMM_KARMA, player.karmapoints); + player.karmaspectated = true; + } // update the scoreboard colour display to out the real killer at the end of the round // running this every frame to avoid cheats int plcolor = MMM_COLOR_CIVILIAN; @@ -695,6 +702,8 @@ MUTATOR_HOOKFUNCTION(mmm, PlayerPreThink) plcolor = MMM_COLOR_SLEUTH; setcolor(player, plcolor); } + if(warmup_stage) + player.karmastarted = false; //CORPSE FEATURE 10-03-2021 if (IS_DEAD(player)) @@ -709,6 +718,14 @@ MUTATOR_HOOKFUNCTION(mmm, PlayerPreThink) MUTATOR_HOOKFUNCTION(mmm, PlayerSpawn) { entity player = M_ARGV(0, entity); + + //Karma points start + if (player.karmastarted != true) + { + player.karmapoints = autocvar_g_mmm_max_karma_points; + GameRules_scoring_add(player, MMM_KARMA, player.karmapoints); + player.karmastarted = true; + } player.mmm_status = 0; player.mmm_validkills = 0; @@ -861,6 +878,8 @@ MUTATOR_HOOKFUNCTION(mmm, MakePlayerObserver) if (IS_PLAYER(player) && !IS_DEAD(player)) mmm_LastPlayerForTeam_Notify(player); + if (player.karmaspectated == true) + player.karmaspectated = false; if (player.killindicator_teamchange == -2) // player wants to spectate player.caplayer = 0; if (player.caplayer) diff --git a/qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qh b/qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qh index e5eca2115..bca2a14a7 100644 --- a/qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qh +++ b/qcsrc/common/gamemodes/gamemode/mmm/sv_mmm.qh @@ -21,4 +21,5 @@ REGISTER_MUTATOR(mmm, false) .string killedwithweapon; //LegendGuard sets a variable to know what cause provoked to the victim 23-03-2021 .bool investigated; //LegendGuard sets a bool to make sure if detective investigated already a corpse once 24-03-2021 .bool karmastarted; //LegendGuard fixes with a bool when round start for karma points +.bool karmaspectated; //LegendGuard fixes with a bool to someone if spectates and joins in the round 25-04-2021 .bool activekillerrole; //LegendGuard sets a variable to active killer role 25-03-2021 \ No newline at end of file