diff --git a/addons/sourcemod/scripting/FunModes.sp b/addons/sourcemod/scripting/FunModes.sp index 632d0fd..67abb4a 100644 --- a/addons/sourcemod/scripting/FunModes.sp +++ b/addons/sourcemod/scripting/FunModes.sp @@ -26,7 +26,7 @@ public Plugin myinfo = name = "FunModes", author = "Dolly", description = "bunch of fun modes for ze mode", - version = "2.0.0", + version = "2.1.0", url = "https://nide.gg" } @@ -57,6 +57,10 @@ public void OnPluginStart() RegAdminCmd(commands[i], Cmd_FunModes, ADMFLAG_CONVARS, "Show all available funmodes"); } + g_iNetPropAmmoIndex = FindSendPropInfo("CBasePlayer", "m_iAmmo"); + if (g_iNetPropAmmoIndex == -1) + SetFailState("[FunModes] Could not find offset `CBasePlayer::m_iAmmo`"); + GameData gd = new GameData("sdkhooks.games/engine.ep2v"); if (gd == null) LogError("[FunModes] Could not find \"sdkhooks.games/engine.ep2v.txt\" file."); @@ -108,13 +112,6 @@ public void OnMapStart() public void OnMapEnd() { - for (int i = 1; i <= MaxClients; i++) - { - g_bSDKHook_OnTakeDamagePost[i] = false; - g_bSDKHook_WeaponEquip[i] = false; - g_bSDKHook_OnTakeDamage[i] = false; - } - DECLARE_FM_FORWARD(OnMapEnd); } @@ -126,8 +123,8 @@ public void OnClientPutInServer(int client) public void OnClientDisconnect(int client) { g_bSDKHook_OnTakeDamagePost[client] = false; - g_bSDKHook_WeaponEquip[client] = false; g_bSDKHook_OnTakeDamage[client] = false; + g_bSDKHook_WeaponEquip[client] = false; DECLARE_FM_FORWARD_PARAM(OnClientDisconnect, client); } @@ -148,6 +145,7 @@ void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast) { g_bRoundEnd = true; + g_bMotherZombie = false; DECLARE_FM_FORWARD(Event_RoundEnd); } @@ -173,20 +171,20 @@ void OnTakeDamagePost(int victim, int attacker, int inflictor, float damage, int DECLARE_FM_FORWARD_PARAM3(OnTakeDamagePost, victim, attacker, damage); } -Action OnWeaponEquip(int client, int weapon) +Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) { Action result = Plugin_Continue; - DECLARE_FM_FORWARD_PARAM3(OnWeaponEquip, client, weapon, result); + DECLARE_FM_FORWARD_PARAM4(OnTakeDamage, victim, attacker, damage, result); return result; } -Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) +Action OnWeaponEquip(int client, int weapon) { Action result = Plugin_Continue; - DECLARE_FM_FORWARD_PARAM4(OnTakeDamage, victim, attacker, damage, result); + DECLARE_FM_FORWARD_PARAM3(OnWeaponEquip, client, weapon, result); return result; } @@ -201,6 +199,20 @@ void FunModes_HookEvent(bool &modeBool, const char[] name, EventHook callback) } } +void FunModes_RestartRound() +{ + // slay all players before terminating the round + for (int i = 1; i <= MaxClients; i++) + { + if (!IsClientInGame(i) || !IsPlayerAlive(i)) + continue; + + ForcePlayerSuicide(i); + } + + CS_TerminateRound(3.0, CSRoundEnd_Draw); +} + public void OnAllPluginsLoaded() { g_bPlugin_DynamicChannels = LibraryExists("DynamicChannels"); @@ -264,16 +276,6 @@ stock void BeaconPlayer(int client, int mode, float distance = 0.0, int color[4] } } -void GiveGrenadesToClient(int client, WeaponAmmoGrenadeType type, int amount) -{ - int ammo = FindSendPropInfo("CBasePlayer", "m_iAmmo"); - if (ammo != -1) - { - int grenadesCount = GetEntData(client, ammo + (view_as(type) * 4)); - SetEntData(client, ammo + (view_as(type) * 4), grenadesCount + amount, _, true); - } -} - Action Cmd_FunModes(int client, int args) { if (!client) diff --git a/addons/sourcemod/scripting/Fun_Modes/BlindMode.sp b/addons/sourcemod/scripting/Fun_Modes/BlindMode.sp index 10f27c5..f52d814 100644 --- a/addons/sourcemod/scripting/Fun_Modes/BlindMode.sp +++ b/addons/sourcemod/scripting/Fun_Modes/BlindMode.sp @@ -214,7 +214,7 @@ void ApplyBlind(int client) int color[4]; color[3] = 255; - int flags = FFADE_OUT; + int flags = FFADE_IN; int clients[1]; clients[0] = client; @@ -273,17 +273,18 @@ Action Timer_BlindMode(Handle timer) float percentage = THIS_MODE_INFO.cvarInfo[BLINDMODE_CONVAR_PERCENTAGE].cvar.FloatValue; int neededZombies = RoundToCeil(zombiesCount * (percentage / 100)); - int enough = 0; + int enough = 1; do { int zombie = zombies[GetRandomInt(0, zombiesCount - 1)]; if (g_bHasFlash[zombie]) zombie = zombies[GetRandomInt(0, zombiesCount - 1)]; - + g_bHasFlash[zombie] = true; + int entity = GivePlayerItem(zombie, "weapon_flashbang"); EquipPlayerWeapon(zombie, entity); - SetEntData(zombie, FindSendPropInfo("CBasePlayer", "m_iAmmo") + (view_as(GrenadeType_Flashbang) * 4), 1, _, true); + CPrintToChat(zombie, "%s You have been granted a FlashBang!!!\nBlind some humans.", THIS_MODE_INFO.tag); enough++; } while (enough <= neededZombies); @@ -315,6 +316,7 @@ Action Timer_ApplyBlind(Handle timer, int ref) GetEntPropVector(entity, Prop_Send, "m_vecOrigin", origin); float maxDistance = THIS_MODE_INFO.cvarInfo[BLINDMODE_CONVAR_MAX_DISTANCE].cvar.FloatValue; + maxDistance *= maxDistance; for (int i = 1; i <= MaxClients; i++) { @@ -324,7 +326,7 @@ Action Timer_ApplyBlind(Handle timer, int ref) float plOrigin[3]; GetClientAbsOrigin(i, plOrigin); - float distance = GetVectorDistance(origin, plOrigin); + float distance = GetVectorDistance(origin, plOrigin, true); if (distance > maxDistance) continue; diff --git a/addons/sourcemod/scripting/Fun_Modes/ChaosWeapons.sp b/addons/sourcemod/scripting/Fun_Modes/ChaosWeapons.sp index 3b53ea5..3e6c888 100644 --- a/addons/sourcemod/scripting/Fun_Modes/ChaosWeapons.sp +++ b/addons/sourcemod/scripting/Fun_Modes/ChaosWeapons.sp @@ -25,16 +25,18 @@ ModeInfo g_ChaosWeaponsInfo; #define CHAOSWEAPONS_CONVAR_TIMER_INTERVAL 0 #define CHAOSWEAPONS_CONVAR_KNOCKBACK 1 -#define CHAOSWEAPONS_CONVAR_TOGGLE 2 +#define CHAOSWEAPONS_CONVAR_COUNTDOWN 2 +#define CHAOSWEAPONS_CONVAR_TOGGLE 3 Handle g_hChaosWeaponsTimer; +char g_sChaosWeaponCurrent[32]; + char g_ChaosWeaponsList[][] = { - "ELITE", "DEAGLE", /* Pistols */ - "MAC10", "TMP", "MP5NAVY", "UMP45", "P90", /* SMGs */ - "GALIL", "FAMAS", "AK47", "M4A1", "AUG", "SG552", /* Rifles */ - "M3", "XM1014" /* Shotguns */ + "mac10", "tmp", "mp5navy", "ump45", "p90", /* SMGs */ + "galil", "famas", "ak47", "m4a1", "aug", "sg552", /* Rifles */ + "m3", "xm1014" /* Shotguns */ }; float g_fOriginalWeaponsKB[sizeof(g_ChaosWeaponsList)]; @@ -62,6 +64,12 @@ stock void OnPluginStart_ChaosWeapons() ("0.1,0.2,0.5,1.0"), "float" ); + DECLARE_FM_CVAR( + THIS_MODE_INFO.cvarInfo, CHAOSWEAPONS_CONVAR_COUNTDOWN, + "sm_chaosweapons_countdown", "10", "How many seconds for the countdown", + ("5,10,15,20"), "int" + ); + DECLARE_FM_CVAR( THIS_MODE_INFO.cvarInfo, CHAOSWEAPONS_CONVAR_TOGGLE, "sm_chaosweapons_enable", "1", "Enable/Disable ChaosWeapons Mode (This differs from turning it on/off)", @@ -203,7 +211,43 @@ Action Timer_ChaosWeapons(Handle timer) return Plugin_Handled; } - PickRandomWeapon(); + CreateTimer(1.0, Timer_ChaosWeaponsRepeat, _, TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT); + return Plugin_Continue; +} + +Action Timer_ChaosWeaponsRepeat(Handle timer) +{ + static int counter; + if (!THIS_MODE_INFO.isOn || g_bRoundEnd || !g_bMotherZombie) + { + counter = 0; + return Plugin_Stop; + } + + int max = THIS_MODE_INFO.cvarInfo[CHAOSWEAPONS_CONVAR_COUNTDOWN].cvar.IntValue; + + if (++counter >= max) + { + counter = 0; + PickRandomWeapon(); + return Plugin_Stop; + } + + char msg[128]; + FormatEx + ( + msg, sizeof(msg), "[ChaosWeapons] The weapon that pushes zombies will change in %d seconds!", + max - counter + ); + + for (int i = 1; i <= MaxClients; i++) + { + if (!IsClientInGame(i)) + continue; + + SendHudText(i, msg, _, 1); + } + return Plugin_Continue; } @@ -211,10 +255,11 @@ void PickRandomWeapon() { int index = GetRandomInt(0, sizeof(g_ChaosWeaponsList) - 1); + FormatEx(g_sChaosWeaponCurrent, sizeof(g_sChaosWeaponCurrent), "weapon_%s", g_ChaosWeaponsList[index]); SetAllWeaponsKnockback(THIS_MODE_INFO.cvarInfo[CHAOSWEAPONS_CONVAR_KNOCKBACK].cvar.FloatValue, index); char msg[255]; - FormatEx(msg, sizeof(msg), "Only the [%s] will push the zombies for the next %d seconds!", g_ChaosWeaponsList[index], THIS_MODE_INFO.cvarInfo[CHAOSWEAPONS_CONVAR_TIMER_INTERVAL].cvar.IntValue); + FormatEx(msg, sizeof(msg), "Only the [%s] will push the zombies for the next %d seconds\nPress F to buy it!", StrToUpper(g_ChaosWeaponsList[index]), THIS_MODE_INFO.cvarInfo[CHAOSWEAPONS_CONVAR_TIMER_INTERVAL].cvar.IntValue); for (int i = 1; i <= MaxClients; i++) { @@ -226,31 +271,90 @@ void PickRandomWeapon() } } +stock char[] StrToUpper(const char[] buffer) +{ + int len = strlen(buffer); + char myChar[32]; + + for (int i = 0; i < len; i++) + { + char c = buffer[i]; + if (c >= 'a' && c <= 'z') + c &= ~0x20; + + myChar[i] = c; + } + + return myChar; +} + void SetAllWeaponsKnockback(float kb = 0.0, int index = -1, bool firstTime = false, bool turnOff = false) { for (int i = 0; i < sizeof(g_ChaosWeaponsList); i++) { - int len = strlen(g_ChaosWeaponsList[i]); - char[] lower = new char[len + 1]; + if (turnOff || (index >= 0 && i == index)) + { + ZR_SetWeaponKnockback(g_ChaosWeaponsList[i], g_fOriginalWeaponsKB[i]); + continue; + } + + if (firstTime) + g_fOriginalWeaponsKB[i] = ZR_GetWeaponKnockback(g_ChaosWeaponsList[i]); + + ZR_SetWeaponKnockback(g_ChaosWeaponsList[i], kb); + } +} + +stock void OnPlayerRunCmdPost_ChaosWeapons(int client, int buttons, int impulse) +{ + #pragma unused buttons + + if (!THIS_MODE_INFO.isOn) + return; + + if (!IsPlayerAlive(client) || !ZR_IsClientHuman(client)) + return; + + static float playersTime[MAXPLAYERS + 1]; + + float currentTime = GetGameTime(); + if (currentTime <= playersTime[client]) + return; + + // https://github.com/ValveSoftware/source-sdk-2013/blob/7191ecc418e28974de8be3a863eebb16b974a7ef/src/game/server/player.cpp#L6073 + if (impulse == 100) + { + playersTime[client] = currentTime + 2.0; + + char curWeapon[sizeof(g_sChaosWeaponCurrent)]; + strcopy(curWeapon, sizeof(curWeapon), g_sChaosWeaponCurrent); - for (int j = 0; j < len; j++) + int weapon = 0; + + ReplaceString(curWeapon, sizeof(curWeapon), "weapon_", ""); + int price = ZR_GetWeaponZMarketPrice(curWeapon); + + int cash = GetEntProp(client, Prop_Send, "m_iAccount"); + if (cash < price) { - char c = g_ChaosWeaponsList[i][j]; - if (c >= 'A' && c <= 'Z') - c |= 0x20; - - lower[j] = c; + CPrintToChat(client, "%s Insufficent fund", THIS_MODE_INFO.tag); + return; } - if (turnOff || (index >= 0 && i == index)) + weapon = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY); + if (IsValidEntity(weapon)) { - ZR_SetWeaponKnockback(lower, g_fOriginalWeaponsKB[i]); - continue; + SDKHooks_DropWeapon(client, weapon); + RemoveEntity(weapon); } - if (firstTime) - g_fOriginalWeaponsKB[i] = ZR_GetWeaponKnockback(lower); + weapon = GivePlayerItem(client, g_sChaosWeaponCurrent); + if (!IsValidEntity(weapon)) + return; + + if (g_hSwitchSDKCall != null) + SDKCall(g_hSwitchSDKCall, client, weapon, 0); - ZR_SetWeaponKnockback(lower, kb); + SetEntProp(client, Prop_Send, "m_iAccount", cash - price); } } \ No newline at end of file diff --git a/addons/sourcemod/scripting/Fun_Modes/Core.sp b/addons/sourcemod/scripting/Fun_Modes/Core.sp index 004a8c9..62d267f 100644 --- a/addons/sourcemod/scripting/Fun_Modes/Core.sp +++ b/addons/sourcemod/scripting/Fun_Modes/Core.sp @@ -45,6 +45,7 @@ int g_iCounter = 0; /* GLOBAL CONVARS */ ConVar g_cvHUDChannel; int g_iPreviousModeIndex[MAXPLAYERS+1]; +int g_iNetPropAmmoIndex = -1; /* SDKCall Handles */ Handle g_hSwitchSDKCall; @@ -105,6 +106,13 @@ enum WeaponAmmoGrenadeType GrenadeType_Smokegrenade = 13, /** CSS - Smokegrenade slot. */ }; +#define HEGRENADE 11 +#define FLASHBANG 12 +#define SMOKEGRENADE 13 + +#define GET_GRENADES_COUNT(%1,%2) GetEntData(%1, g_iNetPropAmmoIndex + (%2 * 4)) +#define SET_GRENADES_COUNT(%1,%2,%3) SetEntData(%1, g_iNetPropAmmoIndex + (%2 * 4), %3, _, true) + /* - New FunModes Update * The plugin will now use macros to define the main functions and forwards @@ -135,7 +143,6 @@ enum WeaponAmmoGrenadeType CALL_MODE_FUNC(%1, RealityShift); \ CALL_MODE_FUNC(%1, PullGame) -#define CALL_MODE_FUNC_PARAM(%1,%2,%3) %1_%2(%3) #define DECLARE_FM_FORWARD_PARAM(%1,%2) \ CALL_MODE_FUNC_PARAM(%1, HealBeacon, %2); \ CALL_MODE_FUNC_PARAM(%1, VIPMode, %2); \ @@ -149,6 +156,7 @@ enum WeaponAmmoGrenadeType CALL_MODE_FUNC_PARAM(%1, CrazyShop, %2); \ CALL_MODE_FUNC_PARAM(%1, RealityShift, %2); \ CALL_MODE_FUNC_PARAM(%1, PullGame, %2) +#define CALL_MODE_FUNC_PARAM(%1,%2,%3) %1_%2(%3) /* these commented macros are not used for now @@ -180,7 +188,8 @@ these commented macros are not used for now #define DECLARE_ONPLAYERRUNCMD_POST(%1,%2,%3,%4) \ CALL_MODE_FUNC_PARAM3(%1, DoubleJump, %2, %3, %4); \ CALL_MODE_FUNC_PARAM3(%1, CrazyShop, %2, %3, %4); \ - CALL_MODE_FUNC_PARAM3(%1, PullGame, %2, %3, %4) + CALL_MODE_FUNC_PARAM3(%1, PullGame, %2, %3, %4); \ + CALL_MODE_FUNC_PARAM3(%1, ChaosWeapons, %2, %3, %4) /* %0: ConVarInfo[], %1: index, %2: name, %3: default value, %4: description %5: cvar values, %6: cvar value type @@ -195,6 +204,10 @@ these commented macros are not used for now %1.%2 = %3; \ g_ModesInfo[%4] = %1 +/* +#define FUNMODE_CONVAR(%1,%2) %1.cvarInfo[%2].cvar +*/ + #define THIS_MODE_INFO /* Add the mode's include file here */ diff --git a/addons/sourcemod/scripting/Fun_Modes/CrazyShop.sp b/addons/sourcemod/scripting/Fun_Modes/CrazyShop.sp index f85c471..738e881 100644 --- a/addons/sourcemod/scripting/Fun_Modes/CrazyShop.sp +++ b/addons/sourcemod/scripting/Fun_Modes/CrazyShop.sp @@ -421,7 +421,7 @@ stock void OnTakeDamage_CrazyShop(int victim, int &attacker, float &damage, Acti // victim is for sure gonna be a real player, so no need to check // check if victim is a human and has laser protect - if (PLAYER_TEMP_VAR(victim, laserProtect) && !isVictimAlive && !isVictimZombie) + if (PLAYER_TEMP_VAR(victim, laserProtect) && isVictimAlive && !isVictimZombie) { if (!IsValidEntity(attacker)) return; @@ -463,7 +463,7 @@ stock void OnTakeDamage_CrazyShop(int victim, int &attacker, float &damage, Acti if (PLAYER_TEMP_VAR(victim, kbProtect)) { - damage -= damage * 0.9; + damage -= damage * g_CrazyShopItems[8].amount; result = Plugin_Changed; return; } @@ -531,7 +531,7 @@ stock void OnPlayerRunCmdPost_CrazyShop(int client, int buttons, int impulse) // https://github.com/ValveSoftware/source-sdk-2013/blob/7191ecc418e28974de8be3a863eebb16b974a7ef/src/game/server/player.cpp#L6073 if (impulse == 100) { - PLAYER_TEMP_VAR(client, lastUse) = currentTime + 2; + PLAYER_TEMP_VAR(client, lastUse) = currentTime + 2.0; CrazyShop_OpenAvailableItems(client); } } @@ -806,7 +806,7 @@ public Action Cmd_CrazyShopToggle(int client, int args) } // Restart the round - CS_TerminateRound(2.0, CSRoundEnd_Draw); + FunModes_RestartRound(); } else delete THIS_MODE_DB; @@ -1462,27 +1462,9 @@ int Menu_AvailableItems(Menu menu, MenuAction action, int param1, int param2) void CrazyShop_Activate(int client, int itemNum) { - if (!IsPlayerAlive(client)) - { - CPrintToChat(client, "%s You are not alive to activate this item.", THIS_MODE_INFO.tag); - return; - } - CrazyShop_Item item; item = g_CrazyShopItems[itemNum]; - - if (item.team == 1 && !ZR_IsClientHuman(client)) - { - CPrintToChat(client, "%s This is a human item, you cannot use it right now!", THIS_MODE_INFO.tag); - return; - } - - if (item.team == 0 && !ZR_IsClientZombie(client)) - { - CPrintToChat(client, "%s This is a zombie item, you cannot use it right now!", THIS_MODE_INFO.tag); - return; - } - + if (PLAYER_ITEM_ACTIVE(client, itemNum)) { CPrintToChat(client, "%s You cannot activate the same item again unless the old ones' effect ended", THIS_MODE_INFO.tag); @@ -1597,7 +1579,7 @@ void CrazyShop_Activate(int client, int itemNum) // Buy a smokegrenade case 5: { - GiveGrenadesToClient(client, GrenadeType_Smokegrenade, 1); + SET_GRENADES_COUNT(client, SMOKEGRENADE, GET_GRENADES_COUNT(client, SMOKEGRENADE) + 1); int wp = GivePlayerItem(client, "weapon_smokegrenade"); EquipPlayerWeapon(client, wp); diff --git a/addons/sourcemod/scripting/Fun_Modes/DamageGame.sp b/addons/sourcemod/scripting/Fun_Modes/DamageGame.sp index 4451a15..433a38e 100644 --- a/addons/sourcemod/scripting/Fun_Modes/DamageGame.sp +++ b/addons/sourcemod/scripting/Fun_Modes/DamageGame.sp @@ -190,7 +190,7 @@ public Action Cmd_DamageGameToggle(int client, int args) OnClientPutInServer_DamageGame(i); } - CS_TerminateRound(3.0, CSRoundEnd_Draw); + FunModes_RestartRound(); } else { diff --git a/addons/sourcemod/scripting/Fun_Modes/DoubleJump.sp b/addons/sourcemod/scripting/Fun_Modes/DoubleJump.sp index 52b7f32..44e73f8 100644 --- a/addons/sourcemod/scripting/Fun_Modes/DoubleJump.sp +++ b/addons/sourcemod/scripting/Fun_Modes/DoubleJump.sp @@ -27,7 +27,8 @@ stock void OnPluginStart_DoubleJump() /* ADMIN COMMANDS */ RegAdminCmd("sm_fm_doublejump", Cmd_DoubleJumpToggle, ADMFLAG_CONVARS, "Enable/Disable Double Jump mode."); - + RegAdminCmd("sm_doublejump_settings", Cmd_DoubleJumpSettings, ADMFLAG_CONFIG, "Open DoubleJump Settings Menu"); + /* CONVARS */ DECLARE_FM_CVAR( THIS_MODE_INFO.cvarInfo, DOUBLEJUMP_CONVAR_BOOST, @@ -186,7 +187,7 @@ stock void ApplyNewJump(int client) } /* DoubleJump Settings */ -public void Cmd_DoubleJumpSettings(int client) +public Action Cmd_DoubleJumpSettings(int client, int args) { Menu menu = new Menu(Menu_DoubleJumpSettings); @@ -196,6 +197,7 @@ public void Cmd_DoubleJumpSettings(int client) menu.ExitBackButton = true; menu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; } int Menu_DoubleJumpSettings(Menu menu, MenuAction action, int param1, int param2) diff --git a/addons/sourcemod/scripting/Fun_Modes/Fog.sp b/addons/sourcemod/scripting/Fun_Modes/Fog.sp index 665e9fd..42dd4cf 100644 --- a/addons/sourcemod/scripting/Fun_Modes/Fog.sp +++ b/addons/sourcemod/scripting/Fun_Modes/Fog.sp @@ -13,11 +13,13 @@ ModeInfo g_FogInfo; #undef THIS_MODE_INFO #define THIS_MODE_INFO g_FogInfo -#define FOGInput_Color 0 -#define FOGInput_Start 1 -#define FOGInput_End 2 +#define FOGInput_Color 0 +#define FOGInput_Start 1 +#define FOGInput_End 2 #define FOGInput_Toggle 3 +#define FOG_NAME "fog_mode_aaa34124n" + enum struct fogData { float fogStart; @@ -110,7 +112,7 @@ stock void Event_RoundStart_Fog() if (!IsClientInGame(i)) continue; - SetVariantString("fog_mode_aaa34124n"); + SetVariantString(FOG_NAME); AcceptEntityInput(i, "SetFogController"); } @@ -123,6 +125,9 @@ stock void Event_RoundStart_Fog() stock void Event_RoundEnd_Fog() {} stock void Event_PlayerSpawn_Fog(int client) { + if (!THIS_MODE_INFO.isOn) + return; + CreateTimer(1.0, PlayerSpawn_Timer, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE); } @@ -138,11 +143,14 @@ stock void Event_PlayerDeath_Fog(int client) Action PlayerSpawn_Timer(Handle timer, int userid) { + if (!THIS_MODE_INFO.isOn) + return Plugin_Stop; + int client = GetClientOfUserId(userid); - if (client < 1 || !THIS_MODE_INFO.isOn) + if (client < 1) return Plugin_Stop; - SetVariantString("fog_mode_aaa34124n"); + SetVariantString(FOG_NAME); AcceptEntityInput(client, "SetFogController"); return Plugin_Continue; } @@ -151,7 +159,7 @@ stock void CreateFogEntity() { /* CHECK FOR ANY FOG MAP HAS */ int entity = -1; - while((entity = FindEntityByClassname(entity, "env_fog_controller")) != -1) + while ((entity = FindEntityByClassname(entity, "env_fog_controller")) != -1) { if (entity == g_iFogEntity) continue; @@ -169,7 +177,7 @@ stock void CreateFogEntity() if (!IsValidEntity(g_iFogEntity)) return; - DispatchKeyValue(g_iFogEntity, "targetname", "fog_mode_aaa34124n"); + DispatchKeyValue(g_iFogEntity, "targetname", FOG_NAME); DispatchKeyValue(g_iFogEntity, "fogenable", "1"); DispatchKeyValue(g_iFogEntity, "fogblend", "1"); DispatchKeyValueFloat(g_iFogEntity, "fogstart", g_FogData.fogStart); @@ -186,7 +194,7 @@ stock void CreateFogEntity() if (!IsClientInGame(i)) continue; - SetVariantString("fog_mode_aaa34124n"); + SetVariantString(FOG_NAME); AcceptEntityInput(i, "SetFogController"); } } @@ -200,8 +208,8 @@ stock void AcceptFogInput(int mode) { case FOGInput_Color: { - char sColor[64]; - Format(sColor, sizeof(sColor), "%i %i %i %i", g_FogData.fogColor[0], g_FogData.fogColor[1], g_FogData.fogColor[2], g_FogData.fogColor[3]); + char sColor[20]; + FormatEx(sColor, sizeof(sColor), "%i %i %i %i", g_FogData.fogColor[0], g_FogData.fogColor[1], g_FogData.fogColor[2], g_FogData.fogColor[3]); SetVariantString(sColor); AcceptEntityInput(g_iFogEntity, "SetColor"); @@ -403,6 +411,7 @@ public Action Cmd_FogToggle(int client, int args) FunModes_HookEvent(g_bEvent_PlayerSpawn, "player_spawn", Event_PlayerSpawn); CReplyToCommand(client, "%s FOG Mode is now {olive}ON!", THIS_MODE_INFO.tag); CreateFogEntity(); + AcceptFogInput(FOGInput_Toggle); return Plugin_Handled; } } diff --git a/addons/sourcemod/scripting/Fun_Modes/GunGame.sp b/addons/sourcemod/scripting/Fun_Modes/GunGame.sp index 5a794b7..addd243 100644 --- a/addons/sourcemod/scripting/Fun_Modes/GunGame.sp +++ b/addons/sourcemod/scripting/Fun_Modes/GunGame.sp @@ -18,9 +18,7 @@ #pragma semicolon 1 #pragma newdecls required -#undef REQUIRE_PLUGIN -#tryinclude -#define REQUIRE_PLUGIN +#include #define _FM_GunGame @@ -29,16 +27,14 @@ ModeInfo g_GunGameInfo; #undef THIS_MODE_INFO #define THIS_MODE_INFO g_GunGameInfo -#define GUNGAME_CONVAR_PISTOLS_DAMAGE 0 -#define GUNGAME_CONVAR_SHOTGUNS_DAMAGE 1 -#define GUNGAME_CONVAR_SMGS_DAMAGE 2 -#define GUNGAME_CONVAR_RIFLES_DAMAGE 3 -#define GUNGAME_CONVAR_M249_DAMAGE 4 -#define GUNGAME_CONVAR_ENTWATCH 5 -#define GUNGAME_CONVAR_HEGRENADES_COUNT 6 -#define GUNGAME_CONVAR_REWARD_GRAVITY 7 -#define GUNGAME_CONVAR_REWARD_SPEED 8 -#define GUNGAME_CONVAR_TOGGLE 9 +#define GUNGAME_CONVAR_PISTOLS_DAMAGE 0 +#define GUNGAME_CONVAR_SHOTGUNS_DAMAGE 1 +#define GUNGAME_CONVAR_SMGS_DAMAGE 2 +#define GUNGAME_CONVAR_RIFLES_DAMAGE 3 +#define GUNGAME_CONVAR_M249_DAMAGE 4 +#define GUNGAME_CONVAR_SMOKEGRENADES_COUNT 5 +#define GUNGAME_CONVAR_REWARD_SPEED 6 +#define GUNGAME_CONVAR_TOGGLE 7 static const char g_GunGameWeaponsList[][][] = { @@ -52,8 +48,7 @@ static const char g_GunGameWeaponsList[][][] = enum GunGame_Reward { REWARD_SPEED = 0, - REWARD_GRAVITY, - REWARD_HEGRENADES, + REWARD_SMOKEGRENADES, REWARD_NONE }; @@ -66,7 +61,6 @@ enum struct GunGame_Data bool allowEquip; float originalSpeed; - float originalGravity; GunGame_Reward reward; Handle rewardTimer; @@ -124,23 +118,11 @@ stock void OnPluginStart_GunGame() ); DECLARE_FM_CVAR( - THIS_MODE_INFO.cvarInfo, GUNGAME_CONVAR_ENTWATCH, - "sm_gungame_allow_entwatch", "0", "Allow entwatch items to be picked up (1 = Enabled, 0 = Disabled)", - ("0,1"), "bool" - ); - - DECLARE_FM_CVAR( - THIS_MODE_INFO.cvarInfo, GUNGAME_CONVAR_HEGRENADES_COUNT, - "sm_gungame_hegrenades_reward", "3", "How many hegrenades to give to the player when completing a cycle", + THIS_MODE_INFO.cvarInfo, GUNGAME_CONVAR_SMOKEGRENADES_COUNT, + "sm_gungame_hegrenades_reward", "2", "How many smokegrenades to give to the player when completing a cycle", ("1,3,5,10,15"), "int" ); - DECLARE_FM_CVAR( - THIS_MODE_INFO.cvarInfo, GUNGAME_CONVAR_REWARD_GRAVITY, - "sm_gungame_gravity_reward", "100.0", "How many seconds can the player keep their low gravity hold", - ("20.0,30.0,40.0,60.0,80.0,100.0"), "float" - ); - DECLARE_FM_CVAR( THIS_MODE_INFO.cvarInfo, GUNGAME_CONVAR_REWARD_SPEED, "sm_gungame_speed_reward", "100.0", "How many seconds can the player keep their high speed hold", @@ -205,6 +187,25 @@ stock void OnClientDisconnect_GunGame(int client) stock void ZR_OnClientInfected_GunGame(int client) { #pragma unused client + if (!THIS_MODE_INFO.isOn) + return; + + if (!g_bMotherZombie) + { + for (int i = 1; i <= MaxClients; i++) + { + if (!IsClientInGame(i) || !IsPlayerAlive(i) || !ZR_IsClientHuman(i)) + continue; + + if (EntWatch_HasSpecialItem(i)) + continue; + + GunGame_ResetHuman(i); + } + + CPrintToChatAll("%s Your weapon will be upgraded when you reach the required damage for each weapon type!", THIS_MODE_INFO.tag); + CPrintToChatAll("%s Type {olive}!gungame {lightgreen}if you lost your weapons!", THIS_MODE_INFO.tag); + } } stock void Event_RoundStart_GunGame() {} @@ -216,7 +217,7 @@ stock void Event_RoundEnd_GunGame() stock void Event_PlayerSpawn_GunGame(int client) { - if (!THIS_MODE_INFO.isOn) + if (!THIS_MODE_INFO.isOn || !g_bMotherZombie) return; CreateTimer(2.0, Timer_GunGame_CheckPlayerSpawn, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE); @@ -228,13 +229,10 @@ Action Timer_GunGame_CheckPlayerSpawn(Handle timer, int userid) if (!client) return Plugin_Stop; - GunGame_GiveReward(client, REWARD_NONE); - g_GunGameData[client].ResetLevel(); - if (!IsPlayerAlive(client) || !ZR_IsClientHuman(client)) return Plugin_Stop; - GunGame_EquipWeapon(client, g_GunGameWeaponsList[0][GetRandomInt(0, 1)]); + GunGame_ResetHuman(client); return Plugin_Stop; } @@ -259,7 +257,7 @@ stock void OnTakeDamagePost_GunGame(int victim, int attacker, float damage) if (!(1<=attacker<=MaxClients) || !IsPlayerAlive(attacker) || !IsPlayerAlive(victim) || !ZR_IsClientZombie(victim) || !ZR_IsClientHuman(attacker)) return; - if (THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_ENTWATCH].cvar.BoolValue && EntWatch_HasSpecialItem(attacker)) + if (EntWatch_HasSpecialItem(attacker)) return; int neededDamage = THIS_MODE_INFO.cvarInfo[g_GunGameData[attacker].level[0]].cvar.IntValue; @@ -282,17 +280,20 @@ stock void OnWeaponEquip_GunGame(int client, int weapon, Action &result) if (!IsPlayerAlive(client) || ZR_IsClientZombie(client)) return; - if (THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_ENTWATCH].cvar.BoolValue) - { - #if !defined _EntWatch_include - THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_ENTWATCH].cvar.BoolValue = false; + char className[32]; + GetEntityClassname(weapon, className, sizeof(className)); + + // kevlar, hegrenades and smokegrenades: + if (StrContains(className, "item_", false) != -1 || StrContains(className, "grenade", false) != -1) return; - #else - if (EntWatch_IsSpecialItem(weapon)) - return; - #endif - } + // flashbang + if (className[7] == 'f' && className[8] == 'l') + return; + + if (EntWatch_IsSpecialItem(weapon)) + return; + if (!g_GunGameData[client].allowEquip) { result = Plugin_Handled; @@ -305,17 +306,9 @@ public Action CS_OnBuyCommand(int client, const char[] weapon) if (!THIS_MODE_INFO.isOn) return Plugin_Continue; - if (THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_ENTWATCH].cvar.BoolValue) - { - #if !defined _EntWatch_include - THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_ENTWATCH].cvar.BoolValue = false; + if (EntWatch_HasSpecialItem(client)) return Plugin_Continue; - #else - if (!EntWatch_HasSpecialItem(client)) - return Plugin_Continue; - #endif - } - + if (!g_GunGameData[client].allowEquip) { CPrintToChat(client, "%s You cannot buy/equip weapons during GunGame Escape Mode", THIS_MODE_INFO.tag); @@ -325,6 +318,15 @@ public Action CS_OnBuyCommand(int client, const char[] weapon) return Plugin_Continue; } +stock void GunGame_ResetHuman(int client) +{ + GunGame_GiveReward(client, REWARD_NONE); + g_GunGameData[client].ResetLevel(); + g_GunGameData[client].completedCycle = false; + + GunGame_EquipWeapon(client, g_GunGameWeaponsList[0][GetRandomInt(0, 1)]); +} + public Action Cmd_GunGameToggle(int client, int args) { if (!THIS_MODE_INFO.cvarInfo[THIS_MODE_INFO.enableIndex].cvar.BoolValue) @@ -353,13 +355,12 @@ public Action Cmd_GunGameToggle(int client, int args) continue; OnClientPutInServer_GunGame(i); - if (view_as(g_GunGameData[i].reward) < view_as(REWARD_HEGRENADES)) + if (view_as(g_GunGameData[i].reward) < view_as(REWARD_SMOKEGRENADES)) GunGame_GiveReward(i, REWARD_NONE); } - CPrintToChatAll("%s Your weapon will be upgraded when you reach the required damage for each weapon type!", THIS_MODE_INFO.tag); - CS_TerminateRound(3.0, CSRoundEnd_Draw); - + FunModes_RestartRound(); + ConVar cvar = FindConVar("zr_weapons_zmarket_rebuy"); if (cvar != null) { @@ -453,18 +454,13 @@ Action Cmd_GunGame(int client, int args) return Plugin_Handled; } - if (THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_ENTWATCH].cvar.BoolValue) + if (EntWatch_HasSpecialItem(client)) { - #if defined _EntWatch_include - if (EntWatch_HasSpecialItem(client)) - { - static const char weapons[][] = { "weapon_p90", "weapon_tmp", "weapon_ak47", "weapon_m4a1" }; - GunGame_EquipWeapon(client, weapons[GetRandomInt(0, sizeof(weapons)-1)], true); - return Plugin_Handled; - } - #endif + static const char weapons[][] = { "weapon_p90", "weapon_tmp", "weapon_ak47", "weapon_m4a1" }; + GunGame_EquipWeapon(client, weapons[GetRandomInt(0, sizeof(weapons)-1)], true); + return Plugin_Handled; } - + int weaponType = g_GunGameData[client].level[0]; int weaponIndex = g_GunGameData[client].level[1]; if (weaponType > 0) @@ -552,7 +548,7 @@ void GunGame_StripPlayer(int client, bool keepSecondary = false, bool giveSecond { for (int i = 0; i <= 5; i++) { - if (i == CS_SLOT_KNIFE || i == CS_SLOT_GRENADE) + if (i != CS_SLOT_SECONDARY && i != CS_SLOT_PRIMARY) continue; if (keepSecondary && i == CS_SLOT_SECONDARY) @@ -580,8 +576,7 @@ void GunGame_ShowRewardsMenu(int client) menu.SetTitle("[GunGame Escape] You have completed a gungame cycle! Choose your reward!\nYou only have 60s to switch your rewards"); menu.AddItem("0", "More Speed", g_GunGameData[client].reward == REWARD_SPEED ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT); - menu.AddItem("1", "Lower Gravity", g_GunGameData[client].reward == REWARD_GRAVITY ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT); - menu.AddItem("2", "More hegrenades", g_GunGameData[client].reward == REWARD_HEGRENADES ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT); + menu.AddItem("2", "Smokegrenades (Freeze)", g_GunGameData[client].reward == REWARD_SMOKEGRENADES ? ITEMDRAW_DISABLED : ITEMDRAW_DEFAULT); menu.ExitBackButton = true; menu.Display(client, 60); @@ -596,6 +591,12 @@ int Menu_GunGame_ShowRewards(Menu menu, MenuAction action, int param1, int param case MenuAction_Select: { + if (!g_GunGameData[param1].completedCycle) + { + CPrintToChat(param1, "%s You cannot pick a reward right now, Sorry :p", THIS_MODE_INFO.tag); + return 0; + } + char data[3]; menu.GetItem(param2, data, sizeof(data)); @@ -618,13 +619,6 @@ void GunGame_GiveReward(int client, GunGame_Reward reward) { case REWARD_SPEED: { - /* Reset Gravity */ - if (g_GunGameData[client].originalGravity != 0.0) - { - SetEntityGravity(client, g_GunGameData[client].originalGravity); - g_GunGameData[client].originalGravity = 0.0; - } - if (!IsPlayerAlive(client) || !ZR_IsClientHuman(client)) return; @@ -637,7 +631,7 @@ void GunGame_GiveReward(int client, GunGame_Reward reward) g_GunGameData[client].rewardTimer = CreateTimer(THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_REWARD_SPEED].cvar.FloatValue, Timer_GunGameReward, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE); } - case REWARD_GRAVITY: + case REWARD_SMOKEGRENADES: { /* Reset Speed */ if (g_GunGameData[client].originalSpeed != 0.0) @@ -649,52 +643,16 @@ void GunGame_GiveReward(int client, GunGame_Reward reward) if (!IsPlayerAlive(client) || !ZR_IsClientHuman(client)) return; - g_GunGameData[client].originalGravity = GetEntityGravity(client); - SetEntityGravity(client, 0.5); - - CPrintToChat(client, "%s You have been granted a lower gravity for finishing a gungame cycle!", THIS_MODE_INFO.tag); + int smoke = GivePlayerItem(client, "weapon_smokegrenade"); + EquipPlayerWeapon(client, smoke); + int count = THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_SMOKEGRENADES_COUNT].cvar.IntValue; + SET_GRENADES_COUNT(client, SMOKEGRENADE, GET_GRENADES_COUNT(client, SMOKEGRENADE)+count-1); - delete g_GunGameData[client].rewardTimer; - g_GunGameData[client].rewardTimer = CreateTimer(THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_REWARD_GRAVITY].cvar.FloatValue, Timer_GunGameReward, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE); - } - - case REWARD_HEGRENADES: - { - /* Reset Gravity */ - if (g_GunGameData[client].originalGravity != 0.0) - { - SetEntityGravity(client, g_GunGameData[client].originalGravity); - g_GunGameData[client].originalGravity = 0.0; - } - - /* Reset Speed */ - if (g_GunGameData[client].originalSpeed != 0.0) - { - SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", g_GunGameData[client].originalSpeed); - g_GunGameData[client].originalSpeed = 0.0; - } - - if (!IsPlayerAlive(client) || !ZR_IsClientHuman(client)) - return; - - g_GunGameData[client].allowEquip = true; - GivePlayerItem(client, "weapon_hegrenade"); - int count = THIS_MODE_INFO.cvarInfo[GUNGAME_CONVAR_HEGRENADES_COUNT].cvar.IntValue; - GiveGrenadesToClient(client, GrenadeType_HEGrenade, count-1); - g_GunGameData[client].allowEquip = false; - - CPrintToChat(client, "%s You have been granted {olive}%d extra hegrenades {lightgreen}for finishing a gungame cycle!", THIS_MODE_INFO.tag, count); + CPrintToChat(client, "%s You have been granted {olive}%d extra SMOKEGRENADES {lightgreen}for finishing a gungame cycle!", THIS_MODE_INFO.tag, count); } default: - { - /* Reset Gravity */ - if (g_GunGameData[client].originalGravity != 0.0) - { - SetEntityGravity(client, g_GunGameData[client].originalGravity); - g_GunGameData[client].originalGravity = 0.0; - } - + { /* Reset Speed */ if (g_GunGameData[client].originalSpeed != 0.0) { @@ -716,4 +674,4 @@ Action Timer_GunGameReward(Handle timer, int userid) CPrintToChat(client, "%s Sorry, your reward has ended!", THIS_MODE_INFO.tag); GunGame_GiveReward(client, REWARD_NONE); return Plugin_Stop; -} \ No newline at end of file +} diff --git a/addons/sourcemod/scripting/Fun_Modes/HealBeacon.sp b/addons/sourcemod/scripting/Fun_Modes/HealBeacon.sp index 7794c8e..a7c6abc 100644 --- a/addons/sourcemod/scripting/Fun_Modes/HealBeacon.sp +++ b/addons/sourcemod/scripting/Fun_Modes/HealBeacon.sp @@ -695,6 +695,8 @@ public Action Cmd_HealBeaconToggle(int client, int args) ReplyToCommand(client, "%s HealBeacon Mode is now ON!", THIS_MODE_INFO.tag); else CReplyToCommand(client, "%s %T", THIS_MODE_INFO.tag, "HealBeacon_Enabled", client); + + FunModes_RestartRound(); } CHANGE_MODE_INFO(THIS_MODE_INFO, isOn, !THIS_MODE_INFO.isOn, THIS_MODE_INFO.index); diff --git a/addons/sourcemod/scripting/Fun_Modes/PullGame.sp b/addons/sourcemod/scripting/Fun_Modes/PullGame.sp index 427239c..9d2ad21 100644 --- a/addons/sourcemod/scripting/Fun_Modes/PullGame.sp +++ b/addons/sourcemod/scripting/Fun_Modes/PullGame.sp @@ -181,7 +181,7 @@ public Action Cmd_PullGameToggle(int client, int args) CPrintToChatAll("%s {olive}%d Random Humans {lightgreen}and {olive}%d Random Zombies {lightgreen}will be selected for the pullgame every %d seconds", THIS_MODE_INFO.tag, humansCount, zombiesCount, interval); - CS_TerminateRound(3.0, CSRoundEnd_Draw); + FunModes_RestartRound(); } else PullGame_ToggleTimer(false); diff --git a/addons/sourcemod/scripting/Fun_Modes/RealityShift.sp b/addons/sourcemod/scripting/Fun_Modes/RealityShift.sp index f374abf..61cfede 100644 --- a/addons/sourcemod/scripting/Fun_Modes/RealityShift.sp +++ b/addons/sourcemod/scripting/Fun_Modes/RealityShift.sp @@ -162,7 +162,7 @@ public Action Cmd_RealityShiftToggle(int client, int args) int interval = THIS_MODE_INFO.cvarInfo[REALITYSHIFT_CONVAR_TIMER_INTERVAL].cvar.IntValue; CPrintToChatAll("%s Positions will be swapped every {olive}%d seconds!", THIS_MODE_INFO.tag, interval); - CS_TerminateRound(3.0, CSRoundEnd_Draw); + FunModes_RestartRound(); } else delete g_hRealityShiftTimer; diff --git a/addons/sourcemod/scripting/Fun_Modes/RedLightGreenLight.sp b/addons/sourcemod/scripting/Fun_Modes/RedLightGreenLight.sp index 33d645d..8bdd109 100644 --- a/addons/sourcemod/scripting/Fun_Modes/RedLightGreenLight.sp +++ b/addons/sourcemod/scripting/Fun_Modes/RedLightGreenLight.sp @@ -35,7 +35,8 @@ stock void OnPluginStart_RLGL() /* ADMIN COMMANDS */ RegAdminCmd("sm_fm_rlgl", Cmd_RLGLToggle, ADMFLAG_CONVARS, "Enable/Disable RedLightGreenLight mode."); - + RegAdminCmd("sm_rlgl_settings", Cmd_RLGLSettings, ADMFLAG_CONVARS, "Open RLGL Settings Menu"); + /* CONVARS */ DECLARE_FM_CVAR( THIS_MODE_INFO.cvarInfo, RLGL_CONVAR_TIME_BETWEEN_DAMAGE,