add: basic amxx module api (actual module pending).
This commit is contained in:
parent
fc080e1a4e
commit
f23d031d2c
8 changed files with 160 additions and 2 deletions
|
|
@ -5308,6 +5308,17 @@ void Bot::startDoubleJump (edict_t *ent) {
|
|||
sendToChat (strings.format ("Ok %s, i will help you!", ent->v.netname.chars ()), true);
|
||||
}
|
||||
|
||||
void Bot::sendBotToOrigin (const Vector &origin) {
|
||||
clearSearchNodes ();
|
||||
clearTask (Task::MoveToPosition); // remove any move tasks
|
||||
|
||||
m_position = origin;
|
||||
startTask (Task::MoveToPosition, TaskPri::MoveToPosition, kInvalidNodeIndex, 0.0f, true);
|
||||
|
||||
m_chosenGoalIndex = graph.getNearest (origin);
|
||||
getTask ()->data = m_chosenGoalIndex;
|
||||
}
|
||||
|
||||
void Bot::resetDoubleJump () {
|
||||
completeTask ();
|
||||
|
||||
|
|
|
|||
89
src/module.cpp
Normal file
89
src/module.cpp
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
//
|
||||
// YaPB - Counter-Strike Bot based on PODBot by Markus Klinge.
|
||||
// Copyright © 2004-2020 YaPB Project <yapb@jeefo.net>.
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
|
||||
#include <yapb.h>
|
||||
|
||||
// module interface implementation
|
||||
class YaPBModule : public IYaPBModule, public Singleton <YaPBModule> {
|
||||
public:
|
||||
// get the bot version string
|
||||
virtual const char *getBotVersion () override {
|
||||
return product.version.chars ();
|
||||
}
|
||||
|
||||
// checks if bots are currently in game
|
||||
virtual bool isBotsInGame () override {
|
||||
return bots.getBotCount () > 0 ;
|
||||
}
|
||||
|
||||
// checks whether specified players is a yapb bot
|
||||
virtual bool isBot (int entity) override {
|
||||
return bots[entity] != nullptr;
|
||||
}
|
||||
|
||||
// gets the node nearest to origin
|
||||
virtual int getNearestNode (const Vector &origin) override {
|
||||
if (graph.length () > 0) {
|
||||
return graph.getNearest (origin);
|
||||
}
|
||||
return kInvalidNodeIndex;
|
||||
}
|
||||
|
||||
// checks wether node is valid
|
||||
virtual bool isNodeValid (int node) override {
|
||||
return graph.exists (node);
|
||||
}
|
||||
|
||||
// gets the node origin
|
||||
virtual float *getNodeOrigin (int node) override {
|
||||
if (!graph.exists (node)) {
|
||||
return nullptr;
|
||||
}
|
||||
return graph[node].origin;
|
||||
}
|
||||
|
||||
// get the bots current active node
|
||||
virtual int getCurrentNodeId (int entity) override {
|
||||
auto bot = bots[entity];
|
||||
|
||||
if (bot) {
|
||||
return bot->getCurrentNodeIndex ();
|
||||
}
|
||||
return kInvalidNodeIndex;
|
||||
}
|
||||
|
||||
// force bot to go to the selected node
|
||||
virtual void setBotGoal (int entity, int node) {
|
||||
if (!graph.exists (node)) {
|
||||
return;
|
||||
}
|
||||
auto bot = bots[entity];
|
||||
|
||||
if (bot) {
|
||||
return bot->sendBotToOrigin (graph[node].origin);
|
||||
}
|
||||
}
|
||||
|
||||
// force bot to go to selected origin
|
||||
virtual void setBotGoalOrigin (int entity, float *origin) {
|
||||
auto bot = bots[entity];
|
||||
|
||||
if (bot) {
|
||||
return bot->sendBotToOrigin (origin);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CR_EXPOSE_GLOBAL_SINGLETON (YaPBModule, botModule);
|
||||
|
||||
// export all the stuff, maybe add versioned interface ?
|
||||
CR_EXPORT IYaPBModule *GetBotAPI (int version) {
|
||||
if (version != kYaPBModuleVersion) {
|
||||
return nullptr;
|
||||
}
|
||||
return &botModule;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue