本文整理匯總了C++中AttackStart函數的典型用法代碼示例。如果您正苦於以下問題:C++ AttackStart函數的具體用法?C++ AttackStart怎麽用?C++ AttackStart使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AttackStart函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: UpdateAllies
void ImpAI::UpdateAI(const uint32 diff)
{
if (!me->isAlive())
return;
m_owner = me->GetCharmerOrOwner();
updateAlliesTimer.Update(diff);
if (updateAlliesTimer.Passed())
UpdateAllies();
if (m_forceTimer)
{
if (m_forceTimer < diff)
m_forceTimer = 0;
else
m_forceTimer -= diff;
}
// me->getVictim() can't be used for check in case stop fighting, me->getVictim() clear at Unit death etc.
if (Unit *target = me->getVictim())
{
if (_needToStop())
{
DEBUG_LOG("Pet AI stoped attacking [guid=%u]", me->GetGUIDLow());
_stopAttack();
return;
}
float dist = me->GetDistance2d(target);
if (dist < 30 && m_chasing)
{
me->clearUnitState(UNIT_STAT_FOLLOW);
me->GetMotionMaster()->MoveIdle();
m_chasing = false;
}
if (dist > 30 && !m_chasing)
{
me->GetMotionMaster()->MoveChase(target);
m_chasing = true;
}
}
else
{
if (me->isInCombat())
{
if (!m_owner|| !m_owner->GetObjectGuid().IsPlayer())
_stopAttack();
}
else if (m_owner && me->GetCharmInfo()) //no victim
{
if (m_owner->isInCombat() && !(me->HasReactState(REACT_PASSIVE) || me->GetCharmInfo()->HasCommandState(COMMAND_STAY)))
AttackStart(m_owner->getAttackerForHelper());
else if (me->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW) && !me->hasUnitState(UNIT_STAT_FOLLOW))
me->GetMotionMaster()->MoveFollow(m_owner,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
}
}
if (!me->GetCharmInfo())
return;
if (!me->hasUnitState(UNIT_STAT_CASTING))
{
//Autocast
for (uint8 i = 0; i < me->GetPetAutoSpellSize(); i++)
PrepareSpellForAutocast(me->GetPetAutoSpellOnPos(i));
AutocastPreparedSpells();
}
}
示例2: UpdateAllies
void PetAI::UpdateAI(const uint32 diff)
{
if (!m_creature->IsAlive())
{ return; }
Unit* owner = m_creature->GetCharmerOrOwner();
if (m_updateAlliesTimer <= diff)
// UpdateAllies self set update timer
{ UpdateAllies(); }
else
{ m_updateAlliesTimer -= diff; }
if (inCombat && (!m_creature->getVictim() || (m_creature->IsPet() && ((Pet*)m_creature)->GetModeFlags() & PET_MODE_DISABLE_ACTIONS)))
{ _stopAttack(); }
// i_pet.getVictim() can't be used for check in case stop fighting, i_pet.getVictim() clear at Unit death etc.
if (m_creature->getVictim())
{
if (_needToStop())
{
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "PetAI (guid = %u) is stopping attack.", m_creature->GetGUIDLow());
_stopAttack();
return;
}
bool meleeReach = m_creature->CanReachWithMeleeAttack(m_creature->getVictim());
if (m_creature->IsStopped() || meleeReach)
{
// required to be stopped cases
if (m_creature->IsStopped() && m_creature->IsNonMeleeSpellCasted(false))
{
if (m_creature->hasUnitState(UNIT_STAT_FOLLOW_MOVE))
{ m_creature->InterruptNonMeleeSpells(false); }
else
{ return; }
}
// not required to be stopped case
else if (DoMeleeAttackIfReady())
{
if (!m_creature->getVictim())
{ return; }
// if pet misses its target, it will also be the first in threat list
m_creature->getVictim()->AddThreat(m_creature);
if (_needToStop())
{ _stopAttack(); }
}
}
}
else if (owner && m_creature->GetCharmInfo())
{
if (owner->IsInCombat() && !(m_creature->GetCharmInfo()->HasReactState(REACT_PASSIVE) || m_creature->GetCharmInfo()->HasCommandState(COMMAND_STAY)))
{
AttackStart(owner->getAttackerForHelper());
}
else if (m_creature->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
{
if (!m_creature->hasUnitState(UNIT_STAT_FOLLOW))
{
m_creature->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
}
}
}
// Autocast (casted only in combat or persistent spells in any state)
if (!m_creature->IsNonMeleeSpellCasted(false))
{
typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;
TargetSpellList targetSpellStore;
for (uint8 i = 0; i < m_creature->GetPetAutoSpellSize(); ++i)
{
uint32 spellID = m_creature->GetPetAutoSpellOnPos(i);
if (!spellID)
{ continue; }
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID);
if (!spellInfo)
{ continue; }
if (m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))
{ continue; }
// ignore some combinations of combat state and combat/noncombat spells
if (!inCombat)
{
// ignore attacking spells, and allow only self/around spells
if (!IsPositiveSpell(spellInfo->Id))
{ continue; }
// non combat spells allowed
// only pet spells have IsNonCombatSpell and not fit this reqs:
// Consume Shadows, Lesser Invisibility, so ignore checks for its
if (!IsNonCombatSpell(spellInfo))
{
// allow only spell without spell cost or with spell cost but not duration limit
int32 duration = GetSpellDuration(spellInfo);
//.........這裏部分代碼省略.........
示例3: UpdateAI
void UpdateAI(const uint32 diff)
{
if (questPhase == 1)
{
if (timer <= diff)
{
me->SetUInt32Value(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_STAND);
me->setFaction(FACTION_HOSTILE);
questPhase = 0;
if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
{
me->AddThreat(pTarget, 5000000.0f);
AttackStart(pTarget);
}
}
else
timer -= diff;
}
if (!UpdateVictim())
return;
// healer
if (spellFlashLight && HealthBelowPct(70))
{
if (timerFlashLight <= diff)
{
DoCast(me, SPELL_FLASH_OF_LIGHT);
timerFlashLight = 3225 + rand()%3225;
}
else
timerFlashLight -= diff;
}
if (spellJustice)
{
if (timerJustice <= diff)
{
DoCast(me, SPELL_SEAL_OF_JUSTICE);
timerJustice = 10000 + rand()%10000;
}
else
timerJustice -= diff;
}
if (spellJudLight)
{
if (timerJudLight <= diff)
{
DoCast(me, SPELL_JUDGEMENT_OF_LIGHT);
timerJudLight = 10000 + rand()%10000;
}
else
timerJudLight -= diff;
}
if (spellCommand)
{
if (timerCommand <= diff)
{
DoCast(me, SPELL_SEAL_OF_COMMAND);
timerCommand = 20000 + rand()%20000;
}
else
timerCommand -= diff;
}
DoMeleeAttackIfReady();
}
示例4: HandleFlightSequence
void HandleFlightSequence()
{
switch (uiFlightCount)
{
case 0:
//me->AttackStop();
me->GetMotionMaster()->Clear(false);
me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
me->StopMoving();
DoScriptText(YELL_TAKEOFF, me);
events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 2000);
break;
case 1:
me->GetMotionMaster()->MovePoint(0, me->GetPositionX()+1, me->GetPositionY(), me->GetPositionZ()+10);
break;
case 2:
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
if (!target)
target = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_PLAYER_GUID) : 0);
if (!target)
{
EnterEvadeMode();
return;
}
Creature* Vapor = me->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
if (Vapor)
{
Vapor->AI()->AttackStart(target);
me->InterruptNonMeleeSpells(false);
DoCast(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
}
events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000);
break;
}
case 3:
{
DespawnSummons(MOB_VAPOR_TRAIL);
//DoCast(me, SPELL_VAPOR_SELECT); need core support
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
if (!target)
target = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_PLAYER_GUID) : 0);
if (!target)
{
EnterEvadeMode();
return;
}
//target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support
Creature* pVapor = me->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
if (pVapor)
{
if (pVapor->AI())
pVapor->AI()->AttackStart(target);
me->InterruptNonMeleeSpells(false);
DoCast(pVapor, SPELL_VAPOR_CHANNEL, false); // core bug
pVapor->CastSpell(pVapor, SPELL_VAPOR_TRIGGER, true);
}
events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000);
break;
}
case 4:
DespawnSummons(MOB_VAPOR_TRAIL);
events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1);
break;
case 5:
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
if (!target)
target = Unit::GetUnit(*me, instance ? instance->GetData64(DATA_PLAYER_GUID) : 0);
if (!target)
{
EnterEvadeMode();
return;
}
breathX = target->GetPositionX();
breathY = target->GetPositionY();
float x, y, z;
target->GetContactPoint(me, x, y, z, 70);
me->GetMotionMaster()->MovePoint(0, x, y, z+10);
break;
}
case 6:
me->SetOrientation(me->GetAngle(breathX, breathY));
me->StopMoving();
//DoTextEmote("takes a deep breath.", NULL);
events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000);
break;
case 7:
{
DoCast(me, SPELL_FOG_BREATH, true);
//.........這裏部分代碼省略.........
示例5: MoveInLineOfSight
void MoveInLineOfSight(Unit* who)
{
if (me->IsWithinDist(who, 50) && !me->isInCombat() && me->IsValidAttackTarget(who))
AttackStart(who);
}
示例6: UpdateAI
void UpdateAI(const uint32 diff)
{
if (SayTimer <= diff)
{
if (Event)
SayTimer = NextStep(++Step);
} else SayTimer -= diff;
if (Attack)
{
Player* pPlayer = Unit::GetPlayer(*me, PlayerGUID);
me->setFaction(14);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
if (pPlayer)
{
Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20);
if (Creepjack)
{
Creepjack->Attack(pPlayer, true);
Creepjack->setFaction(14);
Creepjack->GetMotionMaster()->MoveChase(pPlayer);
Creepjack->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20);
if (Malone)
{
Malone->Attack(pPlayer, true);
Malone->setFaction(14);
Malone->GetMotionMaster()->MoveChase(pPlayer);
Malone->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
DoStartMovement(pPlayer);
AttackStart(pPlayer);
}
Attack = false;
}
if (HealthBelowPct(5) && !Done)
{
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
me->RemoveAllAuras();
Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20);
if (Creepjack)
{
CAST_CRE(Creepjack)->AI()->EnterEvadeMode();
Creepjack->setFaction(1194);
Creepjack->GetMotionMaster()->MoveTargetedHome();
Creepjack->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20);
if (Malone)
{
CAST_CRE(Malone)->AI()->EnterEvadeMode();
Malone->setFaction(1194);
Malone->GetMotionMaster()->MoveTargetedHome();
Malone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
me->setFaction(1194);
Done = true;
DoScriptText(SAY_GIVEUP, me, NULL);
me->DeleteThreatList();
me->CombatStop();
me->GetMotionMaster()->MoveTargetedHome();
Player* pPlayer = Unit::GetPlayer(*me, PlayerGUID);
if (pPlayer)
CAST_PLR(pPlayer)->GroupEventHappens(QUEST_WBI, me);
}
DoMeleeAttackIfReady();
}
示例7: MoveInLineOfSight
void MoveInLineOfSight(Unit *who) {
if (me->IsWithinDist(who, 50) && !me->isInCombat()
&& me->IsHostileTo(who))
AttackStart(who);
}
示例8: UpdateAI
void UpdateAI(const uint32 diff)
{
if (Intro && !Done)
{
if (AggroTimer <= diff)
{
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
DoScriptText(SAY_AGGRO, me);
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE);
Done = true;
if (AggroTargetGUID)
{
Unit* pUnit = Unit::GetUnit((*me), AggroTargetGUID);
if (pUnit)
AttackStart(pUnit);
DoZoneInCombat();
}
else
{
EnterEvadeMode();
return;
}
} else AggroTimer -= diff;
}
if (!UpdateVictim() || !Done)
return;
if (SummonShadowsTimer <= diff)
{
//MindControlGhost();
for (uint8 i = 0; i < 2; ++i)
{
Creature* Shadow = NULL;
float X = CalculateRandomLocation(me->GetPositionX(), 10);
Shadow = me->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 0);
if (Shadow)
{
Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
if (!pTarget)
pTarget = me->getVictim();
if (pTarget)
Shadow->AI()->AttackStart(pTarget);
}
}
SummonShadowsTimer = 60000;
} else SummonShadowsTimer -= diff;
if (SummonDoomBlossomTimer <= diff)
{
if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
{
float X = CalculateRandomLocation(pTarget->GetPositionX(), 20);
float Y = CalculateRandomLocation(pTarget->GetPositionY(), 20);
float Z = pTarget->GetPositionZ();
Z = me->GetMap()->GetVmapHeight(X, Y, Z);
Creature* DoomBlossom = me->SummonCreature(CREATURE_DOOM_BLOSSOM, X, Y, Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 20000);
if (DoomBlossom)
{
DoomBlossom->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
DoomBlossom->setFaction(me->getFaction());
DoomBlossom->AddThreat(pTarget, 1.0f);
CAST_AI(mob_doom_blossomAI, DoomBlossom->AI())->SetTeronGUID(me->GetGUID());
pTarget->CombatStart(DoomBlossom);
SetThreatList(DoomBlossom);
SummonDoomBlossomTimer = 35000;
}
}
} else SummonDoomBlossomTimer -= diff;
if (IncinerateTimer <= diff)
{
Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
if (!pTarget)
pTarget = me->getVictim();
if (pTarget)
{
DoScriptText(RAND(SAY_SPECIAL1,SAY_SPECIAL2), me);
DoCast(pTarget, SPELL_INCINERATE);
IncinerateTimer = 20000 + rand()%31 * 1000;
}
} else IncinerateTimer -= diff;
if (CrushingShadowsTimer <= diff)
{
Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
if (pTarget && pTarget->isAlive())
DoCast(pTarget, SPELL_CRUSHING_SHADOWS);
CrushingShadowsTimer = 10000 + rand()%16 * 1000;
} else CrushingShadowsTimer -= diff;
/*** NOTE FOR FUTURE DEV: UNCOMMENT BELOW ONLY IF MIND CONTROL IS FULLY IMPLEMENTED **/
/*if (ShadowOfDeathTimer <= diff)
{
Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
//.........這裏部分代碼省略.........
示例9: UpdateAI
void UpdateAI(const uint32 diff)
{
//Speech
if (DoingSpeech)
{
if (SpeechTimer <= diff)
{
switch (SpeechNum)
{
case 0:
//16 seconds till next line
DoScriptText(SAY_LINE2, me);
SpeechTimer = 16000;
++SpeechNum;
break;
case 1:
//This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!"
DoScriptText(SAY_LINE3, me);
SpeechTimer = 10000;
++SpeechNum;
break;
case 2:
me->setFaction(103);
if (PlayerGUID && Unit::GetUnit(*me, PlayerGUID))
{
AttackStart(Unit::GetUnit(*me, PlayerGUID));
DoCast(me, SPELL_ESSENCEOFTHERED);
}
SpeechTimer = 0;
DoingSpeech = false;
break;
}
} else SpeechTimer -= diff;
}
//Return since we have no target
if (!UpdateVictim())
return;
// Yell if hp lower than 15%
if (HealthBelowPct(15) && !HasYelled)
{
DoScriptText(SAY_HALFLIFE, me);
HasYelled = true;
}
//Cleave_Timer
if (Cleave_Timer <= diff)
{
DoCast(me->getVictim(), SPELL_CLEAVE);
Cleave_Timer = 15000;
} else Cleave_Timer -= diff;
//FlameBreath_Timer
if (FlameBreath_Timer <= diff)
{
DoCast(me->getVictim(), SPELL_FLAMEBREATH);
FlameBreath_Timer = urand(4000, 8000);
} else FlameBreath_Timer -= diff;
//BurningAdrenalineCaster_Timer
if (BurningAdrenalineCaster_Timer <= diff)
{
Unit* target = NULL;
uint8 i = 0;
while (i < 3) // max 3 tries to get a random target with power_mana
{
++i;
target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); //not aggro leader
if (target && target->getPowerType() == POWER_MANA)
i = 3;
}
if (target) // cast on self (see below)
target->CastSpell(target, SPELL_BURNINGADRENALINE, 1);
BurningAdrenalineCaster_Timer = 15000;
} else BurningAdrenalineCaster_Timer -= diff;
//BurningAdrenalineTank_Timer
if (BurningAdrenalineTank_Timer <= diff)
{
// have the victim cast the spell on himself otherwise the third effect aura will be applied
// to Vael instead of the player
me->getVictim()->CastSpell(me->getVictim(), SPELL_BURNINGADRENALINE, 1);
BurningAdrenalineTank_Timer = 45000;
} else BurningAdrenalineTank_Timer -= diff;
//FireNova_Timer
if (FireNova_Timer <= diff)
{
DoCast(me->getVictim(), SPELL_FIRENOVA);
FireNova_Timer = 5000;
} else FireNova_Timer -= diff;
//TailSwipe_Timer
if (TailSwipe_Timer <= diff)
{
//Only cast if we are behind
//.........這裏部分代碼省略.........
示例10: UpdateAllies
void PetAI::UpdateAI(const uint32 diff) {
if (!me->isAlive())
return;
Unit* owner = me->GetCharmerOrOwner();
if (m_updateAlliesTimer <= diff)
// UpdateAllies self set update timer
UpdateAllies();
else
m_updateAlliesTimer -= diff;
// me->getVictim() can't be used for check in case stop fighting, me->getVictim() clear at Unit death etc.
if (me->getVictim()) {
if (_needToStop()) {
sLog->outStaticDebug("Pet AI stopped attacking [guid=%u]",
me->GetGUIDLow());
_stopAttack();
return;
}
targetHasCC = _CheckTargetCC(me->getVictim());
DoMeleeAttackIfReady();
} else if (owner && me->GetCharmInfo()) //no victim
{
Unit *nextTarget = SelectNextTarget();
if (me->HasReactState(REACT_PASSIVE))
_stopAttack();
else if (nextTarget)
AttackStart(nextTarget);
else
HandleReturnMovement();
} else if (owner && !me->HasUnitState(UNIT_STAT_FOLLOW)) // no charm info and no victim
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST,
me->GetFollowAngle());
if (!me->GetCharmInfo())
return;
// Autocast (casted only in combat or persistent spells in any state)
if (me->GetGlobalCooldown() == 0 && !me->HasUnitState(UNIT_STAT_CASTING)) {
typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;
TargetSpellList targetSpellStore;
for (uint8 i = 0; i < me->GetPetAutoSpellSize(); ++i) {
uint32 spellID = me->GetPetAutoSpellOnPos(i);
if (!spellID)
continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID);
if (!spellInfo)
continue;
// ignore some combinations of combat state and combat/noncombat spells
if (!me->getVictim()) {
// ignore attacking spells, and allow only self/around spells
if (!IsPositiveSpell(spellInfo->Id))
continue;
// non combat spells allowed
// only pet spells have IsNonCombatSpell and not fit this reqs:
// Consume Shadows, Lesser Invisibility, so ignore checks for its
if (!IsNonCombatSpell(spellInfo)) {
// allow only spell without spell cost or with spell cost but not duration limit
int32 duration = GetSpellDuration(spellInfo);
if ((spellInfo->manaCost || spellInfo->ManaCostPercentage
|| spellInfo->manaPerSecond) && duration > 0)
continue;
// allow only spell without cooldown > duration
int32 cooldown = GetSpellRecoveryTime(spellInfo);
if (cooldown >= 0 && duration >= 0 && cooldown > duration)
continue;
}
} else {
// just ignore non-combat spells
if (IsNonCombatSpell(spellInfo))
continue;
}
Spell *spell = new Spell(me, spellInfo, false, 0);
// Fix to allow pets on STAY to autocast
if (me->getVictim() && _CanAttack(me->getVictim())
&& spell->CanAutoCast(me->getVictim())) {
targetSpellStore.push_back(
std::make_pair<Unit*, Spell*>(me->getVictim(), spell));
continue;
} else {
bool spellUsed = false;
for (std::set<uint64>::const_iterator tar = m_AllySet.begin();
tar != m_AllySet.end(); ++tar) {
Unit* Target = ObjectAccessor::GetUnit(*me, *tar);
//only buff targets that are in combat, unless the spell can only be cast while out of combat
if (!Target)
continue;
if (spell->CanAutoCast(Target)) {
//.........這裏部分代碼省略.........
示例11: UpdateAI
void UpdateAI(const uint32 uiDiff) override
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
{
return;
}
// Summon panters every 5 seconds
if (m_uiSummonTimer < uiDiff)
{
if (m_pInstance)
{
if (Creature* pTrigger = m_pInstance->instance->GetCreature(ObjectGuid(m_pInstance->GetData64(TYPE_SIGNAL_2))))
{
m_creature->SummonCreature(NPC_ZULIAN_PROWLER, pTrigger->GetPositionX(), pTrigger->GetPositionY(), pTrigger->GetPositionZ(), 0, TEMPSUMMON_TIMED_OOC_DESPAWN, 30000);
}
if (Creature* pTrigger = m_pInstance->instance->GetCreature(ObjectGuid(m_pInstance->GetData64(TYPE_SIGNAL_3))))
{
m_creature->SummonCreature(NPC_ZULIAN_PROWLER, pTrigger->GetPositionX(), pTrigger->GetPositionY(), pTrigger->GetPositionZ(), 0, TEMPSUMMON_TIMED_OOC_DESPAWN, 30000);
}
}
m_uiSummonTimer = 5000;
}
else
{
m_uiSummonTimer -= uiDiff;
}
if (m_uiVisibleTimer)
{
if (m_uiVisibleTimer <= uiDiff)
{
// Restore visibility
m_creature->SetVisibility(VISIBILITY_ON);
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
{
AttackStart(pTarget);
}
m_uiVisibleTimer = 0;
}
else
{
m_uiVisibleTimer -= uiDiff;
}
// Do nothing while vanished
return;
}
// Troll phase
if (!m_bIsPhaseTwo)
{
if (m_uiShadowWordPainTimer < uiDiff)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
{
if (DoCastSpellIfCan(pTarget, SPELL_SHADOW_WORD_PAIN) == CAST_OK)
{
m_uiShadowWordPainTimer = 15000;
}
}
}
else
{
m_uiShadowWordPainTimer -= uiDiff;
}
if (m_uiMarkTimer < uiDiff)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, SPELL_MARK_ARLOKK, SELECT_FLAG_PLAYER))
{
if (DoCastSpellIfCan(pTarget, SPELL_MARK_ARLOKK) == CAST_OK)
{
DoScriptText(SAY_FEAST_PANTHER, m_creature, pTarget);
m_uiMarkTimer = 30000;
}
}
}
else
{
m_uiMarkTimer -= uiDiff;
}
if (m_uiGougeTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_GOUGE) == CAST_OK)
{
if (m_creature->GetThreatManager().getThreat(m_creature->getVictim()))
{
m_creature->GetThreatManager().modifyThreatPercent(m_creature->getVictim(), -80);
}
m_uiGougeTimer = urand(17000, 27000);
}
}
else
{
//.........這裏部分代碼省略.........
示例12: UpdateAI
void UpdateAI(uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if( me->HasUnitState(UNIT_STATE_CASTING) )
return;
switch( events.GetEvent() )
{
case 0:
break;
case EVENT_YELL_DEAD_1:
Talk(YELL_DEAD_1);
events.PopEvent();
break;
case EVENT_START_RESURRECTION:
me->CastSpell(me, SPELL_SUMMON_VALKYR, true);
events.PopEvent();
events.RescheduleEvent(EVENT_VALKYR_BEAM, 7000);
events.RescheduleEvent(EVENT_VALKYR_MOVE, 1);
events.RescheduleEvent(EVENT_ANNHYLDE_YELL, 3000);
break;
case EVENT_VALKYR_MOVE:
if( Creature* s = ObjectAccessor::GetCreature(*me, ValkyrGUID) )
s->GetMotionMaster()->MovePoint(1, s->GetPositionX(), s->GetPositionY(), s->GetPositionZ()-15.0f);
events.PopEvent();
break;
case EVENT_ANNHYLDE_YELL:
if( Creature* s = ObjectAccessor::GetCreature(*me, ValkyrGUID) )
s->AI()->Talk(YELL_ANHYLDE_2);
events.PopEvent();
break;
case EVENT_VALKYR_BEAM:
me->RemoveAura(SPELL_SUMMON_VALKYR);
if( Creature* c = ObjectAccessor::GetCreature(*me, ValkyrGUID) )
c->CastSpell(me, SPELL_RESURRECTION_BEAM, false);
events.PopEvent();
events.RescheduleEvent(EVENT_RESURRECTION_BALL, 4000);
break;
case EVENT_RESURRECTION_BALL:
me->CastSpell(me, SPELL_RESURRECTION_BALL, true);
events.PopEvent();
events.RescheduleEvent(EVENT_RESURRECTION_HEAL, 4000);
break;
case EVENT_RESURRECTION_HEAL:
me->RemoveAura(SPELL_RESURRECTION_BALL);
me->CastSpell(me, SPELL_RESURRECTION_HEAL, true);
FeignDeath(false);
events.PopEvent();
events.RescheduleEvent(EVENT_MORPH_TO_UNDEAD, 3000);
break;
case EVENT_MORPH_TO_UNDEAD:
me->CastSpell(me, SPELL_INGVAR_TRANSFORM, true);
events.PopEvent();
events.RescheduleEvent(EVENT_START_PHASE_2, 1000);
break;
case EVENT_START_PHASE_2:
if( Creature* c = ObjectAccessor::GetCreature(*me, ValkyrGUID) )
{
c->DespawnOrUnsummon();
summons.DespawnAll();
}
events.PopEvent();
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
AttackStart(me->GetVictim());
me->GetMotionMaster()->MoveChase(me->GetVictim());
Talk(YELL_AGGRO_2);
// schedule Phase 2 abilities
events.RescheduleEvent(EVENT_SPELL_ROAR, 15000);
events.RescheduleEvent(EVENT_SPELL_CLEAVE_OR_WOE_STRIKE, 2000);
events.RescheduleEvent(EVENT_SPELL_SMASH, 5000);
events.RescheduleEvent(EVENT_SPELL_ENRAGE_OR_SHADOW_AXE, 10000);
break;
// ABILITIES HERE:
case EVENT_UNROOT:
me->SetControlled(false, UNIT_STATE_ROOT);
me->DisableRotate(false);
events.PopEvent();
break;
case EVENT_SPELL_ROAR:
Talk(EMOTE_ROAR);
me->_AddCreatureSpellCooldown(SPELL_STAGGERING_ROAR, 0);
me->_AddCreatureSpellCooldown(SPELL_DREADFUL_ROAR, 0);
if (me->GetDisplayId() == DISPLAYID_DEFAULT)
me->CastSpell((Unit*)NULL, SPELL_STAGGERING_ROAR, false);
else
me->CastSpell((Unit*)NULL, SPELL_DREADFUL_ROAR, false);
events.RepeatEvent(urand(15000,20000));
break;
case EVENT_SPELL_CLEAVE_OR_WOE_STRIKE:
if( me->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID) == 0 )
{
//.........這裏部分代碼省略.........
示例13: UpdateAI
void UpdateAI(const uint32 diff)
{
if (instance)
{
if (!leotherasGUID)
leotherasGUID = instance->GetData64(DATA_LEOTHERAS);
if (!me->isInCombat() && instance->GetData64(DATA_LEOTHERAS_EVENT_STARTER))
{
Unit* victim = NULL;
victim = Unit::GetUnit(*me, instance->GetData64(DATA_LEOTHERAS_EVENT_STARTER));
if (victim)
AttackStart(victim);
}
}
if (!UpdateVictim())
{
CastChanneling();
return;
}
if (instance && !instance->GetData64(DATA_LEOTHERAS_EVENT_STARTER))
{
EnterEvadeMode();
return;
}
if (Mindblast_Timer <= diff)
{
Unit* target = NULL;
target = SelectTarget(SELECT_TARGET_RANDOM, 0);
if (target)DoCast(target, SPELL_MINDBLAST);
Mindblast_Timer = urand(10000, 15000);
} else Mindblast_Timer -= diff;
if (Earthshock_Timer <= diff)
{
Map* map = me->GetMap();
Map::PlayerList const &PlayerList = map->GetPlayers();
for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
{
if (Player* i_pl = itr->getSource())
{
bool isCasting = false;
for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
if (i_pl->GetCurrentSpell(i))
isCasting = true;
if (isCasting)
{
DoCast(i_pl, SPELL_EARTHSHOCK);
break;
}
}
}
Earthshock_Timer = urand(8000, 15000);
} else Earthshock_Timer -= diff;
DoMeleeAttackIfReady();
}
示例14: UpdateAllies
void PetAI::UpdateAI(const uint32 diff)
{
if (!m_creature->isAlive())
return;
m_updateAlliesTimer.Update(diff);
if (m_updateAlliesTimer.Passed())
{
UpdateAllies();
m_updateAlliesTimer.Reset();
}
Unit* owner = m_creature->GetCharmerOrOwner();
if (owner && !m_creature->IsWithinDistInMap(owner, m_fMaxRadiusToOwner) && !m_creature->IsInUnitState(UNIT_ACTION_HOME))
{
if (owner->GetTypeId() == TYPEID_PLAYER && (m_creature->IsPet() || m_creature->isCharmed()))
{
owner->CallForAllControlledUnits(DoPetActionWithHelper((Player*)owner, ACT_REACTION, REACT_PASSIVE, m_creature->GetObjectGuid(), ObjectGuid()), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM);
owner->CallForAllControlledUnits(DoPetActionWithHelper((Player*)owner, ACT_COMMAND, COMMAND_FOLLOW, m_creature->GetObjectGuid(), ObjectGuid()), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM);
return;
}
}
if (!inCombat && m_savedTargetGuid)
{
if (Unit* savedTarget = m_creature->GetMap()->GetUnit(m_savedTargetGuid))
{
if (!savedTarget->isAlive())
m_savedTargetGuid.Clear();
else if (!savedTarget->IsCrowdControlled())
AttackStart(savedTarget);
}
else
m_savedTargetGuid.Clear();
}
Unit* pVictim = m_creature->getVictim();
if (inCombat &&
(!pVictim || !pVictim->isAlive() ||
(m_creature->IsPet() && m_creature->GetCharmInfo()->HasState(CHARM_STATE_ACTION, ACTIONS_DISABLE))))
_stopAttack();
if (m_creature->hasUnitState(UNIT_STAT_CAN_NOT_REACT) || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
{
UpdateAIType();
return;
}
// i_pet.getVictim() can't be used for check in case stop fighting, i_pet.getVictim() clear at Unit death etc.
if (pVictim)
{
bool meleeReach = m_creature->CanReachWithMeleeAttack(pVictim);
if (_needToStop())
{
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "PetAI (guid = %u) is stopping attack.", m_creature->GetGUIDLow());
_stopAttack();
return;
}
else if (!pVictim->isAlive()) // Stop attack if target dead
{
m_creature->InterruptNonMeleeSpells(false);
_stopAttack();
return;
}
// Stop attack if target under CC effect
else if (sWorld.getConfig(CONFIG_BOOL_PET_ADVANCED_AI) && IsInCombat() &&
pVictim->IsCrowdControlled() &&
!m_creature->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
{
m_savedTargetGuid = pVictim->GetObjectGuid();
m_creature->InterruptSpell(CURRENT_GENERIC_SPELL, true);
if (!m_creature->IsNonMeleeSpellCasted(false, false, true))
_stopAttack();
return;
}
else if (m_creature->IsStopped() || meleeReach)
{
// required to be stopped cases
if (m_creature->IsStopped() && m_creature->IsNonMeleeSpellCasted(false))
{
if (m_creature->hasUnitState(UNIT_STAT_FOLLOW_MOVE))
m_creature->InterruptNonMeleeSpells(false);
else
return;
}
// not required to be stopped case
else if (DoMeleeAttackIfReady())
{
pVictim = m_creature->getVictim();
if (!pVictim)
return;
// if pet misses its target, it will also be the first in threat list
pVictim->AddThreat(m_creature);
if (_needToStop())
_stopAttack();
//.........這裏部分代碼省略.........
示例15: UpdateAI
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
if (me->getVictim() && me->isAlive())
{
if (HealthAbovePct(50))
{
if (Charge_Timer <= diff)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
{
DoCast(target, SPELL_CHARGE);
AttackStart(target);
}
Charge_Timer = urand(15000, 30000);
} else Charge_Timer -= diff;
if (SonicBurst_Timer <= diff)
{
DoCast(me->getVictim(), SPELL_SONICBURST);
SonicBurst_Timer = urand(8000, 13000);
} else SonicBurst_Timer -= diff;
if (Screech_Timer <= diff)
{
DoCast(me->getVictim(), SPELL_SCREECH);
Screech_Timer = urand(18000, 26000);
} else Screech_Timer -= diff;
if (SpawnBats_Timer <= diff)
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
Creature* Bat = NULL;
Bat = me->SummonCreature(11368, -12291.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (target && Bat) Bat ->AI()->AttackStart(target);
Bat = me->SummonCreature(11368, -12289.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (target && Bat) Bat ->AI()->AttackStart(target);
Bat = me->SummonCreature(11368, -12293.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (target && Bat) Bat ->AI()->AttackStart(target);
Bat = me->SummonCreature(11368, -12291.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (target && Bat) Bat ->AI()->AttackStart(target);
Bat = me->SummonCreature(11368, -12289.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (target && Bat) Bat ->AI()->AttackStart(target);
Bat = me->SummonCreature(11368, -12293.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
if (target && Bat) Bat ->AI()->AttackStart(target);
SpawnBats_Timer = 60000;
} else SpawnBats_Timer -= diff;
}
else
{
if (PhaseTwo)
{
if (PhaseTwo && ShadowWordPain_Timer <= diff)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
{
DoCast(target, SPELL_SHADOW_WORD_PAIN);
ShadowWordPain_Timer = urand(12000, 18000);
}
}
ShadowWordPain_Timer -=diff;
if (MindFlay_Timer <= diff)
{
DoCast(me->getVictim(), SPELL_MIND_FLAY);
MindFlay_Timer = 16000;
}
MindFlay_Timer -=diff;
if (ChainMindFlay_Timer <= diff)
{
me->InterruptNonMeleeSpells(false);
DoCast(me->getVictim(), SPELL_CHAIN_MIND_FLAY);
ChainMindFlay_Timer = urand(15000, 30000);
}
ChainMindFlay_Timer -=diff;
if (GreaterHeal_Timer <= diff)
{
me->InterruptNonMeleeSpells(false);
DoCast(me, SPELL_GREATERHEAL);
GreaterHeal_Timer = urand(25000, 35000);
}
GreaterHeal_Timer -=diff;
if (SpawnFlyingBats_Timer <= diff)
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
if (!target)
return;
//.........這裏部分代碼省略.........