5 #include "../cl_client.qh"
6 #include "../../common/buffs.qh"
8 #include "../../common/items/all.qc"
10 void spawnfunc_item_minst_cells (void)
12 if (!g_instagib) { remove(self); return; }
14 self.ammo_cells = autocvar_g_instagib_ammo_drop;
16 StartItemA (ITEM_VaporizerCells);
19 void instagib_health_mega()
22 StartItemA (ITEM_ExtraLife);
25 .float instagib_nextthink;
26 .float instagib_needammo;
27 void instagib_stop_countdown(entity e)
29 if (!e.instagib_needammo)
31 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_INSTAGIB_FINDAMMO);
32 e.instagib_needammo = false;
34 void instagib_ammocheck()
36 if(time < self.instagib_nextthink)
39 return; // not a player
41 if(self.deadflag || gameover)
42 instagib_stop_countdown(self);
43 else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
44 instagib_stop_countdown(self);
47 self.instagib_needammo = true;
50 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
51 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
53 else if (self.health <= 10)
55 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
56 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
58 else if (self.health <= 20)
60 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
61 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
63 else if (self.health <= 30)
65 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
66 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
68 else if (self.health <= 40)
70 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
71 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
73 else if (self.health <= 50)
75 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
76 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
78 else if (self.health <= 60)
80 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
81 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
83 else if (self.health <= 70)
85 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
86 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
88 else if (self.health <= 80)
90 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
91 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
93 else if (self.health <= 90)
95 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
96 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
97 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
101 Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
102 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
105 self.instagib_nextthink = time + 1;
108 MUTATOR_HOOKFUNCTION(instagib_MatchEnd)
111 FOR_EACH_PLAYER(head)
112 instagib_stop_countdown(head);
117 MUTATOR_HOOKFUNCTION(instagib_MonsterLoot)
119 other.monster_loot = spawnfunc_item_minst_cells;
124 MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
126 // always refill ammo
127 if(self.monsterid == MON_MAGE.monsterid)
133 MUTATOR_HOOKFUNCTION(instagib_BotShouldAttack)
135 if(checkentity.items & ITEM_Strength.m_itemid)
141 MUTATOR_HOOKFUNCTION(instagib_MakePlayerObserver)
143 instagib_stop_countdown(self);
147 MUTATOR_HOOKFUNCTION(instagib_PlayerSpawn)
149 self.effects |= EF_FULLBRIGHT;
153 MUTATOR_HOOKFUNCTION(instagib_PlayerPreThink)
155 instagib_ammocheck();
159 MUTATOR_HOOKFUNCTION(instagib_PlayerRegen)
161 // no regeneration in instagib
165 MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
167 if (!(self.effects & EF_FULLBRIGHT))
168 self.effects |= EF_FULLBRIGHT;
170 if (self.items & ITEM_Strength.m_itemid)
172 play_countdown(self.strength_finished, "misc/poweroff.wav");
173 if (time > self.strength_finished)
175 self.alpha = default_player_alpha;
176 self.exteriorweaponentity.alpha = default_weapon_alpha;
177 self.items &= ~ITEM_Strength.m_itemid;
178 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
183 if (time < self.strength_finished)
185 self.alpha = autocvar_g_instagib_invis_alpha;
186 self.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
187 self.items |= ITEM_Strength.m_itemid;
188 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_INVISIBILITY, self.netname);
189 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_INVISIBILITY);
193 if (self.items & ITEM_Shield.m_itemid)
195 play_countdown(self.invincible_finished, "misc/poweroff.wav");
196 if (time > self.invincible_finished)
198 self.items &= ~ITEM_Shield.m_itemid;
199 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_SPEED);
204 if (time < self.invincible_finished)
206 self.items |= ITEM_Shield.m_itemid;
207 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_SPEED, self.netname);
208 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_SPEED);
214 MUTATOR_HOOKFUNCTION(instagib_PlayerPhysics)
216 if(self.items & ITEM_Shield.m_itemid)
217 self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
222 MUTATOR_HOOKFUNCTION(instagib_SplitHealthArmor)
225 damage_take = frag_damage;
230 MUTATOR_HOOKFUNCTION(instagib_ForbidThrowing)
232 // weapon dropping on death handled by FilterItem
237 MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
239 if(autocvar_g_friendlyfire == 0 && SAME_TEAM(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
242 if(IS_PLAYER(frag_target))
244 if ((frag_deathtype == DEATH_FALL) ||
245 (frag_deathtype == DEATH_DROWN) ||
246 (frag_deathtype == DEATH_SLIME) ||
247 (frag_deathtype == DEATH_LAVA))
252 if(IS_PLAYER(frag_attacker))
253 if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
255 if(frag_target.armorvalue)
257 frag_target.armorvalue -= 1;
259 frag_target.damage_dealt += 1;
260 frag_attacker.damage_dealt += 1; // TODO: change this to a specific hitsound for armor hit
261 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_target.armorvalue);
265 if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
267 if(frag_deathtype & HITTYPE_SECONDARY)
269 frag_damage = frag_mirrordamage = 0;
271 if(frag_target != frag_attacker)
273 if(frag_target.health > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
274 frag_force = '0 0 0';
280 if(IS_PLAYER(frag_attacker))
281 if(frag_mirrordamage > 0)
283 // just lose extra LIVES, don't kill the player for mirror damage
284 if(frag_attacker.armorvalue > 0)
286 frag_attacker.armorvalue -= 1;
287 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_attacker.armorvalue);
288 frag_attacker.damage_dealt += 1;
290 frag_mirrordamage = 0;
293 if((frag_target.buffs & BUFF_INVISIBLE.m_itemid) || (frag_target.items & ITEM_Strength.m_itemid))
299 MUTATOR_HOOKFUNCTION(instagib_SetStartItems)
301 start_health = warmup_start_health = 100;
302 start_armorvalue = warmup_start_armorvalue = 0;
304 start_ammo_shells = warmup_start_ammo_shells = 0;
305 start_ammo_nails = warmup_start_ammo_nails = 0;
306 start_ammo_cells = warmup_start_ammo_cells = cvar("g_instagib_ammo_start");
307 start_ammo_plasma = warmup_start_ammo_plasma = 0;
308 start_ammo_rockets = warmup_start_ammo_rockets = 0;
309 start_ammo_fuel = warmup_start_ammo_fuel = 0;
311 start_weapons = warmup_start_weapons = WEPSET_VAPORIZER;
312 start_items |= IT_UNLIMITED_SUPERWEAPONS;
317 MUTATOR_HOOKFUNCTION(instagib_FilterItem)
319 if(self.classname == "item_cells")
320 return true; // no normal cells?
322 if(self.weapon == WEP_VAPORIZER && self.classname == "droppedweapon")
324 self.ammo_cells = autocvar_g_instagib_ammo_drop;
328 if(self.weapon == WEP_DEVASTATOR || self.weapon == WEP_VORTEX)
331 setorigin(e, self.origin);
335 spawnfunc_item_minst_cells();
340 if(self.flags & FL_POWERUP)
343 if(self.ammo_cells > autocvar_g_instagib_ammo_drop && self.classname != "item_minst_cells")
344 self.ammo_cells = autocvar_g_instagib_ammo_drop;
346 if(self.ammo_cells && !self.weapon)
352 MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
354 entity e = WaypointSprite_getviewentity(other);
356 // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
357 // but only apply this to real players, not to spectators
358 if((self.owner.flags & FL_CLIENT) && (self.owner.items & ITEM_Strength.m_itemid) && (e == other))
359 if(DIFF_TEAM(self.owner, e))
365 MUTATOR_HOOKFUNCTION(instagib_ItemCountdown)
369 case ITEM_Strength.m_itemid: item_name = "item-invis"; item_color = '0 0 1'; break;
370 case ITEM_ExtraLife.m_itemid: item_name = "item-extralife"; item_color = '1 0 0'; break;
371 case ITEM_Shield.m_itemid: item_name = "item-speed"; item_color = '1 0 1'; break;
376 MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
380 // play some cool sounds ;)
381 if (IS_CLIENT(other))
383 if(other.health <= 5)
384 Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_LASTSECOND);
385 else if(other.health < 50)
386 Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_NARROWLY);
389 if(other.health < 100)
392 return MUT_ITEMTOUCH_CONTINUE;
397 other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_instagib_extralives);
398 Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
399 return MUT_ITEMTOUCH_PICKUP;
402 return MUT_ITEMTOUCH_CONTINUE;
405 MUTATOR_HOOKFUNCTION(instagib_OnEntityPreSpawn)
407 if (!autocvar_g_powerups) { return false; }
408 if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.itemdef == ITEM_HealthMega))
414 e.think = spawnfunc_item_strength;
415 else if(random() < 0.6)
416 e.think = instagib_health_mega;
418 e.think = spawnfunc_item_invincible;
420 e.nextthink = time + 0.1;
421 e.spawnflags = self.spawnflags;
422 e.noalign = self.noalign;
423 setorigin(e, self.origin);
428 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsString)
430 ret_string = strcat(ret_string, ":instagib");
434 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsPrettyString)
436 ret_string = strcat(ret_string, ", instagib");
440 MUTATOR_HOOKFUNCTION(instagib_SetModname)
442 modname = "instagib";
446 MUTATOR_DEFINITION(mutator_instagib)
448 MUTATOR_HOOK(MatchEnd, instagib_MatchEnd, CBC_ORDER_ANY);
449 MUTATOR_HOOK(MonsterDropItem, instagib_MonsterLoot, CBC_ORDER_ANY);
450 MUTATOR_HOOK(MonsterSpawn, instagib_MonsterSpawn, CBC_ORDER_ANY);
451 MUTATOR_HOOK(BotShouldAttack, instagib_BotShouldAttack, CBC_ORDER_ANY);
452 MUTATOR_HOOK(PlayerPhysics, instagib_PlayerPhysics, CBC_ORDER_ANY);
453 MUTATOR_HOOK(PlayerSpawn, instagib_PlayerSpawn, CBC_ORDER_ANY);
454 MUTATOR_HOOK(PlayerDamage_Calculate, instagib_PlayerDamage, CBC_ORDER_ANY);
455 MUTATOR_HOOK(MakePlayerObserver, instagib_MakePlayerObserver, CBC_ORDER_ANY);
456 MUTATOR_HOOK(SetStartItems, instagib_SetStartItems, CBC_ORDER_ANY);
457 MUTATOR_HOOK(ItemTouch, instagib_ItemTouch, CBC_ORDER_ANY);
458 MUTATOR_HOOK(FilterItem, instagib_FilterItem, CBC_ORDER_ANY);
459 MUTATOR_HOOK(CustomizeWaypoint, instagib_CustomizeWaypoint, CBC_ORDER_ANY);
460 MUTATOR_HOOK(Item_RespawnCountdown, instagib_ItemCountdown, CBC_ORDER_ANY);
461 MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, instagib_SplitHealthArmor, CBC_ORDER_ANY);
462 MUTATOR_HOOK(PlayerPowerups, instagib_PlayerPowerups, CBC_ORDER_ANY);
463 MUTATOR_HOOK(ForbidThrowCurrentWeapon, instagib_ForbidThrowing, CBC_ORDER_ANY);
464 MUTATOR_HOOK(PlayerPreThink, instagib_PlayerPreThink, CBC_ORDER_ANY);
465 MUTATOR_HOOK(PlayerRegen, instagib_PlayerRegen, CBC_ORDER_ANY);
466 MUTATOR_HOOK(OnEntityPreSpawn, instagib_OnEntityPreSpawn, CBC_ORDER_ANY);
467 MUTATOR_HOOK(BuildMutatorsString, instagib_BuildMutatorsString, CBC_ORDER_ANY);
468 MUTATOR_HOOK(BuildMutatorsPrettyString, instagib_BuildMutatorsPrettyString, CBC_ORDER_ANY);
469 MUTATOR_HOOK(SetModname, instagib_SetModname, CBC_ORDER_ANY);