]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/all.qh
Port shockwave
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / all.qh
index b351e7bd1c9af0c70b4a432ff411f3ee35b70b67..cb13d1e22636836f2aae7bf5117e88bdf4f1c1e1 100644 (file)
@@ -3,12 +3,15 @@
 
 #ifndef MENUQC
 #include "calculations.qh"
+#include "../models/models.qh"
 #endif
 
 #include "../util.qh"
+
 #ifdef SVQC
 #include "../../server/bot/aim.qh"
 #endif
+
 const int MAX_SHOT_DISTANCE = 32768;
 
 // weapon pickup ratings for bot logic
@@ -96,6 +99,7 @@ void WepSet_AddStat();
 void WepSet_AddStat_InMap();
 void WriteWepSet(float dest, WepSet w);
 #endif
+
 #ifdef CSQC
 WepSet WepSet_GetFromStat();
 WepSet WepSet_GetFromStat_InMap();
@@ -104,7 +108,7 @@ WepSet ReadWepSet();
 
 // weapon name macros
 const int WEP_FIRST = 1;
-#define WEP_MAXCOUNT 24 // Increase as needed. Can be up to three times as much.
+#define WEP_MAXCOUNT 32 // Increase as needed. Can be up to 72.
 int WEP_COUNT;
 #define WEP_LAST (WEP_FIRST + WEP_COUNT - 1)
 WepSet WEPSET_ALL;
@@ -193,7 +197,7 @@ CLASS(Weapon, Object)
     /** A: WEPSET_id : WEPSET_... */
     ATTRIB(Weapon, weapons, WepSet, '0 0 0');
     /** M: function  : w_... */
-    ATTRIB(Weapon, weapon_func, bool(entity thiswep, int req), w_new);
+    METHOD(Weapon, weapon_func, bool(entity this, int req)) { return w_new(this, req); }
     /** M: ammotype  : main ammo field */
     ATTRIB(Weapon, ammo_field, .int, ammo_none);
     /** M: impulse   : weapon impulse */
@@ -208,10 +212,8 @@ CLASS(Weapon, Object)
     ATTRIB(Weapon, wpmodel, string, "");
     /** M: modelname : name of model (without g_ v_ or h_ prefixes) */
     ATTRIB(Weapon, mdl, string, "");
-    /** A: modelname : full path to g_ model */
-    ATTRIB(Weapon, model, string, "");
-    /** M: simplemdl : simpleitems weapon model/image */
-    ATTRIB(Weapon, w_simplemdl, string, "foobar");
+    /** M: model MDL_id_ITEM */
+    ATTRIB(Weapon, m_model, entity, NULL);
     /** M: crosshair : per-weapon crosshair: "CrosshairImage Size" */
     ATTRIB(Weapon, w_crosshair, string, "gfx/crosshair1");
     /** A: crosshair : per-weapon crosshair size (argument two of "crosshair" field) */
@@ -235,7 +237,7 @@ CLASS(Weapon, Object)
                float pickupbasevalue,
                vector clr,
                string modelname,
-               string simplemdl,
+               entity m,
                string crosshair,
                string wepimg,
                string refname,
@@ -249,8 +251,7 @@ CLASS(Weapon, Object)
                this.bot_pickupbasevalue = pickupbasevalue;
                this.wpcolor = clr;
                this.mdl = modelname;
-               this.model = strzone(W_Model(strcat("g_", modelname, ".md3")));
-               this.w_simplemdl = strzone(simplemdl); // simpleitems weapon model/image
+               this.m_model = m;
                this.w_crosshair = strzone(car(crosshair));
                string s = cdr(crosshair);
                this.w_crosshair_size = ((s != "") ? stof(s) : 1); // so that we can scale the crosshair from code (for compat)
@@ -260,7 +261,6 @@ CLASS(Weapon, Object)
        }
        void register_weapon(entity this, int id, WepSet bit)
        {
-               this.classname = "weapon_info";
                this.weapon = id;
                this.weapons = bit;
                this.wpmodel = strzone(strcat("wpn-", ftos(id)));
@@ -284,18 +284,20 @@ entity dummy_weapon_info;
                WEPSET_ALL |= (WEPSET_##id = WepSet_FromWeapon(this.m_id)); \
                if ((this.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= WEPSET_##id; \
                register_weapon(this, this.m_id, WEPSET_##id); \
-       }
+               localcmd(sprintf("alias weapon_%s \"impulse %d\"\n", this.netname, 230 + this.m_id - 1)); \
+       } \
+       REGISTER_INIT(WEP, id)
 
-#define _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \
-       REGISTER_WEAPON_2(id, NEW(Weapon, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname))
+#define _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, mdl, crosshair, wepimg, refname, wepname) \
+       REGISTER_WEAPON_2(id, NEW(Weapon, function, ammotype, impulse, flags, rating, color, modelname, mdl, crosshair, wepimg, refname, wepname))
 
 #ifndef MENUQC
-       #define REGISTER_WEAPON_13(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \
+       #define REGISTER_WEAPON_13(id, function, ammotype, impulse, flags, rating, color, modelname, mdl, crosshair, wepimg, refname, wepname) \
        bool function(entity this, int); \
-       _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname)
+       _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, mdl, crosshair, wepimg, refname, wepname)
 #else
-       #define REGISTER_WEAPON_13(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \
-               _REGISTER_WEAPON(id, w_new,   ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname)
+       #define REGISTER_WEAPON_13(id, function, ammotype, impulse, flags, rating, color, modelname, mdl, crosshair, wepimg, refname, wepname) \
+               _REGISTER_WEAPON(id, w_new,   ammotype, impulse, flags, rating, color, modelname, NULL, crosshair, wepimg, refname, wepname)
 #endif
 
 #include "all.inc"