From 151b255994c7c39f2d21561f08c03e4bf5eaabe9 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Thu, 23 Jul 2009 15:05:14 -0700 Subject: [PATCH 1/2] Updated antistick, small performance gain. Modified any multi-valued cvars to accept "1,2" instead of only "1, 2" and made a cosmetic change to get array sizes. --- src/zr/antistick.inc | 54 +++++++++++-------------- src/zr/damage.inc | 5 ++- src/zr/models.inc | 2 +- src/zr/playerclasses/clientoverlays.inc | 5 ++- src/zr/weapons/restrict.inc | 4 +- 5 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/zr/antistick.inc b/src/zr/antistick.inc index 4b8a516..7963972 100644 --- a/src/zr/antistick.inc +++ b/src/zr/antistick.inc @@ -28,28 +28,28 @@ /** * @section Collision values. */ -#define ANTISTICK_COLLISIONS_OFF 2 -#define ANTISTICK_COLLISIONS_ON 5 - -#define COLLISION_GROUP_NONE 0 /** Default; collides with static and dynamic objects. */ -#define COLLISION_GROUP_DEBRIS 1 /** Collides with nothing but world and static stuff. */ -#define COLLISION_GROUP_DEBRIS_TRIGGER 2 /** Same as debris, but hits triggers. */ -#define COLLISION_GROUP_INTERACTIVE_DEBRIS 3 /** Collides with everything except other interactive debris or debris. */ -#define COLLISION_GROUP_INTERACTIVE 4 /** Collides with everything except interactive debris or debris. */ -#define COLLISION_GROUP_PLAYER 5 /** This is the default behavior expected for most prop_physics. */ -#define COLLISION_GROUP_BREAKABLE_GLASS 6 /** Special group for glass debris. */ -#define COLLISION_GROUP_VEHICLE 7 /** Collision group for driveable vehicles. */ -#define COLLISION_GROUP_PLAYER_MOVEMENT 8 /** For HL2, same as Collision_Group_Player. */ -#define COLLISION_GROUP_NPC 9 /** Generic NPC group. */ -#define COLLISION_GROUP_IN_VEHICLE 10 /** For any entity inside a vehicle. */ -#define COLLISION_GROUP_WEAPON 11 /** For any weapons that need collision detection. */ -#define COLLISION_GROUP_VEHICLE_CLIP 12 /** Vehicle clip brush to restrict vehicle movement. */ -#define COLLISION_GROUP_PROJECTILE 13 /** Projectiles. */ -#define COLLISION_GROUP_DOOR_BLOCKER 14 /** Blocks entities not permitted to get near moving doors. */ -#define COLLISION_GROUP_PASSABLE_DOOR 15 /** Doors that the player shouldn't collide with. */ -#define COLLISION_GROUP_DISSOLVING 16 /** Things that are dissolving are in this group. */ -#define COLLISION_GROUP_PUSHAWAY 17 /** Nonsolid on client and server, pushaway in player code. */ +#define COLLISION_GROUP_NONE 0 /** Default; collides with static and dynamic objects. */ +#define COLLISION_GROUP_DEBRIS 1 /** Collides with nothing but world and static stuff. */ +#define COLLISION_GROUP_DEBRIS_TRIGGER 2 /** Same as debris, but hits triggers. */ +#define COLLISION_GROUP_INTERACTIVE_DEBRIS 3 /** Collides with everything except other interactive debris or debris. */ +#define COLLISION_GROUP_INTERACTIVE 4 /** Collides with everything except interactive debris or debris. */ +#define COLLISION_GROUP_PLAYER 5 /** This is the default behavior expected for most prop_physics. */ +#define COLLISION_GROUP_BREAKABLE_GLASS 6 /** Special group for glass debris. */ +#define COLLISION_GROUP_VEHICLE 7 /** Collision group for driveable vehicles. */ +#define COLLISION_GROUP_PLAYER_MOVEMENT 8 /** For HL2, same as Collision_Group_Player. */ +#define COLLISION_GROUP_NPC 9 /** Generic NPC group. */ +#define COLLISION_GROUP_IN_VEHICLE 10 /** For any entity inside a vehicle. */ +#define COLLISION_GROUP_WEAPON 11 /** For any weapons that need collision detection. */ +#define COLLISION_GROUP_VEHICLE_CLIP 12 /** Vehicle clip brush to restrict vehicle movement. */ +#define COLLISION_GROUP_PROJECTILE 13 /** Projectiles. */ +#define COLLISION_GROUP_DOOR_BLOCKER 14 /** Blocks entities not permitted to get near moving doors. */ +#define COLLISION_GROUP_PASSABLE_DOOR 15 /** Doors that the player shouldn't collide with. */ +#define COLLISION_GROUP_DISSOLVING 16 /** Things that are dissolving are in this group. */ +#define COLLISION_GROUP_PUSHAWAY 17 /** Nonsolid on client and server, pushaway in player code. */ #define COLLISION_GROUP_NPC_ACTOR 18 /** Used so NPCs in scripts ignore the player. */ + +#define ANTISTICK_COLLISIONS_OFF COLLISION_GROUP_DEBRIS_TRIGGER +#define ANTISTICK_COLLISIONS_ON COLLISION_GROUP_PLAYER /** * @endsection */ @@ -306,26 +306,18 @@ public ZRTools_Action:AntiStickStartTouch(client, entity) // Get current collision groups of client and entity. new clientcollisiongroup = AntiStickGetCollisionGroup(client); - new entitycollisiongroup = AntiStickGetCollisionGroup(entity); // Note: If zombies get stuck on infection or stuck in a teleport, they'll // get the COLLISION_GROUP_PUSHAWAY collision group, so check this // one too. - // Check if the client have collisions enabled, or have the pushaway collision group. - if (clientcollisiongroup == ANTISTICK_COLLISIONS_ON || clientcollisiongroup == COLLISION_GROUP_PUSHAWAY) + // If the client is in any other collision group than "off", than we must set them to off, to unstick. + if (clientcollisiongroup != ANTISTICK_COLLISIONS_OFF) { // Disable collisions to unstick, and start timers to re-solidify. AntiStickSetCollisionGroup(client, ANTISTICK_COLLISIONS_OFF); CreateTimer(0.0, AntiStickSolidifyTimer, client, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT); } - - // Check if the entity have collisions enabled, or have the pushaway collision group. - if (entitycollisiongroup == ANTISTICK_COLLISIONS_ON || entitycollisiongroup == COLLISION_GROUP_PUSHAWAY) - { - AntiStickSetCollisionGroup(entity, ANTISTICK_COLLISIONS_OFF); - CreateTimer(0.0, AntiStickSolidifyTimer, entity, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT); - } } /** diff --git a/src/zr/damage.inc b/src/zr/damage.inc index e69a5df..008a218 100644 --- a/src/zr/damage.inc +++ b/src/zr/damage.inc @@ -66,12 +66,15 @@ DamageOnCommandsHook() new String:arrayCmds[DAMAGE_SUICIDE_MAX_CMDS][DAMAGE_SUICIDE_MAX_LENGTH]; // Explode string into array indexes. - new cmdcount = ExplodeString(suicidecmds, ", ", arrayCmds, DAMAGE_SUICIDE_MAX_CMDS, DAMAGE_SUICIDE_MAX_LENGTH); + new cmdcount = ExplodeString(suicidecmds, ",", arrayCmds, sizeof(arrayCmds), sizeof(arrayCmds[])); // x = Array index. // arrayCmds[x] = suicide command. for (new x = 0; x <= cmdcount - 1; x++) { + // Trim whitespace. + TrimString(arrayCmds[x]); + // Prepare intercept for this command. RegConsoleCmd(arrayCmds[x], DamageSuicideIntercept); } diff --git a/src/zr/models.inc b/src/zr/models.inc index 44389f4..1386157 100644 --- a/src/zr/models.inc +++ b/src/zr/models.inc @@ -96,7 +96,7 @@ ModelsLoad() ModelReturnPath(x, modelbase, sizeof(modelbase)); // Explode path into pieces. (separated by "/") - new strings = ExplodeString(modelbase, "/", baseexploded, MODELS_PATH_MAX_DEPTH, MODELS_PATH_DIR_MAX_LENGTH); + new strings = ExplodeString(modelbase, "/", baseexploded, sizeof(baseexploded), sizeof(baseexploded[])); // Get model file name. strcopy(modelname, sizeof(modelname), baseexploded[strings - 1]); diff --git a/src/zr/playerclasses/clientoverlays.inc b/src/zr/playerclasses/clientoverlays.inc index b34baec..687eaed 100644 --- a/src/zr/playerclasses/clientoverlays.inc +++ b/src/zr/playerclasses/clientoverlays.inc @@ -57,12 +57,15 @@ ClassOverlayOnCommandsHook() new String:arrayCmds[CLASSOVERLAY_TOGGLE_MAX_CMDS][CLASSOVERLAY_TOGGLE_MAX_LENGTH]; // Explode string into array indexes. - new cmdcount = ExplodeString(togglecmds, ", ", arrayCmds, CLASSOVERLAY_TOGGLE_MAX_CMDS, CLASSOVERLAY_TOGGLE_MAX_LENGTH); + new cmdcount = ExplodeString(togglecmds, ",", arrayCmds, sizeof(arrayCmds), sizeof(arrayCmds[])); // x = Array index. // arrayCmds[x] = suicide command. for (new x = 0; x <= cmdcount - 1; x++) { + // Trim whitespace. + TrimString(arrayCmds[x]); + // Prepare intercept for this command. RegConsoleCmd(arrayCmds[x], ClassOverlayEnableCommand); } diff --git a/src/zr/weapons/restrict.inc b/src/zr/weapons/restrict.inc index d4196f8..60146e1 100644 --- a/src/zr/weapons/restrict.inc +++ b/src/zr/weapons/restrict.inc @@ -98,7 +98,7 @@ RestrictLoad() { WeaponsGetType(x, weapontype, sizeof(weapontype)); - ExplodeString(weapontype, ",", weapontypes, WEAPONS_RESTRICT_MAX_TYPES, WEAPONS_MAX_LENGTH); + ExplodeString(weapontype, ",", weapontypes, sizeof(weapontypes), sizeof(weapontypes[])); for (new y = 0; y < WEAPONS_RESTRICT_MAX_TYPES; y++) { // Cut off whitespace. @@ -498,7 +498,7 @@ stock RestrictGetTypeWeapons(index, &Handle:arrayTypeWeapons) { WeaponsGetType(x, weapontype, sizeof(weapontype)); - ExplodeString(weapontype, ",", weapontypes, WEAPONS_RESTRICT_MAX_TYPES, WEAPONS_MAX_LENGTH); + ExplodeString(weapontype, ",", weapontypes, sizeof(weapontypes), sizeof(weapontypes[])); for (new y = 0; y < WEAPONS_RESTRICT_MAX_TYPES; y++) { // Cut off whitespace. From 37fe9fae8bc6539fafdd713872989a04bcc36f59 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Thu, 23 Jul 2009 15:40:39 -0700 Subject: [PATCH 2/2] Added a shortcut to zmarket loadout in ZCookies, added joinclass to suicide intercept as default. --- .../translations/zombiereloaded.phrases.txt | 5 ++++ .../zombiereloaded/zombiereloaded.cfg | 4 ++-- src/zr/cvars.inc | 8 +++---- src/zr/zcookies.inc | 24 ++++++++++++++++--- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt index 0313d53..6b34eca 100644 --- a/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt +++ b/cstrike/addons/sourcemod/translations/zombiereloaded.phrases.txt @@ -984,6 +984,11 @@ "en" "Human/Zombie Class Overlay: {1}" } + "ZCookies zmarket loadout" + { + "en" "ZMarket Loadout" + } + // =========================== // ZSpawn (module) // =========================== diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index eb9bbe9..aed94fb 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -336,8 +336,8 @@ zr_damage_suicide_mzombie "1" zr_damage_suicide_human "0" // List of client commands to intercept as suicide attempts. [Delimiter: ", "] -// Default: "kill, spectate, jointeam" -zr_damage_suicide_cmds "kill, spectate, jointeam" +// Default: "kill, spectate, jointeam, joinclass" +zr_damage_suicide_cmds "kill, spectate, jointeam, joinclass" // ---------------------------------------------------------------------------- diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 0b213ab..1191623 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -310,10 +310,10 @@ CvarsCreate() g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST] = CreateConVar("zr_damage_block_blast", "1", "Block blast damage inflicted on self or teammates."); // Suicide Intercept - g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE] = CreateConVar("zr_damage_suicide_zombie", "0", "Intercept suicide commands attempted by zombies."); - g_hCvarsList[CVAR_DAMAGE_SUICIDE_MZOMBIE] = CreateConVar("zr_damage_suicide_mzombie", "1", "Intercept suicide commands attempted by mother zombies."); - g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "0", "Intercept suicide commands attempted by humans."); - g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam", "List of client commands to intercept as suicide attempts. [Delimiter: \", \"]"); + g_hCvarsList[CVAR_DAMAGE_SUICIDE_ZOMBIE] = CreateConVar("zr_damage_suicide_zombie", "0", "Intercept suicide commands attempted by zombies."); + g_hCvarsList[CVAR_DAMAGE_SUICIDE_MZOMBIE] = CreateConVar("zr_damage_suicide_mzombie", "1", "Intercept suicide commands attempted by mother zombies."); + g_hCvarsList[CVAR_DAMAGE_SUICIDE_HUMAN] = CreateConVar("zr_damage_suicide_human", "0", "Intercept suicide commands attempted by humans."); + g_hCvarsList[CVAR_DAMAGE_SUICIDE_CMDS] = CreateConVar("zr_damage_suicide_cmds", "kill, spectate, jointeam, joinclass", "List of client commands to intercept as suicide attempts. [Delimiter: \", \"]"); // =========================== diff --git a/src/zr/zcookies.inc b/src/zr/zcookies.inc index 930ad28..78d3e55 100644 --- a/src/zr/zcookies.inc +++ b/src/zr/zcookies.inc @@ -62,22 +62,26 @@ ZCookiesMenuMain(client) decl String:autorebuy[64]; decl String:zhp[64]; decl String:overlay[64]; + decl String:zmarket[64]; // Translate each line into client's language. Format(autorebuy, sizeof(autorebuy), "%t", "ZCookies menu main auto-rebuy", autorebuyenabled); Format(zhp, sizeof(zhp), "%t", "ZCookies menu main zhp", zhpenabled); Format(overlay, sizeof(overlay), "%t", "ZCookies menu main overlay", overlayenabled); + Format(zmarket, sizeof(zmarket), "%t", "ZCookies zmarket loadout"); // Get conditional values for each option. new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]); // For auto-rebuy. new bool:zmarketrebuyauto = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_AUTO]); // For auto-rebuy. - new bool:zhpcvar = GetConVarBool(g_hCvarsList[CVAR_ZHP]); // For ZHP. + new bool:zhpcvar = GetConVarBool(g_hCvarsList[CVAR_ZHP]); // For ZHP. new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); // For class overlay. + new bool:zmarketenabled = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET]); // For ZMarket loadout. // Add items to menu. AddMenuItem(zcookies_menu_main, "autorebuy", autorebuy, MenuGetItemDraw(weapons && zmarketrebuyauto)); AddMenuItem(zcookies_menu_main, "zhp", zhp, MenuGetItemDraw(zhpcvar)); AddMenuItem(zcookies_menu_main, "overlay", overlay, MenuGetItemDraw(overlaytoggle)); + AddMenuItem(zcookies_menu_main, "zmarket", zmarket, MenuGetItemDraw(zmarketenabled)); // Create a "Back" button to the main menu. SetMenuExitBackButton(zcookies_menu_main, true); @@ -100,6 +104,8 @@ public ZCookiesMenuMainHandle(Handle:menu, MenuAction:action, client, slot) // Client selected an option. if (action == MenuAction_Select) { + new bool:resend = true; + switch(slot) { // Toggled auto-rebuy @@ -125,10 +131,22 @@ public ZCookiesMenuMainHandle(Handle:menu, MenuAction:action, client, slot) CookiesSetClientCookieBool(client, g_hOverlayEnabledCookie, overlayenabled); } } + // Opened ZMarket loadout. + case 3: + { + // Show a client their current loadout. + ZMarketMenuLoadout(client); + + // Don't resend ZCookies. + resend = false; + } } - // Re-send menu. - ZCookiesMenuMain(client); + if (resend) + { + // Re-send menu. + ZCookiesMenuMain(client); + } } // Client closed the menu. if (action == MenuAction_Cancel)