Anathema Weapon Base - I've stopped working on it edition

People have been adding me with questions about my weapon base. Some of them were using my atrocious unnetworked version from the past back when I didn’t know about network variables. Some of them were asking about the .zip file I randomly dropped in the WAYWO thread after calling it quits. Here’s a proper thread. (The first video doesn’t have the finalized recoil patterns, spread, and stuff.)

This is an old project I’ve worked for years now. I’ve got no interest in doing much more with this and I’m providing it to the public as a potential base for advanced scripted weaponry.

What’s it got?

  • Tons of variables
  • Hit-scan based bulletdrop
  • Weapon “modes” for sprinting, ironsights, crouching, etc. (variables for movement speed, accuracy, etc.)
  • Dynamic recoil patterns (increases or decreases based on mode and player velocity) (Note that I have it set to randomly flip or scale as well! If you don’t like that, fix it.)
  • Dynamic spread (increases or decreases based on mode and player velocity)
  • Potentially great or bad networking (dunno, haven’t really tested)
  • Lua-based viewmodel animations
  • Things
  • Stuff
  • Example weapons/effects
  • Custom muzzle flashes (made by yours truly)
  • Custom tracers
  • Scope
  • Support for CS:S Shotgun animations

Even if the networking is garbage or if it’s full of other problems, chances are you can rip certain aspects out of this as you see fit. I don’t reccomend this for people who aren’t up for fixing things.

I may return to this project later down the road but I’m not satisfied with Garry’s Mod in it’s current limited state, specifically with lack of support for custom animations and SWEP inheritence. I am excited for Garry’s vision for a Source 2 variant of Garry’s Mod, but that’s besides the point.

I’ll take pull requests as well, so if you know how to make this project better in anyway, feel free to share.

Oh, and here’s the insane amount of variables because I’m that insane of a guy:


--[[
  _|_|                          _|      _|                                    _|_|    
_|    _|  _|_|_|      _|_|_|  _|_|_|_|  _|_|_|      _|_|    _|_|_|  _|_|    _|    _|  
_|_|_|_|  _|    _|  _|    _|    _|      _|    _|  _|_|_|_|  _|    _|    _|  _|_|_|_|  
_|    _|  _|    _|  _|    _|    _|      _|    _|  _|        _|    _|    _|  _|    _|  
_|    _|  _|    _|    _|_|_|      _|_|  _|    _|    _|_|_|  _|    _|    _|  _|    _|
    Scripted Weapon Base by wauterboi
]]--

SWEP.Anathema   =   true

-- Tables *DO NOT TOUCH*

    SWEP.Mode                           = { } 
        SWEP.Mode.Ducking               = { }
        SWEP.Mode.Ironsight             = { }
        SWEP.Mode.Walking               = { }
        SWEP.Mode.Sprinting             = { }
        SWEP.Mode.Misc                  = { }
    SWEP.Primary                        = { }
        SWEP.Primary.Damage             = { }
        SWEP.Primary.Recoil             = { }
        SWEP.Primary.Recoil.Pattern     = { }
        SWEP.Primary.Recoil.Pattern.X   = { }
        SWEP.Primary.Recoil.Pattern.Y   = { }
        SWEP.Primary.Spread             = { }
        SWEP.Primary.BulletDrop         = { }
        SWEP.Primary.Reload             = { }
        SWEP.Primary.Sound              = { }
        SWEP.Primary.Effect             = { }
        SWEP.Primary.Scope              = { }
        SWEP.Primary.Scope.Sound        = { }

-- Customizable Variables

    -- Basic Information

        SWEP.PrintName      =   "AnathemA Weapon Base"
        SWEP.Author         =   "wauterboi"
        SWEP.Instructions   =   ""

    -- View/World Model

        SWEP.ViewModel      =   "models/weapons/v_rif_ak47.mdl"
        SWEP.ViewModelFOV   =   80
        SWEP.ViewModelFlip  =   true

        SWEP.WorldModel     =   "models/weapons/w_rif_ak47.mdl"

    -- Scope Variables

        SWEP.Primary.Scope.Draw         = true
        SWEP.Primary.Scope.BG           = Material( "anathema/scope/scope_test" )       -- Wrap that string in Material( )
        SWEP.Primary.Scope.Refract      = Material( "anathema/scope/scope_refract" )       -- Wrap that string in Material( )
        SWEP.Primary.Scope.FG           = Material( "anathema/scope/scope_test_crosshair" )       -- Wrap that string in Material( )
        SWEP.Primary.Scope.FOV          = 10
        SWEP.Primary.Scope.WhileFiring  = true
        SWEP.Primary.Scope.Sound        = {
            "player/taunt_equipment_gun1.wav",
            "player/taunt_equipment_gun2.wav"
        }

    -- Sound

        SWEP.Primary.Sound.Shoot    =   "weapons/pistol/pistol_fire2.wav"
        SWEP.Primary.Sound.Empty    =   "Weapon_Pistol.Empty"

    -- Effect

    SWEP.Primary.Effect.MuzzleFlash     =   {
        "anathema/sprites/muzzle/anim_muzzle1_01",
        "anathema/sprites/muzzle/anim_muzzle1_02",
        "anathema/sprites/muzzle/anim_muzzle1_03",
        "anathema/sprites/muzzle/anim_muzzle1_04",
        "anathema/sprites/muzzle/anim_muzzle1_05",
        }
    SWEP.Primary.Effect.MuzzleSmoke     =   "particles/smokey"
    SWEP.Primary.Effect.MuzzleEffect    =   "awb_muzzle_rifle"

    -- Reload Speeds

        SWEP.Primary.Reload.ShotgunReload = false   -- This, and the following three variables, are EXPLICITLY for CS:S Shotgun Reload animations.
        SWEP.Primary.Reload.StartAnimDur   =   .25
        SWEP.Primary.Reload.ReloadAnimDur  =   .5
        SWEP.Primary.Reload.FinishAnimDur  =   .5

    -- Gun Modes

        SWEP.Mode.Ducking.Pos           = Vector( 0, 5, 3 )
        SWEP.Mode.Ducking.Ang           = Angle( -4, 4, 2 )
        SWEP.Mode.Ducking.AnimDur     = 1
        SWEP.Mode.Ducking.HoldType      = "smg"
        SWEP.Mode.Ducking.FOV           = 80    -- If using a scope, you keep this the same as the ironsight FOV
        SWEP.Mode.Ducking.FOVSpeed      = 2
        SWEP.Mode.Ducking.WalkSpeed     = 100
        --[[ ! ]] SWEP.Mode.Ducking.DuckSpeed     = 0.3   -- Sets how long it takes for the player to enter the ducking position.

        SWEP.Mode.Sprinting.Pos         = Vector( -10, 0, 0 )
        SWEP.Mode.Sprinting.Ang         = Angle( 0, -70, 10 )
        SWEP.Mode.Sprinting.AnimDur   = 16
        SWEP.Mode.Sprinting.HoldType    = "passive"
        SWEP.Mode.Sprinting.FOV         = 100
        SWEP.Mode.Sprinting.FOVSpeed    = 32
        SWEP.Mode.Sprinting.WalkSpeed   = 250

        SWEP.Mode.Ironsight.Pos         = Vector( -3, 6.1, 2 )
        SWEP.Mode.Ironsight.Ang         = Angle( 3, -.125, 0 )
        SWEP.Mode.Ironsight.AnimDur   = 1
        SWEP.Mode.Ironsight.FocusDur  = .5        -- Length of transition to focus in scope
        SWEP.Mode.Ironsight.HoldType    = "smg"
        SWEP.Mode.Ironsight.FOV         = 75
        SWEP.Mode.Ironsight.FOVSpeed    = 0.5
        SWEP.Mode.Ironsight.WalkSpeed   = 125
        SWEP.Mode.Ironsight.Sensitivity = .125    -- Multiplier of normal sensitivity when aiming

        SWEP.Mode.Walking.Pos           = Vector( 0, 0, 0 )
        SWEP.Mode.Walking.Ang           = Angle( 0, 0, 0 )
        SWEP.Mode.Walking.AnimDur     = 2
        SWEP.Mode.Walking.HoldType      = "shotgun"
        SWEP.Mode.Walking.FOV           = 90
        SWEP.Mode.Walking.FOVSpeed      = 1
        SWEP.Mode.Walking.WalkSpeed     = 200
        --[[ ! ]] SWEP.Mode.Walking.WaterSpeed    = 125

        SWEP.Mode.Misc.Pos              = Vector( -10, 0, -10 )
        SWEP.Mode.Misc.Ang              = Angle( 0, -70, 10 )
        SWEP.Mode.Misc.AnimDur        = 2
        SWEP.Mode.Misc.FOV              = 90
        SWEP.Mode.Misc.FOVSpeed         = 1
        SWEP.Mode.Misc.WalkSpeed        = 100

    -- Firerate

        SWEP.Primary.Delay      =   0.125       -- Firerate
        SWEP.Primary.FirstDelay =   0.2         -- Amount of time that differentiates different sessions of firing
                                                -- This allows the recoil ramping to reset
        SWEP.Primary.Automatic  =   true        -- There is no reason to set this to false
        SWEP.Primary.NumBullets     =   1

    -- Ammo

        SWEP.Primary.Ammo       =   "SMG1"
        SWEP.Primary.ClipSize   =   16
        SWEP.Primary.DefaultClip=   64

    -- Damage

        -- Max damage is done CLOSE and min damage is done FAR

        SWEP.Primary.Damage.MaxDamage       =   100
        SWEP.Primary.Damage.MaxDamageDist   =   64
        SWEP.Primary.Damage.MinDamage       =   75
        SWEP.Primary.Damage.MinDamageDist   =   512

    -- Recoil and Inaccuracy

        -- Starts at BaseX and moves up to MaxX over TimeToMax
    
        SWEP.Primary.Recoil.BaseKick    = 1
        SWEP.Primary.Recoil.MaxKick     = 1
        SWEP.Primary.Recoil.TimeToMax   = 1

        SWEP.Primary.Recoil.IronMult    = .5    -- How much to reduce the recoil when aiming down sights/scope

        SWEP.Primary.Recoil.Pattern.X.Wave  =   "sin"
        SWEP.Primary.Recoil.Pattern.X.Abs   =   true
        SWEP.Primary.Recoil.Pattern.X.Freq  =   3
        SWEP.Primary.Recoil.Pattern.X.Amp   =   1.5

        SWEP.Primary.Recoil.Pattern.Y.Wave  =   "sin"
        SWEP.Primary.Recoil.Pattern.Y.Abs   =   true
        SWEP.Primary.Recoil.Pattern.Y.Freq  =   4
        SWEP.Primary.Recoil.Pattern.Y.Amp   =   2

        SWEP.Primary.Spread.BasePrec    = 0.1
        SWEP.Primary.Spread.MaxPrec     = 1
        SWEP.Primary.Spread.TimeToMax   = 1

    -- Bullet Drop

        -- At how many source units will the bullet hit the ground when shooting up at a 45 degree angle?

        SWEP.Primary.BulletDrop.Dist    = 8000

    -- Disable Secondary (do not touch)

        SWEP.Secondary.ClipSize     = -1
        SWEP.Secondary.DefaultClip  = -1

    -- Console Prefix and colors

        SWEP.Console = { }
            SWEP.Console.Prefix  =   "[AnathemA]"
            SWEP.Console.Colors  =   { }
                SWEP.Console.Colors.Prefix      =    Color( 255, 255, 255 )
                SWEP.Console.Colors.MoveAlert   =    Color( 203, 165, 84 )
                SWEP.Console.Colors.ModeAlert   =    Color( 253, 217, 155 )
                SWEP.Console.Colors.FuncAlert   =    Color( 244, 245, 55 )
                SWEP.Console.Colors.AttackAlert =    Color( 250, 39, 114 )



Holy Variables Batman! Thank you. I’ve been looking for such a tweaked weapons base for a while. +1 for detailed commented out code

Thanks. I think I’ve laid some groundwork for someone better to build off of. I don’t think it’s perfect, but someone will figure out how to make it so.