Skip to content

Commit 56e4534

Browse files
committed
Add names to areatriggers.
1 parent e387833 commit 56e4534

14 files changed

Lines changed: 788 additions & 203 deletions

File tree

sql/migrations/20250320032550_world.sql

Lines changed: 546 additions & 0 deletions
Large diffs are not rendered by default.

src/game/Chat/Chat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3635,7 +3635,7 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x,
36353635
return false;
36363636
}
36373637

3638-
mapid = atEntry->mapid;
3638+
mapid = atEntry->map_id;
36393639
x = atEntry->x;
36403640
y = atEntry->y;
36413641
z = atEntry->z;

src/game/Commands/MiscCommands.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,11 +1397,11 @@ void ChatHandler::ShowTriggerListHelper(AreaTriggerEntry const* atEntry)
13971397
snprintf(dist_buf, 50, GetMangosString(LANG_TRIGGER_DIST), dist);
13981398

13991399
PSendSysMessage(LANG_TRIGGER_LIST_CHAT,
1400-
atEntry->id, atEntry->id, atEntry->mapid, atEntry->x, atEntry->y, atEntry->z, dist_buf, tavern, quest);
1400+
atEntry->id, atEntry->id, atEntry->map_id, atEntry->x, atEntry->y, atEntry->z, dist_buf, tavern, quest);
14011401
}
14021402
else
14031403
PSendSysMessage(LANG_TRIGGER_LIST_CONSOLE,
1404-
atEntry->id, atEntry->mapid, atEntry->x, atEntry->y, atEntry->z, tavern, quest);
1404+
atEntry->id, atEntry->map_id, atEntry->x, atEntry->y, atEntry->z, tavern, quest);
14051405

14061406
if (AreaTriggerTeleport const* at = sObjectMgr.GetAreaTriggerTeleport(atEntry->id))
14071407
ShowTriggerTargetListHelper(atEntry->id, at, true);
@@ -1449,7 +1449,7 @@ bool ChatHandler::HandleTriggerCommand(char* args)
14491449
if (!atTestEntry)
14501450
continue;
14511451

1452-
if (atTestEntry->mapid != m_session->GetPlayer()->GetMapId())
1452+
if (atTestEntry->map_id != m_session->GetPlayer()->GetMapId())
14531453
continue;
14541454

14551455
float dx = atTestEntry->x - player->GetPositionX();
@@ -1531,7 +1531,7 @@ bool ChatHandler::HandleTriggerNearCommand(char* args)
15311531
if (!atEntry)
15321532
continue;
15331533

1534-
if (atEntry->mapid != m_session->GetPlayer()->GetMapId())
1534+
if (atEntry->map_id != m_session->GetPlayer()->GetMapId())
15351535
continue;
15361536

15371537
float dx = atEntry->x - player->GetPositionX();

src/game/Commands/TeleportCommands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ bool ChatHandler::HandleGoTriggerCommand(char* args)
319319
return HandleGoHelper(pPlayer, at->destination.mapId, at->destination.x, at->destination.y, &at->destination.z);
320320
}
321321
else
322-
return HandleGoHelper(pPlayer, atEntry->mapid, atEntry->x, atEntry->y, &atEntry->z);
322+
return HandleGoHelper(pPlayer, atEntry->map_id, atEntry->x, atEntry->y, &atEntry->z);
323323
}
324324

325325
bool ChatHandler::HandleGoGraveyardCommand(char* args)

src/game/Database/DBCStores.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -576,48 +576,6 @@ bool Map2ZoneCoordinates(float& x, float& y, uint32 zone)
576576
return true;
577577
}
578578

579-
bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, float x, float y, float z, float delta)
580-
{
581-
if (mapid != atEntry->mapid)
582-
return false;
583-
584-
if (atEntry->radius > 0)
585-
{
586-
// if we have radius check it
587-
float dist2 = (x - atEntry->x) * (x - atEntry->x) + (y - atEntry->y) * (y - atEntry->y) + (z - atEntry->z) * (z - atEntry->z);
588-
if (dist2 > (atEntry->radius + delta) * (atEntry->radius + delta))
589-
return false;
590-
}
591-
else
592-
{
593-
// we have only extent
594-
595-
// rotate the players position instead of rotating the whole cube, that way we can make a simplified
596-
// is-in-cube check and we have to calculate only one point instead of 4
597-
598-
// 2PI = 360, keep in mind that ingame orientation is counter-clockwise
599-
double rotation = 2 * M_PI - atEntry->box_orientation;
600-
double sinVal = sin(rotation);
601-
double cosVal = cos(rotation);
602-
603-
float playerBoxDistX = x - atEntry->x;
604-
float playerBoxDistY = y - atEntry->y;
605-
606-
float dx = float(playerBoxDistX * cosVal - playerBoxDistY * sinVal);
607-
float dy = float(playerBoxDistY * cosVal + playerBoxDistX * sinVal);
608-
609-
// box edges are parallel to coordiante axis, so we can treat every dimension independently :D
610-
float dz = z - atEntry->z;
611-
612-
if ((fabs(dx) > atEntry->box_x / 2 + delta) ||
613-
(fabs(dy) > atEntry->box_y / 2 + delta) ||
614-
(fabs(dz) > atEntry->box_z / 2 + delta))
615-
return false;
616-
}
617-
618-
return true;
619-
}
620-
621579
SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_)
622580
{
623581
SkillRaceClassInfoBounds bounds = SkillRaceClassInfoBySkill.equal_range(skill);

src/game/Database/DBCStores.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ ChatChannelsEntry const* GetChannelEntryFor(std::string const& name);
4747
bool Zone2MapCoordinates(float& x,float& y,uint32 zone);
4848
bool Map2ZoneCoordinates(float& x,float& y,uint32 zone);
4949

50-
bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, float x, float y, float z, float delta = 0.0f);
51-
5250
typedef std::multimap<uint32, SkillRaceClassInfoEntry const*> SkillRaceClassInfoMap;
5351
typedef std::pair<SkillRaceClassInfoMap::iterator, SkillRaceClassInfoMap::iterator> SkillRaceClassInfoBounds;
5452
SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_);

src/game/Database/DBCStructure.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,6 @@
4141
#pragma pack(push,1)
4242
#endif
4343

44-
struct AreaTriggerEntry
45-
{
46-
uint32 id; // 0
47-
uint32 mapid; // 1
48-
float x; // 2
49-
float y; // 3
50-
float z; // 4
51-
float radius; // 5
52-
float box_x; // 6 extent x edge
53-
float box_y; // 7 extent y edge
54-
float box_z; // 8 extent z edge
55-
float box_orientation; // 9 extent rotation by about z axis
56-
};
57-
5844
struct AuctionHouseEntry
5945
{
6046
uint32 houseId; // 0 m_ID

src/game/ObjectMgr.cpp

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6734,6 +6734,48 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
67346734
CharacterDatabase.AsyncPQueryUnsafe(cb, &OldMailsReturner::Callback, "SELECT `id`, `message_type`, `sender_guid`, `receiver_guid`, `item_text_id`, `has_items`, `expire_time`, `cod`, `checked`, `mail_template_id` FROM `mail` WHERE `expire_time` < '" UI64FMTD "' ORDER BY `expire_time`", (uint64)basetime);
67356735
}
67366736

6737+
bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, float x, float y, float z, float delta)
6738+
{
6739+
if (mapid != atEntry->map_id)
6740+
return false;
6741+
6742+
if (atEntry->radius > 0)
6743+
{
6744+
// if we have radius check it
6745+
float dist2 = (x - atEntry->x) * (x - atEntry->x) + (y - atEntry->y) * (y - atEntry->y) + (z - atEntry->z) * (z - atEntry->z);
6746+
if (dist2 > (atEntry->radius + delta) * (atEntry->radius + delta))
6747+
return false;
6748+
}
6749+
else
6750+
{
6751+
// we have only extent
6752+
6753+
// rotate the players position instead of rotating the whole cube, that way we can make a simplified
6754+
// is-in-cube check and we have to calculate only one point instead of 4
6755+
6756+
// 2PI = 360, keep in mind that ingame orientation is counter-clockwise
6757+
double rotation = 2 * M_PI - atEntry->box_orientation;
6758+
double sinVal = sin(rotation);
6759+
double cosVal = cos(rotation);
6760+
6761+
float playerBoxDistX = x - atEntry->x;
6762+
float playerBoxDistY = y - atEntry->y;
6763+
6764+
float dx = float(playerBoxDistX * cosVal - playerBoxDistY * sinVal);
6765+
float dy = float(playerBoxDistY * cosVal + playerBoxDistX * sinVal);
6766+
6767+
// box edges are parallel to coordiante axis, so we can treat every dimension independently :D
6768+
float dz = z - atEntry->z;
6769+
6770+
if ((fabs(dx) > atEntry->box_x / 2 + delta) ||
6771+
(fabs(dy) > atEntry->box_y / 2 + delta) ||
6772+
(fabs(dz) > atEntry->box_z / 2 + delta))
6773+
return false;
6774+
}
6775+
6776+
return true;
6777+
}
6778+
67376779
void ObjectMgr::LoadAreaTriggers()
67386780
{
67396781
std::unique_ptr<QueryResult> result(WorldDatabase.PQuery("SELECT * FROM `areatrigger_template` t1 WHERE `build`=(SELECT max(`build`) FROM `areatrigger_template` t2 WHERE t1.`id`=t2.`id` && `build` <= %u)", SUPPORTED_CLIENT_BUILD));
@@ -6759,15 +6801,16 @@ void ObjectMgr::LoadAreaTriggers()
67596801
uint32 triggerId = fields[0].GetUInt32();
67606802

67616803
areaTrigger.id = triggerId;
6762-
areaTrigger.mapid = fields[2].GetUInt32();
6763-
areaTrigger.x = fields[3].GetFloat();
6764-
areaTrigger.y = fields[4].GetFloat();
6765-
areaTrigger.z = fields[5].GetFloat();
6766-
areaTrigger.radius = fields[6].GetFloat();
6767-
areaTrigger.box_x = fields[7].GetFloat();
6768-
areaTrigger.box_y = fields[8].GetFloat();
6769-
areaTrigger.box_z = fields[9].GetFloat();
6770-
areaTrigger.box_orientation = fields[10].GetFloat();
6804+
areaTrigger.name = fields[2].GetCppString();
6805+
areaTrigger.map_id = fields[3].GetUInt32();
6806+
areaTrigger.x = fields[4].GetFloat();
6807+
areaTrigger.y = fields[5].GetFloat();
6808+
areaTrigger.z = fields[6].GetFloat();
6809+
areaTrigger.radius = fields[7].GetFloat();
6810+
areaTrigger.box_x = fields[8].GetFloat();
6811+
areaTrigger.box_y = fields[9].GetFloat();
6812+
areaTrigger.box_z = fields[10].GetFloat();
6813+
areaTrigger.box_orientation = fields[11].GetFloat();
67716814

67726815

67736816
m_AreaTriggersMap[triggerId] = areaTrigger;
@@ -7417,7 +7460,7 @@ AreaTriggerTeleport const* ObjectMgr::GetGoBackTrigger(uint32 map_id) const
74177460
if (itr.second.destination.mapId == uint32(mapEntry->ghostEntranceMap))
74187461
{
74197462
AreaTriggerEntry const* atEntry = GetAreaTrigger(itr.first);
7420-
if (atEntry && atEntry->mapid == map_id)
7463+
if (atEntry && atEntry->map_id == map_id)
74217464
return &itr.second;
74227465
}
74237466
}

src/game/ObjectMgr.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ struct GameTele
5555

5656
typedef std::unordered_map<uint32, GameTele > GameTeleMap;
5757

58+
struct AreaTriggerEntry
59+
{
60+
uint32 id;
61+
uint32 map_id;
62+
std::string name;
63+
float x;
64+
float y;
65+
float z;
66+
float radius;
67+
float box_x; // extent x edge
68+
float box_y; // extent y edge
69+
float box_z; // extent z edge
70+
float box_orientation; // extent rotation by about z axis
71+
};
72+
73+
bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, float x, float y, float z, float delta = 0.0f);
74+
5875
struct AreaTriggerTeleport
5976
{
6077
std::string message;

src/scripts/eastern_kingdoms/westfall/deadmines/instance_deadmines.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ struct instance_deadmines : public ScriptedInstance
3838
uint64 m_uiSmiteGUID;
3939
uint64 m_uiRhahkGUID;
4040
uint64 m_uiGilnidGUID;
41-
uint64 m_uiDMFChestGUID;
4241

4342
uint64 m_uiDoor1GUID;
4443
uint64 m_uiDoor2GUID;
@@ -143,23 +142,7 @@ struct instance_deadmines : public ScriptedInstance
143142
m_uiDoor3GUID = pGo->GetGUID();
144143

145144
if (pGo->GetEntry() == GO_DMF_CHEST)
146-
{
147145
pGo->SetVisible(false);
148-
m_uiDMFChestGUID = pGo->GetGUID();
149-
}
150-
}
151-
152-
void OnPlayerEnter(Player* pPlayer) override
153-
{
154-
if (!pPlayer)
155-
return;
156-
157-
// Darkmoon chest visible only for players on the quest
158-
if (pPlayer->GetQuestStatus(QUEST_FORTUNE_AWAITS) == QUEST_STATUS_COMPLETE)
159-
{
160-
if (GameObject* pGo = instance->GetGameObject(m_uiDMFChestGUID))
161-
pGo->SetVisible(true);
162-
}
163146
}
164147

165148
void SetData(uint32 uiType, uint32 uiData) override
@@ -309,11 +292,29 @@ InstanceData* GetInstanceData_instance_deadmines(Map* pMap)
309292
return new instance_deadmines(pMap);
310293
}
311294

295+
bool AreaTrigger_at_dmf_chest_dm(Player* pPlayer, AreaTriggerEntry const* pAt)
296+
{
297+
// Darkmoon chest visible only for players on the quest
298+
if (pPlayer->GetQuestStatus(QUEST_FORTUNE_AWAITS) == QUEST_STATUS_COMPLETE)
299+
{
300+
if (GameObject* pGo = pPlayer->FindNearestGameObject(GO_DMF_CHEST, 100.0f))
301+
pGo->SetVisible(true);
302+
}
303+
304+
return false;
305+
}
306+
312307
void AddSC_instance_deadmines()
313308
{
314309
Script* newscript;
310+
315311
newscript = new Script;
316312
newscript->Name = "instance_deadmines";
317313
newscript->GetInstanceData = &GetInstanceData_instance_deadmines;
318314
newscript->RegisterSelf();
315+
316+
newscript = new Script;
317+
newscript->Name = "at_dmf_chest_dm";
318+
newscript->pAreaTrigger = &AreaTrigger_at_dmf_chest_dm;
319+
newscript->RegisterSelf();
319320
}

0 commit comments

Comments
 (0)