PDA

View Full Version : Change stats on all weapons of a certain type


JRDS
06-21-2016, 10:36
If I want to change the damage on -all- syringe guns, how would I go about it? What about other variables/attributes?

JRDS
06-22-2016, 17:38
-bump-

Trying to help out a friend with a custom weapon mod he's putting together, would really appreciate the assistance. :)

Naydef
06-23-2016, 09:29
Game?
If tf2, use TF2Attributes to change different attributes(ammo, health, damage amount)
If not, use SDKHooks

JRDS
06-25-2016, 22:02
TF2

If I use TF2Attributes, don't I have to modify every weapon individually? Instead of being able to do a "type" of weapon?

nosoop
06-26-2016, 11:48
You can check the weapon class using GetEntityClassname. There's no consistent way to do all sorts of attribute changes for a specific weapon class.


#include <tf2_stocks>
#include <tf2attributes>

public void OnPluginStart() {
HookEvent("post_inventory_application", OnInventoryApplied);
}

public void OnInventoryApplied(Event event, const char[] name, bool dontBroadcast) {
int client = GetClientOfUserId(event.GetInt("userid"));
int hWeapon = GetPlayerWeaponSlot(client, TFWeaponSlot_Primary);

if (IsSyringeGun(hWeapon)) {
// apply damage modifier attribute here, will probably override existing damage modifiers
}
}

bool IsSyringeGun(int hWeapon) {
char weaponClass[32];
return GetEntityClassname(hWeapon, weaponClass, sizeof(weaponClass)) && StrEquals(weaponClass, "tf_weapon_syringegun_medic");
}

// or you can scale damage by hooking OnTakeDamage and checking the source of the attack in some way, I don't know how syringe guns and their projectiles handle it off the top of my head