Skip to content

Instantly share code, notes, and snippets.

@DrVrej
Last active April 7, 2022 02:19
Show Gist options
  • Save DrVrej/af83c753c64270c1cc0c7864eca51b48 to your computer and use it in GitHub Desktop.
Save DrVrej/af83c753c64270c1cc0c7864eca51b48 to your computer and use it in GitHub Desktop.
Common NPC System (CNS)

Common NPC System (CNS)

A common system that any NPC/Nextbot base can adopt to make it compatiable with other bases that are using this system.

IMPLEMENTATION

To implement CNS into your NPC/Nextbot base, you need to take the following steps:

  1. Declare and implement all the functions, variables and enumerations listed below to avoid any possible error.
  2. Declare ENT.UsingCNS = true on a shared enviroment in your NPC.

ENUMS

D_ = Enums for disposition, more information at https://wiki.facepunch.com/gmod/Enums/D

VARIABLES

self.UsingCNS = Signifies that this entity is using CNS.

FUNCTIONS

Disposition

Title Description
Purpose Returns the way the NPC "feels" about an entity
Parameters ent = The entity to check against
Returns enum D_
Default GMod? Yes - NPC library
self:Disposition(ent)

GetEnemy

Title Description
Purpose Obtain the current main enemy
Parameters None
Returns Entity or NULL
Default GMod? Yes - NPC library
self:GetEnemy()

SetEnemy

Title Description
Purpose Set the current main enemy
Parameters ent = The ent to set as enemy
Returns None
Default GMod? Yes - NPC library
self:SetEnemy(ent)

GetActiveWeapon

Title Description
Purpose Returns the current weapon that the entity is using
Parameters None
Returns Entity or NULL
Default GMod? Yes - NPC & Player library
self:GetActiveWeapon()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment