void PlayerbotHunterAI::DoNonCombatActions() { PlayerbotAI *ai = GetAI(); if (!ai) return; Player * m_bot = GetPlayerBot(); if (!m_bot) return; // reset ranged combat state if (!m_rangedCombat) m_rangedCombat = true; // buff group if (TRUESHOT_AURA > 0) (!m_bot->HasAura(TRUESHOT_AURA, EFFECT_INDEX_0) && ai->CastSpell (TRUESHOT_AURA, *m_bot)); // buff myself if (ASPECT_OF_THE_HAWK > 0) (!m_bot->HasAura(ASPECT_OF_THE_HAWK, EFFECT_INDEX_0) && ai->CastSpell (ASPECT_OF_THE_HAWK, *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->TellMaster("I could use a drink."); 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->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; } // 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)) ai->TellMaster("summoning pet."); else { m_petSummonFailed = true; ai->TellMaster("summon pet failed!"); } } else if (pet->getDeathState() != ALIVE) { // revive pet if (PET_REVIVE > 0 && ai->GetManaPercent() >= 80 && ai->CastSpell(PET_REVIVE, *m_bot)) ai->TellMaster("reviving pet."); } 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)) ai->TellMaster("healing pet."); } 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 { // DEBUG_LOG ("[PlayerbotHunterAI]: DoNonCombatActions - Food for pet: %s",pItemProto->Name1); 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->TellMaster("feeding 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; if (pet->HaveInDiet(pItemProto)) // is pItem in pets diet { // DEBUG_LOG ("[PlayerbotHunterAI]: DoNonCombatActions - Food for pet: %s",pItemProto->Name1); 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->TellMaster("feeding pet."); ai->SetIgnoreUpdateTime(10); return; } } } } if (pet->HasAura(PET_MEND, EFFECT_INDEX_0) && !pet->HasAura(PET_FEED, EFFECT_INDEX_0)) ai->TellMaster("..no pet food!"); ai->SetIgnoreUpdateTime(7); } } } // end DoNonCombatActions
void PlayerbotHunterAI::DoNonCombatActions() { if (!m_ai) return; if (!m_bot) return; if (!m_rangedCombat || m_ai->GetCombatStyle() == PlayerbotAI::COMBAT_MELEE) { m_rangedCombat = true; m_ai->SetCombatStyle(PlayerbotAI::COMBAT_RANGED); } // buff group if (TRUESHOT_AURA > 0 && !m_bot->HasAura(TRUESHOT_AURA, EFFECT_INDEX_0)) m_ai->CastSpell(TRUESHOT_AURA, *m_bot); // buff myself if (ASPECT_OF_THE_HAWK > 0 && !m_bot->HasAura(ASPECT_OF_THE_HAWK, EFFECT_INDEX_0)) m_ai->CastSpell(ASPECT_OF_THE_HAWK, *m_bot); //create water if (m_ai->FindDrink() == nullptr && m_bot->getLevel() == 60) { if (Item* pItem = m_bot->StoreNewItemInInventorySlot(CRYSTAL_WATER, 20)) m_bot->SendNewItem(pItem, 20, true, false); return; } // hp/mana check if (EatDrinkBandage()) return; // 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 && m_ai->CastSpell(PET_SUMMON, *m_bot)) m_ai->TellMaster("summoning pet."); else { m_petSummonFailed = true; m_ai->TellMaster("summon pet failed!"); } } else if (!(pet->isAlive())) { if (PET_REVIVE > 0 && m_ai->CastSpell(PET_REVIVE, *m_bot)) m_ai->TellMaster("reviving pet."); } else if (pet->GetHealthPercent() < 50) { if (PET_MEND > 0 && pet->isAlive() && !pet->HasAura(PET_MEND, EFFECT_INDEX_0) && m_ai->CastSpell(PET_MEND, *m_bot)) m_ai->TellMaster("healing pet."); } 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 { // DEBUG_LOG ("[PlayerbotHunterAI]: DoNonCombatActions - Food for pet: %s",pItemProto->Name1); caster->CastSpell(caster, 23355, 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, nullptr, nullptr, true); // feed pet m_ai->TellMaster("feeding pet."); m_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; if (pet->HaveInDiet(pItemProto)) // is pItem in pets diet { // DEBUG_LOG ("[PlayerbotHunterAI]: DoNonCombatActions - Food for pet: %s",pItemProto->Name1); caster->CastSpell(caster, 23355, 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, nullptr, nullptr, true); // feed pet m_ai->TellMaster("feeding pet."); m_ai->SetIgnoreUpdateTime(10); return; } } } } if (pet->HasAura(PET_MEND, EFFECT_INDEX_0) && !pet->HasAura(PET_FEED, EFFECT_INDEX_0)) m_ai->TellMaster("..no pet food!"); m_ai->SetIgnoreUpdateTime(7); } } } // end 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; 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; } } } } if (pet->HasAura(PET_MEND, EFFECT_INDEX_0) && !pet->HasAura(PET_FEED, EFFECT_INDEX_0)) ai->SetIgnoreUpdateTime(7); } } }
void PlayerbotHunterAI::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_STAT_CASTING)) { return; } if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) { return; } // buff group if (CastSpell(TRUESHOT_AURA, 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 (ai->GetManaPercent() < 20 || ai->GetHealthPercent() < 30) { ai->Feast(); } #pragma region Check Pet // 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) ) ai->TellMaster( "summoning pet." ); else { m_petSummonFailed = true; ai->TellMaster( "summon pet failed!" ); } } else if( pet->getDeathState() != ALIVE ) { // revive pet if( PET_REVIVE>0 && ai->GetManaPercent()>=80 && ai->CastSpell(PET_REVIVE,m_bot) ) ai->TellMaster( "reviving pet." ); } 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,0) && ai->GetManaPercent()>=13 && ai->CastSpell(PET_MEND,m_bot) ) ai->TellMaster( "healing pet." ); } 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 ItemTemplate* const pItemProto = pItem->GetTemplate(); if (!pItemProto ) continue; if(pet->HaveInDiet(pItemProto)) // is pItem in pets diet { //sLog.outDebug("Food for pet: %s",pItemProto->Name1); 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->TellMaster( "feeding 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 ItemTemplate* const pItemProto = pItem->GetTemplate(); if (!pItemProto ) continue; if(pet->HaveInDiet(pItemProto)) // is pItem in pets diet { //sLog.outDebug("Food for pet: %s",pItemProto->Name1); 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->TellMaster( "feeding pet." ); ai->SetIgnoreUpdateTime(10); return; } } } } } if( pet->HasAura(PET_MEND, 0) && !pet->HasAura(PET_FEED, 0)) ai->TellMaster( "..no pet food!" ); ai->SetIgnoreUpdateTime(7); } #pragma endregion } } // end DoNonCombatActions