Skip to content

Commit

Permalink
add several modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
Katsute committed Jul 27, 2023
1 parent 7a4ea1e commit 630098e
Show file tree
Hide file tree
Showing 15 changed files with 1,139 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,22 @@ jobs:
spcomp -i ./ rrm_explode.sp
spcomp -i ./ rrm_fire.sp
spcomp -i ./ rrm_friendly.sp
spcomp -i ./ rrm_health.sp
spcomp -i ./ rrm_jarate.sp
spcomp -i ./ rrm_marked.sp
spcomp -i ./ rrm_medieval.sp
spcomp -i ./ rrm_milk.sp
spcomp -i ./ rrm_mirror.sp
spcomp -i ./ rrm_powerup_agility.sp
spcomp -i ./ rrm_powerup_haste.sp
spcomp -i ./ rrm_powerup_king.sp
spcomp -i ./ rrm_powerup_knockout.sp
spcomp -i ./ rrm_powerup_plague.sp
spcomp -i ./ rrm_powerup_precision.sp
spcomp -i ./ rrm_powerup_regeneration.sp
spcomp -i ./ rrm_powerup_resistance.sp
spcomp -i ./ rrm_powerup_strength.sp
spcomp -i ./ rrm_powerup_vampire.sp
spcomp -i ./ rrm_resize.sp
spcomp -i ./ rrm_stun.sp
spcomp -i ./ rrm_taunt.sp
20 changes: 12 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ jobs:

- name: Compile Plugin
run: |
spcomp -i ./ rrm_bleed.sp
spcomp -i ./ rrm_charge.sp
spcomp -i ./ rrm_explode.sp
spcomp -i ./ rrm_fire.sp
spcomp -i ./ rrm_friendly.sp
spcomp -i ./ rrm_health.sp
spcomp -i ./ rrm_jarate.sp
spcomp -i ./ rrm_marked.sp
spcomp -i ./ rrm_medieval.sp
spcomp -i ./ rrm_milk.sp
spcomp -i ./ rrm_resize.sp
spcomp -i ./ rrm_stun.sp
spcomp -i ./ rrm_taunt.sp
spcomp -i ./ rrm_mirror.sp
spcomp -i ./ rrm_powerup_agility.sp
spcomp -i ./ rrm_powerup_haste.sp
spcomp -i ./ rrm_powerup_king.sp
spcomp -i ./ rrm_powerup_knockout.sp
spcomp -i ./ rrm_powerup_plague.sp
spcomp -i ./ rrm_powerup_precision.sp
spcomp -i ./ rrm_powerup_regeneration.sp
spcomp -i ./ rrm_powerup_resistance.sp
spcomp -i ./ rrm_powerup_strength.sp
spcomp -i ./ rrm_powerup_vampire.sp
- name: Deploy to GitHub Releases
uses: AButler/upload-release-assets@v2.0.2
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ 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_health_min`|`0.1`|Min max health|
|`rrm_health_max`|`3.0`|Max max health|
|`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 @@ -24,6 +26,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_mirror_min`|`0.1`|Min mirrored damage|
|`rrm_mirror_max`|`1.0`|Max mirrored damage|
|`rrm_size_min`|`0.25`|Min size|
|`rrm_size_max`|`1.35`|Max size|
|`rrm_stun_min`|`0.1`|Min stun chance|
Expand Down
122 changes: 122 additions & 0 deletions rrm_health.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// 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;
ConVar cMin = null, cMax = null;
float gMin = 0.0, gMax = 0.0;

public Plugin myinfo =
{
name = "[RRM] Health Modifier",
author = "Katsute",
description = "Modifier that changes max health.",
version = "1.0"
};

public void OnPluginStart()
{
cMin = CreateConVar("rrm_health_min", "0.1", "Minimum value for the random number generator.");
cMax = CreateConVar("rrm_health_max", "3.0", "Maximum value for the random number generator.");

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

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

HookEvent("player_spawn", OnPlayerSpawn, EventHookMode_Post);

if(RRM_IsRegOpen())
RegisterModifiers();

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

public void OnPluginEnd()
{
RemoveHealth();
}

public int RRM_OnRegOpen()
{
RegisterModifiers();
}

void RegisterModifiers()
{
RRM_Register("Max Health", gMin, gMax, false, RRM_Callback_Health);
}

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 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_iMaxHealth", RoundToCeil(GetEntProp(i, Prop_Data, "m_iMaxHealth") * gHealth));
return Plugin_Continue;
}

public void OnClientPostAdminCheck(int i)
{
if(!gEnabled)
return;
SetEntPropFloat(i, Prop_Send, "m_iMaxHealth", RoundToCeil(GetEntProp(i, Prop_Data, "m_iMaxHealth") * gHealth));
}

public int RRM_Callback_Health(bool enable, float value)
{
gEnabled = enable;
if(gEnabled)
{
gHealth = value;
AddHealth();
}
else
RemoveHealth();
return gEnabled;
}

void AddHealth()
{
for (int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
SetEntPropFloat(i, Prop_Send, "m_iMaxHealth", RoundToCeil(GetEntProp(i, Prop_Data, "m_iMaxHealth") * gHealth));
}
}

void RemoveHealth()
{
for (int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
SetEntPropFloat(i, Prop_Send, "m_iMaxHealth", RoundToCeil(GetEntProp(i, Prop_Data, "m_iMaxHealth") / gHealth));
}
}
109 changes: 109 additions & 0 deletions rrm_mirror.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// 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 gMirror = 0.0;
ConVar cMin = null, cMax = null;
float gMin = 0.0, gMax = 0.0;

public Plugin myinfo =
{
name = "[RRM] Mirrored Damage Modifier",
author = "Katsute",
description = "Modifier that adds mirrored damage.",
version = "1.0"
};

public void OnPluginStart()
{
cMin = CreateConVar("rrm_mirror_min", "0.1", "Minimum value for the random number generator.");
cMax = CreateConVar("rrm_mirror_max", "1.0", "Maximum value for the random number generator.");

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

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

for (int i = 1; i < MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
SDKHook(i, SDKHook_OnTakeDamageAlive, OnTakeDamage);
}

if(RRM_IsRegOpen())
RegisterModifiers();

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

public int RRM_OnRegOpen()
{
RegisterModifiers();
}

void RegisterModifiers()
{
RRM_Register("Mirrored Damage", gMin, gMax, false, RRM_Callback_Mirrored);
}

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 client)
{
SDKHook(client, SDKHook_OnTakeDamageAlive, OnTakeDamage);
}

public int RRM_Callback_Mirrored(bool enable, float value)
{
gEnabled = enable;
if(gEnabled)
gMirror = 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(!(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;
SDKHooks_TakeDamage(client, inflictor, victim, RoundFloat(damage * gMirror), damagetype, weapon, null, null, true);
}
return Plugin_Continue;
}
88 changes: 88 additions & 0 deletions rrm_powerup_agility.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// 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;

public Plugin myinfo =
{
name = "[RRM] Agility Powerup Modifier",
author = "Katsute",
description = "Modifier that gives agility powerup.",
version = "1.0"
};

public void OnPluginStart()
{
HookEvent("player_spawn", OnPlayerSpawn, EventHookMode_Post);

if(RRM_IsRegOpen())
RegisterModifiers();

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

public void OnPluginEnd()
{
RemovePowerup();
}

public int RRM_OnRegOpen()
{
RegisterModifiers();
}

void RegisterModifiers()
{
RRM_Register("Agility Powerup", 0.0, 0.0, false, RRM_Callback_Powerup);
}

public Action OnPlayerSpawn(Handle event, const char[] name, bool dontBroadcast)
{
if(!gEnabled)
return Plugin_Continue;
int i = GetClientOfUserId(GetEventInt(event, "userid"));
TF2_AddCondition(i, TFCond_RuneAgility);
return Plugin_Continue;
}

public int RRM_Callback_Powerup(bool enable, float value)
{
gEnabled = enable;
if(gEnabled)
AddPowerup();
else
RemovePowerup();
return gEnabled;
}

void AddPowerup()
{
for (int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
TF2_AddCondition(i, TFCond_RuneAgility);
}
}

void RemovePowerup()
{
for (int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
TF2_RemoveCondition(i, TFCond_RuneAgility);
}
}
Loading

0 comments on commit 630098e

Please sign in to comment.