diff options
| author | QAston <none@none> | 2009-05-13 18:33:15 +0200 |
|---|---|---|
| committer | QAston <none@none> | 2009-05-13 18:33:15 +0200 |
| commit | 131c29f1329aa6ec696f51fbe2c75178dc8f8262 (patch) | |
| tree | 886fa69a8248b6b53eb7774944b35a8bf9bf5a3b /src/game | |
| parent | 9aab3899376258c09b7caab7743494495b6374a1 (diff) | |
| parent | 80c19013432ec49fb5c1b57bf2d5aca7be0d53c7 (diff) | |
*Merge.
--HG--
branch : trunk
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/AggressorAI.cpp | 2 | ||||
| -rw-r--r-- | src/game/Creature.cpp | 3 | ||||
| -rw-r--r-- | src/game/CreatureAI.cpp | 55 | ||||
| -rw-r--r-- | src/game/CreatureAI.h | 3 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 2 |
5 files changed, 40 insertions, 25 deletions
diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index 286138fc991..22ebe87cdc6 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -104,7 +104,7 @@ void SpellAI::UpdateAI(const uint32 diff) break; } } - me->CastSpell(target, spellId, false); + if(target) me->CastSpell(target, spellId, false); events.ScheduleEvent(spellId, AISpellInfo[spellId].cooldown + rand()%AISpellInfo[spellId].cooldown); } else diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 85109997390..f322d8326e1 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -455,6 +455,9 @@ void Creature::Update(uint32 diff) } else { + // for delayed spells + m_Events.Update( diff ); + m_deathTimer -= diff; if (m_groupLootTimer && lootingGroupLeaderGUID) { diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index ea65d233a17..0864bc973ab 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -39,6 +39,9 @@ void CreatureAI::DoZoneInCombat(Creature* creature) if (!creature) creature = me; + if(!creature->CanHaveThreatList()) + return; + Map *map = creature->GetMap(); if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated { @@ -46,7 +49,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature) return; } - if(!creature->getVictim()) + if(!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim()) { if(Unit *target = creature->SelectNearestTarget()) creature->AI()->AttackStart(target); @@ -54,29 +57,30 @@ void CreatureAI::DoZoneInCombat(Creature* creature) { if(Unit *summoner = ((TempSummon*)creature)->GetSummoner()) { - if(summoner->getVictim() - && (creature->IsFriendlyTo(summoner) || creature->IsHostileTo(summoner->getVictim()))) - creature->AI()->AttackStart(summoner->getVictim()); + Unit *target = summoner->getAttackerForHelper(); + if(!target && summoner->CanHaveThreatList() && !summoner->getThreatManager().isThreatListEmpty()) + target = summoner->getThreatManager().getHostilTarget(); + if(target && (creature->IsFriendlyTo(summoner) || creature->IsHostileTo(target))) + creature->AI()->AttackStart(target); } } } - if (!creature->CanHaveThreatList() || !creature->getVictim()) + if(!creature->HasReactState(REACT_PASSIVE) && !creature->getVictim()) { - sLog.outError("DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (creature entry = %d)", creature->GetTypeId() == TYPEID_UNIT ? ((Creature*)creature)->GetEntry() : 0); + sLog.outError("DoZoneInCombat called for creature that has empty threat list (creature entry = %u)", creature->GetEntry()); return; } Map::PlayerList const &PlayerList = map->GetPlayers(); for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) { - if (Player* i_pl = i->getSource()) - if (i_pl->isAlive()) - { - creature->SetInCombatWith(i_pl); - i_pl->SetInCombatWith(creature); - creature->AddThreat(i_pl, 0.0f); - } + if (i->getSource()->isAlive()) + { + creature->SetInCombatWith(i->getSource()); + i->getSource()->SetInCombatWith(creature); + creature->AddThreat(i->getSource(), 0.0f); + } } } @@ -102,10 +106,10 @@ bool CreatureAI::UpdateVictim() return me->getVictim(); } -void CreatureAI::EnterEvadeMode() +bool CreatureAI::_EnterEvadeMode() { - if(me->IsInEvadeMode()) - return; + if(me->IsInEvadeMode() || !me->isAlive()) + return false; me->RemoveAllAuras(); me->DeleteThreatList(); @@ -113,13 +117,18 @@ void CreatureAI::EnterEvadeMode() me->LoadCreaturesAddon(); me->SetLootRecipient(NULL); - if(me->isAlive()) - { - if(Unit *owner = me->GetCharmerOrOwner()) - me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE, MOTION_SLOT_IDLE); - else - me->GetMotionMaster()->MoveTargetedHome(); - } + return true; +} + +void CreatureAI::EnterEvadeMode() +{ + if(!_EnterEvadeMode()) + return; + + if(Unit *owner = me->GetCharmerOrOwner()) + me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE, MOTION_SLOT_IDLE); + else + me->GetMotionMaster()->MoveTargetedHome(); Reset(); } diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 605e904c71a..c46dd2a54f2 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -168,6 +168,9 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI static AISpellInfoType *AISpellInfo; static void FillAISpellInfo(); + + protected: + bool _EnterEvadeMode(); }; enum Permitions diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index f142ea623a5..66576396dfa 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9958,7 +9958,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy) ((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); if(enemy) { - if(!((Creature*)this)->HasReactState(REACT_PASSIVE) && ((Creature*)this)->IsAIEnabled) + if(((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->EnterCombat(enemy); if(((Creature*)this)->GetFormation()) ((Creature*)this)->GetFormation()->MemberAttackStart((Creature*)this, enemy); |
