X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Finstagib%2Finstagib.qc;h=ec96d462601d92aa2b189307a2fa0d532b2b4a5a;hb=e9b0f3859726cfc5f17ba0a046147404fb79f5be;hp=bc6ca5be39add6c715a5be00872abde92b6e231a;hpb=ddb77505844f896a3985cdd9582e467ffe3eb591;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/instagib/instagib.qc b/qcsrc/common/mutators/mutator/instagib/instagib.qc index bc6ca5be3..ec96d4626 100644 --- a/qcsrc/common/mutators/mutator/instagib/instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/instagib.qc @@ -16,33 +16,33 @@ int autocvar_g_instagib_ammo_drop; int autocvar_g_instagib_extralives; float autocvar_g_instagib_speed_highspeed; -#include "../../../../server/cl_client.qh" +#include -#include "../../../items/all.qc" +#include 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; + 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; +void instagib_invisibility(entity this) +{ + this.strength_finished = autocvar_g_balance_powerup_strength_time; StartItem(this, ITEM_Invisibility); } -void instagib_extralife() -{SELFPARAM(); +void instagib_extralife(entity this) +{ StartItem(this, ITEM_ExtraLife); } -void instagib_speed() -{SELFPARAM(); - self.invincible_finished = autocvar_g_balance_powerup_invincible_time; +void instagib_speed(entity this) +{ + this.invincible_finished = autocvar_g_balance_powerup_invincible_time; StartItem(this, ITEM_Speed); } @@ -52,89 +52,89 @@ void instagib_stop_countdown(entity e) { 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) @@ -145,7 +145,9 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, MatchEnd) 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; } @@ -168,20 +170,22 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, BotShouldAttack) } MUTATOR_HOOKFUNCTION(mutator_instagib, MakePlayerObserver) -{SELFPARAM(); - instagib_stop_countdown(self); - return false; +{ + entity player = M_ARGV(0, entity); + + instagib_stop_countdown(player); } 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; } @@ -198,7 +202,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups) 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; @@ -221,7 +225,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups) 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; @@ -252,10 +256,8 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPhysics) 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) @@ -267,6 +269,13 @@ 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; @@ -288,12 +297,15 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate) 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); } } @@ -302,8 +314,12 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate) { 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) { @@ -315,6 +331,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate) } } + 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) { @@ -329,8 +346,13 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate) } 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; } @@ -353,48 +375,53 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, SetStartItems) } MUTATOR_HOOKFUNCTION(mutator_instagib, FilterItem) -{SELFPARAM(); - if(self.classname == "item_cells") +{ + entity item = M_ARGV(0, entity); + + if(item.classname == "item_cells") return true; // no normal cells? - if(self.weapon == WEP_VAPORIZER.m_id && self.classname == "droppedweapon") + if(item.weapon == WEP_VAPORIZER.m_id && item.classname == "droppedweapon") { - self.ammo_cells = autocvar_g_instagib_ammo_drop; + item.ammo_cells = autocvar_g_instagib_ammo_drop; return false; } - if(self.weapon == WEP_DEVASTATOR.m_id || self.weapon == WEP_VORTEX.m_id) + if(item.weapon == WEP_DEVASTATOR.m_id || item.weapon == WEP_VORTEX.m_id) { entity e = spawn(); - setorigin(e, self.origin); - e.noalign = self.noalign; - e.cnt = self.cnt; - e.team = self.team; + setorigin(e, item.origin); + e.noalign = item.noalign; + e.cnt = item.cnt; + e.team = item.team; e.spawnfunc_checked = true; - WITH(entity, self, e, spawnfunc_item_minst_cells(e)); + WITHSELF(e, spawnfunc_item_minst_cells(e)); return true; } - if(self.flags & FL_POWERUP) + if(item.flags & FL_POWERUP) return false; - if(self.ammo_cells > autocvar_g_instagib_ammo_drop && self.classname != "item_minst_cells") - self.ammo_cells = autocvar_g_instagib_ammo_drop; + if(item.ammo_cells > autocvar_g_instagib_ammo_drop && item.classname != "item_minst_cells") + item.ammo_cells = autocvar_g_instagib_ammo_drop; - if(self.ammo_cells && !self.weapon) + if(item.ammo_cells && !item.weapon) return false; return true; } MUTATOR_HOOKFUNCTION(mutator_instagib, CustomizeWaypoint) -{SELFPARAM(); - entity e = WaypointSprite_getviewentity(other); +{ + entity wp = M_ARGV(0, entity); + entity player = M_ARGV(1, entity); + + entity e = WaypointSprite_getviewentity(player); // if you have the invisibility powerup, sprites ALWAYS are restricted to your team // but only apply this to real players, not to spectators - if((self.owner.flags & FL_CLIENT) && (self.owner.items & ITEM_Invisibility.m_itemid) && (e == other)) - if(DIFF_TEAM(self.owner, e)) + if((wp.owner.flags & FL_CLIENT) && (wp.owner.items & ITEM_Invisibility.m_itemid) && (e == player)) + if(DIFF_TEAM(wp.owner, e)) return true; return false; @@ -402,10 +429,13 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, CustomizeWaypoint) 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) @@ -438,26 +468,27 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, ItemTouch) } MUTATOR_HOOKFUNCTION(mutator_instagib, OnEntityPreSpawn) -{SELFPARAM(); +{ if (!autocvar_g_powerups) { return false; } + entity ent = M_ARGV(0, entity); // Can't use .itemdef here - if (!(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega")) + if (!(ent.classname == "item_strength" || ent.classname == "item_invincible" || ent.classname == "item_health_mega")) return false; entity e = spawn(); 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; - e.noalign = self.noalign; - setorigin(e, self.origin); + e.spawnflags = ent.spawnflags; + e.noalign = ent.noalign; + setorigin(e, ent.origin); return true; }