Skip to content

Commit

Permalink
add new modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
Katsute committed Jul 8, 2023
1 parent 77afc71 commit a467bd6
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ Additional modifiers for the [RRM](https://forums.alliedmods.net/showthread.php?
|`rrm_bleed_min`|`0.1`|Min bleed chance|
|`rrm_bleed_max`|`1.0`|Max bleed chance|
|`rrm_bleed_duration`|`3.0`|Bleed duration|
|`rrm_charge_min`|`0.1`|Min charge chance|
|`rrm_charge_max`|`1.0`|Max charge chance|
|`rrm_charge_duration`|`3.0`|Charge duration|
|`rrm_explode_min`|`0.1`|Min explode chance|
|`rrm_explode_max`|`1.0`|Max explode chance|
|`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|
Expand All @@ -21,6 +27,8 @@ Additional modifiers for the [RRM](https://forums.alliedmods.net/showthread.php?
|`rrm_milk_min`|`0.1`|Min mad milk chance|
|`rrm_milk_max`|`1.0`|Max mad milk chance|
|`rrm_milk_duration`|`3.0`|Mad milk duration|
|`rrm_size_min`|`0.1`|Min size|
|`rrm_size_max`|`1.0`|Max size|
|`rrm_stun_min`|`0.1`|Min stun chance|
|`rrm_stun_max`|`1.0`|Max stun chance|
|`rrm_stun_duration`|`3.0`|Stun duration|
Expand Down
120 changes: 120 additions & 0 deletions rrm_charge.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright (C) 2023 Katsute | Licensed under CC BY-NC-SA 4.0

#pragma semicolon 1

#define RRM_VERSION "1.0"

#include <sourcemod>
#include <sdkhooks>
#include <tf2attributes>
#include <tf2>
#include <tf2_stocks>
#include <rrm>

#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] Charged Modifier",
author = "Katsute",
description = "Modifier that grants chance of demoman charge.",
version = "1.0"
};

public void OnPluginStart()
{
cMin = CreateConVar("rrm_charge_min", "0.1", "Minimum value for the random number generator.");
cMax = CreateConVar("rrm_charge_max", "1.0", "Maximum value for the random number generator.");
cDuration = CreateConVar("rrm_charge_duration", "3.0", "Duration for charge 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_charge", "rrm");
}

public int RRM_OnRegOpen()
{
RegisterModifiers();
}

void RegisterModifiers()
{
RRM_Register("Charge", gMin, gMax, false, RRM_Callback_Charge);
}

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_Charge(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_Charging))
TF2_AddCondition(victim, TFCond_Charging, gDuration, attacker);
}
return Plugin_Continue;
}

float RandomFloat(const float min = 0.0, const float max = 1.0){
return min + GetURandomFloat() * (max - min);
}
120 changes: 120 additions & 0 deletions rrm_gas.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright (C) 2023 Katsute | Licensed under CC BY-NC-SA 4.0

#pragma semicolon 1

#define RRM_VERSION "1.0"

#include <sourcemod>
#include <sdkhooks>
#include <tf2attributes>
#include <tf2>
#include <tf2_stocks>
#include <rrm>

#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);
}
115 changes: 115 additions & 0 deletions rrm_resize.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright (C) 2023 Katsute | Licensed under CC BY-NC-SA 4.0

#pragma semicolon 1

#define RRM_VERSION "1.0"

#include <sourcemod>
#include <sdkhooks>
#include <tf2attributes>
#include <tf2>
#include <tf2_stocks>
#include <rrm>

#pragma newdecls required

int gEnabled = 0;
float gSize = 0.0;
ConVar cMin = null, cMax = null;
float gMin = 0.0, gMax = 0.0;

public Plugin myinfo =
{
name = "[RRM] Size Modifier",
author = "Katsute",
description = "Modifier that resizes players.",
version = "1.0"
};

public void OnPluginStart()
{
cMin = CreateConVar("rrm_size_min", "0.25", "Minimum value for the random number generator.");
cMax = CreateConVar("rrm_size_max", "1.35", "Maximum value for the random number generator.");

cMin.AddChangeHook(OnConvarChanged);
cMax.AddChangeHook(OnConvarChanged);

gMin = cMin.FloatValue;
gMax = cMax.FloatValue;

if(RRM_IsRegOpen())
RegisterModifiers();

AutoExecConfig(true, "rrm_size", "rrm");
}

public void OnPluginEnd()
{
RemoveSize();
}

public int RRM_OnRegOpen()
{
RegisterModifiers();
}

void RegisterModifiers()
{
RRM_Register("Resize", gMin, gMax, false, RRM_Callback_Size);
}

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;
}

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)
{
gEnabled = enable;
if(gEnabled)
{
gSize = value;
SetSize();
}
else
RemoveSize();
return gEnabled;
}

void SetSize()
{
for (int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
SetEntPropFloat(i, Prop_Send, "m_flModelScale", gSize);
SetEntPropFloat(i, Prop_Send, "m_flStepSize", 18.0 * gSize);
}
}

void RemoveSize()
{
for (int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
SetEntPropFloat(i, Prop_Send, "m_flModelScale", 1.0);
SetEntPropFloat(i, Prop_Send, "m_flStepSize", 18.0);
}
}

0 comments on commit a467bd6

Please sign in to comment.