Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Katsute committed Jul 7, 2023
1 parent 9f4b8c9 commit 65937e1
Show file tree
Hide file tree
Showing 12 changed files with 1,112 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: SourcePawn CI
on: [push]

jobs:
ci:
name: SourcePawn CI
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install SourceMod
uses: KatsuteTF/Workflows/actions/setup-sourcepawn@main

- name: Install RRM
uses: KatsuteTF/Workflows/actions/curl@main
with:
url: https://raw.githubusercontent.com/KatsuteTF/RRM/main/addons/sourcemod/include/rrm.inc
file: rrm.inc

- name: Compile Plugin
run: |
spcomp -i ./ rrm_bleed.sp
spcomp -i ./ rrm_explode.sp
spcomp -i ./ rrm_fire.sp
spcomp -i ./ rrm_jarate.sp
spcomp -i ./ rrm_marked.sp
spcomp -i ./ rrm_medieval.sp
spcomp -i ./ rrm_milked.sp
spcomp -i ./ rrm_stun.sp
spcomp -i ./ rrm_taunt.sp
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release
on:
release:
types: [published]

jobs:
release:
name: Release Plugin
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install SourceMod
uses: KatsuteTF/Workflows/actions/setup-sourcepawn@main

- name: Install RRM
uses: KatsuteTF/Workflows/actions/curl@main
with:
url: https://raw.githubusercontent.com/KatsuteTF/RRM/main/addons/sourcemod/include/rrm.inc
file: rrm.inc

- name: Compile Plugin
run: |
spcomp -i ./ rrm_bleed.sp
spcomp -i ./ rrm_explode.sp
spcomp -i ./ rrm_fire.sp
spcomp -i ./ rrm_jarate.sp
spcomp -i ./ rrm_marked.sp
spcomp -i ./ rrm_medieval.sp
spcomp -i ./ rrm_milked.sp
spcomp -i ./ rrm_stun.sp
spcomp -i ./ rrm_taunt.sp
- name: Deploy to GitHub Releases
uses: AButler/upload-release-assets@v2.0.2
with:
files: "*.smx"
repo-token: ${{ secrets.GITHUB_TOKEN }}
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@ Additional modifiers for the [RRM](https://forums.alliedmods.net/showthread.php?

|cvar|param|description|
|---|:-:|---|
|`rrm_bleed_min`|`0.1`|Min bleed chance|
|`rrm_bleed_max`|`1.0`|Max bleed chance|
|`rrm_bleed_duration`|`3.0`|Bleed 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_jarate_min`|`0.1`|Min jarate chance|
|`rrm_jarate_max`|`1.0`|Max jarate chance|
|`rrm_jarate_duration`|`3.0`|Jarate duration|
|`rrm_marked_min`|`0.1`|Min marked for death chance|
|`rrm_marked_max`|`1.0`|Max marked for death chance|
|`rrm_marked_duration`|`3.0`|Marked for death duration|
|`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_stun_min`|`0.1`|Min stun chance|
|`rrm_stun_max`|`1.0`|Max stun chance|
|`rrm_stun_duration`|`3.0`|Stun duration|
|`rrm_taunt_min`|`0.1`|Min taunt chance|
|`rrm_taunt_max`|`1.0`|Max taunt chance|

[![Creative Commons License](https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-nc-sa/4.0/)

Licensed under [CC BY-NC-SA 4.0](https://github.com/KatsuteTF/Round-Time/blob/main/LICENSE)
Licensed under [CC BY-NC-SA 4.0](https://github.com/KatsuteTF/RRM-Additions/blob/main/LICENSE)
120 changes: 120 additions & 0 deletions rrm_bleed.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] Bleed Modifier",
author = "Katsute",
description = "Modifier that grants chance of bleed.",
version = "1.0"
};

public void OnPluginStart()
{
cMin = CreateConVar("rrm_bleed_min", "0.1", "Minimum value for the random number generator.");
cMax = CreateConVar("rrm_bleed_max", "1.0", "Maximum value for the random number generator.");
cDuration = CreateConVar("rrm_bleed_duration", "3.0", "Duration for bleed 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_bleed", "rrm");
}

public int RRM_OnRegOpen()
{
RegisterModifiers();
}

void RegisterModifiers()
{
RRM_Register("Bleed", gMin, gMax, false, RRM_Callback_Bleed);
}

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_Bleed(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_Bleeding))
TF2_MakeBleed(victim, attacker, gDuration);
}
return Plugin_Continue;
}

float RandomFloat(const float min = 0.0, const float max = 1.0){
return min + GetURandomFloat() * (max - min);
}
116 changes: 116 additions & 0 deletions rrm_explode.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// 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;
float gMin = 0.0, gMax = 0.0;

public Plugin myinfo =
{
name = "[RRM] Explode Modifier",
author = "Katsute",
description = "Modifier that grants chance of exploding.",
version = "1.0"
};

public void OnPluginStart()
{
cMin = CreateConVar("rrm_explode_min", "0.1", "Minimum value for the random number generator.");
cMax = CreateConVar("rrm_explode_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_explode", "rrm");
}

public int RRM_OnRegOpen()
{
RegisterModifiers();
}

void RegisterModifiers()
{
RRM_Register("Explode", gMin, gMax, false, RRM_Callback_Explode);
}

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_Explode(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;
FakeClientCommand(victim, "explode");
}
return Plugin_Continue;
}

float RandomFloat(const float min = 0.0, const float max = 1.0){
return min + GetURandomFloat() * (max - min);
}
Loading

0 comments on commit 65937e1

Please sign in to comment.