From: LegendaryGuard Date: Tue, 23 Feb 2021 00:34:14 +0000 (+0100) Subject: Added Karma points for the scoreboard, there are some TODOs to process X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3502dba9647e940aed550d92d8d0c23931d3fb37;p=xonotic%2Fxonotic-data.pk3dir.git Added Karma points for the scoreboard, there are some TODOs to process --- diff --git a/qcsrc/common/gamemodes/gamemode/ttt/sv_ttt.qc b/qcsrc/common/gamemodes/gamemode/ttt/sv_ttt.qc index 22f30ba07..f7db8d627 100644 --- a/qcsrc/common/gamemodes/gamemode/ttt/sv_ttt.qc +++ b/qcsrc/common/gamemodes/gamemode/ttt/sv_ttt.qc @@ -6,12 +6,14 @@ float autocvar_g_ttt_round_timelimit = 180; float autocvar_g_ttt_warmup = 10; bool autocvar_g_ttt_punish_teamkill = false; bool autocvar_g_ttt_reward_innocent = true; -//float autocvar_g_ttt_karma_points = 1000; //TODO: Karma points 21-02-2021 +float autocvar_g_ttt_max_karma_points = 1000; //LegendGuard sets Karma points 21-02-2021 +float autocvar_g_ttt_min_karma_points = 200; +//TODO: when finished new cvars, add them to gamemodes-server.cfg 22-02-2021 //TODO: add Detective and corpse function if a player is DEAD -//TODO: Problems: Detective is a created team, this team is added inside Innocents team -// if there's a detective and a traitor and no innocent in the round, round ends. +//TOFIX: Problems: Detective is a created team, this team is added inside Innocents team +// when there's a detective and a traitor and no innocent in the round, round ends. // detective shouldn't be attacked by innocent bots. // detective should detect the point of the corpses (new function). @@ -41,17 +43,69 @@ void ttt_UpdateScores(bool timed_out) { it.totalfrags += it.ttt_validkills; if(it.ttt_validkills) + { GameRules_scoring_add(it, SCORE, it.ttt_validkills); + } + //LOG_INFOF("^3it.karmapoints^7: ^8%f", it.karmapoints); it.ttt_validkills = 0; // player survived the round if(IS_PLAYER(it) && !IS_DEAD(it)) //TODO: LegendGuard, add something for Karma if possible 21-02-2021 { + //TODO: Detective doesn't need scores, but if investigated a corpse maybe yes 22-02-2021 if(autocvar_g_ttt_reward_innocent && timed_out && it.ttt_status == TTT_STATUS_INNOCENT && it.ttt_status == TTT_STATUS_DETECTIVE) + { GameRules_scoring_add(it, SCORE, 1); // reward innocents who make it to the end of the round time limit + float increasekarma = 25; //25 points lol //autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) ); + PrintToChatAll(sprintf("^2REWARD ^7increasekarma: ^2%f", increasekarma)); + GameRules_scoring_add(it, TTT_KARMA, increasekarma); + it.karmapoints = it.karmapoints + increasekarma; + PrintToChatAll(sprintf("^2REWARD ^7it.karmapoints: ^1%f", it.karmapoints)); + if(it.karmapoints >= autocvar_g_ttt_max_karma_points) + { + //RESETS KARMAPOINTS TO MAINTAIN THE MAXIMUM + PrintToChatAll("^3REWARD ^1MAXIMUM RESET"); + GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints); + it.karmapoints = autocvar_g_ttt_max_karma_points; + } + else if(it.karmapoints <= autocvar_g_ttt_min_karma_points) + PrintToChatAll("kick kick kick GET OUT!!"); + } if(it.ttt_status == TTT_STATUS_INNOCENT) + { GameRules_scoring_add(it, TTT_RESISTS, 1); + float increasekarma = 50; //autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) ); + PrintToChatAll(sprintf("^2INNOCENT ^7increasekarma: ^2%f", increasekarma)); + GameRules_scoring_add(it, TTT_KARMA, increasekarma); + it.karmapoints = it.karmapoints + increasekarma; + PrintToChatAll(sprintf("^2INNOCENT ^7it.karmapoints: ^1%f", it.karmapoints)); + if(it.karmapoints >= autocvar_g_ttt_max_karma_points) + { + //RESETS KARMAPOINTS TO MAINTAIN THE MAXIMUM + //PrintToChatAll("^3INNOCENT ^1MAXIMUM RESET"); + GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints); + it.karmapoints = autocvar_g_ttt_max_karma_points; + } + else if(it.karmapoints <= autocvar_g_ttt_min_karma_points) + PrintToChatAll("kick kick kick GET OUT!!"); + } else if(it.ttt_status == TTT_STATUS_TRAITOR) + { GameRules_scoring_add(it, TTT_HUNTS, 1); + float increasekarma = 50; //autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) ); + PrintToChatAll(sprintf("^1TRAITOR ^7increasekarma: ^2%f", increasekarma)); + GameRules_scoring_add(it, TTT_KARMA, increasekarma); + it.karmapoints = it.karmapoints + increasekarma; + PrintToChatAll(sprintf("^1TRAITOR ^7it.karmapoints: ^1%f", it.karmapoints)); + if(it.karmapoints >= autocvar_g_ttt_max_karma_points) + { + //RESETS KARMAPOINTS TO MAINTAIN THE MAXIMUM + PrintToChatAll("^3TRAITOR ^1MAXIMUM RESET"); + GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints); + it.karmapoints = autocvar_g_ttt_max_karma_points; + } + else if(it.karmapoints <= autocvar_g_ttt_min_karma_points) + PrintToChatAll("kick kick kick GET OUT!!"); + } } }); } @@ -168,6 +222,25 @@ void ttt_RoundStart() FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), { + PrintToChatAll(sprintf("it.karmapoints ^5begin: ^3%f",it.karmapoints)); + if(it.karmapoints <= 0) + { + //RESETS KARMAPOINTS WHEN MATCH STARTS + PrintToChatAll("^2ZERO RESET"); + GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints); + it.karmapoints = autocvar_g_ttt_max_karma_points; + } + else if(it.karmapoints >= autocvar_g_ttt_max_karma_points) + { + //RESETS KARMAPOINTS TO MAINTAIN THE MAXIMUM + PrintToChatAll("^1MAXIMUM RESET"); + GameRules_scoring_add(it, TTT_KARMA, autocvar_g_ttt_max_karma_points - it.karmapoints); + it.karmapoints = autocvar_g_ttt_max_karma_points; + } + else if(it.karmapoints <= autocvar_g_ttt_min_karma_points) + PrintToChatAll("kick kick kick GET OUT!!"); + PrintToChatAll(sprintf("it.karmapoints ^6end: ^3%f",it.karmapoints)); + if(it.ttt_status == TTT_STATUS_INNOCENT) { Send_Notification(NOTIF_ONE_ONLY, it, MSG_CENTER, CENTER_TTT_INNOCENT); @@ -182,7 +255,7 @@ void ttt_RoundStart() { Send_Notification(NOTIF_ONE_ONLY, it, MSG_CENTER, CENTER_TTT_DETECTIVE); //Detective notification should be sent to all players to see who is PrintToChatAll(sprintf("%s is ^4Detective^7!", it.netname)); - // Should notify in the center for everyone about who is Detective? + // LegendGuard asks a POLL: Should notify in the center for everyone about who is Detective? //Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_TTT_DETECTIVE, 1); } @@ -236,7 +309,7 @@ void ttt_Initialize() // run at the start of a match, initiates game mode GameRules_scoring(0, SFL_SORT_PRIO_PRIMARY, 0, { field(SP_TTT_RESISTS, "resists", 0); field(SP_TTT_HUNTS, "hunts", SFL_SORT_PRIO_SECONDARY); - //field(SP_TTT_KARMA, "karma", autocvar_g_ttt_karma_points); //Karma points in the scoreboard + field(SP_TTT_KARMA, "karma", SFL_SORT_PRIO_SECONDARY); //LegendGuard adds Karma points in the scoreboard 22-02-2021 }); allowed_to_spawn = true; @@ -252,10 +325,13 @@ void ttt_Initialize() // run at the start of a match, initiates game mode MUTATOR_HOOKFUNCTION(ttt, ClientObituary) { + // LegendGuard has an IDEA: To adjust the grade of severity of karma, + // we could add if sentence per weapons and adjust each weapon attack + // its own grade. Instead doing random decrease grade 22-02-2021 + // in ttt, announcing a frag would tell everyone who the traitor is entity frag_attacker = M_ARGV(1, entity); entity frag_target = M_ARGV(2, entity); - //.float karmapoints; //karma points for each player if(IS_PLAYER(frag_attacker) && frag_attacker != frag_target) { float frag_deathtype = M_ARGV(3, float); @@ -264,17 +340,31 @@ MUTATOR_HOOKFUNCTION(ttt, ClientObituary) // unless the player is going to be punished for suicide, in which case just remove one if(frag_attacker.ttt_status == frag_target.ttt_status) { - //PrintToChatAll("^1DEBUG^7: A ^2PLAYER^7 has fragged a ^2PLAYER OF HIS OWN TEAM^7, TOO BAD!"); + PrintToChatAll("^1DEBUG^7: A ^2PLAYER^7 has fragged a ^2PLAYER OF HIS OWN TEAM^7, TOO BAD!"); + float decreasekarma = -( autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) * 0.1 ); + //PrintToChatAll(sprintf("decreasekarma: ^1%f", decreasekarma)); + GameRules_scoring_add(frag_attacker, TTT_KARMA, decreasekarma); + frag_attacker.karmapoints = frag_attacker.karmapoints + decreasekarma; + //PrintToChatAll(sprintf("frag_attacker.karmapoints: ^1%f", frag_attacker.karmapoints)); GiveFrags(frag_attacker, frag_target, ((autocvar_g_ttt_punish_teamkill) ? -1 : -2), frag_deathtype, wep_ent.weaponentity_fld); - //frag_attacker.karmapoints = frag_attacker.karmapoints - (autocvar_g_ttt_karma_points * random(0.9 * 0.1)); //karma points reduce when player attacked to other player //example: 1000 - (1000*(0.9*0.1)) = 910 + if(frag_attacker.karmapoints <= autocvar_g_ttt_min_karma_points) + PrintToChatAll("kick kick kick GET OUT!!"); + //MATH THEORY: example: 1000 * 0.3 * (0.1 + 0.4) * 0.1 // karma points reduce when player attacked to other player } if(frag_attacker.ttt_status == TTT_STATUS_DETECTIVE) { if (frag_target.ttt_status == TTT_STATUS_INNOCENT) { - PrintToChatAll("^7A ^4Detective^7 has fragged an ^2Innocent^7, TOO BAD!"); + PrintToChatAll("^1DEBUG^7: A ^4Detective^7 fragged an ^2Innocent^7, TOO BAD!"); + float decreasekarma = -( autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) * 0.1 ); + //PrintToChatAll(sprintf("decreasekarma: ^1%f", decreasekarma)); + GameRules_scoring_add(frag_attacker, TTT_KARMA, decreasekarma); + frag_attacker.karmapoints = frag_attacker.karmapoints + decreasekarma; + //PrintToChatAll(sprintf("frag_attacker.karmapoints: ^1%f", frag_attacker.karmapoints)); GiveFrags(frag_attacker, frag_target, ((autocvar_g_ttt_punish_teamkill) ? -1 : -2), frag_deathtype, wep_ent.weaponentity_fld); + if(frag_attacker.karmapoints <= autocvar_g_ttt_min_karma_points) + PrintToChatAll("kick kick kick GET OUT!!"); } } @@ -282,8 +372,14 @@ MUTATOR_HOOKFUNCTION(ttt, ClientObituary) { if (frag_target.ttt_status == TTT_STATUS_DETECTIVE) { - PrintToChatAll("^7An ^2Innocent^7 has fragged a ^4Detective^7, TOO BAD!"); + PrintToChatAll("^1DEBUG^7: An ^2Innocent^7 fragged a ^4Detective^7, TOO BAD!"); + float decreasekarma = -( autocvar_g_ttt_max_karma_points * random() * ( 0.1 + random() ) * 0.1 ); + //PrintToChatAll(sprintf("decreasekarma: ^1%f", decreasekarma)); + GameRules_scoring_add(frag_attacker, TTT_KARMA, decreasekarma); + frag_attacker.karmapoints = frag_attacker.karmapoints + decreasekarma; GiveFrags(frag_attacker, frag_target, ((autocvar_g_ttt_punish_teamkill) ? -1 : -2), frag_deathtype, wep_ent.weaponentity_fld); + if(frag_attacker.karmapoints <= autocvar_g_ttt_min_karma_points) + PrintToChatAll("kick kick kick GET OUT!!"); } } //if ttt_status is 1, means innocent, 2 means traitor, 3 means detective, TODO: the bots: frag_attacker(1) shouldn't attack to frag_target(3) @@ -432,18 +528,18 @@ MUTATOR_HOOKFUNCTION(ttt, PlayerDies) { if (frag_target.ttt_status == TTT_STATUS_INNOCENT) { - PrintToChatAll("^7^4DETECTIVE ^1DAMAGE/DEAD^7 HAS TAKEN!"); - //30 damage points deal - Damage(frag_attacker, frag_attacker, frag_attacker, 300, DEATH_MIRRORDAMAGE.m_id, DMG_NOWEP, frag_attacker.origin, '0 0 0'); + //PrintToChatAll("^1DEBUG^7: ^4DETECTIVE ^1DAMAGE/DEAD^7 HAS TAKEN!"); + //50 damage points deal + Damage(frag_attacker, frag_attacker, frag_attacker, 50, DEATH_MIRRORDAMAGE.m_id, DMG_NOWEP, frag_attacker.origin, '0 0 0'); } } if (frag_attacker.ttt_status == TTT_STATUS_INNOCENT) { if (frag_target.ttt_status == TTT_STATUS_DETECTIVE) { - PrintToChatAll("^7^2INNOCENT ^1DAMAGE/DEAD^7 HAS TAKEN!"); - //30 damage points deal - Damage(frag_attacker, frag_attacker, frag_attacker, 300, DEATH_MIRRORDAMAGE.m_id, DMG_NOWEP, frag_attacker.origin, '0 0 0'); + //PrintToChatAll("^1DEBUG^7: ^2INNOCENT ^1DAMAGE/DEAD^7 HAS TAKEN!"); + //50 damage points deal + Damage(frag_attacker, frag_attacker, frag_attacker, 50, DEATH_MIRRORDAMAGE.m_id, DMG_NOWEP, frag_attacker.origin, '0 0 0'); } } return true; @@ -498,7 +594,7 @@ MUTATOR_HOOKFUNCTION(ttt, GiveFragsForKill, CBC_ORDER_FIRST) MUTATOR_HOOKFUNCTION(ttt, AddPlayerScore) { - //TODO: LegendGuard, try to add KARMA for score here if possible 21-02-2021 + // add scorefield for scoreboard here entity scorefield = M_ARGV(0, entity); if(scorefield == SP_KILLS || scorefield == SP_DEATHS || scorefield == SP_SUICIDES || scorefield == SP_DMG || scorefield == SP_DMGTAKEN) M_ARGV(1, float) = 0; // don't report that the player has killed or been killed, that would out them as a traitor! @@ -544,7 +640,7 @@ MUTATOR_HOOKFUNCTION(ttt, GetPlayerStatus) MUTATOR_HOOKFUNCTION(ttt, BotShouldAttack) { - //TODO: LegendGuard, make bots attack to innocents vs traitors, detectives must be on innocents team 21-02-2021 + //TODO: LegendGuard, try bots attack to innocents vs traitors, detectives must be on innocents team 21-02-2021 entity bot = M_ARGV(0, entity); entity targ = M_ARGV(1, entity); diff --git a/qcsrc/common/gamemodes/gamemode/ttt/sv_ttt.qh b/qcsrc/common/gamemodes/gamemode/ttt/sv_ttt.qh index 20b300bfc..c1e5219fb 100644 --- a/qcsrc/common/gamemodes/gamemode/ttt/sv_ttt.qh +++ b/qcsrc/common/gamemodes/gamemode/ttt/sv_ttt.qh @@ -15,3 +15,4 @@ REGISTER_MUTATOR(ttt, false) } .int ttt_validkills; // store the player's valid kills to be given at the end of the match (avoid exposing their score until then) +.float karmapoints; //LegendGuard adds karma points to store player status \ No newline at end of file diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index c871b5387..b81c2503a 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -776,10 +776,9 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input != //LegendGuard adds MSG_CENTER_NOTIF for TTT 20-02-2021 MSG_CENTER_NOTIF(TTT_TRAITOR, N_ENABLE, 0, 0, "", CPID_TTT, "5 0", strcat(BOLD_OPERATOR, _("^BGYou are ^K1Traitor^BG! Kill all the innocents without raising suspicion!")), "") MSG_CENTER_NOTIF(TTT_TRAITOR_WIN, N_ENABLE, 0, 0, "", CPID_ROUND, "0 0", _("^K1Traitors^BG win the round"), "") - MSG_CENTER_NOTIF(TTT_INNOCENT, N_ENABLE, 0, 0, "", CPID_TTT, "5 0", strcat(BOLD_OPERATOR, _("^BGYou are ^F1Innocent^BG! Try to find out who is/are traitors and survive until time is up!")), "") + MSG_CENTER_NOTIF(TTT_INNOCENT, N_ENABLE, 0, 0, "", CPID_TTT, "5 0", strcat(BOLD_OPERATOR, _("^BGYou are ^F1Innocent^BG! Try to find out who are traitors and survive until time is up!")), "") MSG_CENTER_NOTIF(TTT_INNOCENT_WIN, N_ENABLE, 0, 0, "", CPID_ROUND, "0 0", _("^F1Innocents^BG win the round"), "") - MSG_CENTER_NOTIF(TTT_DETECTIVE, N_ENABLE, 0, 0, "", CPID_TTT, "5 0", strcat(BOLD_OPERATOR, _("^BGYou are ^4Detective^BG! Find out who is/are traitors and protect the innocents!")), "") - //TODO: MAKE DETECTIVE WORD BLUE LegendGuard + MSG_CENTER_NOTIF(TTT_DETECTIVE, N_ENABLE, 0, 0, "", CPID_TTT, "5 0", strcat(BOLD_OPERATOR, _("^BGYou are ^4Detective^BG! Find out who are traitors and protect the innocents!")), "") MSG_CENTER_NOTIF(JOIN_PREVENT_MINIGAME, N_ENABLE, 0, 0, "", CPID_Null, "0 0", _("^K1Cannot join given minigame session!"), "" ) diff --git a/qcsrc/common/scores.qh b/qcsrc/common/scores.qh index a520dba5e..4092b83b2 100644 --- a/qcsrc/common/scores.qh +++ b/qcsrc/common/scores.qh @@ -88,7 +88,7 @@ REGISTER_SP(ONS_CAPS); REGISTER_SP(TTT_RESISTS); //LegendGuard adds REGISTER_SP for TTT 20-02-2021 //Innocents as number of suvivals REGISTER_SP(TTT_HUNTS); //Traitors as number of hunts -//REGISTER_SP(TTT_KARMA); //LegendGuard adds REGISTER_SP for TTT Karma points 21-02-2021 +REGISTER_SP(TTT_KARMA); //LegendGuard adds REGISTER_SP for TTT Karma points 21-02-2021 #endif