mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-10 06:43:43 +00:00
fix(quickbuild): take precondition items when the build starts, give them back on cancel
A quickbuild's HasItem preconditions took their items only when the build completed and never gave them back. Live took them when the build started and gave them back when it was cancelled: the FV Stone Warrior pedestal (LOT 8551, precondition 99: 5 of LOT 6194) took the items at Building 5 times and added them back with the loot source Quickbuild on each of the 3 cancels in the live captures. Preconditions now report their item costs instead of removing items while checking. A quickbuild takes them at the start, gives them back on cancel or a reset during the build, keeps them on completion, and gives them back when the builder leaves the world mid-build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -219,6 +219,12 @@ public:
|
||||
*/
|
||||
void CancelQuickBuild(Entity* const builder, const eQuickBuildFailReason failReason, const bool skipChecks = false);
|
||||
|
||||
/**
|
||||
* Cancels the quickbuilds the player is building, giving back the items they took. For a player leaving the world.
|
||||
* @param player the player
|
||||
*/
|
||||
static void CancelBuildsBy(Entity& player);
|
||||
|
||||
void SetState(const eQuickBuildState state) {
|
||||
if (m_State == state) return;
|
||||
m_State = state;
|
||||
@@ -393,6 +399,27 @@ private:
|
||||
*/
|
||||
PreconditionExpression* m_Precondition = nullptr;
|
||||
|
||||
/**
|
||||
* The items the preconditions took from the builder when the build started, given back if it is cancelled
|
||||
*/
|
||||
std::vector<ItemCost> m_TakenItems;
|
||||
|
||||
/**
|
||||
* The player the items in m_TakenItems were taken from
|
||||
*/
|
||||
LWOOBJID m_TakenItemsFrom = LWOOBJID_EMPTY;
|
||||
|
||||
/**
|
||||
* Takes the item costs of the preconditions from the builder, as live did when a build started
|
||||
* @param user the builder
|
||||
*/
|
||||
void TakeItemCosts(Entity& user);
|
||||
|
||||
/**
|
||||
* Gives back the items TakeItemCosts took, as live did when a build was cancelled
|
||||
*/
|
||||
void RefundItemCosts();
|
||||
|
||||
/**
|
||||
* Starts the quickbuild for a certain entity
|
||||
* @param user the entity to start the quickbuild
|
||||
|
||||
Reference in New Issue
Block a user