TrinityCore
instance_old_hillsbrad.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/* ScriptData
19SDName: Instance_Old_Hillsbrad
20SD%Complete: 75
21SDComment: If thrall escort fail, all parts will reset. In future, save sub-parts and continue from last known.
22SDCategory: Caverns of Time, Old Hillsbrad Foothills
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "InstanceScript.h"
27#include "Log.h"
28#include "Map.h"
29#include "old_hillsbrad.h"
30#include "Player.h"
31#include "TemporarySummon.h"
32
33#define THRALL_ENTRY 17876
34#define TARETHA_ENTRY 18887
35#define EPOCH_ENTRY 18096
36
37#define DRAKE_ENTRY 17848
38
39#define QUEST_ENTRY_DIVERSION 10283
40#define LODGE_QUEST_TRIGGER 20155
41
43{
44 { DATA_LIEUTENANT_DRAKE, {{ 1905 }} },
45 { DATA_CAPTAIN_SKARLOC, {{ 1907 }} },
46 { DATA_EPOCH_HUNTER, {{ 1906 }} }
47};
48
50{
51public:
53
55 {
57 }
58
60 {
62 {
66
68 mBarrelCount = 0;
70 }
71
75
79
81 {
82 Map::PlayerList const& players = instance->GetPlayers();
83
84 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
85 if (Player* player = itr->GetSource())
86 player->KilledMonsterCredit(LODGE_QUEST_TRIGGER);
87 }
88
89 void OnCreatureCreate(Creature* creature) override
90 {
91 switch (creature->GetEntry())
92 {
93 case THRALL_ENTRY:
94 ThrallGUID = creature->GetGUID();
95 break;
96 case TARETHA_ENTRY:
97 TarethaGUID = creature->GetGUID();
98 break;
99 case EPOCH_ENTRY:
100 EpochGUID = creature->GetGUID();
101 break;
102 }
103 }
104
105 void SetData(uint32 type, uint32 data) override
106 {
107 switch (type)
108 {
110 {
111 if (data == IN_PROGRESS)
112 {
113 if (mBarrelCount >= 5)
114 return;
115
116 ++mBarrelCount;
118
119 TC_LOG_DEBUG("scripts", "Instance Old Hillsbrad: go_barrel_old_hillsbrad count {}", mBarrelCount);
120
121 if (mBarrelCount == 5)
122 {
124 if (TempSummon* drake = instance->SummonCreature(DRAKE_ENTRY, { 2128.43f, 71.01f, 64.42f, 1.74f }, nullptr, 30min))
125 drake->SetTempSummonType(TEMPSUMMON_DEAD_DESPAWN);
126 }
127 }
128 break;
129 }
131 {
132 if (data != OH_ESCORT_DEATH_EVENT)
133 {
135 if (Creature* thrall = instance->GetCreature(ThrallGUID))
136 thrall->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
137 }
138 else
139 {
141 if (mThrallEventCount >= 20)
142 ThrallEscortState = OH_ESCORT_FINISHED; // wipe limit reached
143 else
144 ThrallEscortState = OH_ESCORT_PRISON_TO_SKARLOC; // not correct, see npc_thrall_old_hillsbrad::InitializeAI for details
145 }
146 TC_LOG_DEBUG("scripts", "Instance Old Hillsbrad: Thrall escort event adjusted to data {}.", data);
147 break;
148 }
149 }
150 }
151
152 uint32 GetData(uint32 data) const override
153 {
154 switch (data)
155 {
157 return mBarrelCount >= 5 ? DONE : IN_PROGRESS;
159 return ThrallEscortState;
160 }
161 return 0;
162 }
163
164 ObjectGuid GetGuidData(uint32 data) const override
165 {
166 switch (data)
167 {
168 case DATA_THRALL:
169 return ThrallGUID;
170 case DATA_TARETHA:
171 return TarethaGUID;
173 return EpochGUID;
174 }
175 return ObjectGuid::Empty;
176 }
177
178 void AfterDataLoad() override
179 {
181 mBarrelCount = 5;
182 /* TODO not correct, see npc_thrall_old_hillsbrad::InitializeAI for details
183 if (GetBossState(DATA_CAPTAIN_SKARLOC) == DONE)
184 ThrallEscortState = OH_ESCORT_HORSE_RIDE;
185 if (GetBossState(DATA_EPOCH_HUNTER) == DONE)
186 ThrallEscortState = OH_ESCORT_FINISHED;
187 */
188 }
189 };
190};
191
193{
195}
uint32_t uint32
Definition: Define.h:142
@ IN_PROGRESS
@ DONE
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
@ TEMPSUMMON_DEAD_DESPAWN
Definition: ObjectDefines.h:69
@ UNIT_NPC_FLAG_GOSSIP
Definition: UnitDefines.h:297
#define DataHeader
void SetBossNumber(uint32 number)
void LoadDungeonEncounterData(T const &encounters)
void DoUpdateWorldState(int32 worldStateId, int32 value)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
void SetHeaders(std::string const &dataHeaders)
iterator end()
Definition: MapRefManager.h:35
iterator begin()
Definition: MapRefManager.h:34
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, Milliseconds duration=0ms, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty, SmoothPhasingInfo const *smoothPhasingInfo=nullptr)
Definition: Object.cpp:1836
PlayerList const & GetPlayers() const
Definition: Map.h:367
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
InstanceScript * GetInstanceScript(InstanceMap *map) const override
@ DATA_THRALL
Definition: hyjal.h:37
void AddSC_instance_old_hillsbrad()
#define THRALL_ENTRY
#define LODGE_QUEST_TRIGGER
#define EPOCH_ENTRY
#define TARETHA_ENTRY
#define DRAKE_ENTRY
DungeonEncounterData const encounters[]
OHThrallEscortStates
Definition: old_hillsbrad.h:47
@ OH_ESCORT_PRISON_TO_SKARLOC
Definition: old_hillsbrad.h:48
@ OH_ESCORT_FINISHED
Definition: old_hillsbrad.h:52
@ OH_ESCORT_DEATH_EVENT
Definition: old_hillsbrad.h:54
@ WORLD_STATE_OH
Definition: old_hillsbrad.h:43
#define OHScriptName
Definition: old_hillsbrad.h:23
constexpr uint32 OldHillsbradFoothillsBossCount
Definition: old_hillsbrad.h:26
@ DATA_CAPTAIN_SKARLOC
Definition: old_hillsbrad.h:31
@ DATA_EPOCH_HUNTER
Definition: old_hillsbrad.h:32
@ TYPE_THRALL_EVENT
Definition: old_hillsbrad.h:35
@ DATA_TARETHA
Definition: old_hillsbrad.h:38
@ DATA_LIEUTENANT_DRAKE
Definition: old_hillsbrad.h:30
@ TYPE_BARREL_DIVERSION
Definition: old_hillsbrad.h:34