本文整理汇总了C++中PlayerbotAI::In_Reach方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerbotAI::In_Reach方法的具体用法?C++ PlayerbotAI::In_Reach怎么用?C++ PlayerbotAI::In_Reach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerbotAI
的用法示例。
在下文中一共展示了PlayerbotAI::In_Reach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HealTarget
bool PlayerbotDruidAI::HealTarget(Unit *target)
{
PlayerbotAI* ai = GetAI();
uint8 hp = target->GetHealth() * 100 / target->GetMaxHealth();
//If spell exists and orders say we should be dispelling
if ((REMOVE_CURSE > 0 || ABOLISH_POISON > 0) && ai->GetCombatOrder() != PlayerbotAI::ORDERS_NODISPEL)
{
//This does something important(lol)
uint32 dispelMask = GetDispellMask(DISPEL_CURSE);
uint32 dispelMask2 = GetDispellMask(DISPEL_POISON);
//Get a list of all the targets auras(spells affecting target)
Unit::SpellAuraHolderMap const& auras = target->GetSpellAuraHolderMap();
//Iterate through the auras
for(Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
SpellAuraHolder *holder = itr->second;
//I dont know what this does but it doesn't work without it
if ((1<<holder->GetSpellProto()->Dispel) & dispelMask)
{
//If the spell is dispellable and we can dispel it, do so
if((holder->GetSpellProto()->Dispel == DISPEL_CURSE) & (REMOVE_CURSE > 0))
ai->CastSpell(REMOVE_CURSE, *target);
return false;
}
else if ((1<<holder->GetSpellProto()->Dispel) & dispelMask2)
{
if((holder->GetSpellProto()->Dispel == DISPEL_POISON) & (ABOLISH_POISON > 0))
ai->CastSpell(ABOLISH_POISON, *target);
return false;
}
}
}
if (hp >= 70)
return false;
// Reset form if needed
GoBuffForm(GetPlayerBot());
if (hp < 70 && REJUVENATION > 0 && ai->In_Reach(target,REJUVENATION) && !target->HasAura(REJUVENATION) && ai->CastSpell(REJUVENATION, *target))
return true;
if (hp < 60 && LIFEBLOOM > 0 && ai->In_Reach(target,LIFEBLOOM) && !target->HasAura(LIFEBLOOM) && ai->CastSpell(LIFEBLOOM, *target))
return true;
if (hp < 55 && REGROWTH > 0 && ai->In_Reach(target,REGROWTH) && !target->HasAura(REGROWTH) && ai->CastSpell(REGROWTH, *target))
return true;
if (hp < 50 && SWIFTMEND > 0 && ai->In_Reach(target,SWIFTMEND) && (target->HasAura(REJUVENATION) || target->HasAura(REGROWTH)) && ai->CastSpell(SWIFTMEND, *target))
return true;
if (hp < 45 && WILD_GROWTH > 0 && ai->In_Reach(target,WILD_GROWTH) && !target->HasAura(WILD_GROWTH) && ai->CastSpell(WILD_GROWTH, *target))
return true;
if (hp < 30 && NOURISH > 0 && ai->In_Reach(target,NOURISH) && ai->CastSpell(NOURISH, *target))
return true;
if (hp < 25 && HEALING_TOUCH > 0 && ai->In_Reach(target,HEALING_TOUCH) && ai->CastSpell(HEALING_TOUCH, *target))
return true;
return false;
} // end HealTarget
示例2: DoNextCombatManeuver
void PlayerbotPriestAI::DoNextCombatManeuver(Unit *pTarget)
{
Unit* pVictim = pTarget->getVictim();
PlayerbotAI* ai = GetAI();
if (!ai)
return;
switch (ai->GetScenarioType())
{
case PlayerbotAI::SCENARIO_PVP_DUEL:
(ai->HasAura(SCREAM, *pTarget) && ai->GetHealthPercent() < 60 && ai->CastSpell(HEAL)) ||
ai->CastSpell(SHADOW_WORD_PAIN) ||
(ai->GetHealthPercent() < 80 && ai->CastSpell(RENEW)) ||
(ai->GetPlayerBot()->GetDistance(pTarget) <= 5 && ai->CastSpell(SCREAM)) ||
ai->CastSpell(MIND_BLAST) ||
(ai->GetHealthPercent() < 50 && ai->CastSpell(GREATER_HEAL)) ||
ai->CastSpell(SMITE);
return;
default:
break;
}
// ------- Non Duel combat ----------
Player *m_bot = GetPlayerBot();
Group *m_group = m_bot->GetGroup();
bool meleeReach = m_bot->CanReachWithMeleeAttack(pTarget);
if (ai->GetCombatStyle() != PlayerbotAI::COMBAT_RANGED && !meleeReach)
ai->SetCombatStyle(PlayerbotAI::COMBAT_RANGED);
// if in melee range OR can't shoot OR have no ranged (wand) equipped
else if (ai->GetCombatStyle() != PlayerbotAI::COMBAT_MELEE
&& (meleeReach || SHOOT == 0 || !m_bot->GetWeaponForAttack(RANGED_ATTACK, true, true))
&& !ai->IsHealer())
ai->SetCombatStyle(PlayerbotAI::COMBAT_MELEE);
if (SHOOT > 0 && ai->GetCombatStyle() == PlayerbotAI::COMBAT_RANGED && !m_bot->FindCurrentSpellBySpellId(SHOOT))
ai->CastSpell(SHOOT, *pTarget);
//ai->TellMaster( "started auto shot." );
else if (SHOOT > 0 && m_bot->FindCurrentSpellBySpellId(SHOOT))
m_bot->InterruptNonMeleeSpells(true, SHOOT);
// Heal myself
if (ai->GetHealthPercent() < 15 && FADE > 0 && !m_bot->HasAura(FADE, EFFECT_INDEX_0))
{
ai->TellMaster("I'm casting fade.");
ai->CastSpell(FADE, *m_bot);
}
else if (ai->GetHealthPercent() < 25 && POWER_WORD_SHIELD > 0 && !m_bot->HasAura(POWER_WORD_SHIELD, EFFECT_INDEX_0))
{
ai->TellMaster("I'm casting pws on myself.");
ai->CastSpell(POWER_WORD_SHIELD);
}
else if (ai->GetHealthPercent() < 35 && DESPERATE_PRAYER > 0)
{
ai->TellMaster("I'm casting desperate prayer.");
ai->CastSpell(DESPERATE_PRAYER, *m_bot);
}
else if (ai->GetHealthPercent() < 80)
HealTarget (m_bot);
// Heal master
uint32 masterHP = GetMaster()->GetHealth() * 100 / GetMaster()->GetMaxHealth();
if (GetMaster()->isAlive())
{
if (masterHP < 25 && POWER_WORD_SHIELD > 0 && !GetMaster()->HasAura(POWER_WORD_SHIELD, EFFECT_INDEX_0))
ai->CastSpell(POWER_WORD_SHIELD, *(GetMaster()));
else if (masterHP < 80)
HealTarget (GetMaster());
}
// Heal group
if (m_group)
{
Group::MemberSlotList const& groupSlot = m_group->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *m_groupMember = sObjectMgr.GetPlayer(itr->guid);
if (!m_groupMember || !m_groupMember->isAlive())
continue;
uint32 memberHP = m_groupMember->GetHealth() * 100 / m_groupMember->GetMaxHealth();
if (memberHP < 25)
HealTarget(m_groupMember);
}
}
// Damage Spells
switch (SpellSequence)
{
case SPELL_HOLY:
if (SMITE > 0 && ai->In_Reach(pTarget,SMITE) && LastSpellHoly < 1 && !pTarget->HasAura(SMITE, EFFECT_INDEX_0) && ai->GetManaPercent() >= 17)
{
ai->CastSpell(SMITE, *pTarget);
SpellSequence = SPELL_SHADOWMAGIC;
LastSpellHoly = LastSpellHoly + 1;
break;
}
else if (MANA_BURN > 0 && ai->In_Reach(pTarget,MANA_BURN) && LastSpellHoly < 2 && pTarget->GetPower(POWER_MANA) > 0 && ai->GetManaPercent() < 70 && ai->GetManaPercent() >= 14)
{
//ai->TellMaster("I'm casting mana burn.");
//.........这里部分代码省略.........
示例3: DoNextCombatManeuver
void PlayerbotDruidAI::DoNextCombatManeuver(Unit *pTarget)
{
PlayerbotAI* ai = GetAI();
if (!ai)
return;
switch (ai->GetScenarioType())
{
case PlayerbotAI::SCENARIO_PVP_DUEL:
ai->CastSpell(MOONFIRE);
return;
default:
break;
}
uint32 masterHP = GetMaster()->GetHealth() * 100 / GetMaster()->GetMaxHealth();
Player *m_bot = GetPlayerBot();
Unit* pVictim = pTarget->getVictim();
if (ai->IsTank())
SpellSequence = DruidTank;
else if (ai->IsDPS())
SpellSequence = DruidSpell;
else if (ai->IsHealer())
SpellSequence = DruidHeal;
else
SpellSequence = DruidCombat;
switch (SpellSequence)
{
case DruidTank: // Its now a tank druid!
//ai->TellMaster("DruidTank");
if (!m_bot->HasInArc(M_PI_F, pTarget))
{
if (pVictim)
pVictim->Attack(pTarget, true);
}
if (m_bot->HasAura(CAT_FORM, EFFECT_INDEX_0))
m_bot->RemoveAurasDueToSpell(768);
//ai->TellMaster("FormClearCat");
if (MOONKIN_FORM > 0 && !m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0))
ai->CastSpell (MOONKIN_FORM);
else if (DIRE_BEAR_FORM > 0 && !m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && !m_bot->HasAura(DIRE_BEAR_FORM, EFFECT_INDEX_0))
ai->CastSpell (DIRE_BEAR_FORM);
else if (BEAR_FORM > 0 && !m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && !m_bot->HasAura(DIRE_BEAR_FORM, EFFECT_INDEX_0) && !m_bot->HasAura(BEAR_FORM, EFFECT_INDEX_0))
ai->CastSpell (BEAR_FORM);
else if (DEMORALIZING_ROAR > 0 && (m_bot->HasAura(DIRE_BEAR_FORM, EFFECT_INDEX_0) || m_bot->HasAura(BEAR_FORM, EFFECT_INDEX_0)) && !m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && !pTarget->HasAura(DEMORALIZING_ROAR, EFFECT_INDEX_0) && ai->GetRageAmount() >= 10)
ai->CastSpell(DEMORALIZING_ROAR, *pTarget);
if (FAERIE_FIRE > 0 && ai->In_Reach(pTarget,FAERIE_FIRE) && DruidSpellCombat < 1 && !pTarget->HasAura(FAERIE_FIRE, EFFECT_INDEX_0))
{
ai->CastSpell(FAERIE_FIRE, *pTarget);
DruidSpellCombat++;
break;
}
else if (MOONFIRE > 0 && ai->In_Reach(pTarget,MOONFIRE) && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && DruidSpellCombat < 2 && !pTarget->HasAura(MOONFIRE, EFFECT_INDEX_0) && ai->GetManaPercent() >= 24)
{
ai->CastSpell(MOONFIRE, *pTarget);
DruidSpellCombat++;
break;
}
else if (ROOTS > 0 && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && DruidSpellCombat < 3 && !pTarget->HasAura(ROOTS, EFFECT_INDEX_0) && ai->GetManaPercent() >= 8)
{
ai->CastSpell(ROOTS, *pTarget);
DruidSpellCombat++;
break;
}
else if (HURRICANE > 0 && ai->In_Reach(pTarget,HURRICANE) && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && ai->GetAttackerCount() >= 5 && DruidSpellCombat < 4 && ai->GetManaPercent() >= 91)
{
//ai->TellMaster("casting hurricane!");
ai->CastSpell(HURRICANE, *pTarget);
ai->SetIgnoreUpdateTime(10);
DruidSpellCombat++;
break;
}
else if (WRATH > 0 && ai->In_Reach(pTarget,WRATH) && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && DruidSpellCombat < 5 && ai->GetManaPercent() >= 13)
{
ai->CastSpell(WRATH, *pTarget);
DruidSpellCombat++;
break;
}
else if (INSECT_SWARM > 0 && ai->In_Reach(pTarget,INSECT_SWARM) && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && DruidSpellCombat < 6 && !pTarget->HasAura(INSECT_SWARM, EFFECT_INDEX_0) && ai->GetManaPercent() >= 9)
{
ai->CastSpell(INSECT_SWARM, *pTarget);
DruidSpellCombat++;
break;
}
else if (STARFIRE > 0 && ai->In_Reach(pTarget,STARFIRE) && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && DruidSpellCombat < 7 && ai->GetManaPercent() >= 18)
{
ai->CastSpell(STARFIRE, *pTarget);
DruidSpellCombat++;
break;
}
else if (FORCE_OF_NATURE > 0 && ai->In_Reach(pTarget,FORCE_OF_NATURE) && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && DruidSpellCombat < 8 && ai->GetManaPercent() >= 12)
{
//ai->TellMaster("summoning treants.");
ai->CastSpell(FORCE_OF_NATURE);
DruidSpellCombat++;
break;
//.........这里部分代码省略.........