5 #include "../cl_client.qh"
6 #include "../../common/buffs.qh"
8 #include "../../common/items/all.qc"
10 void spawnfunc_item_minst_cells()
12 if (!g_instagib) { remove(self); return; }
13 if (!self.ammo_cells) self.ammo_cells = autocvar_g_instagib_ammo_drop;
14 StartItemA(ITEM_VaporizerCells);
17 void instagib_invisibility()
19 self.strength_finished = autocvar_g_balance_powerup_strength_time;
20 StartItemA(ITEM_Invisibility);
23 void instagib_extralife()
26 StartItemA(ITEM_ExtraLife);
31 self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
32 StartItemA(ITEM_Speed);
35 .float instagib_nextthink;
36 .float instagib_needammo;
37 void instagib_stop_countdown(entity e)
39 if (!e.instagib_needammo)
41 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_INSTAGIB_FINDAMMO);
42 e.instagib_needammo = false;
44 void instagib_ammocheck()
46 if(time < self.instagib_nextthink)
49 return; // not a player
51 if(self.deadflag || gameover)
52 instagib_stop_countdown(self);
53 else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
54 instagib_stop_countdown(self);
55 else if(autocvar_g_rm && autocvar_g_rm_laser)
57 if(!self.instagib_needammo)
59 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
60 self.instagib_needammo = true;
65 self.instagib_needammo = true;
68 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
69 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
71 else if (self.health <= 10)
73 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
74 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
76 else if (self.health <= 20)
78 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
79 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
81 else if (self.health <= 30)
83 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
84 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
86 else if (self.health <= 40)
88 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
89 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
91 else if (self.health <= 50)
93 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
94 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
96 else if (self.health <= 60)
98 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
99 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
101 else if (self.health <= 70)
103 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
104 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
106 else if (self.health <= 80)
108 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
109 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
111 else if (self.health <= 90)
113 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
114 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
115 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
119 Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
120 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
123 self.instagib_nextthink = time + 1;
126 MUTATOR_HOOKFUNCTION(instagib_MatchEnd)
129 FOR_EACH_PLAYER(head)
130 instagib_stop_countdown(head);
135 MUTATOR_HOOKFUNCTION(instagib_MonsterLoot)
137 other.monster_loot = spawnfunc_item_minst_cells;
142 MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
144 // always refill ammo
145 if(self.monsterid == MON_MAGE.monsterid)
151 MUTATOR_HOOKFUNCTION(instagib_BotShouldAttack)
153 if (checkentity.items & ITEM_Invisibility.m_itemid)
159 MUTATOR_HOOKFUNCTION(instagib_MakePlayerObserver)
161 instagib_stop_countdown(self);
165 MUTATOR_HOOKFUNCTION(instagib_PlayerSpawn)
167 self.effects |= EF_FULLBRIGHT;
171 MUTATOR_HOOKFUNCTION(instagib_PlayerPreThink)
173 instagib_ammocheck();
177 MUTATOR_HOOKFUNCTION(instagib_PlayerRegen)
179 // no regeneration in instagib
183 MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
185 if (!(self.effects & EF_FULLBRIGHT))
186 self.effects |= EF_FULLBRIGHT;
188 if (self.items & ITEM_Invisibility.m_itemid)
190 play_countdown(self.strength_finished, SND(POWEROFF));
191 if (time > self.strength_finished)
193 self.alpha = default_player_alpha;
194 self.exteriorweaponentity.alpha = default_weapon_alpha;
195 self.items &= ~ITEM_Invisibility.m_itemid;
196 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
201 if (time < self.strength_finished)
203 self.alpha = autocvar_g_instagib_invis_alpha;
204 self.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
205 self.items |= ITEM_Invisibility.m_itemid;
206 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_INVISIBILITY, self.netname);
207 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_INVISIBILITY);
211 if (self.items & ITEM_Speed.m_itemid)
213 play_countdown(self.invincible_finished, SND(POWEROFF));
214 if (time > self.invincible_finished)
216 self.items &= ~ITEM_Speed.m_itemid;
217 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_SPEED);
222 if (time < self.invincible_finished)
224 self.items |= ITEM_Speed.m_itemid;
225 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_SPEED, self.netname);
226 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_SPEED);
232 MUTATOR_HOOKFUNCTION(instagib_PlayerPhysics)
234 if(self.items & ITEM_Speed.m_itemid)
235 self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
240 MUTATOR_HOOKFUNCTION(instagib_SplitHealthArmor)
243 damage_take = frag_damage;
248 MUTATOR_HOOKFUNCTION(instagib_ForbidThrowing)
250 // weapon dropping on death handled by FilterItem
255 MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
257 if(autocvar_g_friendlyfire == 0 && SAME_TEAM(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
260 if(IS_PLAYER(frag_target))
262 if(frag_deathtype == DEATH_FALL)
263 frag_damage = 0; // never count fall damage
265 if(!autocvar_g_instagib_damagedbycontents)
266 switch(frag_deathtype)
275 if(IS_PLAYER(frag_attacker))
276 if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER.m_id))
278 if(frag_target.armorvalue)
280 frag_target.armorvalue -= 1;
282 frag_target.damage_dealt += 1;
283 frag_attacker.damage_dealt += 1; // TODO: change this to a specific hitsound for armor hit
284 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_target.armorvalue);
288 if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER.m_id))
290 if(frag_deathtype & HITTYPE_SECONDARY)
292 if(!autocvar_g_instagib_blaster_keepdamage)
293 frag_damage = frag_mirrordamage = 0;
295 if(frag_target != frag_attacker)
297 if(frag_damage <= 0 && frag_target.health > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
298 if(!autocvar_g_instagib_blaster_keepforce)
299 frag_force = '0 0 0';
305 if(IS_PLAYER(frag_attacker))
306 if(frag_mirrordamage > 0)
308 // just lose extra LIVES, don't kill the player for mirror damage
309 if(frag_attacker.armorvalue > 0)
311 frag_attacker.armorvalue -= 1;
312 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_attacker.armorvalue);
313 frag_attacker.damage_dealt += frag_mirrordamage;
315 frag_mirrordamage = 0;
318 if((frag_target.buffs & BUFF_INVISIBLE.m_itemid) || (frag_target.items & ITEM_Invisibility.m_itemid))
324 MUTATOR_HOOKFUNCTION(instagib_SetStartItems)
326 start_health = warmup_start_health = 100;
327 start_armorvalue = warmup_start_armorvalue = 0;
329 start_ammo_shells = warmup_start_ammo_shells = 0;
330 start_ammo_nails = warmup_start_ammo_nails = 0;
331 start_ammo_cells = warmup_start_ammo_cells = cvar("g_instagib_ammo_start");
332 start_ammo_plasma = warmup_start_ammo_plasma = 0;
333 start_ammo_rockets = warmup_start_ammo_rockets = 0;
334 start_ammo_fuel = warmup_start_ammo_fuel = 0;
336 start_weapons = warmup_start_weapons = WEPSET_VAPORIZER;
337 start_items |= IT_UNLIMITED_SUPERWEAPONS;
342 MUTATOR_HOOKFUNCTION(instagib_FilterItem)
344 if(self.classname == "item_cells")
345 return true; // no normal cells?
347 if(self.weapon == WEP_VAPORIZER.m_id && self.classname == "droppedweapon")
349 self.ammo_cells = autocvar_g_instagib_ammo_drop;
353 if(self.weapon == WEP_DEVASTATOR.m_id || self.weapon == WEP_VORTEX.m_id)
356 setorigin(e, self.origin);
357 e.noalign = self.noalign;
360 WITH(entity, self, e, spawnfunc_item_minst_cells());
364 if(self.flags & FL_POWERUP)
367 if(self.ammo_cells > autocvar_g_instagib_ammo_drop && self.classname != "item_minst_cells")
368 self.ammo_cells = autocvar_g_instagib_ammo_drop;
370 if(self.ammo_cells && !self.weapon)
376 MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
378 entity e = WaypointSprite_getviewentity(other);
380 // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
381 // but only apply this to real players, not to spectators
382 if((self.owner.flags & FL_CLIENT) && (self.owner.items & ITEM_Invisibility.m_itemid) && (e == other))
383 if(DIFF_TEAM(self.owner, e))
389 MUTATOR_HOOKFUNCTION(instagib_PlayerDies)
391 if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER.m_id))
392 frag_damage = 1000; // always gib if it was a vaporizer death
397 MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
401 // play some cool sounds ;)
402 if (IS_CLIENT(other))
404 if(other.health <= 5)
405 Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_LASTSECOND);
406 else if(other.health < 50)
407 Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_NARROWLY);
410 if(other.health < 100)
413 return MUT_ITEMTOUCH_CONTINUE;
418 other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_instagib_extralives);
419 Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
420 return MUT_ITEMTOUCH_PICKUP;
423 return MUT_ITEMTOUCH_CONTINUE;
426 MUTATOR_HOOKFUNCTION(instagib_OnEntityPreSpawn)
428 if (!autocvar_g_powerups) { return false; }
429 // Can't use .itemdef here
430 if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega"))
437 e.think = instagib_invisibility;
439 e.think = instagib_extralife;
441 e.think = instagib_speed;
443 e.nextthink = time + 0.1;
444 e.spawnflags = self.spawnflags;
445 e.noalign = self.noalign;
446 setorigin(e, self.origin);
451 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsString)
453 ret_string = strcat(ret_string, ":instagib");
457 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsPrettyString)
459 ret_string = strcat(ret_string, ", instagib");
463 MUTATOR_HOOKFUNCTION(instagib_SetModname)
465 modname = "instagib";
469 MUTATOR_DEFINITION(mutator_instagib)
471 MUTATOR_HOOK(MatchEnd, instagib_MatchEnd, CBC_ORDER_ANY);
472 MUTATOR_HOOK(MonsterDropItem, instagib_MonsterLoot, CBC_ORDER_ANY);
473 MUTATOR_HOOK(MonsterSpawn, instagib_MonsterSpawn, CBC_ORDER_ANY);
474 MUTATOR_HOOK(BotShouldAttack, instagib_BotShouldAttack, CBC_ORDER_ANY);
475 MUTATOR_HOOK(PlayerPhysics, instagib_PlayerPhysics, CBC_ORDER_ANY);
476 MUTATOR_HOOK(PlayerSpawn, instagib_PlayerSpawn, CBC_ORDER_ANY);
477 MUTATOR_HOOK(PlayerDamage_Calculate, instagib_PlayerDamage, CBC_ORDER_ANY);
478 MUTATOR_HOOK(MakePlayerObserver, instagib_MakePlayerObserver, CBC_ORDER_ANY);
479 MUTATOR_HOOK(SetStartItems, instagib_SetStartItems, CBC_ORDER_ANY);
480 MUTATOR_HOOK(ItemTouch, instagib_ItemTouch, CBC_ORDER_ANY);
481 MUTATOR_HOOK(FilterItem, instagib_FilterItem, CBC_ORDER_ANY);
482 MUTATOR_HOOK(CustomizeWaypoint, instagib_CustomizeWaypoint, CBC_ORDER_ANY);
483 MUTATOR_HOOK(PlayerDies, instagib_PlayerDies, CBC_ORDER_ANY);
484 MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, instagib_SplitHealthArmor, CBC_ORDER_ANY);
485 MUTATOR_HOOK(PlayerPowerups, instagib_PlayerPowerups, CBC_ORDER_ANY);
486 MUTATOR_HOOK(ForbidThrowCurrentWeapon, instagib_ForbidThrowing, CBC_ORDER_ANY);
487 MUTATOR_HOOK(PlayerPreThink, instagib_PlayerPreThink, CBC_ORDER_ANY);
488 MUTATOR_HOOK(PlayerRegen, instagib_PlayerRegen, CBC_ORDER_ANY);
489 MUTATOR_HOOK(OnEntityPreSpawn, instagib_OnEntityPreSpawn, CBC_ORDER_ANY);
490 MUTATOR_HOOK(BuildMutatorsString, instagib_BuildMutatorsString, CBC_ORDER_ANY);
491 MUTATOR_HOOK(BuildMutatorsPrettyString, instagib_BuildMutatorsPrettyString, CBC_ORDER_ANY);
492 MUTATOR_HOOK(SetModname, instagib_SetModname, CBC_ORDER_ANY);