Skip to content

Simple framework for changing built-in values of any entity in GMod.

License

Notifications You must be signed in to change notification settings

CFC-Servers/cfc_entity_stubber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

cfc_entity_stubber

Ever needed to make tweaks to existing weapon packs, but don't want to self-host it? Entity Stubber is for you! With Entity Stubber, you can make modifications to any entity on your server with minimal coding. Here's how:

Let's say you have a M9k Ak47 that does too much damage. You would register the stub as:

lua/cfc_entity_stubber/stubbers/cw_stubber.lua would be:

AddCSLuaFile()
cfcEntityStubber.registerStubber( "m9k" )

lua/cfc_entity_stubber/cw/cw_ak74.lua would be:

AddCSLuaFile()

cfcEntityStubber.registerStub( function()
    local weapon = cfcEntityStubber.getWeapon( "m9k_ak47" )
    weapon.Primary.KickDown = 0.1
    weapon.Primary.Damage = 10000
    weapon.Primary.Spread = .08
end )

Used by

https://github.com/CFC-Servers/cfc_entity_stubber_ttt

https://github.com/CFC-Servers/cfc_entity_stubber_build_kill

Description

This addon allows creation of "stubbers" and "stub" files. Stubbers are used to create functions for the specific stub files. Stub files allow the editor to make specific changes on weapons / entities without modifying the code of the entity.

The stubs are applied after all entities are loaded during server startup, or on client after all entities initialized.

Inner workings

  1. The main stubber gets loaded and includes for all files in:

     lua/cfc_entity_stubber/stubbers
    
  2. The main stubber looks through all the folders that the stubbers registered.

    Looking at files in and it's 1 depth sub folders and registering the files found.

     lua/cfc_entity_stubber/stubname
    
  3. The main stubber includes all files found.

This happens on InitPostEntity for both client and server.

Existing stubber examples ( M9k, CW, CW Attachments )

M9k:

AddCSLuaFile()

cfcEntityStubber.registerStub( function()
    local weapon = cfcEntityStubber.getWeapon( "m9k_ak47" )
    weapon.Primary.KickDown = 0.1
    weapon.Primary.Damage = 10000
    weapon.Primary.Spread = .08
end ) 

CW:

AddCSLuaFile()

cfcEntityStubber.registerStub( function()
    local weapon = cfcEntityStubber.getWeapon( "cw_ak74" )
    weapon.Shots = 1
    weapon.Damage = 20
    weapon.PrintName = "Stubbed gun!"
end )

CW Attachments:

AddCSLuaFile()

cfcEntityStubber.registerStub( function()
    local attachment = cfcEntityStubber.getAttachment( "bg_longbarrel" )

    attachment.statModifiers = {
        AimSpreadMult = -0.1,
        DamageMult = 100,
        OverallMouseSensMult = -0.1,
        RecoilMult = 0.1
    }

    cfcEntityStubber.applyAttachmentChange( attachment )
end )

About

Simple framework for changing built-in values of any entity in GMod.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages