Xonotic
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:

Go to the source code of this file.

Functions

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

Variables

bool autocvar_g_overkill_itemwaypoints = true
 
bool autocvar_g_overkill_powerups_replace
 
Weapon ok_lastwep [MAX_WEAPONSLOTS]
 

Function Documentation

◆ MUTATOR_HOOKFUNCTION() [1/16]

MUTATOR_HOOKFUNCTION ( ok  ,
RandomItems_GetRandomItemClassName   
)

Definition at line 53 of file sv_overkill.qc.

References M_ARGV, and RandomItems_GetRandomOverkillItemClassName().

54 {
56  M_ARGV(0, string));
57  return true;
58 }
string RandomItems_GetRandomOverkillItemClassName(string prefix)
Returns a random classname of the overkill item.
Definition: sv_overkill.qc:16
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [2/16]

MUTATOR_HOOKFUNCTION ( ok  ,
Damage_Calculate  ,
CBC_ORDER_LAST   
)

Definition at line 60 of file sv_overkill.qc.

References DEATH_ISWEAPON, entity(), IS_DEAD, IS_PLAYER, IS_TURRET, IS_VEHICLE, M_ARGV, and vector().

61 {
62  entity frag_attacker = M_ARGV(1, entity);
63  entity frag_target = M_ARGV(2, entity);
64  float frag_deathtype = M_ARGV(3, float);
65 
66  if(IS_PLAYER(frag_attacker) && (IS_PLAYER(frag_target) || IS_VEHICLE(frag_target) || IS_TURRET(frag_target)))
67  if(DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
68  {
69  if(frag_attacker != frag_target)
70  if(!STAT(FROZEN, frag_target))
71  if(!IS_DEAD(frag_target))
72  {
73  M_ARGV(6, vector) = '0 0 0'; // force
74  }
75 
76  M_ARGV(4, float) = 0; // damage
77  }
78 }
entity() spawn
#define IS_TURRET(v)
Definition: utils.qh:23
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define IS_VEHICLE(v)
Definition: utils.qh:22
#define DEATH_ISWEAPON(t, w)
Definition: all.qh:42
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [3/16]

MUTATOR_HOOKFUNCTION ( ok  ,
PlayerDies   
)

Definition at line 88 of file sv_overkill.qc.

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

89 {
90  entity frag_attacker = M_ARGV(1, entity);
91  entity frag_target = M_ARGV(2, entity);
92 
93  entity targ = ((IS_PLAYER(frag_attacker)) ? frag_attacker : frag_target);
94 
95  ok_DropItem(frag_target, targ);
96 
97  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
98  {
99  .entity weaponentity = weaponentities[slot];
100 
101  frag_target.ok_lastwep[slot] = frag_target.(weaponentity).m_switchweapon;
102  }
103 }
entity() spawn
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
#define M_ARGV(x, type)
Definition: events.qh:17
void ok_DropItem(entity this, entity targ)
Definition: sv_overkill.qc:80
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [4/16]

MUTATOR_HOOKFUNCTION ( ok  ,
MonsterDropItem   
)

Definition at line 105 of file sv_overkill.qc.

References entity(), M_ARGV, NULL, and ok_DropItem().

106 {
107  entity mon = M_ARGV(0, entity);
108  entity olditem = M_ARGV(1, entity);
109  entity frag_attacker = M_ARGV(2, entity);
110 
111  delete(olditem);
112 
113  M_ARGV(1, entity) = NULL;
114 
115  ok_DropItem(mon, frag_attacker);
116 }
entity() spawn
#define NULL
Definition: post.qh:17
#define M_ARGV(x, type)
Definition: events.qh:17
void ok_DropItem(entity this, entity targ)
Definition: sv_overkill.qc:80
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [5/16]

MUTATOR_HOOKFUNCTION ( ok  ,
ForbidThrowCurrentWeapon   
)

Definition at line 118 of file sv_overkill.qc.

119 {
120  return true;
121 }

◆ MUTATOR_HOOKFUNCTION() [6/16]

MUTATOR_HOOKFUNCTION ( ok  ,
PlayerPreThink   
)

Definition at line 123 of file sv_overkill.qc.

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

124 {
125  if (game_stopped)
126  {
127  return;
128  }
129  entity player = M_ARGV(0, entity);
130  if (!IS_PLAYER(player) || IS_DEAD(player) || STAT(FROZEN, player))
131  {
132  return;
133  }
134  if (!PHYS_INPUT_BUTTON_ATCK2(player) || weaponLocked(player) ||
136  {
137  return;
138  }
139  // Allow secondary blaster during countdown.
140  for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
141  {
142  .entity weaponentity = weaponentities[slot];
143  Weapon weapon = player.(weaponentity).m_weapon;
144  if (weapon == WEP_Null && slot != 0)
145  {
146  continue;
147  }
148  weapon.wr_think(weapon, player, weaponentity, 2);
149  }
150  PHYS_INPUT_BUTTON_ATCK2(player) = false;
151 }
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition: player.qh:148
#define round_handler_IsActive()
entity() spawn
#define round_handler_IsRoundStarted()
bool weaponLocked(entity player)
float weapon
Definition: progsdefs.qc:139
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
#define M_ARGV(x, type)
Definition: events.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [7/16]

MUTATOR_HOOKFUNCTION ( ok  ,
ForbidRandomStartWeapons   
)

Definition at line 153 of file sv_overkill.qc.

154 {
155  return true;
156 }

◆ MUTATOR_HOOKFUNCTION() [8/16]

MUTATOR_HOOKFUNCTION ( ok  ,
PlayerWeaponSelect   
)

Definition at line 158 of file sv_overkill.qc.

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

159 {
160  entity player = M_ARGV(0, entity);
161 
162  for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
163  {
164  .entity weaponentity = weaponentities[slot];
165  entity thiswep = player.(weaponentity);
166 
167  if(player.ok_lastwep[slot] && player.ok_lastwep[slot] != WEP_Null)
168  {
169  Weapon newwep = player.ok_lastwep[slot];
170  if(player.ok_lastwep[slot] == WEP_OVERKILL_HMG)
171  newwep = WEP_OVERKILL_MACHINEGUN;
172  if(player.ok_lastwep[slot] == WEP_OVERKILL_RPC)
173  newwep = WEP_OVERKILL_NEX;
174  thiswep.m_switchweapon = newwep;
175  player.ok_lastwep[slot] = WEP_Null;
176  }
177  }
178 }
entity() spawn
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
#define M_ARGV(x, type)
Definition: events.qh:17
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition: weapon.qh:41
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [9/16]

MUTATOR_HOOKFUNCTION ( ok  ,
Item_RespawnCountdown   
)

Definition at line 196 of file sv_overkill.qc.

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

197 {
198  entity item = M_ARGV(0, entity);
199  return ok_HandleItemWaypoints(item);
200 }
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
bool ok_HandleItemWaypoints(entity e)
Definition: sv_overkill.qc:180
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [10/16]

MUTATOR_HOOKFUNCTION ( ok  ,
Item_ScheduleRespawn   
)

Definition at line 202 of file sv_overkill.qc.

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

203 {
204  entity item = M_ARGV(0, entity);
205  return ok_HandleItemWaypoints(item);
206 }
entity() spawn
#define M_ARGV(x, type)
Definition: events.qh:17
bool ok_HandleItemWaypoints(entity e)
Definition: sv_overkill.qc:180
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [11/16]

MUTATOR_HOOKFUNCTION ( ok  ,
FilterItem   
)

Definition at line 208 of file sv_overkill.qc.

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_powerups, entity(), Item_Initialize(), Item_ShouldKeepPosition(), M_ARGV, and setorigin().

209 {
210  entity item = M_ARGV(0, entity);
211 
212  if (item.ok_item)
213  {
214  return false;
215  }
216  switch(item.itemdef)
217  {
218  case ITEM_HealthMega: return autocvar_g_overkill_filter_healthmega;
219  case ITEM_ArmorMedium: return autocvar_g_overkill_filter_armormedium;
220  case ITEM_ArmorBig: return autocvar_g_overkill_filter_armorbig;
221  case ITEM_ArmorMega: return autocvar_g_overkill_filter_armormega;
222  }
224  {
225  return true;
226  }
227  if (item.classname == "item_strength")
228  {
229  entity wep = new(weapon_okhmg);
230  setorigin(wep, item.origin);
231  wep.ok_item = true;
232  wep.noalign = Item_ShouldKeepPosition(item);
233  wep.cnt = item.cnt;
234  wep.team = item.team;
235  wep.respawntime = g_pickup_respawntime_superweapon;
236  wep.pickup_anyway = true;
237  wep.spawnfunc_checked = true;
238  Item_Initialize(wep, "weapon_okhmg"); // doesn't actually use spawnfunc
239  return true;
240  }
241  else if (item.classname == "item_shield")
242  {
243  entity wep = new(weapon_okrpc);
244  setorigin(wep, item.origin);
245  wep.ok_item = true;
246  wep.noalign = Item_ShouldKeepPosition(item);
247  wep.cnt = item.cnt;
248  wep.team = item.team;
249  wep.respawntime = g_pickup_respawntime_superweapon;
250  wep.pickup_anyway = true;
251  wep.spawnfunc_checked = true;
252  Item_Initialize(wep, "weapon_okrpc"); // doesn't actually use spawnfunc
253  return true;
254  }
255  return true;
256 }
bool autocvar_g_overkill_powerups_replace
Definition: sv_overkill.qc:7
void Item_Initialize(entity item, string class_name)
Initializes the item according to class name.
Definition: spawning.qc:75
entity() spawn
int autocvar_g_powerups
Definition: sv_powerups.qh:7
bool autocvar_g_overkill_filter_healthmega
Definition: sv_overkill.qh:4
bool autocvar_g_overkill_filter_armorbig
Definition: sv_overkill.qh:6
bool autocvar_g_overkill_filter_armormedium
Definition: sv_overkill.qh:5
#define M_ARGV(x, type)
Definition: events.qh:17
bool autocvar_g_overkill_filter_armormega
Definition: sv_overkill.qh:7
bool Item_ShouldKeepPosition(entity item)
Returns whether item should keep its position or be dropped to the ground.
Definition: spawning.qc:131
setorigin(ent, v)
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [12/16]

MUTATOR_HOOKFUNCTION ( ok  ,
SetStartItems  ,
CBC_ORDER_LAST   
)

Definition at line 258 of file sv_overkill.qc.

References start_items, start_weapons, warmup_start_weapons, and WEPSET.

259 {
260  WepSet ok_start_items = (WEPSET(OVERKILL_MACHINEGUN) | WEPSET(OVERKILL_NEX) | WEPSET(OVERKILL_SHOTGUN));
261 
262  if(WEP_OVERKILL_RPC.weaponstart > 0) { ok_start_items |= WEPSET(OVERKILL_RPC); }
263  if(WEP_OVERKILL_HMG.weaponstart > 0) { ok_start_items |= WEPSET(OVERKILL_HMG); }
264 
265  start_items |= IT_UNLIMITED_AMMO;
266 
267  start_weapons = warmup_start_weapons = ok_start_items;
268 }
vector WepSet
Definition: weapon.qh:11
#define WEPSET(id)
Definition: all.qh:37
WepSet warmup_start_weapons
Definition: world.qh:100
WepSet start_weapons
Definition: world.qh:81
int start_items
Definition: world.qh:84

◆ MUTATOR_HOOKFUNCTION() [13/16]

MUTATOR_HOOKFUNCTION ( ok  ,
SetWeaponArena   
)

Definition at line 270 of file sv_overkill.qc.

References M_ARGV.

271 {
272  // turn weapon arena off
273  M_ARGV(0, string) = "off";
274 }
#define M_ARGV(x, type)
Definition: events.qh:17

◆ MUTATOR_HOOKFUNCTION() [14/16]

MUTATOR_HOOKFUNCTION ( ok  ,
BuildMutatorsString   
)

Definition at line 276 of file sv_overkill.qc.

References M_ARGV, and strcat().

277 {
278  M_ARGV(0, string) = strcat(M_ARGV(0, string), ":OK");
279 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [15/16]

MUTATOR_HOOKFUNCTION ( ok  ,
BuildMutatorsPrettyString   
)

Definition at line 281 of file sv_overkill.qc.

References M_ARGV, and strcat().

282 {
283  M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Overkill");
284 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define M_ARGV(x, type)
Definition: events.qh:17
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION() [16/16]

MUTATOR_HOOKFUNCTION ( ok  ,
SetModname   
)

Definition at line 286 of file sv_overkill.qc.

References M_ARGV.

287 {
288  M_ARGV(0, string) = "Overkill";
289  return true;
290 }
#define M_ARGV(x, type)
Definition: events.qh:17

◆ ok_DropItem()

void ok_DropItem ( entity  this,
entity  targ 
)

Definition at line 80 of file sv_overkill.qc.

References entity(), Item_InitializeLoot(), normalize(), origin, and spawn().

Referenced by MUTATOR_HOOKFUNCTION().

81 {
82  entity e = spawn();
83  e.ok_item = true;
84  Item_InitializeLoot(e, "item_armor_small", this.origin + '0 0 32',
85  '0 0 200' + normalize(targ.origin - this.origin) * 500, 5);
86 }
bool Item_InitializeLoot(entity item, string class_name, vector position, vector vel, float time_to_live)
Initializes the loot item.
Definition: spawning.qc:101
entity() spawn
origin
Definition: ent_cs.qc:114
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ok_HandleItemWaypoints()

bool ok_HandleItemWaypoints ( entity  e)

Definition at line 180 of file sv_overkill.qc.

References autocvar_g_overkill_itemwaypoints.

Referenced by MUTATOR_HOOKFUNCTION().

181 {
183  return false; // don't handle it
184 
185  switch(e.itemdef)
186  {
187  case ITEM_HealthMega: return true;
188  case ITEM_ArmorMedium: return true;
189  case ITEM_ArmorBig: return true;
190  case ITEM_ArmorMega: return true;
191  }
192 
193  return false;
194 }
bool autocvar_g_overkill_itemwaypoints
Definition: sv_overkill.qc:9
+ Here is the caller graph for this function:

◆ 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 16 of file sv_overkill.qc.

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

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

Variable Documentation

◆ autocvar_g_overkill_itemwaypoints

bool autocvar_g_overkill_itemwaypoints = true

Definition at line 9 of file sv_overkill.qc.

Referenced by ok_HandleItemWaypoints().

◆ 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 11 of file sv_overkill.qc.