Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_tmayhem.qc
Go to the documentation of this file.
1#include "sv_tmayhem.qh"
3
6
10
19
27
29
30
36
47
48/*
49MUTATOR_HOOKFUNCTION(tmayhem, Scores_CountFragsRemaining)
50{
51 // do not announce remaining frags, upscaled score count doesn't match well with this
52 // when scorelimit is set to 1000 it would announce 997, 998 and 999 score counts
53 // usually a single shot which deals ~40-80 dmg gives 2 or 3 score
54 // this usually would cause a "2 fra..." announcement to be played as the match ends
55 // without leaving anyone time to even process the announcement
56 return false;
57}
58*/
59
74
76{
78 M_ARGV(2, float) = 0;
80 M_ARGV(3, float) = 0;
82}
83
84MUTATOR_HOOKFUNCTION(tmayhem, ForbidThrowCurrentWeapon)
85{
86 return true;
87}
88
90{
91 if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "")
93}
94
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}
127
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}
146
147MUTATOR_HOOKFUNCTION(tmayhem, PlayerDamage_SplitHealthArmor)
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}
206
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}
216
217MUTATOR_HOOKFUNCTION(tmayhem, reset_map_players)
218{
219 // reset damage dealt on reset
220 FOREACH_CLIENT(true, {
221 it.total_damage_dealt = 0;
222 });
223 return false;
224}
225
const int CBC_ORDER_FIRST
Definition base.qh:10
#define MUTATOR_HOOKFUNCTION(...)
Definition base.qh:335
#define BITS(n)
Definition bits.qh:9
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
const int IT_UNLIMITED_AMMO
Definition item.qh:23
const int IT_UNLIMITED_SUPERWEAPONS
Definition item.qh:24
#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
const int INITPRIO_GAMETYPE
Definition constants.qh:94
RES_ARMOR
Definition ent_cs.qc:155
float bound(float min, float value, float max)
float cvar(string name)
float max(float f,...)
#define NULL
Definition post.qh:14
int autocvar_g_pickup_items
Definition items.qh:11
float autocvar_g_spawnshield_blockdamage
Definition player.qh:4
bool StatusEffects_active(StatusEffect this, entity actor)
float frag_damage
Definition sv_ctf.qc:2315
entity frag_target
Definition sv_ctf.qc:2314
void MayhemCalculatePlayerScore(entity scorer)
Definition sv_mayhem.qc:145
float total_damage_dealt
Definition sv_mayhem.qc:31
int autocvar_g_powerups
Definition sv_powerups.qh:7
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
int autocvar_g_tmayhem_teams_override
Definition sv_tmayhem.qc:8
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
int autocvar_g_tmayhem_teams
Definition sv_tmayhem.qc:7
bool autocvar_g_tmayhem_rot
Definition sv_tmayhem.qc:12
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
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_point_leadlimit
Definition sv_tmayhem.qc:5
bool autocvar_g_tmayhem_selfdamage
Definition sv_tmayhem.qc:15
float autocvar_g_tmayhem_start_ammo_fuel
Definition sv_tmayhem.qc:26
float autocvar_g_tmayhem_start_ammo_rockets
Definition sv_tmayhem.qc:24
void tmayhem_Initialize()
Definition sv_tmayhem.qc:37
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_start_ammo_cells
Definition sv_tmayhem.qc:25
string autocvar_g_tmayhem_weaponarena
Definition sv_tmayhem.qc:13
bool autocvar_g_tmayhem_regenerate
Definition sv_tmayhem.qc:11
float autocvar_g_tmayhem_point_limit
Definition sv_tmayhem.qc:4
float autocvar_g_tmayhem_scoring_damage_weight
Definition sv_tmayhem.qh:8
bool autocvar_g_tmayhem_scoring_disable_selfdamage2score
Definition sv_tmayhem.qh:9
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
#define SAME_TEAM(a, b)
Definition teams.qh:241
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:52
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2229
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