void Player::SetAutoPilotActive(bool on) { IAI *ai = GetAI(); AutoPilotActive = on; ai->SetActive(on); /*AIAutoPilotStrategy *auto_pilot = ai->GetAutoPilotStrategy(); if (auto_pilot) { auto_pilot->SetActive(on); }*/ }
//---------------------------------------------------------------------------- // // ROUTINE: CAIHumanStrategyShootStream::CalculateStreamTime() // // PURPOSE: Calculate how long we should next fire a stream for. // //---------------------------------------------------------------------------- void CAIHumanStrategyShootStream::CalculateStreamTime() { CWeapon* pWeapon = GetAI()->GetCurrentWeapon(); AIASSERT( pWeapon && pWeapon->GetWeaponData(), m_pAIHuman->GetHOBJECT(), "" ); if ( !pWeapon || ( pWeapon && !pWeapon->GetWeaponData()) ) { return; } m_flStreamTime = g_pLTServer->GetTime() + GetRandom(pWeapon->GetWeaponData()->fAIMinBurstInterval, pWeapon->GetWeaponData()->fAIMaxBurstInterval); }
void PlayerbotDruidAI::_DoNextPVECombatManeuverHeal(Unit* /*pTarget*/) { PlayerbotAI* ai = GetAI(); if (!ai) return; uint32 masterHP = GetMaster()->GetHealth() * 100 / GetMaster()->GetMaxHealth(); Player *m_bot = GetPlayerBot(); 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; }
void CAIHumanStateLaunch::Update() { super::Update(); switch( m_eStateStatus ) { case kSStat_Initialized: { // Setup the AI Movement to launch AI. GetAI()->GetAIMovement()->SetMovementDest( m_vLaunchDest ); GetAI()->GetAIMovement()->FaceDest( LTTRUE ); GetAI()->GetAIMovement()->SetSpeed( m_fLaunchSpeed ); GetAI()->GetAIMovement()->SetParabola( m_fLaunchHeight ); GetAI()->GetAIMovement()->IgnoreVolumes( LTTRUE ); m_eStateStatus = kSStat_Moving; } break; case kSStat_Moving: if( GetAI()->GetAIMovement()->IsDone() ) { m_eStateStatus = kSStat_StateComplete; } break; } }
LTBOOL CAIPoodleStrategyFollowPath::UpdateMoveTo(CAIPathWaypoint* pWaypoint) { if ( m_AIMovement.IsSet() ) { if ( !m_AIMovement.Update() ) { return LTFALSE; } if ( m_AIMovement.IsDone() ) { m_pPath->IncrementWaypointIndex(); } } else if ( m_AIMovement.IsUnset() || m_AIMovement.IsDone() ) { if ( !GetAI()->FacePos(pWaypoint->GetArgumentVector1()) ) { // If we're not yet facing the point, don't move, and start to face it. // We need to clear in order to disable the steerings. GetAI()->Stop(); } else { // We're facing the point, so we can start moving. SetMovement(m_eMovement); m_AIMovement.Set(pWaypoint->GetArgumentVector1()); } } else // Stuck { } GetAnimator()->SetMain(m_eMovement); return LTTRUE; }
//---------------------------------------------------------------------------- // // ROUTINE: CAIHumanStrategyShootStream::UpdateAiming() // // PURPOSE: // //---------------------------------------------------------------------------- /*virtual*/ void CAIHumanStrategyShootStream::UpdateAiming(HOBJECT hTarget) { if ( m_flStreamTime < g_pLTServer->GetTime() ) { // Don't calculate new stream time until finished firing animation. if( !GetAnimationContext()->IsLocked() ) { CalculateStreamTime(); } Aim(); } else { // We're done waiting, fire if we're at a reasonable angle if ( m_bIgnoreFOV ) { Fire(); } else { LTVector vTargetPos; g_pLTServer->GetObjectPos(hTarget, &vTargetPos); LTVector vDir = vTargetPos - GetAI()->GetPosition(); vDir.y = 0.0f; vDir.Normalize(); if ( vDir.Dot(GetAI()->GetTorsoForward()) < 0.70f ) { Aim(); } else { Fire(); } } } }
LTBOOL CAIHelicopterStrategyShoot::Update() { if ( !CAIHelicopterStrategy::Update() ) { return LTFALSE; } if ( !m_hTarget ) { return LTFALSE; } for ( int iWeapon = 0 ; iWeapon < GetAI()->GetNumWeapons() ; iWeapon++ ) { CWeapon* pWeapon = GetAI()->GetWeapon(iWeapon); if ( m_aBursts[iWeapon].m_bFired && m_aBursts[iWeapon].m_bActive ) { UpdateFiring(pWeapon, &m_aBursts[iWeapon]); m_aBursts[iWeapon].m_bFired = LTFALSE; } else { UpdateAiming(pWeapon, &m_aBursts[iWeapon]); } if ( 0 == pWeapon->GetAmmoInClip() ) { pWeapon->ReloadClip(LTFALSE); } if ( 0 == pWeapon->GetParent()->GetAmmoCount(pWeapon->GetAmmoId()) ) { pWeapon->GetParent()->AddAmmo(pWeapon->GetAmmoId(), 999999); } } return LTTRUE; }
void PlayerbotDruidAI::DoNextCombatManeuver(Unit *pTarget) { PlayerbotAI* ai = GetAI(); if (!ai) return; switch (ai->GetScenarioType()) { case PlayerbotAI::SCENARIO_DUEL: ai->CastSpell(MOONFIRE); return; default: break; } uint32 masterHP = GetMaster()->GetHealth() * 100 / GetMaster()->GetMaxHealth(); Player *m_bot = GetPlayerBot(); Unit* pVictim = pTarget->getVictim(); if (ai->GetCombatOrder() == PlayerbotAI::ORDERS_HEAL) // && ai->GetMovementOrder() == PlayerbotAI::MOVEMENT_STAY) SpellSequence = DruidHeal; else if (IsFeral() && ai->GetCombatOrder() == PlayerbotAI::ORDERS_ASSIST) // && ai->GetMovementOrder() == PlayerbotAI::MOVEMENT_STAY) SpellSequence = DruidCombat; else if (IsFeral() && ai->GetCombatOrder() == PlayerbotAI::ORDERS_TANK) SpellSequence = DruidTank; else SpellSequence = DruidSpell; switch (SpellSequence) { case DruidTank: // Its now a tank druid! //ai->TellMaster("DruidTank"); _DoNextPVECombatManeuverBear(pTarget); break; case DruidSpell: //ai->TellMaster("DruidSpell"); _DoNextPVECombatManeuverSpellDPS(pTarget); break; case DruidHeal: //ai->TellMaster("DruidHeal"); _DoNextPVECombatManeuverHeal(pTarget); break; case DruidCombat: //ai->TellMaster("DruidCombat"); _DoNextPVECombatManeuverMeleeDPS(pTarget); break; } } // end DoNextCombatManeuver
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; }
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; }
void PlayerbotWarriorAI::DoNonCombatActions() { Player * m_bot = GetPlayerBot(); if (!m_bot) return; // TODO (by Runsttren): check if shout aura bot has is casted by this bot, // otherwise cast other useful shout // If the bot is protect talented, she/he needs stamina not attack power. // With stance change can the shout change to. // Inserted line to battle shout m_bot->HasAura( COMMANDING_SHOUT, 0 ) // Natsukawa if( ( (COMMANDING_SHOUT>0 && !m_bot->HasAura( COMMANDING_SHOUT, 0 )) || (BATTLE_SHOUT>0 && !m_bot->HasAura( BATTLE_SHOUT, 0 )) ) && GetAI()->GetRageAmount()<10 && BLOODRAGE>0 && !m_bot->HasAura( BLOODRAGE, 0 ) ) { // we do have a useful shout, no rage coming but can cast bloodrage... do it GetAI()->CastSpell( BLOODRAGE, *m_bot ); } else if( COMMANDING_SHOUT>0 && !m_bot->HasAura( COMMANDING_SHOUT, 0 ) ) { // use commanding shout now GetAI()->CastSpell( COMMANDING_SHOUT, *m_bot ); } else if( BATTLE_SHOUT>0 && !m_bot->HasAura( BATTLE_SHOUT, 0 ) && !m_bot->HasAura( COMMANDING_SHOUT, 0 ) ) { // use battle shout GetAI()->CastSpell( BATTLE_SHOUT, *m_bot ); } // hp check if (m_bot->getStandState() != UNIT_STAND_STATE_STAND) m_bot->SetStandState(UNIT_STAND_STATE_STAND); Item* pItem = GetAI()->FindFood(); if (pItem != NULL && GetAI()->GetHealthPercent() < 30) { GetAI()->TellMaster("I could use some food."); GetAI()->UseItem(*pItem); GetAI()->SetIgnoreUpdateTime(30); return; } } // end DoNonCombatActions
void PlayerbotRogueAI::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 Up if (ChangeWeaponEnchants()) { return; } } //end DoNonCombatActions
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
void PlayerbotDruidAI::DoNextCombatManeuver(Unit *pTarget) { PlayerbotAI* ai = GetAI(); if (!ai) return; switch (ai->GetScenarioType()) { case PlayerbotAI::SCENARIO_DUEL: ai->CastSpell(MOONFIRE); return; } uint32 masterHP = GetMaster()->GetHealth() * 100 / GetMaster()->GetMaxHealth(); Player *m_bot = GetPlayerBot(); Unit* pVictim = pTarget->getVictim(); if (ai->GetCombatOrder() == PlayerbotAI::ORDERS_HEAL) SpellSequence = DruidHeal; else if (ai->GetCombatOrder() == PlayerbotAI::ORDERS_ASSIST && CAT_FORM > 0) SpellSequence = DruidCombat; // No check for Dire Bear here: you must have Bear form to learn Dire Bear form. else if (ai->GetCombatOrder() == PlayerbotAI::ORDERS_TANK && BEAR_FORM > 0) SpellSequence = DruidTank; else SpellSequence = DruidSpell; switch (SpellSequence) { case DruidTank: // Its now a tank druid! //ai->TellMaster("DruidTank"); _DoNextPVECombatManeuverBear(pTarget); break; case DruidSpell: //ai->TellMaster("DruidSpell"); _DoNextPVECombatManeuverSpellDPS(pTarget); break; case DruidHeal: //ai->TellMaster("DruidHeal"); _DoNextPVECombatManeuverHeal(pTarget); break; case DruidCombat: //ai->TellMaster("DruidCombat"); _DoNextPVECombatManeuverMeleeDPS(pTarget); break; } } // end DoNextCombatManeuver
//---------------------------------------------------------------------------- // // ROUTINE: CAIHumanStateCatch::Init() // // PURPOSE: Handles initialization of the CAIHumanStateCatch class, // Retreive initialization information from the AI, and change // the AI state to reflect entry to this state // //---------------------------------------------------------------------------- LTBOOL CAIHumanStateCatch::Init(CAIHuman* pAIHuman) { LTBOOL bParentInitializationSuccess = CAIHumanState::Init(pAIHuman); UBER_ASSERT( bParentInitializationSuccess, "CAIHumanStateCatch::Init Failed parent class initialization" ); // Retrieve the max hold time from the bute file, failing if it is not // defined for this AI m_fMaxCatchDuration = pAIHuman->GetBrain()->GetAIData(kAIData_MaxCatchDuration); // Be sure that we retrieved a MaxCatch value.. UBER_ASSERT( m_fMaxCatchDuration > 0.0000001, "SetupCatch: MaxCatchDuration not set" ); // Set the incoming position to a position 48 units in front of the AI. m_vIncomingPosition = GetAI()->GetPosition() + GetAI()->GetEyeForward() * 48; // Ensure that node tracking is disabled. m_pAIHuman->DisableNodeTracking(); // Set the Catching AI to an alert state/combat type m_pAIHuman->SetAwareness( kAware_Alert ); return LTTRUE; }
void PlayerbotShamanAI::HealTarget(Unit &target, uint8 hp) { PlayerbotAI* ai = GetAI(); if (hp < 30 && HEALING_WAVE > 0 && ai->GetManaPercent() >= 32) ai->CastSpell(HEALING_WAVE, target); else if (hp < 45 && LESSER_HEALING_WAVE > 0 && ai->GetManaPercent() >= 19) ai->CastSpell(LESSER_HEALING_WAVE, target); else if (hp < 55 && RIPTIDE > 0 && !target.HasAura(RIPTIDE, EFFECT_INDEX_0) && ai->GetManaPercent() >= 21) ai->CastSpell(RIPTIDE, target); else if (hp < 70 && CHAIN_HEAL > 0 && ai->GetManaPercent() >= 24) ai->CastSpell(CHAIN_HEAL, target); // end HealTarget }
bool PlayerbotShamanAI::ChangeTotems(uint32 mode) { uint32 earth=0, fire=0, water=0, air=0; PlayerbotAI *ai = GetAI(); if(!ai) return false; Player *m_bot = GetPlayerBot(); if(!m_bot || m_bot->isDead()) return false; Unit *pTarget = m_bot->GetSelectedUnit(); Unit *pVictim = NULL; if (m_bot->GetSelectedUnit()->IsFriendlyTo(m_bot)) pTarget = NULL; if (pTarget) pVictim = pTarget->getVictim(); //Defaults if (!HasAuraName(m_bot,"Horn of Winter") )earth = STRENGTH_OF_EARTH_TOTEM; if (!earth) earth = STONESKIN_TOTEM; if (!earth) earth = EARTHBIND_TOTEM; fire = TOTEM_OF_WRATH; if (!fire) fire = FLAMETONGUE_TOTEM; if (!fire) fire = SEARING_TOTEM; water = MANA_SPRING_TOTEM; if (!water) water = HEALING_STREAM_TOTEM; if (TALENT_ELEMENTAL || TALENT_RESTO) air = WRATH_OF_AIR_TOTEM; else air = WINDFURY_TOTEM; //Target reactive stuff if (pTarget) { if (GROUNDING_TOTEM && pTarget->IsNonMeleeSpellCasted(true)) air = GROUNDING_TOTEM; } if (STONESKIN_TOTEM && isUnderAttack()) earth = STONESKIN_TOTEM; uint32 totz[4] = {earth, fire, water, air}; for (int i = 0; i < 4; i++) { if (!totz[i]) continue; SpellEntry const *tSpell = GetSpellStore()->LookupEntry(totz[i]); if (!tSpell) continue; uint32 tEntry = (uint32) tSpell->EffectMiscValue[0]; if (!tEntry) continue; CreatureTemplate const *totemEntry = sObjectMgr->GetCreatureTemplate(tEntry); if (!tEntry) continue; if (CanCast(totz[i], m_bot) && !m_bot->FindNearestCreature(tEntry,30)) { return CastSpell(totz[i],m_bot,false); } } return false; }
LTBOOL CAIHelicopterStateAttack::HandleCommand(char** pTokens, int nArgs) { _ASSERT(pTokens && (nArgs >= 1)); if (!pTokens || nArgs < 1) return LTFALSE; if ( CAIHelicopterState::HandleCommand(pTokens, nArgs) ) { return LTTRUE; } if ( !_stricmp(pTokens[0], "ON") ) { for ( int iWeapon = 0 ; iWeapon < GetAI()->GetNumWeapons() ; iWeapon++ ) { if ( !_stricmp(pTokens[1], GetAI()->GetWeaponPosition(iWeapon)->GetName()) ) { m_pStrategyShoot->ActivateWeapon(iWeapon); } } return LTTRUE; } else if ( !_stricmp(pTokens[0], "OFF") ) { for ( int iWeapon = 0 ; iWeapon < GetAI()->GetNumWeapons() ; iWeapon++ ) { if ( !_stricmp(pTokens[1], GetAI()->GetWeaponPosition(iWeapon)->GetName()) ) { m_pStrategyShoot->DeactivateWeapon(iWeapon); } } return LTTRUE; } return LTFALSE; }
void PlayerbotWarriorAI::DoNonCombatActions() { PlayerbotAI *ai = GetAI(); Player * m_bot = GetPlayerBot(); if (!m_bot) return; // TODO (by Runsttren): check if shout aura bot has is casted by this bot, // otherwise cast other useful shout // If the bot is protect talented, she/he needs stamina not attack power. // With stance change can the shout change to. // Inserted line to battle shout m_bot->HasAura( COMMANDING_SHOUT, EFFECT_INDEX_0) // Natsukawa if (((COMMANDING_SHOUT > 0 && !m_bot->HasAura(COMMANDING_SHOUT, EFFECT_INDEX_0)) || (BATTLE_SHOUT > 0 && !m_bot->HasAura(BATTLE_SHOUT, EFFECT_INDEX_0))) && ai->GetRageAmount() < 10 && BLOODRAGE > 0 && !m_bot->HasAura(BLOODRAGE, EFFECT_INDEX_0)) // we do have a useful shout, no rage coming but can cast bloodrage... do it ai->CastSpell(BLOODRAGE, *m_bot); else if (COMMANDING_SHOUT > 0 && !m_bot->HasAura(COMMANDING_SHOUT, EFFECT_INDEX_0)) // use commanding shout now ai->CastSpell(COMMANDING_SHOUT, *m_bot); else if (BATTLE_SHOUT > 0 && !m_bot->HasAura(BATTLE_SHOUT, EFFECT_INDEX_0) && !m_bot->HasAura(COMMANDING_SHOUT, EFFECT_INDEX_0)) // use battle shout ai->CastSpell(BATTLE_SHOUT, *m_bot); // buff master with VIGILANCE if (VIGILANCE > 0) (!GetMaster()->HasAura(VIGILANCE, EFFECT_INDEX_0) && ai->CastSpell(VIGILANCE, *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
bool PlayerbotWarriorAI::DoProtectSelfAction() { PlayerbotAI *ai = GetAI(); Player *m_bot = GetPlayerBot(); if (m_bot->GetHealthPercent() < 40 && ai->Cast(SHIELD_WALL, m_bot)) return true; if (m_bot->GetHealthPercent() < 60 && ai->Cast(ENRAGED_REGENERATION, m_bot)) return true; if (ai->Cast(SPELL_REFLECTION, m_bot)) return true; return false; }
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; }
void PlayerbotPaladinAI::HealTarget(Unit &target, uint8 hp) { PlayerbotAI* ai = GetAI(); if (hp < 40 && HOLY_LIGHT > 0 && ai->GetManaPercent() >= 34) ai->CastSpell(HOLY_LIGHT, target); if (hp < 35 && HOLY_SHOCK > 0 && ai->GetManaPercent() >= 21) ai->CastSpell(HOLY_SHOCK, target); if (hp < 30 && FLASH_OF_LIGHT > 0 && ai->GetManaPercent() >= 8) ai->CastSpell(FLASH_OF_LIGHT, target); if (hp < 25 && LAY_ON_HANDS > 0 && ai->GetHealthPercent() > 30 && ai->GetManaPercent() >= 8) ai->CastSpell(LAY_ON_HANDS, target); } // end HealTarget
void CAIHelicopterStateAttack::Update() { CAIHelicopterState::Update(); if ( !m_hTarget ) { GetAI()->ChangeState("IDLE"); return; } m_pStrategyShoot->SetTarget(m_hTarget); if ( !m_pStrategyShoot->Update() ) { } }
//---------------------------------------------------------------------------- // // ROUTINE: CAIHumanStateObstruct::IsAICloseEnoughToNode() // // PURPOSE: Returns true if the AI is within the prespecified range, false // if the player is not. // //---------------------------------------------------------------------------- bool CAIHumanStateObstruct::IsAICloseEnoughToNode(void) { if ( !m_hNodeToDoObstructAt ) return false; LTVector vNodePos, vAIPos; g_pLTServer->GetObjectPos(m_hNodeToDoObstructAt, &vNodePos); g_pLTServer->GetObjectPos(GetAI()->m_hObject, &vAIPos); float ActualDistance = VEC_DISTSQR(vAIPos, vNodePos); // If the distance we must attain is less than the current distance.. if ( ActualDistance < m_fCloseEnoughDistSqr ) return true; return false; }
void PlayerbotRogueAI::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 Up if (ChangeWeaponEnchants()) { return; } //mana/hp check if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) { return; } if (ai->GetHealthPercent() < 50) { ai->Feast(); } } //end DoNonCombatActions
LTBOOL CAISenseHearAllyPain::Update(HOBJECT hStimulus, LTFLOAT fTimeDelta) { if ( !IsCharacter(hStimulus) ) return LTFALSE; // Don't react to our own pain if ( hStimulus == GetAI()->GetObject() ) return LTFALSE; // See if we can hear the pain CCharacter* pChar = (CCharacter*)g_pLTServer->HandleToObject(hStimulus); // Time has got to be greater than the pain noise time but not too much greater LTFLOAT fTime = g_pLTServer->GetTime(); if ( (fTime > pChar->GetLastPainTime()) && (fTime < pChar->GetLastPainTime() + 1.0f) ) { // Noise has to be within audible radius LTVector vPainPos; g_pLTServer->GetObjectPos(hStimulus, &vPainPos); LTFLOAT fDistance = VEC_DIST(vPainPos, m_pAI->GetPosition()); LTFLOAT fPainNoiseDistance = g_pAIButeMgr->GetSenses()->fAllyPainNoiseDistance; fPainNoiseDistance *= pChar->GetLastPainVolume(); if ( fDistance < (m_fDistance + fPainNoiseDistance) ) { React(); // Record the Timestamp m_fTimestamp = pChar->GetLastPainTime(); // Record the stimulus position m_vStimulusPosition = vPainPos; return LTTRUE; } } return LTFALSE; }
bool PlayerbotWarriorAI::DoFirstCombatManeuver(Unit *pTarget) { Player *m_bot = GetPlayerBot(); PlayerbotAI *ai = GetAI(); PlayerbotAI::CombatOrderType co = ai->GetCombatOrder(); float fTargetDist = m_bot->GetCombatDistance(pTarget); if ((co & PlayerbotAI::ORDERS_TANK) && DEFENSIVE_STANCE > 0 && !m_bot->HasAura(DEFENSIVE_STANCE, EFFECT_INDEX_0) && ai->CastSpell(DEFENSIVE_STANCE)) { if (ai->GetManager()->m_confDebugWhisper) ai->TellMaster("First > Defensive Stance (%d)", DEFENSIVE_STANCE); return true; } else if ((co & PlayerbotAI::ORDERS_TANK) && TAUNT > 0 && m_bot->HasAura(DEFENSIVE_STANCE, EFFECT_INDEX_0) && ai->CastSpell(TAUNT, *pTarget)) { if (ai->GetManager()->m_confDebugWhisper) ai->TellMaster("First > Taunt (%d)", TAUNT); return false; } else if (BATTLE_STANCE > 0 && !m_bot->HasAura(BATTLE_STANCE, EFFECT_INDEX_0) && ai->CastSpell(BATTLE_STANCE)) { if (ai->GetManager()->m_confDebugWhisper) ai->TellMaster("First > Battle Stance (%d)", BATTLE_STANCE); return true; } else if (BATTLE_STANCE > 0 && CHARGE > 0 && m_bot->HasAura(BATTLE_STANCE, EFFECT_INDEX_0)) { if (fTargetDist < 8.0f) return false; else if (fTargetDist > 25.0f) return true; else if (CHARGE > 0 && ai->CastSpell(CHARGE, *pTarget)) { float x, y, z; pTarget->GetContactPoint(m_bot, x, y, z, 3.666666f); m_bot->Relocate(x, y, z); if (ai->GetManager()->m_confDebugWhisper) ai->TellMaster("First > Charge (%d)", CHARGE); return false; } } return false; }
void PlayerbotPriestAI::HealTarget(Unit &target, uint8 hp) { PlayerbotAI* ai = GetAI(); // return ((hp < 80 && !target.HasAura(RENEW, EFFECT_INDEX_0) && ai->CastSpell(RENEW, target)) || // (hp < 60 && ai->CastSpell(HEAL, target)) || // (hp < 30 && ai->CastSpell(FLASH_HEAL, target)) ); if (hp < 25 && FLASH_HEAL > 0 && ai->GetManaPercent() >= 20) { ai->TellMaster("I'm casting flash heal."); ai->CastSpell(FLASH_HEAL, target); } else if (hp < 30 && GREAT_HEAL > 0 && ai->GetManaPercent() >= 36) { ai->TellMaster("I'm casting one of the sorted heal spells."); ai->CastSpell(GREAT_HEAL, target); } else if (hp < 33 && BINDING_HEAL > 0 && ai->GetManaPercent() >= 27) { ai->TellMaster("I'm casting binding heal."); ai->CastSpell(BINDING_HEAL, target); } else if (hp < 40 && PRAYER_OF_HEALING > 0 && ai->GetManaPercent() >= 54) { ai->TellMaster("I'm casting prayer of healing."); ai->CastSpell(PRAYER_OF_HEALING, target); } else if (hp < 50 && CIRCLE_OF_HEALING > 0 && ai->GetManaPercent() >= 24) { ai->TellMaster("I'm casting circle of healing."); ai->CastSpell(CIRCLE_OF_HEALING, target); } else if (hp < 60 && HEAL > 0 && ai->GetManaPercent() >= 36) { ai->TellMaster("I'm casting one of the sorted heal spells."); ai->CastSpell(HEAL, target); } else if (hp < 80 && RENEW > 0 && ai->GetManaPercent() >= 19) { //ai->TellMaster("I'm casting renew."); ai->CastSpell(RENEW, target); } } // end HealTarget
bool PlayerbotDruidAI::CureTarget(Unit *target) { PlayerbotAI *ai = GetAI(); Player *m_bot = GetPlayerBot(); if (!m_bot || !ai || m_bot->isDead()) { return false; } if (!target || target->isDead()) { return false; } // Decide if it is worth to change form (they cange forms even if theres nothing to cure..) if (ai->GetForm() == FORM_CAT || ai->GetForm() == FORM_DIREBEAR || ai->GetForm() == FORM_BEAR) { //if(GetAI()->GetManaPercent() >= 80 ) { ChangeForm(1); } //else { return false; } return false; } if (castDispel(CURE_POISON, target)) { return true; } // if(HasAuraName(target, "Venom Spit") || HasAuraName(target, "Poison")) return CastSpell(CURE_POISON, target); return false; } //end HealTarget
bool PlayerbotPaladinAI::HealTarget(Unit *target) { PlayerbotAI* ai = GetAI(); uint8 hp = target->GetHealth() * 100 / target->GetMaxHealth(); if (hp < 25 && ai->CastSpell(LAY_ON_HANDS, *target)) return true; if (hp < 30 && ai->CastSpell(FLASH_OF_LIGHT, *target)) return true; if (hp < 35 && ai->CastSpell(HOLY_SHOCK, *target)) return true; if (hp < 40 && ai->CastSpell(HOLY_LIGHT, *target)) return true; return false; } // end HealTarget