From f1fb8b4b07105c8f97ebe652b76ea2e0fd7649c8 Mon Sep 17 00:00:00 2001 From: drjaska Date: Sun, 29 Aug 2021 07:13:53 +0300 Subject: [PATCH] Mostly updating stuff changed during my vacation. --- .../gamemodes/gamemode/mayhem/mayhem.qh | 2 +- .../gamemodes/gamemode/mayhem/sv_mayhem.qc | 46 +++++++++--------- .../gamemodes/gamemode/tmayhem/sv_tmayhem.qc | 47 ++++++++++--------- .../gamemodes/gamemode/tmayhem/tmayhem.qh | 2 +- 4 files changed, 50 insertions(+), 47 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/mayhem/mayhem.qh b/qcsrc/common/gamemodes/gamemode/mayhem/mayhem.qh index bf5568b84..2fee85305 100644 --- a/qcsrc/common/gamemodes/gamemode/mayhem/mayhem.qh +++ b/qcsrc/common/gamemodes/gamemode/mayhem/mayhem.qh @@ -7,7 +7,7 @@ CLASS(mayhem, Gametype) INIT(mayhem) { - this.gametype_init(this, _("Mayhem"),"mayhem","g_mayhem",GAMETYPE_FLAG_USEPOINTS | GAMETYPE_FLAG_PREFERRED,"","timelimit=15 pointlimit=30 leadlimit=0",_("The player with the most frags in total mayhem wins!")); + this.gametype_init(this, _("Mayhem"),"mayhem","g_mayhem",GAMETYPE_FLAG_USEPOINTS | GAMETYPE_FLAG_PREFERRED,"","timelimit=15 pointlimit=30 leadlimit=0",_("The player with the most damage and frags in total mayhem wins!")); } METHOD(mayhem, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter)) { diff --git a/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc b/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc index 70bd1dcf8..36f1159fd 100644 --- a/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc +++ b/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc @@ -63,12 +63,12 @@ MUTATOR_HOOKFUNCTION(mayhem, FilterItem) { entity item = M_ARGV(0, entity); if (autocvar_g_powerups == 1){ - if (item.flags & FL_POWERUP){ + if (item.itemdef.instanceOfPowerup){ return false; } } else if (autocvar_g_powerups == -1){ - if (item.flags & FL_POWERUP){ + if (item.itemdef.instanceOfPowerup){ if (autocvar_g_mayhem_powerups){ return false; } @@ -114,26 +114,25 @@ MUTATOR_HOOKFUNCTION(mayhem, PlayerDamage_SplitHealthArmor) float excess = max(0, frag_damage - damage_take - damage_save); if (frag_target != frag_attacker && IS_PLAYER(frag_attacker)) - GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * (1/(start_health + start_armorvalue))); + GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * mayhempointmultiplier * (1/(start_health + start_armorvalue))); if (frag_target == frag_attacker && IS_PLAYER(frag_attacker)) - GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * (1/(start_health + start_armorvalue))); + GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * mayhempointmultiplier * (1/(start_health + start_armorvalue))); - //handle hazard suiciding, check first if player has a registered attacker who most likely pushed them there + //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) && ( + 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)) * (1/(start_health + start_armorvalue))); - - //when hp and armor values are checked when suiciding for some reason they are 0.9 hp and 0 armor regardless that player suicided with 200+200 - //AFAIK dynamic hp value checking is not possible, hardcoded start hp and armor - //FIXME: ^ , might require fixing hp+a check for suicides as a whole - if (frag_deathtype == DEATH_KILL.m_id) - GameRules_scoring_add_team(frag_target, SCORE, (-1 * (start_health + start_armorvalue)) * (1/(start_health + start_armorvalue))); - return; + frag_deathtype == DEATH_SLIME.m_id || + frag_deathtype == DEATH_SWAMP.m_id)) + GameRules_scoring_add_team(frag_target, SCORE, (-1 * (start_health + start_armorvalue)) * mayhempointmultiplier * (1/(start_health + start_armorvalue))); } //combined damage and frags @@ -149,27 +148,28 @@ MUTATOR_HOOKFUNCTION(mayhem, PlayerDamage_SplitHealthArmor) float excess = max(0, frag_damage - damage_take - damage_save); + //non-friendly fire if (frag_target != frag_attacker && IS_PLAYER(frag_attacker)) GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * 0.75 * 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)) * 0.75 * mayhempointmultiplier * (1/(start_health + start_armorvalue))); - //handle hazard suiciding, check first if player has a registered attacker who most likely pushed them there + //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) && ( + 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)) + frag_deathtype == DEATH_SLIME.m_id || + frag_deathtype == DEATH_SWAMP.m_id)) GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * 0.75 * mayhempointmultiplier * (1/(start_health + start_armorvalue))); - - //when hp and armor values are checked when suiciding for some reason they are 0.9 hp and 0 armor regardless that player suicided with 200+200 - //AFAIK dynamic hp value checking is not possible, hardcoded start hp and armor - //FIXME: ^ , might require fixing hp+a check for suicides as a whole - if (frag_deathtype == DEATH_KILL.m_id) - GameRules_scoring_add_team(frag_target, SCORE, (-1 * (start_health + start_armorvalue)) * 0.75 * mayhempointmultiplier * (1/(start_health + start_armorvalue))); - return; } } } diff --git a/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc b/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc index acb10404e..26c3f30ef 100644 --- a/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc +++ b/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc @@ -1,6 +1,6 @@ #include "sv_tmayhem.qh" -// TODO? rename to teammayhem? requires checking alias length +// TODO? rename to teammayhem? requires checking alias and other string lengths int autocvar_g_tmayhem_teams; int autocvar_g_tmayhem_teams_override; @@ -105,12 +105,12 @@ MUTATOR_HOOKFUNCTION(tmayhem, FilterItem) { entity item = M_ARGV(0, entity); if (autocvar_g_powerups == 1){ - if (item.flags & FL_POWERUP){ + if (item.itemdef.instanceOfPowerup){ return false; } } else if (autocvar_g_powerups == -1){ - if (item.flags & FL_POWERUP){ + if (item.itemdef.instanceOfPowerup){ if (autocvar_g_tmayhem_powerups){ return false; } @@ -161,26 +161,27 @@ MUTATOR_HOOKFUNCTION(tmayhem, PlayerDamage_SplitHealthArmor) float excess = max(0, frag_damage - damage_take - damage_save); + //non-friendly fire if (frag_target != frag_attacker && IS_PLAYER(frag_attacker)) - GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * (1/(start_health + start_armorvalue))); - + GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); + + //friendly fire or self damage if (frag_target == frag_attacker && IS_PLAYER(frag_attacker)) - GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * (1/(start_health + start_armorvalue))); - - //handle hazard suiciding, check first if player has a registered attacker who most likely pushed them there + GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * 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) && ( + 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)) * (1/(start_health + start_armorvalue))); - - //when hp and armor values are checked when suiciding for some reason they are 0.9 hp and 0 armor regardless that player suicided with 200+200 - //AFAIK dynamic hp value checking is not possible, hardcoded start hp and armor - //FIXME: ^ , might require fixing hp+a check for suicides as a whole - if (frag_deathtype == DEATH_KILL.m_id) - GameRules_scoring_add_team(frag_target, SCORE, (-1 * (start_health + start_armorvalue)) * (1/(start_health + start_armorvalue))); + GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * 0.75 * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); return; } @@ -197,31 +198,33 @@ MUTATOR_HOOKFUNCTION(tmayhem, PlayerDamage_SplitHealthArmor) float excess = max(0, frag_damage - damage_take - damage_save); + //non-friendly fire if (frag_target != frag_attacker && IS_PLAYER(frag_attacker)) GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * 0.75 * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); + //friendly fire or self damage if (frag_target == frag_attacker && IS_PLAYER(frag_attacker)) GameRules_scoring_add_team(frag_target, SCORE, (-1 * (frag_damage - excess)) * 0.75 * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); - //handle hazard suiciding, check first if player has a registered attacker who most likely pushed them there + //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) && ( + 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)) * 0.75 * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); - - //when hp and armor values are checked when suiciding for some reason they are 0.9 hp and 0 armor regardless that player suicided with 200+200 - //AFAIK dynamic hp value checking is not possible, hardcoded start hp and armor - //FIXME: ^ , might require fixing hp+a check for suicides as a whole - if (frag_deathtype == DEATH_KILL.m_id) - GameRules_scoring_add_team(frag_target, SCORE, (-1 * (start_health + start_armorvalue)) * 0.75 * tmayhempointmultiplier * (1/(start_health + start_armorvalue))); return; } } } + MUTATOR_HOOKFUNCTION(tmayhem, GiveFragsForKill, CBC_ORDER_FIRST) { switch(autocvar_g_tmayhem_scoringmethod) diff --git a/qcsrc/common/gamemodes/gamemode/tmayhem/tmayhem.qh b/qcsrc/common/gamemodes/gamemode/tmayhem/tmayhem.qh index 290881c9c..2fe524aff 100644 --- a/qcsrc/common/gamemodes/gamemode/tmayhem/tmayhem.qh +++ b/qcsrc/common/gamemodes/gamemode/tmayhem/tmayhem.qh @@ -7,7 +7,7 @@ CLASS(tmayhem, Gametype) INIT(tmayhem) { - this.gametype_init(this, _("Team Mayhem"),"tmayhem","g_tmayhem",GAMETYPE_FLAG_TEAMPLAY | GAMETYPE_FLAG_USEPOINTS | GAMETYPE_FLAG_PRIORITY,"","timelimit=15 pointlimit=50 teams=2 leadlimit=0",_("The team with the most frags in total mayhem wins!")); + this.gametype_init(this, _("Team Mayhem"),"tmayhem","g_tmayhem",GAMETYPE_FLAG_TEAMPLAY | GAMETYPE_FLAG_USEPOINTS | GAMETYPE_FLAG_PRIORITY,"","timelimit=15 pointlimit=50 teams=2 leadlimit=0",_("The team with the most damage and frags in total mayhem wins!")); } METHOD(tmayhem, m_parse_mapinfo, bool(string k, string v)) { -- 2.39.2