-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
363 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |