mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-19 21:03:42 -07:00
Available Checks Prices (#5446)
* Improved the item location price availability. * Moved the available checks price logic into location_access.cpp. * Fixed typo and clarified check status identified.
This commit is contained in:
parent
b30fff5d57
commit
e0d5fbec42
5 changed files with 67 additions and 17 deletions
|
@ -421,7 +421,7 @@ bool AddCheckToLogic(LocationAccess& locPair, GetAccessibleLocationsStruct& gals
|
||||||
Rando::ItemLocation* location = ctx->GetItemLocation(loc);
|
Rando::ItemLocation* location = ctx->GetItemLocation(loc);
|
||||||
RandomizerGet locItem = location->GetPlacedRandomizerGet();
|
RandomizerGet locItem = location->GetPlacedRandomizerGet();
|
||||||
|
|
||||||
if (!location->IsAddedToPool() && locPair.ConditionsMet(parentRegion, gals.calculatingAvailableChecks)) {
|
if (!location->IsAddedToPool() && locPair.ConditionsMet(parentRegion)) {
|
||||||
if (gals.calculatingAvailableChecks) {
|
if (gals.calculatingAvailableChecks) {
|
||||||
gals.accessibleLocations.push_back(loc);
|
gals.accessibleLocations.push_back(loc);
|
||||||
StopPerformanceTimer(PT_LOCATION_LOGIC);
|
StopPerformanceTimer(PT_LOCATION_LOGIC);
|
||||||
|
|
|
@ -70,4 +70,4 @@ void GeneratePlaythrough();
|
||||||
|
|
||||||
bool CheckBeatable(RandomizerGet ignore=RG_NONE);
|
bool CheckBeatable(RandomizerGet ignore=RG_NONE);
|
||||||
|
|
||||||
void ValidateEntrances(bool checkPoeCollectorAccess, bool checkOtherEntranceAccess);
|
void ValidateEntrances(bool checkPoeCollectorAccess, bool checkOtherEntranceAccess);
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
#include "soh/Enhancements/debugger/performanceTimer.h"
|
#include "soh/Enhancements/debugger/performanceTimer.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <soh/OTRGlobals.h>
|
||||||
|
|
||||||
|
#include "3drando/shops.hpp"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern PlayState* gPlayState;
|
extern PlayState* gPlayState;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +33,7 @@ bool LocationAccess::CheckConditionAtAgeTime(bool& age, bool& time) const {
|
||||||
return GetConditionsMet();
|
return GetConditionsMet();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocationAccess::ConditionsMet(Region* parentRegion, bool calculatingAvailableChecks) const {
|
bool LocationAccess::ConditionsMet(Region* parentRegion) const {
|
||||||
// WARNING enterance validation can run this after resetting the access for sphere 0 validation
|
// WARNING enterance validation can run this after resetting the access for sphere 0 validation
|
||||||
// When refactoring ToD access, either fix the above or do not assume that we
|
// When refactoring ToD access, either fix the above or do not assume that we
|
||||||
// have any access at all just because this is being run
|
// have any access at all just because this is being run
|
||||||
|
@ -44,17 +46,71 @@ bool LocationAccess::ConditionsMet(Region* parentRegion, bool calculatingAvailab
|
||||||
conditionsMet = true;
|
conditionsMet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return conditionsMet &&
|
return conditionsMet && CanBuy();
|
||||||
(calculatingAvailableChecks || CanBuy()); // TODO: run CanBuy when price is known due to settings
|
}
|
||||||
|
|
||||||
|
static uint16_t GetMinimumPrice(const Rando::Location* loc) {
|
||||||
|
extern PriceSettingsStruct shopsanityPrices;
|
||||||
|
extern PriceSettingsStruct scrubPrices;
|
||||||
|
extern PriceSettingsStruct merchantPrices;
|
||||||
|
PriceSettingsStruct priceSettings = loc->GetRCType() == RCTYPE_SHOP ? shopsanityPrices
|
||||||
|
: loc->GetRCType() == RCTYPE_SCRUB ? scrubPrices
|
||||||
|
: merchantPrices;
|
||||||
|
|
||||||
|
auto ctx = Rando::Context::GetInstance();
|
||||||
|
switch (ctx->GetOption(priceSettings.main).Get()) {
|
||||||
|
case RO_PRICE_VANILLA:
|
||||||
|
return loc->GetVanillaPrice();
|
||||||
|
case RO_PRICE_CHEAP_BALANCED:
|
||||||
|
return 0;
|
||||||
|
case RO_PRICE_BALANCED:
|
||||||
|
return 0;
|
||||||
|
case RO_PRICE_FIXED:
|
||||||
|
return ctx->GetOption(priceSettings.fixedPrice).Get() * 5;
|
||||||
|
case RO_PRICE_RANGE: {
|
||||||
|
uint16_t range1 = ctx->GetOption(priceSettings.range1).Get() * 5;
|
||||||
|
uint16_t range2 = ctx->GetOption(priceSettings.range1).Get() * 5;
|
||||||
|
return range1 < range2 ? range1 : range2;
|
||||||
|
}
|
||||||
|
case RO_PRICE_SET_BY_WALLET: {
|
||||||
|
if (ctx->GetOption(priceSettings.noWallet).Get()) {
|
||||||
|
return 0;
|
||||||
|
} else if (ctx->GetOption(priceSettings.childWallet).Get()) {
|
||||||
|
return 1;
|
||||||
|
} else if (ctx->GetOption(priceSettings.adultWallet).Get()) {
|
||||||
|
return 100;
|
||||||
|
} else if (ctx->GetOption(priceSettings.giantWallet).Get()) {
|
||||||
|
return 201;
|
||||||
|
} else {
|
||||||
|
return 501;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocationAccess::CanBuy() const {
|
bool LocationAccess::CanBuy() const {
|
||||||
return CanBuyAnother(location);
|
const auto& loc = Rando::StaticData::GetLocation(location);
|
||||||
|
const auto& itemLoc = OTRGlobals::Instance->gRandoContext->GetItemLocation(location);
|
||||||
|
|
||||||
|
if (loc->GetRCType() == RCTYPE_SHOP || loc->GetRCType() == RCTYPE_SCRUB || loc->GetRCType() == RCTYPE_MERCHANT) {
|
||||||
|
// Checks should only be identified while playing
|
||||||
|
if (itemLoc->GetCheckStatus() != RCSHOW_IDENTIFIED) {
|
||||||
|
return CanBuyAnother(GetMinimumPrice(loc));
|
||||||
|
} else {
|
||||||
|
return CanBuyAnother(itemLoc->GetPrice());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CanBuyAnother(RandomizerCheck rc) {
|
bool CanBuyAnother(RandomizerCheck rc) {
|
||||||
uint16_t price = ctx->GetItemLocation(rc)->GetPrice();
|
return CanBuyAnother(ctx->GetItemLocation(rc)->GetPrice());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CanBuyAnother(uint16_t price) {
|
||||||
if (price > 500) {
|
if (price > 500) {
|
||||||
return logic->HasItem(RG_TYCOON_WALLET);
|
return logic->HasItem(RG_TYCOON_WALLET);
|
||||||
} else if (price > 200) {
|
} else if (price > 200) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ class LocationAccess {
|
||||||
|
|
||||||
bool CheckConditionAtAgeTime(bool& age, bool& time) const;
|
bool CheckConditionAtAgeTime(bool& age, bool& time) const;
|
||||||
|
|
||||||
bool ConditionsMet(Region* parentRegion, bool calculatingAvailableChecks) const;
|
bool ConditionsMet(Region* parentRegion) const;
|
||||||
|
|
||||||
RandomizerCheck GetLocation() const {
|
RandomizerCheck GetLocation() const {
|
||||||
return location;
|
return location;
|
||||||
|
@ -103,6 +103,7 @@ class LocationAccess {
|
||||||
bool CanBuy() const;
|
bool CanBuy() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool CanBuyAnother(uint16_t price);
|
||||||
bool CanBuyAnother(RandomizerCheck rc);
|
bool CanBuyAnother(RandomizerCheck rc);
|
||||||
|
|
||||||
namespace Rando {
|
namespace Rando {
|
||||||
|
|
|
@ -1967,7 +1967,7 @@ void RecalculateAvailableChecks() {
|
||||||
StartPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS);
|
StartPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS);
|
||||||
|
|
||||||
std::vector<RandomizerCheck> targetLocations;
|
std::vector<RandomizerCheck> targetLocations;
|
||||||
targetLocations.reserve(RR_MAX);
|
targetLocations.reserve(RC_MAX);
|
||||||
for (auto& location : Rando::StaticData::GetLocationTable()) {
|
for (auto& location : Rando::StaticData::GetLocationTable()) {
|
||||||
RandomizerCheck rc = location.GetRandomizerCheck();
|
RandomizerCheck rc = location.GetRandomizerCheck();
|
||||||
Rando::ItemLocation* itemLocation = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc);
|
Rando::ItemLocation* itemLocation = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc);
|
||||||
|
@ -1979,15 +1979,8 @@ void RecalculateAvailableChecks() {
|
||||||
|
|
||||||
std::vector<RandomizerCheck> availableChecks = ReachabilitySearch(targetLocations, RG_NONE, true);
|
std::vector<RandomizerCheck> availableChecks = ReachabilitySearch(targetLocations, RG_NONE, true);
|
||||||
for (auto& rc : availableChecks) {
|
for (auto& rc : availableChecks) {
|
||||||
const auto& location = Rando::StaticData::GetLocation(rc);
|
|
||||||
const auto& itemLocation = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc);
|
const auto& itemLocation = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc);
|
||||||
if (location->GetRCType() == RCTYPE_SHOP && itemLocation->GetCheckStatus() == RCSHOW_IDENTIFIED) {
|
itemLocation->SetAvailable(true);
|
||||||
if (CanBuyAnother(rc)) {
|
|
||||||
itemLocation->SetAvailable(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
itemLocation->SetAvailable(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
totalChecksAvailable = 0;
|
totalChecksAvailable = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue