[Quest API] Add CampAllBots() to Perl/Lua. (#2732)

# Perl
- Add `$client->CampAllBots()`.
- Add `$client->CampAllBots(class_id)`.

# Lua
- Add `client:CampAllBots()`.
- Add `client:CampAllBots(class_id)`.

# Notes
- Adds constants for `NO_CLASS` which is class `0` and uses `RACE_DOUG_0` for any spots that use race ID `0`.
- Cleans up magic number usage of race/class of `0`.
This commit is contained in:
Alex King 2023-01-14 10:14:50 -05:00 committed by GitHub
parent 095f4fb56c
commit f5523b40d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 77 additions and 30 deletions

View File

@ -20,6 +20,7 @@
#include "../common/types.h" #include "../common/types.h"
#define NO_CLASS 0
#define WARRIOR 1 #define WARRIOR 1
#define CLERIC 2 #define CLERIC 2
#define PALADIN 3 #define PALADIN 3

View File

@ -26,6 +26,8 @@
#include "item_instance.h" #include "item_instance.h"
#include "classes.h"
#include "races.h"
#include <list> #include <list>
#include <vector> #include <vector>
@ -130,7 +132,7 @@ namespace EQ
// Swap items in inventory // Swap items in inventory
enum SwapItemFailState : int8 { swapInvalid = -1, swapPass = 0, swapNotAllowed, swapNullData, swapRaceClass, swapDeity, swapLevel }; enum SwapItemFailState : int8 { swapInvalid = -1, swapPass = 0, swapNotAllowed, swapNullData, swapRaceClass, swapDeity, swapLevel };
bool SwapItem(int16 source_slot, int16 destination_slot, SwapItemFailState& fail_state, uint16 race_id = 0, uint8 class_id = 0, uint16 deity_id = 0, uint8 level = 0); bool SwapItem(int16 source_slot, int16 destination_slot, SwapItemFailState& fail_state, uint16 race_id = RACE_DOUG_0, uint8 class_id = NO_CLASS, uint16 deity_id = deity::DeityType::DeityUnknown, uint8 level = 0);
// Remove item from inventory // Remove item from inventory
bool DeleteItem(int16 slot_id, int16 quantity = 0); bool DeleteItem(int16 slot_id, int16 quantity = 0);

View File

@ -1249,7 +1249,7 @@ int EQ::ItemInstance::GetItemBaneDamageBody(bool augments) const
int EQ::ItemInstance::GetItemBaneDamageRace(bool augments) const int EQ::ItemInstance::GetItemBaneDamageRace(bool augments) const
{ {
int race = 0; int race = RACE_DOUG_0;
const auto item = GetItem(); const auto item = GetItem();
if (item) { if (item) {
race = item->BaneDmgRace; race = item->BaneDmgRace;

View File

@ -23,6 +23,7 @@
#include "zonelist.h" #include "zonelist.h"
#include "../common/misc_functions.h" #include "../common/misc_functions.h"
#include "../common/classes.h"
extern ClientList client_list; extern ClientList client_list;
extern ZSList zoneserver_list; extern ZSList zoneserver_list;
@ -32,7 +33,7 @@ GroupLFP::GroupLFP(uint32 inLeaderID) {
LeaderID = inLeaderID; LeaderID = inLeaderID;
for (auto &member : Members) { for (auto &member : Members) {
member.Name[0] = '\0'; member.Name[0] = '\0';
member.Class = 0; member.Class = NO_CLASS;
member.Level = 0; member.Level = 0;
member.Zone = 0; member.Zone = 0;
} }
@ -76,7 +77,7 @@ void GroupLFP::SetDetails(ServerLFPUpdate_Struct *Update) {
Members[i].GuildID = CLE->GuildID(); Members[i].GuildID = CLE->GuildID();
} }
else { else {
Members[i].Class = 0; Members[i].Class = NO_CLASS;
Members[i].Level = 0; Members[i].Level = 0;
Members[i].Zone = 0; Members[i].Zone = 0;
Members[i].GuildID = 0xFFFF; Members[i].GuildID = 0xFFFF;

View File

@ -6220,11 +6220,14 @@ void Bot::EquipBot(std::string* error_message) {
UpdateEquipmentLight(); UpdateEquipmentLight();
} }
void Bot::BotOrderCampAll(Client* c) { void Bot::BotOrderCampAll(Client* c, uint8 class_id) {
if (c) { if (c) {
std::list<Bot*> BotList = entity_list.GetBotsByBotOwnerCharacterID(c->CharacterID()); const auto& l = entity_list.GetBotsByBotOwnerCharacterID(c->CharacterID());
for(std::list<Bot*>::iterator botListItr = BotList.begin(); botListItr != BotList.end(); ++botListItr) for (const auto& b : l) {
(*botListItr)->Camp(); if (!class_id || b->GetClass() == class_id) {
b->Camp();
}
}
} }
} }

View File

@ -393,14 +393,14 @@ public:
// Static Class Methods // Static Class Methods
//static void DestroyBotRaidObjects(Client* client); // Can be removed after bot raids are dumped //static void DestroyBotRaidObjects(Client* client); // Can be removed after bot raids are dumped
static Bot* LoadBot(uint32 botID); static Bot* LoadBot(uint32 botID);
static uint32 SpawnedBotCount(const uint32 owner_id, uint8 class_id = 0); static uint32 SpawnedBotCount(const uint32 owner_id, uint8 class_id = NO_CLASS);
static void LevelBotWithClient(Client* client, uint8 level, bool sendlvlapp); static void LevelBotWithClient(Client* client, uint8 level, bool sendlvlapp);
//static bool SetBotOwnerCharacterID(uint32 botID, uint32 botOwnerCharacterID, std::string* error_message); //static bool SetBotOwnerCharacterID(uint32 botID, uint32 botOwnerCharacterID, std::string* error_message);
static bool IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined); static bool IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined);
static Bot* GetBotByBotClientOwnerAndBotName(Client* c, std::string botName); static Bot* GetBotByBotClientOwnerAndBotName(Client* c, std::string botName);
static void ProcessBotGroupInvite(Client* c, std::string botName); static void ProcessBotGroupInvite(Client* c, std::string botName);
static void ProcessBotGroupDisband(Client* c, std::string botName); static void ProcessBotGroupDisband(Client* c, std::string botName);
static void BotOrderCampAll(Client* c); static void BotOrderCampAll(Client* c, uint8 class_id = NO_CLASS);
static void ProcessBotInspectionRequest(Bot* inspectedBot, Client* client); static void ProcessBotInspectionRequest(Bot* inspectedBot, Client* client);
static void LoadAndSpawnAllZonedBots(Client* bot_owner); static void LoadAndSpawnAllZonedBots(Client* bot_owner);
static bool GroupHasBot(Group* group); static bool GroupHasBot(Group* group);

View File

@ -6548,7 +6548,7 @@ void bot_subcommand_bot_spawn(Client *c, const Seperator *sep)
std::string bot_name = sep->arg[1]; std::string bot_name = sep->arg[1];
uint32 bot_id = 0; uint32 bot_id = 0;
uint8 bot_class = 0; uint8 bot_class = NO_CLASS;
if (!database.botdb.LoadBotID(c->CharacterID(), bot_name, bot_id, bot_class)) { if (!database.botdb.LoadBotID(c->CharacterID(), bot_name, bot_id, bot_class)) {
c->Message( c->Message(
Chat::White, Chat::White,

View File

@ -687,7 +687,7 @@ void helper_command_depart_list(Client* bot_owner, Bot* druid_bot, Bot* wizard_b
bool helper_is_help_or_usage(const char* arg); bool helper_is_help_or_usage(const char* arg);
bool helper_no_available_bots(Client *bot_owner, Bot *my_bot = nullptr); bool helper_no_available_bots(Client *bot_owner, Bot *my_bot = nullptr);
void helper_send_available_subcommands(Client *bot_owner, const char* command_simile, const std::list<const char*>& subcommand_list); void helper_send_available_subcommands(Client *bot_owner, const char* command_simile, const std::list<const char*>& subcommand_list);
void helper_send_usage_required_bots(Client *bot_owner, BCEnum::SpType spell_type, uint8 bot_class = 0); void helper_send_usage_required_bots(Client *bot_owner, BCEnum::SpType spell_type, uint8 bot_class = NO_CLASS);
bool helper_spell_check_fail(STBaseEntry* local_entry); bool helper_spell_check_fail(STBaseEntry* local_entry);
bool helper_spell_list_fail(Client *bot_owner, bcst_list* spell_list, BCEnum::SpType spell_type); bool helper_spell_list_fail(Client *bot_owner, bcst_list* spell_list, BCEnum::SpType spell_type);
#endif #endif

View File

@ -4091,7 +4091,7 @@ void Client::UpdateLFP() {
for(unsigned int i=0; i<MAX_GROUP_MEMBERS; i++) { for(unsigned int i=0; i<MAX_GROUP_MEMBERS; i++) {
LFPMembers[i].Name[0] = '\0'; LFPMembers[i].Name[0] = '\0';
LFPMembers[i].Class = 0; LFPMembers[i].Class = NO_CLASS;
LFPMembers[i].Level = 0; LFPMembers[i].Level = 0;
LFPMembers[i].Zone = 0; LFPMembers[i].Zone = 0;
} }

View File

@ -2068,12 +2068,14 @@ public:
bool GetBotPrecombat() { return m_bot_precombat; } bool GetBotPrecombat() { return m_bot_precombat; }
void SetBotPrecombat(bool flag = true) { m_bot_precombat = flag; } void SetBotPrecombat(bool flag = true) { m_bot_precombat = flag; }
int GetBotRequiredLevel(uint8 class_id = 0); int GetBotRequiredLevel(uint8 class_id = NO_CLASS);
uint32 GetBotCreationLimit(uint8 class_id = 0); uint32 GetBotCreationLimit(uint8 class_id = NO_CLASS);
int GetBotSpawnLimit(uint8 class_id = 0); int GetBotSpawnLimit(uint8 class_id = NO_CLASS);
void SetBotCreationLimit(uint32 new_creation_limit, uint8 class_id = 0); void SetBotCreationLimit(uint32 new_creation_limit, uint8 class_id = NO_CLASS);
void SetBotRequiredLevel(int new_required_level, uint8 class_id = 0); void SetBotRequiredLevel(int new_required_level, uint8 class_id = NO_CLASS);
void SetBotSpawnLimit(int new_spawn_limit, uint8 class_id = 0); void SetBotSpawnLimit(int new_spawn_limit, uint8 class_id = NO_CLASS);
void CampAllBots(uint8 class_id = NO_CLASS);
private: private:
bool bot_owner_options[_booCount]; bool bot_owner_options[_booCount];

View File

@ -1,5 +1,6 @@
#ifdef BOTS #ifdef BOTS
#include "bot.h"
#include "client.h" #include "client.h"
bool Client::GetBotOption(BotOwnerOption boo) const { bool Client::GetBotOption(BotOwnerOption boo) const {
@ -156,4 +157,9 @@ void Client::SetBotSpawnLimit(int new_spawn_limit, uint8 class_id)
SetBucket(bucket_name, std::to_string(new_spawn_limit)); SetBucket(bucket_name, std::to_string(new_spawn_limit));
} }
void Client::CampAllBots(uint8 class_id)
{
Bot::BotOrderCampAll(this, class_id);
}
#endif #endif

View File

@ -9515,7 +9515,7 @@ void Client::Handle_OP_LFPCommand(const EQApplicationPacket *app)
for (unsigned int i = 0; i<MAX_GROUP_MEMBERS; i++) { for (unsigned int i = 0; i<MAX_GROUP_MEMBERS; i++) {
LFPMembers[i].Name[0] = '\0'; LFPMembers[i].Name[0] = '\0';
LFPMembers[i].Class = 0; LFPMembers[i].Class = NO_CLASS;
LFPMembers[i].Level = 0; LFPMembers[i].Level = 0;
LFPMembers[i].Zone = 0; LFPMembers[i].Zone = 0;
LFPMembers[i].GuildID = 0xFFFF; LFPMembers[i].GuildID = 0xFFFF;

View File

@ -5027,9 +5027,9 @@ void EntityList::ZoneWho(Client *c, Who_All_Struct *Who)
FormatMSGID = 5024; // 5024 %T1[ANONYMOUS] %2 %3 FormatMSGID = 5024; // 5024 %T1[ANONYMOUS] %2 %3
else if (ClientEntry->GetAnon() == 2) else if (ClientEntry->GetAnon() == 2)
FormatMSGID = 5023; // 5023 %T1[ANONYMOUS] %2 %3 %4 FormatMSGID = 5023; // 5023 %T1[ANONYMOUS] %2 %3 %4
uint32 PlayerClass = 0; uint32 PlayerClass = NO_CLASS;
uint32 PlayerLevel = 0; uint32 PlayerLevel = 0;
uint32 PlayerRace = 0; uint32 PlayerRace = RACE_DOUG_0;
uint32 ZoneMSGID = 0xFFFFFFFF; uint32 ZoneMSGID = 0xFFFFFFFF;
if (ClientEntry->GetAnon()==0) { if (ClientEntry->GetAnon()==0) {

View File

@ -550,8 +550,8 @@ public:
inline const std::unordered_map<uint16, Client *> &GetClientList() { return client_list; } inline const std::unordered_map<uint16, Client *> &GetClientList() { return client_list; }
#ifdef BOTS #ifdef BOTS
inline const std::list<Bot *> &GetBotList() { return bot_list; } inline const std::list<Bot *> &GetBotList() { return bot_list; }
std::vector<Bot *> GetBotListByCharacterID(uint32 character_id, uint8 class_id = 0); std::vector<Bot *> GetBotListByCharacterID(uint32 character_id, uint8 class_id = NO_CLASS);
std::vector<Bot *> GetBotListByClientName(std::string client_name, uint8 class_id = 0); std::vector<Bot *> GetBotListByClientName(std::string client_name, uint8 class_id = NO_CLASS);
void SignalAllBotsByOwnerCharacterID(uint32 character_id, int signal_id); void SignalAllBotsByOwnerCharacterID(uint32 character_id, int signal_id);
void SignalAllBotsByOwnerName(std::string owner_name, int signal_id); void SignalAllBotsByOwnerName(std::string owner_name, int signal_id);
void SignalBotByBotID(uint32 bot_id, int signal_id); void SignalBotByBotID(uint32 bot_id, int signal_id);

View File

@ -3010,6 +3010,18 @@ void Lua_Client::SetBotSpawnLimit(int new_spawn_limit, uint8 class_id)
self->SetBotSpawnLimit(new_spawn_limit, class_id); self->SetBotSpawnLimit(new_spawn_limit, class_id);
} }
void Lua_Client::CampAllBots()
{
Lua_Safe_Call_Void();
self->CampAllBots();
}
void Lua_Client::CampAllBots(uint8 class_id)
{
Lua_Safe_Call_Void();
self->CampAllBots(class_id);
}
#endif #endif
luabind::scope lua_register_client() { luabind::scope lua_register_client() {
@ -3070,6 +3082,10 @@ luabind::scope lua_register_client() {
.def("CalcEXP", (uint64(Lua_Client::*)(uint8))&Lua_Client::CalcEXP) .def("CalcEXP", (uint64(Lua_Client::*)(uint8))&Lua_Client::CalcEXP)
.def("CalcEXP", (uint64(Lua_Client::*)(uint8,bool))&Lua_Client::CalcEXP) .def("CalcEXP", (uint64(Lua_Client::*)(uint8,bool))&Lua_Client::CalcEXP)
.def("CalcPriceMod", (float(Lua_Client::*)(Lua_Mob,bool))&Lua_Client::CalcPriceMod) .def("CalcPriceMod", (float(Lua_Client::*)(Lua_Mob,bool))&Lua_Client::CalcPriceMod)
#ifdef BOTS
.def("CampAllBots", (void(Lua_Client::*)(void))&Lua_Client::CampAllBots)
.def("CampAllBots", (void(Lua_Client::*)(uint8))&Lua_Client::CampAllBots)
#endif
.def("CanEnterZone", (bool(Lua_Client::*)(std::string))&Lua_Client::CanEnterZone) .def("CanEnterZone", (bool(Lua_Client::*)(std::string))&Lua_Client::CanEnterZone)
.def("CanEnterZone", (bool(Lua_Client::*)(std::string,int16))&Lua_Client::CanEnterZone) .def("CanEnterZone", (bool(Lua_Client::*)(std::string,int16))&Lua_Client::CanEnterZone)
.def("CanHaveSkill", (bool(Lua_Client::*)(int))&Lua_Client::CanHaveSkill) .def("CanHaveSkill", (bool(Lua_Client::*)(int))&Lua_Client::CanHaveSkill)

View File

@ -537,6 +537,8 @@ public:
void SetBotCreationLimit(uint32 new_creation_limit, uint8 class_id); void SetBotCreationLimit(uint32 new_creation_limit, uint8 class_id);
void SetBotSpawnLimit(int new_spawn_limit); void SetBotSpawnLimit(int new_spawn_limit);
void SetBotSpawnLimit(int new_spawn_limit, uint8 class_id); void SetBotSpawnLimit(int new_spawn_limit, uint8 class_id);
void CampAllBots();
void CampAllBots(uint8 class_id);
#endif #endif

View File

@ -1571,7 +1571,7 @@ void Lua_Mob::SendIllusionPacket(luabind::adl::object illusion) {
return; return;
} }
int race = 0; int race = RACE_DOUG_0;
int gender = 255; int gender = 255;
int texture = 255; int texture = 255;
int helmtexture = 255; int helmtexture = 255;

View File

@ -2871,6 +2871,16 @@ void Perl_Client_SetBotSpawnLimit(Client* self, int new_spawn_limit, uint8 class
self->SetBotSpawnLimit(new_spawn_limit, class_id); self->SetBotSpawnLimit(new_spawn_limit, class_id);
} }
void Perl_Client_CampAllBots(Client* self)
{
self->CampAllBots();
}
void Perl_Client_CampAllBots(Client* self, uint8 class_id)
{
self->CampAllBots(class_id);
}
#endif #endif
void perl_register_client() void perl_register_client()
@ -2934,6 +2944,10 @@ void perl_register_client()
package.add("CalcPriceMod", (float(*)(Client*))&Perl_Client_CalcPriceMod); package.add("CalcPriceMod", (float(*)(Client*))&Perl_Client_CalcPriceMod);
package.add("CalcPriceMod", (float(*)(Client*, Mob*))&Perl_Client_CalcPriceMod); package.add("CalcPriceMod", (float(*)(Client*, Mob*))&Perl_Client_CalcPriceMod);
package.add("CalcPriceMod", (float(*)(Client*, Mob*, bool))&Perl_Client_CalcPriceMod); package.add("CalcPriceMod", (float(*)(Client*, Mob*, bool))&Perl_Client_CalcPriceMod);
#ifdef BOTS
package.add("CampAllBots", (void(*)(Client*))&Perl_Client_CampAllBots);
package.add("CampAllBots", (void(*)(Client*, uint8))&Perl_Client_CampAllBots);
#endif
package.add("CanEnterZone", (bool(*)(Client*, std::string))&Perl_Client_CanEnterZone); package.add("CanEnterZone", (bool(*)(Client*, std::string))&Perl_Client_CanEnterZone);
package.add("CanEnterZone", (bool(*)(Client*, std::string, int16))&Perl_Client_CanEnterZone); package.add("CanEnterZone", (bool(*)(Client*, std::string, int16))&Perl_Client_CanEnterZone);
package.add("CanHaveSkill", &Perl_Client_CanHaveSkill); package.add("CanHaveSkill", &Perl_Client_CanHaveSkill);

View File

@ -71,8 +71,8 @@ void Petition::SendPetitionToPlayer(Client* clientto) {
Petition::Petition(uint32 id) Petition::Petition(uint32 id)
{ {
petid = id; petid = id;
charclass = 0; charclass = NO_CLASS;
charrace = 0; charrace = RACE_DOUG_0;
charlevel = 0; charlevel = 0;
checkouts = 0; checkouts = 0;
unavailables = 0; unavailables = 0;

View File

@ -362,8 +362,8 @@ public:
inline bool ProximitySayInUse() { return HaveProximitySays; } inline bool ProximitySayInUse() { return HaveProximitySays; }
#ifdef BOTS #ifdef BOTS
int createbotcount(uint8 class_id = 0); int createbotcount(uint8 class_id = NO_CLASS);
int spawnbotcount(uint8 class_id = 0); int spawnbotcount(uint8 class_id = NO_CLASS);
bool botquest(); bool botquest();
bool createBot(const char *name, const char *lastname, uint8 level, uint16 race, uint8 botclass, uint8 gender); bool createBot(const char *name, const char *lastname, uint8 level, uint16 race, uint8 botclass, uint8 gender);
#endif #endif