From 7118a72572921e3f90898db848f59947fbf80435 Mon Sep 17 00:00:00 2001 From: Katsute <58778985+Katsute@users.noreply.github.com> Date: Fri, 16 Aug 2024 21:27:56 -0400 Subject: [PATCH] 2.0 (#1) --- .github/workflows/ci.yml | 31 ++------- .github/workflows/release.yml | 31 ++------- README.md | 4 ++ rrm_attribute_crit.sp | 127 ++++++++++++++++++++++++++++++++++ rrm_friction.sp | 92 ++++++++++++++++++++++++ 5 files changed, 233 insertions(+), 52 deletions(-) create mode 100644 rrm_attribute_crit.sp create mode 100644 rrm_friction.sp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2de751..1f9b2cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,29 +24,8 @@ jobs: url: https://raw.githubusercontent.com/KatsuteTF/RRM/main/addons/sourcemod/include/rrm.inc file: rrm.inc - - name: Compile Plugin - run: | - spcomp -i ./ rrm_attribute_clip.sp - spcomp -i ./ rrm_attribute_firing.sp - spcomp -i ./ rrm_attribute_projectile.sp - spcomp -i ./ rrm_attribute_spread.sp - 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_jarate.sp - spcomp -i ./ rrm_marked.sp - spcomp -i ./ rrm_medieval.sp - spcomp -i ./ rrm_milk.sp - spcomp -i ./ rrm_powerup_agility.sp - spcomp -i ./ rrm_powerup_haste.sp - spcomp -i ./ rrm_powerup_plague.sp - spcomp -i ./ rrm_powerup_precision.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_skeletons.sp - spcomp -i ./ rrm_stun.sp - spcomp -i ./ rrm_taunt.sp \ No newline at end of file + - name: Compile Plugins + run: |- + for file in *.sp; do + spcomp -i ./ "$file" + done \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 78484ec..6756961 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,32 +26,11 @@ jobs: url: https://raw.githubusercontent.com/KatsuteTF/RRM/main/addons/sourcemod/include/rrm.inc file: rrm.inc - - name: Compile Plugin - run: | - spcomp -i ./ rrm_attribute_clip.sp - spcomp -i ./ rrm_attribute_firing.sp - spcomp -i ./ rrm_attribute_projectile.sp - spcomp -i ./ rrm_attribute_spread.sp - 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_jarate.sp - spcomp -i ./ rrm_marked.sp - spcomp -i ./ rrm_medieval.sp - spcomp -i ./ rrm_milk.sp - spcomp -i ./ rrm_powerup_agility.sp - spcomp -i ./ rrm_powerup_haste.sp - spcomp -i ./ rrm_powerup_plague.sp - spcomp -i ./ rrm_powerup_precision.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_skeletons.sp - spcomp -i ./ rrm_stun.sp - spcomp -i ./ rrm_taunt.sp + - name: Compile Plugins + run: |- + for file in *.sp; do + spcomp -i ./ "$file" + done - name: Deploy to GitHub Releases uses: AButler/upload-release-assets@v2.0.2 diff --git a/README.md b/README.md index a9b0b8a..e17e3d3 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Additional modifiers for the [RRM](https://forums.alliedmods.net/showthread.php? |`rrm_attribute_clip_min`|`0.5`|Min clip size| |`rrm_attribute_clip_max`|`4.0`|Max clip size| |`rrm_attribute_clip_delay`|`1.2`|Attribute delay| +|`rrm_attribute_crit_duration`|`5`|Crit duration| +|`rrm_attribute_crit_delay`|`1.2`|Attribute delay| |`rrm_attribute_firing_min`|`0.5`|Min firing speed| |`rrm_attribute_firing_max`|`4.0`|Max firing speed| |`rrm_attribute_firing_delay`|`1.2`|Attribute delay| @@ -27,6 +29,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_friction_min`|`0`|Min friction| +|`rrm_friction_max`|`1.0`|Max friction| |`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_attribute_crit.sp b/rrm_attribute_crit.sp new file mode 100644 index 0000000..fdcf133 --- /dev/null +++ b/rrm_attribute_crit.sp @@ -0,0 +1,127 @@ +// Copyright (C) 2024 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 gDur = 0.0; +ConVar cDur = null, cDelay = null; +float gDelay = 0.0; + +public Plugin myinfo = { + name = "[RRM] critter Modifier", + author = "Katsute", + description = "Modifier that forces crit on kill.", + version = "1.0" +}; + +public void OnPluginStart(){ + cDelay = CreateConVar("rrm_attribute_crit_delay", "1.2", "Delay to apply attribute."); + cDur = CreateConVar("rrm_attribute_crit_duration", "5", "How long to have crits."); + + cDelay.AddChangeHook(OnConvarChanged); + cDur.AddChangeHook(OnConvarChanged); + + gDelay = cDelay.FloatValue; + gDur = cDur.FloatValue; + + HookEvent("post_inventory_application", PostInventoryApplication); + + if(RRM_IsRegOpen()) + RegisterModifiers(); + + AutoExecConfig(true, "rrm_attribute_crit", "rrm"); +} + +public int RRM_OnRegOpen(){ + RegisterModifiers(); +} + +void RegisterModifiers(){ + RRM_Register("Crit on Kill", 0.0, 0.0, false, RRM_Callback_Attribute); +} + +public void OnConvarChanged(Handle convar, char[] oldValue, char[] newValue){ + if (StrEqual(oldValue, newValue, true)) + return; + + float fNewValue = StringToFloat(newValue); + + if(convar == cDelay) + gDelay = fNewValue; + else if(convar == cDur) + gDur = fNewValue; +} + +public int RRM_Callback_Attribute(bool enable, float value){ + gEnabled = enable; + + for(int i = 1; i <= MaxClients; i++){ + if(IsClientInGame(i)){ + int health = GetClientHealth(i); + TF2_RemoveAllWeapons(i); + TF2_RegeneratePlayer(i); + SetEntityHealth(i, health < 1 ? 1 : health); + } + } + return gEnabled; +} + +public void PostInventoryApplication(const Handle event, const char[] name, const bool dontBroadcast){ + if(gEnabled){ + int client = GetClientOfUserId(GetEventInt(event, "userid")); + CreateTimer(gDelay, PostInventoryApplicationDelayed, client, TIMER_FLAG_NO_MAPCHANGE); + } +} + +public Action PostInventoryApplicationDelayed(const Handle timer, const int client){ + if(gEnabled && IsClientInGame(client)){ + int primary = GetPlayerWeaponSlot(client, 0); + int secondary = GetPlayerWeaponSlot(client, 1); + int melee = GetPlayerWeaponSlot(client, 2); + + if(primary != -1 && TF2Attrib_GetByDefIndex(primary, 2050) == Address_Null){ + ApplyPrimary(primary); + TF2Attrib_SetByDefIndex(primary, 2050, 1.0); + } + if(secondary != -1 && TF2Attrib_GetByDefIndex(secondary, 2050) == Address_Null){ + ApplySecondary(secondary); + TF2Attrib_SetByDefIndex(secondary, 2050, 1.0); + } + if(melee != -1 && TF2Attrib_GetByDefIndex(melee, 2050) == Address_Null){ + ApplyMelee(melee); + TF2Attrib_SetByDefIndex(melee, 2050, 1.0); + } + } + return Plugin_Continue; +} + +public void ApplyAttribute(const int ent, const int attribute, const float value){ + if(ent != -1 && IsValidEntity(ent)){ + Address addr = TF2Attrib_GetByDefIndex(ent, attribute); + float current = addr != Address_Null ? TF2Attrib_GetValue(addr) : 1.0; + TF2Attrib_SetByDefIndex(ent, attribute, current * value); + } +} + +public void ApplyPrimary(const int ent){ + ApplyAttribute(ent, 31, gDur); +} + +public void ApplySecondary(const int ent){ + ApplyAttribute(ent, 31, gDur); +} + +public void ApplyMelee(const int ent){ + ApplyAttribute(ent, 31, gDur); +} \ No newline at end of file diff --git a/rrm_friction.sp b/rrm_friction.sp new file mode 100644 index 0000000..4fef72a --- /dev/null +++ b/rrm_friction.sp @@ -0,0 +1,92 @@ +// Copyright (C) 2024 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 gMul = 0.0; +ConVar cMin = null, cMax = null; +float gMin = 0.0, gMax = 0.0; + +public Plugin myinfo = +{ + name = "[RRM] Friction Modifier", + author = "Katsute", + description = "Modifier changes friction.", + version = "1.0" +}; + +public void OnPluginStart() +{ + cMin = CreateConVar("rrm_friction_min", "0.1", "Minimum value for the random number generator."); + cMax = CreateConVar("rrm_friction_max", "1.0", "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_friction", "rrm"); +} + +public void OnPluginEnd() +{ + DisableEffect(); +} + +public int RRM_OnRegOpen() +{ + RegisterModifiers(); +} + +void RegisterModifiers() +{ + RRM_Register("Friction", gMin, gMax, false, RRM_Callback_Effect); +} + +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 int RRM_Callback_Effect(bool enable, float value) +{ + gEnabled = enable; + gMul = value; + if(gEnabled) + EnableEffect(); + else + DisableEffect(); + return enable; +} + +void EnableEffect() +{ + ServerCommand("sv_friction %f", 4 * gMul); +} + +void DisableEffect() +{ + ServerCommand("sv_friction 4"); +} \ No newline at end of file