From dbb2c3d902c5fa381512a2410b28478d8b17bc7a Mon Sep 17 00:00:00 2001 From: drjaska Date: Sat, 4 Dec 2021 08:32:17 +0200 Subject: [PATCH] add an off-switch for selfdamage2score for scoringmethod 1 bones feature request --- gamemodes-server.cfg | 10 +++++--- .../gamemodes/gamemode/mayhem/sv_mayhem.qc | 25 ++++++++++++------- .../gamemodes/gamemode/tmayhem/sv_tmayhem.qc | 25 ++++++++++++------- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index e00eae6ff..6f6ddd782 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -586,10 +586,12 @@ set g_tmayhem 0 "Team Mayhem: Compete with your team for the most damage dealt a set g_mayhem_scoringmethod 1 "1: By default 25% of the score is based on kills and 75% of it is based on damage. 2: 100% frags. 3: 100% damage." set g_tmayhem_scoringmethod 1 "1: By default 25% of the score is based on kills and 75% of it is based on damage. 2: 100% frags. 3: 100% damage." -set g_mayhem_scoringmethod_damage_weight 0.75 "for the first scoring method how much is damage equal to player's spawning health worth in score" -set g_tmayhem_scoringmethod_damage_weight 0.75 "for the first scoring method how much is damage equal to player's spawning health worth in score" -set g_mayhem_scoringmethod_frag_weight 0.25 "for the first scoring method how much is a frag worth in score" -set g_tmayhem_scoringmethod_frag_weight 0.25 "for the first scoring method how much is a frag worth in score" +set g_mayhem_scoringmethod_1_damage_weight 0.75 "for the first scoring method how much is damage equal to player's spawning health worth in score" +set g_tmayhem_scoringmethod_1_damage_weight 0.75 "for the first scoring method how much is damage equal to player's spawning health worth in score" +set g_mayhem_scoringmethod_1_disable_selfdamage2score 0 "disable reducing score with self damage at the cost of full penalty for suicides regardless of how much health was lost suiciding" +set g_tmayhem_scoringmethod_1_disable_selfdamage2score 0 "disable reducing score with self damage at the cost of full penalty for suicides regardless of how much health was lost suiciding" +set g_mayhem_scoringmethod_1_frag_weight 0.25 "for the first scoring method how much is a frag worth in score" +set g_tmayhem_scoringmethod_1_frag_weight 0.25 "for the first scoring method how much is a frag worth in score" set g_mayhem_fraglimit 30 "Team Mayhem basis for how many frags until the match ends, edit this over point_limit preferably" set g_tmayhem_fraglimit 50 "Team Mayhem basis for how many frags until the match ends, edit this over point_limit preferably" diff --git a/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc b/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc index 1e2d801ed..57c5293b9 100644 --- a/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc +++ b/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc @@ -9,8 +9,9 @@ string autocvar_g_mayhem_weaponarena; bool autocvar_g_mayhem_powerups; bool autocvar_g_mayhem_selfdamage; int autocvar_g_mayhem_scoringmethod; -float autocvar_g_mayhem_scoringmethod_damage_weight; -float autocvar_g_mayhem_scoringmethod_frag_weight; +float autocvar_g_mayhem_scoringmethod_1_damage_weight; +float autocvar_g_mayhem_scoringmethod_1_frag_weight; +bool autocvar_g_mayhem_scoringmethod_1_disable_selfdamage2score; bool autocvar_g_mayhem_pickup_items; bool autocvar_g_mayhem_pickup_items_remove_weapons_and_ammo; bool autocvar_g_mayhem_unlimited_ammo; @@ -186,18 +187,18 @@ MUTATOR_HOOKFUNCTION(mayhem, PlayerDamage_SplitHealthArmor) //non-friendly fire if (frag_target != frag_attacker && IS_PLAYER(frag_attacker)) - GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * autocvar_g_mayhem_scoringmethod_damage_weight * mayhempointmultiplier * (1/(start_health + start_armorvalue))); + GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * autocvar_g_mayhem_scoringmethod_1_damage_weight * mayhempointmultiplier * (1/(start_health + start_armorvalue))); //friendly fire aka self damage - if (frag_target == frag_attacker && IS_PLAYER(frag_attacker)) - GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * autocvar_g_mayhem_scoringmethod_damage_weight * mayhempointmultiplier * (1/(start_health + start_armorvalue))); + if (frag_target == frag_attacker && IS_PLAYER(frag_attacker) && !autocvar_g_mayhem_scoringmethod_1_disable_selfdamage2score) + GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * autocvar_g_mayhem_scoringmethod_1_damage_weight * mayhempointmultiplier * (1/(start_health + start_armorvalue))); //handle (environmental hazard) suiciding, check first if player has a registered attacker who most likely pushed them there to avoid punishing pushed players as pushers are already rewarded //deathtypes: //kill = suicide, drown = drown in water/liquid, hurttrigger = out of the map void or hurt triggers inside maps like electric sparks //camp = campcheck, lava = lava, slime = slime //team change / rebalance suicides are currently not included - if (!IS_PLAYER(frag_attacker) && ( + if (!autocvar_g_mayhem_scoringmethod_1_disable_selfdamage2score && !IS_PLAYER(frag_attacker) && ( frag_deathtype == DEATH_KILL.m_id || frag_deathtype == DEATH_DROWN.m_id || frag_deathtype == DEATH_HURTTRIGGER.m_id || @@ -205,7 +206,7 @@ MUTATOR_HOOKFUNCTION(mayhem, PlayerDamage_SplitHealthArmor) frag_deathtype == DEATH_LAVA.m_id || frag_deathtype == DEATH_SLIME.m_id || frag_deathtype == DEATH_SWAMP.m_id)) - GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * autocvar_g_mayhem_scoringmethod_damage_weight * mayhempointmultiplier * (1/(start_health + start_armorvalue))); + GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * autocvar_g_mayhem_scoringmethod_1_damage_weight * mayhempointmultiplier * (1/(start_health + start_armorvalue))); return; } } @@ -238,7 +239,13 @@ MUTATOR_HOOKFUNCTION(mayhem, GiveFragsForKill, CBC_ORDER_FIRST) default: case 1: { - M_ARGV(2, float) = -autocvar_g_mayhem_scoringmethod_frag_weight * mayhempointmultiplier * 1.0001; + //when selfdamage2score is disabled don't enable cheap discounted suicides at the cost of the possibility of + //punishing for a full life when they only deal a single point worth of self damage to kill themselves + if(autocvar_g_mayhem_scoringmethod_1_disable_selfdamage2score && frag_target==frag_attacker){ + M_ARGV(2, float) = -1 * mayhempointmultiplier * 1.0001; + } else { + M_ARGV(2, float) = -autocvar_g_mayhem_scoringmethod_1_frag_weight * mayhempointmultiplier * 1.0001; + } return true; } } @@ -264,7 +271,7 @@ MUTATOR_HOOKFUNCTION(mayhem, GiveFragsForKill, CBC_ORDER_FIRST) default: case 1: { - M_ARGV(2, float) = autocvar_g_mayhem_scoringmethod_frag_weight * mayhempointmultiplier * 1.0001; + M_ARGV(2, float) = autocvar_g_mayhem_scoringmethod_1_frag_weight * mayhempointmultiplier * 1.0001; return true; } } diff --git a/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc b/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc index 198bc587c..41b3ae633 100644 --- a/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc +++ b/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc @@ -15,8 +15,9 @@ string autocvar_g_tmayhem_weaponarena; bool autocvar_g_tmayhem_powerups; bool autocvar_g_tmayhem_selfdamage; int autocvar_g_tmayhem_scoringmethod; -float autocvar_g_tmayhem_scoringmethod_damage_weight; -float autocvar_g_tmayhem_scoringmethod_frag_weight; +float autocvar_g_tmayhem_scoringmethod_1_damage_weight; +float autocvar_g_tmayhem_scoringmethod_1_frag_weight; +bool autocvar_g_tmayhem_scoringmethod_1_disable_selfdamage2score; bool autocvar_g_tmayhem_pickup_items; bool autocvar_g_tmayhem_pickup_items_remove_weapons_and_ammo; bool autocvar_g_tmayhem_unlimited_ammo; @@ -235,25 +236,25 @@ MUTATOR_HOOKFUNCTION(tmayhem, PlayerDamage_SplitHealthArmor) //non-friendly fire if (IS_PLAYER(frag_attacker) && !SAME_TEAM(frag_target, frag_attacker)) - GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * autocvar_g_tmayhem_scoringmethod_damage_weight * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); + GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * autocvar_g_tmayhem_scoringmethod_1_damage_weight * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); //friendly fire or self damage - if (frag_target == frag_attacker && IS_PLAYER(frag_attacker) || SAME_TEAM(frag_target, frag_attacker)) - GameRules_scoring_add_team(frag_attacker, SCORE, (-1 * (frag_damage - excess)) * autocvar_g_tmayhem_scoringmethod_damage_weight * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); + if ((SAME_TEAM(frag_target, frag_attacker) && frag_target != frag_attacker) || (frag_target == frag_attacker && IS_PLAYER(frag_attacker) && !autocvar_g_tmayhem_scoringmethod_1_disable_selfdamage2score)) + GameRules_scoring_add_team(frag_attacker, SCORE, (-1 * (frag_damage - excess)) * autocvar_g_tmayhem_scoringmethod_1_damage_weight * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); //handle (environmental hazard) suiciding, check first if player has a registered attacker who most likely pushed them there to avoid punishing pushed players as pushers are already rewarded //deathtypes: //kill = suicide, drown = drown in water/liquid, hurttrigger = out of the map void or hurt triggers inside maps like electric sparks //camp = campcheck, lava = lava, slime = slime //team change / rebalance suicides are currently not included - if (!IS_PLAYER(frag_attacker) && ( + if (!autocvar_g_tmayhem_scoringmethod_1_disable_selfdamage2score && !IS_PLAYER(frag_attacker) && ( frag_deathtype == DEATH_KILL.m_id || frag_deathtype == DEATH_DROWN.m_id || frag_deathtype == DEATH_HURTTRIGGER.m_id || frag_deathtype == DEATH_CAMP.m_id || frag_deathtype == DEATH_LAVA.m_id || frag_deathtype == DEATH_SLIME.m_id)) - GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * autocvar_g_tmayhem_scoringmethod_damage_weight * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); + GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * autocvar_g_tmayhem_scoringmethod_1_damage_weight * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); return; } } @@ -286,7 +287,13 @@ MUTATOR_HOOKFUNCTION(tmayhem, GiveFragsForKill, CBC_ORDER_FIRST) default: case 1: { - M_ARGV(2, float) = -autocvar_g_tmayhem_scoringmethod_frag_weight * tmayhempointmultiplier * 1.0001; + //when selfdamage2score is disabled don't enable cheap discounted suicides at the cost of the possibility of + //punishing for a full life when they only deal a single point worth of self damage to kill themselves + if(autocvar_g_tmayhem_scoringmethod_1_disable_selfdamage2score && frag_target==frag_attacker){ + M_ARGV(2, float) = -1 * tmayhempointmultiplier * 1.0001; + } else { + M_ARGV(2, float) = -autocvar_g_tmayhem_scoringmethod_1_frag_weight * tmayhempointmultiplier * 1.0001; + } return true; } } @@ -312,7 +319,7 @@ MUTATOR_HOOKFUNCTION(tmayhem, GiveFragsForKill, CBC_ORDER_FIRST) default: case 1: { - M_ARGV(2, float) = autocvar_g_tmayhem_scoringmethod_frag_weight * tmayhempointmultiplier * 1.0001; + M_ARGV(2, float) = autocvar_g_tmayhem_scoringmethod_1_frag_weight * tmayhempointmultiplier * 1.0001; return true; } } -- 2.39.2