From 56ecbeb9b24c18817ed92aa210fd02711c8d9fdf Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Sat, 29 Jun 2013 19:59:27 -0400 Subject: [PATCH] Put some more work into the config system --- qcsrc/common/constants.qh | 18 ---- qcsrc/common/weapons/config.qc | 4 +- qcsrc/common/weapons/config.qh | 130 +++++---------------------- qcsrc/common/weapons/w_devastator.qc | 44 +++------ qcsrc/common/weapons/weapons.qh | 20 +++++ qcsrc/server/progs.src | 1 + 6 files changed, 58 insertions(+), 159 deletions(-) diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 0fc1a98be..3b5073e87 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -376,24 +376,6 @@ float WATERLEVEL_WETFEET = 1; float WATERLEVEL_SWIMMING = 2; float WATERLEVEL_SUBMERGED = 3; -float MAX_SHOT_DISTANCE = 32768; - -// weapon requests -float WR_SETUP = 1; // (SVQC) setup weapon data -float WR_THINK = 2; // (SVQC) logic to run every frame -float WR_CHECKAMMO1 = 3; // (SVQC) checks ammo for weapon -float WR_CHECKAMMO2 = 4; // (SVQC) checks ammo for weapon -float WR_AIM = 5; // (SVQC) runs bot aiming code for this weapon -float WR_PRECACHE = 6; // (CSQC and SVQC) precaches models/sounds used by this weapon -float WR_SUICIDEMESSAGE = 7; // (SVQC) notification number for suicide message (may inspect w_deathtype for details) -float WR_KILLMESSAGE = 8; // (SVQC) notification number for kill message (may inspect w_deathtype for details) -float WR_RELOAD = 9; // (SVQC) does not need to do anything -float WR_RESETPLAYER = 10; // (SVQC) does not need to do anything -float WR_IMPACTEFFECT = 11; // (CSQC) impact effect -float WR_SWITCHABLE = 12; // (CSQC) impact effect -float WR_PLAYERDEATH = 13; // (SVQC) does not need to do anything -float WR_GONETHINK = 14; // (SVQC) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed - #define SERVERFLAG_ALLOW_FULLBRIGHT 1 #define SERVERFLAG_TEAMPLAY 2 #define SERVERFLAG_PLAYERSTATS 4 diff --git a/qcsrc/common/weapons/config.qc b/qcsrc/common/weapons/config.qc index 454ee22a2..9e05602f8 100644 --- a/qcsrc/common/weapons/config.qc +++ b/qcsrc/common/weapons/config.qc @@ -10,7 +10,7 @@ void Dump_Weapon_Settings(float fh, float alsoprint) WEP_ACTION(i, WR_CONFIG) } - + /* #define WEP_BAL_WRITE(a) { \ fputs(fh, a); \ if(alsoprint) { print(a); } } @@ -107,5 +107,5 @@ void Dump_Weapon_Settings(float fh, float alsoprint) return; #undef NOTIF_WRITE_HARDCODED #undef NOTIF_WRITE_ENTITY - #undef NOTIF_WRITE + #undef NOTIF_WRITE*/ } diff --git a/qcsrc/common/weapons/config.qh b/qcsrc/common/weapons/config.qh index 454ee22a2..462c988d7 100644 --- a/qcsrc/common/weapons/config.qh +++ b/qcsrc/common/weapons/config.qh @@ -2,110 +2,28 @@ // 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 - )); +void Dump_Weapon_Settings(float fh, float alsoprint); +float wep_config_file; +float wep_config_alsoprint; + +#define WEP_CONFIG_WRITE(a) { \ + fputs(wep_config_file, a); \ + if(wep_config_alsoprint) { print(a); } } + +#define WEP_CONFIG_WRITE_CVARS(weapon,mode,name) \ + #if mode == MO_PRI \ + WEP_CONFIG_WRITE(sprintf("set g_balance_%s_primary_%s", #weapon, #name)) \ + #endif \ + #if mode == MO_SEC \ + WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s", #weapon, #name)) \ + #endif \ + #if mode == MO_BOTH \ + WEP_CONFIG_WRITE(sprintf("set g_balance_%s_primary_%s", #weapon, #name)) \ + WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s", #weapon, #name)) \ + #endif \ + #if mode == MO_NONE \ + WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s", #weapon, #name)) \ + #endif - return; - #undef NOTIF_WRITE_HARDCODED - #undef NOTIF_WRITE_ENTITY - #undef NOTIF_WRITE -} +#define WEP_CONFIG_WRITE_PROPS(weapon,prop,name) \ + { WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s", #weapon, #name)) } diff --git a/qcsrc/common/weapons/w_devastator.qc b/qcsrc/common/weapons/w_devastator.qc index c239d70ff..e30c8746e 100644 --- a/qcsrc/common/weapons/w_devastator.qc +++ b/qcsrc/common/weapons/w_devastator.qc @@ -455,13 +455,13 @@ float W_Devastator(float req) { if(autocvar_sv_precacheweapons) { - precache_model ("models/flash.md3"); - precache_model ("models/weapons/g_rl.md3"); - precache_model ("models/weapons/v_rl.md3"); - precache_model ("models/weapons/h_rl.iqm"); - precache_sound ("weapons/rocket_det.wav"); - precache_sound ("weapons/rocket_fire.wav"); - precache_sound ("weapons/rocket_mode.wav"); + precache_model("models/flash.md3"); + precache_model("models/weapons/g_rl.md3"); + precache_model("models/weapons/v_rl.md3"); + precache_model("models/weapons/h_rl.iqm"); + precache_sound("weapons/rocket_det.wav"); + precache_sound("weapons/rocket_fire.wav"); + precache_sound("weapons/rocket_mode.wav"); } #define WEP_ADD_CVAR(weapon,mode,name) /*nothing*/ @@ -471,38 +471,16 @@ 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") + #define WEP_ADD_CVAR(weapon,mode,name) WEP_CONFIG_WRITE_CVARS(weapon,mode,name) + #define WEP_ADD_PROP(weapon,prop,name) WEP_CONFIG_WRITE_PROPS(weapon,mode,name) ARC_SETTINGS(devastator) #undef WEP_ADD_CVAR #undef WEP_ADD_PROP return TRUE; - }*/ + } case WR_SETUP: { weapon_setup(WEP_DEVASTATOR); diff --git a/qcsrc/common/weapons/weapons.qh b/qcsrc/common/weapons/weapons.qh index 2ce6fa5d8..4bf4a694b 100644 --- a/qcsrc/common/weapons/weapons.qh +++ b/qcsrc/common/weapons/weapons.qh @@ -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 +float WR_SETUP = 1; // (SVQC) setup weapon data +float WR_THINK = 2; // (SVQC) logic to run every frame +float WR_CHECKAMMO1 = 3; // (SVQC) checks ammo for weapon +float WR_CHECKAMMO2 = 4; // (SVQC) checks ammo for weapon +float WR_AIM = 5; // (SVQC) runs bot aiming code for this weapon +float WR_PRECACHE = 6; // (CSQC and SVQC) precaches models/sounds used by this weapon +float WR_SUICIDEMESSAGE = 7; // (SVQC) notification number for suicide message (may inspect w_deathtype for details) +float WR_KILLMESSAGE = 8; // (SVQC) notification number for kill message (may inspect w_deathtype for details) +float WR_RELOAD = 9; // (SVQC) does not need to do anything +float WR_RESETPLAYER = 10; // (SVQC) does not need to do anything +float WR_IMPACTEFFECT = 11; // (CSQC) impact effect +float WR_SWITCHABLE = 12; // (CSQC) impact effect +float WR_PLAYERDEATH = 13; // (SVQC) does not need to do anything +float WR_GONETHINK = 14; // (SVQC) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed +float WR_CONFIG = 15; + +// 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; diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index 0014d32ff..b7e822d1a 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -18,6 +18,7 @@ sys-post.qh ../common/test.qh ../common/counting.qh weapons/cl_weapons.qh +../common/weapons/config.qh ../common/weapons/weapons.qh // WEAPONTODO ../common/urllib.qh ../common/command/markup.qh -- 2.39.2