本文整理汇总了C++中PlayerbotAI::GetLeader方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerbotAI::GetLeader方法的具体用法?C++ PlayerbotAI::GetLeader怎么用?C++ PlayerbotAI::GetLeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerbotAI
的用法示例。
在下文中一共展示了PlayerbotAI::GetLeader方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoCombatManeuver
bool PlayerbotWarriorAI::DoCombatManeuver(Unit *pTarget, bool cac)
{
PlayerbotAI* ai = GetAI();
Player* m_bot = GetPlayerBot();
Player* m_master = ai->GetLeader();
switch (m_bot->getRole())
{
case WarriorArms:
{
static const uint32 SpellArms[] = {BLOODTHIRST, WHIRLWIND, BLOODTHIRST, BLOODTHIRST, CLEAVE,
WHIRLWIND, BLOODTHIRST, BLOODTHIRST, WHIRLWIND, BLOODTHIRST, HEROIC_STRIKE};
static uint32 elt = sizeof(SpellArms)/sizeof(uint32);
for (uint32 i = 1; i <= elt; ++i)
{
if (ai->CastSpell(SpellArms[(i+LastSpellArms)%elt], pTarget))
{
LastSpellArms = (i+LastSpellArms)%elt;
return true;
}
}
break;
}
case WarriorProtection:
{
static const uint32 SpellProtection[] = {CHARGE, REND, THUNDER_CLAP, CLEAVE, SHOCKWAVE,
SUNDER_ARMOR, HEROIC_STRIKE, DEVASTATE, SHIELD_SLAM, REVENGE};
static uint32 elt = sizeof(SpellProtection)/sizeof(uint32);
for (uint32 i = 1; i <= elt; ++i)
{
if (ai->CastSpell(SpellProtection[(i+LastSpellProtection)%elt], pTarget))
{
LastSpellProtection = (i+LastSpellProtection)%elt;
return true;
}
}
break;
}
case WarriorFury:
{
static const uint32 SpellFury[] = {BLOODTHIRST, WHIRLWIND, BLOODTHIRST, BLOODTHIRST, CLEAVE,
WHIRLWIND, BLOODTHIRST, BLOODTHIRST, WHIRLWIND, BLOODTHIRST, HEROIC_STRIKE};
static uint32 elt = sizeof(SpellFury)/sizeof(uint32);
for (uint32 i = 1; i <= elt; ++i)
{
if (ai->CastSpell(SpellFury[(i+LastSpellFury)%elt], pTarget))
{
LastSpellFury = (i+LastSpellFury)%elt;
return true;
}
}
break;
}
}
return false;
}
示例2: DoNonCombatActions
void PlayerbotWarriorAI::DoNonCombatActions()
{
PlayerbotAI* ai = GetAI();
Player* m_bot = GetPlayerBot();
Player* m_master = ai->GetLeader();
if (m_bot->getRole() == WarriorProtection && ai->Cast(DEFENSIVE_STANCE))
return;
else if (ai->Cast(BERSERKER_STANCE))
return;
else if (ai->Cast(BATTLE_STANCE))
return;
}
示例3: DoNonCombatActions
void PlayerbotShamanAI::DoNonCombatActions()
{
PlayerbotAI *ai = GetAI();
if (!ai)
return;
Player * m_bot = GetPlayerBot();
if (!m_bot)
return;
Player* m_master = ai->GetLeader();
if (!m_master)
return;
SpellSequence = SPELL_ENHANCEMENT;
// buff master with EARTH_SHIELD
if (EARTH_SHIELD > 0)
(!m_master->HasAura(EARTH_SHIELD, EFFECT_INDEX_0) && ai->CastSpell(EARTH_SHIELD, m_master));
// buff myself with WATER_SHIELD, LIGHTNING_SHIELD
if (WATER_SHIELD > 0)
(!m_bot->HasAura(WATER_SHIELD, EFFECT_INDEX_0) && !m_bot->HasAura(LIGHTNING_SHIELD, EFFECT_INDEX_0) && ai->CastSpell(WATER_SHIELD, m_bot));
else if (LIGHTNING_SHIELD > 0)
(!m_bot->HasAura(LIGHTNING_SHIELD, EFFECT_INDEX_0) && !m_bot->HasAura(WATER_SHIELD, EFFECT_INDEX_0) && ai->CastSpell(LIGHTNING_SHIELD, m_bot));
/*
// buff myself weapon
if (ROCKBITER_WEAPON > 0)
(!m_bot->HasAura(ROCKBITER_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(EARTHLIVING_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(WINDFURY_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(FLAMETONGUE_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(FROSTBRAND_WEAPON, EFFECT_INDEX_0) && ai->CastSpell(ROCKBITER_WEAPON,*m_bot) );
else if (EARTHLIVING_WEAPON > 0)
(!m_bot->HasAura(EARTHLIVING_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(EARTHLIVING_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(FLAMETONGUE_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(FROSTBRAND_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(ROCKBITER_WEAPON, EFFECT_INDEX_0) && ai->CastSpell(WINDFURY_WEAPON,*m_bot) );
else if (WINDFURY_WEAPON > 0)
(!m_bot->HasAura(WINDFURY_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(EARTHLIVING_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(FLAMETONGUE_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(FROSTBRAND_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(ROCKBITER_WEAPON, EFFECT_INDEX_0) && ai->CastSpell(WINDFURY_WEAPON,*m_bot) );
else if (FLAMETONGUE_WEAPON > 0)
(!m_bot->HasAura(FLAMETONGUE_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(EARTHLIVING_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(WINDFURY_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(FROSTBRAND_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(ROCKBITER_WEAPON, EFFECT_INDEX_0) && ai->CastSpell(FLAMETONGUE_WEAPON,*m_bot) );
else if (FROSTBRAND_WEAPON > 0)
(!m_bot->HasAura(FROSTBRAND_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(EARTHLIVING_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(WINDFURY_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(FLAMETONGUE_WEAPON, EFFECT_INDEX_0) && !m_bot->HasAura(ROCKBITER_WEAPON, EFFECT_INDEX_0) && ai->CastSpell(FROSTBRAND_WEAPON,*m_bot) );
*/
// mana check
if (m_bot->getStandState() != UNIT_STAND_STATE_STAND)
m_bot->SetStandState(UNIT_STAND_STATE_STAND);
Item* pItem = ai->FindDrink();
Item* fItem = ai->FindBandage();
if (pItem != NULL && ai->GetManaPercent() < 30)
{
ai->UseItem(pItem);
return;
}
// hp check
if (m_bot->getStandState() != UNIT_STAND_STATE_STAND)
m_bot->SetStandState(UNIT_STAND_STATE_STAND);
pItem = ai->FindFood();
if (pItem != NULL && ai->GetHealthPercent() < 30)
{
ai->UseItem(pItem);
return;
}
else if (pItem == NULL && fItem != NULL && !m_bot->HasAura(RECENTLY_BANDAGED, EFFECT_INDEX_0) && ai->GetHealthPercent() < 70)
{
ai->UseItem(fItem);
return;
}
// heal master's group
if (m_master->GetGroup())
{
Group::MemberSlotList const& groupSlot = m_master->GetGroup()->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *tPlayer = sObjectMgr.GetPlayer(itr->guid);
if (!tPlayer || !tPlayer->isAlive())
continue;
// heal
(HealTarget(tPlayer, tPlayer->GetHealth() * 100 / tPlayer->GetMaxHealth()));
}
}
} // end DoNonCombatActions
示例4: DoNextCombatManeuver
void PlayerbotShamanAI::DoNextCombatManeuver(Unit *pTarget)
{
PlayerbotAI *ai = GetAI();
if (!ai)
return;
Player * m_bot = GetPlayerBot();
if (!m_bot)
return;
Player* m_master = ai->GetLeader();
if (!m_master)
return;
//ai->SetMovementTarget(PlayerbotAI::MOVEMENT_FOLLOW, m_master); // dont want to melee mob <----changed
Group *m_group = m_bot->GetGroup();
// Heal myself
if (ai->GetHealthPercent() < 30 && ai->GetManaPercent() >= 32)
ai->CastSpell(HEALING_WAVE);
else if (ai->GetHealthPercent() < 50 && ai->GetManaPercent() >= 19)
ai->CastSpell(LESSER_HEALING_WAVE);
else if (ai->GetHealthPercent() < 70)
HealTarget(m_bot, ai->GetHealthPercent());
// Heal master
uint32 masterHP = m_master->GetHealth() * 100 / m_master->GetMaxHealth();
if (m_master->isAlive())
{
if (masterHP < 30 && ai->GetManaPercent() >= 32)
ai->CastSpell(HEALING_WAVE, m_master);
else if (masterHP < 70)
HealTarget(m_master, masterHP);
}
// 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 < 30)
HealTarget(m_groupMember, memberHP);
}
}
// Damage Spells
ai->SetInFront(pTarget);
switch (SpellSequence)
{
case SPELL_ENHANCEMENT:
if (STRENGTH_OF_EARTH_TOTEM > 0 && LastSpellEnhancement == 1 && (!m_bot->HasAura(STRENGTH_OF_EARTH_TOTEM, EFFECT_INDEX_0)) && ai->GetManaPercent() >= 13)
{
ai->CastSpell(STRENGTH_OF_EARTH_TOTEM);
SpellSequence = SPELL_RESTORATION;
LastSpellEnhancement = LastSpellEnhancement + 1;
break;
}
else if (STONESKIN_TOTEM > 0 && LastSpellEnhancement == 5 && (!m_bot->HasAura(STONESKIN_TOTEM, EFFECT_INDEX_0)) && (!m_bot->HasAura(STRENGTH_OF_EARTH_TOTEM, EFFECT_INDEX_0)) && ai->GetManaPercent() >= 13)
{
ai->CastSpell(STONESKIN_TOTEM);
SpellSequence = SPELL_RESTORATION;
LastSpellEnhancement = LastSpellEnhancement + 1;
break;
}
else if (FOCUSED > 0 && LastSpellEnhancement == 2)
{
ai->CastSpell(FOCUSED, pTarget);
SpellSequence = SPELL_RESTORATION;
LastSpellEnhancement = LastSpellEnhancement + 1;
break;
}
else if (FROST_RESISTANCE_TOTEM > 0 && LastSpellEnhancement == 10 && (!m_bot->HasAura(FROST_RESISTANCE_TOTEM, EFFECT_INDEX_0)) && (!m_bot->HasAura(TOTEM_OF_WRATH, EFFECT_INDEX_0)) && (!m_bot->HasAura(FLAMETONGUE_TOTEM, EFFECT_INDEX_0)) && ai->GetManaPercent() >= 10)
{
ai->CastSpell(FROST_RESISTANCE_TOTEM);
SpellSequence = SPELL_RESTORATION;
LastSpellEnhancement = LastSpellEnhancement + 1;
break;
}
else if (FLAMETONGUE_TOTEM > 0 && LastSpellEnhancement == 15 && (!m_bot->HasAura(FLAMETONGUE_TOTEM, EFFECT_INDEX_0)) && (!m_bot->HasAura(TOTEM_OF_WRATH, EFFECT_INDEX_0)) && (!m_bot->HasAura(FROST_RESISTANCE_TOTEM, EFFECT_INDEX_0)) && ai->GetManaPercent() >= 14)
{
ai->CastSpell(FLAMETONGUE_TOTEM);
SpellSequence = SPELL_RESTORATION;
LastSpellEnhancement = LastSpellEnhancement + 1;
break;
}
else if (FIRE_RESISTANCE_TOTEM > 0 && LastSpellEnhancement == 20 && (!m_bot->HasAura(FIRE_RESISTANCE_TOTEM, EFFECT_INDEX_0)) && (!m_bot->HasAura(HEALING_STREAM_TOTEM, EFFECT_INDEX_0)) && (!m_bot->HasAura(MANA_SPRING_TOTEM, EFFECT_INDEX_0)) && ai->GetManaPercent() >= 10)
{
ai->CastSpell(FIRE_RESISTANCE_TOTEM);
SpellSequence = SPELL_RESTORATION;
LastSpellEnhancement = LastSpellEnhancement + 1;
break;
}
//.........这里部分代码省略.........
示例5: DoNonCombatActions
void PlayerbotHunterAI::DoNonCombatActions()
{
PlayerbotAI *ai = GetAI();
Player * m_bot = GetPlayerBot();
Player* m_master = ai->GetLeader();
static const uint32 MinorGlyphs[] = {57903, 57866, 57870}; // feigh death - revive pet - healing pet
static const uint32 SurvivalMajorGlyphs[] = {56832, 56826, 63066}; // serpent sting - steady shot - explosive shot
for (uint32 i = 0; i < 3; i++)
{
if (!m_bot->HasSpell(MinorGlyphs[i]))
m_bot->learnSpell(MinorGlyphs[i], true);
if (!m_bot->HasSpell(SurvivalMajorGlyphs[i]))
m_bot->learnSpell(SurvivalMajorGlyphs[i], true);
}
if (!m_bot->HasAura(TRUESHOT_AURA, EFFECT_INDEX_0))
ai->CastSpell(TRUESHOT_AURA, m_bot);
if (!m_bot->HasAura(ASPECT_OF_THE_VIPER, EFFECT_INDEX_0) && ai->GetManaPercent() < 90 && ai->CastSpell(ASPECT_OF_THE_VIPER, m_bot))
return;
else if (!m_bot->HasAura(ASPECT_OF_THE_DRAGONHAWK, EFFECT_INDEX_0) && ai->GetManaPercent() >= 90 && ai->CastSpell(ASPECT_OF_THE_DRAGONHAWK, m_bot))
return;
// reset ranged combat state
if (!m_rangedCombat)
m_rangedCombat = true;
// check for pet
if (PET_SUMMON > 0 && !m_petSummonFailed && HasPet(m_bot))
{
// we can summon pet, and no critical summon errors before
Pet *pet = m_bot->GetPet();
if (!pet)
{
// summon pet
if (PET_SUMMON > 0 && ai->CastSpell(PET_SUMMON, m_bot))
{
}
else
{
m_petSummonFailed = true;
}
}
else if (pet->getDeathState() != ALIVE)
{
// revive pet
if (PET_REVIVE > 0 && ai->GetManaPercent() >= 80 && ai->CastSpell(PET_REVIVE, m_bot))
{
}
}
else if (((float) pet->GetHealth() / (float) pet->GetMaxHealth()) < 0.5f)
{
// heal pet when health lower 50%
if (PET_MEND > 0 && !pet->getDeathState() != ALIVE && !pet->HasAura(PET_MEND, EFFECT_INDEX_0) && ai->GetManaPercent() >= 13 && ai->CastSpell(PET_MEND, m_bot))
{
}
}
else if (pet->GetHappinessState() != HAPPY) // if pet is hungry
{
Unit *caster = (Unit*) m_bot;
// list out items in main backpack
for (uint8 slot = INVENTORY_SLOT_ITEM_START; slot < INVENTORY_SLOT_ITEM_END; slot++)
{
Item* const pItem = m_bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
if (pItem)
{
const ItemPrototype* const pItemProto = pItem->GetProto();
if (!pItemProto)
continue;
if (pet->HaveInDiet(pItemProto)) // is pItem in pets diet
{
caster->CastSpell(caster, 51284, true); // pet feed visual
uint32 count = 1; // number of items used
int32 benefit = pet->GetCurrentFoodBenefitLevel(pItemProto->ItemLevel); // nutritional value of food
m_bot->DestroyItemCount(pItem, count, true); // remove item from inventory
m_bot->CastCustomSpell(m_bot, PET_FEED, &benefit, NULL, NULL, true); // feed pet
ai->SetIgnoreUpdateTime(10);
return;
}
}
}
// list out items in other removable backpacks
for (uint8 bag = INVENTORY_SLOT_BAG_START; bag < INVENTORY_SLOT_BAG_END; ++bag)
{
const Bag* const pBag = (Bag*) m_bot->GetItemByPos(INVENTORY_SLOT_BAG_0, bag);
if (pBag)
for (uint8 slot = 0; slot < pBag->GetBagSize(); ++slot)
{
Item* const pItem = m_bot->GetItemByPos(bag, slot);
if (pItem)
{
const ItemPrototype* const pItemProto = pItem->GetProto();
if (!pItemProto)
continue;
//.........这里部分代码省略.........
示例6: DoCombatManeuver
bool PlayerbotHunterAI::DoCombatManeuver(Unit *pTarget, bool cac)
{
PlayerbotAI *ai = GetAI();
Player * m_bot = GetPlayerBot();
Player* m_master = ai->GetLeader();
// Hunter
Unit* pVictim = pTarget->getVictim();
/*
// check for pet and heal if neccessary
Pet *pet = m_bot->GetPet();
if ((pet)
&& (((float) pet->GetHealth() / (float) pet->GetMaxHealth()) < 0.5f)
&& (PET_MEND > 0 && !pet->getDeathState() != ALIVE && pVictim != m_bot && !pet->HasAura(PET_MEND, EFFECT_INDEX_0) && ai->GetManaPercent() >= 13 && ai->CastSpell(PET_MEND, m_bot)))
{
return true;
}
else if ((pet)
&& (INTIMIDATION > 0 && pVictim == pet && !pet->HasAura(INTIMIDATION, EFFECT_INDEX_0) && ai->CastSpell(INTIMIDATION, m_bot)))
return true;*/
// racial traits
if (m_bot->getRace() == RACE_ORC && !m_bot->HasAura(BLOOD_FURY, EFFECT_INDEX_0) && ai->CastSpell(BLOOD_FURY, m_bot))
return true;
else if (m_bot->getRace() == RACE_TROLL && !m_bot->HasAura(BERSERKING, EFFECT_INDEX_0) && ai->CastSpell(BERSERKING, m_bot))
return true;
if (m_bot->IsWithinDist(pTarget, ATTACK_DISTANCE))
m_rangedCombat = false;
else
m_rangedCombat = true;
if (!m_bot->HasAura(ASPECT_OF_THE_VIPER) && ai->GetManaPercent() < 50 && ai->CastSpell(ASPECT_OF_THE_VIPER, m_bot))
return true;
else if (!m_bot->HasAura(ASPECT_OF_THE_DRAGONHAWK) && ai->GetManaPercent() >= 80 && ai->CastSpell(ASPECT_OF_THE_DRAGONHAWK, m_bot))
return true;
// damage spells
if (!pTarget->HasAura(HUNTERS_MARK) && ai->CastSpell(HUNTERS_MARK, pTarget))
return true;
if (m_bot->HasAura(ASPECT_OF_THE_VIPER) && ai->CastSpell(RAPID_FIRE))
return true;
static const uint32 RangedSpell[] = {KILL_SHOT, EXPLOSIVE_SHOT, SERPENT_STING, BLACK_ARROW, ARCANE_SHOT, AIMED_SHOT, STEADY_SHOT};
static const uint32 MeleeSpell[] = {MONGOOSE_BITE, RAPTOR_STRIKE, IMMOLATION_TRAP, EXPLOSIVE_TRAP};
static const uint32 eltRanged = sizeof(RangedSpell)/sizeof(uint32);
static const uint32 eltMelee = sizeof(MeleeSpell)/sizeof(uint32);
char *RangedSpellEnabled = "001110F";
char *MeleeSpellEnabled = "1110";
uint32 numberTargets = 0;
if (m_bot->getLevel() >= 34)
MeleeSpellEnabled = "1101";
if (m_bot->getLevel() >= 60)
RangedSpellEnabled = "111101F";
// Count number of targets
Group* m_group = m_bot->GetGroup();
GroupReference *ref = (m_group) ? m_group->GetFirstMember() : NULL;
do
{
Player *g_member = (ref) ? ref->getSource() : m_bot;
if (!g_member->isAlive())
continue;
for (Unit::AttackerSet::const_iterator itr = g_member->getAttackers().begin(); itr != g_member->getAttackers().end(); itr++)
if ((*itr)->IsWithinDist(m_bot, 36.0f))
numberTargets++;
}while(ref = (ref) ? ref->next() : NULL);
// Spells with Area of Effect
if (m_rangedCombat && numberTargets >= 3 && ai->CastSpell(MULTI_SHOT, pTarget))
return true;
if (numberTargets >= 5 && ai->CastSpell(VOLLEY, pTarget))
return true;
// Casting spell cycle
if (m_rangedCombat)
{
for (uint32 i = 0; i < eltRanged; ++i)
{
if (RangedSpellEnabled[i] == 'F')
{
if (m_bot->HasAura(ASPECT_OF_THE_DRAGONHAWK) && !pTarget->HasAuraFromUnit(RangedSpell[i], m_bot) && ai->CastSpell(RangedSpell[i], pTarget))
return true;
else
continue;
}
else if (RangedSpellEnabled[i] == '1')
{
if (!pTarget->HasAuraFromUnit(RangedSpell[i], m_bot) && ai->CastSpell(RangedSpell[i], pTarget))
return true;
}
//.........这里部分代码省略.........
示例7: DoNonCombatActions
void PlayerbotDruidAI::DoNonCombatActions()
{
PlayerbotAI *ai = GetAI();
if (!ai)
return;
Player * m_bot = GetPlayerBot();
if (!m_bot)
return;
Player* m_master = ai->GetLeader();
if (!m_master)
return;
// mana check
if (m_bot->getStandState() != UNIT_STAND_STATE_STAND)
m_bot->SetStandState(UNIT_STAND_STATE_STAND);
Item* pItem = ai->FindDrink();
Item* fItem = ai->FindBandage();
if (pItem != NULL && ai->GetManaPercent() < 30)
{
ai->UseItem(pItem);
return;
}
else if (!pItem && INNERVATE > 0 && !m_bot->HasAura(INNERVATE) && ai->GetManaPercent() <= 20 && ai->CastSpell(INNERVATE, m_bot))
return;
// hp check
if (m_bot->getStandState() != UNIT_STAND_STATE_STAND)
m_bot->SetStandState(UNIT_STAND_STATE_STAND);
pItem = ai->FindFood();
if (pItem != NULL && ai->GetHealthPercent() < 30)
{
ai->UseItem(pItem);
return;
}
else if (pItem == NULL && fItem != NULL && !m_bot->HasAura(RECENTLY_BANDAGED, EFFECT_INDEX_0) && ai->GetHealthPercent() < 70)
{
ai->UseItem(fItem);
return;
}
// buff and heal master's group
if (m_master->GetGroup())
{
// Buff master with group buff
if (m_master->isAlive() && GIFT_OF_THE_WILD && ai->HasSpellReagents(GIFT_OF_THE_WILD) && ai->Buff(GIFT_OF_THE_WILD, m_master))
return;
Group::MemberSlotList const& groupSlot = m_master->GetGroup()->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *tPlayer = sObjectMgr.GetPlayer(itr->guid);
if (!tPlayer || tPlayer == m_bot)
continue;
// Resurrect member if needed
if (!tPlayer->isAlive())
{
if (ai->CastSpell(REVIVE, tPlayer))
return;
else
continue;
}
else
{
// buff and heal
if (BuffPlayer(tPlayer))
return;
if (HealTarget(tPlayer))
return;
}
}
}
else
{
if (m_master->isAlive())
{
if (BuffPlayer(m_master))
return;
if (HealTarget(m_master))
return;
}
else
ai->CastSpell(REVIVE, m_master);
}
BuffPlayer(m_bot);
} // end DoNonCombatActions
示例8: DoNextCombatManeuver
void PlayerbotDruidAI::DoNextCombatManeuver(Unit *pTarget)
{
PlayerbotAI *ai = GetAI();
if (!ai)
return;
Player * m_bot = GetPlayerBot();
if (!m_bot)
return;
Player* m_master = ai->GetLeader();
if (!m_master)
return;
uint32 masterHP = m_master->GetHealth() * 100 / m_master->GetMaxHealth();
ai->SetInFront(pTarget);
Unit* pVictim = pTarget->getVictim();
if (pVictim && ai->GetHealthPercent() >= 40 && m_master->GetHealth() >= m_master->GetMaxHealth() * 0.4)
{
if (pVictim == m_bot)
SpellSequence = DruidTank;
}
else if (pTarget->GetHealth() > pTarget->GetMaxHealth() * 0.8 && pVictim)
{
if (pVictim != m_bot)
SpellSequence = DruidSpell;
}
else if (ai->GetHealthPercent() <= 40 || m_master->GetHealth() <= m_master->GetMaxHealth() * 0.4)
SpellSequence = DruidHeal;
else
SpellSequence = DruidCombat;
switch (SpellSequence)
{
case DruidTank: // Its now a tank druid!
if (!m_bot->HasInArc(M_PI_F, pTarget))
{
m_bot->SetInFront(pTarget);
}
if (m_bot->HasAura(CAT_FORM, EFFECT_INDEX_0))
m_bot->RemoveAurasDueToSpell(768);
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 && DruidSpellCombat < 1 && !pTarget->HasAura(FAERIE_FIRE, EFFECT_INDEX_0))
{
ai->CastSpell(FAERIE_FIRE, pTarget);
DruidSpellCombat++;
break;
}
else if (MOONFIRE > 0 && 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 && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && DruidSpellCombat < 4 && ai->GetManaPercent() >= 91)
{
ai->CastSpell(HURRICANE, pTarget);
ai->SetIgnoreUpdateTime(10);
DruidSpellCombat++;
break;
}
else if (WRATH > 0 && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && DruidSpellCombat < 5 && ai->GetManaPercent() >= 13)
{
ai->CastSpell(WRATH, pTarget);
DruidSpellCombat++;
break;
}
else if (INSECT_SWARM > 0 && 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 && 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 && m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0) && DruidSpellCombat < 8 && ai->GetManaPercent() >= 12)
{
ai->CastSpell(FORCE_OF_NATURE);
DruidSpellCombat++;
break;
}
//.........这里部分代码省略.........
示例9: DoNonCombatActions
void PlayerbotPriestAI::DoNonCombatActions()
{
PlayerbotAI *ai = GetAI();
if (!ai)
return;
Player * m_bot = GetPlayerBot();
if (!m_bot)
return;
Player* m_master = ai->GetLeader();
if (!m_master)
return;
SpellSequence = SPELL_HOLY;
// selfbuff goes first
if (ai->SelfBuff(INNER_FIRE))
return;
// mana check
if (m_bot->getStandState() != UNIT_STAND_STATE_STAND)
m_bot->SetStandState(UNIT_STAND_STATE_STAND);
Item* pItem = ai->FindDrink();
Item* fItem = ai->FindBandage();
if (pItem != NULL && ai->GetManaPercent() < 30)
{
ai->UseItem(pItem);
return;
}
// hp check
if (m_bot->getStandState() != UNIT_STAND_STATE_STAND)
m_bot->SetStandState(UNIT_STAND_STATE_STAND);
pItem = ai->FindFood();
if (pItem != NULL && ai->GetHealthPercent() < 30)
{
ai->UseItem(pItem);
return;
}
else if (pItem == NULL && fItem != NULL && !m_bot->HasAura(RECENTLY_BANDAGED, EFFECT_INDEX_0) && ai->GetHealthPercent() < 70)
{
ai->UseItem(fItem);
return;
}
// buff and heal master's group
if (m_master->GetGroup())
{
// Buff master with group buffs
if (m_master->isAlive())
{
if (PRAYER_OF_FORTITUDE && ai->HasSpellReagents(PRAYER_OF_FORTITUDE) && ai->Buff(PRAYER_OF_FORTITUDE, m_master))
return;
if (PRAYER_OF_SPIRIT && ai->HasSpellReagents(PRAYER_OF_SPIRIT) && ai->Buff(PRAYER_OF_SPIRIT, m_master))
return;
}
Group::MemberSlotList const& groupSlot = m_master->GetGroup()->GetMemberSlots();
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
{
Player *tPlayer = sObjectMgr.GetPlayer(itr->guid);
if (!tPlayer || tPlayer == m_bot)
continue;
// first rezz em
if (!tPlayer->isAlive())
{
if (ai->CastSpell(RESURRECTION, tPlayer))
{
std::string msg = "Resurrecting ";
msg += tPlayer->GetName();
m_bot->Say(msg, LANG_UNIVERSAL);
return;
}
else
continue;
}
else
{
// buff and heal
if (BuffPlayer(tPlayer))
return;
if (HealTarget(tPlayer))
return;
}
}
}
else
{
if (m_master->isAlive())
{
if (BuffPlayer(m_master))
return;
//.........这里部分代码省略.........
示例10: DoNextCombatManeuver
void PlayerbotPriestAI::DoNextCombatManeuver(Unit *pTarget)
{
Unit* pVictim = pTarget->getVictim();
PlayerbotAI* ai = GetAI();
if (!ai)
return;
Player* m_master = ai->GetLeader();
if (!m_master)
return;
//ai->SetMovementTarget(PlayerbotAI::MOVEMENT_FOLLOW, m_master); // dont want to melee mob
Player *m_bot = GetPlayerBot();
Group *m_group = m_bot->GetGroup();
// Heal myself
if (ai->GetHealthPercent() < 15 && FADE > 0 && !m_bot->HasAura(FADE, EFFECT_INDEX_0))
{
ai->CastSpell(FADE, m_bot);
}
else if (ai->GetHealthPercent() < 25 && POWER_WORD_SHIELD > 0 && !m_bot->HasAura(POWER_WORD_SHIELD, EFFECT_INDEX_0))
{
ai->CastSpell(POWER_WORD_SHIELD);
}
else if (ai->GetHealthPercent() < 35 && DESPERATE_PRAYER > 0)
{
ai->CastSpell(DESPERATE_PRAYER, m_bot);
}
else if (ai->GetHealthPercent() < 80)
HealTarget (m_bot);
// Heal master
uint32 masterHP = m_master->GetHealth() * 100 / m_master->GetMaxHealth();
if (m_master->isAlive())
{
if (masterHP < 25 && POWER_WORD_SHIELD > 0 && !m_master->HasAura(POWER_WORD_SHIELD, EFFECT_INDEX_0))
ai->CastSpell(POWER_WORD_SHIELD, m_master);
else if (masterHP < 80)
HealTarget (m_master);
}
// 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
ai->SetInFront(pTarget);
float dist = m_bot->GetDistance(pTarget);
switch (SpellSequence)
{
case SPELL_HOLY:
if (SMITE > 0 && 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 && LastSpellHoly < 2 && pTarget->GetPower(POWER_MANA) > 0 && ai->GetManaPercent() < 70 && ai->GetManaPercent() >= 14)
{
ai->CastSpell(MANA_BURN, pTarget);
ai->SetIgnoreUpdateTime(3);
SpellSequence = SPELL_SHADOWMAGIC;
LastSpellHoly = LastSpellHoly + 1;
break;
}
else if (HOLY_NOVA > 0 && LastSpellHoly < 3 && dist <= ATTACK_DISTANCE && ai->GetManaPercent() >= 22)
{
ai->CastSpell(HOLY_NOVA);
SpellSequence = SPELL_SHADOWMAGIC;
LastSpellHoly = LastSpellHoly + 1;
break;
}
else if (HOLY_FIRE > 0 && LastSpellHoly < 4 && !pTarget->HasAura(HOLY_FIRE, EFFECT_INDEX_0) && ai->GetManaPercent() >= 13)
{
ai->CastSpell(HOLY_FIRE, pTarget);
SpellSequence = SPELL_SHADOWMAGIC;
LastSpellHoly = LastSpellHoly + 1;
break;
}
//.........这里部分代码省略.........