mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 18:10:02 +01:00
Item use check
This commit is contained in:
parent
21e9e2e2aa
commit
a1903ad888
@ -600,7 +600,7 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const
|
|||||||
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig->randomBotNonCombatStrategies);
|
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig->randomBotNonCombatStrategies);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// nonCombatEngine->addStrategy("pvp");
|
nonCombatEngine->addStrategy("pvp");
|
||||||
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig->nonCombatStrategies);
|
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig->nonCombatStrategies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,9 +97,11 @@ void PlayerbotFactory::Prepare()
|
|||||||
bot->ResurrectPlayer(1.0f, false);
|
bot->ResurrectPlayer(1.0f, false);
|
||||||
|
|
||||||
bot->CombatStop(true);
|
bot->CombatStop(true);
|
||||||
|
uint32 currentLevel = bot->GetLevel();
|
||||||
bot->GiveLevel(level);
|
bot->GiveLevel(level);
|
||||||
|
if (level != currentLevel) {
|
||||||
bot->SetUInt32Value(PLAYER_XP, 0);
|
bot->SetUInt32Value(PLAYER_XP, 0);
|
||||||
|
}
|
||||||
if (!sPlayerbotAIConfig->randomBotShowHelmet || !urand(0, 4))
|
if (!sPlayerbotAIConfig->randomBotShowHelmet || !urand(0, 4))
|
||||||
{
|
{
|
||||||
bot->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM);
|
bot->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM);
|
||||||
@ -158,6 +160,7 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
|
|
||||||
if (sPlayerbotAIConfig->randomBotPreQuests)
|
if (sPlayerbotAIConfig->randomBotPreQuests)
|
||||||
{
|
{
|
||||||
|
uint32 currentXP = bot->GetUInt32Value(PLAYER_XP);
|
||||||
LOG_INFO("playerbots", "Initializing quests...");
|
LOG_INFO("playerbots", "Initializing quests...");
|
||||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests");
|
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests");
|
||||||
InitQuests(classQuestIds);
|
InitQuests(classQuestIds);
|
||||||
@ -169,7 +172,7 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
|
|
||||||
|
|
||||||
ClearInventory();
|
ClearInventory();
|
||||||
bot->SetUInt32Value(PLAYER_XP, 0);
|
bot->SetUInt32Value(PLAYER_XP, currentXP);
|
||||||
CancelAuras();
|
CancelAuras();
|
||||||
bot->SaveToDB(false, false);
|
bot->SaveToDB(false, false);
|
||||||
if (pmo)
|
if (pmo)
|
||||||
|
|||||||
@ -1329,7 +1329,10 @@ void RandomPlayerbotMgr::Randomize(Player* bot)
|
|||||||
RandomizeFirst(bot);
|
RandomizeFirst(bot);
|
||||||
}
|
}
|
||||||
else if (bot->getLevel() < sPlayerbotAIConfig->randomBotMaxLevel || !sPlayerbotAIConfig->downgradeMaxLevelBot) {
|
else if (bot->getLevel() < sPlayerbotAIConfig->randomBotMaxLevel || !sPlayerbotAIConfig->downgradeMaxLevelBot) {
|
||||||
IncreaseLevel(bot);
|
uint8 level = bot->getLevel();
|
||||||
|
PlayerbotFactory factory(bot, level);
|
||||||
|
factory.Randomize(true);
|
||||||
|
// IncreaseLevel(bot);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
RandomizeFirst(bot);
|
RandomizeFirst(bot);
|
||||||
|
|||||||
@ -56,6 +56,9 @@ bool FollowAction::isUseful()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Formation* formation = AI_VALUE(Formation*, "formation");
|
Formation* formation = AI_VALUE(Formation*, "formation");
|
||||||
|
if (!formation) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
std::string const target = formation->GetTargetName();
|
std::string const target = formation->GetTargetName();
|
||||||
|
|
||||||
Unit* fTarget = nullptr;
|
Unit* fTarget = nullptr;
|
||||||
|
|||||||
@ -86,7 +86,9 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
|||||||
if (item->GetTemplate()->Spells[i].SpellId > 0)
|
if (item->GetTemplate()->Spells[i].SpellId > 0)
|
||||||
{
|
{
|
||||||
spellId = item->GetTemplate()->Spells[i].SpellId;
|
spellId = item->GetTemplate()->Spells[i].SpellId;
|
||||||
break;
|
if (!botAI->CanCastSpell(spellId, bot, false, item)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +197,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
|||||||
|
|
||||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; i++)
|
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; i++)
|
||||||
{
|
{
|
||||||
spellId = item->GetTemplate()->Spells[i].SpellId;
|
uint32 spellId = item->GetTemplate()->Spells[i].SpellId;
|
||||||
if (!spellId)
|
if (!spellId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ class GenericDruidNonCombatStrategyActionNodeFactory : public NamedObjectFactory
|
|||||||
creators["rejuvenation on party"] = &rejuvenation_on_party;
|
creators["rejuvenation on party"] = &rejuvenation_on_party;
|
||||||
creators["remove curse on party"] = &remove_curse_on_party;
|
creators["remove curse on party"] = &remove_curse_on_party;
|
||||||
creators["abolish poison on party"] = &abolish_poison_on_party;
|
creators["abolish poison on party"] = &abolish_poison_on_party;
|
||||||
|
creators["revive"] = &revive;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -81,6 +82,13 @@ class GenericDruidNonCombatStrategyActionNodeFactory : public NamedObjectFactory
|
|||||||
/*A*/ NULL,
|
/*A*/ NULL,
|
||||||
/*C*/ NULL);
|
/*C*/ NULL);
|
||||||
}
|
}
|
||||||
|
static ActionNode* revive(PlayerbotAI* ai)
|
||||||
|
{
|
||||||
|
return new ActionNode ("revive",
|
||||||
|
/*P*/ NextAction::array(0, new NextAction("caster form"), nullptr),
|
||||||
|
/*A*/ NULL,
|
||||||
|
/*C*/ NULL);
|
||||||
|
}
|
||||||
// static ActionNode* innervate([[maybe_unused]] PlayerbotAI* botAI)
|
// static ActionNode* innervate([[maybe_unused]] PlayerbotAI* botAI)
|
||||||
// {
|
// {
|
||||||
// return new ActionNode ("innervate",
|
// return new ActionNode ("innervate",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user