本文整理汇总了C++中PlayerbotAI类的典型用法代码示例。如果您正苦于以下问题:C++ PlayerbotAI类的具体用法?C++ PlayerbotAI怎么用?C++ PlayerbotAI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlayerbotAI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAI
void PlayerbotDeathKnightAI::DoNonCombatActions()
{
PlayerbotAI *ai = GetAI();
Player *m_bot = GetPlayerBot();
if (!m_bot || !ai || m_bot->isDead()) { return; }
//If Casting or Eating/Drinking return
if (m_bot->HasUnitState(UNIT_STATE_CASTING)) { return; }
if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) { return; }
//Buff UP
if (CastSpell(HORN_OF_WINTER,m_bot)) { return; }
if (CastSpell(BONE_SHIELD,m_bot)) { return; }
//mana/hp check
if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) { return; }
if (m_bot->GetHealth() < m_bot->GetMaxHealth() && CastSpell(RUNE_TAP,m_bot)) { return; } //no gcd but lets give the others a time to heal
if (ai->GetHealthPercent() < 30) { ai->Feast(); }
//Item* fItem = ai->FindBandage();
/* if (pItem == NULL && fItem != NULL && !m_bot->HasAura(RECENTLY_BANDAGED, 0) && ai->GetHealthPercent() < 70)
{
ai->TellMaster("I could use first aid.");
ai->UseItem(*fItem);
ai->SetIgnoreUpdateTime(8);
return;
} */
} // end DoNonCombatActions
示例2: GetAI
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;
}
示例3: packet
void PlayerbotAI::DoNextAction()
{
if (bot->IsBeingTeleported() /*|| bot->IsBeingTeleportedDelayEvent()*/|| (GetMaster() && GetMaster()->IsBeingTeleported()))
return;
currentEngine->DoNextAction(NULL);
/*if (!bot->GetAurasByType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED).empty())
{
bot->m_movementInfo.SetMovementFlags((MovementFlags)(MOVEFLAG_FLYING|MOVEFLAG_CAN_FLY));
WorldPacket packet(CMSG_MOVE_SET_FLY);
packet << bot->GetObjectGuid().WriteAsPacked();
packet << bot->m_movementInfo;
bot->SetMover(bot);
bot->GetSession()->HandleMovementOpcodes(packet);
}*/
Player* master = GetMaster();
if (bot->IsMounted() && bot->IsFlying())
{
bot->m_movementInfo.SetMovementFlags((MovementFlags)(MOVEFLAG_FLYING|MOVEFLAG_CAN_FLY));
//bot->SetSpeedRate(MOVE_FLIGHT, 1.0f, true);
bot->SetSpeedRate(MOVE_RUN, 1.0f, true);
if (master)
{
//bot->SetSpeedRate(MOVE_FLIGHT, master->GetSpeedRate(MOVE_FLIGHT), true);
//bot->SetSpeedRate(MOVE_RUN, master->GetSpeedRate(MOVE_FLIGHT), true);
}
}
if (currentEngine != engines[BOT_STATE_DEAD] && !bot->IsAlive())
ChangeEngine(BOT_STATE_DEAD);
if (currentEngine == engines[BOT_STATE_DEAD] && bot->IsAlive())
ChangeEngine(BOT_STATE_NON_COMBAT);
Group *group = bot->GetGroup();
if (!master && group)
{
for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next())
{
Player* member = gref->getSource();
PlayerbotAI* ai = bot->GetPlayerbotAI();
if (member && member->IsInWorld() && !member->GetPlayerbotAI() && (!master || master->GetPlayerbotAI()))
{
ai->SetMaster(member);
ai->ResetStrategies();
ai->TellMaster("Hello");
break;
}
}
}
}
示例4: GetAI
bool PlayerbotHunterAI::DoProtectSelfAction()
{
PlayerbotAI *ai = GetAI();
Player *m_bot = GetPlayerBot();
if (ai->CastAura(DETERRENCE, m_bot))
return true;
return false;
}
示例5: GetAI
void PlayerbotDeathKnightAI::DoNonCombatActions()
{
PlayerbotAI* ai = GetAI();
Player *m_bot = GetPlayerBot();
if (!m_bot)
return;
SpellSequence = SPELL_DK_UNHOLY;
// buff master with HORN_OF_WINTER
if (HORN_OF_WINTER > 0)
(!GetMaster()->HasAura(HORN_OF_WINTER, EFFECT_INDEX_0) && ai->CastSpell (HORN_OF_WINTER, *GetMaster()));
// hp check
if (m_bot->getStandState() != UNIT_STAND_STATE_STAND)
m_bot->SetStandState(UNIT_STAND_STATE_STAND);
Item* pItem = ai->FindFood();
Item* fItem = ai->FindBandage();
if (pItem != NULL && ai->GetHealthPercent() < 30)
{
ai->TellMaster("I could use some food.");
ai->UseItem(pItem);
return;
}
else if (pItem == NULL && fItem != NULL && !m_bot->HasAura(RECENTLY_BANDAGED, EFFECT_INDEX_0) && ai->GetHealthPercent() < 70)
{
ai->TellMaster("I could use first aid.");
ai->UseItem(fItem);
return;
}
} // end DoNonCombatActions
示例6: GetAI
void PlayerbotDruidAI::_DoNextPVECombatManeuverHeal(Unit* pTarget)
{
PlayerbotAI* ai = GetAI();
if (!ai)
return;
uint32 masterHP = GetMaster()->GetHealth() * 100 / GetMaster()->GetMaxHealth();
Player *m_bot = GetPlayerBot();
Unit* pVictim = pTarget->getVictim();
if (TREE_OF_LIFE > 0 && !m_bot->HasAura(TREE_OF_LIFE, EFFECT_INDEX_0))
ai->CastSpell(TREE_OF_LIFE, *m_bot);
if (m_bot->HasAura(CAT_FORM, EFFECT_INDEX_0))
{
m_bot->RemoveAurasDueToSpell(CAT_FORM_1);
//ai->TellMaster("FormClearCat");
return;
}
if (m_bot->HasAura(BEAR_FORM, EFFECT_INDEX_0))
{
m_bot->RemoveAurasDueToSpell(BEAR_FORM_1);
//ai->TellMaster("FormClearBear");
return;
}
if (m_bot->HasAura(DIRE_BEAR_FORM, EFFECT_INDEX_0))
{
m_bot->RemoveAurasDueToSpell(DIRE_BEAR_FORM_1);
//ai->TellMaster("FormClearDireBear");
return;
}
// spellcasting form, but disables healing spells so it's got to go
if (m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0))
{
m_bot->RemoveAurasDueToSpell(MOONKIN_FORM_1);
//ai->TellMaster("FormClearMoonkin");
return;
}
if (ai->GetHealthPercent() <= 60)
{
HealTarget(m_bot);
return;
}
if (masterHP <= 50)
{
HealTarget(GetMaster());
return;
}
// TODO: err... what about the other teammates?
DruidSpellCombat = 0;
}
示例7: GetAI
bool PlayerbotMageAI::BuffPlayer(Player* target)
{
PlayerbotAI * ai = GetAI();
Pet * pet = target->GetPet();
if (pet && pet->getPowerType() == POWER_MANA && ai->Buff(ARCANE_INTELLECT, pet))
return true;
if (ARCANE_INTELLECT)
return ai->Buff(ARCANE_INTELLECT, target);
else
return false;
}
示例8: GetAI
void PlayerbotShamanAI::DoNonCombatActions()
{
PlayerbotAI *ai = GetAI();
Player *m_bot = GetPlayerBot();
if (!m_bot || !ai || m_bot->isDead()) {
return;
}
//If Casting or Eating/Drinking return
if (m_bot->HasUnitState(UNIT_STATE_CASTING)) {
return;
}
if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) {
return;
}
//buff and heal raid
if (DoSupportRaid(m_bot)) {
return;
}
//heal pets and bots
Unit *target = DoSelectLowestHpFriendly(40, 1000);
if (target && target->isAlive() && HealTarget(target, target->GetHealth()*100 / target->GetMaxHealth())) {
return;
}
//Buffs
if (ChangeWeaponEnchants()) {
return;
}
if (CastSpell(WATER_SHIELD,m_bot)) {
return;
}
if (CastSpell(EARTH_SHIELD,m_bot)) {
return;
}
//mana/hp check
//Don't bother with eating, if low on hp, just let it heal themself
if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) {
return;
}
if (m_bot->GetHealth() < m_bot->GetMaxHealth() && CastSpell(LESSER_HEAL,m_bot)) {
return;
}
if (ai->GetManaPercent() < 50) {
ai->Feast();
}
} //end DoNonCombatActions
示例9: GetAI
bool PlayerbotPriestAI::HealTarget(Unit* target)
{
PlayerbotAI* ai = GetAI();
uint8 hp = target->GetHealth() * 100 / target->GetMaxHealth();
if (hp >= 80)
return false;
if (hp < 25 && FLASH_HEAL && ai->CastSpell(FLASH_HEAL, *target))
return true;
else if (hp < 30 && GREATER_HEAL > 0 && ai->CastSpell(GREATER_HEAL, *target))
return true;
else if (hp < 33 && BINDING_HEAL > 0 && ai->CastSpell(BINDING_HEAL, *target))
return true;
else if (hp < 40 && PRAYER_OF_HEALING > 0 && ai->CastSpell(PRAYER_OF_HEALING, *target))
return true;
else if (hp < 50 && CIRCLE_OF_HEALING > 0 && ai->CastSpell(CIRCLE_OF_HEALING, *target))
return true;
else if (hp < 60 && HEAL > 0 && ai->CastSpell(HEAL, *target))
return true;
else if (hp < 80 && RENEW > 0 && ai->CastSpell(RENEW, *target))
return true;
else
return false;
} // end HealTarget
示例10: GetAI
bool PlayerbotDruidAI::ChangeForm(uint32 form)
{
PlayerbotAI *ai = GetAI();
Player *m_bot = GetPlayerBot();
if (!m_bot || !ai || m_bot->isDead()) { return false; }
if (!form) return false;
if (form == 1 && ai->GetForm() == FORM_NONE) return false;
if (form != 1)
{
if (!CanCast(form,m_bot,0,0,1)) return false;
if (m_bot->HasAura(form)) { return false; }
}
if (ai->GetForm() == FORM_TREE) m_bot->RemoveAurasDueToSpell(TREE_OF_LIFE_FORM);
else if (ai->GetForm() == FORM_CAT) m_bot->RemoveAurasDueToSpell(CAT_FORM);
else if (ai->GetForm() == FORM_MOONKIN) m_bot->RemoveAurasDueToSpell(MOONKIN_FORM);
else if (ai->GetForm() == FORM_DIREBEAR || ai->GetForm() == FORM_BEAR) m_bot->RemoveAurasDueToSpell(BEAR_FORM);
else if (ai->GetForm() == FORM_TRAVEL) m_bot->RemoveAurasDueToSpell(TRAVEL_FORM);
else if (ai->GetForm() == FORM_FLIGHT || ai->GetForm() == FORM_FLIGHT_EPIC) m_bot->RemoveAurasDueToSpell(FLIGHT_FORM);
else if (ai->GetForm() == FORM_AQUA) m_bot->RemoveAurasDueToSpell(AQUATIC_FORM);
if (form == 1) { return true; }
return CastSpell(form,m_bot,false);
}
示例11: GetAI
void PlayerbotMageAI::DoNonCombatActions()
{
PlayerbotAI *ai = GetAI();
Player *m_bot = GetPlayerBot();
if (!m_bot || !ai || m_bot->isDead()) { return; }
// make sure pet stays by your side
uint64 pet_guid = m_bot->GetPetGUID();
if (pet_guid>0){
Pet* pet = ObjectAccessor::GetPet(*m_bot, pet_guid);
Unit *unit = ObjectAccessor::GetUnit(*m_bot, pet_guid);
if (unit!=NULL){
m_bot->GetSession()->HandlePetActionHelper(unit, pet_guid, COMMAND_FOLLOW, ACT_COMMAND, 0);
m_bot->GetSession()->HandlePetActionHelper(unit, pet_guid, REACT_DEFENSIVE, ACT_REACTION, 0);
}
}
//If Casting or Eating/Drinking return
if (m_bot->HasUnitState(UNIT_STAT_CASTING)) { return; }
if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) { return; }
//buff and heal raid
if (DoSupportRaid(m_bot,30,0,0,0,1,1)) { return; }
//Own Buffs
if (MOLTEN_ARMOR) { if ( CastSpell(MOLTEN_ARMOR,m_bot)) { return; } }
else if (CastSpell(MAGE_ARMOR,m_bot)) { return; }
if (CastSpell(COMBUSTION,m_bot)) { } //nogcd
if (!HasAuraName(m_bot, MANA_SHIELD)) CastSpell (MANA_SHIELD);
//conjure food & water
Item *pItem = ai->FindDrink();
if(pItem == NULL && ai->GetManaPercent() >= 48)
{
if (CastSpell(CONJURE_REFRESHMENT, m_bot)) { return; }
if (CastSpell(CONJURE_WATER, m_bot)) { return; }
return;
}
pItem = ai->FindFood();
if(pItem == NULL && ai->GetManaPercent() >= 48)
{
if (CastSpell(CONJURE_REFRESHMENT, m_bot)) { return; }
if (CastSpell(CONJURE_FOOD, m_bot)) { return; }
return;
}
//Conjure mana gem??
//mana/hp check
//Don't bother with eating, if low on hp, just let it heal themself
if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) { return; }
if (ai->GetManaPercent() < 50 && CastSpell (EVOCATION, m_bot)) { return; }
if (ai->GetManaPercent() < 50 || ai->GetHealthPercent() < 50) { ai->Feast(); }
} //end DoNonCombatActions
示例12: IsHeal
bool PlayerbotAI::IsHeal(Player* player)
{
PlayerbotAI* botAi = player->GetPlayerbotAI();
if (botAi)
return botAi->ContainsStrategy(STRATEGY_TYPE_HEAL);
switch (player->getClass())
{
case CLASS_PRIEST:
return true;
case CLASS_DRUID:
return HasAnyAuraOf(player, "tree of life form", NULL);
}
return false;
}
示例13: GetAI
bool PlayerbotPriestAI::BuffPlayer(Player* target)
{
PlayerbotAI * ai = GetAI();
Pet * pet = target->GetPet();
if (pet && ai->Buff(POWER_WORD_FORTITUDE, pet))
return true;
if (ai->Buff(POWER_WORD_FORTITUDE, target))
return true;
if ((target->getClass() == CLASS_DRUID || target->GetPowerType() == POWER_MANA) && ai->Buff(DIVINE_SPIRIT, target))
return true;
return false;
}
示例14: Refresh
WorldObject* LootObject::GetWorldObject(Player* bot)
{
Refresh(bot, guid);
PlayerbotAI* ai = bot->GetPlayerbotAI();
Creature *creature = ai->GetCreature(guid);
if (creature && creature->getDeathState() == CORPSE)
return creature;
GameObject* go = ai->GetGameObject(guid);
if (go && go->isSpawned())
return go;
return NULL;
}
示例15: IsTank
bool PlayerbotAI::IsTank(Player* player)
{
PlayerbotAI* botAi = player->GetPlayerbotAI();
if (botAi)
return botAi->ContainsStrategy(STRATEGY_TYPE_TANK);
switch (player->getClass())
{
//case CLASS_DEATH_KNIGHT:
case CLASS_PALADIN:
case CLASS_WARRIOR:
return true;
case CLASS_DRUID:
return HasAnyAuraOf(player, "bear form", "dire bear form", NULL);
}
return false;
}