Port fixes until b4094bf - flying, mount animations, bot attack range, free food option

This commit is contained in:
郑佩茹
2022-03-22 17:13:10 -06:00
parent 44600080ec
commit f1bcca1a7b
25 changed files with 224 additions and 32 deletions

View File

@@ -11,6 +11,44 @@ bool DrinkAction::Execute(Event event)
if (bot->IsInCombat())
return false;
bool hasMana = AI_VALUE2(bool, "has mana", "self target");
if (!hasMana)
return false;
if (sPlayerbotAIConfig->freeFood)
{
if (bot->IsNonMeleeSpellCast(true))
return false;
bot->ClearUnitState(UNIT_STATE_CHASE);
bot->ClearUnitState(UNIT_STATE_FOLLOW);
if (bot->isMoving())
{
bot->StopMoving();
botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
return false;
}
bot->AddUnitState(UNIT_STAND_STATE_SIT);
botAI->InterruptSpell();
//float hp = bot->GetHealthPercent();
float mp = bot->GetPowerPct(POWER_MANA);
float p = mp;
float delay;
if (!bot->InBattleground())
delay = 27000.0f * (100 - p) / 100.0f;
else
delay = 20000.0f * (100 - p) / 100.0f;
botAI->CastSpell(24707, bot);
botAI->SetNextCheckDelay(delay);
return true;
}
return UseItemAction::Execute(event);
}
@@ -19,11 +57,50 @@ bool DrinkAction::isUseful()
return UseItemAction::isUseful() && AI_VALUE2(uint8, "mana", "self target") < 85;
}
bool DrinkAction::isPossible()
{
return sPlayerbotAIConfig->freeFood || UseItemAction::isPossible();
}
bool EatAction::Execute(Event event)
{
if (bot->IsInCombat())
return false;
if (sPlayerbotAIConfig->freeFood)
{
if (bot->IsNonMeleeSpellCast(true))
return false;
bot->ClearUnitState(UNIT_STATE_CHASE);
bot->ClearUnitState(UNIT_STATE_FOLLOW);
if (bot->isMoving())
{
bot->StopMoving();
botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
return false;
}
bot->AddUnitState(UNIT_STAND_STATE_SIT);
botAI->InterruptSpell();
float hp = bot->GetHealthPct();
//float mp = bot->HasMana() ? bot->GetPowerPercent() : 0.f;
float p = hp;
float delay;
if (!bot->InBattleground())
delay = 27000.0f * (100 - p) / 100.0f;
else
delay = 20000.0f * (100 - p) / 100.0f;
botAI->CastSpell(24707, bot);
botAI->SetNextCheckDelay(delay);
return true;
}
return UseItemAction::Execute(event);
}
@@ -31,3 +108,8 @@ bool EatAction::isUseful()
{
return UseItemAction::isUseful() && AI_VALUE2(uint8, "health", "self target") < sPlayerbotAIConfig->lowHealth;
}
bool EatAction::isPossible()
{
return sPlayerbotAIConfig->freeFood || UseItemAction::isPossible();
}