Closed KitRifty closed 2 years ago
Haven't forgotten about this, will review one final time, hopefully this month. I'm aiming at having the giant switch case eliminated before merging, will probably make commits changing that on this branch. I also need to soak deeper into this anyways, making sure I grasped everything considering this moved a lot of code.
This allows developers to customize
CBaseNPC_Locomotion
's behavior by giving the option to override its default functions through callbacks, in similar fashion toNextBotActionFactory
. Developers can now customize how the bot climbs, jumps, collides with other entities, and even determine if an entity is traversable or not. Developers can also still call the default behavior if desired in their callbacks using theCallBaseFunction
native. The default behavior will be called if no callback is set.CallBaseFunction
is restricted to be used within a callback function only as it's supposed to be a private thing. Outside of callbacks, developers should be calling the functions virtually anyway using theILocomotion
/NextBotGroundLocomotion
natives.Moreover this changes the locomotion to utilize its own vtable rather than hooks to call its functions. A lot of
NextBotGroundLocomotion
's functions were being overridden so it seemed more fitting to give the locomotion its own vtable, just like howCBaseNPC_Entity
does it. Thanks to being able to get the vtable offsets dynamically via SourceHook, the locomotion code is now separated into its own header and source files. We did discuss about grabbing offsets dynamically in Discord, but I was surprised to see thatVCall
already has anInit
function overload designed to do just that, so it wasn't a hard choice to make!The
CBaseNPC.GetLocomotion
native has been changed to return aCBaseNPC_Locomotion
object. Backwards compatibility with older plugins won't be an issue asCBaseNPC_Locomotion
inherits fromNextBotGroundLocomotion
.This also adds some helper macros inhelpers.h
in regards to using theVCall
object. This was made to reduce needless repetition in the code.This also removes the
SetCollisionBounds
native, as it's been deprecated and is no longer defined in the .inc files.Let me know if you want any changes!