### Node Class Usage Example Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/types.md Shows basic instantiation and linking of nodes. ```lua local node = Node:New(1, NODE_TYPE_GROUND, Vector(0, 0, 0)) node:Link(node2) local linked = node:GetLinked() ``` -------------------------------- ### Use timer.DrG_Simple Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Example usage of scheduling a callback with arguments. ```lua timer.DrG_Simple(5, function(msg, count) print(msg, count) end, "Hello", 42) ``` -------------------------------- ### Usage of DrG_SelectedEntities Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/player-meta.md Example demonstrating how to iterate over selected entities. ```lua -- Iterate selected entities for ent in ply:DrG_SelectedEntities() do if IsValid(ent) then print(ent:GetClass()) end end ``` -------------------------------- ### Usage of PhysObj:DrG_AimAt Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/meta-extensions.md Example of spawning a projectile and aiming it at an enemy. ```lua -- Throw object at target with speed 800 local proj = ents.Create("prop_physics") proj:SetModel("models/combine_helicopter/helicopter_bomb01.mdl") proj:SetPos(Vector(0, 0, 100)) proj:Spawn() local vel, info = proj:GetPhysicsObject():DrG_AimAt(enemy, 800) print("Impact time: " .. info.duration .. "s") ``` -------------------------------- ### Usage Examples for DrGBase.Print Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Demonstrates printing to console, chat, and applying custom colors. ```lua -- Print to server console DrGBase.Print("Server started") -- Print to player chat DrGBase.Print("Hello player!", {chat = true, player = ply}) -- Print with custom colors DrGBase.Print("Custom message", { title = DrGBase.CLR_PURPLE, color = DrGBase.CLR_ORANGE }) ``` -------------------------------- ### Usage Example for DrGBase.Info Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Prints an info message with a green title and white text. ```lua DrGBase.Info("Nextbot spawned successfully") ``` -------------------------------- ### Use timer.DrG_Loop Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Examples of repeating callbacks with fixed intervals and conditional termination. ```lua -- Loop every 2 seconds timer.DrG_Loop(2, function() print("Tick") return 2 end) -- Stop looping based on condition local count = 0 timer.DrG_Loop(1, function() count = count + 1 print("Iteration " .. count) if count >= 5 then return false -- Stop end end) ``` -------------------------------- ### Use Color Constants in Functions Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/types.md Examples of applying color constants to logging and debug overlay functions. ```lua DrGBase.Print("Success", {color = DrGBase.CLR_GREEN}) debugoverlay.Box(pos, mins, maxs, 5, DrGBase.CLR_BLUE_TR) ``` -------------------------------- ### Visualize projectile trajectories Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Examples demonstrating both linear and ballistic trajectory visualization using DrG_Trajectory. ```lua -- Draw linear trajectory debugoverlay.DrG_Trajectory( Vector(0, 0, 0), Vector(500, 0, 0), 5, DrGBase.CLR_GREEN ) -- Draw ballistic arc debugoverlay.DrG_Trajectory( Vector(0, 0, 0), Vector(500, 0, 500), 5, function(t) return Color(255, t*255, 0) end, false, {ballistic = true} ) ``` -------------------------------- ### Usage Example for DrGBase.ErrorInfo Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Prints an error info message with a green title and red text. ```lua DrGBase.ErrorInfo("Weapon not found in inventory") ``` -------------------------------- ### Usage of DrG_GetSelectedEntities Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/player-meta.md Example demonstrating how to retrieve and process the array of selected entities. ```lua local selected = ply:DrG_GetSelectedEntities() print("Selected " .. #selected .. " entities") for i, ent in ipairs(selected) do print(i .. ": " .. ent:GetClass()) end ``` -------------------------------- ### Usage of DrG_GetSelectionTable Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/player-meta.md Examples for retrieving selection tables and modifying entity selection status. ```lua -- Get selection table for current tool local selections = ply:DrG_GetSelectionTable() -- Get selection table for specific tool local damage_selections = ply:DrG_GetSelectionTable("drgbase_tool_damage") -- Select/deselect entities local sel = ply:DrG_GetSelectionTable() sel[entity1] = true sel[entity2] = false ``` -------------------------------- ### Get Acceleration Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Retrieves the current movement acceleration value. ```lua function ENT:GetAcceleration() return self.loco:GetAcceleration() end ``` -------------------------------- ### Usage of PhysObj:DrG_ThrowAt Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/meta-extensions.md Examples of throwing objects using different trajectory configuration options. ```lua -- Throw at specific angle local vel, info = phys:DrG_ThrowAt(target, {pitch = 45}) -- Throw at specific speed local vel, info = phys:DrG_ThrowAt(target, {magnitude = 500}) -- Throw with higher arc local vel, info = phys:DrG_ThrowAt(target, {highest = true}) ``` -------------------------------- ### Usage Example for DrGBase.Error Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Prints an error message with a green title and red text. ```lua DrGBase.Error("Failed to spawn entity") ``` -------------------------------- ### Nextbot Template Configuration Source: https://github.com/dragoteryx/drgbase/wiki/Nextbot-template-file This is the main configuration table for a Nextbot. It defines various properties such as appearance, stats, AI behavior, locomotion, animations, and more. Ensure DrGBase is installed before using this template. ```lua if not DrGBase then return end -- return if DrGBase isn't installed ENT.Base = "drgbase_nextbot" -- DO NOT TOUCH (obviously) -- Misc -- ENT.PrintName = "Template" ENT.Category = "Other" ENT.Models = {"models/Kleiner.mdl"} ENT.Skins = {0} ENT.ModelScale = 1 ENT.CollisionBounds = Vector(10, 10, 72) ENT.BloodColor = BLOOD_COLOR_RED ENT.RagdollOnDeath = true -- Stats -- ENT.SpawnHealth = 100 ENT.HealthRegen = 0 ENT.MinPhysDamage = 10 ENT.MinFallDamage = 10 -- Sounds -- ENT.OnSpawnSounds = {} ENT.OnIdleSounds = {} ENT.IdleSoundDelay = 2 ENT.ClientIdleSounds = false ENT.OnDamageSounds = {} ENT.DamageSoundDelay = 0.25 ENT.OnDeathSounds = {} ENT.OnDownedSounds = {} ENT.Footsteps = {} -- AI -- ENT.Omniscient = false ENT.SpotDuration = 30 ENT.RangeAttackRange = 0 ENT.MeleeAttackRange = 50 ENT.ReachEnemyRange = 50 ENT.AvoidEnemyRange = 0 -- Relationships -- ENT.Factions = {} ENT.Frightening = false ENT.AllyDamageTolerance = 0.33 ENT.AfraidDamageTolerance = 0.33 ENT.NeutralDamageTolerance = 0.33 -- Locomotion -- ENT.Acceleration = 1000 ENT.Deceleration = 1000 ENT.JumpHeight = 50 ENT.StepHeight = 20 ENT.MaxYawRate = 250 ENT.DeathDropHeight = 200 -- Animations -- ENT.WalkAnimation = ACT_WALK ENT.WalkAnimRate = 1 ENT.RunAnimation = ACT_RUN ENT.RunAnimRate = 1 ENT.IdleAnimation = ACT_IDLE ENT.IdleAnimRate = 1 ENT.JumpAnimation = ACT_JUMP ENT.JumpAnimRate = 1 -- Movements -- ENT.UseWalkframes = false ENT.WalkSpeed = 100 ENT.RunSpeed = 200 -- Climbing -- ENT.ClimbLedges = false ENT.ClimbLedgesMaxHeight = math.huge ENT.ClimbLedgesMinHeight = 0 ENT.LedgeDetectionDistance = 20 ENT.ClimbProps = false ENT.ClimbLadders = false ENT.ClimbLaddersUp = true ENT.LaddersUpDistance = 20 ENT.ClimbLaddersUpMaxHeight = math.huge ENT.ClimbLaddersUpMinHeight = 0 ENT.ClimbLaddersDown = false ENT.LaddersDownDistance = 20 ENT.ClimbLaddersDownMaxHeight = math.huge ENT.ClimbLaddersDownMinHeight = 0 ENT.ClimbSpeed = 60 ENT.ClimbUpAnimation = ACT_CLIMB_UP ENT.ClimbDownAnimation = ACT_CLIMB_DOWN ENT.ClimbAnimRate = 1 ENT.ClimbOffset = Vector(0, 0, 0) -- Detection -- ENT.EyeBone = "" ENT.EyeOffset = Vector(0, 0, 0) ENT.EyeAngle = Angle(0, 0, 0) ENT.SightFOV = 150 ENT.SightRange = 15000 ENT.MinLuminosity = 0 ENT.MaxLuminosity = 1 ENT.HearingCoefficient = 1 -- Weapons -- ENT.UseWeapons = false ENT.Weapons = {} ENT.WeaponAccuracy = 1 ENT.WeaponAttachment = "Anim_Attachment_RH" ENT.DropWeaponOnDeath = false ENT.AcceptPlayerWeapons = true -- Possession -- ENT.PossessionEnabled = false ENT.PossessionPrompt = true ENT.PossessionCrosshair = false ENT.PossessionMovement = POSSESSION_MOVE_1DIR ENT.PossessionViews = {} ENT.PossessionBinds = {} ``` -------------------------------- ### Retrieve Entity Enemy Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/VERIFICATION.txt Example of a function signature and implementation for retrieving an entity's enemy using the DrGBase networking system. ```lua function Entity:GetEnemy() return self:GetNW2Entity("DrGBaseEnemy") end ``` -------------------------------- ### Manage Entity Scale Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Functions to get, set, or multiply the entity's scale multiplier. ```lua function ENT:GetScale() return self:GetNW2Float("DrGBaseScale", 1) end ``` ```lua function ENT:SetScale(scale, delta) self:SetNW2Float("DrGBaseScale", scale) self:SetModelScale(self.ModelScale*scale, delta) self:PhysicsInitShadow() self:UpdateSpeed() end ``` ```lua ent:SetScale(2) -- Double size instantly ent:SetScale(0.5, 1) -- Halve size over 1 second ``` ```lua function ENT:Scale(mult, delta) self:SetScale(self:GetScale()*mult, delta) end ``` ```lua ent:Scale(2) -- Double current size ent:Scale(0.5) -- Halve current size ``` -------------------------------- ### Initialize DrGBase Modules Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Load framework components using the autorun script entry points. ```lua DrGBase.IncludeFolder("drgbase") DrGBase.IncludeFolder("drgbase/meta") DrGBase.IncludeFolder("drgbase/modules") ``` -------------------------------- ### Implement typical Nextbot weapon workflow Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-weapons.md Standard implementation pattern for spawning and initializing entities with weapon support. ```lua -- In custom entity class function ENT:SpawnFunction(_, _) local ent = ents.Create("drgbase_nextbot") -- Weapon setup typically done in Initialize hook return ent end function ENT:Initialize() self.Base_Initialize() -- Weapons are given through other systems -- (e.g., inventory manager, AI behavior) end function ENT:GetAimAtEntity(target) -- Customize aiming per entity type return target:WorldSpaceCenter() end ``` -------------------------------- ### Get Deceleration Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Retrieves the current movement deceleration value. ```lua function ENT:GetDeceleration() return self.loco:GetDeceleration() end ``` -------------------------------- ### Print Pose Parameters Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/entity-meta.md Prints all pose parameters to the console in the format 'name min / max'. ```lua function Entity:PrintPoseParameters() ``` ```lua ent:PrintPoseParameters() ``` -------------------------------- ### Get Jump Height Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Retrieves the configured jump height in units. ```lua function ENT:GetJumpHeight() return self.loco:GetJumpHeight() end ``` -------------------------------- ### Building Nextbot Paths Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Methods for calculating paths to a target position with optional configuration parameters. ```lua -- Find path to target if self:FindPath(targetPos) then -- Path found, nextbot will follow end -- Build path with options self:FindPath(targetPos, { maxPathDistance = 5000 }) ``` -------------------------------- ### Get Possessed Entity Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/player-meta.md Retrieves the entity currently being possessed by the player. ```lua function Player:DrG_Possessing() return self:GetNW2Entity("DrGBasePossessing") end ``` ```lua local possessed = ply:DrG_GetPossessing() if IsValid(possessed) then print("Possessing: " .. possessed:GetClass()) end ``` -------------------------------- ### Include a single file with DrGBase.IncludeFile Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Includes a file with automatic server/client handling based on filename prefixes. ```lua function DrGBase.IncludeFile(fileName) -- Returns: return value of included file ``` ```lua -- Shared file DrGBase.IncludeFile("drgbase/module.lua") -- Server-only DrGBase.IncludeFile("sv_server_logic.lua") -- Client-only DrGBase.IncludeFile("cl_ui.lua") ``` -------------------------------- ### Request-Response Callback Pattern Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Initiate a request from the client and define a server-side handler to return the requested data. ```lua function net.DrG_UseCallback(name, callback, ...) -- name: string - Callback name -- callback: function - Called with response arguments -- ...: any - Arguments to send (server only: first arg must be player) -- Returns: bool - True if request sent ``` ```lua -- Client requests net.DrG_UseCallback("GetPlayerData", function(health, ammo) print("Health: " .. health .. ", Ammo: " .. ammo) end) -- Server defines handler net.DrG_DefineCallback("GetPlayerData", function() return LocalPlayer():Health(), 100 end) ``` -------------------------------- ### Configure Detection Parameters Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Sets vision and hearing properties for the nextbot's sensory system. ```lua ENT.EyeBone = "" ENT.EyeOffset = Vector(0, 0, 0) ENT.EyeAngle = Angle(0, 0, 0) ENT.SightFOV = 150 ENT.SightRange = 15000 ENT.MinLuminosity = 0 ENT.MaxLuminosity = 1 ENT.HearingCoefficient = 1 ``` -------------------------------- ### Usage of NPC:DrG_SetRelationship Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/meta-extensions.md Examples of setting NPC dispositions towards other entities. ```lua npc:DrG_SetRelationship(player, D_LI) -- Like player npc:DrG_SetRelationship(enemy, D_HT) -- Hate enemy ``` -------------------------------- ### Get Step Height Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Retrieves the maximum height of steps the entity can climb. ```lua function ENT:GetStepHeight() return self.loco:GetStepHeight() end ``` -------------------------------- ### Implement Entity Relationship Logic Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/types.md Demonstrates setting a default relationship and overriding the GetRelationshipToEntity method. ```lua ENT.DefaultRelationship = D_NU function ENT:GetRelationshipToEntity(entity) if entity:IsNPC() then return D_LI -- Friendly to NPCs else return D_NU -- Neutral to others end end ``` -------------------------------- ### Configure Climbing Properties Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Sets parameters for ledge and ladder navigation, including detection distances and animation activities. ```lua ENT.ClimbLedges = false ENT.ClimbLedgesMaxHeight = math.huge ENT.ClimbLedgesMinHeight = 0 ENT.LedgeDetectionDistance = 20 ENT.ClimbProps = false ENT.ClimbLadders = false ENT.ClimbLaddersUp = true ENT.LaddersUpDistance = 20 ENT.ClimbLaddersUpMaxHeight = math.huge ENT.ClimbLaddersUpMinHeight = 0 ENT.ClimbLaddersDown = false ENT.LaddersDownDistance = 20 ENT.ClimbLaddersDownMaxHeight = math.huge ENT.ClimbLaddersDownMinHeight = 0 ENT.ClimbSpeed = 60 ENT.ClimbUpAnimation = ACT_CLIMB_UP ENT.ClimbDownAnimation = ACT_CLIMB_DOWN ENT.ClimbAnimRate = 1 ENT.ClimbOffset = Vector(0, 0, 0) ``` -------------------------------- ### Get Death Drop Height Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Retrieves the fall height that results in entity death. ```lua function ENT:GetDeathDropHeight() return self.loco:GetDeathDropHeight() end ``` -------------------------------- ### Create a table with default values Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Sets a metatable on the provided table to return a default value when accessing missing keys. ```lua function table.DrG_Default(tbl, default) return setmetatable(tbl, {__index = function() return default end}) end ``` ```lua local counts = table.DrG_Default({}, 0) counts.a = 5 counts.b = counts.b + 1 -- 0 + 1 = 1 print(counts.b) -- 1 ``` -------------------------------- ### table.DrG_Unpack(tbl, size, i) Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Unpacks a table starting from a specific index up to a defined size. ```APIDOC ## table.DrG_Unpack(tbl, size, i) ### Description Unpack a table starting from index i to size. ### Parameters - **tbl** (table) - Required - Table to unpack - **size** (number) - Required - Number of elements to unpack - **i** (number) - Optional - Starting index (default: 1) ### Returns - **...** - Unpacked arguments ``` -------------------------------- ### Configure Locomotion Settings Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Defines movement capabilities including acceleration, jumping, and turning rates. ```lua ENT.Acceleration = 1000 ENT.Deceleration = 1000 ENT.JumpHeight = 50 ENT.StepHeight = 20 ENT.MaxYawRate = 250 ENT.DeathDropHeight = 200 ``` -------------------------------- ### Create and spawn a nextbot Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/00-START-HERE.txt Initializes a new drgbase_nextbot entity, sets its position and model, and spawns it into the world. ```lua local ent = ents.Create("drgbase_nextbot") ent:SetPos(Vector(0, 0, 0)) ent:SetModel("models/player/combine_soldier.mdl") ent:Spawn() ``` -------------------------------- ### Configure Animation Properties Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Sets activities and playback rates for standard movement and idle states. ```lua ENT.WalkAnimation = ACT_WALK ENT.WalkAnimRate = 1 ENT.RunAnimation = ACT_RUN ENT.RunAnimRate = 1 ENT.IdleAnimation = ACT_IDLE -- ... additional animation properties ``` -------------------------------- ### Include multiple files with DrGBase.IncludeFiles Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Includes an array of files and returns a map of their return values. ```lua function DrGBase.IncludeFiles(fileNames) -- fileNames: table - Array of filenames -- Returns: table - Map of {filename = return_value} ``` ```lua local results = DrGBase.IncludeFiles({ "drgbase/module1.lua", "drgbase/module2.lua" }) ``` -------------------------------- ### Configure Miscellaneous Entity Properties Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Sets basic identity and physical properties for the nextbot entity. ```lua ENT.PrintName = "Template" ENT.Category = "Other" ENT.Models = {"models/player/kleiner.mdl"} ENT.Skins = {0} ENT.ModelScale = 1 ENT.CollisionBounds = Vector(10, 10, 72) ENT.BloodColor = BLOOD_COLOR_RED ENT.RagdollOnDeath = true ``` -------------------------------- ### Get Max Yaw Rate Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Retrieves the maximum turning speed in degrees per second. ```lua function ENT:GetMaxYawRate() return self.loco:GetMaxYawRate() end ``` -------------------------------- ### Trace Result Usage Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/types.md Demonstrates how to perform a trace and access fields from the returned trace result table. ```lua local tr = ent:DrG_TraceLine(ent:GetForward() * 500) if tr.Hit then print("Hit " .. (tr.HitWorld and "world" or tr.Entity:GetClass())) print("At " .. tostring(tr.HitPos)) end ``` -------------------------------- ### Get desired movement speed Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Retrieves the current target speed of the entity in units per second. ```lua function ENT:GetDesiredSpeed() return self:GetNW2Float("DrGBaseDesiredSpeed") end ``` -------------------------------- ### Entity:PrintPoseParameters Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/entity-meta.md Prints all pose parameters to the console in the format 'name min / max'. ```APIDOC ## Entity:PrintPoseParameters() ### Description Prints all pose parameters to the console. ### Signature `function Entity:PrintPoseParameters()` ### Output Format `name min / max` per line ### Example ```lua ent:PrintPoseParameters() ``` ``` -------------------------------- ### Unpack table elements Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Recursively unpacks elements from a table starting at a specific index up to a defined size. ```lua function table.DrG_Unpack(tbl, size, i) if not isnumber(i) then i = 1 end if i < size then return tbl[i], table.DrG_Unpack(tbl, size, i+1) elseif i == size then return tbl[i] end end ``` ```lua local args = {1, 2, 3, 4} local a, b, c = table.DrG_Unpack(args, 3) -- a=1, b=2, c=3 ``` -------------------------------- ### Print Attachments Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/entity-meta.md Prints all attachment points to the console. ```lua function Entity:PrintAttachments() -- Output: id => name ``` ```lua ent:PrintAttachments() ``` -------------------------------- ### Vector:DrG_TrajectoryInfo(direction, ballistic) Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/vector-meta.md Calculates trajectory information for a projectile based on a starting position and velocity vector. ```APIDOC ## Vector:DrG_TrajectoryInfo(direction, ballistic) ### Description Calculate trajectory information for a projectile. Supports optional gravity simulation. ### Parameters - **direction** (Vector) - Required - Direction/velocity vector - **ballistic** (bool) - Optional - Enable gravity (default: false) ### Returns - **table** - Trajectory info containing normal, forward, magnitude, pitch, ballistic, highest, height, and a Predict(t) function. ``` -------------------------------- ### Configure Luminosity ConVar Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/player-meta.md Creates a ConVar to toggle real-time player perception updates. ```lua local UpdateLuminosity = CreateConVar("drgbase_update_luminosity", "1", {FCVAR_ARCHIVE, FCVAR_NOTIFY, FCVAR_REPLICATED}) ``` -------------------------------- ### Regenerate Health Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Defines the RegenHealth method signature and provides examples for basic regeneration and conditional stopping via callback. ```lua function ENT:RegenHealth(health, duration, callback) -- health: number - Target health -- duration: number - Time to regenerate (0 = instant) -- callback: function - Called each tick, return true to stop ``` ```lua ent:RegenHealth(100, 5) -- Regenerate to 100 HP over 5 seconds ent:RegenHealth(100, 10, function(ent, current) if current > 50 then return true -- Stop early end end) ``` -------------------------------- ### Define Framework Icon Path Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Sets the global icon path used for UI elements within the framework. ```lua DrGBase.Icon = "drgbase/icon16.png" ``` -------------------------------- ### Get weapon aim vector with ENT:GetAimVector Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-weapons.md Calculates the normalized aim direction based on possession state or enemy targeting. ```lua function ENT:GetAimVector(class) if self:IsPossessed() then local lockedOn = self:PossessionGetLockedOn() if IsValid(lockedOn) then local aimAt = self:OnAimAtEntity(lockedOn) or lockedOn:WorldSpaceCenter() return self:GetShootPos(class):DrG_Direction(aimAt):GetNormalized() else return self:GetShootPos(class):DrG_Direction(self:PossessorTrace().HitPos):GetNormalized() end elseif self:HasEnemy() then local enemy = self:GetEnemy() local aimAt = self:OnAimAtEntity(enemy) or enemy:WorldSpaceCenter() return self:GetShootPos(class):DrG_Direction(aimAt):GetNormalized() else return self:EyeAngles():Forward() end end ``` ```lua local aimDir = ent:GetAimVector() ``` -------------------------------- ### Node Class API Methods Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/types.md Lists available methods for the custom node graph system. ```lua Node:New(id, type, pos) -- Create new node Node:GetID() -- Get node ID Node:GetType() -- Get node type (NODE_TYPE_*) Node:GetPos() -- Get world position Node:Link(node) -- Link two nodes Node:Unlink(node) -- Remove link Node:IsLinked(node) -- Check if linked Node:GetLinked() -- Get all linked nodes ``` -------------------------------- ### Get weapon shoot position with ENT:GetShootPos Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-weapons.md Calculates the muzzle position based on weapon bones or defaults to the world center. Use the optional class parameter to specify a weapon. ```lua function ENT:GetShootPos(class) if self:HasWeapon(class) then local weapon = self:GetWeapon(class) for boneId = 0, (weapon:GetBoneCount()-1) do local boneName = weapon:GetBoneName(boneId) local lookedUp = self:LookupBone(boneName) if lookedUp then local bonepos = self:GetBonePosition(lookedUp) return bonepos end end return self:WorldSpaceCenter() else return self:WorldSpaceCenter() end end ``` ```lua local shootPos = ent:GetShootPos("weapon_drg_ar2") ``` -------------------------------- ### Manage Tool Selections Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/player-meta.md Handles entity selection toggling and clearing within a tool gun implementation. ```lua -- In tool gun implementation function TOOL:LeftClick(trace) local ply = self:GetOwner() local selections = ply:DrG_GetSelectionTable() if trace.Entity ~= NULL then selections[trace.Entity] = not (selections[trace.Entity] or false) self:SetColor(trace.Entity, selections[trace.Entity]) end end function TOOL:RightClick(trace) local selections = self:GetOwner():DrG_GetSelectionTable() for ent in pairs(selections) do selections[ent] = nil end end ``` -------------------------------- ### ENT:GetWeapons() Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-weapons.md Returns a copy of all weapons currently in the nextbot's inventory. ```APIDOC ## ENT:GetWeapons() ### Description Returns a table containing all weapons in the inventory, mapped as {class = weapon_entity}. ``` -------------------------------- ### Add Resource Files Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/configuration.md Register custom resource files for the addon in lua/drgbase/resources.lua. ```lua resource.AddFile("materials/drgbase/icon16.png") ``` -------------------------------- ### Define Possession Movement Modes Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/types.md Control schemes for player possession of a nextbot. ```lua POSSESSION_MOVE_CUSTOM = 0 POSSESSION_MOVE_8DIR = 1 POSSESSION_MOVE_NSEW = 1 POSSESSION_MOVE_COMPASS = 1 POSSESSION_MOVE_1DIR = 2 POSSESSION_MOVE_FORWARD = 2 POSSESSION_MOVE_4DIR = 3 POSSESSION_MOVE_ANALOG = 4 ``` ```lua ENT.PossessionMovementMode = POSSESSION_MOVE_8DIR ``` -------------------------------- ### Trace and debug Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/00-START-HERE.txt Sets the debug trace console variable and performs a line trace forward from the entity. ```lua GetConVar("drgbase_debug_traces"):SetString("3") local tr = ent:DrG_TraceLine(ent:GetForward() * 500) ``` -------------------------------- ### Launch Projectile at Target Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/meta-extensions.md Uses DrG_AimAt to calculate velocity and launch a physics object toward a target position. ```lua function ENT:LaunchProjectile(target) -- Create physics object local proj = ents.Create("prop_physics") proj:SetModel("models/Combine_Helicopter/helicopter_bomb01.mdl") proj:SetPos(self:GetPos() + Vector(0, 0, 50)) proj:Spawn() -- Launch at target local speed = 800 local phys = proj:GetPhysicsObject() local vel, info = phys:DrG_AimAt(target, speed) -- Visual feedback ParticleEffect("drg_plasma_ball", proj:GetPos(), angle_zero, NULL) return proj, info end ``` -------------------------------- ### Define timer.DrG_Simple Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Implementation of the DrG_Simple timer extension. ```lua function timer.DrG_Simple(delay, callback, ...) local args, n = table.DrG_Pack(...) timer.Simple(delay, function() callback(table.DrG_Unpack(args, n)) end) end ``` -------------------------------- ### DrGBase.IncludeFile(fileName) Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Includes a single Lua file. Automatically handles server/client distribution based on filename prefixes (sv_ or cl_). ```APIDOC ## DrGBase.IncludeFile(fileName) ### Description Includes a file with automatic server/client-only handling via filename convention. If the filename starts with 'sv_', it is included only on the server; if 'cl_', only on the client; otherwise, it is shared. ### Parameters - **fileName** (string) - Required - Path to file, with optional 'sv_' or 'cl_' prefix. ### Returns - (any) - The return value of the included file. ``` -------------------------------- ### DrGBase.IncludeFiles(fileNames) Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Includes multiple Lua files provided in an array. ```APIDOC ## DrGBase.IncludeFiles(fileNames) ### Description Includes multiple files from a provided list. ### Parameters - **fileNames** (table) - Required - Array of file paths to include. ### Returns - (table) - A map of {filename = return_value}. ``` -------------------------------- ### Print Bones Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/entity-meta.md Prints all bone indices and names to the console. ```lua function Entity:PrintBones() -- Output: id => name ``` ```lua ent:PrintBones() ``` -------------------------------- ### Pack variadic arguments Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Converts variadic arguments into a table and returns the table along with the total count of arguments. ```lua function table.DrG_Pack(...) return {...}, select("#", ...) end ``` ```lua local args, n = table.DrG_Pack(1, 2, nil, 4) print(n) -- 4 (includes nil) ``` -------------------------------- ### Enable Trajectory Debugging Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/meta-extensions.md Sets the debug trajectory visualization duration to 5 seconds. ```lua -- Enable for 5 seconds GetConVar("drgbase_debug_trajectories"):SetString("5") ``` -------------------------------- ### DrGBase.IncludeFolder(folder) Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Includes all .lua files within a specific folder (non-recursive). ```APIDOC ## DrGBase.IncludeFolder(folder) ### Description Includes all .lua files from a specified folder. This operation is non-recursive. ### Parameters - **folder** (string) - Required - Path to the folder to include files from. ### Returns - (table) - A map of {filepath = return_value}. ``` -------------------------------- ### Define Callback Handler Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Register a server-side function that responds to client-initiated requests. ```lua function net.DrG_DefineCallback(name, callback) -- name: string - Callback name -- callback: function - Handler returning response values ``` ```lua net.DrG_DefineCallback("GetServerTime", function() return CurTime() end) ``` -------------------------------- ### Configure entity relationships Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/README.md Set faction membership and damage tolerance to define how entities interact with others. ```lua ENT.Factions = {FACTION_COMBINE} ENT.DefaultRelationship = D_LI -- Like allies ENT.AllyDamageTolerance = 0.5 -- 50% damage before hostility ``` -------------------------------- ### Include a folder with DrGBase.IncludeFolder Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Includes all .lua files within a specified folder non-recursively. ```lua function DrGBase.IncludeFolder(folder) -- folder: string - Path to folder -- Returns: table - Map of {filepath = return_value} ``` ```lua local modules = DrGBase.IncludeFolder("drgbase") ``` -------------------------------- ### GetWeapons Implementation and Usage Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-weapons.md Returns a copy of the table containing all weapons currently in the inventory. ```lua function ENT:GetWeapons() return table.DrG_Copy(self._DrGBaseWeapons) end ``` ```lua local weapons = ent:GetWeapons() for class, weapon in pairs(weapons) do if IsValid(weapon) then print(class) end end ``` -------------------------------- ### loco:IsUsingLadder() Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Checks if the Nextbot is currently on a ladder, with support for DrGBase custom ladder climbing. ```APIDOC ## loco:IsUsingLadder() ### Description Returns true if the nextbot is on a ladder. This method is extended to support DrGBase custom ladder climbing. ### Returns - **boolean** - True if on a ladder, false otherwise. ``` -------------------------------- ### Print Entity Debug Information Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/README.md Use these methods to output bone, attachment, animation, and pose parameter data to the console for debugging purposes. ```lua ent:PrintBones() ent:PrintAttachments() ent:PrintAnimations() ent:PrintPoseParameters() ``` -------------------------------- ### FindPath Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Calculates a path to a target position, optionally with configuration parameters. ```APIDOC ## FindPath ### Description Calculates a path from the current position to the specified target position. Returns a boolean indicating if a valid path was found. ### Signature `self:FindPath(targetPos, [options])` ### Parameters - **targetPos** (Vector) - Required - The destination coordinate. - **options** (Table) - Optional - Configuration table (e.g., {maxPathDistance = number}). ``` -------------------------------- ### Path Information Methods Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Methods to retrieve data about the current active path. ```APIDOC ## Path Information Methods ### Description Methods to inspect the state and progress of the current path. ### Methods - **GetCurrentPath()**: Returns the current path segment. - **GetPathDistanceRemaining()**: Returns the remaining distance to the target. - **GetPathTimeRemaining()**: Returns the estimated time remaining to reach the target. ``` -------------------------------- ### Manage God Mode Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Functions to check or toggle god mode status. ```lua function ENT:GetGodMode() return self:GetNW2Bool("DrGBaseGodMode") end ``` ```lua function ENT:SetGodMode(god) return self:SetNW2Bool("DrGBaseGodMode", god) end ``` ```lua ent:SetGodMode(true) ent:EnableGodMode() ent:DisableGodMode() ``` -------------------------------- ### Define a custom Nextbot Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/README.md Configure basic properties and behaviors for a custom Nextbot by setting entity fields. ```lua ENT.Base = "drgbase_nextbot" ENT.Type = "nextbot" ENT.PrintName = "My Bot" ENT.Category = "My Addon" ENT.Models = {"models/player/combine_soldier.mdl"} ENT.SpawnHealth = 100 ENT.WalkSpeed = 150 ENT.RunSpeed = 250 ENT.SightRange = 2000 function ENT:OnNewEnemy(enemy) print("I see you!") end ``` -------------------------------- ### DrGBase.Print(msg, options) Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Prints a message to the console or chat with configurable options. ```APIDOC ## DrGBase.Print(msg, options) ### Description Prints a message to the console or chat. Supports custom colors and target players. ### Parameters - **msg** (string) - Required - The message to display - **options** (table) - Optional - Configuration table - **options.chat** (bool) - Send to chat (default: false) - **options.title** (Color) - Color of title text - **options.color** (Color) - Color of message text - **options.player** (Entity) - Target player (if nil, broadcasts) ### Returns - nil ``` -------------------------------- ### Fire projectiles with ballistic trajectories Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/README.md Calculate ballistic trajectories and spawn projectiles using DrGBase vector extensions. ```lua -- Calculate trajectory local shootPos = ent:GetShootPos() local aimDir = ent:GetAimVector() local vel, info = shootPos:DrG_CalcBallisticTrajectory(target) -- Fire projectile local proj = ents.Create("proj_drg_default") proj:SetModel("models/weapons/w_missile_closed.mdl") proj:SetPos(shootPos) proj:SetVelocity(vel) proj:Spawn() ``` -------------------------------- ### Trace Result Methods Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/types.md Methods for performing trace operations that return standard GMod trace result tables. ```APIDOC ## Trace Result Methods ### Description These methods perform trace operations and return a table containing hit information such as Hit, HitWorld, HitPos, HitNormal, Entity, Fraction, PolyHit, StartSolid, and MatType. ### Methods - util.DrG_TraceLine(data) - util.DrG_TraceHull(data) - Entity:DrG_TraceLine() - Entity:DrG_TraceHull() - Entity:DrG_TraceLineRadial() (returns array) ``` -------------------------------- ### Print Animations Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/entity-meta.md Prints all animations to the console with their corresponding IDs and activity names. ```lua function Entity:PrintAnimations() -- Output: id => name / activity => activity_name ``` ```lua ent:PrintAnimations() ``` -------------------------------- ### Fetch element using callback Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Searches a table for an element based on a custom comparison function. ```lua function table.DrG_Fetch(tbl, callback) -- callback: function(value, fetched, key, fetchedKey) -> bool -- Returns true if current value should be selected ``` ```lua local t = {a = 10, b = 5, c = 20} -- Find largest value local val, key = table.DrG_Fetch(t, function(cur, prev) return prev == nil or cur > prev end) print(key, val) -- c, 20 ``` -------------------------------- ### Recursively include files with DrGBase.RecursiveInclude Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Includes all .lua files from a folder and its subfolders. ```lua function DrGBase.RecursiveInclude(folder) -- folder: string - Path to folder -- Returns: table - Map of all {filepath = return_value} ``` ```lua local all = DrGBase.RecursiveInclude("drgbase") ``` -------------------------------- ### Configure Nextbot Resource Precaching ConVars Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/configuration.md Toggles automatic precaching of models and sounds on startup. ```lua local PrecacheModels = CreateConVar("drgbase_precache_models", "1", {FCVAR_ARCHIVE, FCVAR_NOTIFY, FCVAR_REPLICATED}) ``` ```lua local PrecacheSounds = CreateConVar("drgbase_precache_sounds", "1", {FCVAR_ARCHIVE, FCVAR_NOTIFY, FCVAR_REPLICATED}) ``` -------------------------------- ### Trace Hull from Entity Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/entity-meta.md Performs a hull trace from the entity. Use the 'step' option in data to utilize locomotion step height. ```lua function Entity:DrG_TraceHull(vec, data) -- vec: Vector - Direction vector (default: 0,0,0) -- data: table - Additional parameters -- Returns: TraceResult table ``` ```lua -- Trace hull forward with step height local tr = ent:DrG_TraceHull(ent:GetForward()*100, {step = true}) ``` -------------------------------- ### Define a custom weapon for Nextbots Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/configuration.md Configures weapon metadata and implements the OnSelectWeapon hook to handle AI reactions to weapon selection. ```lua SWEP.PrintName = "My Custom Weapon" SWEP.Category = "DrGBase" SWEP.Spawnable = true -- Custom AI behavior in nextbot function ENT:OnSelectWeapon(weapon, class) -- React to weapon selection end ``` -------------------------------- ### Wrap Entity Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/entity-meta.md Retrieves a wrapper object for simplified entity access, such as specialized door handling on the server. ```lua function Entity:DrG_Wrap() -- Returns specialized wrapper for doors on server ``` ```lua local wrapper = ent:DrG_Wrap() -- Provides proxy access to entity methods ``` -------------------------------- ### Configure AI Behavior Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Sets AI logic parameters such as detection ranges and behavior modes. ```lua ENT.BehaviourType = AI_BEHAV_BASE ENT.Omniscient = false ENT.SpotDuration = 30 ENT.RangeAttackRange = 0 ENT.MeleeAttackRange = 50 ENT.ReachEnemyRange = 50 ENT.AvoidEnemyRange = 0 ENT.AvoidAfraidOfRange = 500 ENT.WatchAfraidOfRange = 750 ``` -------------------------------- ### Set desired movement speed Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Configures the target movement speed for the entity on the server. ```lua function ENT:SetDesiredSpeed(speed) return self.loco:SetDesiredSpeed(speed) end ``` ```lua ent:SetDesiredSpeed(200) -- Move at 200 units/second ``` -------------------------------- ### Configure Movement Properties Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Defines movement speed and animation behavior for the entity. ```lua ENT.UseWalkframes = false ENT.WalkSpeed = 100 ENT.RunSpeed = 200 ``` -------------------------------- ### ENT:SetAcceleration(accel) Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Sets the movement acceleration for the Nextbot. ```APIDOC ## ENT:SetAcceleration(accel) ### Description Sets the movement acceleration rate for the Nextbot. ### Parameters - **accel** (number) - Required - Acceleration rate ``` -------------------------------- ### ENT:SetStepHeight(height) Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-locomotion.md Sets the climbable step height for the Nextbot. ```APIDOC ## ENT:SetStepHeight(height) ### Description Sets the climbable step height for the Nextbot. ### Parameters - **height** (number) - Required - Height in units ``` -------------------------------- ### Create a read-only table proxy Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/utility-modules.md Returns a proxy table that prevents modifications. Attempts to set new values will not raise errors but will have no effect. ```lua function table.DrG_ReadOnly(tbl) return setmetatable({}, { __index = tbl, __newindex = function() end }) end ``` ```lua local data = {x = 10, y = 20} local readonly = table.DrG_ReadOnly(data) print(readonly.x) -- 10 readonly.x = 50 -- No effect, no error print(readonly.x) -- Still 10 ``` -------------------------------- ### AI Lifecycle Hooks Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Hooks for responding to enemy acquisition, changes, or loss. ```lua function ENT:OnNewEnemy(enemy) end function ENT:OnEnemyChange(old, new) end function ENT:OnLastEnemy(last) end ``` -------------------------------- ### Configure Factions Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/configuration.md Assign entities to specific factions to define group relationships. ```lua ENT.Factions = {FACTION_COMBINE, FACTION_GMAN} ``` -------------------------------- ### Entity Selection Management Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/player-meta.md Methods for managing and retrieving selections of entities by the player. ```APIDOC ## Player:DrG_GetSelectionTable() ### Description Returns the raw table of entities currently selected by the player. ### Returns - **table** - A table where keys are entities and values are booleans representing selection state. ## Player:DrG_GetSelectedEntities() ### Description Returns a list of all entities currently selected by the player. ### Returns - **table** - An indexed table of selected entities. ``` -------------------------------- ### Fire a projectile with Lua Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-weapons.md Spawns and initializes a custom projectile entity with a specific model and velocity. ```lua -- Create and fire projectile local proj = ents.Create("proj_drg_default") proj:SetModel("models/Combine_Helicopter/helicopter_bomb01.mdl") proj:SetPos(ent:GetShootPos()) proj:SetVelocity(ent:GetAimVector() * 1000) proj:Spawn() ``` -------------------------------- ### Define Input Flags Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/types.md Additional input button flags for possession controls. ```lua IN_ATTACK3 = 33554432 ``` ```lua if CLIENT then -- Check for third attack button during possession if bit.band(cmd:GetButtons(), IN_ATTACK3) ~= 0 then -- Handle attack end end ``` -------------------------------- ### Register Particle Systems Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/configuration.md Register particle files and precache specific systems in lua/drgbase/particles.lua. ```lua DrGBase.AddParticles("drgbase.pcf", { "drg_plasma_ball", "drg_smokescreen" }) -- Vanilla particles also precached PrecacheParticleSystem("blood_impact_red_01_goop") -- ... more ``` -------------------------------- ### Perform traced lines with debug visualization Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/README.md Execute line traces from an entity and visualize them using the debug ConVar. ```lua -- Enable debug with ConVar ConVarObject = GetConVar("drgbase_debug_traces") ConVarObject:SetString("5") -- Show for 5 seconds -- Trace from entity local tr = ent:DrG_TraceLine(ent:GetForward() * 500) if tr.Hit then print("Hit at:", tr.HitPos) end ``` -------------------------------- ### Network message Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/00-START-HERE.txt Demonstrates sending and receiving custom network messages using the DrGBase networking wrapper. ```lua net.DrG_Send("MyMsg", arg1, arg2, arg3) net.DrG_Receive("MyMsg", function(a, b, c) print(a, b, c) end) ``` -------------------------------- ### Manage Enemies Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-core.md Methods for retrieving and validating the current enemy target. ```lua function ENT:GetEnemy() return self:GetNW2Entity("DrGBaseEnemy") end function ENT:HasEnemy() return IsValid(self:GetEnemy()) end ``` ```lua if ent:HasEnemy() then local enemy = ent:GetEnemy() print("Fighting: " .. enemy:GetClass()) end ``` -------------------------------- ### DrGBase.RecursiveInclude(folder) Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/core-api.md Includes all .lua files within a folder and all its subfolders. ```APIDOC ## DrGBase.RecursiveInclude(folder) ### Description Includes all .lua files from a folder and all subfolders recursively. ### Parameters - **folder** (string) - Required - Path to the root folder. ### Returns - (table) - A flattened table of all filepaths and their return values. ``` -------------------------------- ### GetWeapon Implementation and Usage Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/nextbot-weapons.md Retrieves a weapon by class name or the active weapon if no class is provided. ```lua function ENT:GetWeapon(class) if isstring(class) then return self._DrGBaseWeapons[class] or NULL else return self:GetActiveWeapon() end end ``` ```lua -- Get specific weapon local rifle = ent:GetWeapon("weapon_drg_ar2") -- Get active weapon local current = ent:GetWeapon() ``` -------------------------------- ### Print Bodygroups Source: https://github.com/dragoteryx/drgbase/blob/master/_autodocs/api-reference/entity-meta.md Prints all bodygroup information, including ID, name, and number of subgroups. ```lua function Entity:PrintBodygroups() -- Output: id => name (num_subgroups) ``` ```lua ent:PrintBodygroups() ```