Skip to content

Commit

Permalink
Add a timed action to initialize hunter and warlock pets as well as m…
Browse files Browse the repository at this point in the history
…anual command
  • Loading branch information
davidonete committed Dec 1, 2023
1 parent b0097ae commit e1f5a25
Show file tree
Hide file tree
Showing 8 changed files with 455 additions and 3 deletions.
209 changes: 209 additions & 0 deletions playerbot/PlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ void PlayerbotFactory::Randomize(bool incremental, bool syncWithMaster)
pmo = sPerformanceMonitor.start(PERF_MON_RNDBOT, "PlayerbotFactory_Pet");
sLog.outDetail("Initializing pet...");
InitPet();
InitPetSpells();
if (pmo) pmo->finish();
}

Expand Down Expand Up @@ -680,6 +681,214 @@ void PlayerbotFactory::InitPet()
}
}

void PlayerbotFactory::InitPetSpells()
{
Map* map = bot->GetMap();
if (!map)
return;

Pet* pet = bot->GetPet();
if (pet)
{
if (bot->getClass() == CLASS_HUNTER)
{
// TO DO
// ...
}
// Warlock pets should auto learn spells on WOTLK
#ifndef MANGOSBOT_TWO
else if (bot->getClass() == CLASS_WARLOCK)
{
constexpr uint32 PET_IMP = 416;
constexpr uint32 PET_FELHUNTER = 417;
constexpr uint32 PET_VOIDWALKER = 1860;
constexpr uint32 PET_SUCCUBUS = 1863;
constexpr uint32 PET_FELGUARD = 17252;

// pet type pet level pet spell id
std::map<uint32, std::vector<std::pair<uint32, uint32>>> spellList;

// Imp spells
{
// Blood Pact
spellList[PET_IMP].push_back(std::pair(4, 6307));
spellList[PET_IMP].push_back(std::pair(14, 7804));
spellList[PET_IMP].push_back(std::pair(26, 7805));
spellList[PET_IMP].push_back(std::pair(38, 11766));
spellList[PET_IMP].push_back(std::pair(50, 11767));
spellList[PET_IMP].push_back(std::pair(62, 27268));
spellList[PET_IMP].push_back(std::pair(74, 47982));

// Fire Shield
spellList[PET_IMP].push_back(std::pair(14, 2947));
spellList[PET_IMP].push_back(std::pair(24, 8316));
spellList[PET_IMP].push_back(std::pair(34, 8317));
spellList[PET_IMP].push_back(std::pair(44, 11770));
spellList[PET_IMP].push_back(std::pair(54, 11771));
spellList[PET_IMP].push_back(std::pair(64, 27269));
spellList[PET_IMP].push_back(std::pair(76, 47983));

// Firebolt
spellList[PET_IMP].push_back(std::pair(1, 3110));
spellList[PET_IMP].push_back(std::pair(8, 7799));
spellList[PET_IMP].push_back(std::pair(18, 7800));
spellList[PET_IMP].push_back(std::pair(28, 7801));
spellList[PET_IMP].push_back(std::pair(38, 7802));
spellList[PET_IMP].push_back(std::pair(48, 11762));
spellList[PET_IMP].push_back(std::pair(58, 11763));
spellList[PET_IMP].push_back(std::pair(68, 27267));
spellList[PET_IMP].push_back(std::pair(78, 47964));

// Phase Shift
spellList[PET_IMP].push_back(std::pair(12, 4511));
}

// Felhunter spells
{
// Devour Magic
spellList[PET_FELHUNTER].push_back(std::pair(30, 19505));
spellList[PET_FELHUNTER].push_back(std::pair(38, 19731));
spellList[PET_FELHUNTER].push_back(std::pair(46, 19734));
spellList[PET_FELHUNTER].push_back(std::pair(54, 19736));
spellList[PET_FELHUNTER].push_back(std::pair(62, 27276));
spellList[PET_FELHUNTER].push_back(std::pair(70, 27277));
spellList[PET_FELHUNTER].push_back(std::pair(77, 48011));

// Paranoia
spellList[PET_FELHUNTER].push_back(std::pair(42, 19480));

// Spell Lock
spellList[PET_FELHUNTER].push_back(std::pair(36, 19244));
spellList[PET_FELHUNTER].push_back(std::pair(52, 19647));

// Tainted Blood
spellList[PET_FELHUNTER].push_back(std::pair(32, 19478));
spellList[PET_FELHUNTER].push_back(std::pair(40, 19655));
spellList[PET_FELHUNTER].push_back(std::pair(48, 19656));
spellList[PET_FELHUNTER].push_back(std::pair(56, 19660));
spellList[PET_FELHUNTER].push_back(std::pair(64, 27280));
}

// Voidwalker
{
// Consume Shadows
spellList[PET_VOIDWALKER].push_back(std::pair(18, 17767));
spellList[PET_VOIDWALKER].push_back(std::pair(26, 17850));
spellList[PET_VOIDWALKER].push_back(std::pair(34, 17851));
spellList[PET_VOIDWALKER].push_back(std::pair(42, 17852));
spellList[PET_VOIDWALKER].push_back(std::pair(50, 17853));
spellList[PET_VOIDWALKER].push_back(std::pair(58, 17854));
spellList[PET_VOIDWALKER].push_back(std::pair(66, 27272));
spellList[PET_VOIDWALKER].push_back(std::pair(73, 47987));
spellList[PET_VOIDWALKER].push_back(std::pair(78, 47988));

// Sacrifice
spellList[PET_VOIDWALKER].push_back(std::pair(16, 7812));
spellList[PET_VOIDWALKER].push_back(std::pair(24, 19438));
spellList[PET_VOIDWALKER].push_back(std::pair(32, 19440));
spellList[PET_VOIDWALKER].push_back(std::pair(40, 19441));
spellList[PET_VOIDWALKER].push_back(std::pair(48, 19442));
spellList[PET_VOIDWALKER].push_back(std::pair(56, 19443));
spellList[PET_VOIDWALKER].push_back(std::pair(64, 27273));
spellList[PET_VOIDWALKER].push_back(std::pair(72, 47985));
spellList[PET_VOIDWALKER].push_back(std::pair(79, 47986));

// Suffering
spellList[PET_VOIDWALKER].push_back(std::pair(24, 17735));
spellList[PET_VOIDWALKER].push_back(std::pair(36, 17750));
spellList[PET_VOIDWALKER].push_back(std::pair(48, 17751));
spellList[PET_VOIDWALKER].push_back(std::pair(60, 17752));
spellList[PET_VOIDWALKER].push_back(std::pair(63, 27271));
spellList[PET_VOIDWALKER].push_back(std::pair(69, 33701));
spellList[PET_VOIDWALKER].push_back(std::pair(75, 47989));
spellList[PET_VOIDWALKER].push_back(std::pair(80, 47990));

// Torment
spellList[PET_VOIDWALKER].push_back(std::pair(10, 3716));
spellList[PET_VOIDWALKER].push_back(std::pair(20, 7809));
spellList[PET_VOIDWALKER].push_back(std::pair(30, 7810));
spellList[PET_VOIDWALKER].push_back(std::pair(40, 7811));
spellList[PET_VOIDWALKER].push_back(std::pair(50, 11774));
spellList[PET_VOIDWALKER].push_back(std::pair(60, 11775));
spellList[PET_VOIDWALKER].push_back(std::pair(70, 27270));
spellList[PET_VOIDWALKER].push_back(std::pair(80, 47984));
}

// Succubus
{
// Lash of Pain
spellList[PET_SUCCUBUS].push_back(std::pair(20, 7814));
spellList[PET_SUCCUBUS].push_back(std::pair(28, 7815));
spellList[PET_SUCCUBUS].push_back(std::pair(36, 7816));
spellList[PET_SUCCUBUS].push_back(std::pair(44, 11778));
spellList[PET_SUCCUBUS].push_back(std::pair(52, 11779));
spellList[PET_SUCCUBUS].push_back(std::pair(60, 11780));
spellList[PET_SUCCUBUS].push_back(std::pair(68, 27274));
spellList[PET_SUCCUBUS].push_back(std::pair(74, 47991));
spellList[PET_SUCCUBUS].push_back(std::pair(80, 47992));

// Lesser Invisibility
spellList[PET_SUCCUBUS].push_back(std::pair(32, 7870));

// Seduction
spellList[PET_SUCCUBUS].push_back(std::pair(26, 6358));

// Soothing Kiss
spellList[PET_SUCCUBUS].push_back(std::pair(22, 6360));
spellList[PET_SUCCUBUS].push_back(std::pair(34, 7813));
spellList[PET_SUCCUBUS].push_back(std::pair(46, 11784));
spellList[PET_SUCCUBUS].push_back(std::pair(58, 11785));
spellList[PET_SUCCUBUS].push_back(std::pair(70, 27275));
}

// Felguard
{
// Anguish
spellList[PET_FELGUARD].push_back(std::pair(50, 33698));
spellList[PET_FELGUARD].push_back(std::pair(60, 33699));
spellList[PET_FELGUARD].push_back(std::pair(69, 33700));
spellList[PET_FELGUARD].push_back(std::pair(78, 47993));

// Avoidance
spellList[PET_FELGUARD].push_back(std::pair(60, 32233));

// Cleave
spellList[PET_FELGUARD].push_back(std::pair(50, 30213));
spellList[PET_FELGUARD].push_back(std::pair(60, 30219));
spellList[PET_FELGUARD].push_back(std::pair(68, 30223));
spellList[PET_FELGUARD].push_back(std::pair(76, 47994));

// Demonic Frenzy
spellList[PET_FELGUARD].push_back(std::pair(56, 32850));

// Intercept
spellList[PET_FELGUARD].push_back(std::pair(52, 30151));
spellList[PET_FELGUARD].push_back(std::pair(61, 30194));
spellList[PET_FELGUARD].push_back(std::pair(69, 30198));
spellList[PET_FELGUARD].push_back(std::pair(79, 47996));
}

// Learn the appropriate spells by level and type
const auto& petSpellListItr = spellList.find(pet->GetEntry());
if (petSpellListItr != spellList.end())
{
const auto& petSpellList = petSpellListItr->second;
for (const auto& pair : petSpellListItr->second)
{
const uint32& levelRequired = pair.first;
const uint32& spellID = pair.second;

if (pet->GetLevel() >= levelRequired)
{
pet->learnSpell(spellID);
}
}
}
}
#endif
}
}

void PlayerbotFactory::ClearSkills()
{
for (int i = 0; i < sizeof(tradeSkills) / sizeof(uint32); ++i)
Expand Down
3 changes: 2 additions & 1 deletion playerbot/PlayerbotFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class PlayerbotFactory
void AddConsumes() { return AddConsumables(); }
void AddFood() { return InitFood(); }
void InitAmmo();
void InitPet();
void InitPetSpells();

private:
void Prepare();
Expand All @@ -85,7 +87,6 @@ class PlayerbotFactory
void InitTalentsTree(bool incremental);
void InitTalents(uint32 specNo);
void InitQuests(list<uint32>& questMap);
void InitPet();
void InitTaxiNodes();
void ClearInventory();
void ClearAllItems();
Expand Down
7 changes: 7 additions & 0 deletions playerbot/PlayerbotMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,13 @@ string PlayerbotHolder::ProcessBotCommand(string cmd, ObjectGuid guid, ObjectGui
factory.InitAmmo();
return "ok";
}
else if (cmd == "pet")
{
PlayerbotFactory factory(bot, master->GetLevel(), ITEM_QUALITY_LEGENDARY);
factory.InitPet();
factory.InitPetSpells();
return "ok";
}
}

if (cmd == "levelup" || cmd == "level")
Expand Down
2 changes: 2 additions & 0 deletions playerbot/strategy/actions/ActionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ namespace ai
creators["use trinket"] = &ActionContext::use_trinket;
creators["reset"] = &ActionContext::reset;
creators["interrupt current spell"] = &ActionContext::interrupt_current_spell;
creators["initialize pet"] = &ActionContext::initialize_pet;

// item helpers
creators["goblin sapper"] = &ActionContext::goblin_sapper;
Expand Down Expand Up @@ -369,6 +370,7 @@ namespace ai
static Action* flee_with_pet(PlayerbotAI* ai) { return new FleeWithPetAction(ai); }
static Action* wait_for_attack_keep_safe_distance(PlayerbotAI* ai) { return new WaitForAttackKeepSafeDistanceAction(ai); }
static Action* flee(PlayerbotAI* ai) { return new FleeAction(ai); }
static Action* initialize_pet(PlayerbotAI* ai) { return new InitializePetAction(ai); }

//racials
static Action* war_stomp(PlayerbotAI* ai) { return new CastWarStompAction(ai); }
Expand Down
Loading

0 comments on commit e1f5a25

Please sign in to comment.