]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_blaster.qc
Fix some redundant checks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_blaster.qc
index aa8d0a89b665bbbcd18a58bf3db6887fc98c00f8..6234f4a3e1154b1233afa9ee52ad5fd1b0d7f06d 100644 (file)
@@ -1,4 +1,4 @@
-#ifdef REGISTER_WEAPON
+#ifndef IMPLEMENTATION
 REGISTER_WEAPON(
 /* WEP_##id  */ BLASTER,
 /* function  */ W_Blaster,
@@ -9,7 +9,7 @@ REGISTER_WEAPON(
 /* color     */ '1 0.5 0.5',
 /* modelname */ "laser",
 /* simplemdl */ "foobar",
-/* crosshair */ "gfx/crosshairlaser 0.4",
+/* crosshair */ "gfx/crosshairlaser 0.5",
 /* wepimg    */ "weaponlaser",
 /* refname   */ "blaster",
 /* wepname   */ _("Blaster")
@@ -45,9 +45,10 @@ BLASTER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 .float blaster_force;
 .float blaster_lifetime;
 #endif
-#else
+#endif
+#ifdef IMPLEMENTATION
 #ifdef SVQC
-void spawnfunc_weapon_blaster(void) { weapon_defaultspawnfunc(WEP_BLASTER); }
+void spawnfunc_weapon_blaster(void) { weapon_defaultspawnfunc(WEP_BLASTER.m_id); }
 void spawnfunc_weapon_laser(void) { spawnfunc_weapon_blaster(); }
 
 void W_Blaster_Touch(void)
@@ -68,7 +69,7 @@ void W_Blaster_Touch(void)
                self.projectiledeathtype,
                other
        );
-       
+
        remove(self);
 }
 
@@ -77,7 +78,7 @@ void W_Blaster_Think(void)
        self.movetype = MOVETYPE_FLY;
        self.think = SUB_Remove;
        self.nextthink = time + self.blaster_lifetime;
-       CSQCProjectile(self, TRUE, PROJECTILE_BLASTER, TRUE);
+       CSQCProjectile(self, true, PROJECTILE_BLASTER, true);
 }
 
 void W_Blaster_Attack(
@@ -94,13 +95,13 @@ void W_Blaster_Attack(
 {
        vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD);
 
-       W_SetupShot_Dir(self, s_forward, FALSE, 3, "weapons/lasergun_fire.wav", CH_WEAPON_B, atk_damage);
-       pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
+       W_SetupShot_Dir(self, s_forward, false, 3, W_Sound("lasergun_fire"), CH_WEAPON_B, atk_damage);
+       Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
        entity missile = spawn();
        missile.owner = missile.realowner = self;
        missile.classname = "blasterbolt";
-       missile.bot_dodge = TRUE;
+       missile.bot_dodge = true;
        missile.bot_dodgerating = atk_damage;
        PROJECTILE_MAKETRIGGER(missile);
 
@@ -112,7 +113,7 @@ void W_Blaster_Attack(
 
        setorigin(missile, w_shotorg);
        setsize(missile, '0 0 0', '0 0 0');
-       
+
        W_SetupProjVelocity_Explicit(
                missile,
                w_shotdir,
@@ -121,7 +122,7 @@ void W_Blaster_Attack(
                0,
                0,
                atk_spread,
-               FALSE
+               false
        );
 
        missile.angles = vectoangles(missile.velocity);
@@ -132,11 +133,11 @@ void W_Blaster_Attack(
        missile.touch = W_Blaster_Touch;
        missile.flags = FL_PROJECTILE;
        missile.missile_flags = MIF_SPLASH;
-       missile.projectiledeathtype = atk_deathtype; 
+       missile.projectiledeathtype = atk_deathtype;
        missile.think = W_Blaster_Think;
        missile.nextthink = time + atk_delay;
 
-       other = missile; MUTATOR_CALLHOOK(EditProjectile);
+       MUTATOR_CALLHOOK(EditProjectile, self, missile);
 
        if(time >= missile.nextthink)
        {
@@ -147,7 +148,7 @@ void W_Blaster_Attack(
                self = oldself;
        }
 }
-float W_Blaster(float request)
+bool W_Blaster(int request)
 {
        switch(request)
        {
@@ -156,16 +157,16 @@ float W_Blaster(float request)
                        if(WEP_CVAR(blaster, secondary))
                        {
                                if((random() * (WEP_CVAR_PRI(blaster, damage) + WEP_CVAR_SEC(blaster, damage))) > WEP_CVAR_PRI(blaster, damage))
-                                       { self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(blaster, speed), 0, WEP_CVAR_SEC(blaster, lifetime), FALSE); }
+                                       { self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(blaster, speed), 0, WEP_CVAR_SEC(blaster, lifetime), false); }
                                else
-                                       { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), FALSE); }
+                                       { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
                        }
                        else
-                               { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), FALSE); }
+                               { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); }
 
-                       return TRUE;
+                       return true;
                }
-               
+
                case WR_THINK:
                {
                        if(self.BUTTON_ATCK)
@@ -173,7 +174,7 @@ float W_Blaster(float request)
                                if(weapon_prepareattack(0, WEP_CVAR_PRI(blaster, refire)))
                                {
                                        W_Blaster_Attack(
-                                               WEP_BLASTER,
+                                               WEP_BLASTER.m_id,
                                                WEP_CVAR_PRI(blaster, shotangle),
                                                WEP_CVAR_PRI(blaster, damage),
                                                WEP_CVAR_PRI(blaster, edgedamage),
@@ -193,7 +194,7 @@ float W_Blaster(float request)
                                {
                                        case 0: // switch to last used weapon
                                        {
-                                               if(self.switchweapon == WEP_BLASTER) // don't do this if already switching
+                                               if(self.switchweapon == WEP_BLASTER.m_id) // don't do this if already switching
                                                        W_LastWeapon();
                                                break;
                                        }
@@ -203,7 +204,7 @@ float W_Blaster(float request)
                                                if(weapon_prepareattack(1, WEP_CVAR_SEC(blaster, refire)))
                                                {
                                                        W_Blaster_Attack(
-                                                               WEP_BLASTER | HITTYPE_SECONDARY,
+                                                               WEP_BLASTER.m_id | HITTYPE_SECONDARY,
                                                                WEP_CVAR_SEC(blaster, shotangle),
                                                                WEP_CVAR_SEC(blaster, damage),
                                                                WEP_CVAR_SEC(blaster, edgedamage),
@@ -221,52 +222,52 @@ float W_Blaster(float request)
                                        }
                                }
                        }
-                       return TRUE;
+                       return true;
                }
-               
-               case WR_INIT: 
+
+               case WR_INIT:
                {
-                       precache_model("models/weapons/g_laser.md3");
-                       precache_model("models/weapons/v_laser.md3");
-                       precache_model("models/weapons/h_laser.iqm");
-                       precache_sound("weapons/lasergun_fire.wav");
-                       BLASTER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
-                       return TRUE;
+                       precache_model(W_Model("g_laser.md3"));
+                       precache_model(W_Model("v_laser.md3"));
+                       precache_model(W_Model("h_laser.iqm"));
+                       precache_sound(W_Sound("lasergun_fire"));
+                       BLASTER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
+                       return true;
                }
-               
+
                case WR_SETUP:
                {
                        self.ammo_field = ammo_none;
-                       return TRUE;
+                       return true;
                }
-               
+
                case WR_CHECKAMMO1:
                case WR_CHECKAMMO2:
                {
-                       return TRUE; // laser has infinite ammo
+                       return true; // laser has infinite ammo
                }
-               
+
                case WR_CONFIG:
                {
-                       BLASTER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
-                       return TRUE;
+                       BLASTER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
+                       return true;
                }
-               
+
                case WR_SUICIDEMESSAGE:
                {
                        return WEAPON_BLASTER_SUICIDE;
                }
-               
+
                case WR_KILLMESSAGE:
                {
                        return WEAPON_BLASTER_MURDER;
                }
        }
-       return FALSE;
+       return false;
 }
 #endif
 #ifdef CSQC
-float W_Blaster(float request)
+bool W_Blaster(int request)
 {
        switch(request)
        {
@@ -274,23 +275,23 @@ float W_Blaster(float request)
                {
                        vector org2;
                        org2 = w_org + w_backoff * 6;
-                       pointparticles(particleeffectnum("laser_impact"), org2, w_backoff * 1000, 1);
-                       if(!w_issilent) { sound(self, CH_SHOTS, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM); }
-                       return TRUE;
+                       pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), org2, w_backoff * 1000, 1);
+                       if(!w_issilent) { sound(self, CH_SHOTS, W_Sound("laserimpact"), VOL_BASE, ATTN_NORM); }
+                       return true;
                }
-               
+
                case WR_INIT:
                {
-                       precache_sound("weapons/laserimpact.wav");
-                       return TRUE;
+                       precache_sound(W_Sound("laserimpact"));
+                       return true;
                }
                case WR_ZOOMRETICLE:
                {
                        // no weapon specific image for this weapon
-                       return FALSE;
+                       return false;
                }
        }
-       return FALSE;
+       return false;
 }
 #endif
 #endif