]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Start working on weapon config generator
authorSamual Lenks <samual@xonotic.org>
Sat, 29 Jun 2013 21:39:28 +0000 (17:39 -0400)
committerSamual Lenks <samual@xonotic.org>
Sat, 29 Jun 2013 21:39:28 +0000 (17:39 -0400)
qcsrc/common/weapons/config.qc [new file with mode: 0644]
qcsrc/common/weapons/config.qh [new file with mode: 0644]
qcsrc/common/weapons/w_devastator.qc

diff --git a/qcsrc/common/weapons/config.qc b/qcsrc/common/weapons/config.qc
new file mode 100644 (file)
index 0000000..454ee22
--- /dev/null
@@ -0,0 +1,111 @@
+// ==========================
+//  Balance Config Generator
+// ==========================
+
+void Dump_Weapon_Settings(float fh, float alsoprint)
+{
+       float i;
+       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+       {
+               WEP_ACTION(i, WR_CONFIG)
+       }
+
+                       
+       #define WEP_BAL_WRITE(a) { \
+               fputs(fh, a); \
+               if(alsoprint) { print(a); } }
+       #define WEP_BAL_WRITE_ENTITY(description) { \
+               notif_msg = \
+                       sprintf( \
+                               "seta notification_%s \"%d\" \"%s\"\n", \
+                               e.nent_name, e.nent_default, description \
+                       ); \
+               WEP_BAL_WRITE(notif_msg) }
+       #define WEP_BAL_WRITE_HARDCODED(cvar,default,description) { \
+               notif_msg = \
+                       sprintf( \
+                               "seta notification_%s \"%s\" \"%s\"\n", \
+                               cvar, default, description \
+                       ); \
+               WEP_BAL_WRITE(notif_msg) }
+
+       string notif_msg;
+       float i;
+       entity e;
+
+       NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
+       for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i)
+       {
+               e = Get_Notif_Ent(MSG_ANNCE, i);
+               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
+               
+               NOTIF_WRITE_ENTITY(
+                       "Notification control cvar: 0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled)"
+               );
+       }
+
+       NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
+       for(i = 1; i <= NOTIF_INFO_COUNT; ++i)
+       {
+               e = Get_Notif_Ent(MSG_INFO, i);
+               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
+               
+               NOTIF_WRITE_ENTITY(
+                       "Notification control cvar: 0 = off, 1 = print to console, "
+                       "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
+               );
+       }
+
+       NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
+       for(i = 1; i <= NOTIF_CENTER_COUNT; ++i)
+       {
+               e = Get_Notif_Ent(MSG_CENTER, i);
+               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
+               
+               NOTIF_WRITE_ENTITY(
+                       "Notification control cvar: 0 = off, 1 = centerprint"
+               );
+       }
+
+       NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
+       for(i = 1; i <= NOTIF_MULTI_COUNT; ++i)
+       {
+               e = Get_Notif_Ent(MSG_MULTI, i);
+               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
+               
+               NOTIF_WRITE_ENTITY(
+                       "Notification control cvar: 0 = off, 1 = trigger subcalls"
+               );
+       }
+
+       // edit these to match whichever cvars are used for specific notification options
+       NOTIF_WRITE("\n// HARD CODED notification variables:\n");
+       
+       NOTIF_WRITE_HARDCODED(
+               "allow_chatboxprint", "1",
+               "Allow notifications to be printed to chat box by setting notification cvar to 2 "
+               "(You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)"
+       );
+
+       NOTIF_WRITE(sprintf(
+               strcat(
+                       "\n// Notification counts (total = %d): ",
+                       "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d\n"
+               ),
+               (
+                       NOTIF_ANNCE_COUNT +
+                       NOTIF_INFO_COUNT +
+                       NOTIF_CENTER_COUNT +
+                       NOTIF_MULTI_COUNT
+               ),
+               NOTIF_ANNCE_COUNT,
+               NOTIF_INFO_COUNT,
+               NOTIF_CENTER_COUNT,
+               NOTIF_MULTI_COUNT
+       ));
+       
+       return;
+       #undef NOTIF_WRITE_HARDCODED
+       #undef NOTIF_WRITE_ENTITY
+       #undef NOTIF_WRITE
+}
diff --git a/qcsrc/common/weapons/config.qh b/qcsrc/common/weapons/config.qh
new file mode 100644 (file)
index 0000000..454ee22
--- /dev/null
@@ -0,0 +1,111 @@
+// ==========================
+//  Balance Config Generator
+// ==========================
+
+void Dump_Weapon_Settings(float fh, float alsoprint)
+{
+       float i;
+       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+       {
+               WEP_ACTION(i, WR_CONFIG)
+       }
+
+                       
+       #define WEP_BAL_WRITE(a) { \
+               fputs(fh, a); \
+               if(alsoprint) { print(a); } }
+       #define WEP_BAL_WRITE_ENTITY(description) { \
+               notif_msg = \
+                       sprintf( \
+                               "seta notification_%s \"%d\" \"%s\"\n", \
+                               e.nent_name, e.nent_default, description \
+                       ); \
+               WEP_BAL_WRITE(notif_msg) }
+       #define WEP_BAL_WRITE_HARDCODED(cvar,default,description) { \
+               notif_msg = \
+                       sprintf( \
+                               "seta notification_%s \"%s\" \"%s\"\n", \
+                               cvar, default, description \
+                       ); \
+               WEP_BAL_WRITE(notif_msg) }
+
+       string notif_msg;
+       float i;
+       entity e;
+
+       NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
+       for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i)
+       {
+               e = Get_Notif_Ent(MSG_ANNCE, i);
+               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
+               
+               NOTIF_WRITE_ENTITY(
+                       "Notification control cvar: 0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled)"
+               );
+       }
+
+       NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
+       for(i = 1; i <= NOTIF_INFO_COUNT; ++i)
+       {
+               e = Get_Notif_Ent(MSG_INFO, i);
+               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
+               
+               NOTIF_WRITE_ENTITY(
+                       "Notification control cvar: 0 = off, 1 = print to console, "
+                       "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
+               );
+       }
+
+       NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
+       for(i = 1; i <= NOTIF_CENTER_COUNT; ++i)
+       {
+               e = Get_Notif_Ent(MSG_CENTER, i);
+               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
+               
+               NOTIF_WRITE_ENTITY(
+                       "Notification control cvar: 0 = off, 1 = centerprint"
+               );
+       }
+
+       NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
+       for(i = 1; i <= NOTIF_MULTI_COUNT; ++i)
+       {
+               e = Get_Notif_Ent(MSG_MULTI, i);
+               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
+               
+               NOTIF_WRITE_ENTITY(
+                       "Notification control cvar: 0 = off, 1 = trigger subcalls"
+               );
+       }
+
+       // edit these to match whichever cvars are used for specific notification options
+       NOTIF_WRITE("\n// HARD CODED notification variables:\n");
+       
+       NOTIF_WRITE_HARDCODED(
+               "allow_chatboxprint", "1",
+               "Allow notifications to be printed to chat box by setting notification cvar to 2 "
+               "(You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)"
+       );
+
+       NOTIF_WRITE(sprintf(
+               strcat(
+                       "\n// Notification counts (total = %d): ",
+                       "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d\n"
+               ),
+               (
+                       NOTIF_ANNCE_COUNT +
+                       NOTIF_INFO_COUNT +
+                       NOTIF_CENTER_COUNT +
+                       NOTIF_MULTI_COUNT
+               ),
+               NOTIF_ANNCE_COUNT,
+               NOTIF_INFO_COUNT,
+               NOTIF_CENTER_COUNT,
+               NOTIF_MULTI_COUNT
+       ));
+       
+       return;
+       #undef NOTIF_WRITE_HARDCODED
+       #undef NOTIF_WRITE_ENTITY
+       #undef NOTIF_WRITE
+}
index f193bbc0215a877010a2cd0a7b900c1f50e2990d..c239d70ff1099cb3ffe979a873e28a4f8e311797 100644 (file)
@@ -1,14 +1,14 @@
 #ifdef REGISTER_WEAPON
 REGISTER_WEAPON(
-/* WEP_##id  */ DEVASTATOR,
-/* function  */ W_Devastator,
-/* ammotype  */ IT_ROCKETS,
-/* impulse   */ 9,
-/* flags     */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
-/* rating    */ BOT_PICKUP_RATING_HIGH,
-/* model     */ "rl",
-/* shortname */ "devastator",
-/* fullname  */ _("Devastator")
+/* WEP_##id */ DEVASTATOR,
+/* function */ W_Devastator,
+/* ammotype */ IT_ROCKETS,
+/* impulse  */ 9,
+/* flags    */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
+/* rating   */ BOT_PICKUP_RATING_HIGH,
+/* model    */ "rl",
+/* netname  */ "devastator",
+/* fullname */ _("Devastator")
 );
 
 #define DEVASTATOR_SETTINGS(weapon) \
@@ -471,7 +471,38 @@ float W_Devastator(float req)
                        #undef WEP_ADD_PROP
                        
                        return TRUE;
-               }
+               }/*
+               case WR_CONFIG:
+               {
+                       
+                       #define WEP_CONFIG_WRITE(a) { \
+                               fputs(wep_config_file, a); \
+                               if(wep_config_alsoprint) { print(a); } }
+
+                       #define WEP_CONFIG_WRITE_CVAR(cvarstring) \
+                               { WEP_CONFIG_WRITE(sprintf(cvarstring, weapon, #name)); }
+                               
+                       #define WEP_ADD_CVAR(weapon,mode,name) \
+                               #if mode == MO_PRI \
+                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_primary_%s") \
+                               #endif \
+                               #if mode == MO_SEC \
+                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_secondary_%s") \
+                               #endif \
+                               #if mode == MO_BOTH \
+                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_primary_%s") \
+                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_secondary_%s") \
+                               #endif \
+                               #if mode == MO_NONE \
+                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_%s") \
+                               #endif
+                               
+                       #define WEP_ADD_PROP(weapon,prop,name) WEP_CONFIG_WRITE_CVAR("set g_balance_%s_%s")
+                       ARC_SETTINGS(devastator)
+                       #undef WEP_ADD_CVAR
+                       #undef WEP_ADD_PROP
+                       return TRUE;
+               }*/
                case WR_SETUP:
                {
                        weapon_setup(WEP_DEVASTATOR);