Resource icon

[VScript] give_tf_weapon 5.4.3

  • Updated "RegisterCustomWeapon".
    • Removed "RegisterCustomWeaponEx" code because it was redundant
      • It still works, however.
    • Fixed bug where registering through console threw an error
  • Updated "GiveWeapon".
    • Added extra switches and parameters for custom weapons.
    • GiveWeapon (weapon_name, bool force_overwrite, bool force_clear_stats, bool force_custom, function force_stats_function, string force_class_arms, string force_custom_w_model, string force_custom_v_model, string force_extra_wearable, int force_ammotype, int force_clipsize, int force_ammoreserve)
      • These can be added or excluded from the function.
      • i.e. If in MvM and Engineer, can give yourself this weapon like in the attached screenshot:
      • ME.GiveWeapon("Wrench",false,true,true,null,GTFW_ARMS.SOLDIER,"models/weapons/c_models/c_shovel/c_shovel.mdl")
      • But also ME.GiveWeapon("Wrench") still works
  • Made script more compatible with MvM/Upgrade stations (see above)
  • Fixed bug where taunting after switching from a custom weapon would make the active weapon invisible
  • Fixed CTFPlayer.HasGunslinger throwing a lot of errors
  • Removed some error throws
  • Cleaned up code

Attachments

  • mvm_lost_a10003.jpg
    mvm_lost_a10003.jpg
    581.9 KB · Views: 126
  • Trying to get it compatible with MvM / upgrade stations.
    • Added variable CVAR_GTFW_OVERWRITE_WEAPONS under _master.nut
      • true by default
      • true = weapon in slot is deleted before making the new weapon (via GiveWeapon)
      • false = weapon in slot is not deleted. Instead, the item definition index is changed so the weapon can store upgrades from upgrade stations. It supports custom weapons, too!
        • (it's recommended to reset the stats by using this code:
        • NetProps.SetPropBool(handle hWeapon, "m_AttributeManager.m_Item.m_bOnlyIterateItemViewAttributes", true)
  • Fixed CTFPlayer.SwitchToActive(wep)
  • Added ficool2 fix for handling spy watches

Attachments

  • mvm_aeon_a17_1.png
    mvm_aeon_a17_1.png
    895.8 KB · Views: 147
  • Updates tables.nut
    • Removed all ID2's from every weapon entry that had null in them.
    • Made any unique stock weapon into it's own entry. Each stock weapon is another entry named "Unique <weapon>".
      • Some promos were also made into another entry (Vintage Lugermorph, Genuine Huo-Long Heater, etc)
    • Removed Festives class (removed bc it was a dupe)
      • Moved all entries into TF_WEAPONS class + TF_WEAPONS_ALL array
    • Fixed "Grappling Hook" having an extra space in classname, causing giving the weapon to fail.
  • Updated code.nut to reflect above changes.
  • Added support for tf_bots using this script (thanks Mr.Burguers)
  • Added descriptions in tables.nut
  • Fixed Liberty Launcher saying it had 60 ammo reserve
  • Fixed Quickiebomb Launcher saying it had 72 reserve ammo
  • Fixed weapon's ammo reserve multiplying if weapon had an ammo reserve bonus (i.e. Rocket Jumper)
  • Fixed clip size attributes not applying correctly
REORGANIZED PARAMETERS OF RegisterCustomWeapon() and RegisterCustomWeaponEx()!
  • New param order for RegisterCustomWeapon():
( item_name, baseitem, use_original_stats, stats_function, custom_arms_model, custom_weapon_model )​
  1. Added: use_original_stats = bool. If true, uses the original stats of the weapon. If false, wipes it clean (as if stock) so new stats can be applied.
  2. Removed: extra_custom_wearable. It's now only in the Ex version.
  3. Swapped: custom_arms_model and custom_weapon_model
  • New param order for RegisterCustomWeaponEx():
( item_name, baseitem, use_original_stats, stats_function, custom_arms_model, custom_weapon_worldmodel, custom_weapon_viewmodel, custom_extra_wearable, ammotype, clipsize, ammoreserve)
  • Basically same as above but with the extra things tacked on to the end.

Rest of the 3.0 Update
  • Fixed bug where all given weapons don't have new stats.
    • Seems setting the following netprop to 1 does this:
      • m_AttributeManager.m_Item.m_bOnlyIterateItemViewAttributes
  • Fixed all Spy's watches not using correct animations
  • Added another tutorial "custom_weapons.nut"
  • Fixed some things throwing "Instance does not exist" when switching weapons
  • Moved all files into a folder! And added a "master" file.
    • Folder is /give_tf_weapon/
    • Execute _master.nut to get the script running!
  • Added a readme.
  • Fixed Pyro's Hottest Hand throwing errors when dying.
  • Fixed any custom weapon throwing errors when dying.
  • Updated CTFPlayer.SwitchToActive(weapon)
    • Finds the best weapon to switch to and switches to it.
    • If null, switches to the any valid gun, or if no gun is found, switches to melee, or else, any.
  • Added more error checks
  • Custom/Unintended weapons for classes now set by netprop m_iItemIDHigh
    • If m_iItemIDHigh bit 5 set, it's unintended for the class.
    • If m_iItemIDHigh bit 6 set, it's a custom weapon.
  • Turned off CVAR_GTFW_USE_GLOBAL_ERROR_MESSAGES because I forgot to turn it off
  • Added CTFPlayer.CreateArmsModel(arms_model)
    • Experimental. Overwrites the arms model for the class with another set of arms.
      • NOTE: When used, it adds an ent (tf_weapon_vm) per weapon on the player.
      • Needs to be set every time the class touches the resupply, else weapons in VM will be invisible.
  • Fixes DeleteWeapon, DisableWeapon, EnableWeapon from finding classnames instead of ItemIDs.
    • No more DeleteWeapon("Rocket Jumper") deleting all rocket launchers.
  • Added a way to set custom weapon view model for custom weapons. (Requested by @ImNotSimon )
    • Set it using RegisterCustomWeaponEx()
    • The weapon model parameters will copy over to one another if the other is blank.
    • For example, if world model isn't set, but viewmodel is, it'll use the viewmodel for both world model and view model. Works vice-versa.
  • Fixed Scout's Bat being an invalid index for GiveWeapon/ReturnWeaponTable
  • Got rid of all instances of table PlayerLoadOutGlobal_ClassArms.
    • The table was for setting class arms for the player's main view model, but it is unneeded now that SetCustomViewModel() exists.
    • This should fix any type of "instance doesn't exist" errors when switching weapons.
  • Fixed custom arms model not working if it was the only parameter in RegisterCustomWeapon().
  • Added extra check in viewmodel think script, to prevent an error.