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

Go to the source code of this file.

Functions

 MUTATOR_HOOKFUNCTION (ok, BuildMutatorsPrettyString)
 MUTATOR_HOOKFUNCTION (ok, BuildMutatorsString)
 MUTATOR_HOOKFUNCTION (ok, Damage_Calculate, CBC_ORDER_LAST)
 MUTATOR_HOOKFUNCTION (ok, FilterItem)
 MUTATOR_HOOKFUNCTION (ok, ForbidRandomStartWeapons)
 MUTATOR_HOOKFUNCTION (ok, ForbidThrowCurrentWeapon)
 MUTATOR_HOOKFUNCTION (ok, Item_RespawnCountdown)
 MUTATOR_HOOKFUNCTION (ok, Item_ScheduleRespawn)
 MUTATOR_HOOKFUNCTION (ok, MonsterDropItem)
 MUTATOR_HOOKFUNCTION (ok, PlayerDies)
 MUTATOR_HOOKFUNCTION (ok, PlayerPreThink)
 MUTATOR_HOOKFUNCTION (ok, PlayerWeaponSelect)
 MUTATOR_HOOKFUNCTION (ok, RandomItems_GetRandomItemClassName)
 MUTATOR_HOOKFUNCTION (ok, SetModname)
 MUTATOR_HOOKFUNCTION (ok, SetStartItems, CBC_ORDER_LAST)
 MUTATOR_HOOKFUNCTION (ok, SetWeaponArena)
void ok_DropItem (entity this, entity attacker, string itemlist, float itemlifetime)
bool ok_HandleItemWaypoints (entity e)
string RandomItems_GetRandomOverkillItemClassName (string prefix)
 Returns a random classname of the overkill item.

Variables

bool autocvar_g_overkill_blaster_keepdamage = false
bool autocvar_g_overkill_blaster_keepforce = false
bool autocvar_g_overkill_itemwaypoints = true
string autocvar_g_overkill_loot_monster = "armor_small"
float autocvar_g_overkill_loot_monster_time = 5
string autocvar_g_overkill_loot_player = "armor_small"
float autocvar_g_overkill_loot_player_time = 5
bool autocvar_g_overkill_powerups_replace
Weapon ok_lastwep [MAX_WEAPONSLOTS]

Function Documentation

◆ MUTATOR_HOOKFUNCTION() [1/16]

MUTATOR_HOOKFUNCTION ( ok ,
BuildMutatorsPrettyString  )

Definition at line 288 of file sv_overkill.qc.

289{
290 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Overkill");
291}
#define M_ARGV(x, type)
Definition events.qh:17
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References M_ARGV, and strcat().

◆ MUTATOR_HOOKFUNCTION() [2/16]

MUTATOR_HOOKFUNCTION ( ok ,
BuildMutatorsString  )

Definition at line 283 of file sv_overkill.qc.

284{
285 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":OK");
286}

References M_ARGV, and strcat().

◆ MUTATOR_HOOKFUNCTION() [3/16]

MUTATOR_HOOKFUNCTION ( ok ,
Damage_Calculate ,
CBC_ORDER_LAST  )

Definition at line 65 of file sv_overkill.qc.

66{
67 entity frag_attacker = M_ARGV(1, entity);
69 float frag_deathtype = M_ARGV(3, float);
70
72 if(DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
73 {
74 if(frag_attacker != frag_target)
75 if(!STAT(FROZEN, frag_target))
78 M_ARGV(6, vector) = '0 0 0'; // force
79
81 M_ARGV(4, float) = 0; // damage
82 }
83}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define IS_DEAD(s)
Definition player.qh:245
#define IS_PLAYER(s)
Definition player.qh:243
#define DEATH_ISWEAPON(t, w)
Definition all.qh:46
#define STAT(...)
Definition stats.qh:82
vector
Definition self.qh:92
entity frag_target
Definition sv_ctf.qc:2321
bool autocvar_g_overkill_blaster_keepdamage
bool autocvar_g_overkill_blaster_keepforce
Definition sv_overkill.qc:9
#define IS_TURRET(v)
Definition utils.qh:23
#define IS_VEHICLE(v)
Definition utils.qh:22

References autocvar_g_overkill_blaster_keepdamage, autocvar_g_overkill_blaster_keepforce, CBC_ORDER_LAST, DEATH_ISWEAPON, entity(), frag_target, IS_DEAD, IS_PLAYER, IS_TURRET, IS_VEHICLE, M_ARGV, STAT, and vector.

◆ MUTATOR_HOOKFUNCTION() [4/16]

MUTATOR_HOOKFUNCTION ( ok ,
FilterItem  )

Definition at line 219 of file sv_overkill.qc.

220{
221 entity item = M_ARGV(0, entity);
222
223 if (item.ok_item)
224 {
225 return false;
226 }
227 switch(item.itemdef)
228 {
229 case ITEM_HealthMega: return autocvar_g_overkill_filter_healthmega;
230 case ITEM_ArmorMedium: return autocvar_g_overkill_filter_armormedium;
231 case ITEM_ArmorBig: return autocvar_g_overkill_filter_armorbig;
232 case ITEM_ArmorMega: return autocvar_g_overkill_filter_armormega;
233 }
235 {
236 return true;
237 }
238 if (item.classname == "item_strength")
239 {
240 entity wep = spawn();
241 Item_CopyFields(item, wep);
242 wep.ok_item = true;
244 wep.pickup_anyway = true;
245 wep.itemdef = WEP_OVERKILL_HMG;
246 wep.lifetime = -1;
247 Item_Initialise(wep);
248 return true;
249 }
250 else if (item.classname == "item_shield")
251 {
252 entity wep = spawn();
253 Item_CopyFields(item, wep);
254 wep.ok_item = true;
256 wep.pickup_anyway = true;
257 wep.itemdef = WEP_OVERKILL_RPC;
258 wep.lifetime = -1;
259 Item_Initialise(wep);
260 return true;
261 }
262 return true;
263}
#define spawn
bool Item_Initialise(entity item)
An optimised and generic way to initialise items (loot or permanent)
Definition spawning.qc:27
void Item_CopyFields(entity this, entity to)
Definition items.qc:850
bool autocvar_g_overkill_powerups_replace
Definition sv_overkill.qc:7
bool autocvar_g_overkill_filter_armormega
Definition sv_overkill.qh:7
bool autocvar_g_overkill_filter_armorbig
Definition sv_overkill.qh:6
bool autocvar_g_overkill_filter_healthmega
Definition sv_overkill.qh:4
bool autocvar_g_overkill_filter_armormedium
Definition sv_overkill.qh:5
int autocvar_g_powerups
Definition sv_powerups.qh:7
float autocvar_g_pickup_respawntime_superweapon
Definition spawning.qh:7

References autocvar_g_overkill_filter_armorbig, autocvar_g_overkill_filter_armormedium, autocvar_g_overkill_filter_armormega, autocvar_g_overkill_filter_healthmega, autocvar_g_overkill_powerups_replace, autocvar_g_pickup_respawntime_superweapon, autocvar_g_powerups, entity(), Item_CopyFields(), Item_Initialise(), M_ARGV, and spawn.

◆ MUTATOR_HOOKFUNCTION() [5/16]

MUTATOR_HOOKFUNCTION ( ok ,
ForbidRandomStartWeapons  )

Definition at line 164 of file sv_overkill.qc.

165{
166 return true;
167}

◆ MUTATOR_HOOKFUNCTION() [6/16]

MUTATOR_HOOKFUNCTION ( ok ,
ForbidThrowCurrentWeapon  )

Definition at line 129 of file sv_overkill.qc.

130{
131 return true;
132}

◆ MUTATOR_HOOKFUNCTION() [7/16]

MUTATOR_HOOKFUNCTION ( ok ,
Item_RespawnCountdown  )

Definition at line 207 of file sv_overkill.qc.

208{
209 entity item = M_ARGV(0, entity);
210 return ok_HandleItemWaypoints(item);
211}
bool ok_HandleItemWaypoints(entity e)

References entity(), Item_RespawnCountdown(), M_ARGV, and ok_HandleItemWaypoints().

◆ MUTATOR_HOOKFUNCTION() [8/16]

MUTATOR_HOOKFUNCTION ( ok ,
Item_ScheduleRespawn  )

Definition at line 213 of file sv_overkill.qc.

214{
215 entity item = M_ARGV(0, entity);
216 return ok_HandleItemWaypoints(item);
217}

References entity(), Item_ScheduleRespawn(), M_ARGV, and ok_HandleItemWaypoints().

◆ MUTATOR_HOOKFUNCTION() [9/16]

MUTATOR_HOOKFUNCTION ( ok ,
MonsterDropItem  )

Definition at line 119 of file sv_overkill.qc.

120{
121 entity mon = M_ARGV(0, entity);
122 entity frag_attacker = M_ARGV(2, entity);
123
125
126 M_ARGV(1, string) = ""; // item drops handled
127}
string autocvar_g_overkill_loot_monster
float autocvar_g_overkill_loot_monster_time
void ok_DropItem(entity this, entity attacker, string itemlist, float itemlifetime)

References autocvar_g_overkill_loot_monster, autocvar_g_overkill_loot_monster_time, entity(), M_ARGV, and ok_DropItem().

◆ MUTATOR_HOOKFUNCTION() [10/16]

MUTATOR_HOOKFUNCTION ( ok ,
PlayerDies  )

Definition at line 103 of file sv_overkill.qc.

104{
105 entity frag_attacker = M_ARGV(1, entity);
107
108 entity attacker = ((IS_PLAYER(frag_attacker)) ? frag_attacker : frag_target);
110
111 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
112 {
113 .entity weaponentity = weaponentities[slot];
114
115 frag_target.ok_lastwep[slot] = frag_target.(weaponentity).m_switchweapon;
116 }
117}
string autocvar_g_overkill_loot_player
float autocvar_g_overkill_loot_player_time
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
Weapon m_switchweapon
Definition wepent.qh:25

References autocvar_g_overkill_loot_player, autocvar_g_overkill_loot_player_time, entity(), frag_target, IS_PLAYER, M_ARGV, m_switchweapon, MAX_WEAPONSLOTS, ok_DropItem(), and weaponentities.

◆ MUTATOR_HOOKFUNCTION() [11/16]

MUTATOR_HOOKFUNCTION ( ok ,
PlayerPreThink  )

Definition at line 134 of file sv_overkill.qc.

135{
136 if (game_stopped)
137 {
138 return;
139 }
140 entity player = M_ARGV(0, entity);
141 if (!IS_PLAYER(player) || IS_DEAD(player))
142 {
143 return;
144 }
145 if (!PHYS_INPUT_BUTTON_ATCK2(player) || weaponLocked(player) ||
147 {
148 return;
149 }
150 // Allow secondary blaster during countdown.
151 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
152 {
153 .entity weaponentity = weaponentities[slot];
154 Weapon weapon = player.(weaponentity).m_weapon;
155 if (weapon == WEP_Null && slot != 0)
156 {
157 continue;
158 }
159 weapon.wr_think(weapon, player, weaponentity, 2);
160 }
161 PHYS_INPUT_BUTTON_ATCK2(player) = false;
162}
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:44
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition player.qh:152
float game_stopped
Definition stats.qh:81
float weapon
Definition progsdefs.qc:139
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
bool weaponLocked(entity player)
Weapon m_weapon
Definition wepent.qh:26

References entity(), game_stopped, IS_DEAD, IS_PLAYER, M_ARGV, m_weapon, MAX_WEAPONSLOTS, PHYS_INPUT_BUTTON_ATCK2, PlayerPreThink, round_handler_IsActive, round_handler_IsRoundStarted, weapon, weaponentities, and weaponLocked().

◆ MUTATOR_HOOKFUNCTION() [12/16]

MUTATOR_HOOKFUNCTION ( ok ,
PlayerWeaponSelect  )

Definition at line 169 of file sv_overkill.qc.

170{
171 entity player = M_ARGV(0, entity);
172
173 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
174 {
175 .entity weaponentity = weaponentities[slot];
176 entity thiswep = player.(weaponentity);
177
178 if(player.ok_lastwep[slot] && player.ok_lastwep[slot] != WEP_Null)
179 {
180 Weapon newwep = player.ok_lastwep[slot];
181 if(player.ok_lastwep[slot] == WEP_OVERKILL_HMG)
182 newwep = WEP_OVERKILL_MACHINEGUN;
183 if(player.ok_lastwep[slot] == WEP_OVERKILL_RPC)
184 newwep = WEP_OVERKILL_NEX;
185 thiswep.m_switchweapon = newwep;
186 player.ok_lastwep[slot] = WEP_Null;
187 }
188 }
189}

References entity(), M_ARGV, MAX_WEAPONSLOTS, and weaponentities.

◆ MUTATOR_HOOKFUNCTION() [13/16]

MUTATOR_HOOKFUNCTION ( ok ,
RandomItems_GetRandomItemClassName  )

Definition at line 58 of file sv_overkill.qc.

59{
61 M_ARGV(0, string));
62 return true;
63}
string RandomItems_GetRandomOverkillItemClassName(string prefix)
Returns a random classname of the overkill item.

References M_ARGV, RandomItems_GetRandomItemClassName(), and RandomItems_GetRandomOverkillItemClassName().

◆ MUTATOR_HOOKFUNCTION() [14/16]

MUTATOR_HOOKFUNCTION ( ok ,
SetModname  )

Definition at line 293 of file sv_overkill.qc.

294{
295 M_ARGV(0, string) = "Overkill";
296 return true;
297}

References M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [15/16]

MUTATOR_HOOKFUNCTION ( ok ,
SetStartItems ,
CBC_ORDER_LAST  )

Definition at line 265 of file sv_overkill.qc.

266{
267 WepSet ok_start_items = (WEPSET(OVERKILL_MACHINEGUN) | WEPSET(OVERKILL_NEX) | WEPSET(OVERKILL_SHOTGUN));
268
269 if(WEP_OVERKILL_RPC.weaponstart > 0) { ok_start_items |= WEPSET(OVERKILL_RPC); }
270 if(WEP_OVERKILL_HMG.weaponstart > 0) { ok_start_items |= WEPSET(OVERKILL_HMG); }
271
273
274 start_weapons = warmup_start_weapons = ok_start_items;
275}
const int IT_UNLIMITED_AMMO
Definition item.qh:23
#define WEPSET(id)
Definition all.qh:45
vector WepSet
Definition weapon.qh:14
WepSet start_weapons
Definition world.qh:80
int start_items
Definition world.qh:83
WepSet warmup_start_weapons
Definition world.qh:98

References CBC_ORDER_LAST, IT_UNLIMITED_AMMO, start_items, start_weapons, warmup_start_weapons, and WEPSET.

◆ MUTATOR_HOOKFUNCTION() [16/16]

MUTATOR_HOOKFUNCTION ( ok ,
SetWeaponArena  )

Definition at line 277 of file sv_overkill.qc.

278{
279 // turn weapon arena off
280 M_ARGV(0, string) = "off";
281}

References M_ARGV.

◆ ok_DropItem()

void ok_DropItem ( entity this,
entity attacker,
string itemlist,
float itemlifetime )

Definition at line 85 of file sv_overkill.qc.

86{
87 if (itemlifetime <= 0)
88 return;
89
90 entity loot_itemdef = Item_RandomFromList(itemlist);
91 if (!loot_itemdef)
92 return;
93
94 entity e = spawn();
95 e.ok_item = true;
96 e.itemdef = loot_itemdef;
97 e.origin = this.origin + '0 0 32';
98 e.velocity = '0 0 200' + normalize(attacker.origin - this.origin) * 500;
99 e.lifetime = itemlifetime;
101}
vector origin
entity Item_RandomFromList(string itemlist)
Takes a space-separated list of netnames, returns the itemdef of one of them (or NULL if none are ava...
Definition spawning.qc:71
vector normalize(vector v)

References entity(), Item_Initialise(), Item_RandomFromList(), normalize(), origin, and spawn.

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ ok_HandleItemWaypoints()

bool ok_HandleItemWaypoints ( entity e)

Definition at line 191 of file sv_overkill.qc.

192{
194 return false; // don't handle it
195
196 switch(e.itemdef)
197 {
198 case ITEM_HealthMega: return true;
199 case ITEM_ArmorMedium: return true;
200 case ITEM_ArmorBig: return true;
201 case ITEM_ArmorMega: return true;
202 }
203
204 return false;
205}
bool autocvar_g_overkill_itemwaypoints
Definition sv_overkill.qc:8

References autocvar_g_overkill_itemwaypoints, and entity().

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ RandomItems_GetRandomOverkillItemClassName()

string RandomItems_GetRandomOverkillItemClassName ( string prefix)

Returns a random classname of the overkill item.

Parameters
[in]prefixPrefix of the cvars that hold probabilities.
Returns
Random classname of the overkill item.

Definition at line 21 of file sv_overkill.qc.

22{
26 {
27 string cvar_name = sprintf("g_%s_%s_probability", prefix,
28 it.m_canonical_spawnfunc);
29 if (!(cvar_type(cvar_name) & CVAR_TYPEFLAG_EXISTS))
30 {
31 LOG_WARNF("Random items: cvar %s doesn't exist.", cvar_name);
32 continue;
33 }
34 RandomSelection_AddString(it.m_canonical_spawnfunc, cvar(cvar_name), 1);
35 });
36 string cvar_name = sprintf("g_%s_weapon_okhmg_probability", prefix);
37 if (!(cvar_type(cvar_name) & CVAR_TYPEFLAG_EXISTS))
38 {
39 LOG_WARNF("Random items: cvar %s doesn't exist.", cvar_name);
40 }
41 else
42 {
43 RandomSelection_AddString("weapon_okhmg", cvar(cvar_name), 1);
44 }
45 cvar_name = sprintf("g_%s_weapon_okrpc_probability", prefix);
46 if (!(cvar_type(cvar_name) & CVAR_TYPEFLAG_EXISTS))
47 {
48 LOG_WARNF("Random items: cvar %s doesn't exist.", cvar_name);
49 }
50 else
51 {
52 RandomSelection_AddString("weapon_okrpc", cvar(cvar_name), 1);
53 }
55}
@ ITEM_FLAG_MUTATORBLOCKED
Definition item.qh:121
float CVAR_TYPEFLAG_EXISTS
#define IL_EACH(this, cond, body)
bool Item_IsDefinitionAllowed(entity definition)
Checks whether the items with the specified definition are allowed to spawn.
Definition spawning.qc:17
#define LOG_WARNF(...)
Definition log.qh:62
float cvar(string name)
ERASEABLE void RandomSelection_Init()
Definition random.qc:4
string RandomSelection_chosen_string
Definition random.qh:7
#define RandomSelection_AddString(s, weight, priority)
Definition random.qh:16
IntrusiveList g_overkill_items

References cvar(), CVAR_TYPEFLAG_EXISTS, g_overkill_items, IL_EACH, ITEM_FLAG_MUTATORBLOCKED, Item_IsDefinitionAllowed(), LOG_WARNF, RandomSelection_AddString, RandomSelection_chosen_string, and RandomSelection_Init().

Referenced by MUTATOR_HOOKFUNCTION().

Variable Documentation

◆ autocvar_g_overkill_blaster_keepdamage

bool autocvar_g_overkill_blaster_keepdamage = false

Definition at line 10 of file sv_overkill.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_overkill_blaster_keepforce

bool autocvar_g_overkill_blaster_keepforce = false

Definition at line 9 of file sv_overkill.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_overkill_itemwaypoints

bool autocvar_g_overkill_itemwaypoints = true

Definition at line 8 of file sv_overkill.qc.

Referenced by ok_HandleItemWaypoints().

◆ autocvar_g_overkill_loot_monster

string autocvar_g_overkill_loot_monster = "armor_small"

Definition at line 13 of file sv_overkill.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_overkill_loot_monster_time

float autocvar_g_overkill_loot_monster_time = 5

Definition at line 14 of file sv_overkill.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_overkill_loot_player

string autocvar_g_overkill_loot_player = "armor_small"

Definition at line 11 of file sv_overkill.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_overkill_loot_player_time

float autocvar_g_overkill_loot_player_time = 5

Definition at line 12 of file sv_overkill.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ autocvar_g_overkill_powerups_replace

bool autocvar_g_overkill_powerups_replace

Definition at line 7 of file sv_overkill.qc.

Referenced by MUTATOR_HOOKFUNCTION().

◆ ok_lastwep

Weapon ok_lastwep[MAX_WEAPONSLOTS]

Definition at line 16 of file sv_overkill.qc.