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.
Initial commit for the develop-rando effort
- Loading branch information
1 parent
b24fe23
commit dcc4385
Showing
27 changed files
with
595 additions
and
5 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
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,7 @@ | ||
#include "ActorBehavior.h" | ||
|
||
void Rando::InitActorBehavior(bool isRando) { | ||
ActorBehavior::InitEnBoxBehavior(isRando); | ||
ActorBehavior::InitEnElforgBehavior(isRando); | ||
ActorBehavior::InitEnItem00Behavior(isRando); | ||
} |
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,20 @@ | ||
#ifndef RANDO_ACTOR_BEHAVIOR_H | ||
#define RANDO_ACTOR_BEHAVIOR_H | ||
|
||
#include "Rando/Rando.h" | ||
|
||
namespace Rando { | ||
|
||
void InitActorBehavior(bool isRando); | ||
|
||
namespace ActorBehavior { | ||
|
||
void InitEnBoxBehavior(bool isRando); | ||
void InitEnElforgBehavior(bool isRando); | ||
void InitEnItem00Behavior(bool isRando); | ||
|
||
} // namespace ActorBehavior | ||
|
||
} // namespace Rando | ||
|
||
#endif |
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,43 @@ | ||
#include "ActorBehavior.h" | ||
#include <libultraship/libultraship.h> | ||
|
||
extern "C" { | ||
#include "variables.h" | ||
|
||
s32 func_80832558(PlayState* play, Player* player, PlayerFuncD58 arg2); | ||
void Player_SetAction_PreserveMoveFlags(PlayState* play, Player* player, PlayerActionFunc actionFunc, s32 arg3); | ||
void Player_StopCutscene(Player* player); | ||
void func_80848294(PlayState* play, Player* player); | ||
} | ||
|
||
void Player_Action_65_override(Player* player, PlayState* play) { | ||
if (PlayerAnimation_Update(play, &player->skelAnime)) { | ||
Player_StopCutscene(player); | ||
func_80848294(play, player); | ||
} | ||
} | ||
|
||
void func_80837C78_override(PlayState* play, Player* player) { | ||
Player_SetAction_PreserveMoveFlags(play, player, Player_Action_65_override, 0); | ||
player->stateFlags1 |= (PLAYER_STATE1_400 | PLAYER_STATE1_20000000); | ||
} | ||
|
||
// This simply prevents the player from getting an item from the chest, but still | ||
// plays the chest opening animation and ensure the treasure chest flag is set | ||
void Rando::ActorBehavior::InitEnBoxBehavior(bool isRando) { | ||
static uint32_t shouldHookId = 0; | ||
GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::ShouldVanillaBehavior>(shouldHookId); | ||
|
||
shouldHookId = 0; | ||
|
||
if (!isRando) { | ||
return; | ||
} | ||
|
||
shouldHookId = REGISTER_VB_SHOULD(GI_VB_GIVE_ITEM_FROM_CHEST, { | ||
EnBox* enBox = static_cast<EnBox*>(opt); | ||
Player* player = GET_PLAYER(gPlayState); | ||
func_80832558(gPlayState, player, func_80837C78_override); | ||
*should = false; | ||
}); | ||
} |
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,63 @@ | ||
#include "ActorBehavior.h" | ||
#include <libultraship/libultraship.h> | ||
|
||
extern "C" { | ||
#include "variables.h" | ||
#include "functions.h" | ||
#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" | ||
|
||
void EnElforg_SpawnSparkles(EnElforg* thisx, PlayState* play, s32 life); | ||
} | ||
|
||
void EnElforg_DrawCustom(Actor* thisx, PlayState* play) { | ||
EnElforg* enElforg = (EnElforg*)thisx; | ||
Matrix_Scale(20.0f, 20.0f, 20.0f, MTXMODE_APPLY); | ||
RandoCheck check = RC_UNKNOWN; | ||
|
||
if (STRAY_FAIRY_TYPE(thisx) == STRAY_FAIRY_TYPE_CLOCK_TOWN) { | ||
check = RC_CLOCK_TOWN_STRAY_FAIRY; | ||
} else if (STRAY_FAIRY_TYPE(&enElforg->actor) == STRAY_FAIRY_TYPE_COLLECTIBLE) { | ||
auto checkData = Rando::StaticData::GetCheckFromFlag(FLAG_CYCL_SCENE_COLLECTIBLE, | ||
STRAY_FAIRY_GET_FLAG(&enElforg->actor), play->sceneId); | ||
check = checkData.check; | ||
} else if (STRAY_FAIRY_TYPE(&enElforg->actor) == STRAY_FAIRY_TYPE_FREE_FLOATING) { | ||
auto checkData = Rando::StaticData::GetCheckFromFlag(FLAG_CYCL_SCENE_SWITCH, | ||
STRAY_FAIRY_GET_FLAG(&enElforg->actor), play->sceneId); | ||
check = checkData.check; | ||
} | ||
|
||
if (check == RC_UNKNOWN) { | ||
return; | ||
} | ||
|
||
auto checkSaveData = gSaveContext.save.shipSaveInfo.rando.checks[check]; | ||
|
||
EnElforg_SpawnSparkles(enElforg, play, 16); | ||
thisx->shape.rot.y = thisx->shape.rot.y + 960; | ||
|
||
GetItem_Draw(play, Rando::StaticData::Items[checkSaveData.item].drawId); | ||
} | ||
|
||
void Rando::ActorBehavior::InitEnElforgBehavior(bool isRando) { | ||
static uint32_t onActorInitHookId = 0; | ||
GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::OnActorInit>(onActorInitHookId); | ||
|
||
onActorInitHookId = 0; | ||
|
||
if (!isRando) { | ||
return; | ||
} | ||
|
||
onActorInitHookId = | ||
GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnActorInit>(ACTOR_EN_ELFORG, [](Actor* actor) { | ||
EnElforg* enElforg = (EnElforg*)actor; | ||
|
||
// Currently this will override the draw of all stray fairies, but we should probably add a check for the | ||
// ones we support until we capture all of them in the Checks static data. | ||
if (STRAY_FAIRY_TYPE(&enElforg->actor) == STRAY_FAIRY_TYPE_CLOCK_TOWN || | ||
STRAY_FAIRY_TYPE(&enElforg->actor) == STRAY_FAIRY_TYPE_FREE_FLOATING || | ||
STRAY_FAIRY_TYPE(&enElforg->actor) == STRAY_FAIRY_TYPE_COLLECTIBLE) { | ||
enElforg->actor.draw = EnElforg_DrawCustom; | ||
} | ||
}); | ||
} |
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,74 @@ | ||
#include "ActorBehavior.h" | ||
#include <libultraship/libultraship.h> | ||
|
||
extern "C" { | ||
#include "functions.h" | ||
#include "variables.h" | ||
} | ||
|
||
void EnItem00_DrawCustomForFreestanding(Actor* thisx, PlayState* play) { | ||
EnItem00* enItem00 = (EnItem00*)thisx; | ||
Matrix_Scale(20.0f, 20.0f, 20.0f, MTXMODE_APPLY); | ||
|
||
auto checkData = Rando::StaticData::GetCheckFromFlag(FLAG_CYCL_SCENE_COLLECTIBLE, enItem00->collectibleFlag, | ||
gPlayState->sceneId); | ||
if (checkData.check == RC_UNKNOWN) { | ||
return; | ||
} | ||
|
||
auto checkSaveData = gSaveContext.save.shipSaveInfo.rando.checks[checkData.check]; | ||
|
||
GetItem_Draw(play, Rando::StaticData::Items[checkSaveData.item].drawId); | ||
} | ||
|
||
void Rando::ActorBehavior::InitEnItem00Behavior(bool isRando) { | ||
static uint32_t onActorInitHookId = 0; | ||
static uint32_t shouldHookId = 0; | ||
GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::OnActorInit>(onActorInitHookId); | ||
GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::ShouldVanillaBehavior>(shouldHookId); | ||
|
||
onActorInitHookId = 0; | ||
shouldHookId = 0; | ||
|
||
if (!isRando) { | ||
return; | ||
} | ||
|
||
onActorInitHookId = | ||
GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnActorInit>(ACTOR_EN_ITEM00, [](Actor* actor) { | ||
EnItem00* item00 = (EnItem00*)actor; | ||
|
||
// If it's one of our items ignore it | ||
if (item00->actor.params == ITEM00_NOTHING || item00->actor.params == (ITEM00_NOTHING | 0x8000)) { | ||
return; | ||
} | ||
|
||
auto checkData = Rando::StaticData::GetCheckFromFlag(FLAG_CYCL_SCENE_COLLECTIBLE, item00->collectibleFlag, | ||
gPlayState->sceneId); | ||
if (checkData.check == RC_UNKNOWN) { | ||
return; | ||
} | ||
|
||
auto checkSaveData = gSaveContext.save.shipSaveInfo.rando.checks[checkData.check]; | ||
|
||
if (checkSaveData.obtained) { | ||
Actor_Kill(&item00->actor); | ||
return; | ||
} | ||
|
||
actor->draw = EnItem00_DrawCustomForFreestanding; | ||
}); | ||
|
||
shouldHookId = REGISTER_VB_SHOULD(GI_VB_GIVE_ITEM_FROM_ITEM00, { | ||
EnItem00* item00 = static_cast<EnItem00*>(opt); | ||
|
||
// If it's one of our items ignore it | ||
if (item00->actor.params == ITEM00_NOTHING || item00->actor.params == (ITEM00_NOTHING | 0x8000)) { | ||
return; | ||
} | ||
|
||
Flags_SetCollectible(gPlayState, item00->collectibleFlag); | ||
Actor_Kill(&item00->actor); | ||
*should = false; | ||
}); | ||
} |
Oops, something went wrong.