]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_mortar.qc
Nasty fix for drag cheat
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_mortar.qc
index a8c6a2c59e3e56c946e2c6d7d4ab409bf8b441fc..850a6c342fb4e2a6d0a4d47d552ab611e473bc9b 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_WEAPON
+#ifndef IMPLEMENTATION
 REGISTER_WEAPON(
 /* WEP_##id  */ MORTAR,
 /* function  */ W_Mortar,
@@ -52,10 +52,11 @@ MORTAR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 .float gl_detonate_later;
 .float gl_bouncecnt;
 #endif
-#else
+#endif
+#ifdef IMPLEMENTATION
 #ifdef SVQC
 
-void spawnfunc_weapon_mortar(void) { weapon_defaultspawnfunc(WEP_MORTAR); }
+void spawnfunc_weapon_mortar(void) { weapon_defaultspawnfunc(WEP_MORTAR.m_id); }
 void spawnfunc_weapon_grenadelauncher(void) { spawnfunc_weapon_mortar(); }
 
 void W_Mortar_Grenade_Explode(void)
@@ -139,24 +140,24 @@ void W_Mortar_Grenade_Touch1(void)
                float r;
                r = random() * 6;
                if(r < 1)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce1.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce1"), VOL_BASE, ATTN_NORM);
                else if(r < 2)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce2.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce2"), VOL_BASE, ATTN_NORM);
                else if(r < 3)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce3.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce3"), VOL_BASE, ATTN_NORM);
                else if(r < 4)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce4.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce4"), VOL_BASE, ATTN_NORM);
                else if(r < 5)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce5.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce5"), VOL_BASE, ATTN_NORM);
                else
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce6.wav", VOL_BASE, ATTN_NORM);
-               pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce6"), VOL_BASE, ATTN_NORM);
+               Send_Effect(EFFECT_HAGAR_BOUNCE, self.origin, self.velocity, 1);
                self.projectiledeathtype |= HITTYPE_BOUNCE;
                self.gl_bouncecnt += 1;
        }
        else if(WEP_CVAR_PRI(mortar, type) == 2 && (!other || (other.takedamage != DAMAGE_AIM && other.movetype == MOVETYPE_NONE))) // stick
        {
-               spamsound(self, CH_SHOTS, "weapons/grenade_stick.wav", VOL_BASE, ATTN_NORM);
+               spamsound(self, CH_SHOTS, W_Sound("grenade_stick"), VOL_BASE, ATTN_NORM);
 
                // let it stick whereever it is
                self.oldvelocity = self.velocity;
@@ -184,18 +185,18 @@ void W_Mortar_Grenade_Touch2(void)
                float r;
                r = random() * 6;
                if(r < 1)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce1.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce1"), VOL_BASE, ATTN_NORM);
                else if(r < 2)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce2.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce2"), VOL_BASE, ATTN_NORM);
                else if(r < 3)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce3.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce3"), VOL_BASE, ATTN_NORM);
                else if(r < 4)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce4.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce4"), VOL_BASE, ATTN_NORM);
                else if(r < 5)
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce5.wav", VOL_BASE, ATTN_NORM);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce5"), VOL_BASE, ATTN_NORM);
                else
-                       spamsound(self, CH_SHOTS, "weapons/grenade_bounce6.wav", VOL_BASE, ATTN_NORM);
-               pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
+                       spamsound(self, CH_SHOTS, W_Sound("grenade_bounce6"), VOL_BASE, ATTN_NORM);
+               Send_Effect(EFFECT_HAGAR_BOUNCE, self.origin, self.velocity, 1);
                self.projectiledeathtype |= HITTYPE_BOUNCE;
                self.gl_bouncecnt += 1;
 
@@ -205,7 +206,7 @@ void W_Mortar_Grenade_Touch2(void)
        }
        else if(WEP_CVAR_SEC(mortar, type) == 2 && (!other || (other.takedamage != DAMAGE_AIM && other.movetype == MOVETYPE_NONE))) // stick
        {
-               spamsound(self, CH_SHOTS, "weapons/grenade_stick.wav", VOL_BASE, ATTN_NORM);
+               spamsound(self, CH_SHOTS, W_Sound("grenade_stick"), VOL_BASE, ATTN_NORM);
 
                // let it stick whereever it is
                self.oldvelocity = self.velocity;
@@ -227,10 +228,10 @@ void W_Mortar_Attack(void)
 
        W_DecreaseAmmo(WEP_CVAR_PRI(mortar, ammo));
 
-       W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, "weapons/grenade_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage));
+       W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, W_Sound("grenade_fire"), CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage));
        w_shotdir = v_forward; // no TrueAim for grenades please
 
-       pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
+       Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
        gren = spawn();
        gren.owner = gren.realowner = self;
@@ -241,7 +242,7 @@ void W_Mortar_Attack(void)
        gren.bouncefactor = WEP_CVAR(mortar, bouncefactor);
        gren.bouncestop = WEP_CVAR(mortar, bouncestop);
        PROJECTILE_MAKETRIGGER(gren);
-       gren.projectiledeathtype = WEP_MORTAR;
+       gren.projectiledeathtype = WEP_MORTAR.m_id;
        setorigin(gren, w_shotorg);
        setsize(gren, '-3 -3 -3', '3 3 3');
 
@@ -276,10 +277,10 @@ void W_Mortar_Attack2(void)
 
        W_DecreaseAmmo(WEP_CVAR_SEC(mortar, ammo));
 
-       W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, "weapons/grenade_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage));
+       W_SetupShot_ProjectileSize(self, '-3 -3 -3', '3 3 3', false, 4, W_Sound("grenade_fire"), CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage));
        w_shotdir = v_forward; // no TrueAim for grenades please
 
-       pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
+       Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
        gren = spawn();
        gren.owner = gren.realowner = self;
@@ -290,7 +291,7 @@ void W_Mortar_Attack2(void)
        gren.bouncefactor = WEP_CVAR(mortar, bouncefactor);
        gren.bouncestop = WEP_CVAR(mortar, bouncestop);
        PROJECTILE_MAKETRIGGER(gren);
-       gren.projectiledeathtype = WEP_MORTAR | HITTYPE_SECONDARY;
+       gren.projectiledeathtype = WEP_MORTAR.m_id | HITTYPE_SECONDARY;
        setorigin(gren, w_shotorg);
        setsize(gren, '-3 -3 -3', '3 3 3');
 
@@ -391,7 +392,7 @@ bool W_Mortar(int req)
                                                }
                                        }
                                        if(nadefound)
-                                               sound(self, CH_WEAPON_B, "weapons/rocket_det.wav", VOL_BASE, ATTN_NORM);
+                                               sound(self, CH_WEAPON_B, W_Sound("rocket_det"), VOL_BASE, ATTN_NORM);
                                }
                                else if(weapon_prepareattack(1, WEP_CVAR_SEC(mortar, refire)))
                                {
@@ -404,30 +405,30 @@ bool W_Mortar(int req)
                }
                case WR_INIT:
                {
-                       precache_model("models/weapons/g_gl.md3");
-                       precache_model("models/weapons/v_gl.md3");
-                       precache_model("models/weapons/h_gl.iqm");
-                       precache_sound("weapons/grenade_bounce1.wav");
-                       precache_sound("weapons/grenade_bounce2.wav");
-                       precache_sound("weapons/grenade_bounce3.wav");
-                       precache_sound("weapons/grenade_bounce4.wav");
-                       precache_sound("weapons/grenade_bounce5.wav");
-                       precache_sound("weapons/grenade_bounce6.wav");
-                       precache_sound("weapons/grenade_stick.wav");
-                       precache_sound("weapons/grenade_fire.wav");
+                       precache_model(W_Model("g_gl.md3"));
+                       precache_model(W_Model("v_gl.md3"));
+                       precache_model(W_Model("h_gl.iqm"));
+                       precache_sound(W_Sound("grenade_bounce1"));
+                       precache_sound(W_Sound("grenade_bounce2"));
+                       precache_sound(W_Sound("grenade_bounce3"));
+                       precache_sound(W_Sound("grenade_bounce4"));
+                       precache_sound(W_Sound("grenade_bounce5"));
+                       precache_sound(W_Sound("grenade_bounce6"));
+                       precache_sound(W_Sound("grenade_stick"));
+                       precache_sound(W_Sound("grenade_fire"));
                        MORTAR_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
                }
                case WR_CHECKAMMO1:
                {
                        ammo_amount = self.WEP_AMMO(MORTAR) >= WEP_CVAR_PRI(mortar, ammo);
-                       ammo_amount += self.(weapon_load[WEP_MORTAR]) >= WEP_CVAR_PRI(mortar, ammo);
+                       ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
                        return ammo_amount;
                }
                case WR_CHECKAMMO2:
                {
                        ammo_amount = self.WEP_AMMO(MORTAR) >= WEP_CVAR_SEC(mortar, ammo);
-                       ammo_amount += self.(weapon_load[WEP_MORTAR]) >= WEP_CVAR_SEC(mortar, ammo);
+                       ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
                        return ammo_amount;
                }
                case WR_CONFIG:
@@ -437,7 +438,7 @@ bool W_Mortar(int req)
                }
                case WR_RELOAD:
                {
-                       W_Reload(min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), "weapons/reload.wav"); // WEAPONTODO
+                       W_Reload(min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo)), W_Sound("reload")); // WEAPONTODO
                        return true;
                }
                case WR_SUICIDEMESSAGE:
@@ -467,15 +468,15 @@ bool W_Mortar(int req)
                {
                        vector org2;
                        org2 = w_org + w_backoff * 12;
-                       pointparticles(particleeffectnum("grenade_explode"), org2, '0 0 0', 1);
+                       pointparticles(particleeffectnum(EFFECT_GRENADE_EXPLODE), org2, '0 0 0', 1);
                        if(!w_issilent)
-                               sound(self, CH_SHOTS, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
+                               sound(self, CH_SHOTS, W_Sound("grenade_impact"), VOL_BASE, ATTN_NORM);
 
                        return true;
                }
                case WR_INIT:
                {
-                       precache_sound("weapons/grenade_impact.wav");
+                       precache_sound(W_Sound("grenade_impact"));
                        return true;
                }
                case WR_ZOOMRETICLE: