Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to use Rupees as ammo #591

Merged
merged 6 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions code/src/item_effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,42 @@ void ItemEffect_GiveUpgrade(SaveContext* saveCtx, s16 arg1, s16 arg2) {
}
}
}

//Use rupees as ammo when count gets to 0 and the player has the corresponding item
void ItemEffect_RupeeAmmo(SaveContext* saveCtx) {
if(gSettingsContext.retroAmmo){
if(saveCtx->ammo[SLOT_BOW] == 0 && saveCtx->rupees >= 4 && (saveCtx->items[SLOT_BOW] == ITEM_BOW || saveCtx->items[SLOT_BOW] == ITEM_BOW_ARROW_FIRE || saveCtx->items[SLOT_BOW] == ITEM_BOW_ARROW_ICE || saveCtx->items[SLOT_BOW] == ITEM_BOW_ARROW_LIGHT)){
saveCtx->rupeeAccumulator -= 4;
saveCtx->ammo[SLOT_BOW] += 1;
}
if(saveCtx->ammo[SLOT_BOMB] == 0 && saveCtx->rupees >= 8 && saveCtx->items[SLOT_BOMB] == ITEM_BOMB){
saveCtx->rupeeAccumulator -= 8;
saveCtx->ammo[SLOT_BOMB] += 1;
}
if(saveCtx->ammo[SLOT_BOMBCHU] == 0 && saveCtx->rupees >= 12 && saveCtx->items[SLOT_BOMBCHU] == ITEM_BOMBCHU){
saveCtx->rupeeAccumulator -= 12;
saveCtx->ammo[SLOT_BOMBCHU] += 1;
}
if(saveCtx->ammo[SLOT_SLINGSHOT] == 0 && saveCtx->rupees >= 2 && saveCtx->items[SLOT_SLINGSHOT] == ITEM_SLINGSHOT){
saveCtx->rupeeAccumulator -= 2;
saveCtx->ammo[SLOT_SLINGSHOT] += 1;
}
if(saveCtx->ammo[SLOT_STICK] == 0 && saveCtx->rupees >= 15 && saveCtx->items[SLOT_STICK] == ITEM_STICK){
saveCtx->rupeeAccumulator -= 15;
saveCtx->ammo[SLOT_STICK] += 1;
}
if(saveCtx->ammo[SLOT_NUT] == 0 && saveCtx->rupees >= 4 && saveCtx->items[SLOT_NUT] == ITEM_NUT){
saveCtx->rupeeAccumulator -= 4;
saveCtx->ammo[SLOT_NUT] += 1;
}
//Use rupees as magic when it becomes low, when the player has magic, and when magic isn't being filled
if(saveCtx->magic < 0x18 && saveCtx->rupees >= 1 && (saveCtx->magicState == 0 || saveCtx->magicState == 7) && saveCtx->magicLevel > 0){
saveCtx->rupeeAccumulator -= 1;
saveCtx->magic += 0x01;
}
}
}

void ItemEffect_FillWalletUpgrade(SaveContext* saveCtx, s16 arg1, s16 arg2) {
if (gSettingsContext.startingMaxRupees) {
if (arg1 == 1) {
Expand Down
1 change: 1 addition & 0 deletions code/src/item_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void ItemEffect_GiveUpgrade(SaveContext* saveCtx, s16 arg1, s16 arg2);
void ItemEffect_IceTrap(SaveContext* saveCtx, s16 arg1, s16 arg2);
void ItemEffect_GiveMasterSword(SaveContext* saveCtx, s16 arg1, s16 arg2);
void ItemEffect_BeanPack(SaveContext* saveCtx, s16 arg1, s16 arg2);
void ItemEffect_RupeeAmmo(SaveContext* saveCtx);
void ItemEffect_FillWalletUpgrade(SaveContext* saveCtx, s16 arg1, s16 arg2);
void ItemEffect_OpenMaskShop(SaveContext* saveCtx, s16 arg1, s16 arg2);
void PushSlotIntoInventoryMenu(u8 itemSlot);
Expand Down
3 changes: 3 additions & 0 deletions code/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "savefile.h"
#include "multiplayer.h"
#include "grotto.h"
#include "item_effect.h"

#include "z3D/z3D.h"
#include "3ds/extdata.h"
Expand Down Expand Up @@ -44,6 +45,8 @@ void before_GlobalContext_Update(GlobalContext* globalCtx) {
Settings_SkipSongReplays();

Multiplayer_Run();

ItemEffect_RupeeAmmo(&gSaveContext);
}

void after_GlobalContext_Update() {
Expand Down
1 change: 1 addition & 0 deletions code/src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ typedef struct {
u8 zoraTunicAsChild;
u8 restoreISG;
u8 gkDurability;
u8 retroAmmo;

u8 itemPoolValue;
u8 iceTrapValue;
Expand Down
5 changes: 5 additions & 0 deletions source/descriptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,11 @@ string_view gkDurabilityRandomSafe = "Each Giant's Knife will get a random du
"between 10 and 50, with an average of 30."; //
//
/*------------------------------ //
| RUPEES AS AMMO | //
------------------------------*/ //
string_view retroAmmoDesc = "If you run out of ammo or magic, you'll use\n" //
"rupees instead."; //
/*------------------------------ //
| MULTIPLAYER | //
------------------------------*/ //
string_view mp_EnabledDesc = "Enables multiplayer.\n" //
Expand Down
1 change: 1 addition & 0 deletions source/descriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ extern string_view restoreISGdesc;
extern string_view gkDurabilityVanilla;
extern string_view gkDurabilityRandomRisk;
extern string_view gkDurabilityRandomSafe;
extern string_view retroAmmoDesc;

extern string_view mp_EnabledDesc;
extern string_view mp_SharedProgressDesc;
Expand Down
3 changes: 3 additions & 0 deletions source/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ Option GoronTunicAsChild = Option::Bool(2, "Child Goron Tunic", {"Disabled"
Option ZoraTunicAsChild = Option::Bool(2, "Child Zora Tunic", {"Disabled", "Enabled"}, {childZoraTunicDesc});
Option RestoreISG = Option::Bool("Restore ISG", {"Disabled", "Enabled"}, {restoreISGdesc}, OptionCategory::Setting, ON);
Option GkDurability = Option::U8 ("GK Durability", {"Vanilla", "Random Risk", "Random Safe"}, {gkDurabilityVanilla, gkDurabilityRandomRisk, gkDurabilityRandomSafe});
Option RetroAmmo = Option::Bool("Rupees as Ammo", {"Disabled", "Enabled"}, {retroAmmoDesc});
std::vector<Option *> itemUsabilityOptions = {
&FaroresWindAnywhere,
&AgeItemsToggle,
Expand All @@ -394,6 +395,7 @@ std::vector<Option *> itemUsabilityOptions = {
&ZoraTunicAsChild,
&RestoreISG,
&GkDurability,
&RetroAmmo,
};

// Item Pool Settings
Expand Down Expand Up @@ -1440,6 +1442,7 @@ SettingsContext FillContext() {
ctx.zoraTunicAsChild = (ZoraTunicAsChild) ? 1 : 0;
ctx.restoreISG = (RestoreISG) ? 1 : 0;
ctx.gkDurability = GkDurability.Value<u8>();
ctx.retroAmmo = (RetroAmmo) ? 1 : 0;

ctx.itemPoolValue = ItemPoolValue.Value<u8>();
ctx.iceTrapValue = IceTrapValue.Value<u8>();
Expand Down
1 change: 1 addition & 0 deletions source/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ extern Option GoronTunicAsChild;
extern Option ZoraTunicAsChild;
extern Option RestoreISG;
extern Option GkDurability;
extern Option RetroAmmo;

extern Option ItemPoolValue;
extern Option IceTrapValue;
Expand Down