If a foundation is affected by a ranged aura (e.g. the Seleucid hero with -20% enemy building hp as in the replay in #5113) then the completed structure won't be affected by the aura yet so its max hitpoints won't be the same as the foundation's hitpoints, which means with the current code it won't start at full health. Since entities are created with hitpoints equal to max hitpoints (except for foundations which have an initial value specified), there's no need to set the hitpoints in Foundation. History at rP7352.
Details
- Reviewers
mimo - Commits
- rP21676: Set relative hitpoints for completed foundations
- Trac Tickets
- #5113
See that the replay in #5113 works now, for example.
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/simulation/components/Foundation.js | 322| » » var·pos·=·cmpPosition.GetPosition2D(); | | [NORMAL] JSHintBear: | | 'pos' is already defined. binaries/data/mods/public/simulation/components/Foundation.js | 324| » » var·rot·=·cmpPosition.GetRotation(); | | [NORMAL] JSHintBear: | | 'rot' is already defined.
Link to build: https://jenkins.wildfiregames.com/job/differential/343/display/redirect
And why not setting the relative health (as is done in Promotion or Transform)? Having foundations which are usable without full health may be useful for mods even if we don't use it in vanilla game.
? Foundations are completed (turned into new buildings) when their relative health (i.e. build progress) is 1, but new buildings are initialized at max hitpoints.
What i meant is that, if instead of setting health(structure) = health(foundation) as is done in Foundation, we do (as in Promotion or Transform) health(structure) = max(structure) * health(foundation)/max(foundation), that would fix the bug and allow an easy change for mods (they would just have to add a new Foundation propriety to tell it when to turn the foundation to structure).
Perhaps one should leave a code comment, since the difference between the equations isn't trivial.
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... binaries/data/mods/public/simulation/components/Foundation.js | 322| » » var·pos·=·cmpPosition.GetPosition2D(); | | [NORMAL] JSHintBear: | | 'pos' is already defined. binaries/data/mods/public/simulation/components/Foundation.js | 324| » » var·rot·=·cmpPosition.GetRotation(); | | [NORMAL] JSHintBear: | | 'rot' is already defined.
Link to build: https://jenkins.wildfiregames.com/job/differential/360/display/redirect
binaries/data/mods/public/simulation/components/Foundation.js | ||
---|---|---|
404 ↗ | (On Diff #6345) | if reusing progress, you should use Math.max(progress,1) |
binaries/data/mods/public/simulation/components/Foundation.js | ||
---|---|---|
404 ↗ | (On Diff #6345) | How can progress be > 1? |