1 #include "mutator_overkill.qh"
5 void W_Blaster_Attack(entity, float, float, float, float, float, float, float, float, float, float);
9 void ok_DecreaseCharge(entity ent, int wep)
11 if(!ent.ok_use_ammocharge) return;
13 entity wepent = get_weaponinfo(wep);
15 if(wepent.weapon == 0)
18 ent.ammo_charge[wep] -= max(0, cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
21 void ok_IncreaseCharge(entity ent, int wep)
23 entity wepent = get_weaponinfo(wep);
25 if(wepent.weapon == 0)
28 if(ent.ok_use_ammocharge)
29 if(!ent.BUTTON_ATCK) // not while attacking?
30 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);
33 float ok_CheckWeaponCharge(entity ent, int wep)
35 if(!ent.ok_use_ammocharge) return true;
37 entity wepent = get_weaponinfo(wep);
39 if(wepent.weapon == 0)
42 return (ent.ammo_charge[wep] >= cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
45 MUTATOR_HOOKFUNCTION(ok_PlayerDamage_Calculate)
47 if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target))
48 if(DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
52 if(frag_attacker != frag_target)
53 if(frag_target.health > 0)
54 if(frag_target.frozen == 0)
55 if(frag_target.deadflag == DEAD_NO)
57 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE);
65 MUTATOR_HOOKFUNCTION(ok_PlayerDamage_SplitHealthArmor)
68 self.ok_pauseregen_finished = max(self.ok_pauseregen_finished, time + 2);
72 MUTATOR_HOOKFUNCTION(ok_PlayerDies)
74 entity targ = ((frag_attacker) ? frag_attacker : frag_target);
78 remove(other); // remove default item
85 self.pickup_anyway = true;
86 spawnfunc_item_armor_small(this);
87 self.movetype = MOVETYPE_TOSS;
89 self.reset = SUB_Remove;
90 setorigin(self, frag_target.origin + '0 0 32');
91 self.velocity = '0 0 200' + normalize(targ.origin - self.origin) * 500;
92 self.classname = "droppedweapon"; // hax
93 SUB_SetFade(self, time + 5, 1);
96 self.ok_lastwep = self.switchweapon;
101 MUTATOR_HOOKFUNCTION(ok_PlayerRegen)
103 // overkill's values are different, so use custom regen
106 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);
107 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);
109 float minf, maxf, limitf;
111 maxf = autocvar_g_balance_fuel_rotstable;
112 minf = autocvar_g_balance_fuel_regenstable;
113 limitf = autocvar_g_balance_fuel_limit;
115 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);
117 return true; // return true anyway, as frozen uses no regen
120 MUTATOR_HOOKFUNCTION(ok_ForbidThrowCurrentWeapon)
125 MUTATOR_HOOKFUNCTION(ok_PlayerPreThink)
127 if(intermission_running || gameover)
130 if(self.deadflag != DEAD_NO || !IS_PLAYER(self) || self.frozen)
135 self.switchweapon = self.ok_lastwep;
139 ok_IncreaseCharge(self, self.weapon);
141 if(self.BUTTON_ATCK2)
142 if(!forbidWeaponUse(self) || self.weapon_blocked) // allow if weapon is blocked
143 if(time >= self.jump_interval)
145 self.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor();
146 makevectors(self.v_angle);
148 int oldwep = self.weapon;
149 self.weapon = WEP_BLASTER.m_id;
152 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
153 WEP_CVAR_SEC(vaporizer, shotangle),
154 WEP_CVAR_SEC(vaporizer, damage),
155 WEP_CVAR_SEC(vaporizer, edgedamage),
156 WEP_CVAR_SEC(vaporizer, radius),
157 WEP_CVAR_SEC(vaporizer, force),
158 WEP_CVAR_SEC(vaporizer, speed),
159 WEP_CVAR_SEC(vaporizer, spread),
160 WEP_CVAR_SEC(vaporizer, delay),
161 WEP_CVAR_SEC(vaporizer, lifetime)
163 self.weapon = oldwep;
166 self.weapon_blocked = false;
168 self.ok_ammo_charge = self.ammo_charge[self.weapon];
170 if(self.ok_use_ammocharge)
171 if(!ok_CheckWeaponCharge(self, self.weapon))
173 if(autocvar_g_overkill_ammo_charge_notice && time > self.ok_notice_time && self.BUTTON_ATCK && IS_REAL_CLIENT(self) && self.weapon == self.switchweapon)
175 //Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_OVERKILL_CHARGE);
176 self.ok_notice_time = time + 2;
177 play2(self, SND(DRYFIRE));
179 Weapon wpn = get_weaponinfo(self.weapon);
180 if(self.weaponentity.state != WS_CLEAR)
181 w_ready(wpn, self, self.BUTTON_ATCK, self.BUTTON_ATCK2);
183 self.weapon_blocked = true;
186 self.BUTTON_ATCK2 = 0;
191 MUTATOR_HOOKFUNCTION(ok_PlayerSpawn)
193 if(autocvar_g_overkill_ammo_charge)
195 for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
196 self.ammo_charge[i] = autocvar_g_overkill_ammo_charge_limit;
198 self.ok_use_ammocharge = 1;
199 self.ok_notice_time = time;
202 self.ok_use_ammocharge = 0;
204 self.ok_pauseregen_finished = time + 2;
209 void _spawnfunc_weapon_hmg() { SELFPARAM(); spawnfunc_weapon_hmg(this); }
210 void _spawnfunc_weapon_rpc() { SELFPARAM(); spawnfunc_weapon_rpc(this); }
212 MUTATOR_HOOKFUNCTION(ok_OnEntityPreSpawn)
214 if(autocvar_g_powerups)
215 if(autocvar_g_overkill_powerups_replace)
217 if(self.classname == "item_strength")
219 entity wep = spawn();
220 setorigin(wep, self.origin);
221 setmodel(wep, MDL_OK_HMG);
222 wep.classname = "weapon_hmg";
224 wep.noalign = self.noalign;
226 wep.team = self.team;
227 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
228 wep.pickup_anyway = true;
229 wep.think = _spawnfunc_weapon_hmg;
230 wep.nextthink = time + 0.1;
234 if(self.classname == "item_invincible")
236 entity wep = spawn();
237 setorigin(wep, self.origin);
238 setmodel(wep, MDL_OK_RPC);
239 wep.classname = "weapon_rpc";
241 wep.noalign = self.noalign;
243 wep.team = self.team;
244 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
245 wep.pickup_anyway = true;
246 wep.think = _spawnfunc_weapon_rpc;
247 wep.nextthink = time + 0.1;
255 MUTATOR_HOOKFUNCTION(ok_ItemRemove)
262 case ITEM_HealthMega.m_itemid: return !(autocvar_g_overkill_100h_anyway);
263 case ITEM_ArmorMega.m_itemid: return !(autocvar_g_overkill_100a_anyway);
269 MUTATOR_HOOKFUNCTION(ok_SpectateCopy)
271 self.ammo_charge[self.weapon] = other.ammo_charge[other.weapon];
272 self.ok_use_ammocharge = other.ok_use_ammocharge;
277 MUTATOR_HOOKFUNCTION(ok_StartItems)
279 WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN));
281 if(WEP_RPC.weaponstart > 0) { ok_start_items |= WEPSET(RPC); }
282 if(WEP_HMG.weaponstart > 0) { ok_start_items |= WEPSET(HMG); }
284 start_items |= IT_UNLIMITED_WEAPON_AMMO;
285 start_weapons = warmup_start_weapons = ok_start_items;
290 MUTATOR_HOOKFUNCTION(ok_BuildMutatorsString)
292 ret_string = strcat(ret_string, ":OK");
296 MUTATOR_HOOKFUNCTION(ok_BuildMutatorsPrettyString)
298 ret_string = strcat(ret_string, ", Overkill");
302 MUTATOR_HOOKFUNCTION(ok_SetModname)
304 modname = "Overkill";
310 // hack to force overkill playermodels
311 cvar_settemp("sv_defaultcharacter", "1");
312 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");
313 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");
314 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");
321 precache_all_playermodels("models/ok_player/*.dpm");
323 addstat(STAT_OK_AMMO_CHARGE, AS_FLOAT, ok_use_ammocharge);
324 addstat(STAT_OK_AMMO_CHARGEPOOL, AS_FLOAT, ok_ammo_charge);
326 WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
327 WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
329 WEP_SHOTGUN.mdl = "ok_shotgun";
330 WEP_MACHINEGUN.mdl = "ok_mg";
331 WEP_VORTEX.mdl = "ok_sniper";
334 MUTATOR_DEFINITION(mutator_overkill)
336 MUTATOR_HOOK(ForbidThrowCurrentWeapon, ok_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
337 MUTATOR_HOOK(PlayerPreThink, ok_PlayerPreThink, CBC_ORDER_LAST);
338 MUTATOR_HOOK(PlayerSpawn, ok_PlayerSpawn, CBC_ORDER_ANY);
339 MUTATOR_HOOK(PlayerDamage_Calculate, ok_PlayerDamage_Calculate, CBC_ORDER_LAST);
340 MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, ok_PlayerDamage_SplitHealthArmor, CBC_ORDER_ANY);
341 MUTATOR_HOOK(PlayerDies, ok_PlayerDies, CBC_ORDER_ANY);
342 MUTATOR_HOOK(PlayerRegen, ok_PlayerRegen, CBC_ORDER_ANY);
343 MUTATOR_HOOK(OnEntityPreSpawn, ok_OnEntityPreSpawn, CBC_ORDER_ANY);
344 MUTATOR_HOOK(FilterItem, ok_ItemRemove, CBC_ORDER_ANY);
345 MUTATOR_HOOK(MonsterDropItem, ok_PlayerDies, CBC_ORDER_ANY);
346 MUTATOR_HOOK(SpectateCopy, ok_SpectateCopy, CBC_ORDER_ANY);
347 MUTATOR_HOOK(SetStartItems, ok_StartItems, CBC_ORDER_ANY);
348 MUTATOR_HOOK(BuildMutatorsString, ok_BuildMutatorsString, CBC_ORDER_ANY);
349 MUTATOR_HOOK(BuildMutatorsPrettyString, ok_BuildMutatorsPrettyString, CBC_ORDER_ANY);
350 MUTATOR_HOOK(SetModname, ok_SetModname, CBC_ORDER_ANY);
359 WEP_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
360 WEP_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED;