diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2021-04-30 19:39:16 +0200 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2021-05-02 23:44:16 +0200 |
| commit | e702bffca953a97da1579ae68482e8afef32257b (patch) | |
| tree | 161347280c568c0d826b408d774ac70e4a06a021 /src | |
| parent | 5ad4559642c4e192fff84fd01a8b6a4ac3d39c57 (diff) | |
Decompile goronMerchant
Diffstat (limited to 'src')
| -rw-r--r-- | src/enemy/businessScrub.c | 4 | ||||
| -rw-r--r-- | src/fileScreen.c | 2 | ||||
| -rw-r--r-- | src/game.c | 2 | ||||
| -rw-r--r-- | src/npc/bladeBrothers.c | 2 | ||||
| -rw-r--r-- | src/npc/goronMerchant.c | 100 | ||||
| -rw-r--r-- | src/npc/librari.c | 2 | ||||
| -rw-r--r-- | src/npc/townMinish.c | 8 | ||||
| -rw-r--r-- | src/room.c | 4 |
8 files changed, 90 insertions, 34 deletions
diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 30f0000e..a6fa26a4 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -469,7 +469,7 @@ bool32 sub_0802915C(Entity* this) { return TRUE; break; case 0x1c: - if (CheckGlobalFlag(0x5a) == 0) + if (CheckGlobalFlag(AKINDO_BOTTLE_SELL) == 0) return TRUE; break; case 0x5c: @@ -486,7 +486,7 @@ bool32 sub_08029198(const struct SalesOffering* offer) { if ((offer->field_0x0 & 0xfc) != 0xc) { switch (offer->field_0x8) { case 0x1c: - tmp = CheckGlobalFlag(0x5a); + tmp = CheckGlobalFlag(AKINDO_BOTTLE_SELL); break; case 0x9: case 0x44: diff --git a/src/fileScreen.c b/src/fileScreen.c index f048b296..925e1f54 100644 --- a/src/fileScreen.c +++ b/src/fileScreen.c @@ -1009,7 +1009,7 @@ void HandleFileDelete(void) { sub_08050A64(gUnk_02019EE0.unk6); } -void FUN_080515c8(void) { +void sub_080515c8(void) { sub_080A7114(1); } @@ -247,7 +247,7 @@ void InitializePlayer(void) { MemClear((void*)pl, 0x88); gRoomControls.cameraTarget = pl; gPlayerState.playerAction = gUnk_080FCAC8[gScreenTransition.field_0xf]; - if (!CheckGlobalFlag(0x14)) { + if (!CheckGlobalFlag(EZERO_1ST)) { gPlayerState.flags.all |= 8; } switch (gScreenTransition.field_0xf) { diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index 7bb1fdc3..37067485 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -119,7 +119,7 @@ void sub_08068AFC(Entity* this) { sub_0807DD50(this); } -void FUN_08068b2c(Entity* this) { +void sub_08068b2c(Entity* this) { u32 uVar1; if (this->interactType == '\x02') { diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 5329bd15..06b6e9a2 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -6,13 +6,16 @@ #include "room.h" #include "flags.h" #include "script.h" +#include "save.h" -extern u32 sub_080696BC(Entity*); +extern u32 GoronMerchant_GetSalePrice(Entity*); extern void (*const gUnk_08111B88[])(Entity*); extern void (*const gUnk_08111B98[])(Entity*); -extern u16 gUnk_08111BA0[]; +const u16 GoronMerchant_KinstonePrices[]; + +extern u32 sub_0801E7D0(u32); void GoronMerchant(Entity* this) { if ((this->flags & 2) != 0) { @@ -78,7 +81,7 @@ void sub_08069660(Entity* this) { u32 uVar1; TextboxNoOverlap(0x2c1c, this); - gTextBox.field_0x10 = (u16)sub_080696BC(this); + gTextBox.field_0x10 = (u16)GoronMerchant_GetSalePrice(this); } void sub_08069684(void) { @@ -98,33 +101,86 @@ void sub_080696B0(void) { gRoomVars.itemForSaleIndex = 0; } -u32 sub_080696BC(Entity* this) { - u32 uVar1; +u32 GoronMerchant_GetSalePrice(Entity* this) { + u32 restockCount; u32 temp; - u32 iVar3; - s32 temp2; + u32 kinstoneType; + s32 itemForSale; - temp2 = gRoomVars.field_0x7; - if (temp2 > 0x70) { - iVar3 = 1; + itemForSale = gRoomVars.field_0x7; + if (itemForSale > 0x70) { + kinstoneType = 1; } else { - iVar3 = 0; + kinstoneType = 0; } - if (temp2 > 0x72) { - iVar3 = 2; + if (itemForSale > 0x72) { + kinstoneType = 2; } - temp = CheckGlobalFlag(0x3e); - uVar1 = BOOLCAST(temp); + temp = CheckGlobalFlag(GORON_KAKERA_LV2); + restockCount = BOOLCAST(temp); - if (CheckGlobalFlag(0x3f)) { - uVar1 = 2; + if (CheckGlobalFlag(GORON_KAKERA_LV3)) { + restockCount = 2; } - if (CheckGlobalFlag(0x40)) { - uVar1 = 3; + if (CheckGlobalFlag(GORON_KAKERA_LV4)) { + restockCount = 3; } - if (CheckGlobalFlag(0x41)) { - uVar1 = 4; + if (CheckGlobalFlag(GORON_KAKERA_LV5)) { + restockCount = 4; + } + return GoronMerchant_KinstonePrices[restockCount * 3 + kinstoneType]; +} + +void GoronMerchant_TryToBuyKinstone(Entity* this, ScriptExecutionContext* context) { + s32 salePrice = GoronMerchant_GetSalePrice(this); + if (salePrice <= gSave.stats.rupees) { + if (sub_0801E7D0(gRoomVars.field_0x7) < 99) { + ModRupees(-salePrice); + sub_080A7C18(0x5c, gRoomVars.field_0x7, 0); + gRoomVars.itemForSaleIndex = 0; + gRoomVars.field_0x7 = 0; + context->condition = 1; + } else { + TextboxNoOverlap(0x2c1f, this); + context->condition = 0; + } + } else { + TextboxNoOverlap(0x2c1e, this); + context->condition = 0; } - return gUnk_08111BA0[uVar1 * 3 + iVar3]; + gActiveScriptInfo.flags = gActiveScriptInfo.flags | 1; } + +void (*const gUnk_08111B88[])(Entity*) = { + sub_08069584, + sub_080695AC, + sub_080695E8, + sub_0806961C, +}; +void (*const gUnk_08111B98[])(Entity*) = { + sub_0806963C, + sub_08069654, +}; + +const u16 GoronMerchant_KinstonePrices[] = { + 300, + 200, + 50, + // prices after restock 1 + 300, + 200, + 50, + // prices after restock 2 + 300, + 200, + 50, + // prices after restock 3 + 300, + 200, + 50, + // prices after restock 4 + 300, + 200, + 50, +};
\ No newline at end of file diff --git a/src/npc/librari.c b/src/npc/librari.c index ce6fbefc..992a920c 100644 --- a/src/npc/librari.c +++ b/src/npc/librari.c @@ -43,7 +43,7 @@ void sub_0806B260(Entity* this, ScriptExecutionContext* context) { context->condition = 0; // flippers if (!GetInventoryValue(0x46)) { - if (CheckGlobalFlag(0x29)) { + if (CheckGlobalFlag(MIZUKAKI_START)) { index = 2; context->condition = 1; } else if (!CheckLocalFlag(0x7a)) { diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index df2d8fe3..79f35176 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -256,7 +256,7 @@ void sub_0806AFE8(Entity* this, ScriptExecutionContext* context) { void sub_0806B004(Entity* this, ScriptExecutionContext* context) { int idx = 0; - if (CheckGlobalFlag(0x29)) { + if (CheckGlobalFlag(MIZUKAKI_START)) { if (CheckLocalFlag(0x73)) { if (GetInventoryValue(0x46) == 0) { idx = 3; @@ -279,7 +279,7 @@ void sub_0806B004(Entity* this, ScriptExecutionContext* context) { void sub_0806B064(Entity* this) { int idx = 0; - if (CheckGlobalFlag(0x29)) { + if (CheckGlobalFlag(MIZUKAKI_START)) { idx = 1; if (CheckLocalFlag(0x73)) { idx = 2; @@ -294,8 +294,8 @@ void sub_0806B098(Entity* this) { if (GetInventoryValue(0x46) == 0) { idx = 1; - if (CheckGlobalFlag(0x29)) { - f = CheckGlobalFlag(0x2a); + if (CheckGlobalFlag(MIZUKAKI_START)) { + f = CheckGlobalFlag(MIZUKAKI_HARIFALL); idx = BOOLCAST(f); } } @@ -1003,13 +1003,13 @@ extern EntityData gUnk_080D9108; extern EntityData gUnk_080D9098; void sub_0804C018(void) { - if (!CheckGlobalFlag(0x20)) { + if (!CheckGlobalFlag(HAKA_KEY_LOST)) { // graveyard key if (GetInventoryValue(0x3c) == 1) { LoadRoomEntityList(&gUnk_080D90C8); LoadRoomEntityList(&gUnk_080D9108); } - } else if (!CheckGlobalFlag(0x21)) + } else if (!CheckGlobalFlag(HAKA_KEY_FOUND)) LoadRoomEntityList(&gUnk_080D9108); if (GetInventoryValue(0x3c) != 2) { |
