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)
 MUTATOR_HOOKFUNCTION (tmayhem, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
void tmayhem_DelayedInit (entity this)
void tmayhem_Initialize ()
void tmayhem_SpawnTeam (string teamname, int teamcolor)

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/10]

MUTATOR_HOOKFUNCTION ( tmayhem ,
Damage_Calculate  )

Definition at line 160 of file sv_tmayhem.qc.

161{
162 entity frag_attacker = M_ARGV(1, entity);
164 float frag_deathtype = M_ARGV(3, float);
165 float frag_damage = M_ARGV(4, float);
166 float frag_mirrordamage = M_ARGV(5, float);
167
168 if (IS_PLAYER(frag_target)) // nullify self-damage if self-damage is disabled and always nullify splat
169 if (!IS_DEAD(frag_target)) // but enable anyone to gib corpses, even their own corpses with delayed damage
170 if ((autocvar_g_tmayhem_selfdamage == 0 && frag_target == frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
171 frag_damage = 0;
172
173 frag_mirrordamage = 0; // no mirror damaging
174
175 M_ARGV(4, float) = frag_damage;
176 M_ARGV(5, float) = frag_mirrordamage;
177}
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:245
#define IS_PLAYER(s)
Definition player.qh:243
float frag_damage
Definition sv_ctf.qc:2322
entity frag_target
Definition sv_ctf.qc:2321
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/10]

MUTATOR_HOOKFUNCTION ( tmayhem ,
FilterItem  )

Definition at line 127 of file sv_tmayhem.qc.

128{
129 entity item = M_ARGV(0, entity);
130
131 // enable powerups if forced globally or global accepts gametypes to have powerups according to their own settings
133 if (item.itemdef.instanceOfPowerup){
134 return false;
135 }
136 }
137 // disabled powerups if forced off globally or in this gametype
139 if (item.itemdef.instanceOfPowerup){
140 return true;
141 }
142 }
143 // remove all items if items are forced off globally
144 if (autocvar_g_pickup_items == 0){
145 return true;
146 }
147 // if items are switched on in this gametype allow the removal of weapons and ammo still
149 if (item.itemdef.instanceOfAmmo || item.itemdef.instanceOfWeaponPickup){
150 return true;
151 }
152 }
153 // remove items if not globally set to follow mode's settings and locally set off
155 return true;
156 }
157 return false;
158}
int autocvar_g_pickup_items
Definition items.qh:10
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/10]

MUTATOR_HOOKFUNCTION ( tmayhem ,
ForbidThrowCurrentWeapon  )

Definition at line 116 of file sv_tmayhem.qc.

117{
118 return true;
119}

◆ MUTATOR_HOOKFUNCTION() [4/10]

MUTATOR_HOOKFUNCTION ( tmayhem ,
GiveFragsForKill ,
CBC_ORDER_FIRST  )

Definition at line 239 of file sv_tmayhem.qc.

240{
241 entity frag_attacker = M_ARGV(0, entity);
242 M_ARGV(2, float) = 0; // score to give for the frag directly
243
244 if (IS_PLAYER(frag_attacker)) MayhemCalculatePlayerScore(frag_attacker);
245
246 return true;
247}
void MayhemCalculatePlayerScore(entity scorer)
Definition sv_mayhem.qc:145

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

◆ MUTATOR_HOOKFUNCTION() [5/10]

MUTATOR_HOOKFUNCTION ( tmayhem ,
PlayerDamage_SplitHealthArmor  )

Definition at line 179 of file sv_tmayhem.qc.

180{
182
184
185 if (StatusEffects_active(STATUSEFFECT_SpawnShield, frag_target) && autocvar_g_spawnshield_blockdamage >= 1) return;
186
187 entity frag_attacker = M_ARGV(1, entity);
188 float frag_deathtype = M_ARGV(6, float);
189 float frag_damage = M_ARGV(7, float);
190 float damage_take = bound(0, M_ARGV(4, float), GetResource(frag_target, RES_HEALTH));
191 float damage_save = bound(0, M_ARGV(5, float), GetResource(frag_target, RES_ARMOR));
192 float excess = max(0, frag_damage - damage_take - damage_save);
193 float total = frag_damage - excess;
194
195 if (total == 0) return;
196
199
200 entity scorer = NULL; // entity which needs their score to be updated
201
202 if (IS_PLAYER(frag_attacker))
203 {
204 // non-friendly fire
205 if (!SAME_TEAM(frag_target, frag_attacker))
206 frag_attacker.total_damage_dealt += total;
207
208 // friendly fire aka self damage
209 if (SAME_TEAM(frag_target, frag_attacker) || (frag_target == frag_attacker && !autocvar_g_tmayhem_scoring_disable_selfdamage2score))
210 frag_attacker.total_damage_dealt -= total;
211
212 scorer = frag_attacker;
213 }
214 else
215 {
216 // handle (environmental hazard) suiciding, check first if the player
217 // has a registered attacker who most likely pushed them there to
218 // avoid punishing pushed players as pushers are already rewarded
219 // deathtypes:
220 // kill = suicide, drown = drown in water/liquid, hurttrigger = out of the map void or hurt triggers inside maps like electric sparks
221 // camp = campcheck, lava = lava, slime = slime
222 // team change / rebalance suicides are currently not included
224 frag_deathtype == DEATH_KILL.m_id ||
225 frag_deathtype == DEATH_DROWN.m_id ||
226 frag_deathtype == DEATH_HURTTRIGGER.m_id ||
227 frag_deathtype == DEATH_CAMP.m_id ||
228 frag_deathtype == DEATH_LAVA.m_id ||
229 frag_deathtype == DEATH_SLIME.m_id ||
230 frag_deathtype == DEATH_SWAMP.m_id))
231 frag_target.total_damage_dealt -= total;
232
233 scorer = frag_target;
234 }
235
237}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
RES_ARMOR
Definition ent_cs.qc:130
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/10]

MUTATOR_HOOKFUNCTION ( tmayhem ,
PlayerRegen  )

Definition at line 107 of file sv_tmayhem.qc.

108{
110 M_ARGV(2, float) = 0;
112 M_ARGV(3, float) = 0;
114}
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/10]

MUTATOR_HOOKFUNCTION ( tmayhem ,
reset_map_players  )

Definition at line 249 of file sv_tmayhem.qc.

250{
251 // reset damage dealt on reset
252 FOREACH_CLIENT(true, {
253 it.total_damage_dealt = 0;
254 });
255 return false;
256}
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References FOREACH_CLIENT.

◆ MUTATOR_HOOKFUNCTION() [8/10]

MUTATOR_HOOKFUNCTION ( tmayhem ,
SetStartItems  )

Definition at line 92 of file sv_tmayhem.qc.

93{
95 if (!cvar("g_use_ammunition") || autocvar_g_tmayhem_unlimited_ammo)
97
105}
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/10]

MUTATOR_HOOKFUNCTION ( tmayhem ,
SetWeaponArena  )

Definition at line 121 of file sv_tmayhem.qc.

122{
123 if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
125}
string autocvar_g_tmayhem_weaponarena
Definition sv_tmayhem.qc:13

References autocvar_g_tmayhem_weaponarena, and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [10/10]

Definition at line 75 of file sv_tmayhem.qc.

76{
77 M_ARGV(1, string) = "tmayhem_team";
78}

References CBC_ORDER_EXCLUSIVE, M_ARGV, and TeamBalance_CheckAllowedTeams().

◆ tmayhem_DelayedInit()

void tmayhem_DelayedInit ( entity this)

Definition at line 41 of file sv_tmayhem.qc.

42{
43 // if no teams are found, spawn defaults
44 if (find(NULL, classname, "tmayhem_team") == NULL)
45 {
46 LOG_TRACE("No \"tmayhem_team\" entities found on this map, creating them anyway.");
47
49 if(numteams < 2) { numteams = autocvar_g_tmayhem_teams; }
50
51 int teams = BITS(bound(2, numteams, 4));
52 if(teams & BIT(0))
54 if(teams & BIT(1))
56 if(teams & BIT(2))
58 if(teams & BIT(3))
60 }
61}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
#define BITS(n)
Definition bits.qh:9
entity teams
Definition main.qh:58
string classname
#define LOG_TRACE(...)
Definition log.qh:76
entity find(entity start,.string field, string match)
int autocvar_g_tmayhem_teams_override
Definition sv_tmayhem.qc:8
int autocvar_g_tmayhem_teams
Definition sv_tmayhem.qc:7
void tmayhem_SpawnTeam(string teamname, int teamcolor)
Definition sv_tmayhem.qc:31
const int NUM_TEAM_2
Definition teams.qh:14
const int NUM_TEAM_4
Definition teams.qh:16
const int NUM_TEAM_3
Definition teams.qh:15
const int NUM_TEAM_1
Definition teams.qh:13

References autocvar_g_tmayhem_teams, autocvar_g_tmayhem_teams_override, BIT, BITS, bound(), classname, entity(), find(), LOG_TRACE, NULL, NUM_TEAM_1, NUM_TEAM_2, NUM_TEAM_3, NUM_TEAM_4, teams, and tmayhem_SpawnTeam().

Referenced by tmayhem_Initialize().

◆ tmayhem_Initialize()

void tmayhem_Initialize ( )

Definition at line 63 of file sv_tmayhem.qc.

64{
65 GameRules_teams(true);
67
70
72}
const int INITPRIO_GAMETYPE
Definition constants.qh:94
void GameRules_limit_score(int limit)
Definition sv_rules.qc:23
void GameRules_teams(bool value)
Definition sv_rules.qc:3
void GameRules_limit_lead(int limit)
Definition sv_rules.qc:33
#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:41
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:2209

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().

◆ tmayhem_SpawnTeam()

void tmayhem_SpawnTeam ( string teamname,
int teamcolor )

Definition at line 31 of file sv_tmayhem.qc.

32{
33 entity this = new_pure(tmayhem_team);
34 this.netname = teamname;
35 this.cnt = teamcolor - 1;
36 this.team = teamcolor;
37 this.spawnfunc_checked = true;
38 //spawnfunc_tmayhem_team(this);
39}
string netname
Definition powerups.qc:20
float cnt
Definition powerups.qc:24
int team
Definition main.qh:188
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
bool spawnfunc_checked
Definition spawnfunc.qh:8

References cnt, entity(), netname, new_pure, spawnfunc_checked, and team.

Referenced by tmayhem_DelayedInit().

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.