PDA

View Full Version : [L4D2] INextBot Interface


BHaType
05-16-2020, 19:38
An extension that provides a large number of functions for working with the INextBot class.

/natives

INextBot.inc
native INextBot NextBot_GetINextBot(int bot);
native Address NextBot_GetInterface(INextBot bot, InterfacesList inteface);

// API
native bool NextBot_SetPosition (INextBot bot, float vOrigin[3]);
native void NextBot_GetPosition (INextBot bot, float vOrigin[3]);
native bool NextBot_IsEnemy (INextBot bot, int index);
native bool NextBot_IsFriend (INextBot bot, int index);
native bool NextBot_IsSelf (INextBot bot, int index);
native bool NextBot_IsAllowedToClimb (INextBot bot);
native bool NextBot_IsAbleToClimbOnto (INextBot bot, int index);
native bool NextBot_IsAbleToBreak (INextBot bot, int index);
native bool NextBot_IsAbleToBlockMovementOf (INextBot bot);
native void NextBot_ReactToSurvivorVisibility (INextBot bot);
native void NextBot_ReactToSurvivorNoise (INextBot bot);
native void NextBot_ReactToSurvivorContact (INextBot bot);
native bool NextBot_IsImmobile (INextBot bot);
native float NextBot_GetImmobileDuration (INextBot bot);
native void NextBot_ClearImmobileStatus (INextBot bot);
native float NextBot_GetImmobileSpeedThreshold (INextBot bot);
native bool NextBot_IsRangeLessThan (INextBot bot, int index, float range);
native bool NextBot_IsRangeGreaterThan (INextBot bot, int index, float range);
native float NextBot_GetRangeTo (INextBot bot, int index);
native float NextBot_GetRangeSquaredTo( INextBot bot, int index);
native float NextBot_Get2DRangeTo (INextBot bot, int index);
ILocomotion.inc
native void Locomotion_Approach(ILocomotion locomotion, float vOrigin[3], float flValue);
native void Locomotion_DriveTo(ILocomotion locomotion, float vOrigin[3]);
native bool Locomotion_ClimbUpToLedge(ILocomotion locomotion, float vSource[3], float vEnd[3], int index);
native void Locomotion_JumpAcrossGap(ILocomotion locomotion, float vSource[3], float vEnd[3]);
native void Locomotion_Jump(ILocomotion locomotion);
native bool Locomotion_IsClimbingOrJumping(ILocomotion locomotion);
native bool Locomotion_IsClimbingUpToLedge(ILocomotion locomotion);
native bool Locomotion_IsJumpingAcrossGap(ILocomotion locomotion);
native bool Locomotion_IsScrambling(ILocomotion locomotion);
native void Locomotion_Run(ILocomotion locomotion);
native void Locomotion_Walk(ILocomotion locomotion);
native void Locomotion_Stop(ILocomotion locomotion);
native bool Locomotion_IsRunning(ILocomotion locomotion);
native void Locomotion_SetDesiredSpeed(ILocomotion locomotion, float flValue);
native float Locomotion_GetDesiredSpeed(ILocomotion locomotion);
native void Locomotion_SetSpeedLimit(ILocomotion locomotion, float flValue);
native float Locomotion_GetSpeedLimit(ILocomotion locomotion);
native bool Locomotion_IsOnGround(ILocomotion locomotion);
native int Locomotion_GetGround(ILocomotion locomotion);
native void Locomotion_GetGroundNormal(ILocomotion locomotion, float vNormal[3]);
native float Locomotion_GetGroundSpeed(ILocomotion locomotion);
native void Locomotion_GetGroundMotionVector(ILocomotion locomotion, float vOrigin[3]);
native bool Locomotion_IsUsingLadder(ILocomotion locomotion);
native bool Locomotion_IsAscendingOrDescendingLadder(ILoc omotion locomotion);
native bool Locomotion_IsAbleToAutoCenterOnLadder(ILocomo tion locomotion);
native void Locomotion_FaceTowards(ILocomotion locomotion, float vSource[3]);
native void Locomotion_SetDesiredLean(ILocomotion locomotion, float vSource[3]);
native void Locomotion_GetDesiredLean(ILocomotion locomotion, float vSource[3]);
native void Locomotion_GetFeet(ILocomotion locomotion, float vFeet[3]);
native float Locomotion_GetStepHeight(ILocomotion locomotion);
native float Locomotion_GetMaxJumpHeight(ILocomotion locomotion);
native float Locomotion_GetDeathDropHeight(ILocomotion locomotion);
native float Locomotion_GetRunSpeed(ILocomotion locomotion);
native float Locomotion_GetWalkSpeed(ILocomotion locomotion);
native void Locomotion_GetVelocity(ILocomotion locomotion, float vVelocity[3]);
native float Locomotion_GetSpeed(ILocomotion locomotion);
native void Locomotion_GetMotionVector(ILocomotion locomotion, float vMVector[3]);
native bool Locomotion_IsPotentiallyTraversable(ILocomoti on locomotion, float vSource[3], float vEnd[3], TraverseWhenType type, float &fraction);
native bool Locomotion_HasPotentialGap(ILocomotion locomotion, float vSource[3], float vEnd[3], float &fraction);
native bool Locomotion_IsGap(ILocomotion locomotion, float vSource[3], float vEnd[3]);
native bool Locomotion_IsEntityTraversable(ILocomotion locomotion, int entity, TraverseWhenType type);
native bool Locomotion_IsStuck(ILocomotion locomotion);
native float Locomotion_GetStuckDuration(ILocomotion locomotion);
native void Locomotion_ClearStuckStatus(ILocomotion locomotion, char[] reason);
native bool Locomotion_IsAttemptingToMove(ILocomotion locomotion);
native void Locomotion_AdjustPosture(ILocomotion locomotion, float vPosture[3]);
IBody.inc
native void Body_SetPosition(IBody body, float vVec[3]);
native void Body_GetEyePosition(IBody body, float vVec[3]);
native void Body_GetViewVector(IBody body, float vVec[3]);
native void Body_AimHeadTowardsVector(IBody body, float vSource[3], LookAtPriorityType type, float duration, char[] reason);
native void Body_AimHeadTowardsEntity(IBody body, int index, LookAtPriorityType type, float duration, char[] reason);
native bool Body_IsHeadAimingOnTarget(IBody body);
native bool Body_IsHeadSteady(IBody body);
native float Body_GetHeadSteadyDuration(IBody body);
native float Body_GetMaxHeadAngularVelocity(IBody body);
native bool Body_StartActivity(IBody body, Activity act, int flags);
native int Body_SelectAnimationSequence(IBody body, Activity act);
native Activity Body_GetActivity(IBody body);
native bool Body_IsActivity(IBody body, Activity act);
native bool Body_HasActivityType(IBody body, int flags);
native void Body_SetDesiredPosture(IBody body, PostureType type);
native PostureType Body_GetDesiredPosture(IBody body);
native bool Body_IsDesiredPosture(IBody body, PostureType type);
native bool Body_IsInDesiredPosture(IBody body);
native PostureType Body_GetActualPosture(IBody body);
native bool Body_IsActualPosture(IBody body, PostureType type);
native bool Body_IsPostureMobile(IBody body);
native bool Body_IsPostureChanging(IBody body);
native void Body_SetArousal(IBody body, ArousalType type);
native ArousalType Body_GetArousal(IBody body);
native bool Body_IsArousal(IBody body, ArousalType type);
native float Body_GetHullWidth(IBody body);
native float Body_GetHullHeight(IBody body);
native float Body_GetStandHullHeight(IBody body);
native float Body_GetCrouchHullHeight(IBody body);
native void Body_GetHullMins(IBody body, float vMins[3]);
native void Body_GetHullMaxs(IBody body, float vMaxs[3]);
native int Body_GetSolidMask(IBody body)
IVision.inc
native float Vision_GetTimeSinceVisible(IVision vision, int team);
native int Vision_GetClosestRecognized(IVision vision, int team);
native int Vision_GetRecognizedCount(IVision vision, int team, float range);
native float Vision_GetMaxVisionRange(IVision vision);
native float Vision_GetMinRecognizeTime(IVision vision);
native bool Vision_IsAbleToSeeE(IVision vision, int index, FieldOfViewCheckType type, float vSource[3]);
native bool Vision_IsAbleToSeeV(IVision vision, float vSource[3], FieldOfViewCheckType type);
native bool Vision_IsNoticed(IVision vision, int index);
native bool Vision_IsIgnored(IVision vision, int index );
native bool Vision_IsInFieldOfViewV(IVision vision, float vSource[3]);
native bool Vision_IsInFieldOfViewE(IVision vision, int index);
native float Vision_GetDefaultFieldOfView(IVision vision);
native float Vision_GetFieldOfView(IVision vision);
native void Vision_SetFieldOfView(IVision vision, float flValue);
native bool Vision_IsLineOfSightClear(IVision vision, float vVec[3]);
native bool Vision_IsLineOfSightClearToEntity(IVision vision, int index, float vVec[3]);
native bool Vision_IsLookingAt(IVision vision, float vVec[3], float cosTolerance = 0.95);


Notes:
I have prescribed methodmap for each interface
In order to connect one of the interfaces you just need to register a define
Currently only Windows is supported

Example:
#include <sdktools>

//#define SMEXT_IBODY
//#define SMEXT_IVISION
#define SMEXT_ILOCOMOTION

#include <INextBot>

#pragma newdecls required
#pragma semicolon 1

public void OnPluginStart()
{
RegConsoleCmd("sm_cmd", ConConawd);
}

public Action ConConawd (int client, int args)
{
//int me = client;

client = GetClientAimTarget(client);

if (client <= 0)
return;

INextBot bot = INextBot(client);

ILocomotion locomotion = view_as<ILocomotion>(bot.GetInterface(ILocomotion_t));

locomotion.Jump();
}

Changelist:
0.1 - Fixed vector return

sourcefkccode (https://github.com/Vinillia/L4D2INextBot)

Psyk0tik
10-04-2020, 21:11
Great job on this. Maybe you can update it to include an Intention interface?

BHaType
10-22-2020, 02:11
Great job on this. Maybe you can update it to include an Intention interface?

As far as I remember the Itention interface is almost useless in l4d2