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;
42 MUTATOR_HOOKFUNCTION(ok, W_DecreaseAmmo)
44 entity actor = MUTATOR_ARGV(0, entity);
45 if (actor.ok_use_ammocharge)
47 ok_DecreaseCharge(actor, PS(actor).m_weapon.m_id);
52 MUTATOR_HOOKFUNCTION(ok, W_Reload)
54 entity actor = MUTATOR_ARGV(0, entity);
55 return actor.ok_use_ammocharge;
58 void W_Blaster_Attack(entity, float, float, float, float, float, float, float, float, float, float);
59 spawnfunc(weapon_hmg);
60 spawnfunc(weapon_rpc);
62 void ok_DecreaseCharge(entity ent, int wep)
64 if(!ent.ok_use_ammocharge) return;
66 entity wepent = Weapons_from(wep);
68 if (wepent == WEP_Null) return; // dummy
70 ent.ammo_charge[wep] -= max(0, cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
73 void ok_IncreaseCharge(entity ent, int wep)
75 entity wepent = Weapons_from(wep);
77 if (wepent == WEP_Null) return; // dummy
79 if(ent.ok_use_ammocharge)
80 if(!PHYS_INPUT_BUTTON_ATCK(ent)) // not while attacking?
81 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);
84 float ok_CheckWeaponCharge(entity ent, int wep)
86 if(!ent.ok_use_ammocharge) return true;
88 entity wepent = Weapons_from(wep);
90 if(wepent == WEP_Null) return 0; // dummy
92 return (ent.ammo_charge[wep] >= cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
95 MUTATOR_HOOKFUNCTION(ok, PlayerDamage_Calculate, CBC_ORDER_LAST)
97 if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target))
98 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 frag_force = '0 0 0';
115 MUTATOR_HOOKFUNCTION(ok, PlayerDamage_SplitHealthArmor)
118 frag_target.ok_pauseregen_finished = max(frag_target.ok_pauseregen_finished, time + 2);
122 MUTATOR_HOOKFUNCTION(ok, PlayerDies)
124 entity targ = ((frag_attacker) ? frag_attacker : frag_target);
126 if(IS_MONSTER(frag_target))
128 remove(other); // remove default item
132 entity e = new(droppedweapon); // hax
135 e.pickup_anyway = true;
136 e.spawnfunc_checked = true;
137 spawnfunc_item_armor_small(e);
138 e.movetype = MOVETYPE_TOSS;
140 e.reset = SUB_Remove;
141 setorigin(e, frag_target.origin + '0 0 32');
142 e.velocity = '0 0 200' + normalize(targ.origin - frag_target.origin) * 500;
143 SUB_SetFade(e, time + 5, 1);
145 frag_target.ok_lastwep = PS(frag_target).m_switchweapon.m_id;
149 MUTATOR_HOOKFUNCTION(ok, MonsterDropItem) { ok_PlayerDies(); }
151 MUTATOR_HOOKFUNCTION(ok, PlayerRegen)
153 // overkill's values are different, so use custom regen
154 if(!STAT(FROZEN, self))
156 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);
157 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);
159 float minf, maxf, limitf;
161 maxf = autocvar_g_balance_fuel_rotstable;
162 minf = autocvar_g_balance_fuel_regenstable;
163 limitf = autocvar_g_balance_fuel_limit;
165 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);
167 return true; // return true anyway, as frozen uses no regen
170 MUTATOR_HOOKFUNCTION(ok, ForbidThrowCurrentWeapon)
175 MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
177 if(intermission_running || gameover)
180 if(IS_DEAD(self) || !IS_PLAYER(self) || STAT(FROZEN, self))
185 PS(self).m_switchweapon = Weapons_from(self.ok_lastwep);
189 ok_IncreaseCharge(self, PS(self).m_weapon.m_id);
191 if(PHYS_INPUT_BUTTON_ATCK2(self))
192 if(!forbidWeaponUse(self) || self.weapon_blocked) // allow if weapon is blocked
193 if(time >= self.jump_interval)
195 self.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor();
196 makevectors(self.v_angle);
198 Weapon oldwep = PS(self).m_weapon;
199 PS(self).m_weapon = WEP_BLASTER;
202 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
203 WEP_CVAR_SEC(vaporizer, shotangle),
204 WEP_CVAR_SEC(vaporizer, damage),
205 WEP_CVAR_SEC(vaporizer, edgedamage),
206 WEP_CVAR_SEC(vaporizer, radius),
207 WEP_CVAR_SEC(vaporizer, force),
208 WEP_CVAR_SEC(vaporizer, speed),
209 WEP_CVAR_SEC(vaporizer, spread),
210 WEP_CVAR_SEC(vaporizer, delay),
211 WEP_CVAR_SEC(vaporizer, lifetime)
213 PS(self).m_weapon = oldwep;
216 self.weapon_blocked = false;
218 self.ok_ammo_charge = self.ammo_charge[PS(self).m_weapon.m_id];
220 if(self.ok_use_ammocharge)
221 if(!ok_CheckWeaponCharge(self, PS(self).m_weapon.m_id))
223 if(autocvar_g_overkill_ammo_charge_notice && time > self.ok_notice_time && PHYS_INPUT_BUTTON_ATCK(self) && IS_REAL_CLIENT(self) && PS(self).m_weapon == PS(self).m_switchweapon)
225 //Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_OVERKILL_CHARGE);
226 self.ok_notice_time = time + 2;
227 play2(self, SND(DRYFIRE));
229 Weapon wpn = PS(self).m_weapon;
230 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
231 if(self.(weaponentity).state != WS_CLEAR)
232 w_ready(wpn, self, weaponentity, PHYS_INPUT_BUTTON_ATCK(self) | (PHYS_INPUT_BUTTON_ATCK2(self) << 1));
234 self.weapon_blocked = true;
237 PHYS_INPUT_BUTTON_ATCK2(self) = false;
242 MUTATOR_HOOKFUNCTION(ok, PlayerSpawn)
244 if(autocvar_g_overkill_ammo_charge)
246 FOREACH(Weapons, it != WEP_Null, LAMBDA(self.ammo_charge[it.m_id] = autocvar_g_overkill_ammo_charge_limit));
248 self.ok_use_ammocharge = 1;
249 self.ok_notice_time = time;
252 self.ok_use_ammocharge = 0;
254 self.ok_pauseregen_finished = time + 2;
259 void self_spawnfunc_weapon_hmg() { SELFPARAM(); spawnfunc_weapon_hmg(this); }
260 void self_spawnfunc_weapon_rpc() { SELFPARAM(); spawnfunc_weapon_rpc(this); }
262 MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
264 if(autocvar_g_powerups)
265 if(autocvar_g_overkill_powerups_replace)
267 if(self.classname == "item_strength")
269 entity wep = new(weapon_hmg);
270 setorigin(wep, self.origin);
271 setmodel(wep, MDL_OK_HMG);
273 wep.noalign = self.noalign;
275 wep.team = self.team;
276 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
277 wep.pickup_anyway = true;
278 wep.spawnfunc_checked = true;
279 wep.think = self_spawnfunc_weapon_hmg;
280 wep.nextthink = time + 0.1;
284 if(self.classname == "item_invincible")
286 entity wep = new(weapon_rpc);
287 setorigin(wep, self.origin);
288 setmodel(wep, MDL_OK_RPC);
290 wep.noalign = self.noalign;
292 wep.team = self.team;
293 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
294 wep.pickup_anyway = true;
295 wep.spawnfunc_checked = true;
296 wep.think = self_spawnfunc_weapon_rpc;
297 wep.nextthink = time + 0.1;
305 MUTATOR_HOOKFUNCTION(ok, FilterItem)
312 case ITEM_HealthMega.m_itemid: return !(autocvar_g_overkill_100h_anyway);
313 case ITEM_ArmorMega.m_itemid: return !(autocvar_g_overkill_100a_anyway);
319 MUTATOR_HOOKFUNCTION(ok, SpectateCopy)
321 self.ammo_charge[PS(self).m_weapon.m_id] = other.ammo_charge[PS(other).m_weapon.m_id];
322 self.ok_use_ammocharge = other.ok_use_ammocharge;
327 MUTATOR_HOOKFUNCTION(ok, SetStartItems)
329 WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN));
331 if(WEP_RPC.weaponstart > 0) { ok_start_items |= WEPSET(RPC); }
332 if(WEP_HMG.weaponstart > 0) { ok_start_items |= WEPSET(HMG); }
334 start_items |= IT_UNLIMITED_WEAPON_AMMO;
335 start_weapons = warmup_start_weapons = ok_start_items;
340 MUTATOR_HOOKFUNCTION(ok, BuildMutatorsString)
342 ret_string = strcat(ret_string, ":OK");
346 MUTATOR_HOOKFUNCTION(ok, BuildMutatorsPrettyString)
348 ret_string = strcat(ret_string, ", Overkill");
352 MUTATOR_HOOKFUNCTION(ok, SetModname)
354 modname = "Overkill";
360 // hack to force overkill playermodels
361 cvar_settemp("sv_defaultcharacter", "1");
362 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");
363 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");
364 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");
371 precache_all_playermodels("models/ok_player/*.dpm");
373 WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
374 WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
376 WEP_SHOTGUN.mdl = "ok_shotgun";
377 WEP_MACHINEGUN.mdl = "ok_mg";
378 WEP_VORTEX.mdl = "ok_sniper";