mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
trainer learn command
This commit is contained in:
@@ -2282,8 +2282,8 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effec
|
||||
if (sServerFacade->GetDistance2d(bot, goTarget) > sPlayerbotAIConfig->sightDistance)
|
||||
return false;
|
||||
|
||||
ObjectGuid oldSel = bot->GetTarget();
|
||||
bot->SetTarget(goTarget->GetGUID());
|
||||
// ObjectGuid oldSel = bot->GetTarget();
|
||||
// bot->SetTarget(goTarget->GetGUID());
|
||||
Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE);
|
||||
|
||||
spell->m_targets.SetGOTarget(goTarget);
|
||||
@@ -2292,8 +2292,8 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effec
|
||||
|
||||
SpellCastResult result = spell->CheckCast(true);
|
||||
delete spell;
|
||||
if (oldSel)
|
||||
bot->SetTarget(oldSel);
|
||||
// if (oldSel)
|
||||
// bot->SetTarget(oldSel);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
@@ -2422,7 +2422,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
|
||||
failWithDelay = true;
|
||||
}
|
||||
|
||||
ObjectGuid oldSel = bot->GetTarget();
|
||||
ObjectGuid oldSel = bot->GetSelectedUnit() ? bot->GetSelectedUnit()->GetGUID() : ObjectGuid();
|
||||
bot->SetSelection(target->GetGUID());
|
||||
|
||||
WorldObject* faceTo = target;
|
||||
@@ -2547,7 +2547,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
|
||||
aiObjectContext->GetValue<PositionMap&>("position")->Get()["random"].Reset();
|
||||
|
||||
if (oldSel)
|
||||
bot->SetTarget(oldSel);
|
||||
bot->SetSelection(oldSel);
|
||||
|
||||
|
||||
if (HasStrategy("debug spell", BOT_STATE_NON_COMBAT))
|
||||
@@ -2605,7 +2605,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, float x, float y, float z, Item* ite
|
||||
failWithDelay = true;
|
||||
}
|
||||
|
||||
ObjectGuid oldSel = bot->GetTarget();
|
||||
ObjectGuid oldSel = bot->GetSelectedUnit() ? bot->GetSelectedUnit()->GetGUID() : ObjectGuid();
|
||||
|
||||
if (!bot->isMoving())
|
||||
bot->SetFacingTo(bot->GetAngle(x, y));
|
||||
@@ -2678,7 +2678,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, float x, float y, float z, Item* ite
|
||||
aiObjectContext->GetValue<PositionMap&>("position")->Get()["random"].Reset();
|
||||
|
||||
if (oldSel)
|
||||
bot->SetTarget(oldSel);
|
||||
bot->SetSelection(oldSel);
|
||||
|
||||
if (HasStrategy("debug spell", BOT_STATE_NON_COMBAT))
|
||||
{
|
||||
|
||||
@@ -18,118 +18,118 @@ bool ChangeTalentsAction::Execute(Event event)
|
||||
|
||||
if (!param.empty())
|
||||
{
|
||||
if (param.find("auto") != std::string::npos)
|
||||
{
|
||||
AutoSelectTalents(&out);
|
||||
}
|
||||
else if (param.find("list ") != std::string::npos)
|
||||
{
|
||||
listPremadePaths(getPremadePaths(param.substr(5)), &out);
|
||||
}
|
||||
else if (param.find("list") != std::string::npos)
|
||||
{
|
||||
listPremadePaths(getPremadePaths(""), &out);
|
||||
} else if (param == "1") {
|
||||
// if (param.find("auto") != std::string::npos)
|
||||
// {
|
||||
// AutoSelectTalents(&out);
|
||||
// }
|
||||
// else if (param.find("list ") != std::string::npos)
|
||||
// {
|
||||
// listPremadePaths(getPremadePaths(param.substr(5)), &out);
|
||||
// }
|
||||
// else if (param.find("list") != std::string::npos)
|
||||
// {
|
||||
// listPremadePaths(getPremadePaths(""), &out);
|
||||
if (param == "1") {
|
||||
bot->ActivateSpec(0);
|
||||
} else if (param == "2") {
|
||||
bot->ActivateSpec(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool crop = false;
|
||||
bool shift = false;
|
||||
if (param.find("do ") != std::string::npos)
|
||||
{
|
||||
crop = true;
|
||||
param = param.substr(3);
|
||||
}
|
||||
else if (param.find("shift ") != std::string::npos)
|
||||
{
|
||||
shift = true;
|
||||
param = param.substr(6);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// bool crop = false;
|
||||
// bool shift = false;
|
||||
// if (param.find("do ") != std::string::npos)
|
||||
// {
|
||||
// crop = true;
|
||||
// param = param.substr(3);
|
||||
// }
|
||||
// else if (param.find("shift ") != std::string::npos)
|
||||
// {
|
||||
// shift = true;
|
||||
// param = param.substr(6);
|
||||
// }
|
||||
|
||||
out << "Apply talents [" << param << "] ";
|
||||
if (botSpec.CheckTalentLink(param, &out))
|
||||
{
|
||||
TalentSpec newSpec(bot, param);
|
||||
std::string const specLink = newSpec.GetTalentLink();
|
||||
// out << "Apply talents [" << param << "] ";
|
||||
// if (botSpec.CheckTalentLink(param, &out))
|
||||
// {
|
||||
// TalentSpec newSpec(bot, param);
|
||||
// std::string const specLink = newSpec.GetTalentLink();
|
||||
|
||||
if (crop)
|
||||
{
|
||||
newSpec.CropTalents(bot->getLevel());
|
||||
out << "becomes: " << newSpec.GetTalentLink();
|
||||
}
|
||||
// if (crop)
|
||||
// {
|
||||
// newSpec.CropTalents(bot->getLevel());
|
||||
// out << "becomes: " << newSpec.GetTalentLink();
|
||||
// }
|
||||
|
||||
if (shift)
|
||||
{
|
||||
TalentSpec botSpec(bot);
|
||||
newSpec.ShiftTalents(&botSpec, bot->getLevel());
|
||||
out << "becomes: " << newSpec.GetTalentLink();
|
||||
}
|
||||
// if (shift)
|
||||
// {
|
||||
// TalentSpec botSpec(bot);
|
||||
// newSpec.ShiftTalents(&botSpec, bot->getLevel());
|
||||
// out << "becomes: " << newSpec.GetTalentLink();
|
||||
// }
|
||||
|
||||
if (newSpec.CheckTalents(bot->getLevel(), &out))
|
||||
{
|
||||
newSpec.ApplyTalents(bot, &out);
|
||||
sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specNo", 0);
|
||||
sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specLink", 1, specLink);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<TalentPath*> paths = getPremadePaths(param);
|
||||
if (paths.size() > 0)
|
||||
{
|
||||
out.str("");
|
||||
out.clear();
|
||||
// if (newSpec.CheckTalents(bot->getLevel(), &out))
|
||||
// {
|
||||
// newSpec.ApplyTalents(bot, &out);
|
||||
// sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specNo", 0);
|
||||
// sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specLink", 1, specLink);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::vector<TalentPath*> paths = getPremadePaths(param);
|
||||
// if (paths.size() > 0)
|
||||
// {
|
||||
// out.str("");
|
||||
// out.clear();
|
||||
|
||||
if (paths.size() > 1 && false/*!sPlayerbotAIConfig->autoPickTalents*/)
|
||||
{
|
||||
out << "Found multiple specs: ";
|
||||
listPremadePaths(paths, &out);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paths.size() > 1)
|
||||
out << "Found " << paths.size() << " possible specs to choose from. ";
|
||||
// if (paths.size() > 1 && false/*!sPlayerbotAIConfig->autoPickTalents*/)
|
||||
// {
|
||||
// out << "Found multiple specs: ";
|
||||
// listPremadePaths(paths, &out);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (paths.size() > 1)
|
||||
// out << "Found " << paths.size() << " possible specs to choose from. ";
|
||||
|
||||
TalentPath* path = PickPremadePath(paths, sRandomPlayerbotMgr->IsRandomBot(bot));
|
||||
TalentSpec newSpec = *GetBestPremadeSpec(path->id);
|
||||
std::string const specLink = newSpec.GetTalentLink();
|
||||
newSpec.CropTalents(bot->getLevel());
|
||||
newSpec.ApplyTalents(bot, &out);
|
||||
// TalentPath* path = PickPremadePath(paths, sRandomPlayerbotMgr->IsRandomBot(bot));
|
||||
// TalentSpec newSpec = *GetBestPremadeSpec(path->id);
|
||||
// std::string const specLink = newSpec.GetTalentLink();
|
||||
// newSpec.CropTalents(bot->getLevel());
|
||||
// newSpec.ApplyTalents(bot, &out);
|
||||
|
||||
if (newSpec.GetTalentPoints() > 0)
|
||||
{
|
||||
out << "Apply spec " << "|h|cffffffff" << path->name << " " << newSpec.FormatSpec(bot);
|
||||
sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specNo", path->id + 1);
|
||||
sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specLink", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (newSpec.GetTalentPoints() > 0)
|
||||
// {
|
||||
// out << "Apply spec " << "|h|cffffffff" << path->name << " " << newSpec.FormatSpec(bot);
|
||||
// sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specNo", path->id + 1);
|
||||
// sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specLink", 0);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 specId = sRandomPlayerbotMgr->GetValue(bot->GetGUID().GetCounter(), "specNo") - 1;
|
||||
std::string specName = "";
|
||||
TalentPath* specPath;
|
||||
if (specId)
|
||||
{
|
||||
specPath = getPremadePath(specId);
|
||||
if (specPath->id == specId)
|
||||
specName = specPath->name;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// uint32 specId = sRandomPlayerbotMgr->GetValue(bot->GetGUID().GetCounter(), "specNo") - 1;
|
||||
// std::string specName = "";
|
||||
// TalentPath* specPath;
|
||||
// if (specId)
|
||||
// {
|
||||
// specPath = getPremadePath(specId);
|
||||
// if (specPath->id == specId)
|
||||
// specName = specPath->name;
|
||||
// }
|
||||
|
||||
out << "My current talent spec is: " << "|h|cffffffff";
|
||||
if (specName != "")
|
||||
out << specName << " (" << botSpec.FormatSpec(bot) << ")";
|
||||
else
|
||||
out << chat->FormatClass(bot, botSpec.highestTree());
|
||||
out << " Link: ";
|
||||
out << botSpec.GetTalentLink();
|
||||
}
|
||||
// out << "My current talent spec is: " << "|h|cffffffff";
|
||||
// if (specName != "")
|
||||
// out << specName << " (" << botSpec.FormatSpec(bot) << ")";
|
||||
// else
|
||||
// out << chat->FormatClass(bot, botSpec.highestTree());
|
||||
// out << " Link: ";
|
||||
// out << botSpec.GetTalentLink();
|
||||
// }
|
||||
|
||||
botAI->TellMaster(out);
|
||||
|
||||
|
||||
@@ -89,11 +89,15 @@ bool TrainerAction::Execute(Event event)
|
||||
Player* master = GetMaster();
|
||||
|
||||
Creature* creature = botAI->GetCreature(bot->GetTarget());
|
||||
if (AI_VALUE(GuidPosition, "rpg target") != bot->GetTarget())
|
||||
if (master)
|
||||
creature = botAI->GetCreature(master->GetTarget());
|
||||
else
|
||||
return false;
|
||||
|
||||
if (master) {
|
||||
creature = master->GetSelectedUnit() ? master->GetSelectedUnit()->ToCreature() : nullptr;
|
||||
}
|
||||
// if (AI_VALUE(GuidPosition, "rpg target") != bot->GetTarget())
|
||||
// if (master)
|
||||
// creature = botAI->GetCreature(master->GetTarget());
|
||||
// else
|
||||
// return false;
|
||||
|
||||
if (!creature || !creature->IsTrainer())
|
||||
return false;
|
||||
|
||||
@@ -38,7 +38,7 @@ bool UseItemAction::Execute(Event event)
|
||||
bool UseItemAction::UseGameObject(ObjectGuid guid)
|
||||
{
|
||||
GameObject* go = botAI->GetGameObject(guid);
|
||||
if (!go || !go->isSpawned() || go->GetGoState() != GO_STATE_READY)
|
||||
if (!go || !go->isSpawned()/* || go->GetGoState() != GO_STATE_READY*/)
|
||||
return false;
|
||||
|
||||
go->Use(bot);
|
||||
|
||||
Reference in New Issue
Block a user