1 #include "sv_overkill.qh"
6 string autocvar_g_overkill;
8 bool autocvar_g_overkill_powerups_replace;
10 bool autocvar_g_overkill_itemwaypoints = true;
12 .Weapon ok_lastwep[MAX_WEAPONSLOTS];
14 REGISTER_MUTATOR(ok, expr_evaluate(autocvar_g_overkill) && !cvar("g_instagib") && !g_nexball && cvar_string("g_mod_balance") == "Overkill")
18 precache_all_playermodels("models/ok_player/*.dpm");
20 if (autocvar_g_overkill_filter_healthmega)
22 ITEM_HealthMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
24 if (autocvar_g_overkill_filter_armormedium)
26 ITEM_ArmorMedium.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
28 if (autocvar_g_overkill_filter_armorbig)
30 ITEM_ArmorBig.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
32 if (autocvar_g_overkill_filter_armormega)
34 ITEM_ArmorMega.spawnflags |= ITEM_FLAG_MUTATORBLOCKED;
37 WEP_RPC.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
38 WEP_HMG.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
40 WEP_SHOTGUN.mdl = "ok_shotgun";
41 WEP_MACHINEGUN.mdl = "ok_mg";
42 WEP_VORTEX.mdl = "ok_sniper";
47 ITEM_HealthMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
48 ITEM_ArmorMedium.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
49 ITEM_ArmorBig.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
50 ITEM_ArmorMega.spawnflags &= ~ITEM_FLAG_MUTATORBLOCKED;
52 WEP_RPC.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
53 WEP_HMG.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
57 void W_Blaster_Attack(entity, .entity, float, float, float, float, float, float, float, float, float, float);
59 MUTATOR_HOOKFUNCTION(ok, Damage_Calculate, CBC_ORDER_LAST)
61 entity frag_attacker = M_ARGV(1, entity);
62 entity frag_target = M_ARGV(2, entity);
63 float frag_deathtype = M_ARGV(3, float);
65 if(IS_PLAYER(frag_attacker) && (IS_PLAYER(frag_target) || IS_VEHICLE(frag_target) || IS_TURRET(frag_target)))
66 if(DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
68 if(frag_attacker != frag_target)
69 if(!STAT(FROZEN, frag_target))
70 if(!IS_DEAD(frag_target))
72 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE);
73 M_ARGV(6, vector) = '0 0 0'; // force
76 M_ARGV(4, float) = 0; // damage
80 void ok_DropItem(entity this, entity targ)
84 Item_InitializeLoot(e, "item_armor_small", this.origin + '0 0 32',
85 '0 0 200' + normalize(targ.origin - this.origin) * 500, 5);
88 MUTATOR_HOOKFUNCTION(ok, PlayerDies)
90 entity frag_attacker = M_ARGV(1, entity);
91 entity frag_target = M_ARGV(2, entity);
93 entity targ = ((frag_attacker) ? frag_attacker : frag_target);
95 ok_DropItem(frag_target, targ);
97 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
99 .entity weaponentity = weaponentities[slot];
101 frag_target.ok_lastwep[slot] = frag_target.(weaponentity).m_switchweapon;
105 MUTATOR_HOOKFUNCTION(ok, MonsterDropItem)
107 entity mon = M_ARGV(0, entity);
108 entity olditem = M_ARGV(1, entity);
109 entity frag_attacker = M_ARGV(2, entity);
113 M_ARGV(1, entity) = NULL;
115 ok_DropItem(mon, frag_attacker);
118 MUTATOR_HOOKFUNCTION(ok, ForbidThrowCurrentWeapon)
123 MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
128 entity player = M_ARGV(0, entity);
130 if(IS_DEAD(player) || !IS_PLAYER(player) || STAT(FROZEN, player))
133 if(PHYS_INPUT_BUTTON_ATCK2(player) && time >= player.jump_interval)
134 if( !forbidWeaponUse(player)
135 || (round_handler_IsActive() && !round_handler_IsRoundStarted()) )
137 player.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor(player);
138 makevectors(player.v_angle);
140 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
142 .entity weaponentity = weaponentities[slot];
144 if(player.(weaponentity).m_weapon == WEP_Null && slot != 0)
147 Weapon oldwep = player.(weaponentity).m_weapon;
148 player.(weaponentity).m_weapon = WEP_BLASTER;
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 player.(weaponentity).m_weapon = oldwep;
167 PHYS_INPUT_BUTTON_ATCK2(player) = false;
170 MUTATOR_HOOKFUNCTION(ok, PlayerWeaponSelect)
172 entity player = M_ARGV(0, entity);
174 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
176 .entity weaponentity = weaponentities[slot];
177 entity thiswep = player.(weaponentity);
179 if(player.ok_lastwep[slot] && player.ok_lastwep[slot] != WEP_Null)
181 Weapon newwep = player.ok_lastwep[slot];
182 if(player.ok_lastwep[slot] == WEP_HMG)
183 newwep = WEP_MACHINEGUN;
184 if(player.ok_lastwep[slot] == WEP_RPC)
186 thiswep.m_switchweapon = newwep;
187 player.ok_lastwep[slot] = WEP_Null;
192 void self_spawnfunc_weapon_hmg(entity this) { spawnfunc_weapon_hmg(this); }
193 void self_spawnfunc_weapon_rpc(entity this) { spawnfunc_weapon_rpc(this); }
195 MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
197 entity ent = M_ARGV(0, entity);
199 if(autocvar_g_powerups)
200 if(autocvar_g_overkill_powerups_replace)
202 if(ent.classname == "item_strength")
204 entity wep = new(weapon_hmg);
205 setorigin(wep, ent.origin);
206 setmodel(wep, MDL_OK_HMG);
208 wep.noalign = Item_ShouldKeepPosition(ent);
211 wep.respawntime = g_pickup_respawntime_superweapon;
212 wep.pickup_anyway = true;
213 wep.spawnfunc_checked = true;
214 setthink(wep, self_spawnfunc_weapon_hmg);
215 wep.nextthink = time + 0.1;
218 else if(ent.classname == "item_shield")
220 entity wep = new(weapon_rpc);
221 setorigin(wep, ent.origin);
222 setmodel(wep, MDL_OK_RPC);
224 wep.noalign = Item_ShouldKeepPosition(ent);
227 wep.respawntime = g_pickup_respawntime_superweapon;
228 wep.pickup_anyway = true;
229 wep.spawnfunc_checked = true;
230 setthink(wep, self_spawnfunc_weapon_rpc);
231 wep.nextthink = time + 0.1;
237 bool ok_HandleItemWaypoints(entity e)
239 if(!autocvar_g_overkill_itemwaypoints)
240 return false; // don't handle it
244 case ITEM_HealthMega: return true;
245 case ITEM_ArmorMedium: return true;
246 case ITEM_ArmorBig: return true;
247 case ITEM_ArmorMega: return true;
253 MUTATOR_HOOKFUNCTION(ok, Item_RespawnCountdown)
255 entity item = M_ARGV(0, entity);
256 return ok_HandleItemWaypoints(item);
259 MUTATOR_HOOKFUNCTION(ok, Item_ScheduleRespawn)
261 entity item = M_ARGV(0, entity);
262 return ok_HandleItemWaypoints(item);
265 MUTATOR_HOOKFUNCTION(ok, FilterItem)
267 entity item = M_ARGV(0, entity);
275 MUTATOR_HOOKFUNCTION(ok, SetStartItems, CBC_ORDER_LAST)
277 WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN));
279 if(WEP_RPC.weaponstart > 0) { ok_start_items |= WEPSET(RPC); }
280 if(WEP_HMG.weaponstart > 0) { ok_start_items |= WEPSET(HMG); }
282 start_items |= IT_UNLIMITED_WEAPON_AMMO;
283 start_weapons = warmup_start_weapons = ok_start_items;
286 MUTATOR_HOOKFUNCTION(ok, SetWeaponArena)
288 // turn weapon arena off
289 M_ARGV(0, string) = "off";
292 MUTATOR_HOOKFUNCTION(ok, BuildMutatorsString)
294 M_ARGV(0, string) = strcat(M_ARGV(0, string), ":OK");
297 MUTATOR_HOOKFUNCTION(ok, BuildMutatorsPrettyString)
299 M_ARGV(0, string) = strcat(M_ARGV(0, string), ", Overkill");
302 MUTATOR_HOOKFUNCTION(ok, SetModname)
304 M_ARGV(0, string) = "Overkill";