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