]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_nades.qc
Merge branch 'master' into terencehill/hud_cleanups
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_nades.qc
index f31bff4dc4df86e33044f62ac497f18639b04018..bf55e6704d284707847d0c67fd2ff84f609fd72e 100644 (file)
@@ -1,13 +1,14 @@
 #include "mutator_nades.qh"
-#include "../_all.qh"
 
 #include "mutator.qh"
 
 #include "gamemode_keyhunt.qh"
 #include "gamemode_freezetag.qh"
-#include "../../common/nades.qh"
+#include "../../common/nades/all.qh"
+#include "../../common/gamemodes/all.qh"
 #include "../../common/monsters/spawn.qh"
 #include "../../common/monsters/sv_monsters.qh"
+#include "../g_subs.qh"
 
 .float nade_time_primed;
 
@@ -23,7 +24,7 @@ void nade_timer_think()
 
 void nade_burn_spawn(entity _nade)
 {
-       CSQCProjectile(_nade, true, NADES[_nade.nade_type].m_projectile[true], true);
+       CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[true], true);
 }
 
 void nade_spawn(entity _nade)
@@ -42,7 +43,7 @@ void nade_spawn(entity _nade)
 
        _nade.effects |= EF_LOWPRECISION;
 
-       CSQCProjectile(_nade, true, NADES[_nade.nade_type].m_projectile[false], true);
+       CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[false], true);
 }
 
 void napalm_damage(float dist, float damage, float edgedamage, float burntime)
@@ -131,7 +132,7 @@ void nade_napalm_ball()
        proj.bot_dodge = true;
        proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
        proj.movetype = MOVETYPE_BOUNCE;
-       proj.projectiledeathtype = DEATH_NADE_NAPALM;
+       proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
        PROJECTILE_MAKETRIGGER(proj);
        setmodel(proj, MDL_Null);
        proj.scale = 1;//0.5;
@@ -214,7 +215,7 @@ void nade_napalm_boom()
        fountain.pushltime = fountain.ltime;
        fountain.team = self.team;
        fountain.movetype = MOVETYPE_TOSS;
-       fountain.projectiledeathtype = DEATH_NADE_NAPALM;
+       fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
        fountain.bot_dodge = true;
        fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
        fountain.nade_special_time = time;
@@ -315,7 +316,7 @@ void nade_ice_boom()
        fountain.pushltime = fountain.wait = fountain.ltime;
        fountain.team = self.team;
        fountain.movetype = MOVETYPE_TOSS;
-       fountain.projectiledeathtype = DEATH_NADE_ICE;
+       fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
        fountain.bot_dodge = false;
        setsize(fountain, '-16 -16 -16', '16 16 16');
        fountain.nade_special_time = time+0.3;
@@ -424,7 +425,7 @@ void nade_heal_touch()
                }
                else if ( health_factor < 0 )
                {
-                       Damage(other,self,self.realowner,-health_factor,DEATH_NADE_HEAL,other.origin,'0 0 0');
+                       Damage(other,self,self.realowner,-health_factor,DEATH_NADE_HEAL.m_id,other.origin,'0 0 0');
                }
 
        }
@@ -477,7 +478,7 @@ void nade_boom()
        entity expef = NULL;
        bool nade_blast = true;
 
-       switch ( NADES[self.nade_type] )
+       switch ( Nades[self.nade_type] )
        {
                case NADE_TYPE_NAPALM:
                        nade_blast = autocvar_g_nades_napalm_blast;
@@ -529,7 +530,7 @@ void nade_boom()
        }
 
        if(self.takedamage)
-       switch ( NADES[self.nade_type] )
+       switch ( Nades[self.nade_type] )
        {
                case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
                case NADE_TYPE_ICE: nade_ice_boom(); break;
@@ -597,28 +598,28 @@ void nade_damage(entity inflictor, entity attacker, float damage, int deathtype,
        if(self.nade_type == NADE_TYPE_TRANSLOCATE.m_id || self.nade_type == NADE_TYPE_SPAWN.m_id)
                return;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_BLASTER.m_id))
+       if(DEATH_ISWEAPON(deathtype, WEP_BLASTER))
        {
                force *= 1.5;
                damage = 0;
        }
 
-       if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER.m_id) && (deathtype & HITTYPE_SECONDARY))
+       if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY))
        {
                force *= 0.5; // too much
                frag_damage = 0;
        }
 
-       if(DEATH_ISWEAPON(deathtype, WEP_VORTEX.m_id) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER.m_id))
+       if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
        {
                force *= 6;
                damage = self.max_health * 0.55;
        }
 
-       if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN.m_id) || DEATH_ISWEAPON(deathtype, WEP_HMG.m_id))
+       if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_HMG))
                damage = self.max_health * 0.1;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE.m_id) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN.m_id)) // WEAPONTODO
+       if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO
        if(deathtype & HITTYPE_SECONDARY)
        {
                damage = self.max_health * 0.1;
@@ -709,7 +710,7 @@ void toss_nade(entity e, vector _velocity, float _time)
        _nade.damagedbycontents = true;
        _nade.angles = vectoangles(_nade.velocity);
        _nade.flags = FL_PROJECTILE;
-       _nade.projectiledeathtype = DEATH_NADE;
+       _nade.projectiledeathtype = DEATH_NADE.m_id;
        _nade.toss_time = time;
        _nade.solid = SOLID_CORPSE; //((_nade.nade_type == NADE_TYPE_TRANSLOCATE) ? SOLID_CORPSE : SOLID_BBOX);
 
@@ -772,7 +773,7 @@ float nade_customize()
        {
                //self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
                if(!self.traileffectnum)
-                       self.traileffectnum = _particleeffectnum(Nade_TrailEffect(NADES[self.nade_type].m_projectile[false], self.team).eent_eff_name);
+                       self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[self.nade_type].m_projectile[false], self.team).eent_eff_name);
                self.alpha = 1;
        }
 
@@ -810,14 +811,14 @@ void nade_prime()
                n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
        }
 
-       n.nade_type = bound(1, n.nade_type, NADES_COUNT);
+       n.nade_type = bound(1, n.nade_type, Nades_COUNT);
 
        setmodel(n, MDL_PROJECTILE_NADE);
        //setattachment(n, self, "bip01 l hand");
        n.exteriormodeltoclient = self;
        n.customizeentityforclient = nade_customize;
-       n.traileffectnum = _particleeffectnum(Nade_TrailEffect(NADES[n.nade_type].m_projectile[false], self.team).eent_eff_name);
-       n.colormod = NADES[n.nade_type].m_color;
+       n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[n.nade_type].m_projectile[false], self.team).eent_eff_name);
+       n.colormod = Nades[n.nade_type].m_color;
        n.realowner = self;
        n.colormap = self.colormap;
        n.glowmod = self.glowmod;
@@ -825,12 +826,12 @@ void nade_prime()
        n.nade_time_primed = time;
        n.think = nade_beep;
        n.nextthink = max(n.wait - 3, time);
-       n.projectiledeathtype = DEATH_NADE;
+       n.projectiledeathtype = DEATH_NADE.m_id;
 
        setmodel(fn, MDL_NADE_VIEW);
        setattachment(fn, self.weaponentity, "");
        fn.realowner = fn.owner = self;
-       fn.colormod = NADES[n.nade_type].m_color;
+       fn.colormod = Nades[n.nade_type].m_color;
        fn.colormap = self.colormap;
        fn.glowmod = self.glowmod;
        fn.think = SUB_Remove;
@@ -952,7 +953,7 @@ NadeOffhand OFFHAND_NADE; STATIC_INIT(OFFHAND_NADE) { OFFHAND_NADE = NEW(NadeOff
 
 MUTATOR_HOOKFUNCTION(nades_CheckThrow)
 {
-       if (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK))) {
+       if (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) {
                nades_CheckThrow();
                return true;
        }
@@ -963,7 +964,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
 {SELFPARAM();
        if (!IS_PLAYER(self)) { return false; }
 
-       if (self.nade && self.offhand != OFFHAND_NADE) OFFHAND_NADE.offhand_think(OFFHAND_NADE, self, self.nade_altbutton);
+       if (self.nade && (self.offhand != OFFHAND_NADE || (self.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, self, self.nade_altbutton);
 
        if(IS_PLAYER(self))
        {
@@ -993,7 +994,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerPreThink)
                                self.pokenade_type = autocvar_g_nades_pokenade_monster_type;
                        }
 
-                       self.nade_type = bound(1, self.nade_type, NADES_COUNT);
+                       self.nade_type = bound(1, self.nade_type, Nades_COUNT);
 
                        if(self.bonus_nade_score >= 0 && autocvar_g_nades_bonus_score_max)
                                nades_GiveBonus(self, time_score / autocvar_g_nades_bonus_score_max);
@@ -1119,7 +1120,7 @@ MUTATOR_HOOKFUNCTION(nades_PlayerDamage)
        if(frag_target.frozen)
        if(autocvar_g_freezetag_revive_nade)
        if(frag_attacker == frag_target)
-       if(frag_deathtype == DEATH_NADE)
+       if(frag_deathtype == DEATH_NADE.m_id)
        if(time - frag_inflictor.toss_time <= 0.1)
        {
                Unfreeze(frag_target);