From 54cb8f1a632f094969eb649e3a6e03767d3fcff8 Mon Sep 17 00:00:00 2001 From: Schmoozerd Date: Tue, 18 Jan 2011 13:46:10 +0300 Subject: [PATCH] [11032] Implement CREATURE_FLAG_EXTRA_AGGRO_ZONE. This let control zone wide aggro in DB data instead need special script code. Signed-off-by: VladimirMangos --- src/game/Creature.cpp | 2 +- src/game/Creature.h | 1 + src/game/ObjectMgr.cpp | 10 +++++++++- src/game/Unit.cpp | 12 +++++++++--- src/shared/revision_nr.h | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index a7d62a960..d37e57531 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1985,7 +1985,7 @@ void Creature::SetInCombatWithZone() if (pPlayer->isGameMaster()) continue; - if (pPlayer->isAlive()) + if (pPlayer->isAlive() && !IsFriendlyTo(pPlayer)) { pPlayer->SetInCombatWith(this); AddThreat(pPlayer); diff --git a/src/game/Creature.h b/src/game/Creature.h index 95076db80..563ccb56a 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -52,6 +52,7 @@ enum CreatureFlagsExtra CREATURE_FLAG_EXTRA_NO_XP_AT_KILL = 0x00000040, // creature kill not provide XP CREATURE_FLAG_EXTRA_INVISIBLE = 0x00000080, // creature is always invisible for player (mostly trigger creatures) CREATURE_FLAG_EXTRA_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me + CREATURE_FLAG_EXTRA_AGGRO_ZONE = 0x00000200, // creature sets itself in combat with zone on aggro }; // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 9db8cda84..779bae587 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1350,7 +1350,15 @@ void ObjectMgr::LoadCreatures() if(cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) { if(!mapEntry || !mapEntry->IsDungeon()) - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.",guid,data.id); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND (%u) but creature are not in instance.", + guid, data.id, CREATURE_FLAG_EXTRA_INSTANCE_BIND); + } + + if(cInfo->flags_extra & CREATURE_FLAG_EXTRA_AGGRO_ZONE) + { + if(!mapEntry || !mapEntry->IsDungeon()) + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_AGGRO_ZONE (%u) but creature are not in instance.", + guid, data.id, CREATURE_FLAG_EXTRA_AGGRO_ZONE); } if(data.curmana < cInfo->minmana) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 3a42cbfed..86724edee 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -7711,11 +7711,17 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy) if (getStandState() == UNIT_STAND_STATE_CUSTOM) SetStandState(UNIT_STAND_STATE_STAND); - if (((Creature*)this)->AI()) - ((Creature*)this)->AI()->EnterCombat(enemy); + Creature* pCreature = (Creature*)this; + + if (pCreature->AI()) + pCreature->AI()->EnterCombat(enemy); + + // Some bosses are set into combat with zone + if (GetMap()->IsDungeon() && (pCreature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_AGGRO_ZONE)) + pCreature->SetInCombatWithZone(); if (InstanceData* mapInstance = GetInstanceData()) - mapInstance->OnCreatureEnterCombat((Creature*)this); + mapInstance->OnCreatureEnterCombat(pCreature); } } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 591b926de..7dde86d08 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11031" + #define REVISION_NR "11032" #endif // __REVISION_NR_H__