Functions (Motion) - ShadowBonnieRUS/GMOD-SB_Advanced_Nextbots_Base GitHub Wiki
Here are descriptions for functions used in base in motion.lua
file.
⚠️🔹 NEXTBOT:SetMotionType
Sets bot motion type.
Arguments: 1
- number | Motion Type. See SB_ADVANCED_NEXTBOT_MOTIONTYPE_ Enums.
Returns: 0
⚠️🔹 NEXTBOT:GetMotionType
Returns bot motion type.
Arguments: 0
Returns: 1
- number | Motion Type. See SB_ADVANCED_NEXTBOT_MOTIONTYPE_ Enums.
⚠️🔹 NEXTBOT:SetupSpeed
Called to set locomotion desired motion speed сonsidering NEXTBOT:Should* and NEXTBOT:IsCrouching functions.
Arguments: 0
Returns: 0
🔹 NEXTBOT:GetCurrentSpeed
Returns bot current motion speed.
Arguments: 0
Returns: 1
- number | Motion speed.
🔹 NEXTBOT:GetDesiredSpeed
Returns bots Locomotion desired speed.
Arguments: 0
Returns: 1
- number | Motion speed.
🔹 NEXTBOT:IsMoving
Returns bot is moving or not.
Arguments: 0
Returns: 1
- bool | Bot is moving.
⚠️🔹 NEXTBOT:SetupMotionType
Called to setup motion type сonsidering motion speed and NEXTBOT:IsCrouching.
Arguments: 0
Returns: 0
🔹 NEXTBOT:SetDesiredEyeAngles
Sets direction where bot want aim. You should use this in behaviour.
Arguments: 1
- Angle | Desired direction.
Returns: 0
🔹 NEXTBOT:GetDesiredEyeAngles
Returns direction where bot want aim.
Arguments: 0
Returns: 1
- Angle | Desired direction.
⚠️🔹 NEXTBOT:SetupEyeAngles
Aiming bot to desired direction.
Arguments: 0
Returns: 0
🔹 NEXTBOT:ViewPunch
Performs simple view punch.
Arguments: 1
- Angle | view punch angles.
Returns: 0
⚠️🔹 NEXTBOT:TranslateActivity
Translate ACT_MP_* activity to right activity сonsidering weapon.
Arguments: 1
- number | Activity to translate.
Returns: 1
- number | Translated activity.
⚠️🔹 NEXTBOT:SetupActivity
Sets right activity to bot.
Arguments: 0
Returns: 0
🔹 NEXTBOT:DoGesture
Creates gesture animation (e.g. reload animation). Removes previous gesture.
Arguments: 3
- number | Animation to run. See ACT_* Enums.
- ⭕ number | Playback rate.
- ⭕ bool | Should behaviour be stopped while gesture active (like DoPosture).
Returns: 0
🔹 NEXTBOT:DoPosture
Creates posture animation (e.g. reload animation). Removes previous posture.
NOTE: While posture active behaviour will be disabled and activities will not be updated.
Arguments: 4
- number | Animation to run. See ACT_* Enums. If 2 argument is true, sequence id (also can be string).
- ⭕ bool | If set, creates sequence with 1 argument id, otherwise gets random weighted sequence to 1 argument activity.
- ⭕ number | Playback rate.
- ⭕ bool | If set, disables autokill when sequence has finished.
Returns: 1
- number | Length of created sequence.
🔹 NEXTBOT:StopGesture
Removes current gesture. Does nothing if gesture not active.
Arguments: 0
Returns: 0
🔹 NEXTBOT:StopPosture
Removes current posture. Does nothing if posture not active.
Arguments: 0
Returns: 0
🔹 NEXTBOT:IsGestureActive
Returns whenever we currently playing a gesture or not.
Arguments: 1
- ⭕ bool | If true, function will return true only if behaviour should be stopped while gesture active.
Returns: 1
- bool | Gesture active or not.
🔹 NEXTBOT:IsPostureActive
Returns whenever we currently playing a posture or not.
Arguments: 0
Returns: 1
- bool | Posture active or not.
⚠️🔹 NEXTBOT:SetupGesturePosture
Setups gestures and postures. DoGesture and DoPosture do not actually creates animations, because for correctly work it should be done in BehaveUpdate. SetupGesturePosture is called in BehaveUpdate.
Arguments: 0
Returns: 0
✏️⚠️🔹 NEXTBOT:BodyUpdate
Updates animations and activities.
🔹 NEXTBOT:ShouldRun
Decides should bot run or not.
Arguments: 0
Returns: 1
- bool | Should run or not.
🔹 NEXTBOT:ShouldWalk
Decides should bot walk or not.
Arguments: 0
Returns: 1
- bool | Should walk or not.
🔹 NEXTBOT:ShouldCrouch
Decides should bot crouch or not.
Arguments: 0
Returns: 1
- bool | Should crouch or not.
⚠️🔹 NEXTBOT:CanStandUp
Can bot stand up from crouch and dont stuck anywhere.
Arguments: 0
Returns: 1
- bool | Can stand up or not.
⚠️🔹 NEXTBOT:SetupCollisionBounds
Sets collision bounds сonsidering crouch status. Also recreating physics object using new bounds.
Arguments: 0
Returns: 0
⚠️🔹 NEXTBOT:UpdatePhysicsObject
Updates physics object position and angles.
Arguments: 0
Returns: 0
🔹 NEXTBOT:PhysicsObjectCollide
Called when physics object collides something. Works like ENT:PhysicsCollide.
Arguments: 1
- table | The collision data.
Returns: 0
✏️⚠️🔹 NEXTBOT:OnContact
Used to call NEXTBOT:OnTouch when there is a actual contact.
Arguments: 1
- Entity | Entity the nextbot came contact with.
Returns: 0
🔹 NEXTBOT:OnTouch
Called when bot touches something.
Arguments: 2
- Entity | Entity that bot touches.
- table | TraceResult touch data.
Returns: 0
⚠️🔹 NEXTBOT:SwitchCrouch
Changes crouch status.
Arguments: 1
- bool | Should change from stand to crouch, otherwise change from crouch to stand.
Returns: 0
🔹 NEXTBOT:GetCurrentNavArea
Returns current nav area where bot is.
Arguments: 0
Returns: 1
- NavArea | Current nav area.
🔹 NEXTBOT:GetPath
Returns last PathFollower object used for path finding.
Arguments: 0
Returns: 1
- PathFollower | PathFollower object.
🔹 NEXTBOT:PathIsValid
Returns whenever our PathFollower object is valid or not.
Arguments: 0
Returns: 1
- bool | PathFollower object is valid or not.
⚠️🔹 NEXTBOT:NavMeshPathCostGenerator
Used to remove some nav areas from path.
Arguments: 6
- PathFollower | Path object.
- NavArea | Current area generating cost to.
- NavArea | Current area generating cost from.
- NavLadder | Ladder object.
- Entity | Elevator entity.
- number | Distance between areas.
Returns: 1
- number | New cost for area. -1 to remove area from path.
🔹 NEXTBOT:SetupPath
Creates new PathFollower object and computes path to goal. Invalidates old path.
Arguments: 2
- Vector | Goal position.
- ⭕ table | Table with options:
- mindist - SetMinLookAheadDistance.
- tolerance - SetGoalTolerance.
- generator - Custom cost generator.
- recompute - recompute path every x seconds.
Returns: 1
- any | PathFollower object if created successfully, otherwise false.
⚠️🔹 NEXTBOT:ComputePath
Computes path to goal.
Arguments: 2
- Vector | Goal position.
- ⭕ function | Custom cost generator for A* algorithm.
Returns: 1
- bool | Path generated succesfully.
🔹 NEXTBOT:ControlPath
Moves along path. You should use this to move your bot.
Arguments: 1
- bool | Should bot look at goal while moving.
Returns: 1
- any | true on path successfully ended, false on path invalidate or path is invalid, nothing (nil) otherwise.
✏️⚠️🔹 NEXTBOT:OnNavAreaChanged
Saving new area as current. Also stops bot if area has NAV_MESH_STOP attribute.
⚠️🔹 NEXTBOT:Approach
Moving bot to goal.
Arguments: 1
- Vector | Goal.
Returns: 0
🔹 NEXTBOT:GetPathPos
Returns goal of path.
Arguments: 0
Returns: 1
- Vector | Goal position.
⚠️🔹 NEXTBOT:MoveAlongPath
Process movement along path.
Arguments: 1
- bool | Should bot look at goal while moving.
Returns: 1
- bool | Path was completed right now.
🔹 NEXTBOT:Jump
Use this to make bot jump.
Arguments: 0
Returns: 0
🔹 NEXTBOT:IsJumping
Bot is not on ground because he jump.
Arguments: 0
Returns: 1
- bool | Bot jumping.
✏️⚠️🔹 NEXTBOT:OnLandOnGround
Some functional with jumps
🔹 NEXTBOT:GetFootstepSoundTime
Returns next footstep sound time in ms.
Arguments: 0
Returns: 1
- number | Next time for footstep.
🔹 NEXTBOT:OnFootstep
Called when footstep sound should be played.
Arguments: 5
- Vector | Footstep sound position.
- bool | false - left foot, true - right foot.
- string | Path to default sound to play.
- number | Volume of footstep.
- CRecipientFilter | Decides who can hear footstep.
Returns: 1
- bool | Should we prevent default sound.
⚠️🔹 NEXTBOT:ProcessFootsteps
Called to update footstep data.
Arguments: 0
Returns: 0
⚠️🔹 NEXTBOT:MakeFootstepSound
Creates footstep sound.
Arguments: 2
- number | Sound volume.
- ⭕ number | ID of surface property.
Returns: 0
✏️⚠️🔹 NEXTBOT:OnStuck
Trying teleport if we stuck
✏️⚠️🔹 NEXTBOT:OnUnStuck
Handling OnUnStuck
🔹 NEXTBOT:StuckCheckShouldIgnoreEntity
Decides should stuck check ignore entity or not.
Arguments: 1
- Entity | Entity to check.
Returns: 1
- bool | Return true to skip entity.
⚠️🔹 NEXTBOT:StuckCheck
Updates bot stuck status.
Arguments: 0
Returns: 0
🔹 NEXTBOT:SetHullType
Sets hull type for bot.
Arguments: 1
- number | Hull type. See HULL_* Enums.
Returns: 0
🔹 NEXTBOT:GetHullType
Returns hull type for bot.
Arguments: 0
Returns: 1
- number | Hull type. See HULL_* Enums.
🔹 NEXTBOT:SetDuckHullType
Sets duck hull type for bot.
Arguments: 1
- number | Hull type. See HULL_* Enums.
Returns: 0
🔹 NEXTBOT:GetDuckHullType
Returns duck hull type for bot.
Arguments: 0
Returns: 1
- number | Hull type. See HULL_* Enums.
🔹 NEXTBOT:JumpToPos
Makes bot jump to given position. Jump height depends on height difference of given position and current position.
Arguments: 2
- Vector | Position to jump to.
- ⭕ number | Jump height. Default is CLuaLocomotion:GetJumpHeight()
Returns: 0