Merge [SD2]

r1017 Remove no longer needed functions used in instance scripts. Some additional code cleanup.
r1018 Remove redundant calls to InterruptNonMeeleSpells() and use true in CombatStop() calls instead where needed.
r1019 Fixed: use correct isInFlight check for item 34475 - Skipp already implemented
r1020 Restore work of three scripts after recent changes in AI about AttackedBy(), also some additional code cleanup.

--HG--
branch : trunk
This commit is contained in:
Kudlaty
2009-06-17 03:35:23 +02:00
parent 5547366ce3
commit 3c502513b0
19 changed files with 163 additions and 283 deletions
@@ -115,7 +115,7 @@ void npc_escortAI::UpdateAI(const uint32 diff)
m_creature->setDeathState(JUST_DIED); m_creature->setDeathState(JUST_DIED);
m_creature->SetHealth(0); m_creature->SetHealth(0);
m_creature->CombatStop(); m_creature->CombatStop(true);
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->Respawn(); m_creature->Respawn();
m_creature->GetMotionMaster()->Clear(true); m_creature->GetMotionMaster()->Clear(true);
@@ -161,7 +161,7 @@ void npc_escortAI::UpdateAI(const uint32 diff)
m_creature->setDeathState(JUST_DIED); m_creature->setDeathState(JUST_DIED);
m_creature->SetHealth(0); m_creature->SetHealth(0);
m_creature->CombatStop(); m_creature->CombatStop(true);
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->Respawn(); m_creature->Respawn();
m_creature->GetMotionMaster()->Clear(true); m_creature->GetMotionMaster()->Clear(true);
@@ -92,23 +92,6 @@ struct TRINITY_DLL_DECL instance_shadow_labyrinth : public ScriptedInstance
} }
} }
Player* GetPlayerInMap()
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* plr = itr->getSource())
return plr;
}
}
debug_log("TSCR: Instance Shadow Labyrinth: GetPlayerInMap, but PlayerList is empty!");
return NULL;
}
void SetData(uint32 type, uint32 data) void SetData(uint32 type, uint32 data)
{ {
switch(type) switch(type)
@@ -159,7 +159,7 @@ struct TRINITY_DLL_DECL npc_draenei_survivorAI : public ScriptedAI
m_creature->GetMotionMaster()->MoveIdle(); m_creature->GetMotionMaster()->MoveIdle();
m_creature->setDeathState(JUST_DIED); m_creature->setDeathState(JUST_DIED);
m_creature->SetHealth(0); m_creature->SetHealth(0);
m_creature->CombatStop(); m_creature->CombatStop(true);
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->RemoveCorpse(); m_creature->RemoveCorpse();
}else RunAwayTimer -= diff; }else RunAwayTimer -= diff;
@@ -593,7 +593,7 @@ struct TRINITY_DLL_DECL npc_nestlewood_owlkinAI : public ScriptedAI
m_creature->SetVisibility(VISIBILITY_OFF); m_creature->SetVisibility(VISIBILITY_OFF);
m_creature->setDeathState(JUST_DIED); m_creature->setDeathState(JUST_DIED);
m_creature->SetHealth(0); m_creature->SetHealth(0);
m_creature->CombatStop(); m_creature->CombatStop(true);
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->RemoveCorpse(); m_creature->RemoveCorpse();
}else DespawnTimer -= diff; }else DespawnTimer -= diff;
@@ -120,7 +120,7 @@ struct TRINITY_DLL_DECL npc_taskmaster_fizzuleAI : public ScriptedAI
{ {
m_creature->RemoveAllAuras(); m_creature->RemoveAllAuras();
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->CombatStop(); m_creature->CombatStop(true);
m_creature->StopMoving(); m_creature->StopMoving();
m_creature->GetMotionMaster()->MoveIdle(); m_creature->GetMotionMaster()->MoveIdle();
@@ -1037,10 +1037,9 @@ struct TRINITY_DLL_DECL npc_akama_illidanAI : public ScriptedAI
// Do not call reset in Akama's evade mode, as this will stop him from summoning minions after he kills the first bit // Do not call reset in Akama's evade mode, as this will stop him from summoning minions after he kills the first bit
void EnterEvadeMode() void EnterEvadeMode()
{ {
m_creature->InterruptNonMeleeSpells(true);
m_creature->RemoveAllAuras(); m_creature->RemoveAllAuras();
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->CombatStop(); m_creature->CombatStop(true);
} }
void EnterCombat(Unit *who) {} void EnterCombat(Unit *who) {}
@@ -257,19 +257,14 @@ struct TRINITY_DLL_DECL boss_shade_of_akamaAI : public ScriptedAI
{ {
Channeler->RemoveCorpse(); Channeler->RemoveCorpse();
Channeler->Respawn(); Channeler->Respawn();
Channeler->InterruptNonMeleeSpells(true);
Channeler->RemoveAurasDueToSpell(SPELL_SHADE_SOUL_CHANNEL);
} }
if (Channeler->isAlive())
{
Channeler->CastSpell(m_creature, SPELL_SHADE_SOUL_CHANNEL, true); Channeler->CastSpell(m_creature, SPELL_SHADE_SOUL_CHANNEL, true);
Channeler->CastSpell(m_creature, SPELL_SHADE_SOUL_CHANNEL_2, true); Channeler->CastSpell(m_creature, SPELL_SHADE_SOUL_CHANNEL_2, true);
Channeler->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); Channeler->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
GridSearcherSucceeded = true; GridSearcherSucceeded = true;
} }
} }
}
}else error_log("SD2 ERROR: No Channelers are stored in the list. This encounter will not work properly"); }else error_log("SD2 ERROR: No Channelers are stored in the list. This encounter will not work properly");
} }
} }
@@ -114,23 +114,6 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
Encounter[i] = NOT_STARTED; Encounter[i] = NOT_STARTED;
} }
Player* GetPlayerInMap()
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* plr = itr->getSource())
return plr;
}
}
debug_log("TSCR: Instance Blackrock Depths: GetPlayerInMap, but PlayerList is empty!");
return NULL;
}
void OnCreatureCreate(Creature *creature, bool add) void OnCreatureCreate(Creature *creature, bool add)
{ {
switch(creature->GetEntry()) switch(creature->GetEntry())
@@ -166,14 +149,6 @@ struct TRINITY_DLL_DECL instance_blackrock_depths : public ScriptedInstance
void SetData(uint32 type, uint32 data) void SetData(uint32 type, uint32 data)
{ {
Player *player = GetPlayerInMap();
if (!player)
{
debug_log("TSCR: Instance Blackrock Depths: SetData (Type: %u Data %u) cannot find any player.", type, data);
return;
}
debug_log("TSCR: Instance Blackrock Depths: SetData update (Type: %u Data %u)", type, data); debug_log("TSCR: Instance Blackrock Depths: SetData update (Type: %u Data %u)", type, data);
switch(type) switch(type)
@@ -95,23 +95,6 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
NextPortal_Timer = 0; NextPortal_Timer = 0;
} }
Player* GetPlayerInMap()
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* plr = itr->getSource())
return plr;
}
}
debug_log("TSCR: Instance Black Portal: GetPlayerInMap, but PlayerList is empty!");
return NULL;
}
void UpdateBMWorldState(uint32 id, uint32 state) void UpdateBMWorldState(uint32 id, uint32 state)
{ {
Map::PlayerList const& players = instance->GetPlayers(); Map::PlayerList const& players = instance->GetPlayers();
@@ -158,7 +141,7 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
//what other conditions to check? //what other conditions to check?
bool CanProgressEvent() bool CanProgressEvent()
{ {
if (!GetPlayerInMap()) if (instance->GetPlayers().isEmpty())
return false; return false;
return true; return true;
@@ -183,14 +166,6 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
void SetData(uint32 type, uint32 data) void SetData(uint32 type, uint32 data)
{ {
Player *player = GetPlayerInMap();
if (!player)
{
debug_log("TSCR: Instance Black Portal: SetData (Type: %u Data %u) cannot find any player.", type, data);
return;
}
switch(type) switch(type)
{ {
case TYPE_MEDIVH: case TYPE_MEDIVH:
@@ -201,11 +176,11 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
if (!mShieldPercent) if (!mShieldPercent)
{ {
if (Unit *medivh = Unit::GetUnit(*player,MedivhGUID)) if (Creature* pMedivh = instance->GetCreature(MedivhGUID))
{ {
if (medivh->isAlive()) if (pMedivh->isAlive())
{ {
medivh->DealDamage(medivh, medivh->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); pMedivh->DealDamage(pMedivh, pMedivh->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
Encounter[0] = FAIL; Encounter[0] = FAIL;
Encounter[1] = NOT_STARTED; Encounter[1] = NOT_STARTED;
} }
@@ -225,11 +200,22 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
if (data == DONE) if (data == DONE)
{ {
//this may be completed further out in the post-event //this may be completed further out in the post-event
if (Unit *medivh = Unit::GetUnit(*player,MedivhGUID))
{
debug_log("TSCR: Instance Dark Portal: Event completed."); debug_log("TSCR: Instance Dark Portal: Event completed.");
player->GroupEventHappens(QUEST_OPENING_PORTAL,medivh); Map::PlayerList const& players = instance->GetPlayers();
player->GroupEventHappens(QUEST_MASTER_TOUCH,medivh);
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
{
if (pPlayer->GetQuestStatus(QUEST_OPENING_PORTAL) == QUEST_STATUS_INCOMPLETE)
pPlayer->AreaExploredOrEventHappens(QUEST_OPENING_PORTAL);
if (pPlayer->GetQuestStatus(QUEST_MASTER_TOUCH) == QUEST_STATUS_INCOMPLETE)
pPlayer->AreaExploredOrEventHappens(QUEST_MASTER_TOUCH);
}
}
} }
} }
@@ -272,24 +258,25 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
return 0; return 0;
} }
Unit* SummonedPortalBoss(Unit* source) Creature* SummonedPortalBoss(Creature* pSource)
{ {
uint32 entry = RiftWaves[GetRiftWaveId()].PortalBoss; uint32 entry = RiftWaves[GetRiftWaveId()].PortalBoss;
if (entry == RIFT_BOSS) if (entry == RIFT_BOSS)
entry = RandRiftBoss(); entry = RandRiftBoss();
float x,y,z; float x,y,z;
source->GetRandomPoint(source->GetPositionX(),source->GetPositionY(),source->GetPositionZ(),10.0f,x,y,z); pSource->GetRandomPoint(pSource->GetPositionX(),pSource->GetPositionY(),pSource->GetPositionZ(),10.0f,x,y,z);
//normalize Z-level if we can, if rift is not at ground level. //normalize Z-level if we can, if rift is not at ground level.
z = std::max(instance->GetHeight(x, y, MAX_HEIGHT), instance->GetWaterLevel(x, y)); z = std::max(instance->GetHeight(x, y, MAX_HEIGHT), instance->GetWaterLevel(x, y));
debug_log("TSCR: Instance Dark Portal: Summoning rift boss entry %u.",entry); debug_log("TSCR: Instance Dark Portal: Summoning rift boss entry %u.",entry);
Unit *Summon = source->SummonCreature(entry,x,y,z,source->GetOrientation(), Creature* pSummoned = pSource->SummonCreature(entry,x,y,z,pSource->GetOrientation(),
TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000); TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,600000);
if (Summon) if (pSummoned)
return Summon; return pSummoned;
debug_log("TSCR: Instance Dark Portal: what just happened there? No boss, no loot, no fun..."); debug_log("TSCR: Instance Dark Portal: what just happened there? No boss, no loot, no fun...");
return NULL; return NULL;
@@ -297,11 +284,7 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
void DoSpawnPortal() void DoSpawnPortal()
{ {
Player *player = GetPlayerInMap(); if (Creature* pMedivh = instance->GetCreature(MedivhGUID))
if (!player)
return;
if (Unit *medivh = Unit::GetUnit(*player,MedivhGUID))
{ {
int tmp = rand()%(4-1); int tmp = rand()%(4-1);
@@ -311,26 +294,26 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
CurrentRiftId = tmp; CurrentRiftId = tmp;
Unit *temp = medivh->SummonCreature(C_TIME_RIFT, Creature* pTemp = pMedivh->SummonCreature(C_TIME_RIFT,
PortalLocation[tmp][0],PortalLocation[tmp][1],PortalLocation[tmp][2],PortalLocation[tmp][3], PortalLocation[tmp][0],PortalLocation[tmp][1],PortalLocation[tmp][2],PortalLocation[tmp][3],
TEMPSUMMON_CORPSE_DESPAWN,0); TEMPSUMMON_CORPSE_DESPAWN,0);
if (temp) if (pTemp)
{ {
temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if (Unit* boss = SummonedPortalBoss(temp)) if (Creature* pBoss = SummonedPortalBoss(pTemp))
{ {
if (boss->GetEntry() == C_AEONUS) if (pBoss->GetEntry() == C_AEONUS)
{ {
boss->AddThreat(medivh,0.0f); pBoss->AddThreat(pMedivh,0.0f);
} }
else else
{ {
boss->AddThreat(temp,0.0f); pBoss->AddThreat(pTemp,0.0f);
temp->CastSpell(boss,SPELL_RIFT_CHANNEL,false); pTemp->CastSpell(pBoss,SPELL_RIFT_CHANNEL,false);
} }
} }
} }
@@ -409,11 +409,10 @@ void hyjalAI::Reset()
void hyjalAI::EnterEvadeMode() void hyjalAI::EnterEvadeMode()
{ {
m_creature->InterruptNonMeleeSpells(true);
if(m_creature->GetEntry() != JAINA) if(m_creature->GetEntry() != JAINA)
m_creature->RemoveAllAuras(); m_creature->RemoveAllAuras();
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->CombatStop(); m_creature->CombatStop(true);
m_creature->LoadCreaturesAddon(); m_creature->LoadCreaturesAddon();
if(m_creature->isAlive()) if(m_creature->isAlive())
@@ -88,23 +88,6 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
return false; return false;
} }
Player* GetPlayerInMap()
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* plr = itr->getSource())
return plr;
}
}
debug_log("TSCR: Instance Steamvault: GetPlayerInMap, but PlayerList is empty!");
return NULL;
}
void OnCreatureCreate(Creature *creature, bool add) void OnCreatureCreate(Creature *creature, bool add)
{ {
switch(creature->GetEntry()) switch(creature->GetEntry())
@@ -127,14 +110,6 @@ struct TRINITY_DLL_DECL instance_steam_vault : public ScriptedInstance
void SetData(uint32 type, uint32 data) void SetData(uint32 type, uint32 data)
{ {
Player *player = GetPlayerInMap();
if (!player)
{
debug_log("TSCR: Instance Steamvault: SetData (Type: %u Data %u) cannot find any player.", type, data);
return;
}
switch(type) switch(type)
{ {
case TYPE_HYDROMANCER_THESPIA: case TYPE_HYDROMANCER_THESPIA:
@@ -51,26 +51,7 @@ struct TRINITY_DLL_DECL instance_ramparts : public ScriptedInstance
} }
} }
Player* GetFirstPlayerInInstance()
{
Map::PlayerList const& pPlayers = instance->GetPlayers();
if (!pPlayers.isEmpty())
{
for(Map::PlayerList::const_iterator itr = pPlayers.begin(); itr != pPlayers.end(); ++itr)
{
if (Player* pPlr = itr->getSource())
return pPlr;
}
}
debug_log("TSCR: Instance Ramparts: GetFirstPlayerInInstance, but PlayerList is empty.");
return NULL;
}
void DoRespawnChest() void DoRespawnChest()
{
if (Player* pPlayer = GetFirstPlayerInInstance())
{ {
uint64 uiChest; uint64 uiChest;
@@ -87,7 +68,6 @@ struct TRINITY_DLL_DECL instance_ramparts : public ScriptedInstance
pGo->SetRespawnTime(HOUR*IN_MILISECONDS); pGo->SetRespawnTime(HOUR*IN_MILISECONDS);
} }
} }
}
void SetData(uint32 uiType, uint32 uiData) void SetData(uint32 uiType, uint32 uiData)
{ {
@@ -90,7 +90,7 @@ struct TRINITY_DLL_DECL npc_aeranasAI : public ScriptedAI
m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
m_creature->RemoveAllAuras(); m_creature->RemoveAllAuras();
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->CombatStop(); m_creature->CombatStop(true);
DoScriptText(SAY_FREE, m_creature); DoScriptText(SAY_FREE, m_creature);
return; return;
} }
@@ -1161,7 +1161,7 @@ void boss_julianneAI::DamageTaken(Unit* done_by, uint32 &damage)
Romulo->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); Romulo->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
Romulo->GetMotionMaster()->Clear(); Romulo->GetMotionMaster()->Clear();
Romulo->setDeathState(JUST_DIED); Romulo->setDeathState(JUST_DIED);
Romulo->CombatStop(); Romulo->CombatStop(true);
Romulo->DeleteThreatList(); Romulo->DeleteThreatList();
Romulo->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); Romulo->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
} }
@@ -1216,7 +1216,7 @@ void boss_romuloAI::DamageTaken(Unit* done_by, uint32 &damage)
Julianne->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); Julianne->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
Julianne->GetMotionMaster()->Clear(); Julianne->GetMotionMaster()->Clear();
Julianne->setDeathState(JUST_DIED); Julianne->setDeathState(JUST_DIED);
Julianne->CombatStop(); Julianne->CombatStop(true);
Julianne->DeleteThreatList(); Julianne->DeleteThreatList();
Julianne->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); Julianne->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
} }
@@ -109,6 +109,17 @@ struct TRINITY_DLL_DECL mob_lumpAI : public ScriptedAI
m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
} }
void AttackedBy(Unit* pAttacker)
{
if (m_creature->getVictim())
return;
if (m_creature->IsFriendlyTo(pAttacker))
return;
AttackStart(pAttacker);
}
void DamageTaken(Unit *done_by, uint32 & damage) void DamageTaken(Unit *done_by, uint32 & damage)
{ {
if (done_by->GetTypeId() == TYPEID_PLAYER && (m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 30) if (done_by->GetTypeId() == TYPEID_PLAYER && (m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 30)
@@ -122,7 +133,7 @@ struct TRINITY_DLL_DECL mob_lumpAI : public ScriptedAI
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
m_creature->RemoveAllAuras(); m_creature->RemoveAllAuras();
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->CombatStop(); m_creature->CombatStop(true);
m_creature->setFaction(1080); //friendly m_creature->setFaction(1080); //friendly
m_creature->SetStandState(UNIT_STAND_STATE_SIT); m_creature->SetStandState(UNIT_STAND_STATE_SIT);
DoScriptText(LUMP_DEFEAT, m_creature); DoScriptText(LUMP_DEFEAT, m_creature);
@@ -66,22 +66,6 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
Encounter[i] = NOT_STARTED; Encounter[i] = NOT_STARTED;
} }
Player* GetPlayerInMap()
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* plr = itr->getSource())
return plr;
}
}
debug_log("TSCR: Instance Shadowfang Keep: GetPlayerInMap, but PlayerList is empty!");
return NULL;
}
void OnCreatureCreate(Creature* pCreature, bool add) void OnCreatureCreate(Creature* pCreature, bool add)
{ {
switch(pCreature->GetEntry()) switch(pCreature->GetEntry())
@@ -115,12 +99,8 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
void DoSpeech() void DoSpeech()
{ {
Player* pPlayer = GetPlayerInMap(); Creature* pAda = instance->GetCreature(uiAdaGUID);
Creature* pAsh = instance->GetCreature(uiAshGUID);
if (pPlayer)
{
Unit* pAda = Unit::GetUnit(*pPlayer,uiAdaGUID);
Unit* pAsh = Unit::GetUnit(*pPlayer,uiAshGUID);
if (pAda && pAda->isAlive() && pAsh && pAsh->isAlive()) if (pAda && pAda->isAlive() && pAsh && pAsh->isAlive())
{ {
@@ -128,7 +108,6 @@ struct TRINITY_DLL_DECL instance_shadowfang_keep : public ScriptedInstance
DoScriptText(SAY_BOSS_DIE_AS,pAsh); DoScriptText(SAY_BOSS_DIE_AS,pAsh);
} }
} }
}
void SetData(uint32 type, uint32 data) void SetData(uint32 type, uint32 data)
{ {
@@ -64,58 +64,67 @@ bool GossipSelect_npc_archmage_malin(Player *player, Creature *_Creature, uint32
## npc_bartleby ## npc_bartleby
######*/ ######*/
enum
{
FACTION_ENEMY = 168,
QUEST_BEAT = 1640
};
struct TRINITY_DLL_DECL npc_bartlebyAI : public ScriptedAI struct TRINITY_DLL_DECL npc_bartlebyAI : public ScriptedAI
{ {
npc_bartlebyAI(Creature *c) : ScriptedAI(c) {} npc_bartlebyAI(Creature *c) : ScriptedAI(c)
{
m_uiNormalFaction = c->getFaction();
}
uint64 PlayerGUID; uint32 m_uiNormalFaction;
void Reset() void Reset()
{ {
m_creature->setFaction(11); if (m_creature->getFaction() != m_uiNormalFaction)
m_creature->setFaction(m_uiNormalFaction);
PlayerGUID = 0;
} }
void JustDied(Unit *who) void AttackedBy(Unit* pAttacker)
{ {
m_creature->setFaction(11); if (m_creature->getVictim())
return;
if (m_creature->IsFriendlyTo(pAttacker))
return;
AttackStart(pAttacker);
} }
void DamageTaken(Unit *done_by, uint32 & damage) void Aggro(Unit *who) { }
void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
{ {
if(damage > m_creature->GetHealth() || ((m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 15)) if (uiDamage > m_creature->GetHealth() || ((m_creature->GetHealth() - uiDamage)*100 / m_creature->GetMaxHealth() < 15))
{ {
//Take 0 damage //Take 0 damage
damage = 0; uiDamage = 0;
if (done_by->GetTypeId() == TYPEID_PLAYER && done_by->GetGUID() == PlayerGUID) if (pDoneBy->GetTypeId() == TYPEID_PLAYER)
{ ((Player*)pDoneBy)->AreaExploredOrEventHappens(QUEST_BEAT);
CAST_PLR(done_by)->AttackStop();
CAST_PLR(done_by)->AreaExploredOrEventHappens(1640);
}
m_creature->CombatStop();
EnterEvadeMode(); EnterEvadeMode();
} }
} }
void EnterCombat(Unit *who) {}
}; };
bool QuestAccept_npc_bartleby(Player *player, Creature *_Creature, Quest const *_Quest) bool QuestAccept_npc_bartleby(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
{ {
if(_Quest->GetQuestId() == 1640) if (pQuest->GetQuestId() == QUEST_BEAT)
{ {
_Creature->setFaction(168); pCreature->setFaction(FACTION_ENEMY);
CAST_AI(npc_bartlebyAI, _Creature->AI())->PlayerGUID = player->GetGUID(); ((npc_bartlebyAI*)pCreature->AI())->AttackStart(pPlayer);
CAST_AI(npc_bartlebyAI, _Creature->AI())->AttackStart(player);
} }
return true; return true;
} }
CreatureAI* GetAI_npc_bartleby(Creature *_creature) CreatureAI* GetAI_npc_bartleby(Creature* pCreature)
{ {
return new npc_bartlebyAI(_creature); return new npc_bartlebyAI(pCreature);
} }
/*###### /*######
@@ -130,31 +139,44 @@ enum
struct TRINITY_DLL_DECL npc_dashel_stonefistAI : public ScriptedAI struct TRINITY_DLL_DECL npc_dashel_stonefistAI : public ScriptedAI
{ {
npc_dashel_stonefistAI(Creature *c) : ScriptedAI(c) { uiNormFaction = c->getFaction(); } npc_dashel_stonefistAI(Creature *c) : ScriptedAI(c)
{
m_uiNormalFaction = c->getFaction();
}
uint32 uiNormFaction; uint32 m_uiNormalFaction;
void Reset() void Reset()
{ {
m_creature->setFaction(uiNormFaction); if (m_creature->getFaction() != m_uiNormalFaction)
m_creature->setFaction(m_uiNormalFaction);
} }
void DamageTaken(Unit *done_by, uint32 & damage) void AttackedBy(Unit* pAttacker)
{ {
if ((damage > m_creature->GetHealth()) || (m_creature->GetHealth() - damage)*100 / m_creature->GetMaxHealth() < 15) if (m_creature->getVictim())
return;
if (m_creature->IsFriendlyTo(pAttacker))
return;
AttackStart(pAttacker);
}
void Aggro(Unit *who) {}
void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
{ {
//Take 0 damage if (uiDamage > m_creature->GetHealth() || ((m_creature->GetHealth() - uiDamage)*100 / m_creature->GetMaxHealth() < 15))
damage = 0; {
uiDamage = 0;
if (done_by->GetTypeId() == TYPEID_PLAYER) if (pDoneBy->GetTypeId() == TYPEID_PLAYER)
CAST_PLR(done_by)->AreaExploredOrEventHappens(QUEST_MISSING_DIPLO_PT8); ((Player*)pDoneBy)->AreaExploredOrEventHappens(QUEST_MISSING_DIPLO_PT8);
//m_creature->CombatStop();
EnterEvadeMode(); EnterEvadeMode();
} }
} }
void EnterCombat(Unit *who) {}
}; };
bool QuestAccept_npc_dashel_stonefist(Player* pPlayer, Creature* pCreature, Quest const* pQuest) bool QuestAccept_npc_dashel_stonefist(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
@@ -102,23 +102,6 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
abomnationGUID.clear(); abomnationGUID.clear();
} }
Player* GetPlayerInMap()
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* plr = itr->getSource())
return plr;
}
}
debug_log("TSCR: Instance Stratholme: GetPlayerInMap, but PlayerList is empty!");
return NULL;
}
bool StartSlaugtherSquare() bool StartSlaugtherSquare()
{ {
//change to DONE when crystals implemented //change to DONE when crystals implemented
@@ -183,14 +166,6 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
void SetData(uint32 type, uint32 data) void SetData(uint32 type, uint32 data)
{ {
Player *player = GetPlayerInMap();
if (!player)
{
debug_log("TSCR: Instance Stratholme: SetData (Type: %u Data %u) cannot find any player.", type, data);
return;
}
switch(type) switch(type)
{ {
case TYPE_BARON_RUN: case TYPE_BARON_RUN:
@@ -206,8 +181,10 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
//may add code to remove aura from players, but in theory the time should be up already and removed. //may add code to remove aura from players, but in theory the time should be up already and removed.
break; break;
case DONE: case DONE:
if (Unit *t = Unit::GetUnit(*player, ysidaTriggerGUID)) if (Creature* pYsidaT = instance->GetCreature(ysidaTriggerGUID))
t->SummonCreature(C_YSIDA,t->GetPositionX(),t->GetPositionY(),t->GetPositionZ(),t->GetOrientation(),TEMPSUMMON_TIMED_DESPAWN,1800000); pYsidaT->SummonCreature(C_YSIDA,
pYsidaT->GetPositionX(),pYsidaT->GetPositionY(),pYsidaT->GetPositionZ(),pYsidaT->GetOrientation(),
TEMPSUMMON_TIMED_DESPAWN,1800000);
BaronRun_Timer = 0; BaronRun_Timer = 0;
break; break;
} }
@@ -243,9 +220,9 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
uint32 count = abomnationGUID.size(); uint32 count = abomnationGUID.size();
for(std::set<uint64>::iterator i = abomnationGUID.begin(); i != abomnationGUID.end(); ++i) for(std::set<uint64>::iterator i = abomnationGUID.begin(); i != abomnationGUID.end(); ++i)
{ {
if (Unit* abom = Unit::GetUnit(*player, *i)) if (Creature* pAbom = instance->GetCreature(*i))
{ {
if (!abom->isAlive()) if (!pAbom->isAlive())
--count; --count;
} }
} }
@@ -254,9 +231,12 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
{ {
//a bit itchy, it should close the door after 10 secs, but it doesn't. skipping it for now. //a bit itchy, it should close the door after 10 secs, but it doesn't. skipping it for now.
//UpdateGoState(ziggurat4GUID,0,true); //UpdateGoState(ziggurat4GUID,0,true);
player->SummonCreature(C_RAMSTEIN,4032.84,-3390.24,119.73,4.71,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000); if (Creature* pBaron = instance->GetCreature(baronGUID))
pBaron->SummonCreature(C_RAMSTEIN,4032.84,-3390.24,119.73,4.71,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000);
debug_log("TSCR: Instance Stratholme: Ramstein spawned."); debug_log("TSCR: Instance Stratholme: Ramstein spawned.");
} else debug_log("TSCR: Instance Stratholme: %u Abomnation left to kill.",count); }
else
debug_log("TSCR: Instance Stratholme: %u Abomnation left to kill.",count);
} }
if (data == DONE) if (data == DONE)
{ {
@@ -270,22 +250,22 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
{ {
if (GetData(TYPE_BARON_RUN) == IN_PROGRESS) if (GetData(TYPE_BARON_RUN) == IN_PROGRESS)
{ {
if (Group *pGroup = player->GetGroup()) Map::PlayerList const& players = instance->GetPlayers();
{
for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* pGroupie = itr->getSource();
if (!pGroupie)
continue;
if (pGroupie->HasAura(SPELL_BARON_ULTIMATUM)) if (!players.isEmpty())
pGroupie->RemoveAurasDueToSpell(SPELL_BARON_ULTIMATUM); {
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
{
if (pPlayer->HasAura(SPELL_BARON_ULTIMATUM))
pPlayer->RemoveAurasDueToSpell(SPELL_BARON_ULTIMATUM);
if (pPlayer->GetQuestStatus(QUEST_DEAD_MAN_PLEA) == QUEST_STATUS_INCOMPLETE)
pPlayer->AreaExploredOrEventHappens(QUEST_DEAD_MAN_PLEA);
}
}
} }
} else if (player->HasAura(SPELL_BARON_ULTIMATUM))
player->RemoveAurasDueToSpell(SPELL_BARON_ULTIMATUM);
if (Unit *temp = Unit::GetUnit(*player,GetData64(DATA_BARON)))
player->GroupEventHappens(QUEST_DEAD_MAN_PLEA,temp);
SetData(TYPE_BARON_RUN,DONE); SetData(TYPE_BARON_RUN,DONE);
} }
@@ -363,10 +343,10 @@ struct TRINITY_DLL_DECL instance_stratholme : public ScriptedInstance
{ {
if (SlaugtherSquare_Timer <= diff) if (SlaugtherSquare_Timer <= diff)
{ {
if (Player *p = GetPlayerInMap()) if (Creature* pBaron = instance->GetCreature(baronGUID))
{ {
for(uint8 i = 0; i < 4; i++) for(uint8 i = 0; i < 4; i++)
p->SummonCreature(C_BLACK_GUARD,4032.84,-3390.24,119.73,4.71,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000); pBaron->SummonCreature(C_BLACK_GUARD,4032.84,-3390.24,119.73,4.71,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000);
UpdateGoState(ziggurat4GUID,0,false); UpdateGoState(ziggurat4GUID,0,false);
UpdateGoState(ziggurat5GUID,0,false); UpdateGoState(ziggurat5GUID,0,false);
@@ -73,10 +73,9 @@ struct TRINITY_DLL_DECL npc_mistAI : public ScriptedAI
void EnterEvadeMode() void EnterEvadeMode()
{ {
m_creature->InterruptNonMeleeSpells(true);
m_creature->RemoveAllAuras(); m_creature->RemoveAllAuras();
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->CombatStop(); m_creature->CombatStop(true);
m_creature->LoadCreaturesAddon(); m_creature->LoadCreaturesAddon();
if (m_creature->isAlive()) if (m_creature->isAlive())
@@ -72,7 +72,7 @@ struct TRINITY_DLL_DECL mob_unkor_the_ruthlessAI : public ScriptedAI
m_creature->SetStandState(UNIT_STAND_STATE_SIT); m_creature->SetStandState(UNIT_STAND_STATE_SIT);
m_creature->RemoveAllAuras(); m_creature->RemoveAllAuras();
m_creature->DeleteThreatList(); m_creature->DeleteThreatList();
m_creature->CombatStop(); m_creature->CombatStop(true);
UnkorUnfriendly_Timer = 60000; UnkorUnfriendly_Timer = 60000;
} }