1 #include "mutator_overkill.qh"
6 void W_Blaster_Attack(float, float, float, float, float, float, float, float, float, float);
7 void spawnfunc_weapon_hmg();
8 void spawnfunc_weapon_rpc();
10 void ok_DecreaseCharge(entity ent, int wep)
12 if(!ent.ok_use_ammocharge) return;
14 entity wepent = get_weaponinfo(wep);
16 if(wepent.weapon == 0)
19 ent.ammo_charge[wep] -= max(0, cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
22 void ok_IncreaseCharge(entity ent, int wep)
24 entity wepent = get_weaponinfo(wep);
26 if(wepent.weapon == 0)
29 if(ent.ok_use_ammocharge)
30 if(!ent.BUTTON_ATCK) // not while attacking?
31 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);
34 float ok_CheckWeaponCharge(entity ent, int wep)
36 if(!ent.ok_use_ammocharge) return true;
38 entity wepent = get_weaponinfo(wep);
40 if(wepent.weapon == 0)
43 return (ent.ammo_charge[wep] >= cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
46 MUTATOR_HOOKFUNCTION(ok_PlayerDamage_Calculate)
48 if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target))
49 if(DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER.m_id))
53 if(frag_attacker != frag_target)
54 if(frag_target.health > 0)
55 if(frag_target.frozen == 0)
56 if(frag_target.deadflag == DEAD_NO)
58 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE);
66 MUTATOR_HOOKFUNCTION(ok_PlayerDamage_SplitHealthArmor)
69 self.ok_pauseregen_finished = max(self.ok_pauseregen_finished, time + 2);
73 MUTATOR_HOOKFUNCTION(ok_PlayerDies)
75 entity oldself = self;
76 entity targ = ((frag_attacker) ? frag_attacker : frag_target);
80 remove(other); // remove default item
87 self.pickup_anyway = true;
88 spawnfunc_item_armor_small();
89 self.movetype = MOVETYPE_TOSS;
91 self.reset = SUB_Remove;
92 setorigin(self, frag_target.origin + '0 0 32');
93 self.velocity = '0 0 200' + normalize(targ.origin - self.origin) * 500;
94 self.classname = "droppedweapon"; // hax
95 SUB_SetFade(self, time + 5, 1);
98 self.ok_lastwep = self.switchweapon;
103 MUTATOR_HOOKFUNCTION(ok_PlayerRegen)
105 // overkill's values are different, so use custom regen
108 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);
109 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);
111 float minf, maxf, limitf;
113 maxf = autocvar_g_balance_fuel_rotstable;
114 minf = autocvar_g_balance_fuel_regenstable;
115 limitf = autocvar_g_balance_fuel_limit;
117 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);
119 return true; // return true anyway, as frozen uses no regen
122 MUTATOR_HOOKFUNCTION(ok_ForbidThrowCurrentWeapon)
127 MUTATOR_HOOKFUNCTION(ok_PlayerPreThink)
129 if(intermission_running || gameover)
132 if(self.deadflag != DEAD_NO || !IS_PLAYER(self) || self.frozen)
137 self.switchweapon = self.ok_lastwep;
141 ok_IncreaseCharge(self, self.weapon);
143 if(self.BUTTON_ATCK2)
144 if(!forbidWeaponUse(self) || self.weapon_blocked) // allow if weapon is blocked
145 if(time >= self.jump_interval)
147 self.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor();
148 makevectors(self.v_angle);
150 int oldwep = self.weapon;
151 self.weapon = WEP_BLASTER.m_id;
153 WEP_BLASTER.m_id | HITTYPE_SECONDARY,
154 WEP_CVAR_SEC(vaporizer, shotangle),
155 WEP_CVAR_SEC(vaporizer, damage),
156 WEP_CVAR_SEC(vaporizer, edgedamage),
157 WEP_CVAR_SEC(vaporizer, radius),
158 WEP_CVAR_SEC(vaporizer, force),
159 WEP_CVAR_SEC(vaporizer, speed),
160 WEP_CVAR_SEC(vaporizer, spread),
161 WEP_CVAR_SEC(vaporizer, delay),
162 WEP_CVAR_SEC(vaporizer, lifetime)
164 self.weapon = oldwep;
167 self.weapon_blocked = false;
169 self.ok_ammo_charge = self.ammo_charge[self.weapon];
171 if(self.ok_use_ammocharge)
172 if(!ok_CheckWeaponCharge(self, self.weapon))
174 if(autocvar_g_overkill_ammo_charge_notice && time > self.ok_notice_time && self.BUTTON_ATCK && IS_REAL_CLIENT(self) && self.weapon == self.switchweapon)
176 //Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_OVERKILL_CHARGE);
177 self.ok_notice_time = time + 2;
178 play2(self, "weapons/dryfire.wav");
180 if(self.weaponentity.state != WS_CLEAR)
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 MUTATOR_HOOKFUNCTION(ok_OnEntityPreSpawn)
211 if(autocvar_g_powerups)
212 if(autocvar_g_overkill_powerups_replace)
214 if(self.classname == "item_strength")
216 entity wep = spawn();
217 setorigin(wep, self.origin);
218 setmodel(wep, "models/weapons/g_ok_hmg.md3");
219 wep.classname = "weapon_hmg";
221 wep.noalign = self.noalign;
223 wep.team = self.team;
224 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
225 wep.pickup_anyway = true;
226 wep.think = spawnfunc_weapon_hmg;
227 wep.nextthink = time + 0.1;
231 if(self.classname == "item_invincible")
233 entity wep = spawn();
234 setorigin(wep, self.origin);
235 setmodel(wep, "models/weapons/g_ok_rl.md3");
236 wep.classname = "weapon_rpc";
238 wep.noalign = self.noalign;
240 wep.team = self.team;
241 wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
242 wep.pickup_anyway = true;
243 wep.think = spawnfunc_weapon_rpc;
244 wep.nextthink = time + 0.1;
252 MUTATOR_HOOKFUNCTION(ok_ItemRemove)
259 case ITEM_HealthMega.m_itemid: return !(autocvar_g_overkill_100h_anyway);
260 case ITEM_ArmorMega.m_itemid: return !(autocvar_g_overkill_100a_anyway);
266 MUTATOR_HOOKFUNCTION(ok_SpectateCopy)
268 self.ammo_charge[self.weapon] = other.ammo_charge[other.weapon];
269 self.ok_use_ammocharge = other.ok_use_ammocharge;
274 MUTATOR_HOOKFUNCTION(ok_StartItems)
276 WepSet ok_start_items = (WEPSET_MACHINEGUN | WEPSET_VORTEX | WEPSET_SHOTGUN);
278 if(WEP_RPC.weaponstart > 0) { ok_start_items |= WEPSET_RPC; }
279 if(WEP_HMG.weaponstart > 0) { ok_start_items |= WEPSET_HMG; }
281 start_items |= IT_UNLIMITED_WEAPON_AMMO;
282 start_weapons = warmup_start_weapons = ok_start_items;
287 MUTATOR_HOOKFUNCTION(ok_BuildMutatorsString)
289 ret_string = strcat(ret_string, ":OK");
293 MUTATOR_HOOKFUNCTION(ok_BuildMutatorsPrettyString)
295 ret_string = strcat(ret_string, ", Overkill");
299 MUTATOR_HOOKFUNCTION(ok_SetModname)
301 modname = "Overkill";
307 // hack to force overkill playermodels
308 cvar_settemp("sv_defaultcharacter", "1");
309 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");
310 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");
311 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");
318 precache_all_playermodels("models/ok_player/*.dpm");
320 precache_model("models/weapons/h_ok_mg.iqm");
321 precache_model("models/weapons/v_ok_mg.md3");
322 precache_model("models/weapons/g_ok_mg.md3");
324 precache_model("models/weapons/h_ok_shotgun.iqm");
325 precache_model("models/weapons/v_ok_shotgun.md3");
326 precache_model("models/weapons/g_ok_shotgun.md3");
328 precache_model("models/weapons/h_ok_sniper.iqm");
329 precache_model("models/weapons/v_ok_sniper.md3");
330 precache_model("models/weapons/g_ok_sniper.md3");
332 precache_sound("weapons/dryfire.wav");
334 addstat(STAT_OK_AMMO_CHARGE, AS_FLOAT, ok_use_ammocharge);
335 addstat(STAT_OK_AMMO_CHARGEPOOL, AS_FLOAT, ok_ammo_charge);
337 WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
338 WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
340 WEP_SHOTGUN.mdl = "ok_shotgun";
341 WEP_MACHINEGUN.mdl = "ok_mg";
342 WEP_VORTEX.mdl = "ok_sniper";
345 MUTATOR_DEFINITION(mutator_overkill)
347 MUTATOR_HOOK(ForbidThrowCurrentWeapon, ok_ForbidThrowCurrentWeapon, CBC_ORDER_ANY);
348 MUTATOR_HOOK(PlayerPreThink, ok_PlayerPreThink, CBC_ORDER_LAST);
349 MUTATOR_HOOK(PlayerSpawn, ok_PlayerSpawn, CBC_ORDER_ANY);
350 MUTATOR_HOOK(PlayerDamage_Calculate, ok_PlayerDamage_Calculate, CBC_ORDER_LAST);
351 MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, ok_PlayerDamage_SplitHealthArmor, CBC_ORDER_ANY);
352 MUTATOR_HOOK(PlayerDies, ok_PlayerDies, CBC_ORDER_ANY);
353 MUTATOR_HOOK(PlayerRegen, ok_PlayerRegen, CBC_ORDER_ANY);
354 MUTATOR_HOOK(OnEntityPreSpawn, ok_OnEntityPreSpawn, CBC_ORDER_ANY);
355 MUTATOR_HOOK(FilterItem, ok_ItemRemove, CBC_ORDER_ANY);
356 MUTATOR_HOOK(MonsterDropItem, ok_PlayerDies, CBC_ORDER_ANY);
357 MUTATOR_HOOK(SpectateCopy, ok_SpectateCopy, CBC_ORDER_ANY);
358 MUTATOR_HOOK(SetStartItems, ok_StartItems, CBC_ORDER_ANY);
359 MUTATOR_HOOK(BuildMutatorsString, ok_BuildMutatorsString, CBC_ORDER_ANY);
360 MUTATOR_HOOK(BuildMutatorsPrettyString, ok_BuildMutatorsPrettyString, CBC_ORDER_ANY);
361 MUTATOR_HOOK(SetModname, ok_SetModname, CBC_ORDER_ANY);
370 WEP_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
371 WEP_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED;