*Merge from Mangos. Add MapReference. Author: hunuza.

*Also re-commit the patches reverted in 255.

--HG--
branch : trunk
This commit is contained in:
megamage
2008-11-18 19:40:06 -06:00
parent 78f343397c
commit ea68727d27
39 changed files with 949 additions and 760 deletions
+19 -7
View File
@@ -679,13 +679,11 @@ void ScriptedAI::DoZoneInCombat(Unit* pUnit)
return;
}
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
InstanceMap::PlayerList::const_iterator i;
for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if((*i)->isAlive())
pUnit->AddThreat(*i, 0.0f);
}
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())
pUnit->AddThreat(i_pl, 0.0f);
}
void ScriptedAI::DoResetThreat()
@@ -721,6 +719,20 @@ void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float
((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
}
void ScriptedAI::DoTeleportAll(float x, float y, float z, float o)
{
Map *map = m_creature->GetMap();
if (!map->IsDungeon())
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())
i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
}
Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
{
CellPair p(Trinity::ComputeCellPair(m_creature->GetPositionX(), m_creature->GetPositionY()));
@@ -146,6 +146,7 @@ struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI
//Teleports a player without dropping threat (only teleports to same map)
void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o);
void DoTeleportAll(float x, float y, float z, float o);
//Returns friendly unit with the most amount of hp missing from max hp
Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff = 1);
@@ -220,18 +220,7 @@ struct TRINITY_DLL_DECL boss_grandmaster_vorpilAI : public ScriptedAI
if ( DrawnShadows_Timer < diff)
{
Map *map = m_creature->GetMap();
if(map->IsDungeon())
{
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if((*i)->isAlive())
{
(*i)->TeleportTo(555,VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0);
}
}
}
DoTeleportAll(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0);
m_creature->Relocate(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0);
DoCast(m_creature,SPELL_DRAWN_SHADOWS,true);
@@ -250,12 +250,12 @@ struct TRINITY_DLL_DECL boss_lady_vashjAI : public ScriptedAI
{
//remove old tainted cores to prevent cheating in phase 2
Map *map = m_creature->GetMap();
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
Map::PlayerList const &PlayerList = map->GetPlayers();
for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
{
if((*i))
if(Player* i_pl = i->getSource())
{
(*i)->DestroyItemCount(31088, 1, true);
i_pl->DestroyItemCount(31088, 1, true);
}
}
}
@@ -754,19 +754,22 @@ struct TRINITY_DLL_DECL mob_greyheart_spellbinderAI : public ScriptedAI
if(Earthshock_Timer < diff)
{
Map *map = m_creature->GetMap();
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
for(InstanceMap::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr)
Map::PlayerList const &PlayerList = map->GetPlayers();
for(Map::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr)
{
bool isCasting = false;
for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
if((*itr)->m_currentSpells[i])
isCasting = true;
if(isCasting)
{
DoCast((*itr), SPELL_EARTHSHOCK);
break;
}
if (Player* i_pl = itr->getSource())
{
bool isCasting = false;
for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
if(i_pl->m_currentSpells[i])
isCasting = true;
if(isCasting)
{
DoCast(i_pl, SPELL_EARTHSHOCK);
break;
}
}
}
Earthshock_Timer = 8000 + rand()%7000;
}else Earthshock_Timer -= diff;
@@ -118,9 +118,6 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
void SetData(uint32 type, uint32 data)
{
Player *player = GetPlayer();
if(!player) return;
switch(type)
{
case DATA_MAGTHERIDON_EVENT:
@@ -129,7 +126,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
RespawnTimer = 10000;
if(data != IN_PROGRESS)
{
if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID))
if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
Door->SetGoState(0);
}
break;
@@ -142,7 +139,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
Encounters[1] = NOT_STARTED;
for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
{
if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i))
if(Creature *Channeler = instance->GetCreatureInMap(*i))
{
if(Channeler->isAlive())
Channeler->AI()->EnterEvadeMode();
@@ -151,7 +148,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
}
}
CageTimer = 0;
if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID))
if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
Door->SetGoState(0);
}break;
case IN_PROGRESS: // Event start.
@@ -161,7 +158,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
// Let all five channelers aggro.
for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
{
Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i);
Creature *Channeler = instance->GetCreatureInMap(*i);
if(Channeler && Channeler->isAlive())
{
//if(Unit *target = Channeler->SelectNearbyTarget())
@@ -170,19 +167,19 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
}
}
// Release Magtheridon after two minutes.
Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID);
Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID);
if(Magtheridon && Magtheridon->isAlive())
{
Magtheridon->TextEmote("'s bonds begin to weaken!", 0);
CageTimer = 120000;
}
if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID))
if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
Door->SetGoState(1);
}break;
case DONE: // Add buff and check if all channelers are dead.
for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
{
Unit *Channeler = Unit::GetUnit(*player, *i);
Creature *Channeler = instance->GetCreatureInMap(*i);
if(Channeler && Channeler->isAlive())
{
//Channeler->CastSpell(Channeler, SPELL_SOUL_TRANSFER, true);
@@ -197,7 +194,7 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
// true - collapse / false - reset
for(std::set<uint64>::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i)
{
if(GameObject *Column = GameObject::GetGameObject(*player, *i))
if(GameObject *Column = instance->GetGameObjectInMap(*i))
Column->SetGoState(!data);
}
break;
@@ -213,30 +210,26 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
return 0;
}
Player* GetPlayer()
{
if(((InstanceMap*)instance)->GetPlayers().size())
return ((InstanceMap*)instance)->GetPlayers().front();
return NULL;
}
void AttackNearestTarget(Creature *creature)
{
float minRange = 999.0f;
float range;
Player* target = NULL;
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)instance)->GetPlayers();
InstanceMap::PlayerList::const_iterator i;
Map::PlayerList const &PlayerList = instance->GetPlayers();
Map::PlayerList::const_iterator i;
for(i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if((*i)->isTargetableForAttack())
if(Player* i_pl = i->getSource())
{
range = (*i)->GetDistance(creature);
if(range < minRange)
if(i_pl->isTargetableForAttack())
{
minRange = range;
target = *i;
}
range = i_pl->GetDistance(creature);
if(range < minRange)
{
minRange = range;
target = i_pl;
}
}
}
}
creature->AI()->AttackStart(target);
@@ -248,14 +241,11 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
{
if(CageTimer <= diff)
{
if(Player *player = GetPlayer())
Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID);
if(Magtheridon && Magtheridon->isAlive())
{
Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID);
if(Magtheridon && Magtheridon->isAlive())
{
Magtheridon->clearUnitState(UNIT_STAT_STUNNED);
AttackNearestTarget(Magtheridon);
}
Magtheridon->clearUnitState(UNIT_STAT_STUNNED);
AttackNearestTarget(Magtheridon);
}
CageTimer = 0;
}else CageTimer -= diff;
@@ -265,17 +255,14 @@ struct TRINITY_DLL_DECL instance_magtheridons_lair : public ScriptedInstance
{
if(RespawnTimer <= diff)
{
if(Player *player = GetPlayer())
for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
{
for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
if(Creature *Channeler = instance->GetCreatureInMap(*i))
{
if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i))
{
if(Channeler->isAlive())
Channeler->AI()->EnterEvadeMode();
else
Channeler->Respawn();
}
if(Channeler->isAlive())
Channeler->AI()->EnterEvadeMode();
else
Channeler->Respawn();
}
}
RespawnTimer = 0;
@@ -285,18 +285,18 @@ struct TRINITY_DLL_DECL npc_barnesAI : public npc_escortAI
Map *map = m_creature->GetMap();
if(!map->IsDungeon()) return;
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
if(PlayerList.empty())
Map::PlayerList const &PlayerList = map->GetPlayers();
if(PlayerList.isEmpty())
return;
RaidWiped = true;
for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
{
if((*i)->isAlive() && !(*i)->isGameMaster())
{
RaidWiped = false;
break;
}
for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
{
if (i->getSource()->isAlive() && !i->getSource()->isGameMaster())
{
RaidWiped = false;
break;
}
}
if(RaidWiped)
@@ -231,17 +231,17 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
float x,y,z;
m_creature->Relocate(KaelLocations[0][0], KaelLocations[0][1], LOCATION_Z, 0);
Map *map = m_creature->GetMap();
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
InstanceMap::PlayerList::const_iterator i;
Map::PlayerList const &PlayerList = map->GetPlayers();
Map::PlayerList::const_iterator i;
for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
//if(!(*i)->isGameMaster())
if((*i) && (*i)->isAlive())
{
(*i)->CastSpell((*i), SPELL_TELEPORT_CENTER, true);
m_creature->GetNearPoint(m_creature,x,y,z,5,5,0);
(*i)->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,(*i)->GetOrientation());
}
if (Player* i_pl = i->getSource())
if(i_pl->isAlive())
{
i_pl->CastSpell(i_pl, SPELL_TELEPORT_CENTER, true);
m_creature->GetNearPoint(m_creature,x,y,z,5,5,0);
i_pl->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,i_pl->GetOrientation());
}
}
DoCast(m_creature, SPELL_TELEPORT_CENTER, true);
}
@@ -249,34 +249,38 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
void CastGravityLapseKnockUp()
{
Map *map = m_creature->GetMap();
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
InstanceMap::PlayerList::const_iterator i;
Map::PlayerList const &PlayerList = map->GetPlayers();
Map::PlayerList::const_iterator i;
for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if((*i) && (*i)->isAlive())
{
if (Player* i_pl = i->getSource())
if(i_pl->isAlive())
// Knockback into the air
(*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID());
i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID());
}
}
void CastGravityLapseFly() // Use Fly Packet hack for now as players can't cast "fly" spells unless in map 530. Has to be done a while after they get knocked into the air...
{
Map *map = m_creature->GetMap();
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
InstanceMap::PlayerList::const_iterator i;
Map::PlayerList const &PlayerList = map->GetPlayers();
Map::PlayerList::const_iterator i;
for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if((*i) && (*i)->isAlive())
{
if (Player* i_pl = i->getSource())
{
// Also needs an exception in spell system.
(*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID());
// Use packet hack
WorldPacket data(12);
data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
data.append((*i)->GetPackGUID());
data << uint32(0);
(*i)->SendMessageToSet(&data, true);
(*i)->SetSpeed(MOVE_FLY, 2.0f);
if(i_pl->isAlive())
{
// Also needs an exception in spell system.
i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID());
// Use packet hack
WorldPacket data(12);
data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
data.append(i_pl->GetPackGUID());
data << uint32(0);
i_pl->SendMessageToSet(&data, true);
i_pl->SetSpeed(MOVE_FLY, 2.0f);
}
}
}
}
@@ -284,19 +288,19 @@ struct TRINITY_DLL_DECL boss_felblood_kaelthasAI : public ScriptedAI
void RemoveGravityLapse()
{
Map *map = m_creature->GetMap();
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
InstanceMap::PlayerList::const_iterator i;
Map::PlayerList const &PlayerList = map->GetPlayers();
Map::PlayerList::const_iterator i;
for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if((*i))
if(Player* i_pl = i->getSource())
{
(*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY);
(*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT);
i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY);
i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT);
WorldPacket data(12);
data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY);
data.append((*i)->GetPackGUID());
data.append(i_pl->GetPackGUID());
data << uint32(0);
(*i)->SendMessageToSet(&data, true);
i_pl->SendMessageToSet(&data, true);
}
}
}
@@ -295,7 +295,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
Timer[EVENT_FLIGHT_SEQUENCE] = 0;
break;
case 2:
if(Player* target = SelectRandomPlayer(150))
if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
{
Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
if(Vapor)
@@ -311,7 +311,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
case 3:
DespawnSummons(MOB_VAPOR_TRAIL);
//m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support
if(Player* target = SelectRandomPlayer(150))
if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
{
//target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support
Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
@@ -330,7 +330,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
Timer[EVENT_FLIGHT_SEQUENCE] = 1;
break;
case 5:
if(Player* target = SelectRandomPlayer(150))
if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
{
BreathX = target->GetPositionX();
BreathY = target->GetPositionY();
@@ -433,7 +433,7 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
Timer[EVENT_GAS_NOVA] = 20000 + rand()%5 * 1000;
break;
case EVENT_ENCAPSULATE:
if(Unit* target = SelectRandomPlayer(150))
if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
{
m_creature->CastSpell(target, SPELL_ENCAPSULATE_CHANNEL, false);
target->CastSpell(target, SPELL_ENCAPSULATE_EFFECT, true);// linked aura, need core patch to remove this hack
@@ -515,26 +515,6 @@ struct TRINITY_DLL_DECL boss_felmystAI : public ScriptedAI
(*i)->RemoveCorpse();
}
}
Player* SelectRandomPlayer(float range = 0.0f)
{
Map *map = m_creature->GetMap();
if (!map->IsDungeon()) return NULL;
InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers();
InstanceMap::PlayerList::iterator i;
while(PlayerList.size())
{
i = PlayerList.begin();
advance(i, rand()%PlayerList.size());
if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range))
&& (*i)->isTargetableForAttack())
return *i;
else
PlayerList.erase(i);
}
return NULL;
}
};
struct TRINITY_DLL_DECL mob_felmyst_vaporAI : public ScriptedAI
@@ -368,13 +368,12 @@ struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI
{
Map *map = m_creature->GetMap();
if(!map->IsDungeon()) return;
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
InstanceMap::PlayerList::const_iterator i;
for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if((*i)->HasAura(AURA_SPECTRAL_REALM,0))
(*i)->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM);
}
Map::PlayerList const &PlayerList = map->GetPlayers();
Map::PlayerList::const_iterator i;
for(i = PlayerList.begin(); i != PlayerList.end(); ++i)
if(Player* i_pl = i->getSource())
if(i_pl->HasAura(AURA_SPECTRAL_REALM,0))
i_pl->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM);
}
void Enrage(); // demon and dragon should enrage at the same time
@@ -577,20 +577,23 @@ struct TRINITY_DLL_DECL cthunAI : public Scripted_NoMovementAI
Map *map = m_creature->GetMap();
if(!map->IsDungeon()) return;
InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
Map::PlayerList const &PlayerList = map->GetPlayers();
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
//Play random sound to the zone
switch (rand()%8)
if (Player* i_pl = i->getSource())
{
case 0: (*i)->SendPlaySound(RND_WISPER_1, true); break;
case 1: (*i)->SendPlaySound(RND_WISPER_2, true); break;
case 2: (*i)->SendPlaySound(RND_WISPER_3, true); break;
case 3: (*i)->SendPlaySound(RND_WISPER_4, true); break;
case 4: (*i)->SendPlaySound(RND_WISPER_5, true); break;
case 5: (*i)->SendPlaySound(RND_WISPER_6, true); break;
case 6: (*i)->SendPlaySound(RND_WISPER_7, true); break;
case 7: (*i)->SendPlaySound(RND_WISPER_8, true); break;
//Play random sound to the zone
switch (rand()%8)
{
case 0: i_pl->SendPlaySound(RND_WISPER_1, true); break;
case 1: i_pl->SendPlaySound(RND_WISPER_2, true); break;
case 2: i_pl->SendPlaySound(RND_WISPER_3, true); break;
case 3: i_pl->SendPlaySound(RND_WISPER_4, true); break;
case 4: i_pl->SendPlaySound(RND_WISPER_5, true); break;
case 5: i_pl->SendPlaySound(RND_WISPER_6, true); break;
case 6: i_pl->SendPlaySound(RND_WISPER_7, true); break;
case 7: i_pl->SendPlaySound(RND_WISPER_8, true); break;
}
}
}
@@ -371,7 +371,7 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
if(SiphonSoul_Timer < diff)
{
Player* target = SelectRandomPlayer(50);
Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 70, true);
Unit *trigger = DoSpawnCreature(MOB_TEMP_TRIGGER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
if(!target || !trigger) EnterEvadeMode();
else
@@ -435,26 +435,6 @@ struct TRINITY_DLL_DECL boss_hex_lord_malacrassAI : public ScriptedAI
}
m_creature->CastSpell(target, PlayerAbility[PlayerClass][random].spell, false);
}
Player* SelectRandomPlayer(float range = 0.0f, bool alive = true)
{
Map *map = m_creature->GetMap();
if (!map->IsDungeon()) return NULL;
InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers();
InstanceMap::PlayerList::iterator i;
while(PlayerList.size())
{
i = PlayerList.begin();
advance(i, rand()%PlayerList.size());
if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range))
&& (!alive || (*i)->isAlive()))
return *i;
else
PlayerList.erase(i);
}
return NULL;
}
};
#define SPELL_BLOODLUST 43578
@@ -397,11 +397,12 @@ struct TRINITY_DLL_DECL boss_janalaiAI : public ScriptedAI
//Teleport every Player into the middle
Map *map = m_creature->GetMap();
if(!map->IsDungeon()) return;
InstanceMap::PlayerList const &PlayerList =((InstanceMap*)map)->GetPlayers();
for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
Map::PlayerList const &PlayerList = map->GetPlayers();
for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{
if((*i)->isAlive())
DoTeleportPlayer(*i, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0);
if (Player* i_pl = i->getSource())
if(i_pl->isAlive())
DoTeleportPlayer(i_pl, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0);
}
//m_creature->CastSpell(Temp, SPELL_SUMMON_PLAYERS, true); // core bug, spell does not work if too far
return;
@@ -139,21 +139,28 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
void OpenDoor(uint64 DoorGUID, bool open)
{
if(((InstanceMap*)instance)->GetPlayers().size())
if(Player* first = ((InstanceMap*)instance)->GetPlayers().front())
if(GameObject *Door = GameObject::GetGameObject(*first, DoorGUID))
Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1);
if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1);
}
void SummonHostage(uint8 num)
{
if(QuestMinute && ((InstanceMap*)instance)->GetPlayers().size())
if(Player* first = ((InstanceMap*)instance)->GetPlayers().front())
if(Unit* Hostage = first->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0))
{
Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
}
if(!QuestMinute)
return;
Map::PlayerList const &PlayerList = instance->GetPlayers();
if (PlayerList.isEmpty())
return;
Map::PlayerList::const_iterator i = PlayerList.begin();
if(Player* i_pl = i->getSource())
{
if(Unit* Hostage = i_pl->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0))
{
Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
}
}
}
void CheckInstanceStatus()