Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 4f7498042ee217b8c9e0ffe0c73a1a2350d4a585 Mon Sep 17 00:00:00 2001
- From: higi <higi@calu.cz>
- Date: Sat, 11 Feb 2012 14:41:48 +0100
- Subject: [PATCH] ulduar stuff
- ---
- src/server/game/AI/CreatureAI.cpp | 52 +++++++++++++++++++-
- src/server/game/AI/CreatureAI.h | 4 +-
- src/server/game/AI/ScriptedAI/ScriptedCreature.cpp | 49 ++++++++++++++----
- 3 files changed, 92 insertions(+), 13 deletions(-)
- diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
- index c8818f8..6c56818 100755
- --- a/src/server/game/AI/CreatureAI.cpp
- +++ b/src/server/game/AI/CreatureAI.cpp
- @@ -22,6 +22,7 @@
- #include "World.h"
- #include "SpellMgr.h"
- #include "Vehicle.h"
- +#include "Group.h"
- #include "Log.h"
- #include "MapReference.h"
- #include "Player.h"
- @@ -110,7 +111,56 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/, float maxRangeToN
- }
- }
- -// scripts does not take care about MoveInLineOfSight loops
- +void CreatureAI::DoAttackerAreaInCombat(Unit* attacker, float range, Unit* pUnit)
- +{
- + if (!attacker)
- + attacker = me;
- +
- + if (!pUnit)
- + pUnit = me;
- +
- + Map *map = pUnit->GetMap();
- +
- + if (!map->IsDungeon())
- + return;
- +
- + if (!pUnit->CanHaveThreatList() || pUnit->getThreatManager().isThreatListEmpty())
- + 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() && attacker->GetDistance(i_pl) <= range )
- + {
- + pUnit->SetInCombatWith(i_pl);
- + i_pl->SetInCombatWith(pUnit);
- + pUnit->AddThreat(i_pl, 0.0f);
- + }
- + }
- +}
- +
- +void CreatureAI::DoAttackerGroupInCombat(Player* attacker)
- +{
- + if (attacker)
- + {
- + if (Group* pGroup = attacker->GetGroup() )
- + {
- + for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
- + {
- + Player* pGroupGuy = itr->getSource();
- +
- + if (pGroupGuy && pGroupGuy->isAlive() && pGroupGuy->GetMapId() == me->GetMapId())
- + {
- + me->SetInCombatWith(pGroupGuy);
- + pGroupGuy->SetInCombatWith(me);
- + me->AddThreat(pGroupGuy, 0.0f);
- + }
- + }
- + }
- + }
- +}
- +
- // MoveInLineOfSight can be called inside another MoveInLineOfSight and cause stack overflow
- void CreatureAI::MoveInLineOfSight_Safe(Unit* who)
- {
- diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h
- index 0113447..4831a2b 100755
- --- a/src/server/game/AI/CreatureAI.h
- +++ b/src/server/game/AI/CreatureAI.h
- @@ -97,6 +97,7 @@ class CreatureAI : public UnitAI
- // Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
- virtual void EnterCombat(Unit* /*victim*/) {}
- + virtual void ElementalDamageTaken(Unit * /*done_by*/, uint32 /*damage*/, SpellSchoolMask /*damageSchoolMask*/) {}
- // Called when the creature is killed
- virtual void JustDied(Unit* /*killer*/) {}
- @@ -125,7 +126,6 @@ class CreatureAI : public UnitAI
- // Called at waypoint reached or point movement finished
- virtual void MovementInform(uint32 /*type*/, uint32 /*id*/) {}
- - virtual void SummonedCreatureMovementInform(uint32 /*MovementType*/, uint32 /*Data*/, Creature *) {}
- void OnCharmed(bool apply);
- @@ -135,6 +135,8 @@ class CreatureAI : public UnitAI
- virtual void JustReachedHome() {}
- void DoZoneInCombat(Creature* creature = NULL, float maxRangeToNearestTarget = 50.0f);
- + void DoAttackerAreaInCombat(Unit* attacker, float range, Unit* pUnit = NULL);
- + void DoAttackerGroupInCombat(Player* attacker);
- // Called at text emote receive from player
- virtual void ReceiveEmote(Player* /*player*/, uint32 /*emoteId*/) {}
- diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
- index e3518cb..8851754 100644
- --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
- +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
- @@ -42,7 +42,7 @@ void SummonList::DoAction(uint32 entry, int32 info)
- }
- }
- -void SummonList::DespawnEntry(uint32 entry)
- +void SummonList::DespawnEntry(uint32 entry, uint32 msTimeToDespawn)
- {
- for (iterator i = begin(); i != end();)
- {
- @@ -52,14 +52,14 @@ void SummonList::DespawnEntry(uint32 entry)
- else if (summon->GetEntry() == entry)
- {
- erase(i++);
- - summon->DespawnOrUnsummon();
- + summon->DespawnOrUnsummon(msTimeToDespawn);
- }
- else
- ++i;
- }
- }
- -void SummonList::DespawnAll()
- +void SummonList::DespawnAll(uint32 msTimeToDespawn)
- {
- while (!empty())
- {
- @@ -69,7 +69,13 @@ void SummonList::DespawnAll()
- else
- {
- erase(begin());
- - summon->DespawnOrUnsummon();
- + if (TempSummon* summ = summon->ToTempSummon())
- + {
- + summon->DestroyForNearbyPlayers();
- + summ->UnSummon(msTimeToDespawn);
- + }
- + else
- + summon->DespawnOrUnsummon(msTimeToDespawn);
- }
- }
- }
- @@ -298,7 +304,8 @@ void ScriptedAI::DoModifyThreatPercent(Unit* unit, int32 pct)
- void ScriptedAI::DoTeleportTo(float x, float y, float z, uint32 time)
- {
- me->Relocate(x, y, z);
- - me->SendMonsterMove(x, y, z, time);
- + float speed = me->GetDistance(x, y, z) / ((float)time * 0.001f);
- + me->MonsterMoveWithSpeed(x, y, z, speed);
- }
- void ScriptedAI::DoTeleportTo(const float position[4])
- @@ -406,7 +413,8 @@ enum eNPCs
- NPC_BROODLORD = 12017,
- NPC_VOID_REAVER = 19516,
- NPC_JAN_ALAI = 23578,
- - NPC_SARTHARION = 28860
- + NPC_SARTHARION = 28860,
- + NPC_LEVIATHAN = 33113
- };
- // Hacklike storage used for misc creatures that are expected to evade of outside of a certain area.
- @@ -430,7 +438,7 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff)
- switch (me->GetEntry())
- {
- - case NPC_BROODLORD: // broodlord (not move down stairs)
- + case NPC_BROODLORD: // broodlord (not move down stairs)
- if (z > 448.60f)
- return false;
- break;
- @@ -438,14 +446,18 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff)
- if (me->GetDistance2d(432.59f, 371.93f) < 105.0f)
- return false;
- break;
- - case NPC_JAN_ALAI: // jan'alai (calculate by Z)
- + case NPC_JAN_ALAI: // jan'alai (calculate by Z)
- if (z > 12.0f)
- return false;
- break;
- - case NPC_SARTHARION: // sartharion (calculate box)
- + case NPC_SARTHARION: // sartharion (calculate box)
- if (x > 3218.86f && x < 3275.69f && y < 572.40f && y > 484.68f)
- return false;
- break;
- + case NPC_LEVIATHAN: // flame leviathan (calculate box)
- + if (x > 145.14f && x < 447.26f && y < 83.29f && y > -149.73f)
- + return false;
- + break;
- default: // For most of creatures that certain area is their home area.
- sLog->outDetail("TSCR: EnterEvadeIfOutOfCombatArea used for creature entry %u, but does not have any definition. Using the default one.", me->GetEntry());
- uint32 homeAreaId = me->GetMap()->GetAreaId(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY(), me->GetHomePosition().GetPositionZ());
- @@ -474,6 +486,7 @@ BossAI::BossAI(Creature* creature, uint32 bossId) : ScriptedAI(creature),
- _boundary(instance ? instance->GetBossBoundary(bossId) : NULL),
- _bossId(bossId)
- {
- + SetImmuneToPushPullEffects(true);
- }
- void BossAI::_Reset()
- @@ -486,6 +499,8 @@ void BossAI::_Reset()
- summons.DespawnAll();
- if (instance)
- instance->SetBossState(_bossId, NOT_STARTED);
- +
- + inFightAggroCheck_Timer = MAX_AGGRO_PULSE_TIMER;
- }
- void BossAI::_JustDied()
- @@ -499,6 +514,18 @@ void BossAI::_JustDied()
- }
- }
- +void BossAI::_DoAggroPulse(const uint32 diff)
- +{
- + if (inFightAggroCheck_Timer < diff)
- + {
- + if (me->getVictim() && me->getVictim()->ToPlayer())
- + DoAttackerGroupInCombat(me->getVictim()->ToPlayer());
- + inFightAggroCheck_Timer = MAX_AGGRO_PULSE_TIMER;
- + }
- + else
- + inFightAggroCheck_Timer -= diff;
- +}
- +
- void BossAI::_EnterCombat()
- {
- me->setActive(true);
- @@ -594,7 +621,7 @@ void BossAI::UpdateAI(uint32 const diff)
- events.Update(diff);
- - if (me->HasUnitState(UNIT_STAT_CASTING))
- + if (me->HasUnitState(UNIT_STATE_CASTING))
- return;
- while (uint32 eventId = events.ExecuteEvent())
- @@ -653,7 +680,7 @@ void WorldBossAI::UpdateAI(uint32 const diff)
- events.Update(diff);
- - if (me->HasUnitState(UNIT_STAT_CASTING))
- + if (me->HasUnitState(UNIT_STATE_CASTING))
- return;
- while (uint32 eventId = events.ExecuteEvent())
- --
- 1.7.7.msysgit.1
Add Comment
Please, Sign In to add comment