mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
fix(Scripts/Karazhan): Malchezaar infernals now spawn in the correct locations under the right conditions (#17237)
* initial test Co-authored-by: <100873791+Gultask@users.noreply.github.com> * change spawnMask * better failsafe * get list once * extend search range for relays * put infernal spawn in separate method for readability * add more methods * remove leftover method * dumb and dumber mistakes
This commit is contained in:
17
data/sql/updates/pending_db_world/helpers-malchezaar.sql
Normal file
17
data/sql/updates/pending_db_world/helpers-malchezaar.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
--
|
||||
DELETE FROM `creature` WHERE `guid` IN (135921, 135922, 135923, 135924, 135925, 135926, 135927, 135928, 135929, 135930, 135931, 135932, 135933, 135934);
|
||||
INSERT INTO `creature` (`guid`, `id1`, `id2`, `id3`, `map`, `zoneId`, `areaId`, `spawnMask`, `phaseMask`, `position_x`, `position_y`, `position_z`, `orientation`, `spawntimesecs`, `VerifiedBuild`) VALUES
|
||||
(135923, 17644, 0, 0, 532, 3457, 3457, 1, 1, -11001.4, -1991.33, 275.119, 4.97419, 7200, 49890),
|
||||
(135924, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10984.4, -2016.32, 275.166, 3.1765, 7200, 49890),
|
||||
(135925, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10976.4, -1961.86, 275.128, 5.39307, 7200, 49890),
|
||||
(135926, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10975.6, -1984.06, 275.297, 2.9147, 7200, 49890),
|
||||
(135927, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10962.1, -2014.65, 275.512, 0.628319, 7200, 49890),
|
||||
(135928, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10953.4, -1983.33, 275.446, 5.00909, 7200, 49890),
|
||||
(135929, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10951.9, -1957.37, 275.31, 5.89921, 7200, 49890),
|
||||
(135930, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10931.5, -1983.72, 275.614, 3.22886, 7200, 49890),
|
||||
(135931, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10942.5, -2014.21, 275.737, 5.91667, 7200, 49890),
|
||||
(135932, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10929.6, -1958.1, 275.468, 4.71239, 7200, 49890),
|
||||
(135933, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10911, -1987.62, 275.881, 1.01229, 7200, 49890),
|
||||
(135934, 17644, 0, 0, 532, 3457, 3457, 1, 1, -10924.4, -2005.02, 275.794, 6.05629, 7200, 49890),
|
||||
(135921, 17645, 0, 0, 532, 3457, 3457, 1, 1, -10893.5107421875, -2081.342041015625, 342.29364013671875, 5.183627605438232421, 7200, 49890),
|
||||
(135922, 17645, 0, 0, 532, 3457, 3457, 1, 1, -10833.099609375, -2151.580810546875, 380.8603515625, 4.625122547149658203, 7200, 49890);
|
||||
@@ -47,11 +47,13 @@ enum Spells
|
||||
|
||||
enum creatures
|
||||
{
|
||||
NPC_NETHERSPITE_INFERNAL = 17646,
|
||||
NPC_MALCHEZARS_AXE = 17650,
|
||||
INFERNAL_MODEL_INVISIBLE = 11686,
|
||||
SPELL_INFERNAL_RELAY = 33814, // 30835,
|
||||
EQUIP_ID_AXE = 33542
|
||||
NPC_NETHERSPITE_INFERNAL = 17646,
|
||||
NPC_MALCHEZAARS_AXE = 17650,
|
||||
INFERNAL_MODEL_INVISIBLE = 11686,
|
||||
SPELL_INFERNAL_RELAY = 33814, // 30835,
|
||||
SPELL_INFERNAL_RELAY_ONE = 30834,
|
||||
SPELL_INFERNAL_RELAY_TWO = 30835,
|
||||
EQUIP_ID_AXE = 33542
|
||||
};
|
||||
|
||||
enum EventGroups
|
||||
@@ -68,44 +70,19 @@ enum Phases
|
||||
PHASE_THREE = 3
|
||||
};
|
||||
|
||||
struct InfernalPoint
|
||||
{
|
||||
float x, y;
|
||||
};
|
||||
|
||||
#define INFERNAL_Z 275.5f
|
||||
|
||||
/*static InfernalPoint InfernalPoints[] =
|
||||
{
|
||||
{ -10922.8f, -1985.2f },
|
||||
{ -10916.2f, -1996.2f },
|
||||
{ -10932.2f, -2008.1f },
|
||||
{ -10948.8f, -2022.1f },
|
||||
{ -10958.7f, -1997.7f },
|
||||
{ -10971.5f, -1997.5f },
|
||||
{ -10990.8f, -1995.1f },
|
||||
{ -10989.8f, -1976.5f },
|
||||
{ -10971.6f, -1973.0f },
|
||||
{ -10955.5f, -1974.0f },
|
||||
{ -10939.6f, -1969.8f },
|
||||
{ -10958.0f, -1952.2f },
|
||||
{ -10941.7f, -1954.8f },
|
||||
{ -10943.1f, -1988.5f },
|
||||
{ -10948.8f, -2005.1f },
|
||||
{ -10984.0f, -2019.3f },
|
||||
{ -10932.8f, -1979.6f },
|
||||
{ -10935.7f, -1996.0f }
|
||||
};*/
|
||||
|
||||
struct boss_malchezaar : public BossAI
|
||||
{
|
||||
boss_malchezaar(Creature* creature) : BossAI(creature, DATA_MALCHEZZAR) { }
|
||||
boss_malchezaar(Creature* creature) : BossAI(creature, DATA_MALCHEZAAR) { }
|
||||
|
||||
std::list<Creature*> relays;
|
||||
std::list<Creature*> infernalTargets;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
_phase = 1;
|
||||
clearweapons();
|
||||
positions.clear();
|
||||
relays.clear();
|
||||
infernalTargets.clear();
|
||||
instance->HandleGameObject(instance->GetGuidData(DATA_GO_NETHER_DOOR), true);
|
||||
}
|
||||
|
||||
@@ -145,7 +122,7 @@ struct boss_malchezaar : public BossAI
|
||||
_phase = PHASE_THREE;
|
||||
clearweapons();
|
||||
|
||||
me->SummonCreature(NPC_MALCHEZARS_AXE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
|
||||
me->SummonCreature(NPC_MALCHEZAARS_AXE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
|
||||
|
||||
scheduler.Schedule(20s, 30s, [this](TaskContext context)
|
||||
{
|
||||
@@ -174,10 +151,48 @@ struct boss_malchezaar : public BossAI
|
||||
instance->HandleGameObject(instance->GetGuidData(DATA_GO_NETHER_DOOR), true);
|
||||
}
|
||||
|
||||
void SpawnInfernal(Creature* relay, Creature* target)
|
||||
{
|
||||
if (Creature* infernal = relay->SummonCreature(NPC_NETHERSPITE_INFERNAL, target->GetPosition(), TEMPSUMMON_TIMED_DESPAWN, 180000))
|
||||
{
|
||||
infernal->SetDisplayId(INFERNAL_MODEL_INVISIBLE);
|
||||
relay->CastSpell(target, SPELL_INFERNAL_RELAY_TWO);
|
||||
relay->CastSpell(infernal, SPELL_INFERNAL_RELAY);
|
||||
infernal->SetFaction(me->GetFaction());
|
||||
infernal->SetControlled(true, UNIT_STATE_ROOT);
|
||||
relay->CastSpell(infernal, SPELL_INFERNAL_RELAY);
|
||||
summons.Summon(infernal);
|
||||
}
|
||||
}
|
||||
|
||||
bool MaxSpawns(std::list<Creature*> spawns)
|
||||
{
|
||||
return spawns.size() == 0;
|
||||
}
|
||||
|
||||
Creature* PickTarget(std::list<Creature*> pickList)
|
||||
{
|
||||
uint8 index = urand(0, pickList.size()-1);
|
||||
uint8 counter = 0;
|
||||
for (Creature* creature : pickList)
|
||||
{
|
||||
if (counter == index)
|
||||
{
|
||||
return creature;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void JustEngagedWith(Unit* /*who*/) override
|
||||
{
|
||||
Talk(SAY_AGGRO);
|
||||
_JustEngagedWith();
|
||||
|
||||
me->GetCreaturesWithEntryInRange(relays, 250.0f, NPC_INFERNAL_RELAY);
|
||||
me->GetCreaturesWithEntryInRange(infernalTargets, 100.0f, NPC_INFERNAL_TARGET);
|
||||
|
||||
instance->HandleGameObject(instance->GetGuidData(DATA_GO_NETHER_DOOR), false);
|
||||
|
||||
scheduler.Schedule(30s, [this](TaskContext context)
|
||||
@@ -199,23 +214,30 @@ struct boss_malchezaar : public BossAI
|
||||
context.Repeat();
|
||||
}).Schedule(40s, [this](TaskContext context)
|
||||
{
|
||||
Position pos = me->GetRandomNearPosition(40.0);;
|
||||
|
||||
if (Creature* RELAY = me->FindNearestCreature(NPC_RELAY, 100.0f))
|
||||
if (!MaxSpawns(infernalTargets)) // only spawn infernal when the area is not full
|
||||
{
|
||||
if (Creature* infernal = RELAY->SummonCreature(NPC_NETHERSPITE_INFERNAL, pos, TEMPSUMMON_TIMED_DESPAWN, 180000))
|
||||
Talk(SAY_SUMMON);
|
||||
if (Creature* infernalRelayOne = relays.back())
|
||||
{
|
||||
infernal->SetDisplayId(INFERNAL_MODEL_INVISIBLE);
|
||||
infernal->SetFaction(me->GetFaction());
|
||||
infernal->SetControlled(true, UNIT_STATE_ROOT);
|
||||
RELAY->AI()->DoCast(infernal, SPELL_INFERNAL_RELAY);
|
||||
summons.Summon(infernal);
|
||||
if (Creature* infernalRelayTwo = relays.front())
|
||||
{
|
||||
infernalRelayOne->CastSpell(infernalRelayTwo, SPELL_INFERNAL_RELAY_ONE, true);
|
||||
|
||||
if (Creature* infernalTarget = PickTarget(infernalTargets))
|
||||
{
|
||||
infernalTargets.remove(infernalTarget);
|
||||
SpawnInfernal(infernalRelayTwo, infernalTarget);
|
||||
|
||||
scheduler.Schedule(3min, [this, infernalTarget](TaskContext)
|
||||
{
|
||||
infernalTargets.push_back(infernalTarget); //adds to list again
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.Repeat(_phase == PHASE_THREE ? 15s : 45s);
|
||||
|
||||
Talk(SAY_SUMMON);
|
||||
}).Schedule(20s, [this](TaskContext context)
|
||||
{
|
||||
DoCastVictim(SPELL_SHADOW_WORD_PAIN);
|
||||
@@ -261,7 +283,6 @@ struct boss_malchezaar : public BossAI
|
||||
private:
|
||||
uint32 _phase;
|
||||
std::map<ObjectGuid, uint32> _enfeebleTargets;
|
||||
std::vector<InfernalPoint*> positions;
|
||||
};
|
||||
|
||||
struct npc_netherspite_infernal : public ScriptedAI
|
||||
|
||||
@@ -37,7 +37,7 @@ enum KZDataTypes
|
||||
DATA_TERESTIAN = 7,
|
||||
DATA_NETHERSPITE = 8,
|
||||
DATA_CHESS_EVENT = 9,
|
||||
DATA_MALCHEZZAR = 10,
|
||||
DATA_MALCHEZAAR = 10,
|
||||
DATA_NIGHTBANE = 11,
|
||||
DATA_SERVANT_QUARTERS = 12,
|
||||
DATA_OPERA_OZ_DEATHCOUNT = 13,
|
||||
@@ -132,7 +132,12 @@ enum KZCreatures
|
||||
NPC_ROOK_A = 21160,
|
||||
NPC_KING_H = 21752,
|
||||
NPC_KING_A = 21684,
|
||||
NPC_CHESS_EVENT_MEDIVH_CHEAT_FIRES = 22521
|
||||
NPC_CHESS_EVENT_MEDIVH_CHEAT_FIRES = 22521,
|
||||
|
||||
// Malchezaar Helpers
|
||||
NPC_INFERNAL_TARGET = 17644,
|
||||
NPC_INFERNAL_RELAY = 17645
|
||||
|
||||
};
|
||||
|
||||
enum KZGameObjectIds
|
||||
|
||||
Reference in New Issue
Block a user