5 #include "../cl_client.qh"
6 #include "../../common/buffs.qh"
8 void spawnfunc_item_minst_cells (void)
10 if (!g_instagib) { remove(self); return; }
12 self.ammo_cells = autocvar_g_instagib_ammo_drop;
14 StartItem ("models/items/a_cells.md3",
15 "misc/itempickup.wav", 45, 0,
16 "Vaporizer Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
19 void instagib_health_mega()
22 StartItem ("models/items/g_h100.md3",
23 "misc/megahealth.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
24 "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
27 .float instagib_nextthink;
28 .float instagib_needammo;
29 void instagib_stop_countdown(entity e)
31 if (!e.instagib_needammo)
33 Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_INSTAGIB_FINDAMMO);
34 e.instagib_needammo = false;
36 void instagib_ammocheck()
38 if(time < self.instagib_nextthink)
41 return; // not a player
43 if(self.deadflag || gameover)
44 instagib_stop_countdown(self);
45 else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
46 instagib_stop_countdown(self);
49 self.instagib_needammo = true;
52 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
53 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
55 else if (self.health <= 10)
57 Damage(self, self, self, 5, DEATH_NOAMMO, self.origin, '0 0 0');
58 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
60 else if (self.health <= 20)
62 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
63 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
65 else if (self.health <= 30)
67 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
68 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
70 else if (self.health <= 40)
72 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
73 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
75 else if (self.health <= 50)
77 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
78 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
80 else if (self.health <= 60)
82 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
83 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
85 else if (self.health <= 70)
87 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
88 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
90 else if (self.health <= 80)
92 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
93 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
95 else if (self.health <= 90)
97 Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
98 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
99 Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
103 Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
104 Damage(self, self, self, 10, DEATH_NOAMMO, self.origin, '0 0 0');
107 self.instagib_nextthink = time + 1;
110 MUTATOR_HOOKFUNCTION(instagib_MatchEnd)
113 FOR_EACH_PLAYER(head)
114 instagib_stop_countdown(head);
119 MUTATOR_HOOKFUNCTION(instagib_MonsterLoot)
121 other.monster_loot = spawnfunc_item_minst_cells;
126 MUTATOR_HOOKFUNCTION(instagib_MonsterSpawn)
128 // always refill ammo
129 if(self.monsterid == MON_MAGE)
135 MUTATOR_HOOKFUNCTION(instagib_BotShouldAttack)
137 if(checkentity.items & IT_STRENGTH)
143 MUTATOR_HOOKFUNCTION(instagib_MakePlayerObserver)
145 instagib_stop_countdown(self);
149 MUTATOR_HOOKFUNCTION(instagib_PlayerSpawn)
151 self.effects |= EF_FULLBRIGHT;
155 MUTATOR_HOOKFUNCTION(instagib_PlayerPreThink)
157 instagib_ammocheck();
161 MUTATOR_HOOKFUNCTION(instagib_PlayerRegen)
163 // no regeneration in instagib
167 MUTATOR_HOOKFUNCTION(instagib_PlayerPowerups)
169 if (!(self.effects & EF_FULLBRIGHT))
170 self.effects |= EF_FULLBRIGHT;
172 if (self.items & IT_STRENGTH)
174 play_countdown(self.strength_finished, "misc/poweroff.wav");
175 if (time > self.strength_finished)
177 self.alpha = default_player_alpha;
178 self.exteriorweaponentity.alpha = default_weapon_alpha;
179 self.items &= ~IT_STRENGTH;
180 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_INVISIBILITY);
185 if (time < self.strength_finished)
187 self.alpha = autocvar_g_instagib_invis_alpha;
188 self.exteriorweaponentity.alpha = autocvar_g_instagib_invis_alpha;
189 self.items |= IT_STRENGTH;
190 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_INVISIBILITY, self.netname);
191 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_INVISIBILITY);
195 if (self.items & IT_INVINCIBLE)
197 play_countdown(self.invincible_finished, "misc/poweroff.wav");
198 if (time > self.invincible_finished)
200 self.items &= ~IT_INVINCIBLE;
201 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERDOWN_SPEED);
206 if (time < self.invincible_finished)
208 self.items |= IT_INVINCIBLE;
209 Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_POWERUP_SPEED, self.netname);
210 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_POWERUP_SPEED);
216 MUTATOR_HOOKFUNCTION(instagib_PlayerPhysics)
218 if(self.items & IT_INVINCIBLE)
219 self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed;
224 MUTATOR_HOOKFUNCTION(instagib_SplitHealthArmor)
227 damage_take = frag_damage;
232 MUTATOR_HOOKFUNCTION(instagib_ForbidThrowing)
234 // weapon dropping on death handled by FilterItem
239 MUTATOR_HOOKFUNCTION(instagib_PlayerDamage)
241 if(autocvar_g_friendlyfire == 0 && SAME_TEAM(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
244 if(IS_PLAYER(frag_target))
246 if ((frag_deathtype == DEATH_FALL) ||
247 (frag_deathtype == DEATH_DROWN) ||
248 (frag_deathtype == DEATH_SLIME) ||
249 (frag_deathtype == DEATH_LAVA))
254 if(IS_PLAYER(frag_attacker))
255 if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
257 if(frag_target.armorvalue)
259 frag_target.armorvalue -= 1;
261 frag_target.damage_dealt += 1;
262 frag_attacker.damage_dealt += 1; // TODO: change this to a specific hitsound for armor hit
263 Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_target.armorvalue);
267 if(IS_PLAYER(frag_attacker) && DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
269 if(frag_deathtype & HITTYPE_SECONDARY)
271 frag_damage = frag_mirrordamage = 0;
273 if(frag_target != frag_attacker)
275 if(frag_target.health > 0) { Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE); }
276 frag_force = '0 0 0';
282 if(IS_PLAYER(frag_attacker))
283 if(frag_mirrordamage > 0)
285 // just lose extra LIVES, don't kill the player for mirror damage
286 if(frag_attacker.armorvalue > 0)
288 frag_attacker.armorvalue -= 1;
289 Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_attacker.armorvalue);
290 frag_attacker.damage_dealt += 1;
292 frag_mirrordamage = 0;
295 if((frag_target.buffs & BUFF_INVISIBLE) || (frag_target.items & IT_STRENGTH))
301 MUTATOR_HOOKFUNCTION(instagib_SetStartItems)
303 start_health = warmup_start_health = 100;
304 start_armorvalue = warmup_start_armorvalue = 0;
306 start_ammo_shells = warmup_start_ammo_shells = 0;
307 start_ammo_nails = warmup_start_ammo_nails = 0;
308 start_ammo_cells = warmup_start_ammo_cells = cvar("g_instagib_ammo_start");
309 start_ammo_plasma = warmup_start_ammo_plasma = 0;
310 start_ammo_rockets = warmup_start_ammo_rockets = 0;
311 start_ammo_fuel = warmup_start_ammo_fuel = 0;
313 start_weapons = warmup_start_weapons = WEPSET_VAPORIZER;
314 start_items |= IT_UNLIMITED_SUPERWEAPONS;
319 MUTATOR_HOOKFUNCTION(instagib_FilterItem)
321 if(self.classname == "item_cells")
322 return true; // no normal cells?
324 if(self.weapon == WEP_VAPORIZER && self.classname == "droppedweapon")
326 self.ammo_cells = autocvar_g_instagib_ammo_drop;
330 if(self.weapon == WEP_DEVASTATOR || self.weapon == WEP_VORTEX)
333 setorigin(e, self.origin);
337 spawnfunc_item_minst_cells();
342 if(self.flags & FL_POWERUP)
345 if(self.ammo_cells > autocvar_g_instagib_ammo_drop && self.classname != "item_minst_cells")
346 self.ammo_cells = autocvar_g_instagib_ammo_drop;
348 if(self.ammo_cells && !self.weapon)
354 MUTATOR_HOOKFUNCTION(instagib_CustomizeWaypoint)
356 entity e = WaypointSprite_getviewentity(other);
358 // if you have the invisibility powerup, sprites ALWAYS are restricted to your team
359 // but only apply this to real players, not to spectators
360 if((self.owner.flags & FL_CLIENT) && (self.owner.items & IT_STRENGTH) && (e == other))
361 if(DIFF_TEAM(self.owner, e))
367 MUTATOR_HOOKFUNCTION(instagib_ItemCountdown)
371 case IT_STRENGTH: item_name = "item-invis"; item_color = '0 0 1'; break;
372 case IT_NAILS: item_name = "item-extralife"; item_color = '1 0 0'; break;
373 case IT_INVINCIBLE: item_name = "item-speed"; item_color = '1 0 1'; break;
378 MUTATOR_HOOKFUNCTION(instagib_ItemTouch)
382 // play some cool sounds ;)
383 if (IS_CLIENT(other))
385 if(other.health <= 5)
386 Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_LASTSECOND);
387 else if(other.health < 50)
388 Send_Notification(NOTIF_ONE, other, MSG_ANNCE, ANNCE_INSTAGIB_NARROWLY);
391 if(other.health < 100)
394 return MUT_ITEMTOUCH_CONTINUE;
399 other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_instagib_extralives);
400 Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
401 return MUT_ITEMTOUCH_PICKUP;
404 return MUT_ITEMTOUCH_CONTINUE;
407 MUTATOR_HOOKFUNCTION(instagib_OnEntityPreSpawn)
409 if (!autocvar_g_powerups) { return false; }
410 if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega"))
416 e.think = spawnfunc_item_strength;
417 else if(random() < 0.6)
418 e.think = instagib_health_mega;
420 e.think = spawnfunc_item_invincible;
422 e.nextthink = time + 0.1;
423 e.spawnflags = self.spawnflags;
424 e.noalign = self.noalign;
425 setorigin(e, self.origin);
430 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsString)
432 ret_string = strcat(ret_string, ":instagib");
436 MUTATOR_HOOKFUNCTION(instagib_BuildMutatorsPrettyString)
438 ret_string = strcat(ret_string, ", instagib");
442 MUTATOR_HOOKFUNCTION(instagib_SetModname)
444 modname = "instagib";
448 MUTATOR_DEFINITION(mutator_instagib)
450 MUTATOR_HOOK(MatchEnd, instagib_MatchEnd, CBC_ORDER_ANY);
451 MUTATOR_HOOK(MonsterDropItem, instagib_MonsterLoot, CBC_ORDER_ANY);
452 MUTATOR_HOOK(MonsterSpawn, instagib_MonsterSpawn, CBC_ORDER_ANY);
453 MUTATOR_HOOK(BotShouldAttack, instagib_BotShouldAttack, CBC_ORDER_ANY);
454 MUTATOR_HOOK(PlayerPhysics, instagib_PlayerPhysics, CBC_ORDER_ANY);
455 MUTATOR_HOOK(PlayerSpawn, instagib_PlayerSpawn, CBC_ORDER_ANY);
456 MUTATOR_HOOK(PlayerDamage_Calculate, instagib_PlayerDamage, CBC_ORDER_ANY);
457 MUTATOR_HOOK(MakePlayerObserver, instagib_MakePlayerObserver, CBC_ORDER_ANY);
458 MUTATOR_HOOK(SetStartItems, instagib_SetStartItems, CBC_ORDER_ANY);
459 MUTATOR_HOOK(ItemTouch, instagib_ItemTouch, CBC_ORDER_ANY);
460 MUTATOR_HOOK(FilterItem, instagib_FilterItem, CBC_ORDER_ANY);
461 MUTATOR_HOOK(CustomizeWaypoint, instagib_CustomizeWaypoint, CBC_ORDER_ANY);
462 MUTATOR_HOOK(Item_RespawnCountdown, instagib_ItemCountdown, CBC_ORDER_ANY);
463 MUTATOR_HOOK(PlayerDamage_SplitHealthArmor, instagib_SplitHealthArmor, CBC_ORDER_ANY);
464 MUTATOR_HOOK(PlayerPowerups, instagib_PlayerPowerups, CBC_ORDER_ANY);
465 MUTATOR_HOOK(ForbidThrowCurrentWeapon, instagib_ForbidThrowing, CBC_ORDER_ANY);
466 MUTATOR_HOOK(PlayerPreThink, instagib_PlayerPreThink, CBC_ORDER_ANY);
467 MUTATOR_HOOK(PlayerRegen, instagib_PlayerRegen, CBC_ORDER_ANY);
468 MUTATOR_HOOK(OnEntityPreSpawn, instagib_OnEntityPreSpawn, CBC_ORDER_ANY);
469 MUTATOR_HOOK(BuildMutatorsString, instagib_BuildMutatorsString, CBC_ORDER_ANY);
470 MUTATOR_HOOK(BuildMutatorsPrettyString, instagib_BuildMutatorsPrettyString, CBC_ORDER_ANY);
471 MUTATOR_HOOK(SetModname, instagib_SetModname, CBC_ORDER_ANY);