]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote-tracking branch 'gitlab/TimePath/unified_weapons' into TimePath/unified_...
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 28 Sep 2015 05:01:24 +0000 (15:01 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 28 Sep 2015 05:02:55 +0000 (15:02 +1000)
qcsrc/common/weapons/weapon/blaster.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/tuba.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc

index bdbc23b7d658e626a6089fbcfccce0a875dc6ec4..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",
-/* model     */ MDL_BLASTER_ITEM,
-/* 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) \
@@ -144,11 +146,8 @@ void W_Blaster_Attack(
                WITH(entity, self, missile, missile.think());
        }
 }
-bool W_Blaster(entity thiswep, int request)
-{SELFPARAM();
-       switch(request)
-       {
-               case WR_AIM:
+
+               METHOD(Blaster, wr_aim, bool(entity thiswep))
                {
                        if(WEP_CVAR(blaster, secondary))
                        {
@@ -163,7 +162,7 @@ bool W_Blaster(entity thiswep, int request)
                        return true;
                }
 
-               case WR_THINK:
+               METHOD(Blaster, wr_think, bool(entity thiswep))
                {
                        if(self.BUTTON_ATCK)
                        {
@@ -221,49 +220,48 @@ bool W_Blaster(entity thiswep, int request)
                        return true;
                }
 
-               case WR_INIT:
+               METHOD(Blaster, wr_init, bool(entity thiswep))
                {
                        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(entity thiswep, int request)
-{SELFPARAM();
-       switch(request)
-       {
-               case WR_IMPACTEFFECT:
+
+               METHOD(Blaster, wr_impacteffect, bool(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 6;
@@ -272,17 +270,16 @@ bool W_Blaster(entity thiswep, int request)
                        return true;
                }
 
-               case WR_INIT:
+               METHOD(Blaster, wr_init, bool(entity thiswep))
                {
                        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
index 245ff30e664fb51d14a4028e1773b0f9becb1307..76ebd8e994ef167813539f563a64377e807cf815 100644 (file)
@@ -1,19 +1,21 @@
 #ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id  */ DEVASTATOR,
-/* function  */ W_Devastator,
-/* ammotype  */ ammo_rockets,
-/* impulse   */ 9,
-/* flags     */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
-/* rating    */ BOT_PICKUP_RATING_HIGH,
-/* color     */ '1 1 0',
-/* modelname */ "rl",
-/* model     */ MDL_DEVASTATOR_ITEM,
-/* crosshair */ "gfx/crosshairrocketlauncher 0.7",
-/* wepimg    */ "weaponrocketlauncher",
-/* refname   */ "devastator",
-/* wepname   */ _("Devastator")
-);
+CLASS(Devastator, Weapon)
+/* ammotype  */ ATTRIB(Devastator, ammo_field, .int, ammo_rockets)
+/* impulse   */ ATTRIB(Devastator, impulse, int, 9)
+/* flags     */ ATTRIB(Devastator, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
+/* rating    */ ATTRIB(Devastator, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH);
+/* color     */ ATTRIB(Devastator, wpcolor, vector, '1 1 0');
+/* modelname */ ATTRIB(Devastator, mdl, string, "rl");
+#ifndef MENUQC
+/* model     */ ATTRIB(Devastator, m_model, Model, MDL_DEVASTATOR_ITEM);
+#endif
+/* crosshair */ ATTRIB(Devastator, w_crosshair, string, "gfx/crosshairrocketlauncher");
+/* crosshair */ ATTRIB(Devastator, w_crosshair_size, float, 0.7);
+/* wepimg    */ ATTRIB(Devastator, model2, string, "weaponrocketlauncher");
+/* refname   */ ATTRIB(Devastator, netname, string, "devastator");
+/* wepname   */ ATTRIB(Devastator, message, string, _("Devastator"));
+ENDCLASS(Devastator)
+REGISTER_WEAPON(DEVASTATOR, NEW(Devastator));
 
 #define DEVASTATOR_SETTINGS(w_cvar,w_prop) DEVASTATOR_SETTINGS_LIST(w_cvar, w_prop, DEVASTATOR, devastator)
 #define DEVASTATOR_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
@@ -392,15 +394,8 @@ void W_Devastator_Attack(void)
        MUTATOR_CALLHOOK(EditProjectile, self, missile);
 }
 
-bool W_Devastator(entity thiswep, int req)
-{SELFPARAM();
-       entity rock;
-       float rockfound;
-       float ammo_amount;
-       switch(req)
-       {
                #if 0
-               case WR_AIM:
+               METHOD(Devastator, wr_aim, bool(entity thiswep))
                {
                        // aim and decide to fire if appropriate
                        self.BUTTON_ATCK = bot_aim(WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
@@ -429,7 +424,7 @@ bool W_Devastator(entity thiswep, int req)
                        return true;
                }
                #else
-               case WR_AIM:
+               METHOD(Devastator, wr_aim, bool(entity thiswep))
                {
                        // aim and decide to fire if appropriate
                        self.BUTTON_ATCK = bot_aim(WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
@@ -527,7 +522,7 @@ bool W_Devastator(entity thiswep, int req)
                        return true;
                }
                #endif
-               case WR_THINK:
+               METHOD(Devastator, wr_think, bool(entity thiswep))
                {
                        if(WEP_CVAR(devastator, reload_ammo) && self.clip_load < WEP_CVAR(devastator, ammo)) // forced reload
                                _WEP_ACTION(self.weapon, WR_RELOAD);
@@ -549,13 +544,14 @@ bool W_Devastator(entity thiswep, int req)
                                if(self.BUTTON_ATCK2)
                                if(self.switchweapon == WEP_DEVASTATOR.m_id)
                                {
-                                       rockfound = 0;
+                                       entity rock;
+                                       bool rockfound = false;
                                        for(rock = world; (rock = find(rock, classname, "rocket")); ) if(rock.realowner == self)
                                        {
                                                if(!rock.rl_detonate_later)
                                                {
                                                        rock.rl_detonate_later = true;
-                                                       rockfound = 1;
+                                                       rockfound = true;
                                                }
                                        }
                                        if(rockfound)
@@ -565,17 +561,17 @@ bool W_Devastator(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Devastator, wr_init, bool(entity thiswep))
                {
                        DEVASTATOR_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
                }
-               case WR_SETUP:
+               METHOD(Devastator, wr_setup, bool(entity thiswep))
                {
                        self.rl_release = 1;
                        return true;
                }
-               case WR_CHECKAMMO1:
+               METHOD(Devastator, wr_checkammo1, bool(entity thiswep))
                {
                        #if 0
                        // don't switch while guiding a missile
@@ -606,51 +602,46 @@ bool W_Devastator(entity thiswep, int req)
                                return ammo_amount;
                        }
                        #else
-                       ammo_amount = self.WEP_AMMO(DEVASTATOR) >= WEP_CVAR(devastator, ammo);
+                       float ammo_amount = self.WEP_AMMO(DEVASTATOR) >= WEP_CVAR(devastator, ammo);
                        ammo_amount += self.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
                        return ammo_amount;
                        #endif
                }
-               case WR_CHECKAMMO2:
+               METHOD(Devastator, wr_checkammo2, bool(entity thiswep))
                {
                        return false;
                }
-               case WR_CONFIG:
+               METHOD(Devastator, wr_config, bool(entity thiswep))
                {
                        DEVASTATOR_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
                        return true;
                }
-               case WR_RESETPLAYER:
+               METHOD(Devastator, wr_resetplayer, bool(entity thiswep))
                {
                        self.rl_release = 0;
                        return true;
                }
-               case WR_RELOAD:
+               METHOD(Devastator, wr_reload, bool(entity thiswep))
                {
                        W_Reload(WEP_CVAR(devastator, ammo), SND(RELOAD));
                        return true;
                }
-               case WR_SUICIDEMESSAGE:
+               METHOD(Devastator, wr_suicidemessage, bool(entity thiswep))
                {
                        return WEAPON_DEVASTATOR_SUICIDE;
                }
-               case WR_KILLMESSAGE:
+               METHOD(Devastator, wr_killmessage, bool(entity thiswep))
                {
                        if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
                                return WEAPON_DEVASTATOR_MURDER_SPLASH;
                        else
                                return WEAPON_DEVASTATOR_MURDER_DIRECT;
                }
-       }
-       return false;
-}
+
 #endif
 #ifdef CSQC
-bool W_Devastator(entity thiswep, int req)
-{SELFPARAM();
-       switch(req)
-       {
-               case WR_IMPACTEFFECT:
+
+               METHOD(Devastator, wr_impacteffect, bool(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 12;
@@ -660,17 +651,15 @@ bool W_Devastator(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Devastator, wr_init, bool(entity thiswep))
                {
                        return true;
                }
-               case WR_ZOOMRETICLE:
+               METHOD(Devastator, wr_zoomreticle, bool(entity thiswep))
                {
                        // no weapon specific image for this weapon
                        return false;
                }
-       }
-       return false;
-}
+
 #endif
 #endif
index 29157412c1afcdb5259d30f2435ada859310a5f8..073a4e0f597ea73fab2d6c8d77d7e5b72d3dfc43 100644 (file)
@@ -1,19 +1,21 @@
 #ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id  */ ELECTRO,
-/* function  */ W_Electro,
-/* ammotype  */ ammo_cells,
-/* impulse   */ 5,
-/* flags     */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
-/* rating    */ BOT_PICKUP_RATING_MID,
-/* color     */ '0 0.5 1',
-/* modelname */ "electro",
-/* model     */ MDL_ELECTRO_ITEM,
-/* crosshair */ "gfx/crosshairelectro 0.6",
-/* wepimg    */ "weaponelectro",
-/* refname   */ "electro",
-/* wepname   */ _("Electro")
-);
+CLASS(Electro, Weapon)
+/* ammotype  */ ATTRIB(Electro, ammo_field, .int, ammo_cells)
+/* impulse   */ ATTRIB(Electro, impulse, int, 5)
+/* flags     */ ATTRIB(Electro, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
+/* rating    */ ATTRIB(Electro, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
+/* color     */ ATTRIB(Electro, wpcolor, vector, '0 0.5 1');
+/* modelname */ ATTRIB(Electro, mdl, string, "electro");
+#ifndef MENUQC
+/* model     */ ATTRIB(Electro, m_model, Model, MDL_ELECTRO_ITEM);
+#endif
+/* crosshair */ ATTRIB(Electro, w_crosshair, string, "gfx/crosshairelectro");
+/* crosshair */ ATTRIB(Electro, w_crosshair_size, float, 0.6);
+/* wepimg    */ ATTRIB(Electro, model2, string, "weaponelectro");
+/* refname   */ ATTRIB(Electro, netname, string, "electro");
+/* wepname   */ ATTRIB(Electro, message, string, _("Electro"));
+ENDCLASS(Electro)
+REGISTER_WEAPON(ELECTRO, NEW(Electro));
 
 #define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro)
 #define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
@@ -420,12 +422,8 @@ void W_Electro_CheckAttack(void)
 }
 
 .float bot_secondary_electromooth;
-bool W_Electro(entity thiswep, int req)
-{SELFPARAM();
-       float ammo_amount;
-       switch(req)
-       {
-               case WR_AIM:
+
+               METHOD(Electro, wr_aim, bool(entity thiswep))
                {
                        self.BUTTON_ATCK = self.BUTTON_ATCK2 = false;
                        if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
@@ -455,11 +453,11 @@ bool W_Electro(entity thiswep, int req)
 
                        return true;
                }
-               case WR_THINK:
+               METHOD(Electro, wr_think, bool(entity thiswep))
                {
                        if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
                        {
-                               ammo_amount = 0;
+                               float ammo_amount = 0;
                                if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
                                        ammo_amount = 1;
                                if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
@@ -496,19 +494,20 @@ bool W_Electro(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Electro, wr_init, bool(entity thiswep))
                {
                        ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
                }
-               case WR_CHECKAMMO1:
+               METHOD(Electro, wr_checkammo1, bool(entity thiswep))
                {
-                       ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
+                       float ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
                        ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
                        return ammo_amount;
                }
-               case WR_CHECKAMMO2:
+               METHOD(Electro, wr_checkammo2, bool(entity thiswep))
                {
+                       float ammo_amount;
                        if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
                        {
                                ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
@@ -521,29 +520,29 @@ bool W_Electro(entity thiswep, int req)
                        }
                        return ammo_amount;
                }
-               case WR_CONFIG:
+               METHOD(Electro, wr_config, bool(entity thiswep))
                {
                        ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
                        return true;
                }
-               case WR_RESETPLAYER:
+               METHOD(Electro, wr_resetplayer, bool(entity thiswep))
                {
                        self.electro_secondarytime = time;
                        return true;
                }
-               case WR_RELOAD:
+               METHOD(Electro, wr_reload, bool(entity thiswep))
                {
                        W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND(RELOAD));
                        return true;
                }
-               case WR_SUICIDEMESSAGE:
+               METHOD(Electro, wr_suicidemessage, bool(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_SECONDARY)
                                return WEAPON_ELECTRO_SUICIDE_ORBS;
                        else
                                return WEAPON_ELECTRO_SUICIDE_BOLT;
                }
-               case WR_KILLMESSAGE:
+               METHOD(Electro, wr_killmessage, bool(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_SECONDARY)
                        {
@@ -557,16 +556,11 @@ bool W_Electro(entity thiswep, int req)
                                        return WEAPON_ELECTRO_MURDER_BOLT;
                        }
                }
-       }
-       return false;
-}
+
 #endif
 #ifdef CSQC
-bool W_Electro(entity thiswep, int req)
-{SELFPARAM();
-       switch(req)
-       {
-               case WR_IMPACTEFFECT:
+
+               METHOD(Electro, wr_impacteffect, bool(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 6;
@@ -595,17 +589,15 @@ bool W_Electro(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Electro, wr_init, bool(entity thiswep))
                {
                        return true;
                }
-               case WR_ZOOMRETICLE:
+               METHOD(Electro, wr_zoomreticle, bool(entity thiswep))
                {
                        // no weapon specific image for this weapon
                        return false;
                }
-       }
-       return false;
-}
+
 #endif
 #endif
index a83009cd5dcc4058ec578b26eb49bc04c003f9c7..1ff37df00bf137f366835815436cd44da41783f7 100644 (file)
@@ -1,19 +1,21 @@
 #ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id  */ FIREBALL,
-/* function  */ W_Fireball,
-/* ammotype  */ ammo_none,
-/* impulse   */ 9,
-/* flags     */ WEP_FLAG_SUPERWEAPON | WEP_TYPE_SPLASH,
-/* rating    */ BOT_PICKUP_RATING_MID,
-/* color     */ '1 0.5 0',
-/* modelname */ "fireball",
-/* model     */ MDL_FIREBALL_ITEM,
-/* crosshair */ "gfx/crosshairfireball",
-/* wepimg    */ "weaponfireball",
-/* refname   */ "fireball",
-/* wepname   */ _("Fireball")
-);
+CLASS(Fireball, Weapon)
+/* ammotype  */ //ATTRIB(Fireball, ammo_field, .int, ammo_none)
+/* impulse   */ ATTRIB(Fireball, impulse, int, 9)
+/* flags     */ ATTRIB(Fireball, spawnflags, int, WEP_FLAG_SUPERWEAPON | WEP_TYPE_SPLASH);
+/* rating    */ ATTRIB(Fireball, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
+/* color     */ ATTRIB(Fireball, wpcolor, vector, '1 0.5 0');
+/* modelname */ ATTRIB(Fireball, mdl, string, "fireball");
+#ifndef MENUQC
+/* model     */ ATTRIB(Fireball, m_model, Model, MDL_FIREBALL_ITEM);
+#endif
+/* crosshair */ ATTRIB(Fireball, w_crosshair, string, "gfx/crosshairfireball");
+/* crosshair */ //ATTRIB(Fireball, w_crosshair_size, float, 0.65);
+/* wepimg    */ ATTRIB(Fireball, model2, string, "weaponfireball");
+/* refname   */ ATTRIB(Fireball, netname, string, "fireball");
+/* wepname   */ ATTRIB(Fireball, message, string, _("Fireball"));
+ENDCLASS(Fireball)
+REGISTER_WEAPON(FIREBALL, NEW(Fireball));
 
 #define FIREBALL_SETTINGS(w_cvar,w_prop) FIREBALL_SETTINGS_LIST(w_cvar, w_prop, FIREBALL, fireball)
 #define FIREBALL_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
@@ -348,11 +350,7 @@ void W_Fireball_Attack2(void)
        MUTATOR_CALLHOOK(EditProjectile, self, proj);
 }
 
-bool W_Fireball(entity thiswep, int req)
-{SELFPARAM();
-       switch(req)
-       {
-               case WR_AIM:
+               METHOD(Fireball, wr_aim, bool(entity thiswep))
                {
                        self.BUTTON_ATCK = false;
                        self.BUTTON_ATCK2 = false;
@@ -375,7 +373,7 @@ bool W_Fireball(entity thiswep, int req)
 
                        return true;
                }
-               case WR_THINK:
+               METHOD(Fireball, wr_think, bool(entity thiswep))
                {
                        if(self.BUTTON_ATCK)
                        {
@@ -397,55 +395,53 @@ bool W_Fireball(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Fireball, wr_init, bool(entity thiswep))
                {
                        FIREBALL_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
                }
-               case WR_SETUP:
+               METHOD(Fireball, wr_setup, bool(entity thiswep))
                {
                        self.ammo_field = ammo_none;
                        return true;
                }
-               case WR_CHECKAMMO1:
-               case WR_CHECKAMMO2:
+               METHOD(Fireball, wr_checkammo1, bool(entity thiswep))
+               {
+                       return true; // infinite ammo
+               }
+               METHOD(Fireball, wr_checkammo2, bool(entity thiswep))
                {
                        return true; // fireball has infinite ammo
                }
-               case WR_CONFIG:
+               METHOD(Fireball, wr_config, bool(entity thiswep))
                {
                        FIREBALL_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
                        return true;
                }
-               case WR_RESETPLAYER:
+               METHOD(Fireball, wr_resetplayer, bool(entity thiswep))
                {
                        self.fireball_primarytime = time;
                        return true;
                }
-               case WR_SUICIDEMESSAGE:
+               METHOD(Fireball, wr_suicidemessage, bool(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_SECONDARY)
                                return WEAPON_FIREBALL_SUICIDE_FIREMINE;
                        else
                                return WEAPON_FIREBALL_SUICIDE_BLAST;
                }
-               case WR_KILLMESSAGE:
+               METHOD(Fireball, wr_killmessage, bool(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_SECONDARY)
                                return WEAPON_FIREBALL_MURDER_FIREMINE;
                        else
                                return WEAPON_FIREBALL_MURDER_BLAST;
                }
-       }
-       return false;
-}
+
 #endif
 #ifdef CSQC
-bool W_Fireball(entity thiswep, int req)
-{SELFPARAM();
-       switch(req)
-       {
-               case WR_IMPACTEFFECT:
+
+               METHOD(Fireball, wr_impacteffect, bool(entity thiswep))
                {
                        vector org2;
                        if(w_deathtype & HITTYPE_SECONDARY)
@@ -462,17 +458,15 @@ bool W_Fireball(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Fireball, wr_init, bool(entity thiswep))
                {
                        return true;
                }
-               case WR_ZOOMRETICLE:
+               METHOD(Fireball, wr_zoomreticle, bool(entity thiswep))
                {
                        // no weapon specific image for this weapon
                        return false;
                }
-       }
-       return false;
-}
+
 #endif
 #endif
index a63bffe5d76687b227ea08ff4ea2d076e8cd0f5f..2c827cb220c83b7064875539999a801f7d173e8c 100644 (file)
@@ -1,19 +1,21 @@
 #ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id  */ HAGAR,
-/* function  */ W_Hagar,
-/* ammotype  */ ammo_rockets,
-/* impulse   */ 8,
-/* flags     */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
-/* rating    */ BOT_PICKUP_RATING_MID,
-/* color     */ '1 1 0.5',
-/* modelname */ "hagar",
-/* model     */ MDL_HAGAR_ITEM,
-/* crosshair */ "gfx/crosshairhagar 0.8",
-/* wepimg    */ "weaponhagar",
-/* refname   */ "hagar",
-/* wepname   */ _("Hagar")
-);
+CLASS(Hagar, Weapon)
+/* ammotype  */ ATTRIB(Hagar, ammo_field, .int, ammo_rockets)
+/* impulse   */ ATTRIB(Hagar, impulse, int, 8)
+/* flags     */ ATTRIB(Hagar, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
+/* rating    */ ATTRIB(Hagar, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
+/* color     */ ATTRIB(Hagar, wpcolor, vector, '1 1 0.5');
+/* modelname */ ATTRIB(Hagar, mdl, string, "hagar");
+#ifndef MENUQC
+/* model     */ ATTRIB(Hagar, m_model, Model, MDL_HAGAR_ITEM);
+#endif
+/* crosshair */ ATTRIB(Hagar, w_crosshair, string, "gfx/crosshairhagar");
+/* crosshair */ ATTRIB(Hagar, w_crosshair_size, float, 0.8);
+/* wepimg    */ ATTRIB(Hagar, model2, string, "weaponhagar");
+/* refname   */ ATTRIB(Hagar, netname, string, "hagar");
+/* wepname   */ ATTRIB(Hagar, message, string, _("Hagar"));
+ENDCLASS(Hagar)
+REGISTER_WEAPON(HAGAR, NEW(Hagar));
 
 #define HAGAR_SETTINGS(w_cvar,w_prop) HAGAR_SETTINGS_LIST(w_cvar, w_prop, HAGAR, hagar)
 #define HAGAR_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
@@ -397,12 +399,7 @@ void W_Hagar_Attack2_Load(void)
        }
 }
 
-bool W_Hagar(entity thiswep, int req)
-{SELFPARAM();
-       float ammo_amount;
-       switch(req)
-       {
-               case WR_AIM:
+               METHOD(Hagar, wr_aim, bool(entity thiswep))
                {
                        if(random()>0.15)
                                self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false);
@@ -411,7 +408,7 @@ bool W_Hagar(entity thiswep, int req)
 
                        return true;
                }
-               case WR_THINK:
+               METHOD(Hagar, wr_think, bool(entity thiswep))
                {
                        float loadable_secondary;
                        loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
@@ -438,7 +435,7 @@ bool W_Hagar(entity thiswep, int req)
                        }
                        return true;
                }
-               case WR_GONETHINK:
+               METHOD(Hagar, wr_gonethink, bool(entity thiswep))
                {
                        // we lost the weapon and want to prepare switching away
                        if(self.hagar_load)
@@ -449,12 +446,12 @@ bool W_Hagar(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Hagar, wr_init, bool(entity thiswep))
                {
                        HAGAR_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
                }
-               case WR_SETUP:
+               METHOD(Hagar, wr_setup, bool(entity thiswep))
                {
                        self.hagar_loadblock = false;
 
@@ -466,29 +463,29 @@ bool W_Hagar(entity thiswep, int req)
 
                        return true;
                }
-               case WR_CHECKAMMO1:
+               METHOD(Hagar, wr_checkammo1, bool(entity thiswep))
                {
-                       ammo_amount = self.WEP_AMMO(HAGAR) >= WEP_CVAR_PRI(hagar, ammo);
+                       float ammo_amount = self.WEP_AMMO(HAGAR) >= WEP_CVAR_PRI(hagar, ammo);
                        ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
                        return ammo_amount;
                }
-               case WR_CHECKAMMO2:
+               METHOD(Hagar, wr_checkammo2, bool(entity thiswep))
                {
-                       ammo_amount = self.WEP_AMMO(HAGAR) >= WEP_CVAR_SEC(hagar, ammo);
+                       float ammo_amount = self.WEP_AMMO(HAGAR) >= WEP_CVAR_SEC(hagar, ammo);
                        ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
                        return ammo_amount;
                }
-               case WR_CONFIG:
+               METHOD(Hagar, wr_config, bool(entity thiswep))
                {
                        HAGAR_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
                        return true;
                }
-               case WR_RESETPLAYER:
+               METHOD(Hagar, wr_resetplayer, bool(entity thiswep))
                {
                        self.hagar_load = 0;
                        return true;
                }
-               case WR_PLAYERDEATH:
+               METHOD(Hagar, wr_playerdeath, bool(entity thiswep))
                {
                        // if we have any rockets loaded when we die, release them
                        if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
@@ -496,34 +493,29 @@ bool W_Hagar(entity thiswep, int req)
 
                        return true;
                }
-               case WR_RELOAD:
+               METHOD(Hagar, wr_reload, bool(entity thiswep))
                {
                        if(!self.hagar_load) // require releasing loaded rockets first
                                W_Reload(min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND(RELOAD));
 
                        return true;
                }
-               case WR_SUICIDEMESSAGE:
+               METHOD(Hagar, wr_suicidemessage, bool(entity thiswep))
                {
                        return WEAPON_HAGAR_SUICIDE;
                }
-               case WR_KILLMESSAGE:
+               METHOD(Hagar, wr_killmessage, bool(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_SECONDARY)
                                return WEAPON_HAGAR_MURDER_BURST;
                        else
                                return WEAPON_HAGAR_MURDER_SPRAY;
                }
-       }
-       return false;
-}
+
 #endif
 #ifdef CSQC
-bool W_Hagar(entity thiswep, int req)
-{SELFPARAM();
-       switch(req)
-       {
-               case WR_IMPACTEFFECT:
+
+               METHOD(Hagar, wr_impacteffect, bool(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 6;
@@ -540,17 +532,15 @@ bool W_Hagar(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Hagar, wr_init, bool(entity thiswep))
                {
                        return true;
                }
-               case WR_ZOOMRETICLE:
+               METHOD(Hagar, wr_zoomreticle, bool(entity thiswep))
                {
                        // no weapon specific image for this weapon
                        return false;
                }
-       }
-       return false;
-}
+
 #endif
 #endif
index ef73577549f14f1753d13b87cc4407e82975685f..590a576096b5d4d2a5828219c91be27046d60c2d 100644 (file)
@@ -1,20 +1,22 @@
 #ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id  */ TUBA,
-/* function  */ W_Tuba,
-/* ammotype  */ ammo_none,
-/* impulse   */ 1,
-/* flags     */ WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH,
-/* rating    */ BOT_PICKUP_RATING_MID,
-/* color     */ '0 1 0',
-/* modelname */ "tuba",
-/* model     */ MDL_TUBA_ITEM,
-/* crosshair */ "gfx/crosshairtuba",
-/* wepimg    */ "weapontuba",
-/* refname   */ "tuba",
+CLASS(Tuba, Weapon)
+/* ammotype  */ //ATTRIB(Tuba, ammo_field, .int, ammo_none)
+/* impulse   */ ATTRIB(Tuba, impulse, int, 1)
+/* flags     */ ATTRIB(Tuba, spawnflags, int, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH);
+/* rating    */ ATTRIB(Tuba, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
+/* color     */ ATTRIB(Tuba, wpcolor, vector, '0 1 0');
+/* modelname */ ATTRIB(Tuba, mdl, string, "tuba");
+#ifndef MENUQC
+/* model     */ ATTRIB(Tuba, m_model, Model, MDL_TUBA_ITEM);
+#endif
+/* crosshair */ ATTRIB(Tuba, w_crosshair, string, "gfx/crosshairtuba");
+/* crosshair */ //ATTRIB(Tuba, w_crosshair_size, float, 0.65);
+/* wepimg    */ ATTRIB(Tuba, model2, string, "weapontuba");
+/* refname   */ ATTRIB(Tuba, netname, string, "tuba");
 /* xgettext:no-c-format */
-/* wepname   */ _("@!#%'n Tuba")
-);
+/* wepname   */ ATTRIB(Tuba, message, string, _("@!#%'n Tuba"));
+ENDCLASS(Tuba)
+REGISTER_WEAPON(TUBA, NEW(Tuba));
 
 #define TUBA_SETTINGS(w_cvar,w_prop) TUBA_SETTINGS_LIST(w_cvar, w_prop, TUBA, tuba)
 #define TUBA_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
@@ -365,11 +367,7 @@ void W_Tuba_NoteOn(float hittype)
        }
 }
 
-bool W_Tuba(entity thiswep, int req)
-{SELFPARAM();
-       switch(req)
-       {
-               case WR_AIM:
+               METHOD(Tuba, wr_aim, bool(entity thiswep))
                {
                        // bots cannot play the Tuba well yet
                        // I think they should start with the recorder first
@@ -383,7 +381,7 @@ bool W_Tuba(entity thiswep, int req)
 
                        return true;
                }
-               case WR_THINK:
+               METHOD(Tuba, wr_think, bool(entity thiswep))
                {
                        if(self.BUTTON_ATCK)
                        if(weapon_prepareattack(0, WEP_CVAR(tuba, refire)))
@@ -409,18 +407,18 @@ bool W_Tuba(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Tuba, wr_init, bool(entity thiswep))
                {
                        TUBA_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
                }
-               case WR_SETUP:
+               METHOD(Tuba, wr_setup, bool(entity thiswep))
                {
                        self.ammo_field = ammo_none;
                        self.tuba_instrument = 0;
                        return true;
                }
-               case WR_RELOAD:
+               METHOD(Tuba, wr_reload, bool(entity thiswep))
                {
                        // switch to alternate instruments :)
                        if(self.weaponentity.state == WS_READY)
@@ -448,17 +446,20 @@ bool W_Tuba(entity thiswep, int req)
 
                        return true;
                }
-               case WR_CHECKAMMO1:
-               case WR_CHECKAMMO2:
+               METHOD(Tuba, wr_checkammo1, bool(entity thiswep))
+               {
+                       return true; // infinite ammo
+               }
+               METHOD(Tuba, wr_checkammo2, bool(entity thiswep))
                {
                        return true; // tuba has infinite ammo
                }
-               case WR_CONFIG:
+               METHOD(Tuba, wr_config, bool(entity thiswep))
                {
                        TUBA_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
                        return true;
                }
-               case WR_SUICIDEMESSAGE:
+               METHOD(Tuba, wr_suicidemessage, bool(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_BOUNCE)
                                return WEAPON_KLEINBOTTLE_SUICIDE;
@@ -467,7 +468,7 @@ bool W_Tuba(entity thiswep, int req)
                        else
                                return WEAPON_TUBA_SUICIDE;
                }
-               case WR_KILLMESSAGE:
+               METHOD(Tuba, wr_killmessage, bool(entity thiswep))
                {
                        if(w_deathtype & HITTYPE_BOUNCE)
                                return WEAPON_KLEINBOTTLE_MURDER;
@@ -476,26 +477,15 @@ bool W_Tuba(entity thiswep, int req)
                        else
                                return WEAPON_TUBA_MURDER;
                }
-       }
-       return false;
-}
+
 #endif
 #ifdef CSQC
-bool W_Tuba(entity thiswep, int req)
-{SELFPARAM();
-       // nothing to do here; particles of tuba are handled differently
-       // WEAPONTODO
 
-       switch(req)
-       {
-               case WR_ZOOMRETICLE:
+               METHOD(Tuba, wr_zoomreticle, bool(entity thiswep))
                {
                        // no weapon specific image for this weapon
                        return false;
                }
-       }
 
-       return false;
-}
 #endif
 #endif
index 558f0449eec1588193b5fb769c0d8032493e23be..2f6d94dd7d18852fb428ef92f84a24f68bd31763 100644 (file)
@@ -1,19 +1,21 @@
 #ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id  */ VAPORIZER,
-/* function  */ W_Vaporizer,
-/* ammotype  */ ammo_cells,
-/* impulse   */ 7,
-/* flags     */ WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN,
-/* rating    */ BOT_PICKUP_RATING_HIGH,
-/* color     */ '0.5 1 1',
-/* modelname */ "minstanex",
-/* model     */ MDL_VAPORIZER_ITEM,
-/* crosshair */ "gfx/crosshairminstanex 0.6",
-/* wepimg    */ "weaponminstanex",
-/* refname   */ "vaporizer",
-/* wepname   */ _("Vaporizer")
-);
+CLASS(Vaporizer, Weapon)
+/* ammotype  */ ATTRIB(Vaporizer, ammo_field, .int, ammo_cells)
+/* impulse   */ ATTRIB(Vaporizer, impulse, int, 7)
+/* flags     */ ATTRIB(Vaporizer, spawnflags, int, WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_FLAG_SUPERWEAPON | WEP_TYPE_HITSCAN);
+/* rating    */ ATTRIB(Vaporizer, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH);
+/* color     */ ATTRIB(Vaporizer, wpcolor, vector, '0.5 1 1');
+/* modelname */ ATTRIB(Vaporizer, mdl, string, "minstanex");
+#ifndef MENUQC
+/* model     */ ATTRIB(Vaporizer, m_model, Model, MDL_VAPORIZER_ITEM);
+#endif
+/* crosshair */ ATTRIB(Vaporizer, w_crosshair, string, "gfx/crosshairminstanex");
+/* crosshair */ ATTRIB(Vaporizer, w_crosshair_size, float, 0.6);
+/* wepimg    */ ATTRIB(Vaporizer, model2, string, "weaponminstanex");
+/* refname   */ ATTRIB(Vaporizer, netname, string, "vaporizer");
+/* wepname   */ ATTRIB(Vaporizer, message, string, _("Vaporizer"));
+ENDCLASS(Vaporizer)
+REGISTER_WEAPON(VAPORIZER, NEW(Vaporizer));
 
 #define VAPORIZER_SETTINGS(w_cvar,w_prop) VAPORIZER_SETTINGS_LIST(w_cvar, w_prop, VAPORIZER, vaporizer)
 #define VAPORIZER_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
@@ -235,18 +237,7 @@ void W_RocketMinsta_Attack3 (void)
     }
 }
 
-float W_Vaporizer(entity thiswep, float req)
-{SELFPARAM();
-       float ammo_amount;
-       float vaporizer_ammo;
-       float rapid = autocvar_g_rm_laser_rapid;
-
-       // now multiple WR_s use this
-       vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
-
-       switch(req)
-       {
-               case WR_AIM:
+               METHOD(Vaporizer, wr_aim, bool(entity thiswep))
                {
                        if(self.WEP_AMMO(VAPORIZER) > 0)
                                self.BUTTON_ATCK = bot_aim(1000000, 0, 1, false);
@@ -255,8 +246,9 @@ float W_Vaporizer(entity thiswep, float req)
 
                        return true;
                }
-               case WR_THINK:
+               METHOD(Vaporizer, wr_think, bool(entity thiswep))
                {
+                       float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
                        // if the laser uses load, we also consider its ammo for reloading
                        if(WEP_CVAR(vaporizer, reload_ammo) && WEP_CVAR_SEC(vaporizer, ammo) && self.clip_load < min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo))) // forced reload
                                _WEP_ACTION(self.weapon, WR_RELOAD);
@@ -274,6 +266,7 @@ float W_Vaporizer(entity thiswep, float req)
                        {
                                if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2)
                                {
+                                       bool rapid = autocvar_g_rm_laser_rapid;
                                        if(self.jump_interval <= time && !self.held_down)
                                        {
                                                if(rapid)
@@ -327,44 +320,46 @@ float W_Vaporizer(entity thiswep, float req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Vaporizer, wr_init, bool(entity thiswep))
                {
                        //W_Blaster(WR_INIT); // Samual: Is this really the proper thing to do? Didn't we already run this previously?
                        VAPORIZER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
                }
-               case WR_SETUP:
+               METHOD(Vaporizer, wr_setup, bool(entity thiswep))
                {
                        self.ammo_field = WEP_AMMO(VAPORIZER);
                        self.vaporizer_lasthit = 0;
                        return true;
                }
-               case WR_CHECKAMMO1:
+               METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep))
                {
-                       ammo_amount = self.WEP_AMMO(VAPORIZER) >= vaporizer_ammo;
+                       float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
+                       float ammo_amount = self.WEP_AMMO(VAPORIZER) >= vaporizer_ammo;
                        ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
                        return ammo_amount;
                }
-               case WR_CHECKAMMO2:
+               METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep))
                {
                        if(!WEP_CVAR_SEC(vaporizer, ammo))
                                return true;
-                       ammo_amount = self.WEP_AMMO(VAPORIZER) >= WEP_CVAR_SEC(vaporizer, ammo);
+                       float ammo_amount = self.WEP_AMMO(VAPORIZER) >= WEP_CVAR_SEC(vaporizer, ammo);
                        ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
                        return ammo_amount;
                }
-               case WR_CONFIG:
+               METHOD(Vaporizer, wr_config, bool(entity thiswep))
                {
                        VAPORIZER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
                        return true;
                }
-               case WR_RESETPLAYER:
+               METHOD(Vaporizer, wr_resetplayer, bool(entity thiswep))
                {
                        self.vaporizer_lasthit = 0;
                        return true;
                }
-               case WR_RELOAD:
+               METHOD(Vaporizer, wr_reload, bool(entity thiswep))
                {
+                       float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
                        float used_ammo;
                        if(WEP_CVAR_SEC(vaporizer, ammo))
                                used_ammo = min(vaporizer_ammo, WEP_CVAR_SEC(vaporizer, ammo));
@@ -374,24 +369,19 @@ float W_Vaporizer(entity thiswep, float req)
                        W_Reload(used_ammo, SND(RELOAD));
                        return true;
                }
-               case WR_SUICIDEMESSAGE:
+               METHOD(Vaporizer, wr_suicidemessage, bool(entity thiswep))
                {
                        return WEAPON_THINKING_WITH_PORTALS;
                }
-               case WR_KILLMESSAGE:
+               METHOD(Vaporizer, wr_killmessage, bool(entity thiswep))
                {
                        return WEAPON_VAPORIZER_MURDER;
                }
-       }
-       return false;
-}
+
 #endif
 #ifdef CSQC
-float W_Vaporizer(entity thiswep, float req)
-{SELFPARAM();
-       switch(req)
-       {
-               case WR_IMPACTEFFECT:
+
+               METHOD(Vaporizer, wr_impacteffect, bool(entity thiswep))
                {
                        vector org2 = w_org + w_backoff * 6;
                        if(w_deathtype & HITTYPE_SECONDARY)
@@ -406,7 +396,7 @@ float W_Vaporizer(entity thiswep, float req)
                        }
                        return true;
                }
-               case WR_INIT:
+               METHOD(Vaporizer, wr_init, bool(entity thiswep))
                {
                        if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
                        {
@@ -414,7 +404,7 @@ float W_Vaporizer(entity thiswep, float req)
                        }
                        return true;
                }
-               case WR_ZOOMRETICLE:
+               METHOD(Vaporizer, wr_zoomreticle, bool(entity thiswep))
                {
                        if(button_zoom || zoomscript_caught)
                        {
@@ -427,8 +417,6 @@ float W_Vaporizer(entity thiswep, float req)
                                return false;
                        }
                }
-       }
-       return false;
-}
+
 #endif
 #endif
index 965c6428a6fe8cc321c172b71c36354195ccc4f1..e9e659e0c9ed2a61b5976a64ff3a0838d9c16acb 100644 (file)
@@ -1,19 +1,21 @@
 #ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id  */ VORTEX,
-/* function  */ W_Vortex,
-/* ammotype  */ ammo_cells,
-/* impulse   */ 7,
-/* flags     */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
-/* rating    */ BOT_PICKUP_RATING_HIGH,
-/* color     */ '0.5 1 1',
-/* modelname */ "nex",
-/* model     */ MDL_VORTEX_ITEM,
-/* crosshair */ "gfx/crosshairnex 0.65",
-/* wepimg    */ "weaponnex",
-/* refname   */ "vortex",
-/* wepname   */ _("Vortex")
-);
+CLASS(Vortex, Weapon)
+/* ammotype  */ ATTRIB(Vortex, ammo_field, .int, ammo_cells)
+/* impulse   */ ATTRIB(Vortex, impulse, int, 7)
+/* flags     */ ATTRIB(Vortex, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN);
+/* rating    */ ATTRIB(Vortex, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH);
+/* color     */ ATTRIB(Vortex, wpcolor, vector, '0.5 1 1');
+/* modelname */ ATTRIB(Vortex, mdl, string, "nex");
+#ifndef MENUQC
+/* model     */ ATTRIB(Vortex, m_model, Model, MDL_VORTEX_ITEM);
+#endif
+/* crosshair */ ATTRIB(Vortex, w_crosshair, string, "gfx/crosshairnex");
+/* crosshair */ ATTRIB(Vortex, w_crosshair_size, float, 0.65);
+/* wepimg    */ ATTRIB(Vortex, model2, string, "weaponnex");
+/* refname   */ ATTRIB(Vortex, netname, string, "vortex");
+/* wepname   */ ATTRIB(Vortex, message, string, _("Vortex"));
+ENDCLASS(Vortex)
+REGISTER_WEAPON(VORTEX, NEW(Vortex));
 
 #define VORTEX_SETTINGS(w_cvar,w_prop) VORTEX_SETTINGS_LIST(w_cvar, w_prop, VORTEX, vortex)
 #define VORTEX_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
@@ -129,16 +131,9 @@ void W_Vortex_Attack(float issecondary)
        W_DecreaseAmmo(myammo);
 }
 
-void spawnfunc_weapon_vortex(void); // defined in t_items.qc
-
 .float vortex_chargepool_pauseregen_finished;
-bool W_Vortex(entity thiswep, int req)
-{SELFPARAM();
-       float dt;
-       float ammo_amount;
-       switch(req)
-       {
-               case WR_AIM:
+
+               METHOD(Vortex, wr_aim, bool(entity thiswep))
                {
                        if(bot_aim(1000000, 0, 1, false))
                                self.BUTTON_ATCK = true;
@@ -149,7 +144,7 @@ bool W_Vortex(entity thiswep, int req)
                        }
                        return true;
                }
-               case WR_THINK:
+               METHOD(Vortex, wr_think, bool(entity thiswep))
                {
                        if(WEP_CVAR(vortex, charge) && self.vortex_charge < WEP_CVAR(vortex, charge_limit))
                                self.vortex_charge = min(1, self.vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME);
@@ -179,7 +174,7 @@ bool W_Vortex(entity thiswep, int req)
                                        if(WEP_CVAR(vortex, charge))
                                        {
                                                self.vortex_charge_rottime = time + WEP_CVAR(vortex, charge_rot_pause);
-                                               dt = frametime / W_TICSPERFRAME;
+                                               float dt = frametime / W_TICSPERFRAME;
 
                                                if(self.vortex_charge < 1)
                                                {
@@ -251,28 +246,28 @@ bool W_Vortex(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Vortex, wr_init, bool(entity thiswep))
                {
                        VORTEX_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
                        return true;
                }
-               case WR_SETUP:
+               METHOD(Vortex, wr_setup, bool(entity thiswep))
                {
                        self.vortex_lasthit = 0;
                        return true;
                }
-               case WR_CHECKAMMO1:
+               METHOD(Vortex, wr_checkammo1, bool(entity thiswep))
                {
-                       ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_PRI(vortex, ammo);
+                       float ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_PRI(vortex, ammo);
                        ammo_amount += (autocvar_g_balance_vortex_reload_ammo && self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
                        return ammo_amount;
                }
-               case WR_CHECKAMMO2:
+               METHOD(Vortex, wr_checkammo2, bool(entity thiswep))
                {
                        if(WEP_CVAR(vortex, secondary))
                        {
                                // don't allow charging if we don't have enough ammo
-                               ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_SEC(vortex, ammo);
+                               float ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_SEC(vortex, ammo);
                                ammo_amount += self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
                                return ammo_amount;
                        }
@@ -281,40 +276,35 @@ bool W_Vortex(entity thiswep, int req)
                                return false; // zoom is not a fire mode
                        }
                }
-               case WR_CONFIG:
+               METHOD(Vortex, wr_config, bool(entity thiswep))
                {
                        VORTEX_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
                        return true;
                }
-               case WR_RESETPLAYER:
+               METHOD(Vortex, wr_resetplayer, bool(entity thiswep))
                {
                        self.vortex_lasthit = 0;
                        return true;
                }
-               case WR_RELOAD:
+               METHOD(Vortex, wr_reload, bool(entity thiswep))
                {
                        W_Reload(min(WEP_CVAR_PRI(vortex, ammo), WEP_CVAR_SEC(vortex, ammo)), SND(RELOAD));
                        return true;
                }
-               case WR_SUICIDEMESSAGE:
+               METHOD(Vortex, wr_suicidemessage, bool(entity thiswep))
                {
                        return WEAPON_THINKING_WITH_PORTALS;
                }
-               case WR_KILLMESSAGE:
+               METHOD(Vortex, wr_killmessage, bool(entity thiswep))
                {
                        return WEAPON_VORTEX_MURDER;
                }
-       }
-       return false;
-}
+
 #endif
 #ifdef CSQC
 float autocvar_g_balance_vortex_secondary = 0; // WEAPONTODO
-bool W_Vortex(entity thiswep, int req)
-{SELFPARAM();
-       switch(req)
-       {
-               case WR_IMPACTEFFECT:
+
+               METHOD(Vortex, wr_impacteffect, bool(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 6;
@@ -324,7 +314,7 @@ bool W_Vortex(entity thiswep, int req)
 
                        return true;
                }
-               case WR_INIT:
+               METHOD(Vortex, wr_init, bool(entity thiswep))
                {
                        if(autocvar_cl_reticle && autocvar_cl_reticle_weapon)
                        {
@@ -332,7 +322,7 @@ bool W_Vortex(entity thiswep, int req)
                        }
                        return true;
                }
-               case WR_ZOOMRETICLE:
+               METHOD(Vortex, wr_zoomreticle, bool(entity thiswep))
                {
                        if(button_zoom || zoomscript_caught || (!WEP_CVAR(vortex, secondary) && button_attack2))
                        {
@@ -345,8 +335,6 @@ bool W_Vortex(entity thiswep, int req)
                                return false;
                        }
                }
-       }
-       return false;
-}
+
 #endif
 #endif