Skip to content

Commit

Permalink
Merge pull request #105 from gymnast86/logic
Browse files Browse the repository at this point in the history
App:Various minor fixes
  • Loading branch information
gamestabled committed Apr 10, 2021
2 parents 3c72a23 + 3fd91cf commit e598976
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
6 changes: 3 additions & 3 deletions code/src/item_effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ void ItemEffect_PlaceMagicArrowsInInventory(SaveContext* saveCtx, s16 arg1, s16
ResetItemSlotsIfMatchesID(ItemSlots[ITEM_ARROW_ICE]);
ResetItemSlotsIfMatchesID(ItemSlots[ITEM_ARROW_LIGHT]);
} else if (saveCtx->items[ItemSlots[ITEM_BOW]] == ITEM_NONE) {
if (arg1 == 1) { // Fire Arrow
if (arg1 == 1 && saveCtx->items[ItemSlots[ITEM_ARROW_FIRE]] == ITEM_NONE) { // Fire Arrow
PushSlotIntoInventoryMenu(ItemSlots[ITEM_ARROW_FIRE]);
} else if (arg1 == 2) { // Ice Arrow
} else if (arg1 == 2 && saveCtx->items[ItemSlots[ITEM_ARROW_ICE]] == ITEM_NONE) { // Ice Arrow
PushSlotIntoInventoryMenu(ItemSlots[ITEM_ARROW_ICE]);
} else if (arg1 == 3) { // Light Arrow
} else if (arg1 == 3 && saveCtx->items[ItemSlots[ITEM_ARROW_LIGHT]] == ITEM_NONE) { // Light Arrow
PushSlotIntoInventoryMenu(ItemSlots[ITEM_ARROW_LIGHT]);
}
}
Expand Down
5 changes: 5 additions & 0 deletions code/src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ typedef enum {
EXCLUDE,
} ExcludeLocationSetting;

typedef enum {
TRICK_DISABLED,
TRICK_ENABLED,
} LogicTrickSetting;

typedef enum {
DAMAGEMULTIPLIER_HALF,
DAMAGEMULTIPLIER_DEFAULT,
Expand Down
4 changes: 2 additions & 2 deletions source/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ static std::vector<ItemLocation*> GetAccessibleLocations(std::vector<ItemLocatio
}
}
//Triforce has been found, seed is beatable, nothing else in this or future spheres matters
else if (location->GetPlacedItem().GetName() == "Triforce") {
else if (location->GetPlacedItem() == I_Triforce) {
sphere.clear();
sphere.push_back(location);
playthroughBeatable = true;
}
}
//All we care about is if the game is beatable, used to pare down playthrough
else if (mode == CHECK_BEATABLE && location->GetPlacedItem().GetName() == "Triforce") {
else if (mode == CHECK_BEATABLE && location->GetPlacedItem() == I_Triforce) {
playthroughBeatable = true;
return {}; //Return early for efficiency
}
Expand Down
9 changes: 6 additions & 3 deletions source/location_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2045,9 +2045,12 @@ namespace Exits { //name, scene, hint, events, locations, exits

Exit SpiritTemple_ChildClimb = Exit("Child Spirit Temple Climb", "Spirit Temple", "", NO_DAY_NIGHT_CYCLE, {}, {
//Locations
ItemLocationPairing(&SpiritTemple_ChildClimbNorthChest, []{return HasProjectile("Both") || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && HasProjectile("Adult")) || (SmallKeys(SpiritTempleKeys, 5) && IsChild && HasProjectile("Child"));}),
ItemLocationPairing(&SpiritTemple_ChildClimbEastChest, []{return HasProjectile("Both") || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && HasProjectile("Adult")) || (SmallKeys(SpiritTempleKeys, 5) && IsChild && HasProjectile("Child"));}),
ItemLocationPairing(&SpiritTemple_GS_SunOnFloorRoom, []{return HasProjectile("Both") || CanUse(CanUseItem::Dins_Fire) || ((DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) || Fairy || CanUse(CanUseItem::Nayrus_Love)) && (Sticks || KokiriSword || HasProjectile("Child"))) || (IsChild && SmallKeys(SpiritTempleKeys, 5) && HasProjectile("Child")) || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && (HasProjectile("Adult") || DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) || Fairy || CanUse(CanUseItem::Nayrus_Love)));}),
ItemLocationPairing(&SpiritTemple_ChildClimbNorthChest, []{return HasProjectile(HasProjectileAge::Both) || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && HasProjectile(HasProjectileAge::Adult)) || (SmallKeys(SpiritTempleKeys, 5) && IsChild && HasProjectile(HasProjectileAge::Child));}),
ItemLocationPairing(&SpiritTemple_ChildClimbEastChest, []{return HasProjectile(HasProjectileAge::Both) || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && HasProjectile(HasProjectileAge::Adult)) || (SmallKeys(SpiritTempleKeys, 5) && IsChild && HasProjectile(HasProjectileAge::Child));}),
ItemLocationPairing(&SpiritTemple_GS_SunOnFloorRoom, []{return HasProjectile(HasProjectileAge::Both) || CanUse(CanUseItem::Dins_Fire) ||
((DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) || Fairy || CanUse(CanUseItem::Nayrus_Love)) && (Sticks || KokiriSword || HasProjectile(HasProjectileAge::Child))) ||
(IsChild && SmallKeys(SpiritTempleKeys, 5) && HasProjectile(HasProjectileAge::Child)) ||
((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && (HasProjectile(HasProjectileAge::Adult) || DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) || Fairy || CanUse(CanUseItem::Nayrus_Love)));}),
}, {
//Exits
ExitPairing::Both(&SpiritTemple_CentralChamber, []{return HasExplosives;}),
Expand Down
10 changes: 5 additions & 5 deletions source/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,12 @@ namespace Logic {
(IsChildItem(itemName) && HasItem(itemName) && IsChild);
}

bool HasProjectile(std::string_view age) {
bool HasProjectile(HasProjectileAge age) {
return HasExplosives ||
(age == "Child" && (Slingshot || Boomerang)) ||
(age == "Adult" && (Hookshot || Bow )) ||
(age == "Both" && (Slingshot || Boomerang) && (Hookshot || Bow)) ||
(age == "Either" && (Slingshot || Boomerang || Hookshot || Bow));
(age == HasProjectileAge::Child && (Slingshot || Boomerang)) ||
(age == HasProjectileAge::Adult && (Hookshot || Bow )) ||
(age == HasProjectileAge::Both && (Slingshot || Boomerang) && (Hookshot || Bow)) ||
(age == HasProjectileAge::Either && (Slingshot || Boomerang || Hookshot || Bow));
}

//Updates all logic helpers. Should be called whenever a non-helper is changed
Expand Down
9 changes: 8 additions & 1 deletion source/logic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,17 @@ namespace Logic {
Light_Arrows,
};

enum class HasProjectileAge {
Adult,
Child,
Both,
Either,
};

extern void UpdateHelpers();
extern bool CanPlay(bool song);
extern bool CanUse(CanUseItem itemName);
extern bool HasProjectile(std::string_view age);
extern bool HasProjectile(HasProjectileAge age);
extern bool SmallKeys(u8 dungeonKeyCount, u8 requiredAmount);
extern bool EventsUpdated();
extern void LogicReset();
Expand Down
4 changes: 2 additions & 2 deletions source/spoiler_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static void WriteSettings() {
//List Excluded Locations
logtxt += "\nExcluded Locations:\n";
for (auto& l : Settings::excludeLocationsOptions) {
if (l->GetSelectedOptionText() == "Exclude") {
if (l->GetSelectedOptionIndex() == EXCLUDE) {
std::string name = l->GetName().data();

//get rid of newline characters if necessary
Expand All @@ -137,7 +137,7 @@ static void WriteSettings() {
//List Enabled Tricks
logtxt += "\nEnabled Tricks:\n";
for (auto& l : Settings::detailedLogicOptions) {
if (l->GetSelectedOptionText() == "Enabled" && l->IsCategory(OptionCategory::Setting)) {
if (l->GetSelectedOptionIndex() == TRICK_ENABLED && l->IsCategory(OptionCategory::Setting)) {
std::string name = l->GetName().data();

//get rid of newline characters if necessary
Expand Down

0 comments on commit e598976

Please sign in to comment.