Resource icon

[VScript] give_tf_weapon GTFW is now Retired

  • Removed all instances of needing draw sequences
    • All weapon's models use SetCustomViewModel() now!
    • Note to users with RegisterCustomWeaponEx(): No longer needs draw sequnce param at the end.
  • Updated GiveWeapon() viewmodels to use v_models, and world models to use w_models (if both aren't just c_models)

Attachments

  • 10.png
    10.png
    2.1 MB · Views: 61
  • give_tf_weapon.nut: Added more documentation, reorganized the function order and improved readability across the entire document.
  • Added more error messages and cancellations of functions if an error occurred.
  • Fixed bug where weapon wouldn't actually update the draw sequence nor arms correctly
  • Fixed bug with giving a weapon to a class with a weapon that was in a slot that didn't already have a weapon
  • Added new CVAR to enable global debug messages
    • CVAR_GTFW_USE_GLOBAL_ERROR_MESSAGES
    • True by default.
  • Fixed special case where weapons would not update.
    • Was related to UpdateArms() checking a weapon that didn't exist on a predefined list.
    • UpdateArms() no longer checks for this.
  • Fixed all weapon commands not being able to accept handles.
  • Updated documentation.
  • Fixed Warpainted weapons returning invalid item string when used
  • Added Festive Shotgun to the list.
  • Fixed shotguns not deleting the right weapon as certain classes.
  • Fixed lingering bug from 1.8:
If you are a Scout/Medic/Sniper and give yourself the Saxxy, the draw animation will be bugged. However by giving yourself the Saxxy again, it fixes the animation.
This has been fixed in 2.0.1.
  • Rewrote GiveWeapon() code
    • Fixed custom weapon arms not updating
    • Fixed custom weapon deploy animations not updating
    • Fixed some parts in the code that were running twice
  • Rewrote SwitchToActive()
  • Added new function RegisterCustomWeaponEx(), which includes being able to change weapon's ammo type, clip size, ammo reserve and draw sequence.
  • Fixed ammo stats updater placing attributes on weapon instead of invisible AmmoFix tf_wearable.
  • Fixed ammo stats updater giving ammo to the metal-type weapons (Widowmaker, PDAs, Wrenches, etc) after one was already equipped
  • Fixed bug where searching for ItemIDs would net you a custom weapon
    • Custom weapon IDs have bit 20 set, so they don't conflict with other weapons.
  • Deleted SetCustomWeapon()
  • Updated custom weapon examples
    • "Scout Crossbow" now updates ammo through RegisterCustomWeaponEx()
    • "Horsemann's Hex" now reverts Demo back if he loses the weapon.
    • "Hottest Hand" shoots from the hands at any player scale.

TO-DO LIST
  • Find a way to add/detect wearables like demoshield, booties, razorback, etc
  • Fix custom weapon's crit boost glows
  • Giving class with passive items (Targe, Razorback, etc) need extra check when deleting secondaries because they're not in m_hMyWeapons
  • CVAR to keep weapons on resupply
  • Stray from using netprop m_bOnlyIterateItemViewAttributes because it's used by tf_dropped_weapon.
Have fun with making custom weapons!

Attachments

  • 7.png
    7.png
    2.6 MB · Views: 56
  • 8.png
    8.png
    2 MB · Views: 49
  • 9.png
    9.png
    2.5 MB · Views: 52
  • Removed CTFPlayer.GiveWeaponEx().
    • Function was redundant, and can be done better using basic functions as building blocks to do the same thing.
    • Please refer to the examples in give_tf_weapon_examples.nut to replicate this functionality.
  • Fixed ReturnWeapon() returning weapon by classname instead of weapon ID
  • Rewrote some documentation.
  • Added CTFPlayer.CreateCustomWearable(weapon, wearable_model)
    • Creates a tf_wearable and associates it with a weapon (if valid)
    • weapon accepts arg null.
  • Changed CTFPlayer.DisableWeapon() and CTFPlayer.EnableWeapon()
    • DisableWeapon() now removes all ammo reserve and clip, and sets maxammo reserve to 0 to prevent picking up ammo.
    • EnableWeapon() removes the maxammo penalty to restore functionality.
    • Both functions add a tf_wearable (if one didn't exist) that modifies the ammo. It uses outputs "OnUser" to check if the attribute was applied or not.

Special thanks @LizardOfOz for the bug reports.
  • Added better documentation in give_tf_weapon_custom.nut
  • Added another example weapon: Pyro's Hottest Hand.
    • Shoots fireballs, like Street Fighter! Hadouken!
    • Use hPlayer.GiveWeapon("Hottest Hand") to give yourself the weapon.
  • Fixed bug with switching to active weapons not switching to melees
There is a bug roaming about that I haven't figured out yet: If you are a Scout/Medic/Sniper and give yourself the Saxxy, the draw animation will be bugged. However by giving yourself the Saxxy again, it fixes the animation.

Attachments

  • 6.png
    6.png
    940.8 KB · Views: 60
  • Made metal capacity fix only increase metal if using a metal ammotype weapon (i.e. PDAs, wrenches, Widowmaker...)
  • Fixed bug with metal ammotype weapons that are not melee would be switched to with no ammo.
    • Updated documentation a little bit to reflect these changes
  • Fixed custom weapons becoming visible immediately on spawn
  • Fixed custom weapons not certain params were missing
  • Fixed class TF_WEAPONS_BASE not being in roottable in file give_tf_weapon_all.nut
    • Should now work in Hammer