mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
decent start on consolidation
This commit is contained in:
parent
84911ee07d
commit
857a7d87aa
7 changed files with 45 additions and 41 deletions
|
@ -545,12 +545,18 @@ void Randomizer::ParseItemLocations(std::string spoilerFileName) {
|
|||
}
|
||||
}
|
||||
|
||||
GetItemID Randomizer::GetItemFromActor(s16 actorId, GetItemID ogItemId) {
|
||||
return GetItemFromGet(this->itemLocations[GetCheckFromActor(actorId, ogItemId)], ogItemId);
|
||||
s32 Randomizer::GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ) {
|
||||
if (actorId != -1) {
|
||||
s32 itemId = GetItemFromActor(actorId, ogId);
|
||||
return itemId;
|
||||
} else {
|
||||
s32 itemId = GetItemFromSceneParamsAndHomePos(sceneNum, actorParams, homePosX, homePosY, homePosZ, ogId);
|
||||
return itemId;
|
||||
}
|
||||
}
|
||||
|
||||
GetItemID Randomizer::GetItemFromSceneAndParams(s16 sceneNum, s16 actorParams, GetItemID ogItemId) {
|
||||
return GetItemFromGet(this->itemLocations[GetCheckFromSceneAndParams(sceneNum, actorParams)], ogItemId);
|
||||
GetItemID Randomizer::GetItemFromActor(s16 actorId, GetItemID ogItemId) {
|
||||
return GetItemFromGet(this->itemLocations[GetCheckFromActor(actorId, ogItemId)], ogItemId);
|
||||
}
|
||||
|
||||
GetItemID Randomizer::GetItemFromSceneParamsAndHomePos(s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ, GetItemID ogItemId) {
|
||||
|
|
|
@ -12,7 +12,9 @@ class Randomizer {
|
|||
std::unordered_map<RandomizerCheck, RandomizerGet> itemLocations;
|
||||
GetItemID GetItemFromGet(RandomizerGet randoGet, GetItemID ogItemId);
|
||||
RandomizerCheck GetCheckFromActor(s16 actorId, GetItemID ogItemId);
|
||||
RandomizerCheck GetCheckFromSceneAndParams(s16 sceneNum, s16 actorParams, s32 homePosX = 0, s32 homePosY = 0, s32 homePosZ = 0);
|
||||
RandomizerCheck GetCheckFromSceneAndParams(s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ);
|
||||
GetItemID GetItemFromActor(s16 actorId, GetItemID ogItemId);
|
||||
GetItemID GetItemFromSceneParamsAndHomePos(s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ, GetItemID ogItemId);
|
||||
|
||||
public:
|
||||
Randomizer();
|
||||
|
@ -20,9 +22,7 @@ class Randomizer {
|
|||
|
||||
void LoadItemLocations();
|
||||
void ParseItemLocations(std::string spoilerfilename);
|
||||
GetItemID GetItemFromActor(s16 actorId, GetItemID ogItemId);
|
||||
GetItemID GetItemFromSceneAndParams(s16 sceneNum, s16 actorParams, GetItemID ogItemId);
|
||||
GetItemID GetItemFromSceneParamsAndHomePos(s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ, GetItemID ogItemId);
|
||||
s32 GetRandomizedItemId(GetItemID ogId, s16 actorId = -1, s16 sceneNum = -1, s16 actorParams = -1, s32 homePosX = 0, s32 homePosY = 0, s32 homePosZ = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1004,15 +1004,28 @@ extern "C" void ParseItemLocations(const char* spoilerfilename) {
|
|||
OTRGlobals::Instance->gRandomizer->ParseItemLocations(spoilerfilename);
|
||||
}
|
||||
|
||||
extern "C" GetItemID GetItemFromActor(s16 actorId, GetItemID ogItemId) {
|
||||
return OTRGlobals::Instance->gRandomizer->GetItemFromActor(actorId, ogItemId);
|
||||
extern "C" s32 GetRandomizedItemId(GetItemID ogId, s16 sceneNum, s16 actorParams) {
|
||||
return OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, -1, sceneNum, actorParams);
|
||||
}
|
||||
|
||||
extern "C" GetItemID GetItemFromSceneAndParams(s16 sceneNum, s16 actorParams, GetItemID ogItemId) {
|
||||
return OTRGlobals::Instance->gRandomizer->GetItemFromSceneAndParams(sceneNum, actorParams, ogItemId);
|
||||
// the lack of optional params in c is frustrating
|
||||
extern "C" s32 GetRandomizedItemIdFromActor(GetItemID ogId, s16 actorId ) {
|
||||
return OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, actorId);
|
||||
}
|
||||
|
||||
// use an explicit (s32) cast on the position values from the Vec3f when calling
|
||||
extern "C" GetItemID GetItemFromSceneParamsAndHomePos(s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ, GetItemID ogItemId) {
|
||||
return OTRGlobals::Instance->gRandomizer->GetItemFromSceneParamsAndHomePos(sceneNum, actorParams, homePosX, homePosY, homePosZ, ogItemId);
|
||||
extern "C" s32 GetRandomizedItemIdFromPosition(GetItemID ogId, s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ) {
|
||||
return OTRGlobals::Instance->gRandomizer->GetRandomizedItemId(ogId, -1, sceneNum, actorParams, homePosX, homePosY, homePosZ);
|
||||
}
|
||||
|
||||
// extern "C" GetItemID GetItemFromActor(s16 actorId, GetItemID ogItemId) {
|
||||
// return OTRGlobals::Instance->gRandomizer->GetItemFromActor(actorId, ogItemId);
|
||||
// }
|
||||
|
||||
// extern "C" GetItemID GetItemFromSceneAndParams(s16 sceneNum, s16 actorParams, GetItemID ogItemId) {
|
||||
// return OTRGlobals::Instance->gRandomizer->GetItemFromSceneAndParams(sceneNum, actorParams, ogItemId);
|
||||
// }
|
||||
|
||||
// // use an explicit (s32) cast on the position values from the Vec3f when calling
|
||||
// extern "C" GetItemID GetItemFromSceneParamsAndHomePos(s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ, GetItemID ogItemId) {
|
||||
// return OTRGlobals::Instance->gRandomizer->GetItemFromSceneParamsAndHomePos(sceneNum, actorParams, homePosX, homePosY, homePosZ, ogItemId);
|
||||
// }
|
||||
|
|
|
@ -75,8 +75,10 @@ void AudioPlayer_Play(const uint8_t* buf, uint32_t len);
|
|||
void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples);
|
||||
int Controller_ShouldRumble(size_t i);
|
||||
void ParseItemLocations(const char* spoilerfilename);
|
||||
GetItemID GetItemFromActor(s16 actorId, GetItemID ogItemId);
|
||||
GetItemID GetItemFromSceneAndParams(s16 sceneNum, s16 actorParams, GetItemID ogItemId);
|
||||
s32 GetRandomizedItemId(GetItemID ogId, s16 sceneNum, s16 actorParams);
|
||||
s32 GetRandomizedItemIdFromActor(GetItemID ogId, s16 actorId);
|
||||
s32 GetRandomizedItemIdFromPosition(GetItemID ogId, s16 sceneNum, s16 actorParams, s32 homePosX, s32 homePosY, s32 homePosZ);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -332,11 +332,6 @@ void EnItem00_SetupAction(EnItem00* this, EnItem00ActionFunc actionFunc) {
|
|||
this->actionFunc = actionFunc;
|
||||
}
|
||||
|
||||
s32 Item00_GetRandomizedItemId(EnItem00* this, s16 sceneNum, s16 actorParams) {
|
||||
s32 itemId = GetItemFromSceneAndParams(sceneNum, this->actor.params, this->getItemId);
|
||||
return itemId;
|
||||
}
|
||||
|
||||
void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
EnItem00* this = (EnItem00*)thisx;
|
||||
s32 pad;
|
||||
|
@ -695,7 +690,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
|
|||
}
|
||||
|
||||
if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, globalCtx)) {
|
||||
getItemId = Item00_GetRandomizedItemId(this, globalCtx->sceneNum, this->actor.params);
|
||||
getItemId = GetRandomizedItemId(globalCtx->sceneNum, this->actor.params, this->getItemId);
|
||||
func_8002F554(&this->actor, globalCtx, getItemId);
|
||||
}
|
||||
|
||||
|
@ -1056,7 +1051,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
|
|||
|
||||
if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, globalCtx)) {
|
||||
if (gSaveContext.n64ddFlag) {
|
||||
getItemId = Item00_GetRandomizedItemId(this, globalCtx->sceneNum, this->actor.params);
|
||||
getItemId = GetRandomizedItemId(globalCtx->sceneNum, this->actor.params, this->getItemId);
|
||||
}
|
||||
func_8002F554(&this->actor, globalCtx, getItemId);
|
||||
}
|
||||
|
|
|
@ -383,11 +383,6 @@ void EnBox_AppearAnimation(EnBox* this, GlobalContext* globalCtx) {
|
|||
}
|
||||
}
|
||||
|
||||
s32 EnBox_GetRandomizedItemId(s16 actorParams, s16 sceneNum) {
|
||||
s32 itemId = GetItemFromSceneAndParams(sceneNum, actorParams, actorParams >> 5 & 0x7F);
|
||||
return 0 - itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chest is ready to be open
|
||||
*/
|
||||
|
@ -429,8 +424,7 @@ void EnBox_WaitOpen(EnBox* this, GlobalContext* globalCtx) {
|
|||
func_8002DBD0(&this->dyna.actor, &sp4C, &player->actor.world.pos);
|
||||
if (sp4C.z > -50.0f && sp4C.z < 0.0f && fabsf(sp4C.y) < 10.0f && fabsf(sp4C.x) < 20.0f &&
|
||||
Player_IsFacingActor(&this->dyna.actor, 0x3000, globalCtx)) {
|
||||
func_8002F554(&this->dyna.actor, globalCtx,
|
||||
EnBox_GetRandomizedItemId(this->dyna.actor.params, globalCtx->sceneNum));
|
||||
func_8002F554(&this->dyna.actor, globalCtx, GetRandomizedItemId(this->dyna.actor.params >> 5 & 0x7F, globalCtx->sceneNum, this->dyna.actor.params));
|
||||
}
|
||||
if (Flags_GetTreasure(globalCtx, this->dyna.actor.params & 0x1F)) {
|
||||
EnBox_SetupAction(this, EnBox_Open);
|
||||
|
|
|
@ -294,11 +294,6 @@ void func_80ABA244(EnNiwLady* this, GlobalContext* globalCtx) {
|
|||
}
|
||||
}
|
||||
|
||||
s32 NiwLady_GetRandomizedItemId(EnNiwLady* this, GetItemID ogId) {
|
||||
s32 itemId = GetItemFromActor(this->actor.id, ogId);
|
||||
return itemId;
|
||||
}
|
||||
|
||||
void func_80ABA654(EnNiwLady* this, GlobalContext* globalCtx) {
|
||||
if (this->unk_262 == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx)) {
|
||||
Message_CloseTextbox(globalCtx);
|
||||
|
@ -309,9 +304,8 @@ void func_80ABA654(EnNiwLady* this, GlobalContext* globalCtx) {
|
|||
if (!(gSaveContext.itemGetInf[0] & 0x1000)) {
|
||||
this->actor.parent = NULL;
|
||||
|
||||
this->getItemId = NiwLady_GetRandomizedItemId(this, GI_BOTTLE);
|
||||
|
||||
func_8002F434(&this->actor, globalCtx, NiwLady_GetRandomizedItemId(this, GI_BOTTLE), 100.0f, 50.0f);
|
||||
this->getItemId = GetRandomizedItemIdFromActor(GI_BOTTLE, this->actor.id);
|
||||
func_8002F434(&this->actor, globalCtx, GetRandomizedItemIdFromActor(GI_BOTTLE, this->actor.id), 100.0f, 50.0f); //not sure if calling again makes sense here or if we should just use this->getItemId
|
||||
this->actionFunc = func_80ABAC00;
|
||||
return;
|
||||
}
|
||||
|
@ -393,7 +387,7 @@ void func_80ABA9B8(EnNiwLady* this, GlobalContext* globalCtx) {
|
|||
case 0:
|
||||
Message_CloseTextbox(globalCtx);
|
||||
this->actor.parent = NULL;
|
||||
func_8002F434(&this->actor, globalCtx, NiwLady_GetRandomizedItemId(this, GI_POCKET_EGG), 200.0f,
|
||||
func_8002F434(&this->actor, globalCtx, GetRandomizedItemIdFromActor(GI_POCKET_EGG, this->actor.id), 200.0f,
|
||||
100.0f);
|
||||
this->actionFunc = func_80ABAC00;
|
||||
break;
|
||||
|
@ -447,7 +441,7 @@ void func_80ABAC00(EnNiwLady* this, GlobalContext* globalCtx) {
|
|||
getItemId = this->getItemId;
|
||||
if (LINK_IS_ADULT) {
|
||||
getItemId =
|
||||
!(gSaveContext.itemGetInf[2] & 0x1000) ? NiwLady_GetRandomizedItemId(this, GI_POCKET_EGG) : GI_COJIRO;
|
||||
!(gSaveContext.itemGetInf[2] & 0x1000) ? GetRandomizedItemIdFromActor(GI_POCKET_EGG, this->actor.id) : GI_COJIRO;
|
||||
}
|
||||
func_8002F434(&this->actor, globalCtx, getItemId, 200.0f, 100.0f);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue