1 #include "sv_overkill.qh"
6 bool autocvar_g_overkill_powerups_replace;
7 float autocvar_g_overkill_superguns_respawn_time;
8 bool autocvar_g_overkill_100h_anyway;
9 bool autocvar_g_overkill_100a_anyway;
12 .float ok_spawnsys_timer;
13 .Weapon ok_lastwep[MAX_WEAPONSLOTS];
16 .float ok_pauseregen_finished;
20 REGISTER_MUTATOR(ok, cvar("g_overkill") && !cvar("g_instagib") && !g_nexball && cvar_string("g_mod_balance") == "Overkill")
29 WEP_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
30 WEP_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
34 void W_Blaster_Attack(entity, .entity, float, float, float, float, float, float, float, float, float, float);
35 spawnfunc(weapon_hmg);
36 spawnfunc(weapon_rpc);
38 MUTATOR_HOOKFUNCTION(ok, PlayerDamage_Calculate, CBC_ORDER_LAST)
40 entity frag_attacker = M_ARGV(1, entity);
41 entity frag_target = M_ARGV(2, entity);
42 float frag_deathtype = M_ARGV(3, float);
44 if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target))
45 if(DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
47 if(frag_attacker != frag_target)
48 if(frag_target.health > 0)
49 if(STAT(FROZEN, frag_target) == 0)
50 if(!IS_DEAD(frag_target))
52 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE);
53 M_ARGV(6, vector) = '0 0 0';
60 MUTATOR_HOOKFUNCTION(ok, PlayerDamage_SplitHealthArmor)
62 entity frag_target = M_ARGV(2, entity);
63 float damage_take = M_ARGV(4, float);
66 frag_target.ok_pauseregen_finished = max(frag_target.ok_pauseregen_finished, time + 2);
69 void ok_DropItem(entity this, entity targ)
71 entity e = new(droppedweapon); // hax
74 e.pickup_anyway = true;
75 e.spawnfunc_checked = true;
76 spawnfunc_item_armor_small(e);
77 if (!wasfreed(e)) { // might have been blocked by a mutator
78 set_movetype(e, MOVETYPE_TOSS);
81 setorigin(e, this.origin + '0 0 32');
82 e.velocity = '0 0 200' + normalize(targ.origin - this.origin) * 500;
83 SUB_SetFade(e, time + 5, 1);
87 MUTATOR_HOOKFUNCTION(ok, PlayerDies)
89 entity frag_attacker = M_ARGV(1, entity);
90 entity frag_target = M_ARGV(2, entity);
92 entity targ = ((frag_attacker) ? frag_attacker : frag_target);
94 ok_DropItem(frag_target, targ);
96 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
98 .entity weaponentity = weaponentities[slot];
100 frag_target.ok_lastwep[slot] = frag_target.(weaponentity).m_switchweapon;
104 MUTATOR_HOOKFUNCTION(ok, MonsterDropItem)
106 entity mon = M_ARGV(0, entity);
107 entity olditem = M_ARGV(1, entity);
108 entity frag_attacker = M_ARGV(2, entity);
112 M_ARGV(1, entity) = NULL;
114 ok_DropItem(mon, frag_attacker);
117 MUTATOR_HOOKFUNCTION(ok, PlayerRegen)
119 entity player = M_ARGV(0, entity);
121 // overkill's values are different, so use custom regen
122 if(!STAT(FROZEN, player))
124 player.armorvalue = CalcRotRegen(player.armorvalue, autocvar_g_balance_armor_regenstable, autocvar_g_balance_armor_regen, autocvar_g_balance_armor_regenlinear,
125 1 * frametime * (time > player.ok_pauseregen_finished), 0, 0, 1, 1 * frametime * (time > player.pauserotarmor_finished), autocvar_g_balance_armor_limit);
126 player.health = CalcRotRegen(player.health, autocvar_g_balance_health_regenstable, 0, 100, 1 * frametime * (time > player.ok_pauseregen_finished), 200, 0,
127 autocvar_g_balance_health_rotlinear, 1 * frametime * (time > player.pauserothealth_finished), autocvar_g_balance_health_limit);
129 float minf, maxf, limitf;
131 maxf = autocvar_g_balance_fuel_rotstable;
132 minf = autocvar_g_balance_fuel_regenstable;
133 limitf = autocvar_g_balance_fuel_limit;
135 player.ammo_fuel = CalcRotRegen(player.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear,
136 frametime * (time > player.pauseregen_finished) * ((player.items & ITEM_JetpackRegen.m_itemid) != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, frametime * (time > player.pauserotfuel_finished), limitf);
138 return true; // return true anyway, as frozen uses no regen
141 MUTATOR_HOOKFUNCTION(ok, ForbidThrowCurrentWeapon)
146 MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
148 if(intermission_running || gameover)
151 entity player = M_ARGV(0, entity);
153 if(IS_DEAD(player) || !IS_PLAYER(player) || STAT(FROZEN, player))
156 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
158 .entity weaponentity = weaponentities[slot];
159 entity thiswep = player.(weaponentity);
161 if(player.ok_lastwep[slot] && player.ok_lastwep[slot] != WEP_Null)
163 Weapon newwep = player.ok_lastwep[slot];
164 if(player.ok_lastwep[slot] == WEP_HMG)
165 newwep = WEP_MACHINEGUN;
166 if(player.ok_lastwep[slot] == WEP_RPC)
168 thiswep.m_switchweapon = newwep;
169 player.ok_lastwep[slot] = WEP_Null;
173 if(PHYS_INPUT_BUTTON_ATCK2(player))
174 if(!forbidWeaponUse(player) || player.weapon_blocked) // allow if weapon is blocked
175 if(time >= player.jump_interval)
177 player.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor(player);
178 makevectors(player.v_angle);
180 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
182 .entity weaponentity = weaponentities[slot];
184 if(player.(weaponentity).m_weapon == WEP_Null && slot != 0)
187 Weapon oldwep = player.(weaponentity).m_weapon;
188 player.(weaponentity).m_weapon = WEP_BLASTER;
192 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
193 WEP_CVAR_SEC(vaporizer, shotangle),
194 WEP_CVAR_SEC(vaporizer, damage),
195 WEP_CVAR_SEC(vaporizer, edgedamage),
196 WEP_CVAR_SEC(vaporizer, radius),
197 WEP_CVAR_SEC(vaporizer, force),
198 WEP_CVAR_SEC(vaporizer, speed),
199 WEP_CVAR_SEC(vaporizer, spread),
200 WEP_CVAR_SEC(vaporizer, delay),
201 WEP_CVAR_SEC(vaporizer, lifetime)
203 player.(weaponentity).m_weapon = oldwep;
207 PHYS_INPUT_BUTTON_ATCK2(player) = false;
210 MUTATOR_HOOKFUNCTION(ok, PlayerSpawn)
212 entity player = M_ARGV(0, entity);
214 // if player changed their weapon while dead, don't switch to their death weapon
217 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
219 player.ok_lastwep[slot] = WEP_Null;
223 player.ok_pauseregen_finished = time + 2;
226 void self_spawnfunc_weapon_hmg(entity this) { spawnfunc_weapon_hmg(this); }
227 void self_spawnfunc_weapon_rpc(entity this) { spawnfunc_weapon_rpc(this); }
229 MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
231 entity ent = M_ARGV(0, entity);
233 if(autocvar_g_powerups)
234 if(autocvar_g_overkill_powerups_replace)
236 if(ent.classname == "item_strength")
238 entity wep = new(weapon_hmg);
239 setorigin(wep, ent.origin);
240 setmodel(wep, MDL_OK_HMG);
242 wep.noalign = ent.noalign;
245 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
246 wep.pickup_anyway = true;
247 wep.spawnfunc_checked = true;
248 setthink(wep, self_spawnfunc_weapon_hmg);
249 wep.nextthink = time + 0.1;
253 if(ent.classname == "item_invincible")
255 entity wep = new(weapon_rpc);
256 setorigin(wep, ent.origin);
257 setmodel(wep, MDL_OK_RPC);
259 wep.noalign = ent.noalign;
262 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
263 wep.pickup_anyway = true;
264 wep.spawnfunc_checked = true;
265 setthink(wep, self_spawnfunc_weapon_rpc);
266 wep.nextthink = time + 0.1;
272 MUTATOR_HOOKFUNCTION(ok, FilterItem)
274 entity item = M_ARGV(0, entity);
281 case ITEM_HealthMega.m_itemid: return !(autocvar_g_overkill_100h_anyway);
282 case ITEM_ArmorMega.m_itemid: return !(autocvar_g_overkill_100a_anyway);
288 MUTATOR_HOOKFUNCTION(ok, SetStartItems, CBC_ORDER_LAST)
290 WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN));
292 if(WEP_RPC.weaponstart > 0) { ok_start_items |= WEPSET(RPC); }
293 if(WEP_HMG.weaponstart > 0) { ok_start_items |= WEPSET(HMG); }
295 start_items |= IT_UNLIMITED_WEAPON_AMMO;
296 start_weapons = warmup_start_weapons = ok_start_items;
299 MUTATOR_HOOKFUNCTION(ok, BuildMutatorsString)
301 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":OK");
304 MUTATOR_HOOKFUNCTION(ok, BuildMutatorsPrettyString)
306 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Overkill");
309 MUTATOR_HOOKFUNCTION(ok, SetModname)
311 M_ARGV(0, string) = "Overkill";
317 // hack to force overkill playermodels
318 cvar_settemp("sv_defaultcharacter", "1");
319 cvar_settemp("sv_defaultplayermodel", "models/ok_player/okrobot1.dpm models/ok_player/okrobot2.dpm models/ok_player/okrobot3.dpm models/ok_player/okrobot4.dpm models/ok_player/okmale1.dpm models/ok_player/okmale2.dpm models/ok_player/okmale3.dpm models/ok_player/okmale4.dpm");
320 cvar_settemp("sv_defaultplayermodel_red", "models/ok_player/okrobot1.dpm models/ok_player/okrobot2.dpm models/ok_player/okrobot3.dpm models/ok_player/okrobot4.dpm");
321 cvar_settemp("sv_defaultplayermodel_blue", "models/ok_player/okmale1.dpm models/ok_player/okmale2.dpm models/ok_player/okmale3.dpm models/ok_player/okmale4.dpm");
328 precache_all_playermodels("models/ok_player/*.dpm");
330 WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
331 WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
333 WEP_SHOTGUN.mdl = "ok_shotgun";
334 WEP_MACHINEGUN.mdl = "ok_mg";
335 WEP_VORTEX.mdl = "ok_sniper";