forked from HarbourMasters/2ship2harkinian
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move a bunch of things out of the main rando.cpp file
- Loading branch information
1 parent
0c4c6f2
commit 0a70999
Showing
21 changed files
with
437 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,41 @@ | ||
#include "ActorBehavior.h" | ||
|
||
void Rando::InitActorBehavior(bool isRando) { | ||
ActorBehavior::InitDmStkBehavior(isRando); | ||
ActorBehavior::InitEnBoxBehavior(isRando); | ||
ActorBehavior::InitEnElfgrpBehavior(isRando); | ||
ActorBehavior::InitEnElforgBehavior(isRando); | ||
ActorBehavior::InitEnItem00Behavior(isRando); | ||
ActorBehavior::InitEnSiBehavior(isRando); | ||
ActorBehavior::InitItemBHeartBehavior(isRando); | ||
extern "C" { | ||
#include "variables.h" | ||
} | ||
|
||
void MiscVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, void* optionalArg) { | ||
switch (id) { | ||
case GI_VB_GIVE_ITEM_FROM_GURUGURU: | ||
case GI_VB_GIVE_ITEM_FROM_SCRIPT: | ||
case GI_VB_GIVE_ITEM_FROM_SWORDSMAN: | ||
*should = false; | ||
break; | ||
} | ||
} | ||
|
||
void Rando::ActorBehavior::Init() { | ||
} | ||
|
||
void Rando::ActorBehavior::OnFileLoad() { | ||
Rando::ActorBehavior::InitDmStkBehavior(); | ||
Rando::ActorBehavior::InitEnBoxBehavior(); | ||
Rando::ActorBehavior::InitEnElfgrpBehavior(); | ||
Rando::ActorBehavior::InitEnElforgBehavior(); | ||
Rando::ActorBehavior::InitEnItem00Behavior(); | ||
Rando::ActorBehavior::InitEnSiBehavior(); | ||
Rando::ActorBehavior::InitItemBHeartBehavior(); | ||
|
||
static uint32_t onVanillaBehaviorHook = 0; | ||
|
||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::ShouldVanillaBehavior>(onVanillaBehaviorHook); | ||
|
||
onVanillaBehaviorHook = 0; | ||
|
||
if (!IS_RANDO) { | ||
return; | ||
} | ||
|
||
onVanillaBehaviorHook = | ||
GameInteractor::Instance->RegisterGameHook<GameInteractor::ShouldVanillaBehavior>(MiscVanillaBehaviorHandler); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "MiscBehavior.h" | ||
#include <libultraship/libultraship.h> | ||
|
||
extern "C" { | ||
#include "variables.h" | ||
} | ||
|
||
static bool queued = false; | ||
void Rando::MiscBehavior::CheckQueue() { | ||
if (queued) { | ||
return; | ||
} | ||
|
||
for (auto& randoSaveCheck : RANDO_SAVE_CHECKS) { | ||
if (randoSaveCheck.eligible && !randoSaveCheck.obtained) { | ||
queued = true; | ||
|
||
RandoItemId randoItemId = Rando::ConvertItem(randoSaveCheck.randoItemId); | ||
GameInteractor::Instance->events.emplace_back(GIEventGiveItem{ | ||
.showGetItemCutscene = !CVarGetInteger("gEnhancements.Cutscenes.SkipGetItemCutscenes", 0), | ||
.getItemText = Rando::StaticData::Items[randoItemId].name, | ||
.drawItem = [randoItemId]() { Rando::DrawItem(randoItemId); }, | ||
.giveItem = | ||
[&randoSaveCheck, randoItemId]() { | ||
Rando::GiveItem(randoItemId); | ||
randoSaveCheck.obtained = true; | ||
queued = false; | ||
} }); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
void Rando::MiscBehavior::CheckQueueReset() { | ||
queued = false; | ||
GameInteractor::Instance->currentEvent = GIEventNone{}; | ||
GameInteractor::Instance->events.clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "MiscBehavior.h" | ||
|
||
extern "C" { | ||
#include "variables.h" | ||
} | ||
|
||
// Entry point for the module, run once on game boot | ||
void Rando::MiscBehavior::Init() { | ||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSaveInit>(Rando::MiscBehavior::OnFileCreate); | ||
} | ||
|
||
void Rando::MiscBehavior::OnFileLoad() { | ||
static uint32_t onFlagSetHook = 0; | ||
static uint32_t onSceneFlagSetHook = 0; | ||
static uint32_t onPlayerUpdateHook = 0; | ||
|
||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnFlagSet>(onFlagSetHook); | ||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnSceneFlagSet>(onSceneFlagSetHook); | ||
GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::OnActorUpdate>(onPlayerUpdateHook); | ||
|
||
onFlagSetHook = 0; | ||
onSceneFlagSetHook = 0; | ||
onPlayerUpdateHook = 0; | ||
|
||
Rando::MiscBehavior::CheckQueueReset(); | ||
|
||
if (!IS_RANDO) { | ||
return; | ||
} | ||
|
||
onFlagSetHook = | ||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnFlagSet>(Rando::MiscBehavior::OnFlagSet); | ||
onSceneFlagSetHook = | ||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneFlagSet>(Rando::MiscBehavior::OnSceneFlagSet); | ||
onPlayerUpdateHook = GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnActorUpdate>( | ||
ACTOR_PLAYER, [](Actor* actor) { Rando::MiscBehavior::CheckQueue(); }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef RANDO_MISC_BEHAVIOR_H | ||
#define RANDO_MISC_BEHAVIOR_H | ||
|
||
#include "Rando/Rando.h" | ||
|
||
namespace Rando { | ||
|
||
namespace MiscBehavior { | ||
|
||
void Init(); | ||
void OnFileLoad(); | ||
|
||
void CheckQueue(); | ||
void CheckQueueReset(); | ||
void OnFileCreate(s16 fileNum); | ||
void OnFlagSet(FlagType flagType, u32 flag); | ||
void OnSceneFlagSet(s16 sceneId, FlagType flagType, u32 flag); | ||
|
||
} // namespace MiscBehavior | ||
|
||
} // namespace Rando | ||
|
||
#endif |
Oops, something went wrong.