]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_hlac.qc
Merge branch 'Mario/despawn_effects'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_hlac.qc
index ab2ef87d5a7931ba37e7d462521fcbd7b1ed45ab..d3dbed2f9c9fd9a88d974d227c378460016570b4 100644 (file)
@@ -1,46 +1,55 @@
 #ifdef REGISTER_WEAPON
 REGISTER_WEAPON(
-/* WEP_##id */ HLAC,
-/* function */ w_hlac,
-/* ammotype */ IT_CELLS,
-/* impulse  */ 6,
-/* flags    */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
-/* rating   */ BOT_PICKUP_RATING_MID,
-/* model    */ "hlac",
-/* netname  */ "hlac",
-/* fullname */ _("Heavy Laser Assault Cannon")
+/* WEP_##id  */ HLAC,
+/* function  */ W_HLAC,
+/* ammotype  */ ammo_cells,
+/* impulse   */ 6,
+/* flags     */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
+/* rating    */ BOT_PICKUP_RATING_MID,
+/* color     */ '0 1 0',
+/* modelname */ "hlac",
+/* simplemdl */ "foobar",
+/* crosshair */ "gfx/crosshairhlac 0.6",
+/* wepimg    */ "weaponhlac",
+/* refname   */ "hlac",
+/* wepname   */ _("Heavy Laser Assault Cannon")
 );
 
-#define HLAC_SETTINGS(w_cvar,w_prop) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, ammo) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, animtime) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, damage) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, edgedamage) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, force) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, lifetime) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, radius) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, refire) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, speed) \
-       w_cvar(WEP_HLAC, hlac, MO_BOTH, spread_crouchmod) \
-       w_cvar(WEP_HLAC, hlac, MO_PRI,  spread_add) \
-       w_cvar(WEP_HLAC, hlac, MO_PRI,  spread_max) \
-       w_cvar(WEP_HLAC, hlac, MO_PRI,  spread_min) \
-       w_cvar(WEP_HLAC, hlac, MO_NONE, secondary) \
-       w_cvar(WEP_HLAC, hlac, MO_SEC,  shots) \
-       w_cvar(WEP_HLAC, hlac, MO_SEC,  spread) \
-       w_prop(WEP_HLAC, hlac, reloading_ammo, reload_ammo) \
-       w_prop(WEP_HLAC, hlac, reloading_time, reload_time) \
-       w_prop(WEP_HLAC, hlac, switchdelay_raise, switchdelay_raise) \
-       w_prop(WEP_HLAC, hlac, switchdelay_drop, switchdelay_drop)
+#define HLAC_SETTINGS(w_cvar,w_prop) HLAC_SETTINGS_LIST(w_cvar, w_prop, HLAC, hlac)
+#define HLAC_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
+       w_cvar(id, sn, BOTH, ammo) \
+       w_cvar(id, sn, BOTH, animtime) \
+       w_cvar(id, sn, BOTH, damage) \
+       w_cvar(id, sn, BOTH, edgedamage) \
+       w_cvar(id, sn, BOTH, force) \
+       w_cvar(id, sn, BOTH, lifetime) \
+       w_cvar(id, sn, BOTH, radius) \
+       w_cvar(id, sn, BOTH, refire) \
+       w_cvar(id, sn, BOTH, speed) \
+       w_cvar(id, sn, BOTH, spread_crouchmod) \
+       w_cvar(id, sn, PRI,  spread_add) \
+       w_cvar(id, sn, PRI,  spread_max) \
+       w_cvar(id, sn, PRI,  spread_min) \
+       w_cvar(id, sn, NONE, secondary) \
+       w_cvar(id, sn, SEC,  shots) \
+       w_cvar(id, sn, SEC,  spread) \
+       w_prop(id, sn, float,  reloading_ammo, reload_ammo) \
+       w_prop(id, sn, float,  reloading_time, reload_time) \
+       w_prop(id, sn, float,  switchdelay_raise, switchdelay_raise) \
+       w_prop(id, sn, float,  switchdelay_drop, switchdelay_drop) \
+       w_prop(id, sn, string, weaponreplace, weaponreplace) \
+       w_prop(id, sn, float,  weaponstart, weaponstart) \
+       w_prop(id, sn, float,  weaponstartoverride, weaponstartoverride) \
+       w_prop(id, sn, float,  weaponthrowable, weaponthrowable)
 
 #ifdef SVQC
 HLAC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #endif
 #else
 #ifdef SVQC
-void spawnfunc_weapon_hlac() { weapon_defaultspawnfunc(WEP_HLAC); }
+void spawnfunc_weapon_hlac(void) { weapon_defaultspawnfunc(WEP_HLAC); }
 
-void W_HLAC_Touch (void)
+void W_HLAC_Touch(void)
 {
        float isprimary;
 
@@ -52,30 +61,30 @@ void W_HLAC_Touch (void)
        
        RadiusDamage(self, self.realowner, WEP_CVAR_BOTH(hlac, isprimary, damage), WEP_CVAR_BOTH(hlac, isprimary, edgedamage), WEP_CVAR_BOTH(hlac, isprimary, radius), world, world, WEP_CVAR_BOTH(hlac, isprimary, force), self.projectiledeathtype, other);
 
-       remove (self);
+       remove(self);
 }
 
-void W_HLAC_Attack (void)
+void W_HLAC_Attack(void)
 {
        entity missile;
     float spread;
 
-       W_DecreaseAmmo(ammo_cells, WEP_CVAR_PRI(hlac, ammo), autocvar_g_balance_hlac_reload_ammo);
+       W_DecreaseAmmo(WEP_CVAR_PRI(hlac, ammo));
 
     spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * self.misc_bulletcounter);
     spread = min(spread,WEP_CVAR_PRI(hlac, spread_max));
     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));
+       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);
-       if (!autocvar_g_norecoil)
+       if(!autocvar_g_norecoil)
        {
-               self.punchangle_x = random () - 0.5;
-               self.punchangle_y = random () - 0.5;
+               self.punchangle_x = random() - 0.5;
+               self.punchangle_y = random() - 0.5;
        }
 
-       missile = spawn ();
+       missile = spawn();
        missile.owner = missile.realowner = self;
        missile.classname = "hlacbolt";
        missile.bot_dodge = TRUE;
@@ -85,11 +94,11 @@ void W_HLAC_Attack (void)
        missile.movetype = MOVETYPE_FLY;
        PROJECTILE_MAKETRIGGER(missile);
 
-       setorigin (missile, w_shotorg);
+       setorigin(missile, w_shotorg);
        setsize(missile, '0 0 0', '0 0 0');
 
-       W_SetupProjectileVelocity(missile, WEP_CVAR_PRI(hlac, speed), spread);
-       //missile.angles = vectoangles (missile.velocity); // csqc
+       W_SetupProjVelocity_Basic(missile, WEP_CVAR_PRI(hlac, speed), spread);
+       //missile.angles = vectoangles(missile.velocity); // csqc
 
        missile.touch = W_HLAC_Touch;
        missile.think = SUB_Remove;
@@ -104,7 +113,7 @@ void W_HLAC_Attack (void)
        other = missile; MUTATOR_CALLHOOK(EditProjectile);
 }
 
-void W_HLAC_Attack2(void)
+void W_HLAC_Attack2(void)
 {
        entity missile;
     float spread;
@@ -115,10 +124,10 @@ void W_HLAC_Attack2f (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));
+       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);
 
-       missile = spawn ();
+       missile = spawn();
        missile.owner = missile.realowner = self;
        missile.classname = "hlacbolt";
        missile.bot_dodge = TRUE;
@@ -128,11 +137,11 @@ void W_HLAC_Attack2f (void)
        missile.movetype = MOVETYPE_FLY;
        PROJECTILE_MAKETRIGGER(missile);
 
-       setorigin (missile, w_shotorg);
+       setorigin(missile, w_shotorg);
        setsize(missile, '0 0 0', '0 0 0');
 
-       W_SetupProjectileVelocity(missile, WEP_CVAR_SEC(hlac, speed), spread);
-       //missile.angles = vectoangles (missile.velocity); // csqc
+       W_SetupProjVelocity_Basic(missile, WEP_CVAR_SEC(hlac, speed), spread);
+       //missile.angles = vectoangles(missile.velocity); // csqc
 
        missile.touch = W_HLAC_Touch;
        missile.think = SUB_Remove;
@@ -148,24 +157,8 @@ void W_HLAC_Attack2f (void)
        other = missile; MUTATOR_CALLHOOK(EditProjectile);
 }
 
-void W_HLAC_Attack2 (void)
-{
-    float i;
-
-       W_DecreaseAmmo(ammo_cells, WEP_CVAR_SEC(hlac, ammo), autocvar_g_balance_hlac_reload_ammo);
-
-    for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
-        W_HLAC_Attack2f();
-
-       if (!autocvar_g_norecoil)
-       {
-               self.punchangle_x = random () - 0.5;
-               self.punchangle_y = random () - 0.5;
-       }
-}
-
 // weapon frames
-void HLAC_fire1_02()
+void W_HLAC_Attack_Frame(void)
 {
        if(self.weapon != self.switchweapon) // abort immediately if switching
        {
@@ -173,10 +166,10 @@ void HLAC_fire1_02()
                return;
        }
 
-       if (self.BUTTON_ATCK)
+       if(self.BUTTON_ATCK)
        {
-               if (!WEP_ACTION(self.weapon, WR_CHECKAMMO1))
-               if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+               if(!WEP_ACTION(self.weapon, WR_CHECKAMMO1))
+               if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(self, w_getbestweapon(self));
                        w_ready();
@@ -186,7 +179,7 @@ void HLAC_fire1_02()
                ATTACK_FINISHED(self) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor();
                W_HLAC_Attack();
                self.misc_bulletcounter = self.misc_bulletcounter + 1;
-        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), HLAC_fire1_02);
+        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
        }
        else
        {
@@ -194,7 +187,23 @@ void HLAC_fire1_02()
        }
 }
 
-float w_hlac(float req)
+void W_HLAC_Attack2_Frame(void)
+{
+    float i;
+
+       W_DecreaseAmmo(WEP_CVAR_SEC(hlac, ammo));
+
+    for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i)
+        W_HLAC_Attack2();
+
+       if(!autocvar_g_norecoil)
+       {
+               self.punchangle_x = random() - 0.5;
+               self.punchangle_y = random() - 0.5;
+       }
+}
+
+float W_HLAC(float req)
 {
        float ammo_amount;
        switch(req)
@@ -208,21 +217,21 @@ float w_hlac(float req)
                {
                        if(autocvar_g_balance_hlac_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) // forced reload
                                WEP_ACTION(self.weapon, WR_RELOAD);
-                       else if (self.BUTTON_ATCK)
+                       else if(self.BUTTON_ATCK)
                        {
-                               if (weapon_prepareattack(0, WEP_CVAR_PRI(hlac, refire)))
+                               if(weapon_prepareattack(0, WEP_CVAR_PRI(hlac, refire)))
                                {
                                        self.misc_bulletcounter = 0;
                                        W_HLAC_Attack();
-                                       weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), HLAC_fire1_02);
+                                       weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
                                }
                        }
 
-                       else if (self.BUTTON_ATCK2 && WEP_CVAR(hlac, secondary))
+                       else if(self.BUTTON_ATCK2 && WEP_CVAR(hlac, secondary))
                        {
-                               if (weapon_prepareattack(1, WEP_CVAR_SEC(hlac, refire)))
+                               if(weapon_prepareattack(1, WEP_CVAR_SEC(hlac, refire)))
                                {
-                                       W_HLAC_Attack2();
+                                       W_HLAC_Attack2_Frame();
                                        weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
                                }
                        }
@@ -231,27 +240,22 @@ float w_hlac(float 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");
-                       HLAC_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
-                       return TRUE;
-               }
-               case WR_SETUP:
-               {
-                       self.current_ammo = ammo_cells;
+                       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");
+                       HLAC_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
                        return TRUE;
                }
                case WR_CHECKAMMO1:
                {
-                       ammo_amount = self.ammo_cells >= WEP_CVAR_PRI(hlac, ammo);
+                       ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_PRI(hlac, ammo);
                        ammo_amount += self.(weapon_load[WEP_HLAC]) >= WEP_CVAR_PRI(hlac, ammo);
                        return ammo_amount;
                }
                case WR_CHECKAMMO2:
                {
-                       ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(hlac, ammo);
+                       ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_SEC(hlac, ammo);
                        ammo_amount += self.(weapon_load[WEP_HLAC]) >= WEP_CVAR_SEC(hlac, ammo);
                        return ammo_amount;
                }
@@ -274,11 +278,11 @@ float w_hlac(float req)
                        return WEAPON_HLAC_MURDER;
                }
        }
-       return TRUE;
+       return FALSE;
 }
 #endif
 #ifdef CSQC
-float w_hlac(float req)
+float W_HLAC(float req)
 {
        switch(req)
        {
@@ -297,8 +301,13 @@ float w_hlac(float req)
                        precache_sound("weapons/laserimpact.wav");
                        return TRUE;
                }
+               case WR_ZOOMRETICLE:
+               {
+                       // no weapon specific image for this weapon
+                       return FALSE;
+               }
        }
-       return TRUE;
+       return FALSE;
 }
 #endif
 #endif