custom_weaponry
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| custom_weaponry [2023/06/12 10:49] – frank_lee_smith | custom_weaponry [2026/05/01 23:26] (current) – frank_lee_smith | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Custom Weaponry ====== | + | coming soon when facepunch lets us do addons |
| - | You can create custom weaponry from deriving from one of the following classes: | + | |
| - | * Gun (Gun provides common useful methods such as ShootBullet that gun like weapons would find useful, it is derived from Weapon) | + | |
| - | * Melee (Melee has an Attack method, it is derived from Weapon) | + | |
| - | * Weapon (Weapon provides reload and ammo system and no more, it is derived from Carriable) | + | |
| - | * 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 | + | |
| - | <code csharp> | + | |
| - | using Editor; | + | |
| - | using Sandbox; | + | |
| - | using TerrorTown; | + | |
| - | + | ||
| - | [Library(" | + | |
| - | [Title(" | + | |
| - | public class OverpoweredWeapon : Gun, ISecondaryWeapon, | + | |
| - | { | + | |
| - | public override string ViewModelPath => " | + | |
| - | public override string WorldModelPath => " | + | |
| - | 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, | + | |
| - | PlaySound(" | + | |
| - | (Owner as AnimatedEntity)? | + | |
| - | ShootEffects(); | + | |
| - | } | + | |
| - | public override void ReloadPrimary() | + | |
| - | { | + | |
| - | base.ReloadPrimary(); | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | if you would like to make a scope similar to the one on the m24, you can use this code snippet taken from the m24 | + | |
| - | <code csharp> | + | |
| - | public override void SecondaryAttack() | + | |
| - | { | + | |
| - | base.SecondaryAttack(); | + | |
| - | if ( Game.IsClient ) | + | |
| - | { | + | |
| - | if ( !Scoped ) | + | |
| - | { | + | |
| - | ScopeIn(); | + | |
| - | } | + | |
| - | else if ( Scoped ) | + | |
| - | { | + | |
| - | ScopeOut(); | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| - | ScopeOverlay ScopeOverlay; | + | |
| - | void ScopeIn() | + | |
| - | { | + | |
| - | Scoped = true; | + | |
| - | (Owner as Player).CameraController.SensitivityMultiplier = 25 / Game.Preferences.FieldOfView; | + | |
| - | (Owner as Player).CameraController.FOVMultiplier = 25 / Game.Preferences.FieldOfView; | + | |
| - | if ( Game.IsClient ) | + | |
| - | { | + | |
| - | ViewModelEntity.EnableDrawing = false; | + | |
| - | ScopeOverlay = new ScopeOverlay(); | + | |
| - | HUDRootPanel.Current.AddChild( ScopeOverlay ); | + | |
| - | PlaySound( " | + | |
| - | } | + | |
| - | } | + | |
| - | void ScopeOut() | + | |
| - | { | + | |
| - | Scoped = false; | + | |
| - | (Owner as Player).CameraController.SensitivityMultiplier = 1; | + | |
| - | (Owner as Player).CameraController.FOVMultiplier = 1; | + | |
| - | if ( Game.IsClient ) | + | |
| - | { | + | |
| - | ViewModelEntity.EnableDrawing = true; | + | |
| - | ScopeOverlay? | + | |
| - | PlaySound( " | + | |
| - | } | + | |
| - | } | + | |
| - | public override void OnActiveEnd() | + | |
| - | { | + | |
| - | ScopeOverlay? | + | |
| - | if ( Owner is Player player ) | + | |
| - | { | + | |
| - | player.CameraController.SensitivityMultiplier = 1; | + | |
| - | player.CameraController.FOVMultiplier = 1; | + | |
| - | } | + | |
| - | base.OnActiveEnd(); | + | |
| - | + | ||
| - | } | + | |
| - | </ | + | |
custom_weaponry.1686566963.txt.gz · Last modified: 2023/06/12 10:49 by frank_lee_smith