[Bots] Remove hardcoded race-class combinations from bots. (#1375)

* [Bots] Remove hardcoded race-class combinations from bots.
- Allows server operators to directly influence via a database table the classes a specific bot race can be.
- Previously this was hardcoded and required a source modification to do.
- Allowed races, classes, and genders have been removed due to redundancy at this point.

* Remove const cast and modify saylink definition.
This commit is contained in:
Alex
2021-06-11 14:30:56 -04:00
committed by GitHub
parent 0461ac7912
commit c3456ebea0
10 changed files with 147 additions and 365 deletions
+7 -316
View File
@@ -1701,206 +1701,15 @@ bool Bot::IsValidRaceClassCombo()
return Bot::IsValidRaceClassCombo(GetRace(), GetClass());
}
bool Bot::IsValidRaceClassCombo(uint16 r, uint8 c)
bool Bot::IsValidRaceClassCombo(uint16 bot_race, uint8 bot_class)
{
switch (r) {
case HUMAN:
switch (c) {
case WARRIOR:
case CLERIC:
case PALADIN:
case RANGER:
case SHADOWKNIGHT:
case DRUID:
case MONK:
case BARD:
case ROGUE:
case NECROMANCER:
case WIZARD:
case MAGICIAN:
case ENCHANTER:
return true;
}
break;
case BARBARIAN:
switch (c) {
case WARRIOR:
case ROGUE:
case SHAMAN:
case BEASTLORD:
case BERSERKER:
return true;
}
break;
case ERUDITE:
switch (c) {
case CLERIC:
case PALADIN:
case SHADOWKNIGHT:
case NECROMANCER:
case WIZARD:
case MAGICIAN:
case ENCHANTER:
return true;
}
break;
case WOOD_ELF:
switch (c) {
case WARRIOR:
case RANGER:
case DRUID:
case BARD:
case ROGUE:
return true;
}
break;
case HIGH_ELF:
switch (c) {
case CLERIC:
case PALADIN:
case WIZARD:
case MAGICIAN:
case ENCHANTER:
return true;
}
break;
case DARK_ELF:
switch (c) {
case WARRIOR:
case CLERIC:
case SHADOWKNIGHT:
case ROGUE:
case NECROMANCER:
case WIZARD:
case MAGICIAN:
case ENCHANTER:
return true;
}
break;
case HALF_ELF:
switch (c) {
case WARRIOR:
case PALADIN:
case RANGER:
case DRUID:
case BARD:
case ROGUE:
return true;
}
break;
case DWARF:
switch (c) {
case WARRIOR:
case CLERIC:
case PALADIN:
case ROGUE:
case BERSERKER:
return true;
}
break;
case TROLL:
switch (c) {
case WARRIOR:
case SHADOWKNIGHT:
case SHAMAN:
case BEASTLORD:
case BERSERKER:
return true;
}
break;
case OGRE:
switch (c) {
case WARRIOR:
case SHADOWKNIGHT:
case SHAMAN:
case BEASTLORD:
case BERSERKER:
return true;
}
break;
case HALFLING:
switch (c) {
case WARRIOR:
case CLERIC:
case PALADIN:
case RANGER:
case DRUID:
case ROGUE:
return true;
}
break;
case GNOME:
switch (c) {
case WARRIOR:
case CLERIC:
case PALADIN:
case SHADOWKNIGHT:
case ROGUE:
case NECROMANCER:
case WIZARD:
case MAGICIAN:
case ENCHANTER:
return true;
}
break;
case IKSAR:
switch (c) {
case WARRIOR:
case SHADOWKNIGHT:
case MONK:
case SHAMAN:
case NECROMANCER:
case BEASTLORD:
return true;
}
break;
case VAHSHIR:
switch (c) {
case WARRIOR:
case BARD:
case ROGUE:
case SHAMAN:
case BEASTLORD:
case BERSERKER:
return true;
}
break;
case FROGLOK:
switch (c) {
case WARRIOR:
case CLERIC:
case PALADIN:
case SHADOWKNIGHT:
case ROGUE:
case SHAMAN:
case NECROMANCER:
case WIZARD:
return true;
}
break;
case DRAKKIN:
switch (c) {
case WARRIOR:
case CLERIC:
case PALADIN:
case RANGER:
case SHADOWKNIGHT:
case DRUID:
case MONK:
case BARD:
case ROGUE:
case NECROMANCER:
case WIZARD:
case MAGICIAN:
case ENCHANTER:
return true;
}
break;
default:
break;
bool is_valid = false;
auto classes = database.botdb.GetRaceClassBitmask(bot_race);
auto bot_class_bitmask = GetPlayerClassBit(bot_class);
if (classes & bot_class_bitmask) {
is_valid = true;
}
return false;
return is_valid;
}
bool Bot::IsValidName()
@@ -4264,124 +4073,6 @@ void Bot::LevelBotWithClient(Client* client, uint8 level, bool sendlvlapp) {
}
}
std::string Bot::ClassIdToString(uint16 classId) {
std::string Result;
if(classId > 0 && classId < 17) {
switch(classId) {
case 1:
Result = std::string("Warrior");
break;
case 2:
Result = std::string("Cleric");
break;
case 3:
Result = std::string("Paladin");
break;
case 4:
Result = std::string("Ranger");
break;
case 5:
Result = std::string("Shadowknight");
break;
case 6:
Result = std::string("Druid");
break;
case 7:
Result = std::string("Monk");
break;
case 8:
Result = std::string("Bard");
break;
case 9:
Result = std::string("Rogue");
break;
case 10:
Result = std::string("Shaman");
break;
case 11:
Result = std::string("Necromancer");
break;
case 12:
Result = std::string("Wizard");
break;
case 13:
Result = std::string("Magician");
break;
case 14:
Result = std::string("Enchanter");
break;
case 15:
Result = std::string("Beastlord");
break;
case 16:
Result = std::string("Berserker");
break;
}
}
return Result;
}
std::string Bot::RaceIdToString(uint16 raceId) {
std::string Result;
if(raceId > 0) {
switch(raceId) {
case 1:
Result = std::string("Human");
break;
case 2:
Result = std::string("Barbarian");
break;
case 3:
Result = std::string("Erudite");
break;
case 4:
Result = std::string("Wood Elf");
break;
case 5:
Result = std::string("High Elf");
break;
case 6:
Result = std::string("Dark Elf");
break;
case 7:
Result = std::string("Half Elf");
break;
case 8:
Result = std::string("Dwarf");
break;
case 9:
Result = std::string("Troll");
break;
case 10:
Result = std::string("Ogre");
break;
case 11:
Result = std::string("Halfling");
break;
case 12:
Result = std::string("Gnome");
break;
case 128:
Result = std::string("Iksar");
break;
case 130:
Result = std::string("Vah Shir");
break;
case 330:
Result = std::string("Froglok");
break;
case 522:
Result = std::string("Drakkin");
break;
}
}
return Result;
}
void Bot::SendBotArcheryWearChange(uint8 material_slot, uint32 material, uint32 color) {
EQApplicationPacket* outapp = new EQApplicationPacket(OP_WearChange, sizeof(WearChange_Struct));
WearChange_Struct* wc = (WearChange_Struct*)outapp->pBuffer;