4 #include "../cl_client.qh"
5 #include "../../common/buffs/all.qh"
7 #include "../../common/items/all.qc"
9 spawnfunc(item_minst_cells)
11 if (!g_instagib) { remove(self); return; }
12 if (!self.ammo_cells) self.ammo_cells = autocvar_g_instagib_ammo_drop;
13 StartItemA(ITEM_VaporizerCells);
16 void instagib_invisibility()
18 self.strength_finished = autocvar_g_balance_powerup_strength_time;
19 StartItemA(ITEM_Invisibility);
22 void instagib_extralife()
25 StartItemA(ITEM_ExtraLife);
30 self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
31 StartItemA(ITEM_Speed);
34 .float instagib_nextthink;
35 .float instagib_needammo;
36 void instagib_stop_countdown(entity e)
38 if (!e.instagib_needammo)
40 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_INSTAGIB_FINDAMMO);
41 e.instagib_needammo = false;
43 void instagib_ammocheck()
45 if(time < self.instagib_nextthink)
48 return; // not a player
50 if(self.deadflag || gameover)
51 instagib_stop_countdown(self);
52 else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
53 instagib_stop_countdown(self);
54 else if(autocvar_g_rm && autocvar_g_rm_laser)
56 if(!self.instagib_needammo)
58 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
59 self.instagib_needammo = true;
64 self.instagib_needammo = true;
67 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
68 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
70 else if (self.health <= 10)
72 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
73 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
75 else if (self.health <= 20)
77 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
78 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
80 else if (self.health <= 30)
82 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
83 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
85 else if (self.health <= 40)
87 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
88 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
90 else if (self.health <= 50)
92 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
93 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
95 else if (self.health <= 60)
97 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
98 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
100 else if (self.health <= 70)
102 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
103 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
105 else if (self.health <= 80)
107 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
108 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
110 else if (self.health <= 90)
112 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
113 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
114 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
118 Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
119 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
122 self.instagib_nextthink = time + 1;
125 MUTATOR_HOOKFUNCTION(instagib_MatchEnd)
128 FOR_EACH_PLAYER(head)
129 instagib_stop_countdown(head);
134 MUTATOR_HOOKFUNCTION(instagib_MonsterLoot)
136 other.monster_loot = spawnfunc_item_minst_cells;
141 MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
143 // always refill ammo
144 if(self.monsterid == MON_MAGE.monsterid)
150 MUTATOR_HOOKFUNCTION(instagib_BotShouldAttack)
152 if (checkentity.items & ITEM_Invisibility.m_itemid)
158 MUTATOR_HOOKFUNCTION(instagib_MakePlayerObserver)
160 instagib_stop_countdown(self);
164 MUTATOR_HOOKFUNCTION(instagib_PlayerSpawn)
166 self.effects |= EF_FULLBRIGHT;
170 MUTATOR_HOOKFUNCTION(instagib_PlayerPreThink)
172 instagib_ammocheck();
176 MUTATOR_HOOKFUNCTION(instagib_PlayerRegen)
178 // no regeneration in instagib
182 MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
184 if (!(self.effects & EF_FULLBRIGHT))
185 self.effects |= EF_FULLBRIGHT;
187 if (self.items & ITEM_Invisibility.m_itemid)
189 play_countdown(self.strength_finished, SND(POWEROFF));
190 if (time > self.strength_finished)
192 self.alpha = default_player_alpha;
193 self.exteriorweaponentity.alpha = default_weapon_alpha;
194 self.items &= ~ITEM_Invisibility.m_itemid;
195 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
200 if (time < self.strength_finished)
202 self.alpha = autocvar_g_instagib_invis_alpha;
203 self.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
204 self.items |= ITEM_Invisibility.m_itemid;
205 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_INVISIBILITY, self.netname);
206 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_INVISIBILITY);
210 if (self.items & ITEM_Speed.m_itemid)
212 play_countdown(self.invincible_finished, SND(POWEROFF));
213 if (time > self.invincible_finished)
215 self.items &= ~ITEM_Speed.m_itemid;
216 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_SPEED);
221 if (time < self.invincible_finished)
223 self.items |= ITEM_Speed.m_itemid;
224 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_SPEED, self.netname);
225 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_SPEED);
231 .float stat_sv_maxspeed;
233 MUTATOR_HOOKFUNCTION(instagib_PlayerPhysics)
235 if(self.items & ITEM_Speed.m_itemid)
236 self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
241 MUTATOR_HOOKFUNCTION(instagib_SplitHealthArmor)
244 damage_take = frag_damage;
249 MUTATOR_HOOKFUNCTION(instagib_ForbidThrowing)
251 // weapon dropping on death handled by FilterItem
256 MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
258 if(autocvar_g_friendlyfire == 0 && SAME_TEAM(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
261 if(IS_PLAYER(frag_target))
263 if(frag_deathtype == DEATH_FALL)
264 frag_damage = 0; // never count fall damage
266 if(!autocvar_g_instagib_damagedbycontents)
267 switch(frag_deathtype)
276 if(IS_PLAYER(frag_attacker))
277 if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER.m_id))
279 if(frag_target.armorvalue)
281 frag_target.armorvalue -= 1;
283 frag_target.damage_dealt += 1;
284 frag_attacker.damage_dealt += 1; // TODO: change this to a specific hitsound for armor hit
285 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_target.armorvalue);
289 if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER.m_id))
291 if(frag_deathtype & HITTYPE_SECONDARY)
293 if(!autocvar_g_instagib_blaster_keepdamage)
294 frag_damage = frag_mirrordamage = 0;
296 if(frag_target != frag_attacker)
298 if(frag_damage <= 0 && frag_target.health > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
299 if(!autocvar_g_instagib_blaster_keepforce)
300 frag_force = '0 0 0';
306 if(IS_PLAYER(frag_attacker))
307 if(frag_mirrordamage > 0)
309 // just lose extra LIVES, don't kill the player for mirror damage
310 if(frag_attacker.armorvalue > 0)
312 frag_attacker.armorvalue -= 1;
313 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_attacker.armorvalue);
314 frag_attacker.damage_dealt += frag_mirrordamage;
316 frag_mirrordamage = 0;
319 if((frag_target.buffs & BUFF_INVISIBLE.m_itemid) || (frag_target.items & ITEM_Invisibility.m_itemid))
325 MUTATOR_HOOKFUNCTION(instagib_SetStartItems)
327 start_health = warmup_start_health = 100;
328 start_armorvalue = warmup_start_armorvalue = 0;
330 start_ammo_shells = warmup_start_ammo_shells = 0;
331 start_ammo_nails = warmup_start_ammo_nails = 0;
332 start_ammo_cells = warmup_start_ammo_cells = cvar("g_instagib_ammo_start");
333 start_ammo_plasma = warmup_start_ammo_plasma = 0;
334 start_ammo_rockets = warmup_start_ammo_rockets = 0;
335 start_ammo_fuel = warmup_start_ammo_fuel = 0;
337 start_weapons = warmup_start_weapons = WEPSET(VAPORIZER);
338 start_items |= IT_UNLIMITED_SUPERWEAPONS;
343 MUTATOR_HOOKFUNCTION(instagib_FilterItem)
345 if(self.classname == "item_cells")
346 return true; // no normal cells?
348 if(self.weapon == WEP_VAPORIZER.m_id && self.classname == "droppedweapon")
350 self.ammo_cells = autocvar_g_instagib_ammo_drop;
354 if(self.weapon == WEP_DEVASTATOR.m_id || self.weapon == WEP_VORTEX.m_id)
357 setorigin(e, self.origin);
358 e.noalign = self.noalign;
361 WITH(entity, self, e, spawnfunc_item_minst_cells(e));
365 if(self.flags & FL_POWERUP)
368 if(self.ammo_cells > autocvar_g_instagib_ammo_drop && self.classname != "item_minst_cells")
369 self.ammo_cells = autocvar_g_instagib_ammo_drop;
371 if(self.ammo_cells && !self.weapon)
377 MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
379 entity e = WaypointSprite_getviewentity(other);
381 // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
382 // but only apply this to real players, not to spectators
383 if((self.owner.flags & FL_CLIENT) && (self.owner.items & ITEM_Invisibility.m_itemid) && (e == other))
384 if(DIFF_TEAM(self.owner, e))
390 MUTATOR_HOOKFUNCTION(instagib_PlayerDies)
392 if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER.m_id))
393 frag_damage = 1000; // always gib if it was a vaporizer death
398 MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
402 // play some cool sounds ;)
403 if (IS_CLIENT(other))
405 if(other.health <= 5)
406 Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_LASTSECOND);
407 else if(other.health < 50)
408 Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_NARROWLY);
411 if(other.health < 100)
414 return MUT_ITEMTOUCH_CONTINUE;
419 other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_instagib_extralives);
420 Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
421 return MUT_ITEMTOUCH_PICKUP;
424 return MUT_ITEMTOUCH_CONTINUE;
427 MUTATOR_HOOKFUNCTION(instagib_OnEntityPreSpawn)
429 if (!autocvar_g_powerups) { return false; }
430 // Can't use .itemdef here
431 if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega"))
438 e.think = instagib_invisibility;
440 e.think = instagib_extralife;
442 e.think = instagib_speed;
444 e.nextthink = time + 0.1;
445 e.spawnflags = self.spawnflags;
446 e.noalign = self.noalign;
447 setorigin(e, self.origin);
452 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsString)
454 ret_string = strcat(ret_string, ":instagib");
458 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsPrettyString)
460 ret_string = strcat(ret_string, ", instagib");
464 MUTATOR_HOOKFUNCTION(instagib_SetModname)
466 modname = "instagib";
470 MUTATOR_DEFINITION(mutator_instagib)
472 MUTATOR_HOOK(MatchEnd, instagib_MatchEnd, CBC_ORDER_ANY);
473 MUTATOR_HOOK(MonsterDropItem, instagib_MonsterLoot, CBC_ORDER_ANY);
474 MUTATOR_HOOK(MonsterSpawn, instagib_MonsterSpawn, CBC_ORDER_ANY);
475 MUTATOR_HOOK(BotShouldAttack, instagib_BotShouldAttack, CBC_ORDER_ANY);
476 MUTATOR_HOOK(PlayerPhysics, instagib_PlayerPhysics, CBC_ORDER_ANY);
477 MUTATOR_HOOK(PlayerSpawn, instagib_PlayerSpawn, CBC_ORDER_ANY);
478 MUTATOR_HOOK(PlayerDamage_Calculate, instagib_PlayerDamage, CBC_ORDER_ANY);
479 MUTATOR_HOOK(MakePlayerObserver, instagib_MakePlayerObserver, CBC_ORDER_ANY);
480 MUTATOR_HOOK(SetStartItems, instagib_SetStartItems, CBC_ORDER_ANY);
481 MUTATOR_HOOK(ItemTouch, instagib_ItemTouch, CBC_ORDER_ANY);
482 MUTATOR_HOOK(FilterItem, instagib_FilterItem, CBC_ORDER_ANY);
483 MUTATOR_HOOK(CustomizeWaypoint, instagib_CustomizeWaypoint, CBC_ORDER_ANY);
484 MUTATOR_HOOK(PlayerDies, instagib_PlayerDies, CBC_ORDER_ANY);
485 MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, instagib_SplitHealthArmor, CBC_ORDER_ANY);
486 MUTATOR_HOOK(PlayerPowerups, instagib_PlayerPowerups, CBC_ORDER_ANY);
487 MUTATOR_HOOK(ForbidThrowCurrentWeapon, instagib_ForbidThrowing, CBC_ORDER_ANY);
488 MUTATOR_HOOK(PlayerPreThink, instagib_PlayerPreThink, CBC_ORDER_ANY);
489 MUTATOR_HOOK(PlayerRegen, instagib_PlayerRegen, CBC_ORDER_ANY);
490 MUTATOR_HOOK(OnEntityPreSpawn, instagib_OnEntityPreSpawn, CBC_ORDER_ANY);
491 MUTATOR_HOOK(BuildMutatorsString, instagib_BuildMutatorsString, CBC_ORDER_ANY);
492 MUTATOR_HOOK(BuildMutatorsPrettyString, instagib_BuildMutatorsPrettyString, CBC_ORDER_ANY);
493 MUTATOR_HOOK(SetModname, instagib_SetModname, CBC_ORDER_ANY);