AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [TF2] Spy Enforcer Weapon Attributes (https://forums.alliedmods.net/showthread.php?t=325687)

PC Gamer 07-02-2020 15:53

[TF2] Spy Enforcer Weapon Attributes
 
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.

Whai 07-29-2020 15:27

Re: [TF2] Spy Enforcer Weapon Attributes
 
I don't know if it is solved but did you try this ?
PHP Code:

TF2Attrib_RemoveByDefIndex(weapon797); 


PC Gamer 07-29-2020 21:30

Re: [TF2] Spy Enforcer Weapon Attributes
 
Quote:

Originally Posted by Whai (Post 2712210)
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.

Crasher_3637 07-29-2020 22:37

Re: [TF2] Spy Enforcer Weapon Attributes
 
Quote:

Originally Posted by PC Gamer (Post 2712285)
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.


All times are GMT -4. The time now is 11:08.

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