diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 391a52d..699843c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,6 @@ jobs: spcomp -i ./ rrm_charge.sp spcomp -i ./ rrm_explode.sp spcomp -i ./ rrm_fire.sp - spcomp -i ./ rrm_gas.sp spcomp -i ./ rrm_jarate.sp spcomp -i ./ rrm_marked.sp spcomp -i ./ rrm_medieval.sp diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 365f2b9..e0f5690 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,6 @@ jobs: spcomp -i ./ rrm_charge.sp spcomp -i ./ rrm_explode.sp spcomp -i ./ rrm_fire.sp - spcomp -i ./ rrm_gas.sp spcomp -i ./ rrm_jarate.sp spcomp -i ./ rrm_marked.sp spcomp -i ./ rrm_medieval.sp diff --git a/README.md b/README.md index c78fdf6..fd981c9 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,6 @@ Additional modifiers for the [RRM](https://forums.alliedmods.net/showthread.php? |`rrm_fire_min`|`0.1`|Min fire chance| |`rrm_fire_max`|`1.0`|Max fire chance| |`rrm_fire_duration`|`3.0`|Fire duration| -|`rrm_gas_min`|`0.1`|Min gas chance| -|`rrm_gas_max`|`1.0`|Max gas chance| -|`rrm_gas_duration`|`3.0`|Gas duration| |`rrm_jarate_min`|`0.1`|Min jarate chance| |`rrm_jarate_max`|`1.0`|Max jarate chance| |`rrm_jarate_duration`|`3.0`|Jarate duration| diff --git a/rrm_gas.sp b/rrm_gas.sp deleted file mode 100644 index 054c3dc..0000000 --- a/rrm_gas.sp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2023 Katsute | Licensed under CC BY-NC-SA 4.0 - -#pragma semicolon 1 - -#define RRM_VERSION "1.0" - -#include -#include -#include -#include -#include -#include - -#pragma newdecls required - -int gEnabled = 0; -float gChance = 0.0; -ConVar cMin = null, cMax = null, cDuration = null; -float gMin = 0.0, gMax = 0.0, gDuration = 0.0; - -public Plugin myinfo = -{ - name = "[RRM] Gas Modifier", - author = "Katsute", - description = "Modifier that grants chance of gas.", - version = "1.0" -}; - -public void OnPluginStart() -{ - cMin = CreateConVar("rrm_gas_min", "0.1", "Minimum value for the random number generator."); - cMax = CreateConVar("rrm_gas_max", "1.0", "Maximum value for the random number generator."); - cDuration = CreateConVar("rrm_gas_duration", "3.0", "Duration for gas to last on affected players."); - - cMin.AddChangeHook(OnConvarChanged); - cMax.AddChangeHook(OnConvarChanged); - cDuration.AddChangeHook(OnConvarChanged); - - gMin = cMin.FloatValue; - gMax = cMax.FloatValue; - gDuration = cDuration.FloatValue; - - for (int i = 1; i < MaxClients; i++) - { - if(!IsClientInGame(i)) - continue; - SDKHook(i, SDKHook_OnTakeDamageAlive, OnTakeDamage); - } - - if(RRM_IsRegOpen()) - RegisterModifiers(); - - AutoExecConfig(true, "rrm_gas", "rrm"); -} - -public int RRM_OnRegOpen() -{ - RegisterModifiers(); -} - -void RegisterModifiers() -{ - RRM_Register("Gas", gMin, gMax, false, RRM_Callback_Gas); -} - -public void OnConvarChanged(Handle convar, char[] oldValue, char[] newValue) -{ - if (StrEqual(oldValue, newValue, true)) - return; - - float fNewValue = StringToFloat(newValue); - - if(convar == cMin) - gMin = fNewValue; - else if(convar == cMax) - gMax = fNewValue; - else if(convar == cDuration) - gDuration = fNewValue; -} - -public void OnClientPostAdminCheck(int client) -{ - SDKHook(client, SDKHook_OnTakeDamageAlive, OnTakeDamage); -} - -public int RRM_Callback_Gas(bool enable, float value) -{ - gEnabled = enable; - if(gEnabled) - gChance = value; - return gEnabled; -} - -public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, - float damageForce[3], float damagePosition[3], int damagecustom) -{ - if(!gEnabled) - return Plugin_Continue; - - if(gChance > RandomFloat(RandomFloat(0.0, 1.0))) - { - if(!(1 <= victim <= MaxClients)) - return Plugin_Continue; - if(!IsClientInGame(victim)) - return Plugin_Continue; - if(!(1 <= attacker <= MaxClients)) - return Plugin_Continue; - if(!IsClientInGame(attacker)) - return Plugin_Continue; - if(!IsPlayerAlive(victim)) - return Plugin_Continue; - if(!TF2_IsPlayerInCondition(victim, TFCond_Gas)) - TF2_AddCondition(victim, TFCond_Gas, gDuration, attacker); - } - return Plugin_Continue; -} - -float RandomFloat(const float min = 0.0, const float max = 1.0){ - return min + GetURandomFloat() * (max - min); -} \ No newline at end of file diff --git a/rrm_resize.sp b/rrm_resize.sp index ef9511b..ef749aa 100644 --- a/rrm_resize.sp +++ b/rrm_resize.sp @@ -37,6 +37,8 @@ public void OnPluginStart() gMin = cMin.FloatValue; gMax = cMax.FloatValue; + HookEvent("player_spawn", OnPlayerSpawn, EventHookMode_Post); + if(RRM_IsRegOpen()) RegisterModifiers(); @@ -71,12 +73,20 @@ public void OnConvarChanged(Handle convar, char[] oldValue, char[] newValue) gMax = fNewValue; } +public Action OnPlayerSpawn(Handle event, const char[] name, bool dontBroadcast) +{ + if(!gEnabled) + return Plugin_Continue; + int i = GetClientOfUserId(GetEventInt(event, "userid")); + SetEntPropFloat(i, Prop_Send, "m_flModelScale", gSize); + return Plugin_Continue; +} + public void OnClientPostAdminCheck(int i) { if(!gEnabled) return; SetEntPropFloat(i, Prop_Send, "m_flModelScale", gSize); - SetEntPropFloat(i, Prop_Send, "m_flStepSize", 18.0 * gSize); } public int RRM_Callback_Size(bool enable, float value) @@ -99,7 +109,6 @@ void SetSize() if(!IsClientInGame(i)) continue; SetEntPropFloat(i, Prop_Send, "m_flModelScale", gSize); - SetEntPropFloat(i, Prop_Send, "m_flStepSize", 18.0 * gSize); } } @@ -110,6 +119,5 @@ void RemoveSize() if(!IsClientInGame(i)) continue; SetEntPropFloat(i, Prop_Send, "m_flModelScale", 1.0); - SetEntPropFloat(i, Prop_Send, "m_flStepSize", 18.0); } } \ No newline at end of file