set g_duel_with_powerups 0 "Enable powerups to spawn in the duel gamemode"
set g_duel_not_dm_maps 0 "when this is set, DM maps will NOT be listed in duel"
-// ======================
-// mayhem (ffa or team)
-// ======================
+// ==============================
+// free for all and team mayhem
+// ==============================
set g_mayhem 0 "Mayhem: the player with the most frags in total mayhem wins"
-set g_mayhem_regenerate 0 "allow players to regenerate hp. rates controlled by hp regeneration and rotting cvars"
+set g_tmayhem 0 "Team Mayhem: the team with the most frags in total mayhem wins"
+
+set g_mayhem_scoringmethod 1 "1: 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: 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_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"
+
+set g_mayhem_point_limit 1000 "Mayhem visual score limit overriding the mapinfo specified one"
+set g_tmayhem_point_limit 1000 "Team Mayhem visual score limit overriding the mapinfo specified one"
+
+set g_tmayhem_point_leadlimit -1 "Team Mayhem point lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+
set g_mayhem_weaponarena "most_available" "starting weapons - takes the same options as g_weaponarena"
+set g_tmayhem_weaponarena "most_available" "starting weapons - takes the same options as g_weaponarena"
+
set g_mayhem_powerups 1 "Allow powerups in mayhem. Only checked if g_powerups is -1 therefore this will be overridden by g_powerups 1 or 0"
+set g_tmayhem_powerups 1 "Allow powerups in team mayhem. Only checked if g_powerups is -1 therefore this will be overridden by g_powerups 1 or 0"
+
set g_mayhem_selfdamage 0 "0 = disable selfdamage in mayhem, 1 = enable selfdamage in mayhem"
-set g_mayhem_frags2score 1 "enable frags counting towards score"
-set g_mayhem_damage2score 0 "enable damage counting towards score"
-set g_mayhem_damage2score_multiplier 0.0025 "how much score is given for damage dealt. 0.01 -> 1k dmg = 10 score, 0.001 1k dmg = 1 score, 0.0025 400 dmg = 1 score"
+set g_tmayhem_selfdamage 0 "0 = disable selfdamage in tmayhem, 1 = enable selfdamage in tmayhem"
+
+set g_mayhem_regenerate 0 "allow players to regenerate hp. rates controlled by hp regeneration and rotting cvars"
+set g_tmayhem_regenerate 0 "allow players to regenerate hp. rates controlled by hp regeneration and rotting cvars"
-set g_tmayhem 0 "Team Mayhem: the team with the most frags in total mayhem wins"
set g_tmayhem_teams 2 "how many teams are in team mayhem (set by mapinfo)"
set g_tmayhem_team_spawns 0 "when 1, players spawn from the team spawnpoints of the map, if any"
set g_tmayhem_teams_override 0 "how many teams are in team mayhem"
-set g_tmayhem_point_limit -1 "Team Mayhem point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
-set g_tmayhem_point_leadlimit -1 "Team Mayhem point lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
-set g_tmayhem_weaponarena "most_available" "starting weapons - takes the same options as g_weaponarena"
-set g_tmayhem_powerups 1 "Allow powerups in team mayhem. Only checked if g_powerups is -1 therefore this will be overridden by g_powerups 1 or 0"
-set g_tmayhem_regenerate 0 "allow players to regenerate hp. rates controlled by hp regeneration and rotting cvars"
-set g_tmayhem_selfdamage 0 "0 = disable selfdamage in tmayhem, 1 = enable selfdamage in tmayhem"
-set g_tmayhem_frags2score 1 "enable frags counting towards score"
-set g_tmayhem_damage2score 0 "enable damage counting towards score"
-set g_tmayhem_damage2score_multiplier 0.0025 "how much score is given for damage dealt. 0.01 -> 1k dmg = 10 score, 0.001 1k dmg = 1 score, 0.0025 400 dmg = 1 score"
string autocvar_g_mayhem_weaponarena;
bool autocvar_g_mayhem_powerups;
bool autocvar_g_mayhem_selfdamage;
-bool autocvar_g_mayhem_frags2score;
-bool autocvar_g_mayhem_damage2score;
-float autocvar_g_mayhem_damage2score_multiplier;
+int autocvar_g_mayhem_scoringmethod;
+
+void mayhem_DelayedInit(entity this)
+{
+ return;
+}
+
+void mayhem_Initialize()
+{
+ if(autocvar_g_mayhem_point_limit > 0 && autocvar_g_mayhem_fraglimit > 0)
+ mayhempointmultiplier = autocvar_g_mayhem_point_limit / autocvar_g_mayhem_fraglimit;
+
+ GameRules_limit_score(autocvar_g_mayhem_point_limit);
+
+ InitializeEntity(NULL, mayhem_DelayedInit, INITPRIO_GAMETYPE);
+}
MUTATOR_HOOKFUNCTION(mayhem, Scores_CountFragsRemaining)
{
MUTATOR_HOOKFUNCTION(mayhem, PlayerDamage_SplitHealthArmor)
{
- if(autocvar_g_mayhem_damage2score){
- entity frag_attacker = M_ARGV(1, entity);
- entity frag_target = M_ARGV(2, entity);
- float frag_deathtype = M_ARGV(6, float);
- float frag_damage = M_ARGV(7, float);
- float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
- float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
-
- 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) * autocvar_g_mayhem_damage2score_multiplier);
+ switch(autocvar_g_mayhem_scoringmethod)
+ {
+ //frags only
+ case 2:
+ {
+ return;
+ }
+
+ //damage only
+ case 3:
+ {
+ entity frag_attacker = M_ARGV(1, entity);
+ entity frag_target = M_ARGV(2, entity);
+ float frag_deathtype = M_ARGV(6, float);
+ float frag_damage = M_ARGV(7, float);
+ float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
+ float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
+
+ 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)));
+
+ 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
+ if (!IS_PLAYER(frag_attacker) && (
+ 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;
+ }
+
+ //combined damage and frags
+ default:
+ case 1:
+ {
+ entity frag_attacker = M_ARGV(1, entity);
+ entity frag_target = M_ARGV(2, entity);
+ float frag_deathtype = M_ARGV(6, float);
+ float frag_damage = M_ARGV(7, float);
+ float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
+ float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
+
+ 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) * 0.75 * 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)) * autocvar_g_mayhem_damage2score_multiplier);
+ 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
- if (!IS_PLAYER(frag_attacker) && (
- 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_mayhem_damage2score_multiplier);
+ //handle hazard suiciding, check first if player has a registered attacker who most likely pushed them there
+ if (!IS_PLAYER(frag_attacker) && (
+ 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 * mayhempointmultiplier * (1/(start_health + start_armorvalue)));
- //autocvar_g_mayhem_frags2score is checked to avoid punishing twice for a suicide
- //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 && !autocvar_g_mayhem_frags2score)
- GameRules_scoring_add_team(frag_target, SCORE, (-1 * (start_health + start_armorvalue)) * autocvar_g_mayhem_damage2score_multiplier);
+ //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;
+ }
}
}
MUTATOR_HOOKFUNCTION(mayhem, GiveFragsForKill, CBC_ORDER_FIRST)
{
- if(!autocvar_g_mayhem_frags2score){
- M_ARGV(2, float) = 0;
- return true;
+ switch(autocvar_g_mayhem_scoringmethod)
+ {
+ //frags only
+ case 2:
+ {
+ //fix 999 score from 30 kills for example
+ M_ARGV(2, float) = 1 * mayhempointmultiplier * 1.0001;
+ return true;
+ }
+
+ //damage only
+ case 3:
+ {
+ M_ARGV(2, float) = 0;
+ return true;
+ }
+
+ //combined damage and frags
+ default:
+ case 1:
+ {
+ M_ARGV(2, float) = 0.25 * mayhempointmultiplier * 1.0001;
+ return true;
+ }
}
}
#pragma once
#include <common/mutators/base.qh>
+//someone who understands numbers better check if 2 following floats can be ints without imprecision, I'm scared of spaghettimonsters
+float autocvar_g_mayhem_fraglimit;
+float autocvar_g_mayhem_point_limit;
+float mayhempointmultiplier = 1000/30;
+void mayhem_Initialize();
+
REGISTER_MUTATOR(mayhem, false)
{
MUTATOR_STATIC();
+ MUTATOR_ONADD
+ {
+ mayhem_Initialize();
+ }
return 0;
}
#include "sv_tmayhem.qh"
-// TODO? rename to teamdeathmatch
+// TODO? rename to teammayhem? requires checking alias length
int autocvar_g_tmayhem_teams;
int autocvar_g_tmayhem_teams_override;
string autocvar_g_tmayhem_weaponarena;
bool autocvar_g_tmayhem_powerups;
bool autocvar_g_tmayhem_selfdamage;
-bool autocvar_g_tmayhem_frags2score;
-bool autocvar_g_tmayhem_damage2score;
-float autocvar_g_tmayhem_damage2score_multiplier;
+int autocvar_g_tmayhem_scoringmethod;
+
+
// code from here on is just to support maps that don't have team entities
void tmayhem_SpawnTeam (string teamname, int teamcolor)
void tmayhem_Initialize()
{
+ if(autocvar_g_tmayhem_point_limit != 0 && autocvar_g_tmayhem_fraglimit != 0)
+ tmayhempointmultiplier = autocvar_g_tmayhem_point_limit / autocvar_g_tmayhem_fraglimit;
+
GameRules_teams(true);
GameRules_spawning_teams(autocvar_g_tmayhem_team_spawns);
GameRules_limit_score(autocvar_g_tmayhem_point_limit);
MUTATOR_HOOKFUNCTION(tmayhem, PlayerDamage_SplitHealthArmor)
{
- if(autocvar_g_tmayhem_damage2score){
- entity frag_attacker = M_ARGV(1, entity);
- entity frag_target = M_ARGV(2, entity);
- float frag_deathtype = M_ARGV(6, float);
- float frag_damage = M_ARGV(7, float);
- float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
- float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
-
- float excess = max(0, frag_damage - damage_take - damage_save);
-
- if (frag_target != frag_attacker && IS_PLAYER(frag_attacker) && DIFF_TEAM(frag_target, frag_attacker))
- GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * autocvar_g_tmayhem_damage2score_multiplier);
+ switch(autocvar_g_tmayhem_scoringmethod)
+ {
+ //frags only
+ case 2:
+ {
+ return;
+ }
+
+ //damage only
+ case 3:
+ {
+ entity frag_attacker = M_ARGV(1, entity);
+ entity frag_target = M_ARGV(2, entity);
+ float frag_deathtype = M_ARGV(6, float);
+ float frag_damage = M_ARGV(7, float);
+ float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
+ float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
+
+ 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)));
- 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_damage2score_multiplier);
+ 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
- if (!IS_PLAYER(frag_attacker) && (
- 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_damage2score_multiplier);
+ //handle hazard suiciding, check first if player has a registered attacker who most likely pushed them there
+ if (!IS_PLAYER(frag_attacker) && (
+ 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;
+ }
- //autocvar_g_tmayhem_frags2score is checked to avoid punishing twice for a suicide
- //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 && !autocvar_g_tmayhem_frags2score)
- GameRules_scoring_add_team(frag_target, SCORE, (-1 * (start_health + start_armorvalue)) * autocvar_g_tmayhem_damage2score_multiplier);
+ //combined damage and frags
+ default:
+ case 1:
+ {
+ entity frag_attacker = M_ARGV(1, entity);
+ entity frag_target = M_ARGV(2, entity);
+ float frag_deathtype = M_ARGV(6, float);
+ float frag_damage = M_ARGV(7, float);
+ float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
+ float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
+
+ 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) * 0.75 * tmayhempointmultiplier * (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)) * 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
+ if (!IS_PLAYER(frag_attacker) && (
+ 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)
{
- if(!autocvar_g_tmayhem_frags2score){
- M_ARGV(2, float) = 0;
- return true;
+ switch(autocvar_g_tmayhem_scoringmethod)
+ {
+ //frags only
+ case 2:
+ {
+ //fix 999 score from 30 kills for example
+ M_ARGV(2, float) = 1 * tmayhempointmultiplier * 1.0001;
+ return true;
+ }
+
+ //damage only
+ case 3:
+ {
+ M_ARGV(2, float) = 0;
+ return true;
+ }
+
+ //combined damage and frags
+ default:
+ case 1:
+ {
+ M_ARGV(2, float) = 0.25 * tmayhempointmultiplier * 1.0001;
+ return true;
+ }
}
}
#pragma once
#include <common/mutators/base.qh>
-int autocvar_g_tmayhem_point_limit;
-int autocvar_g_tmayhem_point_leadlimit;
+//someone who understands numbers better check if 2 following floats can be ints without imprecision, I'm scared of spaghettimonsters
+float autocvar_g_tmayhem_fraglimit;
+float autocvar_g_tmayhem_point_limit;
+float autocvar_g_tmayhem_point_leadlimit;
bool autocvar_g_tmayhem_team_spawns;
+float tmayhempointmultiplier = 1000/50;
void tmayhem_Initialize();
REGISTER_MUTATOR(tmayhem, false)