Page MenuHomeWildfire Games

Simplify conquest code
ClosedPublic

Authored by temple on Nov 7 2017, 10:14 PM.

Details

Reviewers
bb
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Owners Package(Owns No Changed Paths)
Commits
rP20471: Cleanup the conquest code
Summary

Currently the conquest code checks for ownership change, add structure, and training finished, however the latter two also generate ownership change messages. It would make sense to simplify the code and remove those two cases.

In addition, the current code is bugged because it doesn't take into account promoted units which are changed from no owner to the player directly instead of being trained. (I.e., you'll lose the game if you only have promoted units left.)

The convention is to ignore foundations so there's an extra check for that.

For conquest units, currently sheep count as units but their carcasses don't. With the patch, if we kept "Unit" then the carcass would also count as a unit, which doesn't seem correct. If we use "Unit+!Animal" then neither will count, and that seems acceptable or even preferred, since it seems tedious to have to kill all sheep to win. (Dogs and trained elephants don't have the Animal class.)

Test Plan

Agree?

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

temple created this revision.Nov 7 2017, 10:14 PM

It looks like, you missed changes in Conquest.js and ConquestStructures.js, no? They have lines like:

cmpTrigger.RegisterTrigger("OnStructureBuilt", "ConquestAddStructure", data);
temple updated this revision to Diff 4118.Nov 7 2017, 10:21 PM

Was going to add the three specific conquest files to a new diff but probably makes more sense to add them here.

temple edited the summary of this revision. (Show Details)Nov 7 2017, 10:26 PM
temple updated this revision to Diff 4119.Nov 8 2017, 12:37 AM
leper added reviewers: Restricted Owners Package, Restricted Owners Package.Nov 8 2017, 1:58 AM
leper added a subscriber: leper.
leper added inline comments.
binaries/data/mods/public/maps/scripts/ConquestCommon.js
14 ↗(On Diff #4119)

The msg.to checks were useful, and you should at least keep the != -1 part, as in those cases entities are created or destroyed and you will maybe run into warnings, or at least try to keep state that is useless.

Also those add/remove comments don't seem very useful.

temple updated this revision to Diff 4124.Nov 8 2017, 4:34 AM
temple marked an inline comment as done.
temple edited the summary of this revision. (Show Details)
temple edited the test plan for this revision. (Show Details)
temple added inline comments.
binaries/data/mods/public/maps/scripts/ConquestCommon.js
14 ↗(On Diff #4119)

I figured the checks would fail anyway since this.conquestEntitiesByPlayer[-1] doesn't exist.

leper added inline comments.Nov 8 2017, 7:01 PM
binaries/data/mods/public/maps/scripts/ConquestCommon.js
14 ↗(On Diff #4119)

Did you test it? I did say maybe, but I presume checking explicitly is nicer anyway.

temple added inline comments.Nov 8 2017, 7:40 PM
binaries/data/mods/public/maps/scripts/ConquestCommon.js
14 ↗(On Diff #4119)

Yes, I did test, I should've phrased that as "The checks do fail anyway...".
We don't store gaia either so msg.to > 0 should be all we need to do. (Testing and it's fine.)

temple updated this revision to Diff 4127.Nov 8 2017, 7:43 PM
temple added a comment.Nov 8 2017, 7:52 PM

(This checks for defeat only when you lose units, so if you started with no valid entities e.g. conquest structure on nomad, it won't say you're defeated until you build something and then lose it.)

bb added a subscriber: bb.Nov 10 2017, 1:51 PM

Simplification indeed nice and bugs solved :)
Notice that upgraded units have the same bug as promoted, and it is solved here since first the new ent is created and after that the old one removed.

Mostly some questions open for discussion:

binaries/data/mods/public/maps/scripts/Conquest.js
5 ↗(On Diff #4127)

(In fact this definition is global for all conquest types, thus could be moved to conquestCommon, planned to do that in the combine vc, can be done here to idc)

binaries/data/mods/public/maps/scripts/ConquestCommon.js
10 ↗(On Diff #4127)

Is this what we really want? what if a player builds a cc foundation, all ppl get killed and ally can finish?

42–47 ↗(On Diff #4127)

we lost some debugging, but this code route seems odd already so meh

binaries/data/mods/public/maps/scripts/ConquestUnits.js
3 ↗(On Diff #4127)

got wondering if some sort of thing in here would help me in the combine vc (victory condition), but concluded it won't :/
Still I agree on the change, but wouldn't "Unit+ConquestCritical" be more accurate?

probably the same counts for buildings dunno

temple added inline comments.Nov 10 2017, 4:51 PM
binaries/data/mods/public/maps/scripts/ConquestCommon.js
10 ↗(On Diff #4127)

I kept it like this because that's how it was done. You make a good point of course, and I considered that too. The problem I see is that foundations don't show on the minimap, and that would get frustrating for an enemy who can't find the last house or dock foundation.

So I'll agree with your change if we can show foundations on the minimap.
(Note that sheep don't appear in the player color on the minimap, so that's a reason why they shouldn't count in "conquest units".)

binaries/data/mods/public/maps/scripts/ConquestUnits.js
3 ↗(On Diff #4127)

I don't think I ever play with conquest units or structures. But maybe the joy of those game modes is hunting down every last trader and razing down every last storehouse? (Neither of which are conquest critical.)

(Buildings will revert to gaia anyway unless connected to an ally, but my plan after D840 is to change that so buildings don't decay and people have to explicitly capture or destroy them.)

bb added inline comments.Nov 10 2017, 5:03 PM
binaries/data/mods/public/maps/scripts/ConquestUnits.js
3 ↗(On Diff #4127)

I believe that is why they were added, so it proofs more that +ConquestCritical is more accurate, since then traders and storehouse are excluded from the list, so players can't survive with them

elexis added a subscriber: elexis.Nov 10 2017, 5:12 PM
elexis added inline comments.
binaries/data/mods/public/maps/scripts/ConquestUnits.js
3 ↗(On Diff #4127)

Remove TerritoryDecay? :-l

temple marked an inline comment as done.Nov 10 2017, 9:17 PM
temple added inline comments.
binaries/data/mods/public/maps/scripts/ConquestUnits.js
3 ↗(On Diff #4127)

I think I would keep units and structures as is, unless we get some feedback from players who use those modes. In the json's:

		"Description": "Destroy all enemy structures to win.",
		"Description": "Kill all enemy units to win.",

That's pretty explicit, whereas conquest says:

		"Description": "Defeat all opponents to win.",

"Defeat" could reasonably mean destroy/kill the important things, not all things. (We could change the name to "Conquest Critical" or something to be more precise.)

On the other hand, the defeat messages aren't quite right, so let me tweak those.

temple updated this revision to Diff 4139.Nov 10 2017, 9:22 PM

Allow foundations to count and add them to the minimap.
(There are construction entities too, but they don't have an identity component so they won't match the classlist.)

bb accepted this revision as: bb.EditedNov 11 2017, 6:58 PM

behaviour ok for my taste, leaving it open a bit in case someone wants to complain

binaries/data/mods/public/maps/scripts/ConquestCommon.js
54 ↗(On Diff #4139)

slightly unfortunate seeing the combine vc, but understand the logic and as said idc

This revision is now accepted and ready to land.Nov 11 2017, 6:58 PM
This revision was automatically updated to reflect the committed changes.