#include "items.qc"
+#ifdef SVQC
+float autocvar_g_instagib_invis_alpha;
+#endif
+
#endif
#ifdef IMPLEMENTATION
#ifdef SVQC
-#include "../../../../server/cl_client.qh"
-#include "../../../buffs/all.qh"
+int autocvar_g_instagib_ammo_drop;
+int autocvar_g_instagib_extralives;
+float autocvar_g_instagib_speed_highspeed;
+
+#include <server/cl_client.qh>
-#include "../../../items/all.qc"
+#include <common/items/all.qc>
REGISTER_MUTATOR(mutator_instagib, cvar("g_instagib") && !g_nexball);
spawnfunc(item_minst_cells)
{
- if (!g_instagib) { remove(self); return; }
- if (!self.ammo_cells) self.ammo_cells = autocvar_g_instagib_ammo_drop;
- StartItemA(ITEM_VaporizerCells);
+ if (!g_instagib) { remove(this); return; }
+ if (!this.ammo_cells) this.ammo_cells = autocvar_g_instagib_ammo_drop;
+ StartItem(this, ITEM_VaporizerCells);
}
-void instagib_invisibility()
-{SELFPARAM();
- self.strength_finished = autocvar_g_balance_powerup_strength_time;
- StartItemA(ITEM_Invisibility);
+void instagib_invisibility(entity this)
+{
+ this.strength_finished = autocvar_g_balance_powerup_strength_time;
+ StartItem(this, ITEM_Invisibility);
}
-void instagib_extralife()
-{SELFPARAM();
- self.max_health = 1;
- StartItemA(ITEM_ExtraLife);
+void instagib_extralife(entity this)
+{
+ StartItem(this, ITEM_ExtraLife);
}
-void instagib_speed()
-{SELFPARAM();
- self.invincible_finished = autocvar_g_balance_powerup_invincible_time;
- StartItemA(ITEM_Speed);
+void instagib_speed(entity this)
+{
+ this.invincible_finished = autocvar_g_balance_powerup_invincible_time;
+ StartItem(this, ITEM_Speed);
}
.float instagib_nextthink;
{
if (!e.instagib_needammo)
return;
- Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER_CPID, CPID_INSTAGIB_FINDAMMO);
+ Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_INSTAGIB_FINDAMMO);
e.instagib_needammo = false;
}
-void instagib_ammocheck()
-{SELFPARAM();
- if(time < self.instagib_nextthink)
+void instagib_ammocheck(entity this)
+{
+ if(time < this.instagib_nextthink)
return;
- if(!IS_PLAYER(self))
+ if(!IS_PLAYER(this))
return; // not a player
- if(self.deadflag || gameover)
- instagib_stop_countdown(self);
- else if (self.ammo_cells > 0 || (self.items & IT_UNLIMITED_WEAPON_AMMO) || (self.flags & FL_GODMODE))
- instagib_stop_countdown(self);
+ if(IS_DEAD(this) || gameover)
+ instagib_stop_countdown(this);
+ else if (this.ammo_cells > 0 || (this.items & IT_UNLIMITED_WEAPON_AMMO) || (this.flags & FL_GODMODE))
+ instagib_stop_countdown(this);
else if(autocvar_g_rm && autocvar_g_rm_laser)
{
- if(!self.instagib_needammo)
+ if(!this.instagib_needammo)
{
- Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
- self.instagib_needammo = true;
+ Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_INSTAGIB_DOWNGRADE);
+ this.instagib_needammo = true;
}
}
else
{
- self.instagib_needammo = true;
- if (self.health <= 5)
+ this.instagib_needammo = true;
+ if (this.health <= 5)
{
- Damage(self, self, self, 5, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
+ Damage(this, this, this, 5, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_INSTAGIB_TERMINATED);
}
- else if (self.health <= 10)
+ else if (this.health <= 10)
{
- Damage(self, self, self, 5, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_1);
+ Damage(this, this, this, 5, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_1);
}
- else if (self.health <= 20)
+ else if (this.health <= 20)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_2);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_2);
}
- else if (self.health <= 30)
+ else if (this.health <= 30)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_3);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_3);
}
- else if (self.health <= 40)
+ else if (this.health <= 40)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_4);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_4);
}
- else if (self.health <= 50)
+ else if (this.health <= 50)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_5);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_5);
}
- else if (self.health <= 60)
+ else if (this.health <= 60)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_6);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_6);
}
- else if (self.health <= 70)
+ else if (this.health <= 70)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_7);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_7);
}
- else if (self.health <= 80)
+ else if (this.health <= 80)
{
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_8);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_8);
}
- else if (self.health <= 90)
+ else if (this.health <= 90)
{
- Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
- Send_Notification(NOTIF_ONE, self, MSG_ANNCE, ANNCE_NUM_9);
+ Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_INSTAGIB_FINDAMMO);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE, this, MSG_ANNCE, ANNCE_NUM_9);
}
else
{
- Send_Notification(NOTIF_ONE_ONLY, self, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
- Damage(self, self, self, 10, DEATH_NOAMMO.m_id, self.origin, '0 0 0');
+ Send_Notification(NOTIF_ONE_ONLY, this, MSG_MULTI, MULTI_INSTAGIB_FINDAMMO);
+ Damage(this, this, this, 10, DEATH_NOAMMO.m_id, this.origin, '0 0 0');
}
}
- self.instagib_nextthink = time + 1;
+ this.instagib_nextthink = time + 1;
}
MUTATOR_HOOKFUNCTION(mutator_instagib, MatchEnd)
{
- entity head;
- FOR_EACH_PLAYER(head)
- instagib_stop_countdown(head);
-
+ FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(instagib_stop_countdown(it)));
return false;
}
MUTATOR_HOOKFUNCTION(mutator_instagib, MonsterDropItem)
{
- other.monster_loot = spawnfunc_item_minst_cells;
+ entity item = M_ARGV(1, entity);
+
+ item.monster_loot = spawnfunc_item_minst_cells;
return false;
}
}
MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerSpawn)
-{SELFPARAM();
- self.effects |= EF_FULLBRIGHT;
- return false;
+{
+ entity player = M_ARGV(0, entity);
+
+ player.effects |= EF_FULLBRIGHT;
}
MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPreThink)
-{
- instagib_ammocheck();
+{SELFPARAM();
+ instagib_ammocheck(self);
return false;
}
if (self.items & ITEM_Invisibility.m_itemid)
{
- play_countdown(self.strength_finished, SND(POWEROFF));
+ play_countdown(self.strength_finished, SND_POWEROFF);
if (time > self.strength_finished)
{
self.alpha = default_player_alpha;
if (self.items & ITEM_Speed.m_itemid)
{
- play_countdown(self.invincible_finished, SND(POWEROFF));
+ play_countdown(self.invincible_finished, SND_POWEROFF);
if (time > self.invincible_finished)
{
self.items &= ~ITEM_Speed.m_itemid;
MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_SplitHealthArmor)
{
- damage_save = 0;
- damage_take = frag_damage;
-
- return false;
+ M_ARGV(4, float) = M_ARGV(7, float); // take = damage
+ M_ARGV(5, float) = 0; // save
}
MUTATOR_HOOKFUNCTION(mutator_instagib, ForbidThrowCurrentWeapon)
MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
{
+ entity frag_attacker = M_ARGV(1, entity);
+ entity frag_target = M_ARGV(2, entity);
+ float frag_deathtype = M_ARGV(3, float);
+ float frag_damage = M_ARGV(4, float);
+ float frag_mirrordamage = M_ARGV(5, float);
+ vector frag_force = M_ARGV(6, vector);
+
if(autocvar_g_friendlyfire == 0 && SAME_TEAM(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
frag_damage = 0;
if(IS_PLAYER(frag_attacker))
if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
{
+ if(!autocvar_g_instagib_friendlypush && SAME_TEAM(frag_target, frag_attacker))
+ frag_force = '0 0 0';
+
if(frag_target.armorvalue)
{
frag_target.armorvalue -= 1;
frag_damage = 0;
frag_target.damage_dealt += 1;
- frag_attacker.damage_dealt += 1; // TODO: change this to a specific hitsound for armor hit
+ frag_attacker.damage_dealt += 1;
Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_INSTAGIB_LIVES_REMAINING, frag_target.armorvalue);
}
}
{
if(frag_deathtype & HITTYPE_SECONDARY)
{
- if(!autocvar_g_instagib_blaster_keepdamage)
- frag_damage = frag_mirrordamage = 0;
+ if(!autocvar_g_instagib_blaster_keepdamage || frag_attacker == frag_target)
+ {
+ frag_damage = 0;
+ if(!autocvar_g_instagib_mirrordamage)
+ frag_mirrordamage = 0; // never do mirror damage on enemies
+ }
if(frag_target != frag_attacker)
{
}
}
+ if(!autocvar_g_instagib_mirrordamage) // only apply the taking lives hack if we don't want to support real damage mirroring
if(IS_PLAYER(frag_attacker))
if(frag_mirrordamage > 0)
{
frag_mirrordamage = 0;
}
- if((frag_target.buffs & BUFF_INVISIBLE.m_itemid) || (frag_target.items & ITEM_Invisibility.m_itemid))
+ if(frag_target.alpha && frag_target.alpha < 1)
+ if(IS_PLAYER(frag_target))
yoda = 1;
+ M_ARGV(4, float) = frag_damage;
+ M_ARGV(5, float) = frag_mirrordamage;
+ M_ARGV(6, vector) = frag_force;
+
return false;
}
e.cnt = self.cnt;
e.team = self.team;
e.spawnfunc_checked = true;
- WITH(entity, self, e, spawnfunc_item_minst_cells(e));
+ WITHSELF(e, spawnfunc_item_minst_cells(e));
return true;
}
MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDies)
{
+ float frag_deathtype = M_ARGV(3, float);
+ float frag_damage = M_ARGV(4, float);
+
if(DEATH_ISWEAPON(frag_deathtype, WEP_VAPORIZER))
frag_damage = 1000; // always gib if it was a vaporizer death
- return FALSE;
+ return false;
}
MUTATOR_HOOKFUNCTION(mutator_instagib, ItemTouch)
return MUT_ITEMTOUCH_CONTINUE;
}
- if(self.max_health)
+ if(self.itemdef == ITEM_ExtraLife)
{
other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_instagib_extralives);
Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
float r = random();
if (r < 0.3)
- e.think = instagib_invisibility;
+ setthink(e, instagib_invisibility);
else if (r < 0.6)
- e.think = instagib_extralife;
+ setthink(e, instagib_extralife);
else
- e.think = instagib_speed;
+ setthink(e, instagib_speed);
e.nextthink = time + 0.1;
e.spawnflags = self.spawnflags;