mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 19:10:25 +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:
+46
-20
@@ -5100,14 +5100,12 @@ void EntityList::GateAllClients()
|
||||
}
|
||||
}
|
||||
|
||||
void EntityList::SignalAllClients(uint32 data)
|
||||
void EntityList::SignalAllClients(int signal_id)
|
||||
{
|
||||
auto it = client_list.begin();
|
||||
while (it != client_list.end()) {
|
||||
Client *ent = it->second;
|
||||
if (ent)
|
||||
ent->Signal(data);
|
||||
++it;
|
||||
for (const auto& c : client_list) {
|
||||
if (c.second) {
|
||||
c.second->Signal(signal_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5159,8 +5157,9 @@ void EntityList::GetClientList(std::list<Client *> &c_list)
|
||||
void EntityList::GetBotList(std::list<Bot *> &b_list)
|
||||
{
|
||||
b_list.clear();
|
||||
for (auto bot : bot_list) {
|
||||
b_list.push_back(bot);
|
||||
|
||||
for (const auto& b : bot_list) {
|
||||
b_list.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5172,16 +5171,12 @@ std::vector<Bot *> EntityList::GetBotListByCharacterID(uint32 character_id, uint
|
||||
return client_bot_list;
|
||||
}
|
||||
|
||||
for (auto bot : bot_list) {
|
||||
for (const auto& b : bot_list) {
|
||||
if (
|
||||
bot->GetOwner() &&
|
||||
bot->GetBotOwnerCharacterID() == character_id &&
|
||||
(
|
||||
!class_id ||
|
||||
bot->GetClass() == class_id
|
||||
)
|
||||
b->GetOwner() &&
|
||||
b->GetBotOwnerCharacterID() == character_id
|
||||
) {
|
||||
client_bot_list.push_back(bot);
|
||||
client_bot_list.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5196,14 +5191,45 @@ std::vector<Bot *> EntityList::GetBotListByClientName(std::string client_name)
|
||||
return client_bot_list;
|
||||
}
|
||||
|
||||
for (auto bot : bot_list) {
|
||||
if (bot->GetOwner() && Strings::ToLower(bot->GetOwner()->GetCleanName()) == Strings::ToLower(client_name)) {
|
||||
client_bot_list.push_back(bot);
|
||||
for (const auto& b : bot_list) {
|
||||
if (
|
||||
b->GetOwner() &&
|
||||
Strings::ToLower(b->GetOwner()->GetCleanName()) == Strings::ToLower(client_name)
|
||||
) {
|
||||
client_bot_list.push_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
return client_bot_list;
|
||||
}
|
||||
|
||||
void EntityList::SignalAllBotsByOwnerCharacterID(uint32 character_id, int signal_id)
|
||||
{
|
||||
auto client_bot_list = GetBotListByCharacterID(character_id);
|
||||
if (client_bot_list.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& b : client_bot_list) {
|
||||
b->SignalBot(signal_id);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityList::SignalBotByBotID(uint32 bot_id, int signal_id)
|
||||
{
|
||||
auto b = GetBotByBotID(bot_id);
|
||||
if (b) {
|
||||
b->SignalBot(signal_id);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityList::SignalBotByBotName(std::string bot_name, int signal_id)
|
||||
{
|
||||
auto b = GetBotByBotName(bot_name);
|
||||
if (b) {
|
||||
b->SignalBot(signal_id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void EntityList::GetCorpseList(std::list<Corpse *> &c_list)
|
||||
|
||||
Reference in New Issue
Block a user