Page MenuHomeWildfire Games

Allow entities to auto-upgrade.
AbandonedPublic

Authored by Freagarach on Apr 7 2020, 9:39 AM.

Details

Reviewers
wraitii
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

This patch adds an AutoUpgrade tag to the Upgrade component, which allows entities to automatigically upgrade into another.
Currently a random upgrade from the possible upgrades is chosen, but it might be better to specify which upgrade to perform or to choose from?

This would allow, e.g., for trees to autoproduce (D2658) a sapling, that automatically upgrades into a bigger tree, which can again reproduces itself.

Test Plan

Test that, with the given template change, sentry towers will automatically upgrade into a defense tower.

Event Timeline

Freagarach created this revision.Apr 7 2020, 9:39 AM
Owners added a subscriber: Restricted Owners Package.Apr 7 2020, 9:39 AM
Vulcan added a comment.Apr 7 2020, 9:43 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/1447/display/redirect

Vulcan added a comment.Apr 7 2020, 9:43 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/554/display/redirect

Vulcan added a comment.Apr 7 2020, 9:44 AM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1974/display/redirect

Freagarach edited the summary of this revision. (Show Details)Apr 7 2020, 9:44 AM
Stan added a subscriber: Stan.Apr 7 2020, 10:27 AM
Stan added inline comments.
binaries/data/mods/public/simulation/components/Upgrade.js
96

Should you call this if the above is false?

Freagarach updated this revision to Diff 11639.Apr 7 2020, 1:47 PM
Freagarach marked an inline comment as done.
  • Test.
  • Do not check auto-upgrade when dying.
Vulcan added a comment.Apr 7 2020, 1:54 PM

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

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (dot-notation):
|    | ["Upgrade"] is better written in dot notation.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
| 163| 163| TS_ASSERT_UNEVAL_EQUALS(cmpUpgrade.GetUpgrades()[0].cost, { "stone": 160, "wood": 25, "time": 90 });
| 164| 164| 
| 165| 165| // Test automatic upgrading.
| 166|    |-template["Upgrade"] = {
|    | 166|+template.Upgrade = {
| 167| 167| 	"Upgrades": {
| 168| 168| 		"Tower": {
| 169| 169| 			"Cost": { "stone": "100", "wood": "50" },

binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
|  94| »   "ApplyTemplateModifiers":·(valueName,·curValue,·template,·player)·=>·{
|    | [NORMAL] ESLintBear (no-shadow):
|    | 'template' is already declared in the upper scope.

binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
| 166| template["Upgrade"]·=·{
|    | [NORMAL] JSHintBear:
|    | ['Upgrade'] is better written in dot notation.
|    | [NORMAL] ESLintBear (operator-linebreak):
|    | '||' should be placed at the end of the line.
|----|    | /zpool0/trunk/binaries/data/mods/public/globalscripts/Templates.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/globalscripts/Templates.js
|  87|  87| 		// If the elements are still strings, split them by space or by '+'
|  88|  88| 		if (typeof sublist == "string")
|  89|  89| 			sublist = sublist.split(/[+\s]+/);
|  90|    |-		if (sublist.every(c => (c[0] == "!" && classes.indexOf(c.substr(1)) == -1)
|  91|    |-		                    || (c[0] != "!" && classes.indexOf(c) != -1)))
|    |  90|+		if (sublist.every(c => (c[0] == "!" && classes.indexOf(c.substr(1)) == -1) ||
|    |  91|+		                    (c[0] != "!" && classes.indexOf(c) != -1)))
|  92|  92| 			return true;
|  93|  93| 	}
|  94|  94| 

binaries/data/mods/public/globalscripts/Templates.js
|  91| »   »   ····················||·(c[0]·!=·"!"·&&·classes.indexOf(c)·!=·-1)))
|    | [NORMAL] JSHintBear:
|    | Misleading line break before '||'; readers may interpret this as an expression boundary.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1975/display/redirect

Freagarach added inline comments.May 9 2020, 12:29 PM
binaries/data/mods/public/simulation/templates/template_structure_defensive_tower_sentry.xml
71

Ought not to be committed obviously.

wraitii requested changes to this revision.May 30 2020, 2:40 PM
wraitii added a subscriber: wraitii.

This doesn't seem extremely worthwhile tbh.

One can simply add an experience trickle, since D1245, and let the entity promote.
Picking from a random promotion might be worth having, so I'd refactor this diff into that.

This revision now requires changes to proceed.May 30 2020, 2:40 PM
Freagarach planned changes to this revision.Jul 1 2022, 7:20 AM

I agree on the current patch not adding much, but one can put constraints on upgrading (e.g. tech required) and not on promoting. So this can be changed a bit to check for that.

Freagarach abandoned this revision.Jul 1 2022, 7:20 AM

However, I consider this a very low prio at the moment. ^^