Jump to content

Delenda Est: An overhaul mod for 0 A.D.


wowgetoffyourcellphone
 Share

Recommended Posts

  • 1 month later...

Hey, so I tried running Delenda est (the one from github) on A26 christmas build, and this has came up which is the same with other mods updated to A26 such as Han Chinese. 

Any ideas?

EDIT: for some reason the log refuses to appear when I screenshot it.

screenshot0001.png

Edited by CovenantKillerJ
  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi guys! Need some help here.

I'm playing 0ad on M1 Mac with Delenda Est, and so far I've been enjoying it very much. It's just that whenever I try to play the Nomad mode (by toggling the Nomad option), the game will fail to load. A window will pop up, saying "Error generating random map. Check application log for details," and there'll be a few lines on the interface as below:-

[34.996] error: JavaScript error: maps/random/rmgen-common/player.jsline471
[34.996] error: Script value conversion check failed v.isString() || v.isNumber() || v.isBoolean() (got type undefimed)
[34.996] error: placePlayersNomad@maps/random/rmgen-common/player.js:471:12
[34.996] error: @maps/random/red_sea.js: 353:18
[34.996] error: CMapGeneratorWorker:: Run: Failed to Load RMS 'maps/random/red_sea.js'

I did some trial and error, so I'm pretty sure that this only happens when I toggle the Nomad option.

I tried to uninstall, then reinstall both the game and the mod (I'm a complete noob when it comes to computers), but it didn't work. Then I tried switching to the newly released ARM native test build for M1 Mac, but it didn't work either. I tried Googling for solutions, but there aren't any. Am I the only person having this issue here? Huge thanks to anyone who can help me with this problem =)

Edited by anony5496
  • Like 1
Link to comment
Share on other sites

Here's the section

function placePlayersNomad(playerClass, constraints)
{
	if (!isNomad())
		return undefined;

	g_Map.log("Placing nomad starting units");

	let distance = scaleByMapSize(60, 240);
	let constraint = new StaticConstraint(constraints);

	let numPlayers = getNumPlayers();
	let playerIDs = shuffleArray(sortAllPlayers());
	let playerPosition = [];

	for (let i = 0; i < numPlayers; ++i)
	{
		let objects = getStartingEntities(playerIDs[i]).filter(ents => ents.Template.startsWith("units/")).map(
			ents => new SimpleObject(ents.Template, ents.Count || 1, ents.Count || 1, 1, 3));

		// Add treasure if too few resources for a civic center
		let ccCost = Engine.GetTemplate("structures/" + getCivCode(playerIDs[i]) + "/civil_centre").Cost.Resources;
		for (let resourceType in ccCost)
		{
			let treasureTemplate = g_NomadTreasureTemplates[resourceType];

			let count = Math.max(0, Math.ceil(
				(ccCost[resourceType] - (g_MapSettings.StartingResources || 0)) /
				Engine.GetTemplate(treasureTemplate).Treasure.Resources[resourceType]));

			objects.push(new SimpleObject(treasureTemplate, count, count, 3, 5));
		}

		// Try place these entities at a random location
		let group = new SimpleGroup(objects, true, playerClass);
		let success = false;
		for (let distanceFactor of [1, 1/2, 1/4, 0])
			if (createObjectGroups(group, playerIDs[i], new AndConstraint([constraint, avoidClasses(playerClass, distance * distanceFactor)]), 1, 200, false).length)
			{
				success = true;
				playerPosition[i] = group.centerPosition;
				break;
			}

		if (!success)
			throw new Error("Could not place starting units for player " + playerIDs[i] + "!");
	}

	return [playerIDs, playerPosition];
}

 

Here is the line (471):

			let treasureTemplate = g_NomadTreasureTemplates[resourceType];

 

 

I tried bypassing treasure generation by setting the starting resources to 1000, but then I got an error for line 475:

ERROR: JavaScript error: maps/random/rmgen-common/player.js line 475 Script value conversion check failed: v.isString() || v.isNumber() || v.isBoolean() (got type undefined) placePlayersNomad@maps/random/rmgen-common/player.js:475:12 @maps/random/mainland.js:192:18

ERROR: CMapGeneratorWorker::Run: Failed to load RMS 'maps/random/mainland.js'

 

Line 475:

				Engine.GetTemplate(treasureTemplate).Treasure.Resources[resourceType]));

 

Could the "problem" be that Delenda Est's treasures give more than 1 resource? :) A few months ago @Freagarach made it possible in the core game, so I ran with it. This could be an edge case not tested for? 

Link to comment
Share on other sites

On 28/04/2022 at 8:40 AM, wowgetoffyourcellphone said:

No, only wood and stone.

Well, yes and no. They cost "0" coin and glory (inherited from template_structure), which means

for (let resourceType in ccCost)

will still loop over coin and glory. But

g_NomadTreasureTemplates[resourceType]

then doesn't exist, such that

Engine.GetTemplate(treasureTemplate)

will fail.

You(/We) have some options to fix this:

  • Add coin and glory treasures to g_NomadTreasureTemplates (in maps/random/rmgen-common/player_DE.js).
  • Change the function to either (or both)
    • not account for zero-cost resources.
    • fail/warn when no treasure template exist.
  • Don't have standard cost of "0" for structures (not specified resources are already assumed "0", be aware that this might not be true for every piece of code).

These options can be mixed and matched. :)

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Freagarach said:
  • Don't have standard cost of "0" for structures (not specified resources are already assumed "0", be aware that this might not be true for every piece of code).

 

Thank you for parsing the issue. This is the solution I went with and it fixed the issue!

 

@anony5496 This will be fixed in the next release.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...