Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_tmayhem.qc File Reference
Include dependency graph for sv_tmayhem.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (tmayhem, Damage_Calculate)
 MUTATOR_HOOKFUNCTION (tmayhem, FilterItem)
 MUTATOR_HOOKFUNCTION (tmayhem, ForbidThrowCurrentWeapon)
 MUTATOR_HOOKFUNCTION (tmayhem, GiveFragsForKill, CBC_ORDER_FIRST)
 MUTATOR_HOOKFUNCTION (tmayhem, PlayerDamage_SplitHealthArmor)
 MUTATOR_HOOKFUNCTION (tmayhem, PlayerRegen)
 MUTATOR_HOOKFUNCTION (tmayhem, reset_map_players)
 MUTATOR_HOOKFUNCTION (tmayhem, SetStartItems)
 MUTATOR_HOOKFUNCTION (tmayhem, SetWeaponArena)
void tmayhem_DelayedInit (entity this)
void tmayhem_Initialize ()

Variables

bool autocvar_g_tmayhem_pickup_items
bool autocvar_g_tmayhem_pickup_items_remove_weapons_and_ammo
float autocvar_g_tmayhem_point_leadlimit
float autocvar_g_tmayhem_point_limit
bool autocvar_g_tmayhem_powerups
bool autocvar_g_tmayhem_regenerate
bool autocvar_g_tmayhem_rot
bool autocvar_g_tmayhem_selfdamage
float autocvar_g_tmayhem_start_ammo_cells = 180
float autocvar_g_tmayhem_start_ammo_fuel = 0
float autocvar_g_tmayhem_start_ammo_nails = 320
float autocvar_g_tmayhem_start_ammo_rockets = 160
float autocvar_g_tmayhem_start_ammo_shells = 60
float autocvar_g_tmayhem_start_armor = 200
float autocvar_g_tmayhem_start_health = 200
bool autocvar_g_tmayhem_team_spawns
int autocvar_g_tmayhem_teams
int autocvar_g_tmayhem_teams_override
bool autocvar_g_tmayhem_unlimited_ammo
string autocvar_g_tmayhem_weaponarena
float total_damage_dealt

Function Documentation

◆ MUTATOR_HOOKFUNCTION() [1/9]

MUTATOR_HOOKFUNCTION ( tmayhem ,
Damage_Calculate  )

Definition at line 128 of file sv_tmayhem.qc.

129{
130 entity frag_attacker = M_ARGV(1, entity);
132 float frag_deathtype = M_ARGV(3, float);
133 float frag_damage = M_ARGV(4, float);
134 float frag_mirrordamage = M_ARGV(5, float);
135
136 if (IS_PLAYER(frag_target)) // nullify self-damage if self-damage is disabled and always nullify splat
137 if (!IS_DEAD(frag_target)) // but enable anyone to gib corpses, even their own corpses with delayed damage
138 if ((autocvar_g_tmayhem_selfdamage == 0 && frag_target == frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
139 frag_damage = 0;
140
141 frag_mirrordamage = 0; // no mirror damaging
142
143 M_ARGV(4, float) = frag_damage;
144 M_ARGV(5, float) = frag_mirrordamage;
145}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define M_ARGV(x, type)
Definition events.qh:17
#define IS_DEAD(s)
Definition player.qh:244
#define IS_PLAYER(s)
Definition player.qh:242
float frag_damage
Definition sv_ctf.qc:2315
entity frag_target
Definition sv_ctf.qc:2314
bool autocvar_g_tmayhem_selfdamage
Definition sv_tmayhem.qc:15

References autocvar_g_tmayhem_selfdamage, entity(), frag_damage, frag_target, IS_DEAD, IS_PLAYER, and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [2/9]

MUTATOR_HOOKFUNCTION ( tmayhem ,
FilterItem  )

Definition at line 95 of file sv_tmayhem.qc.

96{
97 entity item = M_ARGV(0, entity);
98
99 // enable powerups if forced globally or global accepts gametypes to have powerups according to their own settings
101 if (item.itemdef.instanceOfPowerup){
102 return false;
103 }
104 }
105 // disabled powerups if forced off globally or in this gametype
107 if (item.itemdef.instanceOfPowerup){
108 return true;
109 }
110 }
111 // remove all items if items are forced off globally
112 if (autocvar_g_pickup_items == 0){
113 return true;
114 }
115 // if items are switched on in this gametype allow the removal of weapons and ammo still
117 if (item.itemdef.instanceOfAmmo || item.itemdef.instanceOfWeaponPickup){
118 return true;
119 }
120 }
121 // remove items if not globally set to follow mode's settings and locally set off
123 return true;
124 }
125 return false;
126}
int autocvar_g_pickup_items
Definition items.qh:11
int autocvar_g_powerups
Definition sv_powerups.qh:7
bool autocvar_g_tmayhem_pickup_items
Definition sv_tmayhem.qc:16
bool autocvar_g_tmayhem_pickup_items_remove_weapons_and_ammo
Definition sv_tmayhem.qc:17
bool autocvar_g_tmayhem_powerups
Definition sv_tmayhem.qc:14

References autocvar_g_pickup_items, autocvar_g_powerups, autocvar_g_tmayhem_pickup_items, autocvar_g_tmayhem_pickup_items_remove_weapons_and_ammo, autocvar_g_tmayhem_powerups, entity(), and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [3/9]

MUTATOR_HOOKFUNCTION ( tmayhem ,
ForbidThrowCurrentWeapon  )

Definition at line 84 of file sv_tmayhem.qc.

85{
86 return true;
87}

◆ MUTATOR_HOOKFUNCTION() [4/9]

MUTATOR_HOOKFUNCTION ( tmayhem ,
GiveFragsForKill ,
CBC_ORDER_FIRST  )

Definition at line 207 of file sv_tmayhem.qc.

208{
209 entity frag_attacker = M_ARGV(0, entity);
210 M_ARGV(2, float) = 0; // score to give for the frag directly
211
212 if (IS_PLAYER(frag_attacker)) MayhemCalculatePlayerScore(frag_attacker);
213
214 return true;
215}
void MayhemCalculatePlayerScore(entity scorer)
Definition sv_mayhem.qc:145

References CBC_ORDER_FIRST, entity(), IS_PLAYER, M_ARGV, and MayhemCalculatePlayerScore().

◆ MUTATOR_HOOKFUNCTION() [5/9]

MUTATOR_HOOKFUNCTION ( tmayhem ,
PlayerDamage_SplitHealthArmor  )

Definition at line 147 of file sv_tmayhem.qc.

148{
150
152
153 if (StatusEffects_active(STATUSEFFECT_SpawnShield, frag_target) && autocvar_g_spawnshield_blockdamage >= 1) return;
154
155 entity frag_attacker = M_ARGV(1, entity);
156 float frag_deathtype = M_ARGV(6, float);
157 float frag_damage = M_ARGV(7, float);
158 float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
159 float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
160 float excess = max(0, frag_damage - damage_take - damage_save);
161 float total = frag_damage - excess;
162
163 if (total == 0) return;
164
167
168 entity scorer = NULL; // entity which needs their score to be updated
169
170 if (IS_PLAYER(frag_attacker))
171 {
172 // non-friendly fire
173 if (!SAME_TEAM(frag_target, frag_attacker))
174 frag_attacker.total_damage_dealt += total;
175
176 // friendly fire aka self damage
177 if (SAME_TEAM(frag_target, frag_attacker) || (frag_target == frag_attacker && !autocvar_g_tmayhem_scoring_disable_selfdamage2score))
178 frag_attacker.total_damage_dealt -= total;
179
180 scorer = frag_attacker;
181 }
182 else
183 {
184 // handle (environmental hazard) suiciding, check first if the player
185 // has a registered attacker who most likely pushed them there to
186 // avoid punishing pushed players as pushers are already rewarded
187 // deathtypes:
188 // kill = suicide, drown = drown in water/liquid, hurttrigger = out of the map void or hurt triggers inside maps like electric sparks
189 // camp = campcheck, lava = lava, slime = slime
190 // team change / rebalance suicides are currently not included
192 frag_deathtype == DEATH_KILL.m_id ||
193 frag_deathtype == DEATH_DROWN.m_id ||
194 frag_deathtype == DEATH_HURTTRIGGER.m_id ||
195 frag_deathtype == DEATH_CAMP.m_id ||
196 frag_deathtype == DEATH_LAVA.m_id ||
197 frag_deathtype == DEATH_SLIME.m_id ||
198 frag_deathtype == DEATH_SWAMP.m_id))
199 frag_target.total_damage_dealt -= total;
200
201 scorer = frag_target;
202 }
203
205}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
RES_ARMOR
Definition ent_cs.qc:155
float bound(float min, float value, float max)
float max(float f,...)
#define NULL
Definition post.qh:14
float autocvar_g_spawnshield_blockdamage
Definition player.qh:4
bool StatusEffects_active(StatusEffect this, entity actor)
float autocvar_g_tmayhem_scoring_damage_weight
Definition sv_tmayhem.qh:8
bool autocvar_g_tmayhem_scoring_disable_selfdamage2score
Definition sv_tmayhem.qh:9
#define SAME_TEAM(a, b)
Definition teams.qh:241

References autocvar_g_spawnshield_blockdamage, autocvar_g_tmayhem_scoring_damage_weight, autocvar_g_tmayhem_scoring_disable_selfdamage2score, bound(), entity(), frag_damage, frag_target, GetResource(), IS_PLAYER, M_ARGV, max(), MayhemCalculatePlayerScore(), NULL, RES_ARMOR, SAME_TEAM, and StatusEffects_active().

◆ MUTATOR_HOOKFUNCTION() [6/9]

MUTATOR_HOOKFUNCTION ( tmayhem ,
PlayerRegen  )

Definition at line 75 of file sv_tmayhem.qc.

76{
78 M_ARGV(2, float) = 0;
80 M_ARGV(3, float) = 0;
82}
bool autocvar_g_tmayhem_rot
Definition sv_tmayhem.qc:12
bool autocvar_g_tmayhem_regenerate
Definition sv_tmayhem.qc:11

References autocvar_g_tmayhem_regenerate, autocvar_g_tmayhem_rot, and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [7/9]

MUTATOR_HOOKFUNCTION ( tmayhem ,
reset_map_players  )

Definition at line 217 of file sv_tmayhem.qc.

218{
219 // reset damage dealt on reset
220 FOREACH_CLIENT(true, {
221 it.total_damage_dealt = 0;
222 });
223 return false;
224}
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:52

References FOREACH_CLIENT.

◆ MUTATOR_HOOKFUNCTION() [8/9]

MUTATOR_HOOKFUNCTION ( tmayhem ,
SetStartItems  )

Definition at line 60 of file sv_tmayhem.qc.

61{
63 if (!cvar("g_use_ammunition") || autocvar_g_tmayhem_unlimited_ammo)
65
73}
const int IT_UNLIMITED_AMMO
Definition item.qh:23
const int IT_UNLIMITED_SUPERWEAPONS
Definition item.qh:24
float cvar(string name)
float autocvar_g_tmayhem_start_ammo_nails
Definition sv_tmayhem.qc:23
float autocvar_g_tmayhem_start_health
Definition sv_tmayhem.qc:20
bool autocvar_g_tmayhem_unlimited_ammo
Definition sv_tmayhem.qc:18
float autocvar_g_tmayhem_start_ammo_shells
Definition sv_tmayhem.qc:22
float autocvar_g_tmayhem_start_armor
Definition sv_tmayhem.qc:21
float autocvar_g_tmayhem_start_ammo_fuel
Definition sv_tmayhem.qc:26
float autocvar_g_tmayhem_start_ammo_rockets
Definition sv_tmayhem.qc:24
float autocvar_g_tmayhem_start_ammo_cells
Definition sv_tmayhem.qc:25
float warmup_start_ammo_cells
Definition world.qh:105
float start_ammo_shells
Definition world.qh:84
float warmup_start_ammo_rockets
Definition world.qh:104
float warmup_start_ammo_shells
Definition world.qh:102
float start_ammo_fuel
Definition world.qh:88
int start_items
Definition world.qh:83
float warmup_start_ammo_nails
Definition world.qh:103
float start_ammo_cells
Definition world.qh:87
float warmup_start_health
Definition world.qh:107
float start_ammo_rockets
Definition world.qh:86
float start_armorvalue
Definition world.qh:97
float warmup_start_ammo_fuel
Definition world.qh:106
float start_health
Definition world.qh:96
float warmup_start_armorvalue
Definition world.qh:108
float start_ammo_nails
Definition world.qh:85

References autocvar_g_tmayhem_start_ammo_cells, autocvar_g_tmayhem_start_ammo_fuel, autocvar_g_tmayhem_start_ammo_nails, autocvar_g_tmayhem_start_ammo_rockets, autocvar_g_tmayhem_start_ammo_shells, autocvar_g_tmayhem_start_armor, autocvar_g_tmayhem_start_health, autocvar_g_tmayhem_unlimited_ammo, cvar(), IT_UNLIMITED_AMMO, IT_UNLIMITED_SUPERWEAPONS, start_ammo_cells, start_ammo_fuel, start_ammo_nails, start_ammo_rockets, start_ammo_shells, start_armorvalue, start_health, start_items, warmup_start_ammo_cells, warmup_start_ammo_fuel, warmup_start_ammo_nails, warmup_start_ammo_rockets, warmup_start_ammo_shells, warmup_start_armorvalue, and warmup_start_health.

◆ MUTATOR_HOOKFUNCTION() [9/9]

MUTATOR_HOOKFUNCTION ( tmayhem ,
SetWeaponArena  )

Definition at line 89 of file sv_tmayhem.qc.

90{
91 if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
93}
string autocvar_g_tmayhem_weaponarena
Definition sv_tmayhem.qc:13

References autocvar_g_tmayhem_weaponarena, and M_ARGV.

◆ tmayhem_DelayedInit()

void tmayhem_DelayedInit ( entity this)

Definition at line 31 of file sv_tmayhem.qc.

32{
34 teamplay_bitmask = Team_MapEnts_FindOrSpawn("tmayhem_team", BITS(bound(2, numteams, 4)));
35}
#define BITS(n)
Definition bits.qh:9
int autocvar_g_tmayhem_teams_override
Definition sv_tmayhem.qc:8
int autocvar_g_tmayhem_teams
Definition sv_tmayhem.qc:7
int Team_MapEnts_FindOrSpawn(string ent_classname, int defaultmask)
Finds any team map entities and returns their bitmask, else spawns them.
Definition teamplay.qc:56
int teamplay_bitmask
The set of currently available teams (AVAILABLE_TEAMS is the number of them).
Definition teamplay.qh:18

References autocvar_g_tmayhem_teams, autocvar_g_tmayhem_teams_override, BITS, bound(), entity(), Team_MapEnts_FindOrSpawn(), and teamplay_bitmask.

Referenced by tmayhem_Initialize().

◆ tmayhem_Initialize()

void tmayhem_Initialize ( )

Definition at line 37 of file sv_tmayhem.qc.

38{
39 GameRules_teams(true);
41
44
46}
const int INITPRIO_GAMETYPE
Definition constants.qh:94
void GameRules_limit_score(int limit)
Definition sv_rules.qc:22
void GameRules_teams(bool value)
Definition sv_rules.qc:3
void GameRules_limit_lead(int limit)
Definition sv_rules.qc:32
#define GameRules_spawning_teams(value)
Used to disable team spawns in team modes.
Definition sv_rules.qh:35
float autocvar_g_tmayhem_point_leadlimit
Definition sv_tmayhem.qc:5
void tmayhem_DelayedInit(entity this)
Definition sv_tmayhem.qc:31
bool autocvar_g_tmayhem_team_spawns
Definition sv_tmayhem.qc:9
float autocvar_g_tmayhem_point_limit
Definition sv_tmayhem.qc:4
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2229

References autocvar_g_tmayhem_point_leadlimit, autocvar_g_tmayhem_point_limit, autocvar_g_tmayhem_team_spawns, GameRules_limit_lead(), GameRules_limit_score(), GameRules_spawning_teams, GameRules_teams(), InitializeEntity(), INITPRIO_GAMETYPE, NULL, and tmayhem_DelayedInit().

Referenced by REGISTER_MUTATOR().

Variable Documentation

◆ autocvar_g_tmayhem_pickup_items

bool autocvar_g_tmayhem_pickup_items

Definition at line 16 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_pickup_items_remove_weapons_and_ammo

bool autocvar_g_tmayhem_pickup_items_remove_weapons_and_ammo

Definition at line 17 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_point_leadlimit

float autocvar_g_tmayhem_point_leadlimit

Definition at line 5 of file sv_tmayhem.qc.

Referenced by tmayhem_Initialize().

◆ autocvar_g_tmayhem_point_limit

float autocvar_g_tmayhem_point_limit

Definition at line 4 of file sv_tmayhem.qc.

Referenced by tmayhem_Initialize().

◆ autocvar_g_tmayhem_powerups

bool autocvar_g_tmayhem_powerups

Definition at line 14 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_regenerate

bool autocvar_g_tmayhem_regenerate

Definition at line 11 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_rot

bool autocvar_g_tmayhem_rot

Definition at line 12 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_selfdamage

bool autocvar_g_tmayhem_selfdamage

Definition at line 15 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_start_ammo_cells

float autocvar_g_tmayhem_start_ammo_cells = 180

Definition at line 25 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_start_ammo_fuel

float autocvar_g_tmayhem_start_ammo_fuel = 0

Definition at line 26 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_start_ammo_nails

float autocvar_g_tmayhem_start_ammo_nails = 320

Definition at line 23 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_start_ammo_rockets

float autocvar_g_tmayhem_start_ammo_rockets = 160

Definition at line 24 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_start_ammo_shells

float autocvar_g_tmayhem_start_ammo_shells = 60

Definition at line 22 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_start_armor

float autocvar_g_tmayhem_start_armor = 200

Definition at line 21 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_start_health

float autocvar_g_tmayhem_start_health = 200

Definition at line 20 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_team_spawns

bool autocvar_g_tmayhem_team_spawns

Definition at line 9 of file sv_tmayhem.qc.

Referenced by tmayhem_Initialize().

◆ autocvar_g_tmayhem_teams

int autocvar_g_tmayhem_teams

Definition at line 7 of file sv_tmayhem.qc.

Referenced by tmayhem_DelayedInit().

◆ autocvar_g_tmayhem_teams_override

int autocvar_g_tmayhem_teams_override

Definition at line 8 of file sv_tmayhem.qc.

Referenced by tmayhem_DelayedInit().

◆ autocvar_g_tmayhem_unlimited_ammo

bool autocvar_g_tmayhem_unlimited_ammo

Definition at line 18 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_tmayhem_weaponarena

string autocvar_g_tmayhem_weaponarena

Definition at line 13 of file sv_tmayhem.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ total_damage_dealt

float total_damage_dealt

Definition at line 28 of file sv_tmayhem.qc.