custom_weaponry
This is an old revision of the document!
Custom Weaponry
You can create custom weaponry from deriving from one of the following classes: - Gun - Melee - Weapon - Carriable Gun provides common useful methods such as ShootBullet that gun like weapons would find useful (derived from Weapon) Melee has an Attack method (derived from Weapon) Weapon provides reload and ammo system and no more (derived from Carriable) Carriable provides nothing, its a bare bones thing that goes into your inventory and has a viewmodel
heres an example weapon you might find helpful
using Editor; using Sandbox; namespace MyGame; [Library("ttt_weapon_overpowered"), HammerEntity] [Title("Overpowered Weapon"), Category("Weapons")] public class OverpoweredWeapon : Gun, ISecondaryWeapon, IRandomWeapon { public override string ViewModelPath => "weapons/rust_pistol/v_rust_pistol.vmdl"; public override string WorldModelPath => "weapons/rust_pistol/rust_pistol.vmdl"; public override float PrimaryAttackDelay => 0.000f; public override float PrimaryReloadDelay => 0.000f; public override int MaxPrimaryAmmo => 100000; public override AmmoType PrimaryAmmoType => AmmoType.Spare; public override float HeadshotMultiplier => 10.00f; public override bool Automatic => true; public override void PrimaryAttack() { PrimaryAmmo -= 1; ShootBullet(1000, 0.0f, 1000); PlaySound("rust_pistol.shoot"); (Owner as AnimatedEntity)?.SetAnimParameter("b_attack", true); ShootEffects(); } public override void ReloadPrimary() { base.ReloadPrimary(); } }
custom_weaponry.1684542087.txt.gz · Last modified: 2023/05/20 00:21 by frank_lee_smith