aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-10-10 11:42:28 +0200
committerShauren <shauren.trinity@gmail.com>2015-10-10 11:42:28 +0200
commitb8a846d33ed0c5fe15f06f0454fbcd50f48c9f38 (patch)
treee66c1e282ff1432bfbd7d2984243d67c3b3dabf9 /src
parent15f2706acaaf22d1f04b054b0dafbbd3d90a8c5b (diff)
parent6a8524c068d418092c193a3419b65818f3fd3443 (diff)
Merge pull request #15504 from Treeston/3.3.5-bosscombatpulse
Core/Creature: Add default-disabled periodic zone combat pulse (and have base AI enable it for bosses)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp2
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp36
-rw-r--r--src/server/game/Entities/Creature/Creature.h10
3 files changed, 47 insertions, 1 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 8e2a82dbfd3..7b145268d22 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -470,6 +470,7 @@ void BossAI::_Reset()
if (!me->IsAlive())
return;
+ me->SetCombatPulseDelay(0);
me->ResetLootMode();
events.Reset();
summons.DespawnAll();
@@ -500,6 +501,7 @@ void BossAI::_EnterCombat()
instance->SetBossState(_bossId, IN_PROGRESS);
}
+ me->SetCombatPulseDelay(5);
me->setActive(true);
DoZoneInCombat();
ScheduleTasks();
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 7fe3628f893..c8a258ad386 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -138,7 +138,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(),
m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0),
m_lootRecipient(), m_lootRecipientGroup(0), _skinner(), _pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0),
-m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE),
+m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE),
m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
m_originalEntry(0), m_homePosition(), m_transportHomePosition(), m_creatureInfo(NULL), m_creatureData(NULL), m_waypointID(0), m_path_id(0), m_formation(NULL)
@@ -539,10 +539,44 @@ void Creature::Update(uint32 diff)
LastCharmerGUID.Clear();
}
+ // if periodic combat pulse is enabled and we are both in combat and in a dungeon, do this now
+ if (m_combatPulseDelay > 0 && IsInCombat() && GetMap()->IsDungeon())
+ {
+ if (diff > m_combatPulseTime)
+ m_combatPulseTime = 0;
+ else
+ m_combatPulseTime -= diff;
+
+ if (m_combatPulseTime == 0)
+ {
+ Map::PlayerList const &players = GetMap()->GetPlayers();
+ if (!players.isEmpty())
+ for (Map::PlayerList::const_iterator it = players.begin(); it != players.end(); ++it)
+ {
+ if (Player* player = it->GetSource())
+ {
+ if (player->IsGameMaster())
+ continue;
+
+ if (player->IsAlive() && this->IsHostileTo(player))
+ {
+ if (CanHaveThreatList())
+ AddThreat(player, 0.0f);
+ this->SetInCombatWith(player);
+ player->SetInCombatWith(this);
+ }
+ }
+ }
+
+ m_combatPulseTime = m_combatPulseDelay * IN_MILLISECONDS;
+ }
+ }
+
if (!IsInEvadeMode() && IsAIEnabled)
{
// do not allow the AI to be changed during update
m_AI_locked = true;
+
i_AI->UpdateAI(diff);
m_AI_locked = false;
}
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 3e381063772..79832b70f52 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -601,6 +601,14 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
float GetRespawnRadius() const { return m_respawnradius; }
void SetRespawnRadius(float dist) { m_respawnradius = dist; }
+ uint32 GetCombatPulseDelay() const { return m_combatPulseDelay; }
+ void SetCombatPulseDelay(uint32 delay) // (secs) interval at which the creature pulses the entire zone into combat (only works in dungeons)
+ {
+ m_combatPulseDelay = delay;
+ if (m_combatPulseTime == 0 || m_combatPulseTime > delay)
+ m_combatPulseTime = delay;
+ }
+
uint32 m_groupLootTimer; // (msecs)timer used for group loot
uint32 lootingGroupLowGUID; // used to find group which is looting corpse
@@ -686,6 +694,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
uint32 m_respawnDelay; // (secs) delay between corpse disappearance and respawning
uint32 m_corpseDelay; // (secs) delay between death and corpse disappearance
float m_respawnradius;
+ uint32 m_combatPulseTime; // (msecs) remaining time for next zone-in-combat pulse
+ uint32 m_combatPulseDelay; // (secs) how often the creature puts the entire zone in combat (only works in dungeons)
ReactStates m_reactState; // for AI, not charmInfo
void RegenerateMana();