Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_overkill.qc
Go to the documentation of this file.
1#include "sv_overkill.qh"
2
3#include "okshotgun.qh"
4#include "okhmg.qh"
5#include "okrpc.qh"
6
11string autocvar_g_overkill_loot_player = "armor_small";
13string autocvar_g_overkill_loot_monster = "armor_small";
15
17
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}
56
57
64
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}
84
85void ok_DropItem(entity this, entity attacker, string itemlist, float itemlifetime)
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}
102
103MUTATOR_HOOKFUNCTION(ok, PlayerDies)
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}
118
119MUTATOR_HOOKFUNCTION(ok, MonsterDropItem)
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}
128
129MUTATOR_HOOKFUNCTION(ok, ForbidThrowCurrentWeapon)
130{
131 return true;
132}
133
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}
163
164MUTATOR_HOOKFUNCTION(ok, ForbidRandomStartWeapons)
165{
166 return true;
167}
168
169MUTATOR_HOOKFUNCTION(ok, PlayerWeaponSelect)
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}
190
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}
206
212
218
219MUTATOR_HOOKFUNCTION(ok, FilterItem)
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}
264
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}
276
277MUTATOR_HOOKFUNCTION(ok, SetWeaponArena)
278{
279 // turn weapon arena off
280 M_ARGV(0, string) = "off";
281}
282
283MUTATOR_HOOKFUNCTION(ok, BuildMutatorsString)
284{
285 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":OK");
286}
287
288MUTATOR_HOOKFUNCTION(ok, BuildMutatorsPrettyString)
289{
290 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Overkill");
291}
292
293MUTATOR_HOOKFUNCTION(ok, SetModname)
294{
295 M_ARGV(0, string) = "Overkill";
296 return true;
297}
298
const int CBC_ORDER_LAST
Definition base.qh:11
#define MUTATOR_HOOKFUNCTION(...)
Definition base.qh:335
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
Definition weapon.qh:44
const int IT_UNLIMITED_AMMO
Definition item.qh:23
@ ITEM_FLAG_MUTATORBLOCKED
Definition item.qh:121
#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
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition player.qh:152
float game_stopped
Definition stats.qh:81
float CVAR_TYPEFLAG_EXISTS
vector origin
#define spawn
#define DEATH_ISWEAPON(t, w)
Definition all.qh:46
#define IL_EACH(this, cond, body)
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
bool Item_Initialise(entity item)
An optimised and generic way to initialise items (loot or permanent)
Definition spawning.qc:27
bool Item_IsDefinitionAllowed(entity definition)
Checks whether the items with the specified definition are allowed to spawn.
Definition spawning.qc:17
#define PlayerPreThink
Definition _all.inc:254
#define STAT(...)
Definition stats.qh:82
#define LOG_WARNF(...)
Definition log.qh:62
float cvar(string name)
vector normalize(vector v)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
float weapon
Definition progsdefs.qc:139
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
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
vector
Definition self.qh:92
void Item_ScheduleRespawn(entity e)
Definition items.qc:391
void Item_CopyFields(entity this, entity to)
Definition items.qc:850
void Item_RespawnCountdown(entity this)
Definition items.qc:258
entity frag_target
Definition sv_ctf.qc:2321
Weapon ok_lastwep[MAX_WEAPONSLOTS]
string autocvar_g_overkill_loot_monster
bool autocvar_g_overkill_itemwaypoints
Definition sv_overkill.qc:8
bool autocvar_g_overkill_powerups_replace
Definition sv_overkill.qc:7
bool autocvar_g_overkill_blaster_keepdamage
string autocvar_g_overkill_loot_player
float autocvar_g_overkill_loot_monster_time
float autocvar_g_overkill_loot_player_time
void ok_DropItem(entity this, entity attacker, string itemlist, float itemlifetime)
string RandomItems_GetRandomOverkillItemClassName(string prefix)
Returns a random classname of the overkill item.
bool ok_HandleItemWaypoints(entity e)
bool autocvar_g_overkill_blaster_keepforce
Definition sv_overkill.qc:9
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
IntrusiveList g_overkill_items
int autocvar_g_powerups
Definition sv_powerups.qh:7
string RandomItems_GetRandomItemClassName(string prefix)
Returns a random classname of the item.
#define IS_TURRET(v)
Definition utils.qh:23
#define IS_VEHICLE(v)
Definition utils.qh:22
#define WEPSET(id)
Definition all.qh:45
float autocvar_g_pickup_respawntime_superweapon
Definition spawning.qh:7
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17
vector WepSet
Definition weapon.qh:14
bool weaponLocked(entity player)
Weapon m_weapon
Definition wepent.qh:26
Weapon m_switchweapon
Definition wepent.qh:25
WepSet start_weapons
Definition world.qh:80
int start_items
Definition world.qh:83
WepSet warmup_start_weapons
Definition world.qh:98