1+ #include " soh/Enhancements/RogueLike/RogueLike.h"
2+ #include " soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
3+ #include " soh/ShipInit.hpp"
4+ #include " soh/ActorDB.h"
5+ #include " soh/Enhancements/custom-message/CustomMessageManager.h"
6+
7+ extern " C" {
8+ #include " variables.h"
9+ #include < macros.h>
10+ #include < functions.h>
11+
12+ extern PlayState* gPlayState ;
13+ }
14+
15+ // clang-format off
16+ std::vector<RogueLikeQuestObject> rogueLikeQuestList = {
17+ { RL_QUEST_HF_STALFOS , RL_QUEST_KILL , " Stal-Not-So-Child" , " The Stalchild in Hyrule Field have\n gotten bigger, take them out!" , 0 , 5 },
18+ };
19+ // clang-format on
20+
21+ extern std::vector<RogueLikeQuestObject> activeQuests;
22+
23+ bool CheckActiveQuestById (u8 questId) {
24+ for (auto & quest : activeQuests) {
25+ if (quest.questId == questId) {
26+ return true ;
27+ }
28+ }
29+ return false ;
30+ }
31+
32+ bool CheckQuestCompleteById (u8 questId) {
33+ for (auto & quest : activeQuests) {
34+ if (quest.questId == questId) {
35+ return (quest.questProgress == quest.questGoal );
36+ }
37+ }
38+ return false ;
39+ }
40+
41+ void RogueLike::Quests::AddQuestById (u8 questId) {
42+ if (CheckActiveQuestById (questId)) {
43+ return ;
44+ }
45+
46+ activeQuests.push_back (rogueLikeQuestList[questId]);
47+ }
48+
49+ void RogueLike::Quests::UpdateQuestProgress (u8 questId) {
50+ if (CheckActiveQuestById (questId)) {
51+ return ;
52+ }
53+
54+ activeQuests.at (questId).questProgress ++;
55+ }
56+
57+ static void InitRogueLikeQuests () {
58+ activeQuests.clear ();
59+ }
60+
61+ static void OnLoadGame () {
62+ activeQuests.clear ();
63+ for (auto & load : gSaveContext .ship .quest .data .rogueLike .quests ) {
64+ if (load.questDescription != NULL ) {
65+ activeQuests.push_back (load);
66+ }
67+ }
68+
69+ // Test Quest Add
70+ // RogueLike::Quests::AddQuestById(RL_QUEST_HF_STALFOS);
71+
72+ COND_HOOK (OnSceneSpawnActors, IS_ROGUELIKE , []() {
73+ if (gPlayState ->sceneNum == SCENE_HYRULE_FIELD ) {
74+ if (CheckActiveQuestById (RL_QUEST_HF_STALFOS )) {
75+ if (!CheckQuestCompleteById (RL_QUEST_HF_STALFOS )) {
76+ float centerX = 2475 .3f ;
77+ float centerZ = 496 .3f ;
78+ float radius = 100 .0f ;
79+
80+ for (int i = activeQuests.at (RL_QUEST_HF_STALFOS ).questProgress ;
81+ i < activeQuests.at (RL_QUEST_HF_STALFOS ).questGoal ; i++) {
82+ float angle = i * (2 * M_PI / 5 );
83+ float spawnX = centerX + radius * cosf (angle);
84+ float spawnZ = centerZ + radius * sinf (angle);
85+
86+ if (ActorDB::Instance->RetrieveEntry (ACTOR_EN_TEST ).entry .valid ) {
87+ Actor_Spawn (&gPlayState ->actorCtx , gPlayState , ACTOR_EN_TEST , spawnX, -4 .7f , spawnZ, 0 , 0 ,
88+ 0 , 1 , 0 );
89+ }
90+ }
91+ }
92+ }
93+ }
94+ });
95+
96+ COND_HOOK (OnActorKill, IS_ROGUELIKE , [](void * actor) {
97+ Actor* refActor = (Actor*)actor;
98+
99+ switch (refActor->id ) {
100+ case ACTOR_EN_TEST :
101+ if (CheckActiveQuestById (RL_QUEST_HF_STALFOS )) {
102+ if (!CheckQuestCompleteById (RL_QUEST_HF_STALFOS )) {
103+ activeQuests.at (RL_QUEST_HF_STALFOS ).questProgress ++;
104+ }
105+ }
106+ break ;
107+ default :
108+ break ;
109+ }
110+ });
111+
112+ COND_HOOK (OnOpenText, IS_ROGUELIKE , [](u16 * textId, bool * loadFromMessageTable) {
113+ if (std::to_string (*textId) == " 20542" ) {
114+ auto entry = CustomMessage::LoadVanillaMessageTableEntry (*textId);
115+ // std::string newText = "Stalfos have been attacking our Cucco's, please help us!";
116+ // entry.msg = newText.c_str();
117+ }
118+ })
119+ }
120+
121+ static RegisterShipInitFunc initFunc (InitRogueLikeQuests, {});
122+ static RegisterShipInitFunc initFunc2 (OnLoadGame, { " IS_ROGUELIKE" });
0 commit comments