]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/blaster.qc
Merge remote-tracking branch 'gitlab/TimePath/unified_weapons' into TimePath/unified_...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / blaster.qc
index 5c7fd8dfcd49dc1dffd61f25c8ad16c57ca16467..bba93388769eac8dbc7bb3fd1b1cf416b29f6370 100644 (file)
@@ -1,19 +1,21 @@
 #ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id  */ BLASTER,
-/* function  */ W_Blaster,
-/* ammotype  */ ammo_none,
-/* impulse   */ 1,
-/* flags     */ WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
-/* rating    */ 0,
-/* color     */ '1 0.5 0.5',
-/* modelname */ "laser",
-/* simplemdl */ "foobar",
-/* crosshair */ "gfx/crosshairlaser 0.5",
-/* wepimg    */ "weaponlaser",
-/* refname   */ "blaster",
-/* wepname   */ _("Blaster")
-);
+CLASS(Blaster, Weapon)
+/* ammotype  */ //ATTRIB(Blaster, ammo_field, .int, ammo_none)
+/* impulse   */ ATTRIB(Blaster, impulse, int, 1)
+/* flags     */ ATTRIB(Blaster, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
+/* rating    */ ATTRIB(Blaster, bot_pickupbasevalue, float, 0);
+/* color     */ ATTRIB(Blaster, wpcolor, vector, '1 0.5 0.5');
+/* modelname */ ATTRIB(Blaster, mdl, string, "laser");
+#ifndef MENUQC
+/* model     */ ATTRIB(Blaster, m_model, Model, MDL_BLASTER_ITEM);
+#endif
+/* crosshair */ ATTRIB(Blaster, w_crosshair, string, "gfx/crosshairlaser");
+/* crosshair */ ATTRIB(Blaster, w_crosshair_size, float, 0.5);
+/* wepimg    */ ATTRIB(Blaster, model2, string, "weaponlaser");
+/* refname   */ ATTRIB(Blaster, netname, string, "blaster");
+/* wepname   */ ATTRIB(Blaster, message, string, _("Blaster"));
+ENDCLASS(Blaster)
+REGISTER_WEAPON(BLASTER, NEW(Blaster));
 
 #define BLASTER_SETTINGS(w_cvar,w_prop) BLASTER_SETTINGS_LIST(w_cvar, w_prop, BLASTER, blaster)
 #define BLASTER_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
@@ -95,7 +97,7 @@ void W_Blaster_Attack(
 {SELFPARAM();
        vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD);
 
-       W_SetupShot_Dir(self, s_forward, false, 3, W_Sound("lasergun_fire"), CH_WEAPON_B, atk_damage);
+       W_SetupShot_Dir(self, s_forward, false, 3, SND(LASERGUN_FIRE), CH_WEAPON_B, atk_damage);
        Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 
        entity missile = spawn();
@@ -141,15 +143,11 @@ void W_Blaster_Attack(
 
        if(time >= missile.nextthink)
        {
-               SELFCALL(missile, missile.think());
-               SELFCALL_DONE();
+               WITH(entity, self, missile, missile.think());
        }
 }
-bool W_Blaster(int request)
-{SELFPARAM();
-       switch(request)
-       {
-               case WR_AIM:
+
+               METHOD(Blaster, wr_aim, bool(entity thiswep))
                {
                        if(WEP_CVAR(blaster, secondary))
                        {
@@ -164,7 +162,7 @@ bool W_Blaster(int request)
                        return true;
                }
 
-               case WR_THINK:
+               METHOD(Blaster, wr_think, bool(entity thiswep))
                {
                        if(self.BUTTON_ATCK)
                        {
@@ -222,73 +220,66 @@ bool W_Blaster(int request)
                        return true;
                }
 
-               case WR_INIT:
+               METHOD(Blaster, wr_init, bool(entity thiswep))
                {
-                       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:
+               METHOD(Blaster, wr_setup, bool(entity thiswep))
                {
                        self.ammo_field = ammo_none;
                        return true;
                }
 
-               case WR_CHECKAMMO1:
-               case WR_CHECKAMMO2:
+               METHOD(Blaster, wr_checkammo1, bool(entity thiswep))
                {
-                       return true; // laser has infinite ammo
+                       return true; // infinite ammo
                }
 
-               case WR_CONFIG:
+               METHOD(Blaster, wr_checkammo2, bool(entity thiswep))
+               {
+                       return true; // blaster has infinite ammo
+               }
+
+               METHOD(Blaster, wr_config, bool(entity thiswep))
                {
                        BLASTER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
                        return true;
                }
 
-               case WR_SUICIDEMESSAGE:
+               METHOD(Blaster, wr_suicidemessage, bool(entity thiswep))
                {
                        return WEAPON_BLASTER_SUICIDE;
                }
 
-               case WR_KILLMESSAGE:
+               METHOD(Blaster, wr_killmessage, bool(entity thiswep))
                {
                        return WEAPON_BLASTER_MURDER;
                }
-       }
-       return false;
-}
+
 #endif
 #ifdef CSQC
-bool W_Blaster(int request)
-{SELFPARAM();
-       switch(request)
-       {
-               case WR_IMPACTEFFECT:
+
+               METHOD(Blaster, wr_impacteffect, bool(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 6;
                        pointparticles(particleeffectnum(EFFECT_BLASTER_IMPACT), org2, w_backoff * 1000, 1);
-                       if(!w_issilent) { sound(self, CH_SHOTS, W_Sound("laserimpact"), VOL_BASE, ATTN_NORM); }
+                       if(!w_issilent) { sound(self, CH_SHOTS, SND_LASERIMPACT, VOL_BASE, ATTN_NORM); }
                        return true;
                }
 
-               case WR_INIT:
+               METHOD(Blaster, wr_init, bool(entity thiswep))
                {
-                       precache_sound(W_Sound("laserimpact"));
                        return true;
                }
-               case WR_ZOOMRETICLE:
+
+               METHOD(Blaster, wr_zoomreticle, bool(entity thiswep))
                {
                        // no weapon specific image for this weapon
                        return false;
                }
-       }
-       return false;
-}
+
 #endif
 #endif