Skip to content

Commit 41181d3

Browse files
committed
Improve crediting code
1 parent 15d5a27 commit 41181d3

File tree

3 files changed

+62
-46
lines changed

3 files changed

+62
-46
lines changed

src/ZoneDifficulty.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,23 @@ enum ZoneDifficultySettings
125125
TYPE_RAID_AQ40 = 7,
126126
TYPE_HEROIC_TBC = 8,
127127
TYPE_RAID_T4 = 9,
128-
TYPE_RAID_T5 = 10,
128+
TYPE_RAID_SSC = 10,
129129
TYPE_RAID_T6 = 11,
130130
TYPE_RAID_ZA = 12,
131131
TYPE_HEROIC_WOTLK = 13,
132132
TYPE_RAID_T7 = 14,
133133
TYPE_RAID_T8 = 15,
134134
TYPE_RAID_T9 = 16,
135135
TYPE_RAID_T10 = 17,
136+
TYPE_RAID_HYJAL = 18,
136137

137138
TYPE_MAX_TIERS,
138139

139140
// Completed tiers settings
140141
SETTING_BLACK_TEMPLE = 0,
141-
SETTING_ZULAMAN = 1
142+
SETTING_ZULAMAN = 1,
143+
SETTING_SSC = 2,
144+
SETTING_HYJAL = 3
142145
};
143146

144147
enum Misc
@@ -168,14 +171,16 @@ class ZoneDifficulty
168171
bool HasMythicmode(int8 mode) { return (mode & MODE_HARD) == MODE_HARD; }
169172
bool HasCompletedFullTier(uint32 category, uint32 playerGUID);
170173
bool OverrideModeMatches(uint32 instanceId, uint32 spellId, uint32 mapId);
174+
[[nodiscord]] bool CheckCompletionStatus(Creature* creature, Player* player, uint32 category) const;
171175
[[nodiscard]] bool IsValidNerfTarget(Unit* target);
172176
[[nodiscard]] bool VectorContainsUint32(std::vector<uint32> vec, uint32 element);
173177
[[nodiscard]] bool IsMythicmodeMap(uint32 mapid);
174178
[[nodiscard]] bool ShouldNerfInDuels(Unit* target);
175179
[[nodiscard]] bool ShouldNerfMap(uint32 mapId) { return NerfInfo.find(mapId) != NerfInfo.end(); };
176180
[[nodiscard]] int32 GetLowestMatchingPhase(uint32 mapId, uint32 phaseMask);
177181
void RewardItem(Player* player, uint8 category, uint8 itemType, uint8 counter, Creature* creature, uint32 itemEntry);
178-
void LogAndAnnounceKill(Unit* creature, bool isMythic);
182+
void LogAndAnnounceKill(Map* map, bool isMythic);
183+
void ProcessCreatureDeath(Map* map, uint32 entry);
179184

180185
bool IsEnabled{ false };
181186
bool IsDebugInfoEnabled{ false };

src/mod_zone_difficulty_handler.cpp

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ std::string ZoneDifficulty::GetContentTypeString(uint32 type)
509509
case TYPE_RAID_T4:
510510
typestring = "for T4 Raids.";
511511
break;
512-
case TYPE_RAID_T5:
513-
typestring = "for T5 Raids.";
512+
case TYPE_RAID_SSC:
513+
typestring = "for Serpentshrine Cavern.";
514514
break;
515515
case TYPE_RAID_T6:
516516
typestring = "for T6 Raids.";
@@ -957,6 +957,9 @@ bool ZoneDifficulty::HasCompletedFullTier(uint32 category, uint32 playerGuid)
957957

958958
void ZoneDifficulty::RewardItem(Player* player, uint8 category, uint8 itemType, uint8 counter, Creature* creature, uint32 itemEntry)
959959
{
960+
if (!sZoneDifficulty->CheckCompletionStatus(creature, player, category))
961+
return;
962+
960963
uint32 availableScore = player->GetPlayerSetting(ModZoneDifficultyString + "score", category).value;
961964

962965
auto reward = sZoneDifficulty->Rewards[category][itemType][counter];
@@ -970,24 +973,6 @@ void ZoneDifficulty::RewardItem(Player* player, uint8 category, uint8 itemType,
970973
}
971974
}
972975

973-
if (category == TYPE_RAID_T6)
974-
{
975-
if (!player->GetPlayerSetting(ModZoneDifficultyString + "ct", SETTING_BLACK_TEMPLE).value)
976-
{
977-
creature->Whisper("Ah, hero! The threads of fate bring you to me. To claim the rewards you desire, you must first confront Illidan Stormrage on Mythic difficulty.",
978-
LANG_UNIVERSAL, player);
979-
return;
980-
}
981-
} else if (category == TYPE_RAID_ZA)
982-
{
983-
if (!player->GetPlayerSetting(ModZoneDifficultyString + "ct", SETTING_ZULAMAN).value)
984-
{
985-
creature->Whisper("Ah, hero! The threads of fate bring you to me. To claim the rewards you desire, you must first confront Zul'jin on Mythic difficulty.",
986-
LANG_UNIVERSAL, player);
987-
return;
988-
}
989-
}
990-
991976
if (availableScore < reward.Price)
992977
{
993978
if (player->GetSession())
@@ -1017,9 +1002,9 @@ void ZoneDifficulty::RewardItem(Player* player, uint8 category, uint8 itemType,
10171002
player->GetSession()->SendAreaTriggerMessage("You were rewarded %s for %u points.", proto->Name1.c_str(), reward.Price);
10181003
};
10191004

1020-
void ZoneDifficulty::LogAndAnnounceKill(Unit* source, bool isMythic)
1005+
void ZoneDifficulty::LogAndAnnounceKill(Map* map, bool isMythic)
10211006
{
1022-
if (source->GetMap()->GetId() == 564)
1007+
if (map->GetId() == 564)
10231008
{
10241009
if (sZoneDifficulty->IsBlackTempleDone)
10251010
return;
@@ -1030,17 +1015,53 @@ void ZoneDifficulty::LogAndAnnounceKill(Unit* source, bool isMythic)
10301015

10311016
std::string names = "Realm first group: ";
10321017

1033-
if (Map* map = source->GetMap())
1034-
{
1035-
map->DoForAllPlayers([&](Player* mapPlayer) {
1036-
if (!mapPlayer->IsGameMaster())
1037-
{
1038-
names.append(mapPlayer->GetName() + ", ");
1039-
CharacterDatabase.Execute("INSERT INTO zone_difficulty_completion_logs (guid, type, mode) VALUES ({}, {}, {})", mapPlayer->GetGUID().GetCounter(), TYPE_RAID_T6, 1);
1040-
}
1041-
});
1042-
}
1018+
map->DoForAllPlayers([&](Player* mapPlayer) {
1019+
if (!mapPlayer->IsGameMaster())
1020+
{
1021+
names.append(mapPlayer->GetName() + ", ");
1022+
CharacterDatabase.Execute("INSERT INTO zone_difficulty_completion_logs (guid, type, mode) VALUES ({}, {}, {})", mapPlayer->GetGUID().GetCounter(), TYPE_RAID_T6, 1);
1023+
}
1024+
});
10431025

10441026
ChatHandler(nullptr).SendWorldText(names.c_str());
10451027
}
10461028
};
1029+
1030+
bool ZoneDifficulty::CheckCompletionStatus(Creature* creature, Player* player, uint32 category) const
1031+
{
1032+
if (category == TYPE_RAID_T6)
1033+
{
1034+
if (!player->GetPlayerSetting(ModZoneDifficultyString + "ct", SETTING_BLACK_TEMPLE).value)
1035+
{
1036+
creature->Whisper("Ah, hero! The threads of fate bring you to me. To claim the rewards you desire, you must first confront Illidan Stormrage on Mythic difficulty.",
1037+
LANG_UNIVERSAL, player);
1038+
return false;
1039+
}
1040+
}
1041+
else if (category == TYPE_RAID_ZA)
1042+
{
1043+
if (!player->GetPlayerSetting(ModZoneDifficultyString + "ct", SETTING_ZULAMAN).value)
1044+
{
1045+
creature->Whisper("Ah, hero! The threads of fate bring you to me. To claim the rewards you desire, you must first confront Zul'jin on Mythic difficulty.",
1046+
LANG_UNIVERSAL, player);
1047+
return false;
1048+
}
1049+
}
1050+
1051+
return true;
1052+
}
1053+
1054+
void ZoneDifficulty::ProcessCreatureDeath(Map* map, uint32 entry)
1055+
{
1056+
switch (entry)
1057+
{
1058+
case NPC_ILLIDAN_STORMRAGE:
1059+
map->DoForAllPlayers([&](Player* player)
1060+
{
1061+
player->UpdatePlayerSetting(ModZoneDifficultyString + "ct", SETTING_BLACK_TEMPLE, 1);
1062+
ChatHandler(player->GetSession()).PSendSysMessage("Congratulations on completing the Black Temple!");
1063+
});
1064+
sZoneDifficulty->LogAndAnnounceKill(map, true);
1065+
break;
1066+
}
1067+
}

src/mod_zone_difficulty_scripts.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -555,17 +555,7 @@ class mod_zone_difficulty_globalscript : public GlobalScript
555555
else if (map->IsRaid())
556556
{
557557
sZoneDifficulty->AddMythicmodeScore(map, sZoneDifficulty->Expansion[mapId], score);
558-
559-
if (source->GetEntry() == NPC_ILLIDAN_STORMRAGE)
560-
{
561-
map->DoForAllPlayers([&](Player* player)
562-
{
563-
player->UpdatePlayerSetting(ModZoneDifficultyString + "ct", SETTING_BLACK_TEMPLE, 1);
564-
ChatHandler(player->GetSession()).PSendSysMessage("Congratulations on completing the Black Temple!");
565-
});
566-
567-
sZoneDifficulty->LogAndAnnounceKill(source, true);
568-
}
558+
sZoneDifficulty->ProcessCreatureDeath(map, source->GetEntry());
569559
}
570560
/* debug
571561
* else

0 commit comments

Comments
 (0)