Is it possible to remove the attribute 'dmg pierces resists absorbs' (attribute 797) from the Spy weapon called 'The Enforcer' (weapon 460)? If so, how?
I've tried to do it a couple of different ways, but after each effort I spectate the client to view their weapon it still says "Attacks pierce damage resistance effects and bonuses". I'm wondering if the effect is removed but the text is hardcoded, or if I am just unable to remove it.
What I've tried so far that didn't work:
Method 1: Used tf2items.weapon.txt file
PHP Code:
"custom_weapons_v3"
{
"*"
{
"460"
{
"1" "797 ; 0"
}
}
}
Method 2: Wrote this plugin
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <tf2_stocks>
#include <tf2attributes>
#define PLUGIN_VERSION "1.0"
public Plugin:myinfo =
{
name = "[TF2] Remove Enforcer Resistance Penetration",
author = "PC Gamer",
description = "Remove Enforcer Resistance Penetration",
version = PLUGIN_VERSION,
url = "www.sourcemod.net"
}
public void OnPluginStart()
{
HookEvent("post_inventory_application", EventInventoryApplication);
}
public EventInventoryApplication(Handle:event, const String:name[], bool:dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if (IsValidClient(client) && TF2_GetPlayerClass(client) == TFClass_Spy)
{
int myslot0 = GetIndexOfWeaponSlot(client, 0);
if(myslot0 == 460)//Enforcer
{
PrintToChatAll("Debug: Found Spy named %N holding The Enforcer", client);
int weapon = GetPlayerWeaponSlot(client, 0);
TF2Attrib_SetByDefIndex(weapon, 797, 0.0);
PrintToChatAll("Debug: Removed Enforcer resistance piercing ability");
}
}
}
stock bool:IsValidClient(client, bool:nobots = true)
{
if (client <= 0 || client > MaxClients)
{
return false;
}
return IsClientInGame(client);
}
stock GetIndexOfWeaponSlot(iClient, iSlot)
{
return GetWeaponIndex(GetPlayerWeaponSlot(iClient, iSlot));
}
stock GetClientCloakIndex(iClient)
{
return GetWeaponIndex(GetPlayerWeaponSlot(iClient, TFWeaponSlot_Watch));
}
stock GetWeaponIndex(iWeapon)
{
return IsValidEnt(iWeapon) ? GetEntProp(iWeapon, Prop_Send, "m_iItemDefinitionIndex"):-1;
}
stock GetActiveIndex(iClient)
{
return GetWeaponIndex(GetEntPropEnt(iClient, Prop_Send, "m_hActiveWeapon"));
}
stock bool:IsWeaponSlotActive(iClient, iSlot)
{
return GetPlayerWeaponSlot(iClient, iSlot) == GetEntPropEnt(iClient, Prop_Send, "m_hActiveWeapon");
}
stock bool:IsIndexActive(iClient, iIndex)
{
return iIndex == GetWeaponIndex(GetEntPropEnt(iClient, Prop_Send, "m_hActiveWeapon"));
}
stock bool:IsSlotIndex(iClient, iSlot, iIndex)
{
return iIndex == GetIndexOfWeaponSlot(iClient, iSlot);
}
stock bool:IsValidEnt(iEnt)
{
return iEnt > MaxClients && IsValidEntity(iEnt);
}
stock GetSlotFromPlayerWeapon(iClient, iWeapon)
{
for (new i = 0; i <= 5; i++)
{
if (iWeapon == GetPlayerWeaponSlot(iClient, i))
{
return i;
}
}
return -1;
}
Neither one prevented the text of "Attacks pierce damage resistance effects and bonuses" from being displayed when the weapon is inspected by another player.
Any assistance would be appreciated.