2 bool autocvar_g_overkill_powerups_replace;
3 float autocvar_g_overkill_superguns_respawn_time;
4 bool autocvar_g_overkill_100h_anyway;
5 bool autocvar_g_overkill_100a_anyway;
6 bool autocvar_g_overkill_ammo_charge;
7 float autocvar_g_overkill_ammo_charge_notice;
8 float autocvar_g_overkill_ammo_charge_limit;
11 .float ok_spawnsys_timer;
15 .float ok_notice_time;
16 .float ammo_charge[Weapons_MAX];
17 .float ok_use_ammocharge = _STAT(OK_AMMO_CHARGE);
18 .float ok_ammo_charge = _STAT(OK_AMMO_CHARGEPOOL);
20 .float ok_pauseregen_finished;
22 void(entity ent, float wep) ok_DecreaseCharge;
26 REGISTER_MUTATOR(ok, cvar("g_overkill") && !cvar("g_instagib") && !g_nexball && cvar_string("g_mod_balance") == "Overkill")
35 WEP_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
36 WEP_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
40 MUTATOR_HOOKFUNCTION(ok, W_DecreaseAmmo)
42 entity actor = M_ARGV(0, entity);
43 if (actor.ok_use_ammocharge)
45 ok_DecreaseCharge(actor, PS(actor).m_weapon.m_id);
50 MUTATOR_HOOKFUNCTION(ok, W_Reload)
52 entity actor = M_ARGV(0, entity);
53 return actor.ok_use_ammocharge;
56 void W_Blaster_Attack(entity, float, float, float, float, float, float, float, float, float, float);
57 spawnfunc(weapon_hmg);
58 spawnfunc(weapon_rpc);
60 void ok_DecreaseCharge(entity ent, int wep)
62 if(!ent.ok_use_ammocharge) return;
64 entity wepent = Weapons_from(wep);
66 if (wepent == WEP_Null) return; // dummy
68 ent.ammo_charge[wep] -= max(0, cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
71 void ok_IncreaseCharge(entity ent, int wep)
73 entity wepent = Weapons_from(wep);
75 if (wepent == WEP_Null) return; // dummy
77 if(ent.ok_use_ammocharge)
78 if(!PHYS_INPUT_BUTTON_ATCK(ent)) // not while attacking?
79 ent.ammo_charge[wep] = min(autocvar_g_overkill_ammo_charge_limit, ent.ammo_charge[wep] + cvar(sprintf("g_overkill_ammo_charge_rate_%s", wepent.netname)) * frametime / W_TICSPERFRAME);
82 float ok_CheckWeaponCharge(entity ent, int wep)
84 if(!ent.ok_use_ammocharge) return true;
86 entity wepent = Weapons_from(wep);
88 if(wepent == WEP_Null) return false; // dummy
90 return (ent.ammo_charge[wep] >= cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
93 MUTATOR_HOOKFUNCTION(ok, PlayerDamage_Calculate, CBC_ORDER_LAST)
95 entity frag_attacker = M_ARGV(1, entity);
96 entity frag_target = M_ARGV(2, entity);
97 float frag_deathtype = M_ARGV(3, float);
99 if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target))
100 if(DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
102 if(frag_attacker != frag_target)
103 if(frag_target.health > 0)
104 if(STAT(FROZEN, frag_target) == 0)
105 if(!IS_DEAD(frag_target))
107 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE);
108 M_ARGV(6, vector) = '0 0 0';
111 M_ARGV(4, float) = 0;
115 MUTATOR_HOOKFUNCTION(ok, PlayerDamage_SplitHealthArmor)
117 entity frag_target = M_ARGV(2, entity);
118 float damage_take = M_ARGV(4, float);
121 frag_target.ok_pauseregen_finished = max(frag_target.ok_pauseregen_finished, time + 2);
124 void ok_DropItem(entity this, entity targ)
126 entity e = new(droppedweapon); // hax
129 e.pickup_anyway = true;
130 e.spawnfunc_checked = true;
131 WITHSELF(e, spawnfunc_item_armor_small(e));
132 if (!wasfreed(e)) { // might have been blocked by a mutator
133 e.movetype = MOVETYPE_TOSS;
135 e.reset = SUB_Remove;
136 setorigin(e, this.origin + '0 0 32');
137 e.velocity = '0 0 200' + normalize(targ.origin - this.origin) * 500;
138 SUB_SetFade(e, time + 5, 1);
142 MUTATOR_HOOKFUNCTION(ok, PlayerDies)
144 entity frag_attacker = M_ARGV(1, entity);
145 entity frag_target = M_ARGV(2, entity);
147 entity targ = ((frag_attacker) ? frag_attacker : frag_target);
149 ok_DropItem(frag_target, targ);
151 frag_target.ok_lastwep = PS(frag_target).m_switchweapon.m_id;
154 MUTATOR_HOOKFUNCTION(ok, MonsterDropItem)
156 entity mon = M_ARGV(0, entity);
157 entity olditem = M_ARGV(1, entity);
158 entity frag_attacker = M_ARGV(2, entity);
162 M_ARGV(1, entity) = NULL;
164 ok_DropItem(mon, frag_attacker);
167 MUTATOR_HOOKFUNCTION(ok, PlayerRegen)
169 // overkill's values are different, so use custom regen
170 if(!STAT(FROZEN, self))
172 self.armorvalue = CalcRotRegen(self.armorvalue, autocvar_g_balance_armor_regenstable, autocvar_g_balance_armor_regen, autocvar_g_balance_armor_regenlinear, 1 * frametime * (time > self.ok_pauseregen_finished), 0, 0, 1, 1 * frametime * (time > self.pauserotarmor_finished), autocvar_g_balance_armor_limit);
173 self.health = CalcRotRegen(self.health, autocvar_g_balance_health_regenstable, 0, 100, 1 * frametime * (time > self.ok_pauseregen_finished), 200, 0, autocvar_g_balance_health_rotlinear, 1 * frametime * (time > self.pauserothealth_finished), autocvar_g_balance_health_limit);
175 float minf, maxf, limitf;
177 maxf = autocvar_g_balance_fuel_rotstable;
178 minf = autocvar_g_balance_fuel_regenstable;
179 limitf = autocvar_g_balance_fuel_limit;
181 self.ammo_fuel = CalcRotRegen(self.ammo_fuel, minf, autocvar_g_balance_fuel_regen, autocvar_g_balance_fuel_regenlinear, frametime * (time > self.pauseregen_finished) * ((self.items & ITEM_JetpackRegen.m_itemid) != 0), maxf, autocvar_g_balance_fuel_rot, autocvar_g_balance_fuel_rotlinear, frametime * (time > self.pauserotfuel_finished), limitf);
183 return true; // return true anyway, as frozen uses no regen
186 MUTATOR_HOOKFUNCTION(ok, ForbidThrowCurrentWeapon)
191 MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
193 if(intermission_running || gameover)
196 entity player = M_ARGV(0, entity);
198 if(IS_DEAD(player) || !IS_PLAYER(player) || STAT(FROZEN, player))
201 if(player.ok_lastwep)
203 Weapon newwep = Weapons_from(player.ok_lastwep);
204 if(player.ok_lastwep == WEP_HMG.m_id)
205 newwep = WEP_MACHINEGUN;
206 if(player.ok_lastwep == WEP_RPC.m_id)
208 PS(player).m_switchweapon = newwep;
209 player.ok_lastwep = 0;
212 ok_IncreaseCharge(player, PS(player).m_weapon.m_id);
214 if(PHYS_INPUT_BUTTON_ATCK2(player))
215 if(!forbidWeaponUse(player) || player.weapon_blocked) // allow if weapon is blocked
216 if(time >= player.jump_interval)
218 player.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor(player);
219 makevectors(player.v_angle);
221 Weapon oldwep = PS(player).m_weapon;
222 PS(player).m_weapon = WEP_BLASTER;
225 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
226 WEP_CVAR_SEC(vaporizer, shotangle),
227 WEP_CVAR_SEC(vaporizer, damage),
228 WEP_CVAR_SEC(vaporizer, edgedamage),
229 WEP_CVAR_SEC(vaporizer, radius),
230 WEP_CVAR_SEC(vaporizer, force),
231 WEP_CVAR_SEC(vaporizer, speed),
232 WEP_CVAR_SEC(vaporizer, spread),
233 WEP_CVAR_SEC(vaporizer, delay),
234 WEP_CVAR_SEC(vaporizer, lifetime)
236 PS(player).m_weapon = oldwep;
239 player.weapon_blocked = false;
241 player.ok_ammo_charge = player.ammo_charge[PS(player).m_weapon.m_id];
243 if(player.ok_use_ammocharge)
244 if(!ok_CheckWeaponCharge(player, PS(player).m_weapon.m_id))
246 if(autocvar_g_overkill_ammo_charge_notice && time > player.ok_notice_time && PHYS_INPUT_BUTTON_ATCK(player) && IS_REAL_CLIENT(player) && PS(player).m_weapon == PS(player).m_switchweapon)
248 //Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_OVERKILL_CHARGE);
249 player.ok_notice_time = time + 2;
250 play2(player, SND(DRYFIRE));
252 Weapon wpn = PS(player).m_weapon;
253 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
254 if(player.(weaponentity).state != WS_CLEAR)
255 w_ready(wpn, player, weaponentity, PHYS_INPUT_BUTTON_ATCK(player) | (PHYS_INPUT_BUTTON_ATCK2(player) << 1));
257 player.weapon_blocked = true;
260 PHYS_INPUT_BUTTON_ATCK2(player) = false;
263 MUTATOR_HOOKFUNCTION(ok, PlayerSpawn)
265 entity player = M_ARGV(0, entity);
267 if(autocvar_g_overkill_ammo_charge)
269 FOREACH(Weapons, it != WEP_Null, LAMBDA(player.ammo_charge[it.m_id] = autocvar_g_overkill_ammo_charge_limit));
271 player.ok_use_ammocharge = 1;
272 player.ok_notice_time = time;
275 player.ok_use_ammocharge = 0;
277 // if player changed their weapon while dead, don't switch to their death weapon
279 player.ok_lastwep = 0;
281 player.ok_pauseregen_finished = time + 2;
284 void self_spawnfunc_weapon_hmg(entity this) { spawnfunc_weapon_hmg(this); }
285 void self_spawnfunc_weapon_rpc(entity this) { spawnfunc_weapon_rpc(this); }
287 MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
289 entity ent = M_ARGV(0, entity);
291 if(autocvar_g_powerups)
292 if(autocvar_g_overkill_powerups_replace)
294 if(ent.classname == "item_strength")
296 entity wep = new(weapon_hmg);
297 setorigin(wep, ent.origin);
298 setmodel(wep, MDL_OK_HMG);
300 wep.noalign = ent.noalign;
303 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
304 wep.pickup_anyway = true;
305 wep.spawnfunc_checked = true;
306 setthink(wep, self_spawnfunc_weapon_hmg);
307 wep.nextthink = time + 0.1;
311 if(ent.classname == "item_invincible")
313 entity wep = new(weapon_rpc);
314 setorigin(wep, ent.origin);
315 setmodel(wep, MDL_OK_RPC);
317 wep.noalign = ent.noalign;
320 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
321 wep.pickup_anyway = true;
322 wep.spawnfunc_checked = true;
323 setthink(wep, self_spawnfunc_weapon_rpc);
324 wep.nextthink = time + 0.1;
330 MUTATOR_HOOKFUNCTION(ok, FilterItem)
332 entity item = M_ARGV(0, entity);
339 case ITEM_HealthMega.m_itemid: return !(autocvar_g_overkill_100h_anyway);
340 case ITEM_ArmorMega.m_itemid: return !(autocvar_g_overkill_100a_anyway);
346 MUTATOR_HOOKFUNCTION(ok, SpectateCopy)
348 entity spectatee = M_ARGV(0, entity);
349 entity client = M_ARGV(1, entity);
351 client.ammo_charge[PS(client).m_weapon.m_id] = spectatee.ammo_charge[PS(spectatee).m_weapon.m_id];
352 client.ok_use_ammocharge = spectatee.ok_use_ammocharge;
355 MUTATOR_HOOKFUNCTION(ok, SetStartItems)
357 WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN));
359 if(WEP_RPC.weaponstart > 0) { ok_start_items |= WEPSET(RPC); }
360 if(WEP_HMG.weaponstart > 0) { ok_start_items |= WEPSET(HMG); }
362 start_items |= IT_UNLIMITED_WEAPON_AMMO;
363 start_weapons = warmup_start_weapons = ok_start_items;
366 MUTATOR_HOOKFUNCTION(ok, BuildMutatorsString)
368 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":OK");
371 MUTATOR_HOOKFUNCTION(ok, BuildMutatorsPrettyString)
373 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Overkill");
376 MUTATOR_HOOKFUNCTION(ok, SetModname)
378 M_ARGV(0, string) = "Overkill";
384 // hack to force overkill playermodels
385 cvar_settemp("sv_defaultcharacter", "1");
386 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");
387 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");
388 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");
395 precache_all_playermodels("models/ok_player/*.dpm");
397 WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
398 WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
400 WEP_SHOTGUN.mdl = "ok_shotgun";
401 WEP_MACHINEGUN.mdl = "ok_mg";
402 WEP_VORTEX.mdl = "ok_sniper";