Skip to content

Commit

Permalink
Merge pull request #1 from aMannus/tokensanity-code-cleanup
Browse files Browse the repository at this point in the history
Tokensanity code cleanup
  • Loading branch information
leggettc18 authored Aug 14, 2022
2 parents 3f55409 + 8842d1e commit ca54853
Showing 1 changed file with 24 additions and 34 deletions.
58 changes: 24 additions & 34 deletions soh/src/overlays/actors/ovl_En_Si/z_en_si.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ s32 func_80AFB748(EnSi* this, GlobalContext* globalCtx);
void func_80AFB768(EnSi* this, GlobalContext* globalCtx);
void func_80AFB89C(EnSi* this, GlobalContext* globalCtx);
void func_80AFB950(EnSi* this, GlobalContext* globalCtx);
void Randomizer_GrantSkullReward(EnSi* this, GlobalContext* globalCtx);

s32 textId = 0xB4;
s32 giveItemId = ITEM_SKULL_TOKEN;
Expand Down Expand Up @@ -99,22 +100,7 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) {
if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) {
this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER;
if (gSaveContext.n64ddFlag) {
getItem = Randomizer_GetRandomizedItem(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum);
getItemId = getItem.getItemId;
if (getItem.getItemId == RG_ICE_TRAP) {
player->pendingIceTrap = true;
textId = 0xF8;
} else {
textId = getItem.textId;
giveItemId = getItem.itemId;
if (getItem.modIndex == MOD_NONE) {
Item_Give(globalCtx, giveItemId);
} else if (getItem.modIndex == MOD_RANDOMIZER) {
Randomizer_Item_Give(globalCtx, getItem);
}
}
player->getItemEntry = getItem;
//player->getItemId = getItemId;
Randomizer_GrantSkullReward(this, globalCtx);
} else {
Item_Give(globalCtx, giveItemId);
}
Expand All @@ -139,30 +125,13 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) {
}

void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);

Math_SmoothStepToF(&this->actor.scale.x, 0.25f, 0.4f, 1.0f, 0.0f);
Actor_SetScale(&this->actor, this->actor.scale.x);
this->actor.shape.rot.y += 0x400;

if (!CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_13)) {
if (gSaveContext.n64ddFlag) {
getItem = Randomizer_GetRandomizedItem(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum);
getItemId = getItem.getItemId;
if (getItemId == RG_ICE_TRAP) {
player->pendingIceTrap = true;
textId = 0xF8;
} else {
textId = getItem.textId;
giveItemId = getItem.itemId;
if (getItem.modIndex == MOD_NONE) {
Item_Give(globalCtx, giveItemId);
} else if (getItem.modIndex == MOD_RANDOMIZER) {
Randomizer_Item_Give(globalCtx, getItem);
}
}
//player->getItemId = getItemId;
player->getItemEntry = getItem;
Randomizer_GrantSkullReward(this, globalCtx);
} else {
Item_Give(globalCtx, giveItemId);
}
Expand Down Expand Up @@ -217,3 +186,24 @@ void EnSi_Draw(Actor* thisx, GlobalContext* globalCtx) {

}
}

void Randomizer_GrantSkullReward(EnSi* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);

getItem = Randomizer_GetRandomizedItem(GI_SKULL_TOKEN, this->actor.id, this->actor.params, globalCtx->sceneNum);
getItemId = getItem.getItemId;
if (getItemId == RG_ICE_TRAP) {
player->pendingIceTrap = true;
textId = 0xF8;
} else {
textId = getItem.textId;
giveItemId = getItem.itemId;
if (getItem.modIndex == MOD_NONE) {
Item_Give(globalCtx, giveItemId);
} else if (getItem.modIndex == MOD_RANDOMIZER) {
Randomizer_Item_Give(globalCtx, getItem);
}
}
// player->getItemId = getItemId;
player->getItemEntry = getItem;
}

0 comments on commit ca54853

Please sign in to comment.