From e8eba4a6b6e37d6eda787b4d51aee9d3a2abbc33 Mon Sep 17 00:00:00 2001 From: Mikusch Date: Mon, 5 Apr 2021 00:05:16 +0200 Subject: [PATCH] Allow configuring backstab damage against the activator --- README.md | 1 + addons/sourcemod/configs/deathrun/items.cfg | 20 ++++++++++++++++--- addons/sourcemod/scripting/deathrun.sp | 3 ++- .../sourcemod/scripting/deathrun/convars.sp | 1 + .../sourcemod/scripting/deathrun/sdkhooks.sp | 12 +++++++++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 375b94e..49dfe18 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ Any item definition indexes specified in a map-specific item configuration will - `dr_activator_count ( def. "1" )` - Amount of activators chosen at the start of a round. - `dr_activator_health_modifier ( def. "1.0" )` - Modifier of the health the activator receives from runners. - `dr_activator_healthbar ( def. "1" )` - If enabled, the activator health will be displayed on screen. +- `dr_backstab_damage ( def. "750.0" )` - Damage dealt to the activator by Spy backstabs. Set to 0 to let the game determine the damage. - `dr_speed_modifier ( def. "0.0" )` - Maximum speed modifier for all classes, in HU/s. - `dr_speed_modifier_scout ( def. "-80.0" )` - Maximum speed modifier for Scout, in HU/s. - `dr_speed_modifier_sniper ( def. "0.0" )` - Maximum speed modifier for Sniper, in HU/s. diff --git a/addons/sourcemod/configs/deathrun/items.cfg b/addons/sourcemod/configs/deathrun/items.cfg index cafa5ea..03de137 100644 --- a/addons/sourcemod/configs/deathrun/items.cfg +++ b/addons/sourcemod/configs/deathrun/items.cfg @@ -51,11 +51,25 @@ // Scout - Secondary [Slot 1] "46" // Bonk! Atomic Punch { - "block_attack" "1" + "attributes" + { + "1" + { + "name" "lunchbox adds minicrits" + "value" "2.0" + } + } } "1145" // Festive Bonk! { - "block_attack" "1" + "attributes" + { + "1" + { + "name" "lunchbox adds minicrits" + "value" "2.0" + } + } } "449" // Winger { @@ -1214,7 +1228,7 @@ } } } - "211" // Medi Gun(Renamed/Strange) + "211" // Medi Gun (Renamed/Strange) { "attributes" { diff --git a/addons/sourcemod/scripting/deathrun.sp b/addons/sourcemod/scripting/deathrun.sp index 91f5bc8..45eda12 100644 --- a/addons/sourcemod/scripting/deathrun.sp +++ b/addons/sourcemod/scripting/deathrun.sp @@ -30,7 +30,7 @@ #define PLUGIN_NAME "Deathrun Neu" #define PLUGIN_AUTHOR "Mikusch" -#define PLUGIN_VERSION "1.5.0" +#define PLUGIN_VERSION "1.5.1" #define PLUGIN_URL "https://github.com/Mikusch/deathrun" #define PLUGIN_TAG "[{primary}" ... PLUGIN_NAME ... "{default}]" @@ -106,6 +106,7 @@ ConVar dr_runner_glow; ConVar dr_activator_count; ConVar dr_activator_health_modifier; ConVar dr_activator_healthbar; +ConVar dr_backstab_damage; ConVar dr_speed_modifier[view_as(TFClassType)]; ArrayList g_CurrentActivators; diff --git a/addons/sourcemod/scripting/deathrun/convars.sp b/addons/sourcemod/scripting/deathrun/convars.sp index a9ffe88..ae00c49 100644 --- a/addons/sourcemod/scripting/deathrun/convars.sp +++ b/addons/sourcemod/scripting/deathrun/convars.sp @@ -46,6 +46,7 @@ void ConVars_Init() dr_speed_modifier[6] = CreateConVar("dr_speed_modifier_heavy", "0.0", "Maximum speed modifier for Heavy, in HU/s."); dr_speed_modifier[7] = CreateConVar("dr_speed_modifier_pyro", "0.0", "Maximum speed modifier for Pyro, in HU/s."); dr_speed_modifier[8] = CreateConVar("dr_speed_modifier_spy", "0.0", "Maximum speed modifier for Spy, in HU/s."); + dr_backstab_damage = CreateConVar("dr_backstab_damage", "750.0", "Damage dealt to the activator by Spy backstabs. Set to 0 to let the game determine the damage."); dr_speed_modifier[9] = CreateConVar("dr_speed_modifier_engineer", "0.0", "Maximum speed modifier for Engineer, in HU/s."); dr_chattips_interval.AddChangeHook(ConVarChanged_ChatTipsInterval); diff --git a/addons/sourcemod/scripting/deathrun/sdkhooks.sp b/addons/sourcemod/scripting/deathrun/sdkhooks.sp index 5dab2b1..5302ff0 100644 --- a/addons/sourcemod/scripting/deathrun/sdkhooks.sp +++ b/addons/sourcemod/scripting/deathrun/sdkhooks.sp @@ -30,6 +30,7 @@ static char g_OwnerEntityList[][] = { void SDKHooks_OnClientPutInServer(int client) { SDKHook(client, SDKHook_SetTransmit, SDKHookCB_ClientSetTransmit); + SDKHook(client, SDKHook_OnTakeDamageAlive, SDKHookCB_ClientOnTakeDamageAlive); } void SDKHooks_OnEntityCreated(int entity, const char[] classname) @@ -89,6 +90,17 @@ public Action SDKHookCB_ClientSetTransmit(int entity, int client) return Plugin_Continue; } +public Action SDKHookCB_ClientOnTakeDamageAlive(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom) +{ + if (DRPlayer(victim).IsActivator() && damagecustom == TF_CUSTOM_BACKSTAB && dr_backstab_damage.FloatValue > 0.0) + { + damage = dr_backstab_damage.FloatValue; + return Plugin_Changed; + } + + return Plugin_Continue; +} + public Action SDKHookCB_OwnerEntitySetTransmit(int entity, int client) { int owner = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");