mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-11 11:48:37 +00:00
[Bots] Add support for Bot scripting. (#2515)
* [Bots] Add support for Bot scripting. # Perl - Add support for `zone/bot.pl` and `zone/bot_v#.pl`. - Add support for `global/global_bot.pl`. - Add `$bot->SignalBot(signal_id)` to Perl. - Add `$bot->OwnerMessage(message)` to Perl. - Add `$entity_list->SignalAllBotsByOwnerCharacterID(character_id, signal_id)` to Perl. - Add `$entity_list->SignalBotByBotID(bot_id, signal_id)` to Perl. - Add `$entity_list->SignalBotByBotName(bot_name, signal_id)` to Perl. - Add `EVENT_SPELL_EFFECT_BOT` to Perl. - Add `EVENT_SPELL_EFFECT_BUFF_TIC_BOT` to Perl. # Lua - Add support for `zone/bot.lua` and `zone/bot_v#.lua`. - Add support for `global/global_bot.lua`. - Add `bot:SignalBot(signal_id)` to Lua. - Add `bot:OwnerMessage(message)` to Lua. - Add `entity_list:SignalAllBotsByOwnerCharacterID(character_id, signal_id)` to Lua. - Add `entity_list:SignalBotByBotID(bot_id, signal_id)` to Lua. - Add `entity_list:SignalBotByBotName(bot_name, signal_id)` to Lua. - Add `EVENT_SPELL_EFFECT_BOT` to Lua. - Add `EVENT_SPELL_EFFECT_BUFF_TIC_BOT` to Lua. # Supported Bot Events 1. `EVENT_CAST` 2. `EVENT_CAST_BEGIN` 3. `EVENT_CAST_ON` 4. `EVENT_COMBAT` 5. `EVENT_DEATH` 6. `EVENT_DEATH_COMPLETE` 7. `EVENT_SAY` 8. `EVENT_SIGNAL` 9. `EVENT_SLAY` 10. `EVENT_SLAY_NPC` 11. `EVENT_SPAWN` 12. `EVENT_TARGET_CHANGE` 13. `EVENT_TIMER` 14. `EVENT_USE_SKILL` # Common - Convert NPC pointers in common events to Mob pointers so bots are supported. - Convert signal IDs to `int` where it wasn't already, allowing negative signals to be sent properly. * Add EVENT_POPUP_RESPONSE. * Cleanup and fix EVENT_COMBAT/EVENT_SLAY/EVENT_NPC_SLAY. * Fix DoNPCEmote calls. * Update attack.cpp * Update event_codes.h * Update bot_command.cpp
This commit is contained in:
+194
-32
@@ -36,20 +36,80 @@ class LuaParser : public QuestInterface {
|
||||
public:
|
||||
~LuaParser();
|
||||
|
||||
virtual int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int EventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int EventEncounter(QuestEventID evt, std::string encounter_name, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int EventNPC(
|
||||
QuestEventID evt,
|
||||
NPC* npc,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int EventGlobalNPC(
|
||||
QuestEventID evt,
|
||||
NPC* npc,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int EventPlayer(
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int EventGlobalPlayer(
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int EventItem(
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
EQ::ItemInstance *item,
|
||||
Mob *mob,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int EventSpell(
|
||||
QuestEventID evt,
|
||||
Mob* mob,
|
||||
Client *client,
|
||||
uint32 spell_id,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int EventEncounter(
|
||||
QuestEventID evt,
|
||||
std::string encounter_name,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
#ifdef BOTS
|
||||
virtual int EventBot(
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int EventGlobalBot(
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
#endif
|
||||
|
||||
virtual bool HasQuestSub(uint32 npc_id, QuestEventID evt);
|
||||
virtual bool HasGlobalQuestSub(QuestEventID evt);
|
||||
@@ -60,6 +120,11 @@ public:
|
||||
virtual bool EncounterHasQuestSub(std::string encounter_name, QuestEventID evt);
|
||||
virtual bool HasEncounterSub(const std::string& package_name, QuestEventID evt);
|
||||
|
||||
#ifdef BOTS
|
||||
virtual bool BotHasQuestSub(QuestEventID evt);
|
||||
virtual bool GlobalBotHasQuestSub(QuestEventID evt);
|
||||
#endif
|
||||
|
||||
virtual void LoadNPCScript(std::string filename, int npc_id);
|
||||
virtual void LoadGlobalNPCScript(std::string filename);
|
||||
virtual void LoadPlayerScript(std::string filename);
|
||||
@@ -68,6 +133,11 @@ public:
|
||||
virtual void LoadSpellScript(std::string filename, uint32 spell_id);
|
||||
virtual void LoadEncounterScript(std::string filename, std::string encounter_name);
|
||||
|
||||
#ifdef BOTS
|
||||
virtual void LoadBotScript(std::string filename);
|
||||
virtual void LoadGlobalBotScript(std::string filename);
|
||||
#endif
|
||||
|
||||
virtual void AddVar(std::string name, std::string val);
|
||||
virtual std::string GetVar(std::string name);
|
||||
virtual void Init();
|
||||
@@ -75,14 +145,50 @@ public:
|
||||
virtual void RemoveEncounter(const std::string &name);
|
||||
virtual uint32 GetIdentifier() { return 0xb0712acc; }
|
||||
|
||||
virtual int DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int DispatchEventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int DispatchEventItem(QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int DispatchEventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
virtual int DispatchEventNPC(
|
||||
QuestEventID evt,
|
||||
NPC* npc,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int DispatchEventPlayer(
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int DispatchEventItem(
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
EQ::ItemInstance *item,
|
||||
Mob *mob,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
virtual int DispatchEventSpell(
|
||||
QuestEventID evt,
|
||||
Mob* mob,
|
||||
Client *client,
|
||||
uint32 spell_id,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
#ifdef BOTS
|
||||
virtual int DispatchEventBot(
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
#endif
|
||||
|
||||
static LuaParser* Instance() {
|
||||
static LuaParser inst;
|
||||
@@ -107,16 +213,68 @@ private:
|
||||
LuaParser(const LuaParser&);
|
||||
LuaParser& operator=(const LuaParser&);
|
||||
|
||||
int _EventNPC(std::string package_name, QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
||||
int _EventPlayer(std::string package_name, QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
||||
int _EventItem(std::string package_name, QuestEventID evt, Client *client, EQ::ItemInstance *item, Mob *mob, std::string data,
|
||||
uint32 extra_data, std::vector<std::any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
||||
int _EventSpell(std::string package_name, QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
||||
int _EventEncounter(std::string package_name, QuestEventID evt, std::string encounter_name, std::string data, uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers);
|
||||
int _EventNPC(
|
||||
std::string package_name,
|
||||
QuestEventID evt,
|
||||
NPC* npc,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers,
|
||||
luabind::adl::object *l_func = nullptr
|
||||
);
|
||||
int _EventPlayer(
|
||||
std::string package_name,
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers,
|
||||
luabind::adl::object *l_func = nullptr
|
||||
);
|
||||
int _EventItem(
|
||||
std::string package_name,
|
||||
QuestEventID evt,
|
||||
Client *client,
|
||||
EQ::ItemInstance *item,
|
||||
Mob *mob,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers,
|
||||
luabind::adl::object *l_func = nullptr
|
||||
);
|
||||
int _EventSpell(
|
||||
std::string package_name,
|
||||
QuestEventID evt,
|
||||
Mob* mob,
|
||||
Client *client,
|
||||
uint32 spell_id,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers,
|
||||
luabind::adl::object *l_func = nullptr
|
||||
);
|
||||
int _EventEncounter(
|
||||
std::string package_name,
|
||||
QuestEventID evt,
|
||||
std::string encounter_name,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
#ifdef BOTS
|
||||
int _EventBot(
|
||||
std::string package_name,
|
||||
QuestEventID evt,
|
||||
Bot *bot,
|
||||
Mob *init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers,
|
||||
luabind::adl::object *l_func = nullptr
|
||||
);
|
||||
#endif
|
||||
|
||||
void LoadScript(std::string filename, std::string package_name);
|
||||
void MapFunctions(lua_State *L);
|
||||
@@ -133,6 +291,10 @@ private:
|
||||
SpellArgumentHandler SpellArgumentDispatch[_LargestEventID];
|
||||
EncounterArgumentHandler EncounterArgumentDispatch[_LargestEventID];
|
||||
|
||||
#ifdef BOTS
|
||||
BotArgumentHandler BotArgumentDispatch[_LargestEventID];
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user