#3132 closed defect (fixed)
[PATCH] Return proportional amount of resources when deleting foundations
Reported by: | elexis | Owned by: | mimo |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 19 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description (last modified by )
Currently 100% of the resources are returned when a building foundation is deleted or destroyed.
The source code actually says that a proportional amount should be returned. Only because of a programming mistake or bug 100% are returned.
See function Foundation.prototype.OnDestroy in file trunk/binaries/data/mods/public/simulation/components/Foundation.js
Foundation.prototype.OnDestroy = function() { // Refund a portion of the construction cost, proportional to the amount of build progress remaining // ... for (var r in this.costs) { var scaled = Math.floor(this.costs[r] * (1.0 - this.GetBuildProgress())); // ... } }; /** * Returns the current build progress in a [0,1] range. */ Foundation.prototype.GetBuildProgress = function() { var cmpHealth = Engine.QueryInterface(this.entity, IID_Health) var hitpoints = cmpHealth.GetHitpoints(); var maxHitpoints = cmpHealth.GetMaxHitpoints(); return (hitpoints / maxHitpoints); };
The GetBuildProgress() function always returns 0 because the hitpoint count in this function equates to 0.
Attachments (1)
Change History (12)
comment:1 by , 9 years ago
Description: | modified (diff) |
---|---|
Summary: | Return proportional amount of resources when deleting buildings → Return proportional amount of resources when deleting foundations |
comment:2 by , 9 years ago
Owner: | set to |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:3 by , 9 years ago
Component: | Core engine → UI & Simulation |
---|---|
Milestone: | Backlog → Alpha 19 |
by , 9 years ago
Attachment: | t3132_refund_a_bit_more_resources.patch added |
---|
comment:4 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:5 by , 9 years ago
With the patch above, it will refund 100% of the resources when a completely unbuilt building will be deleted. Currently it returns only 99%, which is a bit annoying when playing nomad and you misplaced your CC. In that case you will not be able to place it somewhere else without gathering 1 unit of each resource.
comment:6 by , 9 years ago
Keywords: | patch review added |
---|---|
Summary: | Return proportional amount of resources when deleting foundations → [PATCH] Return proportional amount of resources when deleting foundations |
follow-up: 10 comment:9 by , 9 years ago
r16622 not only fixed a oos that was caused by the original patch - it also changes the behaviour of the refund. The original patch refunded resources just by the current build progress, while the new behaviour is to return resources according to the highest build progress.
This way another 'bug' is fixed. If you would build a CC 90% and then the enemy destroys it, you would get returned 100% of the resources. With the newer version you get only those 10% back. Thanks for that fix.
follow-up: 11 comment:10 by , 9 years ago
Replying to elexis:
r16622 not only fixed a oos that was caused by the original patch - it also changes the behaviour of the refund. The original patch refunded resources just by the current build progress, while the new behaviour is to return resources according to the highest build progress.
hummm, did you read or used the original patch before posting this comment ? the highest build progress was there since the first patch.
comment:11 by , 9 years ago
Replying to mimo:
hummm, did you read or used the original patch before posting this comment ? the highest build progress was there since the first patch.
Ah, true. Sorry for not crediting you.
Before mimos patch (r16470) it had the wrong behaviour (returning always 100% when a structure is destroyed by enemies).
In 16470: