Raised This Month: $85 Target: $400
 21% 

Solved [TF2] Spy Enforcer Weapon Attributes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 07-02-2020 , 15:53   [TF2] Spy Enforcer Weapon Attributes
Reply With Quote #1

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(client0);
        if(
myslot0 == 460)//Enforcer
        
{
            
PrintToChatAll("Debug: Found Spy named %N holding The Enforcer"client);    
            
int weapon GetPlayerWeaponSlot(client0);
            
TF2Attrib_SetByDefIndex(weapon7970.0);
            
PrintToChatAll("Debug: Removed Enforcer resistance piercing ability");
        }
    }
}

stock bool:IsValidClient(clientbool:nobots true)

    if (
client <= || client MaxClients)
    {
        return 
false
    }
    return 
IsClientInGame(client); 
}  

stock GetIndexOfWeaponSlot(iClientiSlot)
{
    return 
GetWeaponIndex(GetPlayerWeaponSlot(iClientiSlot));
}

stock GetClientCloakIndex(iClient)
{
    return 
GetWeaponIndex(GetPlayerWeaponSlot(iClientTFWeaponSlot_Watch));
}

stock GetWeaponIndex(iWeapon)
{
    return 
IsValidEnt(iWeapon) ? GetEntProp(iWeaponProp_Send"m_iItemDefinitionIndex"):-1;
}

stock GetActiveIndex(iClient)
{
    return 
GetWeaponIndex(GetEntPropEnt(iClientProp_Send"m_hActiveWeapon"));
}

stock bool:IsWeaponSlotActive(iClientiSlot)
{
    return 
GetPlayerWeaponSlot(iClientiSlot) == GetEntPropEnt(iClientProp_Send"m_hActiveWeapon");
}

stock bool:IsIndexActive(iClientiIndex)
{
    return 
iIndex == GetWeaponIndex(GetEntPropEnt(iClientProp_Send"m_hActiveWeapon"));
}

stock bool:IsSlotIndex(iClientiSlotiIndex)
{
    return 
iIndex == GetIndexOfWeaponSlot(iClientiSlot);
}

stock bool:IsValidEnt(iEnt)
{
    return 
iEnt MaxClients && IsValidEntity(iEnt);
}

stock GetSlotFromPlayerWeapon(iClientiWeapon)
{
    for (new 
0<= 5i++)
    {
        if (
iWeapon == GetPlayerWeaponSlot(iClienti))
        {
            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.

Last edited by PC Gamer; 07-29-2020 at 21:30.
PC Gamer is offline
Whai
Senior Member
Join Date: Jul 2018
Old 07-29-2020 , 15:27   Re: [TF2] Spy Enforcer Weapon Attributes
Reply With Quote #2

I don't know if it is solved but did you try this ?
PHP Code:
TF2Attrib_RemoveByDefIndex(weapon797); 
__________________
Whai is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 07-29-2020 , 21:30   Re: [TF2] Spy Enforcer Weapon Attributes
Reply With Quote #3

Quote:
Originally Posted by Whai View Post
I don't know if it is solved but did you try this ?
PHP Code:
TF2Attrib_RemoveByDefIndex(weapon797); 
Thanks! That worked, but I don't know why it worked. I was under the belief that you could only use TF2 Attributes to remove attributes that were set by TF2 Attributes. However, in this case I was able to use it to remove a static attribute on a weapon. Odd.
PC Gamer is offline
Crasher_3637
AlliedModders Donor
Join Date: May 2012
Old 07-29-2020 , 22:37   Re: [TF2] Spy Enforcer Weapon Attributes
Reply With Quote #4

Quote:
Originally Posted by PC Gamer View Post
Thanks! That worked, but I don't know why it worked. I was under the belief that you could only use TF2 Attributes to remove attributes that were set by TF2 Attributes. However, in this case I was able to use it to remove a static attribute on a weapon. Odd.
I've used that function a few times before and I can confirm that it does work on pre-existing attributes, regardless of who or what applied them. I'm not sure if it has always been that way since I only started using it last year.
__________________
AFK like JFK
Crasher_3637 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:27.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode