Page MenuHomeWildfire Games

allow negative resource trickle rate
Needs ReviewPublic

Authored by Nescio on Feb 23 2018, 4:04 PM.


Group Reviewers
Restricted Owners Package(Owns No Changed Paths)

Changes the resource trickle rate from “nonNegativeDecimal” to simply “decimal”. This will allow mods to easily use the trickle rate for upkeep etc.
[EDIT] And prevents resources from going negative.

Test Plan

Check for mistakes.

Diff Detail

rP 0 A.D. Public Repository
Lint OK
No Unit Test Coverage
Build Status
Buildable 9083
Build 14882: Vulcan BuildJenkins
Build 14881: arc lint + arc unit

Event Timeline

Nescio created this revision.Feb 23 2018, 4:04 PM
Stan added a subscriber: Stan.Feb 23 2018, 4:23 PM

Won't it cause stuff like negative resources ?

Won't it cause stuff like negative resources ?

Yes, it does; negative resources actually behave quite nicely. (E.g. if you have −100 food, the game informs you you'll need 150 more food before you can train a female with a food cost of 50.)

Angen added a subscriber: Angen.Feb 23 2018, 4:35 PM

You cannot go to negative resources. That means you use something you do not have.

Negative resources could represent debts and famine. And you still need a positive amount of resources in order to actively spend it on something.
I've been happily using it for several weeks in my 0abc mod, and I figure others might want to try it out in future mods. This patch is not terribly important, just a nice to have for modders.

Stan added a comment.Feb 23 2018, 5:25 PM

Okay so it's not that bad. I was worried allowing this would break the game in the sense of having negative resources make you have unlimited ones.

Vulcan added a subscriber: Vulcan.Feb 23 2018, 5:47 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Default...
Executing section Source...
Executing section JS...

|  17| ·»   cmpTimer.SetInterval(this.entity,·IID_ResourceTrickle,·"Trickle",·this.GetTimer(),·this.GetTimer(),·undefined);
|    | [NORMAL] ESLintBear (no-mixed-spaces-and-tabs):
|    | Mixed spaces and tabs.

Link to build:

wraitii added a reviewer: Restricted Owners Package.May 14 2018, 12:08 PM
smiley added a subscriber: smiley.Dec 21 2018, 6:52 AM
smiley added inline comments.

Math.max(0, ...) would solve the negative resource problem (which should not happen).

Math.max(0, ...) would solve the negative resource problem (which should not happen).

The idea of this patch is to allow for negative resource trickle rate to represent upkeep etc. Negative resource *amounts* are probably undesirable, however, your suggestion would prevent the *rate* from being negative.

Nescio updated this revision to Diff 9512.Aug 25 2019, 8:25 PM
Nescio edited the summary of this revision. (Show Details)
Nescio edited the test plan for this revision. (Show Details)

Updated ( this forum post reminded me).

Successful build - Chance fights ever on the side of the prudent.

Link to build: