Merge [SD2]

r1272 Rough cleanup of hyjal-related scripts. Mainly applied SD2 code style, but also minor improvement of code and removal of not needed functions. - skip
r1273 Move code and use JustSummoned() instead of own system in hyjalAI - skip
r1274 Simplify way to determine where to spawn creature and remove already known base area passed in function. Also rename arrays. - skip
r1275 Provide updated .patch file after changes in Mangos rev 8255 - skip
r1277 Remove adding threat for summoned waves in hyjal and instead move to point when summoned. Also add simple handler to attempt move summoned closer to base bosses when not in combat. - skip
r1278 Replace world state functions in misc scripts with new ScriptedInstance function.
r1279 Simplify spawning of correct wave in hyjal. Remove no longer needed arguments in related function.
      Also restore wave timer reset in case all mobs in wave are dead before master timer end. - skip
r1280 Added basic support for quest 1324. Patch by jotapdiez
      Also adding additional data for further development of event.

--HG--
branch : trunk
This commit is contained in:
Kudlaty
2009-08-14 21:29:28 +02:00
parent b3c9916177
commit 5ebba6e2fe
10 changed files with 128 additions and 102 deletions
+1
View File
@@ -438,6 +438,7 @@ UPDATE `creature_template` SET `ScriptName`='npc_deserter_agitator' WHERE `entry
UPDATE `creature_template` SET `ScriptName`='npc_lady_jaina_proudmoore' WHERE `entry`=4968;
UPDATE `creature_template` SET `ScriptName`='npc_nat_pagle' WHERE `entry`=12919;
UPDATE `creature_template` SET `ScriptName`='npc_restless_apparition' WHERE `entry`=23861;
UPDATE `creature_template` SET `ScriptName`='npc_private_hendel' WHERE `entry`=4966;
/* EASTERN PLAGUELANDS */
UPDATE `creature_template` SET `ScriptName`='mobs_ghoul_flayer' WHERE `entry` IN (8530,8531,8532);
+1
View File
@@ -0,0 +1 @@
UPDATE creature_template SET ScriptName='npc_private_hendel' WHERE entry=4966;
@@ -95,25 +95,11 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
NextPortal_Timer = 0;
}
void UpdateBMWorldState(uint32 id, uint32 state)
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
pPlayer->SendUpdateWorldState(id,state);
}
}else debug_log("TSCR: Instance Black Portal: UpdateBMWorldState, but PlayerList is empty!");
}
void InitWorldState(bool Enable = true)
{
UpdateBMWorldState(WORLD_STATE_BM,Enable ? 1 : 0);
UpdateBMWorldState(WORLD_STATE_BM_SHIELD,100);
UpdateBMWorldState(WORLD_STATE_BM_RIFT,0);
DoUpdateWorldState(WORLD_STATE_BM,Enable ? 1 : 0);
DoUpdateWorldState(WORLD_STATE_BM_SHIELD, 100);
DoUpdateWorldState(WORLD_STATE_BM_RIFT, 0);
}
bool IsEncounterInProgress()
@@ -172,7 +158,8 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
if (data == SPECIAL && m_auiEncounter[0] == IN_PROGRESS)
{
--mShieldPercent;
UpdateBMWorldState(WORLD_STATE_BM_SHIELD,mShieldPercent);
DoUpdateWorldState(WORLD_STATE_BM_SHIELD, mShieldPercent);
if (!mShieldPercent)
{
@@ -337,7 +324,8 @@ struct TRINITY_DLL_DECL instance_dark_portal : public ScriptedInstance
if (NextPortal_Timer <= diff)
{
++mRiftPortalCount;
UpdateBMWorldState(WORLD_STATE_BM_RIFT,mRiftPortalCount);
DoUpdateWorldState(WORLD_STATE_BM_RIFT, mRiftPortalCount);
DoSpawnPortal();
NextPortal_Timer = RiftWaves[GetRiftWaveId()].NextPortalTime;
@@ -396,9 +396,9 @@ void hyjalAI::Reset()
if ((!pInstance->GetData(DATA_ALLIANCE_RETREAT) && m_creature->GetEntry() == JAINA) || (pInstance->GetData(DATA_ALLIANCE_RETREAT) && m_creature->GetEntry() == THRALL))
{
//Reset World States
UpdateWorldState(WORLD_STATE_WAVES, 0);
UpdateWorldState(WORLD_STATE_ENEMY, 0);
UpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0);
pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, 0);
pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0);
pInstance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0);
pInstance->SetData(DATA_RESET_TRASH_COUNT, 0);
}
}else error_log(ERROR_INST_DATA);
@@ -548,8 +548,11 @@ void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3])
uint32 stateValue = Count+1;
if (FirstBossDead)
stateValue -= 9; // Subtract 9 from it to give the proper wave number if we are greater than 8
UpdateWorldState(WORLD_STATE_WAVES, stateValue); // Set world state to our current wave number
UpdateWorldState(WORLD_STATE_ENEMY, 1); // Enable world state
// Set world state to our current wave number
pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, stateValue); // Set world state to our current wave number
// Enable world state
pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 1); // Enable world state
pInstance->SetData(DATA_TRASH, EnemyCount); // Send data for instance script to update count
@@ -563,9 +566,13 @@ void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3])
}
else
{
UpdateWorldState(WORLD_STATE_WAVES, 0); // Set world state for waves to 0 to disable it.
UpdateWorldState(WORLD_STATE_ENEMY, 1);
UpdateWorldState(WORLD_STATE_ENEMYCOUNT, 1); // Set World State for enemies invading to 1.
// Set world state for waves to 0 to disable it.
pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, 0);
pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 1);
// Set World State for enemies invading to 1.
pInstance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 1);
Summon = false;
}
CheckTimer = 5000;
@@ -573,7 +580,7 @@ void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3])
void hyjalAI::StartEvent(Player* pPlayer)
{
if (!pPlayer || IsDummy)
if (!pPlayer || IsDummy || !pInstance)
return;
Talk(BEGIN);
@@ -587,9 +594,9 @@ void hyjalAI::StartEvent(Player* pPlayer)
m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
UpdateWorldState(WORLD_STATE_WAVES, 0);
UpdateWorldState(WORLD_STATE_ENEMY, 0);
UpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0);
pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, 0);
pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0);
pInstance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0);
DeSpawnVeins();
}
@@ -639,25 +646,6 @@ void hyjalAI::Talk(uint32 id)
DoScriptText(YellId, m_creature);
}
void hyjalAI::UpdateWorldState(uint32 id, uint32 state)
{
Map* pMap = m_creature->GetMap();
if (!pMap->IsDungeon())
return;
Map::PlayerList const& players = pMap->GetPlayers();
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
pPlayer->SendUpdateWorldState(id,state);
}
}else debug_log("TSCR: HyjalAI: UpdateWorldState, but PlayerList is empty");
}
void hyjalAI::Retreat()
{
if (pInstance)
@@ -879,7 +867,7 @@ void hyjalAI::UpdateAI(const uint32 diff)
CheckTimer = 0;
m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
BossGUID[i] = 0;
UpdateWorldState(WORLD_STATE_ENEMY, 0); // Reset world state for enemies to disable it
pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0); // Reset world state for enemies to disable it
}
}
}
@@ -195,7 +195,6 @@ struct TRINITY_DLL_DECL hyjalAI : public npc_escortAI
void Talk(uint32 id); // Searches for the appropriate yell and sound and uses it to inform the raid of various things
void UpdateWorldState(uint32 field, uint32 value); // NYI: Requires core support. Updates the world state counter at the top of the UI.
public:
ScriptedInstance* pInstance;
@@ -211,7 +211,7 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
case DATA_TRASH:
if (data) Trash = data;
else Trash--;
UpdateWorldState(WORLD_STATE_ENEMYCOUNT, Trash);
DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, Trash);
break;
case TYPE_RETREAT:
if (data == SPECIAL)
@@ -283,20 +283,6 @@ struct TRINITY_DLL_DECL instance_mount_hyjal : public ScriptedInstance
return 0;
}
void UpdateWorldState(uint32 id, uint32 state)
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
{
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
pPlayer->SendUpdateWorldState(id,state);
}
}else debug_log("TSCR: Instance Hyjal: UpdateWorldState, but PlayerList is empty!");
}
std::string GetSaveData()
{
return str_data;
@@ -29,17 +29,15 @@ EndScriptData */
## go_barrel_old_hillsbrad
######*/
bool GOHello_go_barrel_old_hillsbrad(Player* pPlayer, GameObject* _GO)
bool GOHello_go_barrel_old_hillsbrad(Player* pPlayer, GameObject* pGO)
{
ScriptedInstance* pInstance = _GO->GetInstanceData();
if (ScriptedInstance* pInstance = pGO->GetInstanceData())
{
if (pInstance->GetData(TYPE_BARREL_DIVERSION) == DONE)
return false;
if (!pInstance)
return false;
if (pInstance->GetData(TYPE_BARREL_DIVERSION) == DONE)
return false;
pInstance->SetData(TYPE_BARREL_DIVERSION, IN_PROGRESS);
pInstance->SetData(TYPE_BARREL_DIVERSION, IN_PROGRESS);
}
return false;
}
@@ -75,7 +75,7 @@ struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance
return NULL;
}
void UpdateOHWorldState()
void UpdateQuestCredit()
{
Map::PlayerList const& players = instance->GetPlayers();
@@ -84,15 +84,9 @@ struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance
for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
{
pPlayer->SendUpdateWorldState(WORLD_STATE_OH,mBarrelCount);
if (mBarrelCount == 5)
pPlayer->KilledMonsterCredit(LODGE_QUEST_TRIGGER,0);
}
pPlayer->KilledMonsterCredit(LODGE_QUEST_TRIGGER,0);
}
}else
debug_log("TSCR: Instance Old Hillsbrad: UpdateOHWorldState, but PlayerList is empty!");
}
}
void OnCreatureCreate(Creature *creature, bool add)
@@ -131,7 +125,7 @@ struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance
return;
++mBarrelCount;
UpdateOHWorldState();
DoUpdateWorldState(WORLD_STATE_OH, mBarrelCount);
debug_log("TSCR: Instance Old Hillsbrad: go_barrel_old_hillsbrad count %u",mBarrelCount);
@@ -139,8 +133,9 @@ struct TRINITY_DLL_DECL instance_old_hillsbrad : public ScriptedInstance
if (mBarrelCount == 5)
{
pPlayer->SummonCreature(DRAKE_ENTRY,2128.43,71.01,64.42,1.74,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,1800000);
m_auiEncounter[0] = DONE;
UpdateQuestCredit();
pPlayer->SummonCreature(DRAKE_ENTRY, 2128.43, 71.01, 64.42, 1.74, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 1800000);
m_auiEncounter[0] = DONE;
}
}
break;
@@ -17,7 +17,7 @@
/* ScriptData
SDName: Dustwallow_Marsh
SD%Complete: 95
SDComment: Quest support: 11180, 558, 11126, 11142, Vendor Nat Pagle
SDComment: Quest support: 11180, 558, 11126, 11142, 11180. Vendor Nat Pagle
SDCategory: Dustwallow Marsh
EndScriptData */
@@ -27,6 +27,8 @@ npc_restless_apparition
npc_deserter_agitator
npc_lady_jaina_proudmoore
npc_nat_pagle
npc_private_hendel
npc_cassa_crimsonwing - handled by npc_taxi
EndContentData */
#include "precompiled.h"
@@ -221,6 +223,75 @@ bool GossipSelect_npc_nat_pagle(Player* pPlayer, Creature* pCreature, uint32 uiS
return true;
}
/*######
## npc_private_hendel
######*/
enum
{
SAY_PROGRESS_1_TER = -1000411,
SAY_PROGRESS_2_HEN = -1000412,
SAY_PROGRESS_3_TER = -1000413,
SAY_PROGRESS_4_TER = -1000414,
EMOTE_SURRENDER = -1000415,
QUEST_MISSING_DIPLO_PT16 = 1324,
FACTION_HOSTILE = 168, //guessed, may be different
NPC_SENTRY = 5184, //helps hendel
NPC_JAINA = 4968, //appears once hendel gives up
NPC_TERVOSH = 4967
};
//TODO: develop this further, end event not created
struct TRINITY_DLL_DECL npc_private_hendelAI : public ScriptedAI
{
npc_private_hendelAI(Creature* pCreature) : ScriptedAI(pCreature) { }
void Reset()
{
me->RestoreFaction();
}
void AttackedBy(Unit* pAttacker)
{
if (m_creature->getVictim())
return;
if (m_creature->IsFriendlyTo(pAttacker))
return;
AttackStart(pAttacker);
}
void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
{
if (uiDamage > m_creature->GetHealth() || ((m_creature->GetHealth() - uiDamage)*100 / m_creature->GetMaxHealth() < 20))
{
uiDamage = 0;
if (Player* pPlayer = pDoneBy->GetCharmerOrOwnerPlayerOrPlayerItself())
pPlayer->GroupEventHappens(QUEST_MISSING_DIPLO_PT16, m_creature);
DoScriptText(EMOTE_SURRENDER, m_creature);
EnterEvadeMode();
}
}
};
bool QuestAccept_npc_private_hendel(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
{
if (pQuest->GetQuestId() == QUEST_MISSING_DIPLO_PT16)
pCreature->setFaction(FACTION_HOSTILE);
return true;
}
CreatureAI* GetAI_npc_private_hendel(Creature* pCreature)
{
return new npc_private_hendelAI(pCreature);
}
/*######
##
######*/
@@ -256,5 +327,11 @@ void AddSC_dustwallow_marsh()
newscript->pGossipHello = &GossipHello_npc_nat_pagle;
newscript->pGossipSelect = &GossipSelect_npc_nat_pagle;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name = "npc_private_hendel";
newscript->GetAI = &GetAI_npc_private_hendel;
newscript->pQuestAccept = &QuestAccept_npc_private_hendel;
newscript->RegisterSelf();
}
@@ -166,13 +166,6 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
HandleGameObject(ZulJinGateGUID, true);
}
void UpdateWorldState(uint32 field, uint32 value)
{
WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8);
data << field << value;
instance->SendToPlayers(&data);
}
std::string GetSaveData()
{
std::ostringstream ss;
@@ -211,7 +204,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
if (QuestMinute)
{
QuestMinute += 15;
UpdateWorldState(3106, QuestMinute);
DoUpdateWorldState(3106, QuestMinute);
}
SummonHostage(0);
}
@@ -224,7 +217,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
if (QuestMinute)
{
QuestMinute += 10;
UpdateWorldState(3106, QuestMinute);
DoUpdateWorldState(3106, QuestMinute);
}
SummonHostage(1);
}
@@ -267,7 +260,7 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
if (QuestMinute && BossKilled >= 4)
{
QuestMinute = 0;
UpdateWorldState(3104, 0);
DoUpdateWorldState(3104, 0);
}
CheckInstanceStatus();
SaveToDB();
@@ -302,9 +295,9 @@ struct TRINITY_DLL_DECL instance_zulaman : public ScriptedInstance
QuestTimer += 60000;
if (QuestMinute)
{
UpdateWorldState(3104, 1);
UpdateWorldState(3106, QuestMinute);
}else UpdateWorldState(3104, 0);
DoUpdateWorldState(3104, 1);
DoUpdateWorldState(3106, QuestMinute);
}else DoUpdateWorldState(3104, 0);
}
QuestTimer -= diff;
}