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);
45 else if(autocvar_g_rm && autocvar_g_rm_laser)
47 if(!self.instagib_needammo)
49 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
50 self.instagib_needammo = true;
55 self.instagib_needammo = true;
58 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
59 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
61 else if (self.health <= 10)
63 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
64 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
66 else if (self.health <= 20)
68 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
69 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
71 else if (self.health <= 30)
73 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
74 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
76 else if (self.health <= 40)
78 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
79 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
81 else if (self.health <= 50)
83 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
84 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
86 else if (self.health <= 60)
88 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
89 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
91 else if (self.health <= 70)
93 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
94 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
96 else if (self.health <= 80)
98 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
99 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
101 else if (self.health <= 90)
103 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
104 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
105 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
109 Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
110 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
113 self.instagib_nextthink = time + 1;
116 MUTATOR_HOOKFUNCTION(instagib_MatchEnd)
119 FOR_EACH_PLAYER(head)
120 instagib_stop_countdown(head);
125 MUTATOR_HOOKFUNCTION(instagib_MonsterLoot)
127 other.monster_loot = spawnfunc_item_minst_cells;
132 MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
134 // always refill ammo
135 if(self.monsterid == MON_MAGE.monsterid)
141 MUTATOR_HOOKFUNCTION(instagib_BotShouldAttack)
143 if(checkentity.items & ITEM_Strength.m_itemid)
149 MUTATOR_HOOKFUNCTION(instagib_MakePlayerObserver)
151 instagib_stop_countdown(self);
155 MUTATOR_HOOKFUNCTION(instagib_PlayerSpawn)
157 self.effects |= EF_FULLBRIGHT;
161 MUTATOR_HOOKFUNCTION(instagib_PlayerPreThink)
163 instagib_ammocheck();
167 MUTATOR_HOOKFUNCTION(instagib_PlayerRegen)
169 // no regeneration in instagib
173 MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
175 if (!(self.effects & EF_FULLBRIGHT))
176 self.effects |= EF_FULLBRIGHT;
178 if (self.items & ITEM_Strength.m_itemid)
180 play_countdown(self.strength_finished, "misc/poweroff.wav");
181 if (time > self.strength_finished)
183 self.alpha = default_player_alpha;
184 self.exteriorweaponentity.alpha = default_weapon_alpha;
185 self.items &= ~ITEM_Strength.m_itemid;
186 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
191 if (time < self.strength_finished)
193 self.alpha = autocvar_g_instagib_invis_alpha;
194 self.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
195 self.items |= ITEM_Strength.m_itemid;
196 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_INVISIBILITY, self.netname);
197 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_INVISIBILITY);
201 if (self.items & ITEM_Shield.m_itemid)
203 play_countdown(self.invincible_finished, "misc/poweroff.wav");
204 if (time > self.invincible_finished)
206 self.items &= ~ITEM_Shield.m_itemid;
207 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_SPEED);
212 if (time < self.invincible_finished)
214 self.items |= ITEM_Shield.m_itemid;
215 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_SPEED, self.netname);
216 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_SPEED);
222 MUTATOR_HOOKFUNCTION(instagib_PlayerPhysics)
224 if(self.items & ITEM_Shield.m_itemid)
225 self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
230 MUTATOR_HOOKFUNCTION(instagib_SplitHealthArmor)
233 damage_take = frag_damage;
238 MUTATOR_HOOKFUNCTION(instagib_ForbidThrowing)
240 // weapon dropping on death handled by FilterItem
245 MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
247 if(autocvar_g_friendlyfire == 0 && SAME_TEAM(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
250 if(IS_PLAYER(frag_target))
252 if(frag_deathtype == DEATH_FALL)
253 frag_damage = 0; // never count fall damage
255 if(!autocvar_g_instagib_damagedbycontents)
256 switch(frag_deathtype)
265 if(IS_PLAYER(frag_attacker))
266 if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER.m_id))
268 if(frag_target.armorvalue)
270 frag_target.armorvalue -= 1;
272 frag_target.damage_dealt += 1;
273 frag_attacker.damage_dealt += 1; // TODO: change this to a specific hitsound for armor hit
274 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_target.armorvalue);
278 if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER.m_id))
280 if(frag_deathtype & HITTYPE_SECONDARY)
282 if(!autocvar_g_instagib_blaster_keepdamage)
283 frag_damage = frag_mirrordamage = 0;
285 if(frag_target != frag_attacker)
287 if(frag_damage <= 0 && frag_target.health > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
288 if(!autocvar_g_instagib_blaster_keepforce)
289 frag_force = '0 0 0';
295 if(IS_PLAYER(frag_attacker))
296 if(frag_mirrordamage > 0)
298 // just lose extra LIVES, don't kill the player for mirror damage
299 if(frag_attacker.armorvalue > 0)
301 frag_attacker.armorvalue -= 1;
302 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_attacker.armorvalue);
303 frag_attacker.damage_dealt += frag_mirrordamage;
305 frag_mirrordamage = 0;
308 if((frag_target.buffs & BUFF_INVISIBLE.m_itemid) || (frag_target.items & ITEM_Strength.m_itemid))
314 MUTATOR_HOOKFUNCTION(instagib_SetStartItems)
316 start_health = warmup_start_health = 100;
317 start_armorvalue = warmup_start_armorvalue = 0;
319 start_ammo_shells = warmup_start_ammo_shells = 0;
320 start_ammo_nails = warmup_start_ammo_nails = 0;
321 start_ammo_cells = warmup_start_ammo_cells = cvar("g_instagib_ammo_start");
322 start_ammo_plasma = warmup_start_ammo_plasma = 0;
323 start_ammo_rockets = warmup_start_ammo_rockets = 0;
324 start_ammo_fuel = warmup_start_ammo_fuel = 0;
326 start_weapons = warmup_start_weapons = WEPSET_VAPORIZER;
327 start_items |= IT_UNLIMITED_SUPERWEAPONS;
332 MUTATOR_HOOKFUNCTION(instagib_FilterItem)
334 if(self.classname == "item_cells")
335 return true; // no normal cells?
337 if(self.weapon == WEP_VAPORIZER.m_id && self.classname == "droppedweapon")
339 self.ammo_cells = autocvar_g_instagib_ammo_drop;
343 if(self.weapon == WEP_DEVASTATOR.m_id || self.weapon == WEP_VORTEX.m_id)
346 setorigin(e, self.origin);
347 e.noalign = self.noalign;
350 WITH(entity, self, e, spawnfunc_item_minst_cells());
354 if(self.flags & FL_POWERUP)
357 if(self.ammo_cells > autocvar_g_instagib_ammo_drop && self.classname != "item_minst_cells")
358 self.ammo_cells = autocvar_g_instagib_ammo_drop;
360 if(self.ammo_cells && !self.weapon)
366 MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
368 entity e = WaypointSprite_getviewentity(other);
370 // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
371 // but only apply this to real players, not to spectators
372 if((self.owner.flags & FL_CLIENT) && (self.owner.items & ITEM_Strength.m_itemid) && (e == other))
373 if(DIFF_TEAM(self.owner, e))
379 MUTATOR_HOOKFUNCTION(instagib_ItemCountdown)
383 case ITEM_Strength.m_itemid: item_name = "item-invis"; item_color = '0 0 1'; break;
384 case ITEM_ExtraLife.m_itemid: item_name = "item-extralife"; item_color = '1 0 0'; break;
385 case ITEM_Shield.m_itemid: item_name = "item-speed"; item_color = '1 0 1'; break;
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 if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.itemdef == ITEM_HealthMega))
436 e.think = spawnfunc_item_strength;
437 else if(random() < 0.6)
438 e.think = instagib_health_mega;
440 e.think = spawnfunc_item_invincible;
442 e.nextthink = time + 0.1;
443 e.spawnflags = self.spawnflags;
444 e.noalign = self.noalign;
445 setorigin(e, self.origin);
450 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsString)
452 ret_string = strcat(ret_string, ":instagib");
456 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsPrettyString)
458 ret_string = strcat(ret_string, ", instagib");
462 MUTATOR_HOOKFUNCTION(instagib_SetModname)
464 modname = "instagib";
468 MUTATOR_DEFINITION(mutator_instagib)
470 MUTATOR_HOOK(MatchEnd, instagib_MatchEnd, CBC_ORDER_ANY);
471 MUTATOR_HOOK(MonsterDropItem, instagib_MonsterLoot, CBC_ORDER_ANY);
472 MUTATOR_HOOK(MonsterSpawn, instagib_MonsterSpawn, CBC_ORDER_ANY);
473 MUTATOR_HOOK(BotShouldAttack, instagib_BotShouldAttack, CBC_ORDER_ANY);
474 MUTATOR_HOOK(PlayerPhysics, instagib_PlayerPhysics, CBC_ORDER_ANY);
475 MUTATOR_HOOK(PlayerSpawn, instagib_PlayerSpawn, CBC_ORDER_ANY);
476 MUTATOR_HOOK(PlayerDamage_Calculate, instagib_PlayerDamage, CBC_ORDER_ANY);
477 MUTATOR_HOOK(MakePlayerObserver, instagib_MakePlayerObserver, CBC_ORDER_ANY);
478 MUTATOR_HOOK(SetStartItems, instagib_SetStartItems, CBC_ORDER_ANY);
479 MUTATOR_HOOK(ItemTouch, instagib_ItemTouch, CBC_ORDER_ANY);
480 MUTATOR_HOOK(FilterItem, instagib_FilterItem, CBC_ORDER_ANY);
481 MUTATOR_HOOK(CustomizeWaypoint, instagib_CustomizeWaypoint, CBC_ORDER_ANY);
482 MUTATOR_HOOK(Item_RespawnCountdown, instagib_ItemCountdown, 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);