Skip to content

Commit

Permalink
Fishing Prize Models
Browse files Browse the repository at this point in the history
  • Loading branch information
HylianFreddy committed Dec 10, 2023
1 parent c4af77e commit 4dd5121
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 1 deletion.
5 changes: 5 additions & 0 deletions code/src/actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "bean_plant.h"
#include "sheik.h"
#include "skulltula_people.h"
#include "fishing.h"

#define OBJECT_GI_KEY 170
#define OBJECT_GI_BOSSKEY 185
Expand Down Expand Up @@ -143,6 +144,10 @@ void Actor_Init() {
gActorOverlayTable[0xF1].initInfo->destroy = ItemOcarina_rDestroy;
gActorOverlayTable[0xF1].initInfo->draw = ItemOcarina_rDraw;

gActorOverlayTable[0xFE].initInfo->init = Fishing_rInit;
gActorOverlayTable[0xFE].initInfo->update = Fishing_rUpdateFish;
gActorOverlayTable[0xFE].initInfo->draw = Fishing_rDrawFish;

gActorOverlayTable[0xFF].initInfo->update = ObjOshihiki_rUpdate;

gActorOverlayTable[0x104].initInfo->init = BgSpot01Idomizu_rInit;
Expand Down
35 changes: 35 additions & 0 deletions code/src/fishing.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
#include "z3D/z3D.h"
#include "fishing.h"
#include "models.h"
#include "settings.h"

u32 isFishing(void) {
return gSaveContext.equips.buttonItems[0] == ITEM_FISHING_POLE && gGlobalContext->sceneNum == 73;
}

static s32 rewardObtained(void) {
u8 obtainedRewardFlag = gSaveContext.linkAge == AGE_ADULT ? 0x8 : 0x4;
return gSaveContext.fishingStats.flags & obtainedRewardFlag;
}

void Fishing_rInit(Actor* thisx, GlobalContext* globalCtx) {
u16 baseItemId = gSaveContext.linkAge == AGE_ADULT ? GI_SCALE_GOLD : GI_HEART_PIECE;
Fishing_Init(thisx, globalCtx);
if (gSettingsContext.fishingHints && thisx->params == EN_FISH_AQUARIUM && !rewardObtained()) {
Model_SpawnByActor(thisx, globalCtx, baseItemId);
}
}

void Fishing_rUpdateFish(Actor* thisx, GlobalContext* globalCtx) {
Fishing_UpdateFish(thisx, globalCtx);
if (gSettingsContext.fishingHints && thisx->params == EN_FISH_AQUARIUM && !rewardObtained()) {
thisx->textId = 0x40AE; // custom text, overrides vanilla "pond owner" record text
}
}

void Fishing_rDrawFish(Actor* thisx, GlobalContext* globalCtx) {
static s16 sPrizeRotation = 0x8000; // used because shape.rot.y is reset between update cycles

if (gSettingsContext.fishingHints && thisx->params == EN_FISH_AQUARIUM && !rewardObtained()) {
sPrizeRotation += 0x100;
thisx->shape.rot.y = sPrizeRotation;
Model_DrawByActor(thisx);
} else {
Fishing_DrawFish(thisx, globalCtx);
}
}
16 changes: 16 additions & 0 deletions code/src/fishing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef _FISHING_H_
#define _FISHING_H_

#include "z3D/z3D.h"

#define Fishing_Init ((ActorFunc)0x1C0AD8)
#define Fishing_UpdateFish ((ActorFunc)0x1F9ACC)
#define Fishing_DrawFish ((ActorFunc)0x1F98B4)

#define EN_FISH_AQUARIUM 200 // param for record fish in tank.

void Fishing_rInit(Actor* thisx, GlobalContext* globalCtx);
void Fishing_rUpdateFish(Actor* thisx, GlobalContext* globalCtx);
void Fishing_rDrawFish(Actor* thisx, GlobalContext* globalCtx);

#endif //_FISHING_H_
4 changes: 4 additions & 0 deletions code/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ void after_GlobalContext_Update() {
}

Multiplayer_Sync_Update();

if (gGlobalContext->state.running == 0) {
Model_DestroyAll();
}
}
1 change: 1 addition & 0 deletions code/src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ typedef struct {
u8 sheikHints;
u8 dampeHint;
u8 skulltulaHints;
u8 fishingHints;
u8 compassesShowReward;
u8 compassesShowWotH;
u8 mapsShowDungeonMode;
Expand Down
9 changes: 9 additions & 0 deletions source/custom_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,15 @@ void CreateAlwaysIncludedMessages() {
rutoDialog.Replace("$", ""); // Plural marker
CreateMessageFromTextObject(0x4050, 0, 2, 3, AddColorsAndFormat(rutoDialog, { itemColor }));
}

if (Settings::FishingHints) {
Text aquariumText = Text{ /*english*/ "You can have this if you catch a fish to put in the aquarium.",
/*french */ "",
/*spanish*/ "",
/*italian*/ "Puoi avere questo se catturi un pesce da mettere nell'acquario.",
/*german */ "" };
CreateMessageFromTextObject(0x40AE, 0, 2, 3, AddColorsAndFormat(aquariumText, {}));
}
}

std::vector<Text> CreateBaseCompassTexts() {
Expand Down
2 changes: 2 additions & 0 deletions source/descriptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ string_view dampeHintDesc = "Reading Dampe's diary will reveal the l
string_view skulltulaHintDesc = "Talking to a cursed House of Skulltula resident\n"//
"will tell you the reward they will give you for\n"//
"removing their curse."; //
string_view fishingHintsDesc = "The aquarium at the fishing pond will show what\n"//
"reward you can win as your current age."; //
/*------------------------------ //
| MAP AND COMPASS GIVES INFO | //
------------------------------*/ //
Expand Down
1 change: 1 addition & 0 deletions source/descriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ extern string_view totAltarHintsDesc;
extern string_view ganonHintsDesc;
extern string_view dampeHintDesc;
extern string_view skulltulaHintDesc;
extern string_view fishingHintsDesc;

extern string_view compassesShowRewardsDesc;
extern string_view compassesShowWotHDesc;
Expand Down
5 changes: 4 additions & 1 deletion source/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ Option ToTAltarHints = Option::Bool(2, "Temple of Time Altar",{"Off", "On"
Option GanonHints = Option::Bool(2, "Ganondorf", {"Off", "On"}, {ganonHintsDesc});
Option DampeHint = Option::Bool(2, "Dampe's Diary", {"Off", "On"}, {dampeHintDesc});
Option SkulltulaHints = Option::Bool(2, "House of Skulltula", {"Off", "On"}, {skulltulaHintDesc});
Option FishingHints = Option::Bool(2, "Fishing Prizes", {"Off", "On"}, {fishingHintsDesc});
Option ClearerHints = Option::U8 ("Hint Clarity", {"Obscure", "Ambiguous", "Clear"}, {obscureHintsDesc, ambiguousHintsDesc, clearHintsDesc});
Option CompassesShowReward = Option::U8 ("Compasses Show Rewards", {"No", "Yes"}, {compassesShowRewardsDesc});
Option CompassesShowWotH = Option::U8 ("Compasses Show WotH", {"No", "Yes"}, {compassesShowWotHDesc}, OptionCategory::Setting, ON);
Expand All @@ -347,6 +348,7 @@ std::vector<Option *> miscOptions = {
&GanonHints,
&DampeHint,
&SkulltulaHints,
&FishingHints,
&ClearerHints,
&CompassesShowReward,
&CompassesShowWotH,
Expand Down Expand Up @@ -1471,6 +1473,7 @@ SettingsContext FillContext() {
(!StartingLightArrows || (ShuffleMasterSword && !StartingMasterSword)));
ctx.dampeHint = DampeHint ? 1 : 0;
ctx.skulltulaHints = SkulltulaHints ? 1 : 0;
ctx.fishingHints = FishingHints ? 1 : 0;
ctx.compassesShowReward = CompassesShowReward.Value<u8>();
ctx.compassesShowWotH = CompassesShowWotH.Value<u8>();
ctx.mapsShowDungeonMode = MapsShowDungeonMode.Value<u8>();
Expand Down Expand Up @@ -2268,7 +2271,7 @@ void ForceChange(u32 kDown, Option* currentSetting) {
}

// Manage toggle for misc hints options
ToggleSet(miscOptions, &MiscHints, &ToTAltarHints, &SkulltulaHints);
ToggleSet(miscOptions, &MiscHints, &ToTAltarHints, &FishingHints);

if (ChestAppearance.IsNot(CHESTAPPEARANCE_VANILLA)) {
ChestAgony.Unhide();
Expand Down
1 change: 1 addition & 0 deletions source/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ extern Option ToTAltarHints;
extern Option GanonHints;
extern Option DampeHint;
extern Option SkulltulaHints;
extern Option FishingHints;
extern Option CompassesShowReward;
extern Option CompassesShowWotH;
extern Option MapsShowDungeonMode;
Expand Down

0 comments on commit 4dd5121

Please sign in to comment.