TrinityCore
Loading...
Searching...
No Matches
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{
44public:
46
48 {
50 }
51
53 {
63
67
71
73 {
74 Map::PlayerList const& players = instance->GetPlayers();
75
76 if (!players.isEmpty())
77 {
78 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
79 {
80 if (Player* player = itr->GetSource())
81 player->KilledMonsterCredit(LODGE_QUEST_TRIGGER);
82 }
83 }
84 }
85
86 void OnCreatureCreate(Creature* creature) override
87 {
88 switch (creature->GetEntry())
89 {
90 case THRALL_ENTRY:
91 ThrallGUID = creature->GetGUID();
92 break;
93 case TARETHA_ENTRY:
94 TarethaGUID = creature->GetGUID();
95 break;
96 case EPOCH_ENTRY:
97 EpochGUID = creature->GetGUID();
98 break;
99 }
100 }
101
102 void SetData(uint32 type, uint32 data) override
103 {
104 switch (type)
105 {
107 {
108 if (data == IN_PROGRESS)
109 {
110 if (mBarrelCount >= 5)
111 return;
112
113 ++mBarrelCount;
115
116 TC_LOG_DEBUG("scripts", "Instance Old Hillsbrad: go_barrel_old_hillsbrad count {}", mBarrelCount);
117
118 if (mBarrelCount == 5)
119 {
121 if (TempSummon* drake = instance->SummonCreature(DRAKE_ENTRY, { 2128.43f, 71.01f, 64.42f, 1.74f }, nullptr, Milliseconds(30min).count()))
122 drake->SetTempSummonType(TEMPSUMMON_DEAD_DESPAWN);
123 }
124 }
125 break;
126 }
128 {
129 if (data != OH_ESCORT_DEATH_EVENT)
130 {
132 if (Creature* thrall = instance->GetCreature(ThrallGUID))
133 thrall->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
134 }
135 else
136 {
138 if (mThrallEventCount >= 20)
139 ThrallEscortState = OH_ESCORT_FINISHED; // wipe limit reached
140 else
141 ThrallEscortState = OH_ESCORT_PRISON_TO_SKARLOC; // not correct, see npc_thrall_old_hillsbrad::InitializeAI for details
142 }
143 TC_LOG_DEBUG("scripts", "Instance Old Hillsbrad: Thrall escort event adjusted to data {}.", data);
144 break;
145 }
146 }
147 }
148
149 uint32 GetData(uint32 data) const override
150 {
151 switch (data)
152 {
154 return mBarrelCount >= 5 ? DONE : IN_PROGRESS;
156 return ThrallEscortState;
157 }
158 return 0;
159 }
160
161 ObjectGuid GetGuidData(uint32 data) const override
162 {
163 switch (data)
164 {
165 case DATA_THRALL:
166 return ThrallGUID;
167 case DATA_TARETHA:
168 return TarethaGUID;
170 return EpochGUID;
171 }
172 return ObjectGuid::Empty;
173 }
174
175 void ReadSaveDataMore(std::istringstream&) override
176 {
178 mBarrelCount = 5;
179 /* TODO not correct, see npc_thrall_old_hillsbrad::InitializeAI for details
180 if (GetBossState(DATA_CAPTAIN_SKARLOC) == DONE)
181 ThrallEscortState = OH_ESCORT_HORSE_RIDE;
182 if (GetBossState(DATA_EPOCH_HUNTER) == DONE)
183 ThrallEscortState = OH_ESCORT_FINISHED;
184 */
185 }
186 };
187};
188
uint32_t uint32
Definition Define.h:133
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
@ IN_PROGRESS
@ DONE
#define TC_LOG_DEBUG(filterType__,...)
Definition Log.h:156
@ TEMPSUMMON_DEAD_DESPAWN
@ UNIT_NPC_FLAG_GOSSIP
#define DataHeader
void SetBossNumber(uint32 number)
InstanceMap * instance
EncounterState GetBossState(uint32 id) const
void DoUpdateWorldState(uint32 worldstateId, uint32 worldstateValue)
void SetHeaders(std::string const &dataHeaders)
bool isEmpty() const
Definition LinkedList.h:108
iterator end()
iterator begin()
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1852
PlayerList const & GetPlayers() const
Definition Map.h:448
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:4397
static ObjectGuid const Empty
Definition ObjectGuid.h:140
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
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
OHThrallEscortStates
@ OH_ESCORT_PRISON_TO_SKARLOC
@ OH_ESCORT_FINISHED
@ OH_ESCORT_DEATH_EVENT
@ WORLD_STATE_OH
#define OHScriptName
constexpr uint32 OldHillsbradFoothillsBossCount
@ DATA_EPOCH_HUNTER
@ TYPE_THRALL_EVENT
@ DATA_TARETHA
@ DATA_LIEUTENANT_DRAKE
@ TYPE_BARREL_DIVERSION