Skip to content

Commit 24fe3d6

Browse files
committed
Clean up and reorgs
1 parent ba47b50 commit 24fe3d6

2 files changed

Lines changed: 67 additions & 38 deletions

File tree

soh/soh/Enhancements/RogueLike/Quests.cpp

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId);
1919

2020
// clang-format off
2121
std::vector<RogueLikeQuestObject> rogueLikeQuestList = {
22-
{ RL_QUEST_HF_TRIAL_A, RL_QUEST_TRIAL, "Ganon's Fury I", "Watch out!", RL_QUEST_ACTIVE, 0, 1 },
23-
{ RL_QUEST_KF_HOPOFFAITH, RL_QUEST_SIGHTSEEING, "Hop of Faith", "Sidehop from the fence\nabove the waterfall and land\non the middle platform.", RL_QUEST_ACTIVE, 0, 1},
24-
{ RL_QUEST_KF_STRONGMAN, RL_QUEST_SIGHTSEEING, "Toe Crushers", "Mido likes rock, show them\nthat we don't!", RL_QUEST_ACTIVE, 0, 11 },
25-
{ RL_QUEST_KV_POTHUNT, RL_QUEST_SIGHTSEEING, "The Pot Thickens", "A magical pot with extra lives?\nFind out how many!", RL_QUEST_ACTIVE, 0, 4 },
26-
{ RL_QUEST_KV_STALFOS, RL_QUEST_KILL, "Stal-Not-So-Child", "The Stalchild in Hyrule Field have\ngotten bigger, take them out!", RL_QUEST_ACTIVE, 0, 5 },
27-
{ RL_QUEST_ZD_POTTERY, RL_QUEST_SIGHTSEEING, "A Smashing View", "Toss a pot off the edge\nof the waterfall.", RL_QUEST_ACTIVE, 0, 1 },
22+
{ RL_QUEST_HF_TRIAL_A, "Ganon's Fury I", "Watch out!", RL_QUEST_ACTIVE, 0, 1 },
23+
{ RL_QUEST_KF_HOPOFFAITH, "Hop of Faith", "Sidehop from the fence\nabove the waterfall and land\non the middle platform.", RL_QUEST_ACTIVE, 0, 1},
24+
{ RL_QUEST_KF_STRONGMAN, "Toe Crushers", "Mido likes rock, show them\nthat we don't!", RL_QUEST_ACTIVE, 0, 11 },
25+
{ RL_QUEST_KV_POTHUNT, "The Pot Thickens", "A magical pot with extra lives?\nFind out how many!", RL_QUEST_ACTIVE, 0, 4 },
26+
{ RL_QUEST_KV_STALFOS, "Stal-Not-So-Child", "The Stalchild in Hyrule Field have\ngotten bigger, take them out!", RL_QUEST_ACTIVE, 0, 5 },
27+
{ RL_QUEST_ZD_POTTERY, "A Smashing View", "Toss a pot off the edge\nof the waterfall.", RL_QUEST_ACTIVE, 0, 1 },
2828
};
2929

3030
std::vector<Vec3f> potHuntLocations = {
@@ -48,7 +48,7 @@ extern std::vector<RogueLikeQuestObject> activeQuests;
4848
static std::vector<Vec3f> potHuntAvailability;
4949
static std::vector<Actor*> currentTrialActorList;
5050
static bool potHuntActorSpawned = false;
51-
static bool showTrialConditions = true;
51+
static bool sendConditionMessage = true;
5252

5353
bool CheckActiveQuestById(u8 questId) {
5454
for (auto& quest : activeQuests) {
@@ -77,6 +77,33 @@ bool CheckQuestCompletedById(u8 questId) {
7777
return false;
7878
}
7979

80+
void SendQuestConditionMessage(u8 questId) {
81+
if (!sendConditionMessage) {
82+
return;
83+
}
84+
85+
std::string message = "";
86+
ImVec4 color = ImVec4(1, 1, 1, 1);
87+
88+
switch (questId) {
89+
case RL_QUEST_KV_POTHUNT:
90+
message = "A Magical Pot has appeared nearby.";
91+
color = ImVec4(0.25f, 0, 0.75f, 1);
92+
break;
93+
case RL_QUEST_HF_TRIAL_A:
94+
message = "Come back when you have a sword...";
95+
color = ImVec4(1, 0, 0, 1);
96+
break;
97+
default:
98+
return;
99+
}
100+
Notification::Emit({
101+
.message = message,
102+
.messageColor = color,
103+
});
104+
sendConditionMessage = false;
105+
}
106+
80107
void RogueLike::Quests::CompleteQuestById(u8 questId) {
81108
for (auto& quest : activeQuests) {
82109
if (quest.questId == questId) {
@@ -233,15 +260,31 @@ void StartQuest(u8 questId) {
233260
spawnPoint.y, spawnPoint.z, 0, 0, 0, 256, false);
234261
Actor_SetColorFilter(potActor, 0x1000, 150, 0, 1000);
235262
potHuntAvailability.erase(potHuntAvailability.begin() + potRoll);
236-
Notification::Emit({
237-
.message = "A Magical Pot has appeared nearby.",
238-
.messageColor = ImVec4(0.25f, 0, 0.75f, 1),
239-
});
263+
SendQuestConditionMessage(RL_QUEST_KV_POTHUNT);
264+
}
265+
break;
266+
default:
267+
break;
268+
}
269+
}
270+
271+
RogueLikeQuest FindTrialByLocation(Actor* trialActor) {
272+
switch (gPlayState->sceneNum) {
273+
case SCENE_HYRULE_FIELD:
274+
if (trialActor->world.pos.x == 335.571f && trialActor->world.pos.z == 2677.854f) {
275+
if (LINK_IS_ADULT && ((EQUIP_FLAG_SWORD_MASTER & gSaveContext.inventory.equipment) ||
276+
(EQUIP_FLAG_SWORD_BGS & gSaveContext.inventory.equipment))) {
277+
return RL_QUEST_HF_TRIAL_A;
278+
} else {
279+
SendQuestConditionMessage(RL_QUEST_HF_TRIAL_A);
280+
}
240281
}
241282
break;
242283
default:
243284
break;
244285
}
286+
287+
return RL_QUEST_ID_MAX;
245288
}
246289

247290
static void InitRogueLikeQuests() {
@@ -259,6 +302,7 @@ static void OnLoadGame() {
259302

260303
COND_HOOK(OnPlayerUpdate, IS_ROGUELIKE, []() {
261304
Player* player = GET_PLAYER(gPlayState);
305+
RogueLikeQuest questId = RL_QUEST_ID_MAX;
262306
static bool hopOfFaithStart = false;
263307

264308
if (CheckActiveQuestById(RL_QUEST_KF_HOPOFFAITH) && !CheckQuestGoalCompleteById(RL_QUEST_KF_HOPOFFAITH)) {
@@ -274,24 +318,17 @@ static void OnLoadGame() {
274318
}
275319
}
276320
}
277-
if (!CheckQuestGoalCompleteById(RL_QUEST_HF_TRIAL_A) && gPlayState->sceneNum == SCENE_HYRULE_FIELD) {
278-
if (!CheckActiveQuestById(RL_QUEST_HF_TRIAL_A)) {
279-
Actor* trialActor =
280-
Actor_FindNearby(gPlayState, &GET_PLAYER(gPlayState)->actor, ACTOR_BG_MJIN, ACTORCAT_BG, 45.0f);
281-
if (trialActor != NULL) {
282-
if (LINK_IS_ADULT && ((EQUIP_FLAG_SWORD_MASTER & gSaveContext.inventory.equipment) ||
283-
(EQUIP_FLAG_SWORD_BGS & gSaveContext.inventory.equipment))) {
284-
RogueLike::Quests::AddQuestById(RL_QUEST_HF_TRIAL_A);
285-
StartQuest(RL_QUEST_HF_TRIAL_A);
286-
} else {
287-
if (showTrialConditions) {
288-
Notification::Emit({
289-
.message = "Come back when you have a sword...",
290-
.messageColor = ImVec4(1, 0, 0, 1),
291-
});
292-
showTrialConditions = false;
293-
}
294-
}
321+
if (gPlayState->sceneNum == SCENE_HYRULE_FIELD) {
322+
Actor* trialActor =
323+
Actor_FindNearby(gPlayState, &GET_PLAYER(gPlayState)->actor, ACTOR_BG_MJIN, ACTORCAT_BG, 45.0f);
324+
if (trialActor != NULL) {
325+
questId = FindTrialByLocation(trialActor);
326+
if (questId == RL_QUEST_ID_MAX) {
327+
return;
328+
}
329+
if (!CheckActiveQuestById(questId)) {
330+
RogueLike::Quests::AddQuestById(questId);
331+
StartQuest(questId);
295332
}
296333
}
297334
}
@@ -301,7 +338,7 @@ static void OnLoadGame() {
301338
for (auto& quest : activeQuests) {
302339
RogueLike::Quests::ResetQuestProgress(quest.questId);
303340
}
304-
showTrialConditions = true;
341+
sendConditionMessage = true;
305342
});
306343

307344
COND_HOOK(OnRoomInit, IS_ROGUELIKE, [](u16 roomNum) {

soh/soh/Enhancements/RogueLike/Types.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ typedef enum {
1313
RL_MAX,
1414
} RoguelikeStats;
1515

16-
typedef enum {
17-
RL_QUEST_KILL,
18-
RL_QUEST_SIGHTSEEING,
19-
RL_QUEST_TRIAL,
20-
RL_QUEST_MAX,
21-
} RogueLikeQuestTypes;
22-
2316
typedef enum {
2417
RL_QUEST_ACTIVE,
2518
RL_QUEST_COMPLETE,
@@ -37,7 +30,6 @@ typedef enum {
3730

3831
typedef struct {
3932
u8 questId;
40-
u8 questType;
4133
const char* questName;
4234
const char* questDescription;
4335
u8 questStatus;

0 commit comments

Comments
 (0)