diff options
author | megamage <none@none> | 2009-04-07 19:38:09 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-04-07 19:38:09 -0500 |
commit | f59c4debf6d413fefb7f55d422263fbb44772054 (patch) | |
tree | a65e607067e5caf81a2b10b0eaecbaa78d9cf062 /src/game/CreatureAI.cpp | |
parent | 24dede78d339f348ab67d4e7235ed12d93802b69 (diff) |
[7622] Added creatureAI with related database tables. Author: AlexDereka
*Note: three tables are renamed.
--HG--
branch : trunk
Diffstat (limited to 'src/game/CreatureAI.cpp')
-rw-r--r-- | src/game/CreatureAI.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 45608ef317e..e7043c6042f 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -70,6 +70,38 @@ void CreatureAI::OnCharmed(bool apply) me->IsAIEnabled = false; } +void CreatureAI::DoZoneInCombat(Unit* pUnit) +{ + if (!pUnit) + pUnit = me; + + Map *map = pUnit->GetMap(); + + if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated + { + sLog.outError("DoZoneInCombat call for map that isn't an instance (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); + return; + } + + if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty()) + { + sLog.outError("DoZoneInCombat called for creature that either cannot have threat list or has empty threat list (pUnit entry = %d)", pUnit->GetTypeId() == TYPEID_UNIT ? ((Creature*)pUnit)->GetEntry() : 0); + 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()) + { + pUnit->SetInCombatWith(i_pl); + i_pl->SetInCombatWith(pUnit); + pUnit->AddThreat(i_pl, 0.0f); + } + } +} + void CreatureAI::MoveInLineOfSight(Unit *who) { if(!me->getVictim() && me->canStartAttack(who)) |