mirror of
https://github.com/EQEmu/Server.git
synced 2026-08-30 17:58:16 +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:
+170
-27
@@ -48,18 +48,73 @@ public:
|
||||
PerlembParser();
|
||||
~PerlembParser();
|
||||
|
||||
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 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
|
||||
);
|
||||
|
||||
#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 npcid, QuestEventID evt);
|
||||
virtual bool HasGlobalQuestSub(QuestEventID evt);
|
||||
@@ -68,6 +123,11 @@ public:
|
||||
virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
|
||||
virtual bool ItemHasQuestSub(EQ::ItemInstance *itm, 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);
|
||||
@@ -75,6 +135,11 @@ public:
|
||||
virtual void LoadItemScript(std::string filename, EQ::ItemInstance *item);
|
||||
virtual void LoadSpellScript(std::string filename, uint32 spell_id);
|
||||
|
||||
#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 ReloadQuests();
|
||||
@@ -91,25 +156,98 @@ private:
|
||||
void ExportVar(const char* pkgprefix, const char* varname, const char* classname, void* value);
|
||||
void ExportVarComplex(const char *pkgprefix, const char *varname, const char *value);
|
||||
|
||||
int EventCommon(QuestEventID event, uint32 objid, const char * data, NPC* npcmob, EQ::ItemInstance* item_inst, const SPDat_Spell_Struct* spell, Mob* mob,
|
||||
uint32 extradata, bool global, std::vector<std::any> *extra_pointers);
|
||||
int SendCommands(const char *pkgprefix, const char *event, uint32 spell_id, Mob* other, Mob* mob, EQ::ItemInstance *item_inst, const SPDat_Spell_Struct *spell);
|
||||
int EventCommon(
|
||||
QuestEventID event,
|
||||
uint32 objid,
|
||||
const char* data,
|
||||
Mob* npcmob,
|
||||
EQ::ItemInstance* item_inst,
|
||||
const SPDat_Spell_Struct* spell,
|
||||
Mob* mob,
|
||||
uint32 extradata,
|
||||
bool global,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
int SendCommands(
|
||||
const char *pkgprefix,
|
||||
const char *event,
|
||||
uint32 spell_id,
|
||||
Mob* other,
|
||||
Mob* mob,
|
||||
EQ::ItemInstance *item_inst,
|
||||
const SPDat_Spell_Struct *spell
|
||||
);
|
||||
void MapFunctions();
|
||||
|
||||
void GetQuestTypes(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
|
||||
bool &isSpellQuest, QuestEventID event, NPC* npcmob, EQ::ItemInstance* item_inst, Mob* mob, bool global);
|
||||
void GetQuestPackageName(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
|
||||
bool &isSpellQuest, std::string &package_name, QuestEventID event, uint32 objid, const char * data,
|
||||
NPC* npcmob, EQ::ItemInstance* item_inst, bool global);
|
||||
void ExportCharID(const std::string &package_name, int &char_id, NPC *npcmob, Mob *mob);
|
||||
void ExportQGlobals(bool isPlayerQuest, bool isGlobalPlayerQuest, bool isGlobalNPC, bool isItemQuest,
|
||||
bool isSpellQuest, std::string &package_name, NPC *npcmob, Mob *mob, int char_id);
|
||||
void ExportMobVariables(bool isPlayerQuest, bool isGlobalPlayerQuest, bool isGlobalNPC, bool isItemQuest,
|
||||
bool isSpellQuest, std::string &package_name, Mob *mob, NPC *npcmob);
|
||||
void GetQuestTypes(
|
||||
bool &isPlayerQuest,
|
||||
bool &isGlobalPlayerQuest,
|
||||
bool &isBotQuest,
|
||||
bool &isGlobalBotQuest,
|
||||
bool &isGlobalNPC,
|
||||
bool &isItemQuest,
|
||||
bool &isSpellQuest,
|
||||
QuestEventID event,
|
||||
Mob* npcmob,
|
||||
EQ::ItemInstance* item_inst,
|
||||
Mob* mob,
|
||||
bool global
|
||||
);
|
||||
void GetQuestPackageName(
|
||||
bool &isPlayerQuest,
|
||||
bool &isGlobalPlayerQuest,
|
||||
bool &isBotQuest,
|
||||
bool &isGlobalBotQuest,
|
||||
bool &isGlobalNPC,
|
||||
bool &isItemQuest,
|
||||
bool &isSpellQuest,
|
||||
std::string &package_name,
|
||||
QuestEventID event,
|
||||
uint32 objid,
|
||||
const char * data,
|
||||
Mob* npcmob,
|
||||
EQ::ItemInstance* item_inst,
|
||||
bool global
|
||||
);
|
||||
void ExportCharID(const std::string &package_name, int &char_id, Mob *npcmob, Mob *mob);
|
||||
void ExportQGlobals(
|
||||
bool isPlayerQuest,
|
||||
bool isGlobalPlayerQuest,
|
||||
bool isBotQuest,
|
||||
bool isGlobalBotQuest,
|
||||
bool isGlobalNPC,
|
||||
bool isItemQuest,
|
||||
bool isSpellQuest,
|
||||
std::string &package_name,
|
||||
Mob *npcmob,
|
||||
Mob *mob,
|
||||
int char_id
|
||||
);
|
||||
void ExportMobVariables(
|
||||
bool isPlayerQuest,
|
||||
bool isGlobalPlayerQuest,
|
||||
bool isBotQuest,
|
||||
bool isGlobalBotQuest,
|
||||
bool isGlobalNPC,
|
||||
bool isItemQuest,
|
||||
bool isSpellQuest,
|
||||
std::string &package_name,
|
||||
Mob *mob,
|
||||
Mob *npcmob
|
||||
);
|
||||
void ExportZoneVariables(std::string &package_name);
|
||||
void ExportItemVariables(std::string &package_name, Mob *mob);
|
||||
void ExportEventVariables(std::string &package_name, QuestEventID event, uint32 objid, const char * data,
|
||||
NPC* npcmob, EQ::ItemInstance* item_inst, Mob* mob, uint32 extradata, std::vector<std::any> *extra_pointers);
|
||||
void ExportEventVariables(
|
||||
std::string &package_name,
|
||||
QuestEventID event,
|
||||
uint32 objid,
|
||||
const char* data,
|
||||
Mob* npcmob,
|
||||
EQ::ItemInstance* item_inst,
|
||||
Mob* mob,
|
||||
uint32 extradata,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
std::map<uint32, PerlQuestStatus> npc_quest_status_;
|
||||
PerlQuestStatus global_npc_quest_status_;
|
||||
@@ -118,6 +256,11 @@ private:
|
||||
std::map<uint32, PerlQuestStatus> item_quest_status_;
|
||||
std::map<uint32, PerlQuestStatus> spell_quest_status_;
|
||||
|
||||
#ifdef BOTS
|
||||
PerlQuestStatus bot_quest_status_;
|
||||
PerlQuestStatus global_bot_quest_status_;
|
||||
#endif
|
||||
|
||||
std::map<std::string, std::string> vars_;
|
||||
SV *_empty_sv;
|
||||
std::map<std::string, int> clear_vars_;
|
||||
|
||||
Reference in New Issue
Block a user