]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapons.qh
Even more cleanup (sort of)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapons.qh
index 23ae3a45d6262d1768e13fbd78369d3bfef6c9ec..a4ced87a9b990055ba8a30a55ef7b3916187f720 100644 (file)
@@ -17,6 +17,26 @@ float WEP_FLAG_RELOADABLE     =  0x80; // can has reload
 float WEP_FLAG_SUPERWEAPON    = 0x100; // powerup timer
 float WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
 
+float MAX_SHOT_DISTANCE = 32768;
+
+// weapon requests // WEAPONTODO
+#define WR_SETUP          1 // (SERVER) setup weapon data
+#define WR_THINK          2 // (SERVER) logic to run every frame
+#define WR_CHECKAMMO1     3 // (SERVER) checks ammo for weapon
+#define WR_CHECKAMMO2     4 // (SERVER) checks ammo for weapon
+#define WR_AIM            5 // (SERVER) runs bot aiming code for this weapon
+#define WR_INIT           6 // (BOTH) precaches models/sounds used by this weapon
+#define WR_SUICIDEMESSAGE 7 // (SERVER) notification number for suicide message (may inspect w_deathtype for details)
+#define WR_KILLMESSAGE    8 // (SERVER) notification number for kill message (may inspect w_deathtype for details)
+#define WR_RELOAD         9 // (SERVER) does not need to do anything
+#define WR_RESETPLAYER    10 // (SERVER) does not need to do anything
+#define WR_IMPACTEFFECT   11 // (CLIENT) impact effect
+#define WR_SWITCHABLE     12 // (CLIENT) impact effect
+#define WR_PLAYERDEATH    13 // (SERVER) does not need to do anything
+#define WR_GONETHINK      14 // (SERVER) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed
+#define WR_CONFIG         15 // (ALL) 
+
+// WEAPONTODO
 float  IT_UNLIMITED_WEAPON_AMMO     = 1;
 // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
 float  IT_UNLIMITED_SUPERWEAPONS    = 2;
@@ -206,6 +226,8 @@ string W_NumberWeaponOrder(string order);
 WEPSET_DECLARE_A(WEPBIT_ALL);
 WEPSET_DECLARE_A(WEPBIT_SUPERWEAPONS);
 
+// other useful macros
+#define WEP_ACTION(wpn,wrequest) (get_weaponinfo(wpn)).weapon_func(wrequest)
 
 // =====================
 //  Weapon Registration
@@ -246,19 +268,34 @@ float WEP_LAST;
 #define MO_SEC 2
 #define MO_BOTH 3
 
+#define WEP_DUPECHECK(dupecheck,cvar) \
+       #ifndef dupecheck \
+               #define dupecheck \
+               float cvar; \
+       #else \
+               #error DUPLICATE WEAPON CVAR: cvar \
+       #endif
+
+/*
+#define WEP_CLEAN_DUPECHECK(dupecheck) \
+       #ifdef WEP_CVAR_##weapon##_##name \
+               #undef WEP_CVAR_##weapon##_##name \
+       #endif
+*/
+
 #define WEP_ADD_CVAR(weapon,mode,name) \
        #if mode == MO_PRI \
-               float autocvar_g_balance_##weapon##_primary_##name; \
+               WEP_DUPECHECK(WEP_CVAR_P_##weapon##_##name, autocvar_g_balance_##weapon##_primary_##name) \
        #endif \
        #if mode == MO_SEC \
-               float autocvar_g_balance_##weapon##_secondary_##name; \
+               WEP_DUPECHECK(WEP_CVAR_S_##weapon##_##name, autocvar_g_balance_##weapon##_secondary_##name) \
        #endif \
        #if mode == MO_BOTH \
-               float autocvar_g_balance_##weapon##_primary_##name; \
-               float autocvar_g_balance_##weapon##_secondary_##name; \
+               WEP_DUPECHECK(WEP_CVAR_P_##weapon##_##name, autocvar_g_balance_##weapon##_primary_##name) \
+               WEP_DUPECHECK(WEP_CVAR_S_##weapon##_##name, autocvar_g_balance_##weapon##_secondary_##name) \
        #endif \
        #if mode == MO_NONE \
-               float autocvar_g_balance_##weapon##_##name; \
+               WEP_DUPECHECK(WEP_CVAR_##weapon##_##name, autocvar_g_balance_##weapon##_##name) \
        #endif
 
 #define WEP_CVAR(weapon,name) autocvar_g_balance_##weapon##_##name
@@ -268,7 +305,16 @@ float WEP_LAST;
 
 #define WEP_ADD_PROP(weapon,prop,name) \
        .float ##prop; \
-       float autocvar_g_balance_##weapon##_##name;
+       WEP_DUPECHECK(WEP_CVAR_##weapon##_##name, autocvar_g_balance_##weapon##_##name)
+
+#define WEP_SET_PROP(wepid,weapon,prop,name) get_weaponinfo(##wepid).##prop = autocvar_g_balance_##weapon##_##name;
+
+#define WEP_SET_PROPS(wepsettings,wepid) \
+       #define WEP_ADD_CVAR(weapon,mode,name) \
+       #define WEP_ADD_PROP(weapon,prop,name) WEP_SET_PROP(wepid,weapon,prop,name) \
+       wepsettings \
+       #undef WEP_ADD_CVAR \
+       #undef WEP_ADD_PROP
 
 #include "all.qh"