Permalink
Browse files

Scripts/FlameLeviathan: fix door handling, try to fix pursue thanks t…

…o zwerg

Signed-off-by: locknes <locknes91@windowslive.com>
  • Loading branch information...
1 parent ccd6d2b commit dd0975c3c631519c3de3597784f4dfd5fdbfb967 locknes committed May 28, 2011
@@ -3750,7 +3750,6 @@ void SpellMgr::LoadSpellCustomAttr()
case 25425: // Shoot
case 45761: // Shoot
case 42611: // Shoot
- case 62374: // Pursued
case 61588: // Blazing Harpoon
spellInfo->MaxAffectedTargets = 1;
++count;
@@ -311,13 +311,6 @@ class boss_flame_leviathan : public CreatureScript
DoScriptText(SAY_AGGRO, me);
}
- // TODO: effect 0 and effect 1 may be on different target
- void SpellHitTarget(Unit* target, SpellEntry const* spell)
- {
- if (spell->Id == SPELL_PURSUED)
- AttackStart(target);
- }
-
void JustDied(Unit* /*victim*/)
{
_JustDied();
@@ -339,6 +332,17 @@ class boss_flame_leviathan : public CreatureScript
}
}
+ void SpellHitTarget(Unit* target, SpellEntry const* spell)
+ {
+ if (spell->Id == SPELL_PURSUED)
+ {
+ DoResetThreat();
+ me->AddThreat(target, 9999999.0f);
+ if (Player* player = target->GetCharmerOrOwnerPlayerOrPlayerItself())
+ me->MonsterTextEmote(EMOTE_PURSUE, player->GetGUID(), true);
+ }
+ }
+
void SpellHit(Unit* /*caster*/, SpellEntry const* spell)
{
if (spell->Id == SPELL_START_THE_ENGINE)
@@ -406,6 +410,9 @@ class boss_flame_leviathan : public CreatureScript
if (me->HasUnitState(UNIT_STAT_CASTING))
return;
+ if (me->getVictim() && !me->getVictim()->HasAura(SPELL_PURSUED))
+ events.RescheduleEvent(EVENT_PURSUE, 0);
+
uint32 eventId = events.GetEvent();
switch(eventId)
@@ -414,11 +421,7 @@ class boss_flame_leviathan : public CreatureScript
break; // this is a must
case EVENT_PURSUE:
DoScriptText(RAND(SAY_TARGET_1, SAY_TARGET_2, SAY_TARGET_3), me);
- if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 75, true))
- {
- me->AddAura(SPELL_PURSUED, target);
- me->MonsterTextEmote(EMOTE_PURSUE, target->GetGUID(), true);
- }
+ DoCast(SPELL_PURSUED);
events.RepeatEvent(30*IN_MILLISECONDS);
break;
case EVENT_MISSILE:
@@ -1454,6 +1457,98 @@ class spell_anti_air_rocket : public SpellScriptLoader
}
};
+class spell_pursued : public SpellScriptLoader
+{
+ public:
+ spell_pursued() : SpellScriptLoader("spell_pursued") { }
+
+ class spell_pursued_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_pursued_SpellScript);
+
+ bool Load()
+ {
+ _target = NULL;
+ return GetCaster()->GetTypeId() == TYPEID_UNIT;
+ }
+
+ void SelectTarget(std::list<Unit*>& targetList)
+ {
+ if (targetList.empty())
+ return;
+
+ std::list<Unit*> tempList;
+
+ // try to find demolisher or siege engine first
+ for (std::list<Unit*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
+ {
+ _target = *itr;
+
+ if (!_target->ToCreature())
+ continue;
+
+ if (_target->ToCreature()->GetEntry() == VEHICLE_SIEGE || _target->ToCreature()->GetEntry() == VEHICLE_DEMOLISHER)
+ tempList.push_back(_target);
+ }
+
+ if (tempList.empty())
+ {
+ // no demolisher or siege engine, find a chopper
+ for (std::list<Unit*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
+ {
+ _target = *itr;
+
+ if (!_target->ToCreature())
+ continue;
+
+ if (_target->ToCreature()->GetEntry() == VEHICLE_CHOPPER)
+ tempList.push_back(_target);
+ }
+ }
+
+ if (!tempList.empty())
+ {
+ // found one or more vehicles, select a random one
+ std::list<Unit*>::iterator itr = tempList.begin();
+ std::advance(itr, urand(0, tempList.size() - 1));
+ _target = *itr;
+ targetList.clear();
+ targetList.push_back(_target);
+ }
+ else
+ {
+ // found no vehicles, select a random player or pet
+ std::list<Unit*>::iterator itr = targetList.begin();
+ std::advance(itr, urand(0, targetList.size() - 1));
+ _target = *itr;
+ targetList.clear();
+ targetList.push_back(_target);
+ }
+ }
+
+ void SetTarget(std::list<Unit*>& targetList)
+ {
+ targetList.clear();
+
+ if (_target)
+ targetList.push_back(_target);
+ }
+
+ void Register()
+ {
+ OnUnitTargetSelect += SpellUnitTargetFn(spell_pursued_SpellScript::SelectTarget, EFFECT_0, TARGET_UNIT_AREA_ENEMY_SRC);
+ OnUnitTargetSelect += SpellUnitTargetFn(spell_pursued_SpellScript::SetTarget, EFFECT_1, TARGET_UNIT_AREA_ENEMY_SRC);
+ }
+
+ Unit* _target;
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_pursued_SpellScript();
+ }
+};
+
void AddSC_boss_flame_leviathan()
{
new boss_flame_leviathan();
@@ -1480,4 +1575,5 @@ void AddSC_boss_flame_leviathan()
new achievement_shutout();
new achievement_unbroken();
new spell_anti_air_rocket();
+ new spell_pursued();
}
@@ -41,8 +41,8 @@ class instance_ulduar : public InstanceMapScript
// Leviathan
uint64 uiLeviathanGUID;
- uint64 uiLeviathanDoor[7];
uint64 uiLeviathanGateGUID;
+ std::list<uint64> uiLeviathanDoorGUIDList;
// Ignis
uint64 uiIgnisGUID;
@@ -144,6 +144,7 @@ class instance_ulduar : public InstanceMapScript
void Initialize()
{
SetBossNumber(MAX_ENCOUNTER);
+
uiIgnisGUID = 0;
uiRazorscaleGUID = 0;
uiRazorscaleController = 0;
@@ -199,7 +200,6 @@ class instance_ulduar : public InstanceMapScript
memset(uiEncounter, 0, sizeof(uiEncounter));
memset(uiAssemblyGUIDs, 0, sizeof(uiAssemblyGUIDs));
- memset(&uiLeviathanDoor, 0, sizeof(uiLeviathanDoor));
memset(uiRazorHarpoonGUIDs, 0, sizeof(uiRazorHarpoonGUIDs));
}
@@ -244,12 +244,12 @@ class instance_ulduar : public InstanceMapScript
// This will work for 90% of all Players ... someone will found the backdoor (and i try to close this later)
if(InstancePlayerBind* bind = player->GetBoundInstance(instance->GetId(),instance->GetDifficulty()))
{
- if(bind->perm)
+ if (bind->perm)
return;
uint32 achievement = instance->GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL? ACHIEVEMENT_CHAMPION_OF_ULDUAR : ACHIEVEMENT_CONQUEROR_OF_ULDUAR;
- if(!player->HasAchieved(achievement))
+ if (!player->HasAchieved(achievement))
player->GetAchievementMgr().RemoveAchievement(achievement);
}
}
@@ -514,12 +514,8 @@ class instance_ulduar : public InstanceMapScript
uiFreyaChestGUID = go->GetGUID();
break;
case GO_LEVIATHAN_DOOR:
- //uiLeviathanDoor[flag] = go->GetGUID();
- //HandleGameObject(NULL, true, go);
- //flag++;
- //if (flag == 7)
- // flag =0;
- AddDoor(go, true);
+ go->setActive(true);
+ uiLeviathanDoorGUIDList.push_back(go->GetGUID());
break;
case GO_LEVIATHAN_GATE:
uiLeviathanGateGUID = go->GetGUID();
@@ -681,12 +677,11 @@ class instance_ulduar : public InstanceMapScript
switch (type)
{
case TYPE_LEVIATHAN:
- if (state == IN_PROGRESS)
- for (uint8 uiI = 0; uiI < 7; ++uiI)
- HandleGameObject(uiLeviathanDoor[uiI],false);
- else
- for (uint8 uiI = 0; uiI < 7; ++uiI)
- HandleGameObject(uiLeviathanDoor[uiI],true);
+ for (std::list<uint64>::iterator i = uiLeviathanDoorGUIDList.begin(); i != uiLeviathanDoorGUIDList.end(); i++)
+ {
+ if (GameObject* obj = instance->GetGameObject(*i))
+ obj->SetGoState(state == IN_PROGRESS ? GO_STATE_READY : GO_STATE_ACTIVE );
+ }
if (state == DONE)
HandleGameObject(uiXT002DoorGUID, true);

0 comments on commit dd0975c

Please sign in to comment.