Page MenuHomeWildfire Games

Add options to Mainland and African Plains that place teammates more closely together
Needs ReviewPublic

Authored by andy5995 on Mon, Oct 11, 7:11 AM.

Details

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

This will add options to the Mainland and African Plains random maps that will place allies more closely together (the algorithm used for the multiarcs function was written by @Jammyjamjamman (who freely and ethically admits to pinching code from other sources)).

Test Plan

Using the svn version, I ran the game and loaded the maps.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

andy5995 requested review of this revision.Mon, Oct 11, 7:11 AM
andy5995 created this revision.

These 2 maps are from the stock mainland and African Plains map.

--- mainland.js	2021-10-10 13:36:08.628017649 -0500
+++ mainland_tg.js	2021-10-10 23:55:42.406775607 -0500
@@ -54,8 +54,16 @@
 var clFood = g_Map.createTileClass();
 var clBaseResource = g_Map.createTileClass();
 
+const mapCenter = g_Map.getCenter();
+var playerIDs = sortAllPlayers();
+
 placePlayerBases({
-	"PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)),
+	"PlayerPlacement": [sortAllPlayers(), ...playerPlacementMultiArcs(
+		playerIDs,
+		mapCenter,
+		fractionToTiles(0.35),
+		0,
+		0.75)],
 	"PlayerTileClass": clPlayer,
 	"BaseResourceClass": clBaseResource,
 	"CityPatch": {
--- african_plains.js	2021-10-10 13:36:08.581350791 -0500
+++ african_plains_tg.js	2021-10-10 23:52:03.089125684 -0500
@@ -68,8 +68,16 @@
 var clFood = g_Map.createTileClass();
 var clBaseResource = g_Map.createTileClass();
 
+const mapCenter = g_Map.getCenter();
+var playerIDs = sortAllPlayers();
+
 placePlayerBases({
-	"PlayerPlacement": playerPlacementCircle(fractionToTiles(0.35)),
+	"PlayerPlacement": [sortAllPlayers(), ...playerPlacementMultiArcs(
+		playerIDs,
+		mapCenter,
+		fractionToTiles(0.35),
+		0,
+		0.75)],
 	"PlayerTileClass": clPlayer,
 	"BaseResourceClass": clBaseResource,
 	"CityPatch": {
Stan added a comment.Mon, Oct 11, 8:54 AM

I wonder if it should/could be an option.

This should definitely be an option, especially when the other option is having almost duplicated maps. ^^

So now I've avoided duplicating the maps, and just use 2 distinct json files, adding the setting "EvenPlayerSpacing".

The problem right now is that when either map is loaded, the placement puts the team members closely together. I don't know what wrong with my condition. I have very little experience with javascript. Anyone know the problem?

btw, here's what placement looks like in a 2v3 game...

This comment was removed by andy5995.
andy5995 updated this revision to Diff 18801.Mon, Oct 11, 7:52 PM

I completed removed african_plains_tg.js and mainland_tg.js. The option is now in the .json files.

Freagarach edited reviewers, added: Restricted Owners Package; removed: Stan, Angen, Freagarach.Mon, Oct 11, 7:56 PM
andy5995 updated this revision to Diff 18802.Mon, Oct 11, 7:58 PM

No changes, just regenerated the diff with 'git diff -U9999 master'

andy5995 updated this revision to Diff 18803.Mon, Oct 11, 8:37 PM

Still trying to get the value of g_MapSettings.EvenPlayerSpacing for the newly-added condition in the .js files. Still getting the same result. Always evaluates to true.

Freagarach added inline comments.
binaries/data/mods/public/maps/random/african_plains.js
73 ↗(On Diff #18803)

I guess you only need to have the if here?
(Less duplication is (often) better.)

109–110 ↗(On Diff #18803)

This can be done in the function?

andy5995 added inline comments.Tue, Oct 12, 1:32 AM
binaries/data/mods/public/maps/random/african_plains.js
73 ↗(On Diff #18803)

I guess you only need to have the if here?

I don't know what you mean. Are you asking a question or confirming something, or suggesting something? I don't know where else to put the if, as as I'm used to C function calls, I don't know if it's possible with javascript to put an if statement within parentheses.

andy5995 updated this revision to Diff 18804.Tue, Oct 12, 1:34 AM

removed 2 duplicated variables

Do you think it could be a general game-setup option? (I'm not sure whether we can generalise it like that.) I envision a checkbox Teams together for random maps that squeezes teammates closer when possible.

binaries/data/mods/public/maps/random/african_plains.js
73 ↗(On Diff #18805)

In kind of pseudocode.

Also, have you seen the Frontier random map? That seems to have what you want.

Also, have you seen the Frontier random map? That seems to have what you want.

Oh... yeah that should work well. If I can figure out how to implement it. Looking at frontier.js, I don't understand yet how to do what I'm trying to do with mainland and african plains... Thanks @Freagarach

andy5995 updated this revision to Diff 18815.Tue, Oct 12, 9:15 PM

implemented TeamPlacement (per-map) settings similar to Frontier

andy5995 updated this revision to Diff 18817.Tue, Oct 12, 9:20 PM

remove unused tight_arc from g_PlayerbaseTypes (setup.js)

andy5995 retitled this revision from Adds maps that place teammates more closely together to Add options to Mainland and African Plains that place teammates more closely together.Tue, Oct 12, 9:22 PM
andy5995 edited the summary of this revision. (Show Details)
andy5995 updated this revision to Diff 18818.Tue, Oct 12, 9:26 PM

temporarily revert african_plains to original version

I'll make changes to it after mainland is fine-tuned.

I think it would be good to also add the "stronghold" formation that's used on the Frontier map. I haven't figured out how to implement it cleanly yet though.

I think it would be good to also add the "stronghold" formation that's used on the Frontier map. I haven't figured out how to implement it cleanly yet though.

Me and @Jammyjamjamman discussed this for a while and we figured out a pretty good solution. he'll likely have something on your desk within a week or so.

andy5995 set the repository for this revision to rP 0 A.D. Public Repository.Wed, Oct 13, 12:57 AM

I would remove the Random option, players expect a certain type of team placement by default. There is no Random for the map size either.

Even better would be a schematic preview of what it looks like on the map when I select Tight Arc or Circle. The font for the tooltip is tiny on a normal monitor (1920x1200) and the placement in the lower left corner is so far from where I need the information that I never actually read these tooltips unless there is a flashing color in them.

Should the option appear if there are only two players? Better just disable and gray them out.

Should the option appear if there are only two players? Better just disable and gray them out.

That seems something for a separate patch, but a good idea indeed.

I would remove the Random option, players expect a certain type of team placement by default. There is no Random for the map size either.

I would vote against removing the Random option. Map size seems compleately different to me. Although admittedly it would be a very interesting option to have more settings that can be random (including the map size, resources and victory conditions).

binaries/data/mods/public/gui/gamesettings/attributes/TeamPlacement.js
61

See randomGroup.

binaries/data/mods/public/maps/random/rmgen-common/player.js
857–858

The linter will also have something to say about this function. (Mostly const.)

The naming could be done better instead of Tight Arc/ Circle just call it Teams Together/ Equally distanced.


Twitch: AOE4 - Highlight: rank 1 rush king returns | best rusher(7/Oct/21)

More alternative naming ideas:

beside each other or packed together

Teams together

:)

Should the option appear if there are only two players? Better just disable and gray them out.

That would be a separate patch. The random option is also presented for the Frontier and Ambush map.

It seems the default when using "TeamPlacements" is to add that random option (not the randomGroup which is completely different); So any patch that changes the code to remove the random option would affect all maps that use TeamPlacements in the .json file.

Even better would be a schematic preview of what it looks like on the map when I select Tight Arc or Circle. The font for the tooltip is tiny on a normal monitor (1920x1200) and the placement in the lower left corner is so far from where I need the information that I never actually read these tooltips unless there is a flashing color in them.

Again, that would be a separate patch. There's no other maps I know of that display a schematic preview such as you describe, and it doesn't happen for Frontier or Ambush, which is where we'll be pinching the existing code from.

Though you might want to strongly consider adding schematic previews. It hardly seems worth maintaining. It would need to be changed if distances were adjusted or possibly some other facets which affect placement. Also, it wouldn't be very accurate. You could show a 4v4 preview, but that wouldn't reflect very well what a 2v2 setup would like; or a 1v2, a 2v3, a 2v2v3, etc...

Should the option appear if there are only two players? Better just disable and gray them out.

That would be a separate patch. The random option is also presented for the Frontier and Ambush map.

It seems the default when using "TeamPlacements" is to add that random option (not the randomGroup which is completely different); So any patch that changes the code to remove the random option would affect all maps that use TeamPlacements in the .json file.

I mistakenly replied to a different comment there. To address the disabling of the option if there are only two players... again, that would be a separate patch, as it would affect the other maps using the TeamPlacements line in the json files.