Pill Framework



I’m releasing the unfinished beta of my Pill Framework. I’m working on so many other things now that I doubt I’ll have time to finish it anytime soon. That’s why I figured it would be unfair to keep it to myself so here you are. It works as far as I can tell. Post here if you find any problems.

What is this?
This is a weapons framework designed for making pill SWEPs. The Pill framework comes with a wide variety of features to accomodate all sorts of pills. Making your own pill can be as easy as changing variables.

Here’s some eye candy.

http://www.youtube.com/watch?v=3yiq72ITflw[/media] [media]http://www.youtube.com/watch?v=j9Mg1_gNyxY

Extract to your garrysmod folder. Includes the framework and two unfinished sample pills. Pills are in the lua/pills folder.

Need help understanding the framework?
Post here, PM me, or shoot me a message on steam and I’ll gladly help you (if I’m not too busy).

Awesome work! Can’t wait to see what comes out of this.

Thanks. I hope to see some pill packs made using this.




Oh yeah, and here’s how you’d make a pill.

  1. Go into lua/pills.
  2. Make a new folder. Call it pill_whatever or something.
  3. In the folder, make two files - pill.lua and actions.lua.

Here are the base pill and base actions files. You can copy/paste it, remove all the stuff you don’t need, and edit it to your liking.

Your pill.lua file:
// General
PILL.Base = “pill_base” – This works just like SWEP.Base. Yes, pills have their own BaseClass.
PILL.DisplayName = “Base Pill” – Pill nice-name
PILL.PlayerModel = “” – The pseudo player model file path
PILL.Author = “” – Pill Author
PILL.Contact = “” – Author contact
PILL.Purpose = “” – Pill Purpose
PILL.Instructions = “” – Pill Instructions
PILL.SpawnIcon = “” – The icon you’d see in the spawn menu
PILL.SelectIcon = “j” – The weapon select icon.
PILL.AdminOnly = true – Use this for admin sweps.

// SWEP Table - Use this to override SWEP properties and functions.
// Please use PILL Think, OnPrimary, OnSecondary, OnReload, CanDeploy, CanHolster, OnDeploy, and OnHolster rather than overriding.
PILL.SWEP.Spawnable = false
PILL.SWEP.AdminSpawnable = false

// Misc Values
//PILL.CanEnterVehicle = false – Don’t let players enter vehicles.
PILL.UseBlood = true – When true, we use can blood effects
PILL.UseCharacterEntity = true – Use a character entity? If you don’t, you’ll need to script all the rendering from scratch.
PILL.UseCharacterEntityHull = true – Use the character entity hull for player collisions.
//PILL.UseCustomBloodEffect = false – Assuming PILL.UseBlood is true, this overrides the default blood effects and uses PILL.Effects.Blood as a replacement.
//PILL.UseSimpleMovement = false – When set to true, the pill will disable all custom move hooks. Instead, you’ll use the PILL.Movement table for movement modification.
//PILL.UseCharacterEntityMovement = false – This is only to be used when you are using a custom character entity like a SENT or a prop_physics.
//PILL.UseThirdPersonView = true – When set to false, the default CalcView hooks will get disabled. This does not include PILL.CalcView (which is blank by default) or any action CalcView hooks.

PILL.CanDuck = false – A lot of stuff can’t duck (headcrabs, etc.). This sets HullDuck to the normal Hull, and disables view changes to simulate no ducking. This allows us to detect the +duck key.
PILL.CanZoom = false – I doubt your pill will have binoculars, but maybe it will. Set this to true to reenable zoom.
PILL.CanJump = true – Can they use the default jump?

PILL.StartHealth = 100 – Starting health.
PILL.MaxHealth = 100 – Maximum health.
PILL.BloodColor = BLOOD_COLOR_RED – Assuming PILL.UseBlood is true, this sets the color. Check out http://wiki.garrysmod.com/?title=Enumeration_List:Blood_Color for the enum list.

//PILL.ShouldTakeDamage = true – When false, the player will not take damage.
//PILL.ShouldDrawLocalPlayer = false – Only set this to true if you are drawing the player and want to see them in your Third Person View
//PILL.ShouldDrawPlayer = false – Only set this to true if you are drawing the player

// Character Entity Handling
// This table controls how we handle the character entity for this pill.
//PILL.Character.OverrideEntityHandling = false – This overrides all character entity handling. You’ll need to write your own hooks. With this you could make a physical melon roller.
//PILL.Character.HidePlayerForPhysMove = true – If/when you try to hotswitch to physical movement, the player will be placed out of the way.
//PILL.Character.TransferDamageForPhysMove = true – If/when you use physical movement, the player will be given any damage the character entity recieves.
//PILL.Character.ClampCharacterPitch = true – When true, pitch will be clamped to 0 by default.
//PILL.Character.MaxYawBeforeTurn = 0 – Absolute yaw change before turning the character.
//PILL.Character.MaxPitchBeforeTurn = 0 – Absolute pitch change before turning the character. Only available when ClampCharacterPitch is false.
PILL.Character.ParentToPlayer = true – Parent it to player
PILL.Character.FadeCharacterEntity = true – When true, the character entity will fade as the camera gets closer to the model
PILL.Character.Movetype = MOVETYPE_NONE – Change this if you must.
PILL.Character.Solid = SOLID_NONE – Change this if you must.
PILL.Character.SurfaceProp = “flesh” – PhysObj material.
PILL.Character.CharacterEntity = “prop_pillcharacterentity” – If you want to give the pill a custom character entity. You’ll need to write your own hooks.

// Use this to override hull
// The script will only set the ones you use, so you can override normal and duck hulls separately.
//PILL.Hull.Normal = { Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) } – Normal hull. If PILL.Character.UseCharacterEntityHull is true, then using this will override that.
//PILL.Hull.Duck = { Vector( -16, -16, 0 ), Vector( 16, 16, 36 ) } – Hull while ducking. This is good to use if you know you want your character to duck, but it doesn’t have a hull specified for that animation.

// This table will override any custom CalcView hooks.
// This table should only be used when PILL.UseThirdPersonView is set to true
PILL.ThirdPersonView.VectorOffset = Vector( 0, 0, 0 ) – Vector offset from camera origin. This is applied before ThirdPersonView.Distance.
PILL.ThirdPersonView.AngleOffset = Angle( 0, 0, 0 ) – Angle offset from camera angles. This is applied before ThirdPersonView.Distance.
PILL.ThirdPersonView.Distance = -100 – Distance backwards from the VectorOffset in units.
PILL.ThirdPersonView.UseCharacterCenter = true – Use the character’s OBBCenter as the camera origin.
PILL.ThirdPersonView.AllowFullRotation = false – When set to true, the player can rotate the camera all the way around the character entity without it turning.

// This table will set movement characteristics.
// This table should only be used when PILL.UseNormalMovement is set to true
PILL.Movement.WalkSpeed = 250 – Speed while walking
PILL.Movement.RunSpeed = 500 – Speed while running
PILL.Movement.CrouchedWalkSpeed = 0.50 – Speed while crouched walking
PILL.Movement.CrouchedRunSpeed = 0.75 – Speed while crouched running
PILL.Movement.JumpPower = 160 – Jump power
PILL.Movement.StepSize = 18 – Step size.

// This table can be for personal utility. ChangeTo and ChangeFrom are automatically used in Deploy/Holster.
// Any effects you add to this table will be compatible with the SWEP.BangHowdy method
PILL.Effects.ChangeTo = “Sparks” – Effect to be played when changing to/from?
PILL.Effects.ChangeFrom = “Sparks” – Effect to be played when changing to/from?
PILL.Effects.Blood = “” – Internal member Blood - This effect replaces the default player blood effect. Only used when PILL.UseCustomBloodEffect is true. Check out http://wiki.garrysmod.com/?title=Util.Effect for a full list of default effects.

// This table is partly a personal utility for your use. It’s not required, but some of the sounds are used internally.
// The Deploy, Holster, Reload, Hurt, Death, and Footstep members are used internally, so fill them out and they will be used automatically.
// You may add your own sounds to this table as a personal utility to be played with PILL:PlaySound( sound, pitch, volume )
// To find the NPC sounds in their short versions like this, check out http://www.synergymod.net/docs_v11/?p=npcsounds
PILL.Sounds.Deploy = “Weapon_Bugbait.Splat” – Internal member Deploy - Play this when we take the weapon out
PILL.Sounds.Holster = “Weapon_Bugbait.Splat” – Internal member Holster - Play this when we put the weapon away
PILL.Sounds.Reload = “” – Internal member Reload - Play this when we reload
PILL.Sounds.Hurt = “” – Internal member Hurt - Play when hurt
PILL.Sounds.Death = “” – Internal member Die - Play when you die
PILL.Sounds.Footstep = “” – Internal member Footstep - Footstep sound to play in GM.PlayerFootstep

// Called on gamemode initialize
function PILL:Initialize()

// Called when the pill SWEP is spawned
function PILL:OnSpawn()

// Called when the pill SWEP is removed
function PILL:OnRemove()

// PILL HOOKS - Called from their corresponding internal versions.
// Only use these when you need them. Their very existence can override the internal methods.
// Most of these are also available in the actions system, which only overrides the internal methods as long as the particular action is being used.
function PILL:PlayerFootstep( ply, pos, foot, sound, volume, rf )
function PILL:DoPlayerDeath( ply, attacker, dmginfo )
function PILL:EntityTakeDamage( ent, inflictor, attacker, amount, dmginfo )
function PILL:CalcView( ply, origin, angles, fov )
function PILL:Move( ply, move )
function PILL:CreateMove( ucmd )
function PILL:HUDPaint()

// Called every frame from SWEP.Think
function PILL:Think()

// Called when the weapon deploys, but before OnDeploy. Return false to disable and halt deployment.
// This would be good for pills that require certain environmental conditions before they can be used
function PILL:CanDeploy()
return true

// Called when the weapon holsters, but before OnHolster. Return false to disable and halt holstering.
// This would be good for pills that require certain environmental conditions before they can be used
function PILL:CanHolster()
return true

// Called when the weapon deploys
// Run any code pertaining to when the SWEP is Deployed (pulled out)
function PILL:OnDeploy()

// Called when the weapon holsters
// Run any code pertaining to when the SWEP is Holstered (put away)
function PILL:OnHolster()

// Called from SWEP.PrimaryAttack
function PILL:OnPrimaryAttack()

// Called from SWEP.SecondaryAttack
function PILL:OnSecondaryAttack()

// Called from SWEP.Reload
function PILL:OnReload()


Your actions.lua file:

ACTION.Base = “action_base” – Derive from this action

// Called on gamemode initialize
function ACTION:Initialize()

// This is a function that is called every frame for every action to render the entity
function ACTION:RenderCharacterEntity( ply, ent )

-- You may leave this blank unless you want to add some special stuff like bone editing that ocurrs in more than one action
-- In my bird pill, I made the head turn when you aim the camera
-- That's the sorta stuff that you could do with this.


// This is called once every time the pill weapon is deployed to decide what action to start with.
function ACTION:Begin( ply, ent )

-- In here, decide which action to start with when the pill is deployed.
-- Since all of them will fail to call if you don't have a PillAction set, you need to set it here.
-- This gets called when the character entity is activated.

-- Use ply:SetPillAction( strAction ) to set it.


ACTION.Actions.MyAction = {} – Creates a new action.

// ShouldPerform is called first when the action is set, and then from SWEP:Think() as long as this is the current action.
// Every action NEEDS a ShouldPerform method. It is the logic behind the entire system.
function ACTION.Actions.MyAction:ShouldPerform( ply, ent )
– Basically, make a bunch of if statements.
– When you return false, make sure you use ply:SetPillAction( strAction ).
– I usually return true as a blanket statement in my logic, but do whatever works for you.
– Example:
–[[if ent:WaterLevel() > 1 then
ply:SetPillAction( “Swim” )
return false
if !ply:OnGround() then
ply:SetPillAction( “Jump” )
return false
if ply:GetVelocity():Length() > 10 then
ply:SetPillAction( “Walk” )
return false
return true]]
function ACTION.Actions.MyAction:CalcView( ply, origin, angles, fov )
function ACTION.Actions.MyAction:Move( ply, move )
function ACTION.Actions.MyAction:CreateMove( ply, ucmd )
function ACTION.Actions.MyAction:Render( ply, ent )
function ACTION.Actions.MyAction:Think( ply, ent )
function ACTION.Actions.MyAction:HUDPaint( ply )


Some of the features may not work. As I said, the script isn’t exactly finished.

Omg. :iia:

Remind me of my first pills done with the hellknight and pinky monster from doom3 xD.

Exelent job btw ^^

Thanks! I’m hoping some people will remake the old pills with this. :buddy:

Who knows, maybe I will! :DD

I wish cringerpants hadn’t disappeared. :frown:

Lol, me too…

This will be interesting. :slight_smile: Thanks a lot for this, Greasemonkey.

Yeah, its fantastic. :buddy:

Came across this when searching ‘headcrab’ on Garrysmod.org. :confused:

It’s been out for 2 whole days and still no new pills. :saddowns:

If the framework seems confusing, just ask your questions here.

Is it possible to give ranged attacks to your pills? For example, a Combine soldier that can shoot and throw grenades.

So if I was to edit the antlion pill to make an antlion worker, would it be possible to make it spit acid?

Sure. You’d need to make it throw acid manually like you would with any SWEP. Just go and edit the PILL:PrimaryAttack() function.

Keep in mind that self.Owner is available in those.

Thanks. :v:

I think tomorrow I will attempt to make some pills, who knows… [sp]I love Grea$eMonkey’s work…[/sp]