]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_hlac.qc
Add a function to control weapon sound paths with hooks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_hlac.qc
index e9c7ffee4802185c99108c547bcfb64cbc4c5113..d2428ffb4c7220e2ca4ceeeca91cd29bcb946023 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_WEAPON
+#ifndef IMPLEMENTATION
 REGISTER_WEAPON(
 /* WEP_##id  */ HLAC,
 /* function  */ W_HLAC,
@@ -45,9 +45,10 @@ REGISTER_WEAPON(
 #ifdef SVQC
 HLAC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #endif
-#else
+#endif
+#ifdef IMPLEMENTATION
 #ifdef SVQC
-void spawnfunc_weapon_hlac(void) { weapon_defaultspawnfunc(WEP_HLAC); }
+void spawnfunc_weapon_hlac(void) { weapon_defaultspawnfunc(WEP_HLAC.m_id); }
 
 void W_HLAC_Touch(void)
 {
@@ -76,8 +77,8 @@ void W_HLAC_Attack(void)
     if(self.crouch)
         spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod);
 
-       W_SetupShot(self, false, 3, "weapons/lasergun_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage));
-       pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
+       W_SetupShot(self, false, 3, W_Sound("lasergun_fire"), CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage));
+       Send_Effect("laser_muzzleflash", w_shotorg, w_shotdir * 1000, 1);
        if(!autocvar_g_norecoil)
        {
                self.punchangle_x = random() - 0.5;
@@ -106,7 +107,7 @@ void W_HLAC_Attack(void)
     missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
 
        missile.flags = FL_PROJECTILE;
-       missile.projectiledeathtype = WEP_HLAC;
+       missile.projectiledeathtype = WEP_HLAC.m_id;
 
        CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
 
@@ -124,8 +125,8 @@ void W_HLAC_Attack2(void)
     if(self.crouch)
         spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod);
 
-       W_SetupShot(self, false, 3, "weapons/lasergun_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage));
-       pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
+       W_SetupShot(self, false, 3, W_Sound("lasergun_fire"), CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage));
+       Send_Effect("laser_muzzleflash", w_shotorg, w_shotdir * 1000, 1);
 
        missile = spawn();
        missile.owner = missile.realowner = self;
@@ -150,7 +151,7 @@ void W_HLAC_Attack2(void)
 
        missile.flags = FL_PROJECTILE;
        missile.missile_flags = MIF_SPLASH;
-       missile.projectiledeathtype = WEP_HLAC | HITTYPE_SECONDARY;
+       missile.projectiledeathtype = WEP_HLAC.m_id | HITTYPE_SECONDARY;
 
        CSQCProjectile(missile, true, PROJECTILE_HLAC, true);
 
@@ -240,23 +241,23 @@ bool W_HLAC(int req)
                }
                case WR_INIT:
                {
-                       precache_model("models/weapons/g_hlac.md3");
-                       precache_model("models/weapons/v_hlac.md3");
-                       precache_model("models/weapons/h_hlac.iqm");
-                       precache_sound("weapons/lasergun_fire.wav");
+                       precache_model(W_Model("g_hlac.md3"));
+                       precache_model(W_Model("v_hlac.md3"));
+                       precache_model(W_Model("h_hlac.iqm"));
+                       precache_sound(W_Sound("lasergun_fire"));
                        HLAC_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
                }
                case WR_CHECKAMMO1:
                {
                        ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_PRI(hlac, ammo);
-                       ammo_amount += self.(weapon_load[WEP_HLAC]) >= WEP_CVAR_PRI(hlac, ammo);
+                       ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
                        return ammo_amount;
                }
                case WR_CHECKAMMO2:
                {
                        ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_SEC(hlac, ammo);
-                       ammo_amount += self.(weapon_load[WEP_HLAC]) >= WEP_CVAR_SEC(hlac, ammo);
+                       ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
                        return ammo_amount;
                }
                case WR_CONFIG:
@@ -266,7 +267,7 @@ bool W_HLAC(int req)
                }
                case WR_RELOAD:
                {
-                       W_Reload(min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), "weapons/reload.wav");
+                       W_Reload(min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo)), W_Sound("reload"));
                        return true;
                }
                case WR_SUICIDEMESSAGE: