Skip to content

Commit

Permalink
Allow configuring backstab damage against the activator
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikusch committed Apr 4, 2021
1 parent 2b0bc76 commit e8eba4a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 17 additions & 3 deletions addons/sourcemod/configs/deathrun/items.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -1214,7 +1228,7 @@
}
}
}
"211" // Medi Gun(Renamed/Strange)
"211" // Medi Gun (Renamed/Strange)
{
"attributes"
{
Expand Down
3 changes: 2 additions & 1 deletion addons/sourcemod/scripting/deathrun.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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}]"
Expand Down Expand Up @@ -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<int>(TFClassType)];

ArrayList g_CurrentActivators;
Expand Down
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/deathrun/convars.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions addons/sourcemod/scripting/deathrun/sdkhooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit e8eba4a

Please sign in to comment.