Jump to content

Hyrule Conquest


Recommended Posts

Hello,

I'm one of the on-off two members of "Hyrule Conquest Team," we haven't had much to do as with the engine switch neph is able to do most of its without needing any additional help, so I've been keeping myself busy trying to understand the 0 AD engine and help fix errors and bugs to the best of my ability.

I've noticed, at least in my game, the temporary hero selection screen has stopped working in single-player, with the attached error message. If anyone has any idea as to what problem with that GUI file is please let me know.

And thanks for all the help with Hyrule Conquest, it's nice to meet you all :D

@Lion.Kanzen That armor is being used for the Lanayru Zora faction, these Zora Neph is working on, the Dominion Zora, have a much fancier gold/sapphire aesthetic :P

 

 

 

Capture.PNG

  • Like 3
Link to comment
Share on other sites

Whenever you're experiencing any errors or warnings, please access the interestinglog.html file (its location typically depends on your operating system, see https://trac.wildfiregames.com/wiki/GameDataPaths), and copy the message from there; plain text is easier to read than a screenshot.

My guess is that if you fix whatever is wrong in the hero selection screen, the gui file error will disappear as a consequence.

And welcome to 0 A.D., darkinterloper! Hyrule Conquest seems to be a very promising mod :)

  • Like 2
Link to comment
Share on other sites

@darkinterloper hello and welcome to the forums!

  On 03/11/2017 at 5:56 AM, darkinterloper said:

I've noticed, at least in my game, the temporary hero selection screen has stopped working in single-player, with the attached error message.

Expand  

As @Nescio correctly said, all the following lines are subsequences of the syntax error in civ_choices.js

The syntax error must be consistent (rather than depending on some data), so someone must have changed the file (comparing to its 'original' state in the civ choices mod ). So please share the file itself (or even better a repo where both the file and the changes history may be seen).

  • Like 1
Link to comment
Share on other sites

fcxSanya, the session.js copy sounds like trouble. It already misses out some of the recent changes to it. As far as I see its only use is calling initCivChoicesDialog.

We should find some mechanism to avoid that copy. If the file was renamed to be loaded after session.js, we could probably replace the init function with a new init function that calls the old one and the init function of the mod.

Afaics, that mod misses a session.xml copy loading that civ choices file until D619 is committed.

Link to comment
Share on other sites

  On 04/11/2017 at 2:28 PM, elexis said:

the session.js copy sounds like trouble <...>

We should find some mechanism to avoid that copy <...>

Expand  

It was a proof-of-concept implementation, if Hyrule Conquest (or any other mod) is going to stick with it, we indeed shoud find a way to call initCivChoicesDialog without modifying session.js

  On 04/11/2017 at 2:28 PM, elexis said:

If the file was renamed to be loaded after session.js, we could probably replace the init function with a new init function that calls the old one and the init function of the mod.

Expand  

Do you mean we need to modify the main game to call the new init method (under a new name) or we may name it 'init' too and somehow call the original with the same name?

  On 04/11/2017 at 2:28 PM, elexis said:

As far as I see its only use is calling initCivChoicesDialog.

Expand  

Yes, I separated copying files from 0ad and introducing actual changes to make them easier to track.

  On 04/11/2017 at 2:28 PM, elexis said:

It already misses out some of the recent changes to it.

Expand  

It's based on Alpha 22.

  On 04/11/2017 at 2:28 PM, elexis said:

Afaics, that mod misses a session.xml copy loading that civ choices file until D619 is committed.

Expand  

If you are talking about civ_choices_window.xml then it's loaded by

<include directory="gui/session/dialogs/"/>

here

Link to comment
Share on other sites

  On 04/11/2017 at 4:38 PM, fcxSanya said:

Do you mean we need to modify the main game to call the new init method (under a new name) or we may name it 'init' too and somehow call the original with the same name?

Expand  

First all JS files are loaded and executed in alphabetical order. (i.e. first session.js can set the global init, then a file of your mod could replace that init with a new one that calls the previous one and your civChoicesInit). After that the engine calls the global init function, whatever it may now contain.

Basically

var oldInit = init;
function init(args)
{
     oldInit(args);
     modInit();
}

Not a beauty queen, but would avoid the duplication.

> it's loaded

Ah, good.

Link to comment
Share on other sites

  On 04/11/2017 at 5:35 PM, elexis said:
var oldInit = init;
function init(args)
{
     oldInit(args);
     modInit();
}

 

Expand  

By some reason I can't get this working, I tried disabling all mods and putting your example (with and without replacing "args" to "initData, hotloadData") into mods/user/gui/session/session2.js , but the game crashes on the session init without the crash logs or any useful messages in the logs:

image.png

Link to comment
Share on other sites

  On 04/11/2017 at 6:57 PM, elexis said:

I can't reproduce it on unix unless that is a function calling itself indefinitely.

Expand  

Yeah, something strange is happening.

  On 04/11/2017 at 6:57 PM, elexis said:

Try "init = function" for the init overwriting instead of "function init" - that worked at least when doing it in the public mod in my test.

Expand  

Works this way, thanks! Committed.

  • Like 1
Link to comment
Share on other sites

Observer fix and AI auto select for civ_choices.js

function initCivChoicesDialog()
{
	for(let player in g_Players)
	{ //unlock teck for AI
		if( g_GameAttributes.settings.PlayerData[ player ] ) //Observers have no player data
			if( g_GameAttributes.settings.PlayerData[ player ].AI != "" )
			{
				let aiPlayer = g_Players[player];
				let civChoices = g_CivData[aiPlayer.civ].CivChoices;
				if( civChoices )
				{
					let randomi = Math.floor( Math.random()* (g_CivData[aiPlayer.civ].CivChoices.length));
					Engine.PostNetworkCommand({ "type": "civ-choice", 
						"template": g_CivData[aiPlayer.civ].CivChoices[randomi] });
//warn(player +" AI choose: "+g_CivData[aiPlayer.civ].CivChoices[randomi]); //Unsure how to make petra unlock it though
					Engine.GetGUIObjectByName("civChoicesDialogPanel").hidden = true;
				}
			}
	}

	if( Engine.GetPlayerID() == -1) { //observers have no playerData
		return;
	}

	let currentPlayer = g_Players[Engine.GetPlayerID()];
//choice menu for players
	let civChoices = g_CivData[currentPlayer.civ].CivChoices;

	if (civChoices)
	{
		for (let i = 0; i < civChoices.length; ++i)
		{
			if( civChoices[i] == undefined)
				continue;
			let civChoiceButton = Engine.GetGUIObjectByName("civChoice[" + i + "]");
			civChoiceButton.caption = GetTechnologyData(civChoices[i]).name.generic;

			let size = civChoiceButton.size;
			size.top = 20 * i;
			size.bottom = 20 * (i + 1);
			civChoiceButton.size = size;

			civChoiceButton.onPress = (function(tech) { return function() {
//warn("playerSelected:"+tech );
				Engine.PostNetworkCommand({ "type": "civ-choice", "template": tech });
				Engine.GetGUIObjectByName("civChoicesDialogPanel").hidden = true;
			}})(civChoices[i]);

			civChoiceButton.hidden = false;
		}
		Engine.GetGUIObjectByName("civChoicesDialogPanel").hidden = false;
	}
}

Until petra is patched, which mimo seems to know everything needed to be done, the AI doesn't quite work well. Note: gerudo's won't train any sheep for some reason and I can't figure out why. It might be something wrong with the pig template. I don't know missing Unit tag?

I did edit petra to get hyrule to build farms and start building civcentres early. I'm impatient for a mod friendly AI. I don't know if mimo's edits will work with A22 as it is or not. I don't quite know how to download a folder from the tracbrowser anyway. He's seemed to have removed the mod breaking aspect of petra: which was using direct template names and not gathering them off the <Classes> tag (NOTE: VisibleClasses are completely different). You may want to revisit some files and make sure they have the proper tags. I had to add "Field" to the hyrule's farmstead/field combo for my petra edits to work properly.

 

Anyway: Hyrule Conquest Opinions - probably already addressed these in this forum somewhere.

Training times are 30 seconds. One minute for 2 soldiers... I don't like that really. You may have to edit petra's researchManager quiet a bit to get some of the techs to work for the AI. I'll look over them but I want to see if mimo's AI does this already. The building models are quite huge the AI (and people) will have trouble expanding with the small amount of territory influence they add ( and the 'must build in own territory' limitation). You can edit the limitation by adding neutral to the build restrictions territory tag. You may have to set the territory influence to 0. I'm not sure if petra really cares about the neutral tag though. I have yet to properly look over A23's future version to see if that's changed. They didn't seem to notice it or take advantage of it in delenda though.

 

UPDATE: ... -.- It doesn't seem to unlock the tech for the AI. It will pick one. I'm not sure how to force the tech to be unlocked.

Edited by SirPope
Moved fix from sessions to to civ_choices for easier implementation
  • Like 2
Link to comment
Share on other sites

  On 10/11/2017 at 12:12 AM, SirPope said:

Observer fix and AI auto select for civ_choices.js

function initCivChoicesDialog()
{
	for(let player in g_Players)
	{ //unlock teck for AI
		if( g_GameAttributes.settings.PlayerData[ player ] ) //Observers have no player data
			if( g_GameAttributes.settings.PlayerData[ player ].AI != "" )
			{
				let aiPlayer = g_Players[player];
				let civChoices = g_CivData[aiPlayer.civ].CivChoices;
				if( civChoices )
				{
					let randomi = Math.floor( Math.random()* (g_CivData[aiPlayer.civ].CivChoices.length));
					Engine.PostNetworkCommand({ "type": "civ-choice", 
						"template": g_CivData[aiPlayer.civ].CivChoices[randomi] });
//warn(player +" AI choose: "+g_CivData[aiPlayer.civ].CivChoices[randomi]); //Unsure how to make petra unlock it though
					Engine.GetGUIObjectByName("civChoicesDialogPanel").hidden = true;
				}
			}
	}

	if( Engine.GetPlayerID() == -1) { //observers have no playerData
		return;
	}

	let currentPlayer = g_Players[Engine.GetPlayerID()];
//choice menu for players
	let civChoices = g_CivData[currentPlayer.civ].CivChoices;

	if (civChoices)
	{
		for (let i = 0; i < civChoices.length; ++i)
		{
			if( civChoices[i] == undefined)
				continue;
			let civChoiceButton = Engine.GetGUIObjectByName("civChoice[" + i + "]");
			civChoiceButton.caption = GetTechnologyData(civChoices[i]).name.generic;

			let size = civChoiceButton.size;
			size.top = 20 * i;
			size.bottom = 20 * (i + 1);
			civChoiceButton.size = size;

			civChoiceButton.onPress = (function(tech) { return function() {
//warn("playerSelected:"+tech );
				Engine.PostNetworkCommand({ "type": "civ-choice", "template": tech });
				Engine.GetGUIObjectByName("civChoicesDialogPanel").hidden = true;
			}})(civChoices[i]);

			civChoiceButton.hidden = false;
		}
		Engine.GetGUIObjectByName("civChoicesDialogPanel").hidden = false;
	}
}

Until petra is patched, which mimo seems to know everything needed to be done, the AI doesn't quite work well. Note: gerudo's won't train any sheep for some reason and I can't figure out why. It might be something wrong with the pig template. I don't know missing Unit tag?

I did edit petra to get hyrule to build farms and start building civcentres early. I'm impatient for a mod friendly AI. I don't know if mimo's edits will work with A22 as it is or not. I don't quite know how to download a folder from the tracbrowser anyway. He's seemed to have removed the mod breaking aspect of petra: which was using direct template names and not gathering them off the <Classes> tag (NOTE: VisibleClasses are completely different). You may want to revisit some files and make sure they have the proper tags. I had to add "Field" to the hyrule's farmstead/field combo for my petra edits to work properly.

 

Anyway: Hyrule Conquest Opinions - probably already addressed these in this forum somewhere.

Training times are 30 seconds. One minute for 2 soldiers... I don't like that really. You may have to edit petra's researchManager quiet a bit to get some of the techs to work for the AI. I'll look over them but I want to see if mimo's AI does this already. The building models are quite huge the AI (and people) will have trouble expanding with the small amount of territory influence they add ( and the 'must build in own territory' limitation). You can edit the limitation by adding neutral to the build restrictions territory tag. You may have to set the territory influence to 0. I'm not sure if petra really cares about the neutral tag though. I have yet to properly look over A23's future version to see if that's changed. They didn't seem to notice it or take advantage of it in delenda though.

 

UPDATE: ... -.- It doesn't seem to unlock the tech for the AI. It will pick one. I'm not sure how to force the tech to be unlocked.

Expand  

Hi Sirpope, I tried adding your altered civ_choices.js, it does seem to unlock techs for AI in some capacity, but may also unlock unique hero units for a player who is the same faction as said AI: for example, when playing as the Kingdom of Hyrule, with the hero Kazakk, versus an AI Kingdom of Hyrule of medium difficulty, I was able to train "Champion Knight", the Hero Link's unique unit as well as Kazakk's "Goldenclad Elite." Additionally, the AI began experiencing numerous error logs as I sent and attack force after it, which are attached, I can't make any sense of them not knowing anything about how Petra works.

interestinglog.html

20171109230619_1.jpg

Link to comment
Share on other sites

  On 10/11/2017 at 7:25 AM, fcxSanya said:

I don't think gui scripts are executed for AI. And in any case you should send that command from the AI itself.

Expand  

Yeah I don't think they do either. I don't think the AI isn't actually set up or initialized until session.js is finished. I tried to get access to the AI but the player object hasn't even been assigned yet. I could turn it into a function and just call ResearchTech when petra starts. However, I'm not sure why player.js has an AddStartingTechnology function if you can't even access it before the game begins. I can't figure out how to get to the data at all. Moving it to shared.js might work. I'd have access to the AI there and the actual player I think it's also 'shared' between players as well so network play should work. I just don't know if it's only for sharing AI data. Will it run with 2 actual people and no AI?

@darkinterlooper

When you attacked? From what I can tell it's a combination of getBestBase and an improper template with 'getAttackBonus'. My edit doesn't do anything to the Attack or defence manager. Yeah, I think it will unlock it for the player now that you mention it. I was just testing it with gerudo vs hyrule... never thought of that. I'm glad someone tested it though. The function needs to get out of session.js anyways. That is ran when you join a game. If someone (like an observer) joins the game the dialog menu will pop up again for everyone. It's an easy way to troll.

Some of the template's obstruction radius is off a bit. I noticed that with the main CivCenter for hyrule. My guess is it tried to set a building checked the obstruction radius said 'it will fit', marked it as done, and then the foundation collision checker popped in. That's the best explanation I can give. Can't get units info from a building that can't be built. It's kinda neat to see a tree growing from a barracks. The Capture attack part of some templates might also be messed up.

 

Link to comment
Share on other sites

What I'm wondering is why does it change the civ name for the AI? I think it is unlocking it... it's just not researching it. Might have to create a separate tech and function. Just for AI's sake and then call that in petra depending on the AI's name? I don't know. I'm done trying to figure this out for the moment. If anyone knows how to get the gerudo to train animals let me know. Is it a template error on the pig side?? I got it to search for the actually template of the corral. I had to add the class Corral to the pigfarm and then search for the important classes. I also got hyrule to build farms. :) you might be able to force them to just by changing the hyrule_farmstead.xml to hyrule_field.xml might break something though. I got them to build them, corrals, civcenters, 'specialbuildings'... Not posting the whole code there was quiet a few annoyances along the way.

	for(let t in gameState.templates)
	{ //gameState.templates holds every template avaliable to all civs (including gaia)
		if( t.indexOf("structures/"+gameState.getPlayerCiv()) == -1 ) //we just want ours
			continue;
		let template = gameState.getTemplate(t);
		if( template )
		{
			if( template.hasClass("Field") )
				this.buildings.field.push(t);

			if( template.hasClass("Corral") ) //I did do a warning check and pig farm was added.
				this.buildings.corral.push(t);
//... everything other important class

I expanded this.buildings list in config.js:

"field": new Array(), "corral": new Array(), //all others - FYI all advanced building have the class SpecialBuildings...

//Why would you type them out or keep using applyCiv if you already know which is what? It's all stored for you.

Then everywhere in several files i do the below: ... I find anything labeled with {civ} and change it

let templateList = undefined; let temp_storehouse = "structures/{civ}_field";
templateList = gameState.ai.Config.getBuildingsOfType("Field"); //basically just returns template.buildings[field] //I toLowerCase it the value passed.
if( templateList )
        temp_field = templateList[0]; //default to first - needs a smarter way - sort them all by costSum()?
let template = gameState.getTemplate(gameState.applyCiv(temp_field));

 

Of course this is clunky and needs a better way to get the file. A simple function...

 

Link to comment
Share on other sites

Annnnddd the Mage heavy fully aquatic Zora Dominion army is done:

DqwAxMd.jpg

As usual, unit details:

  Reveal hidden contents

 

Time to get all the buildings in now

 

Edited by The Undying Nephalim
  • Like 6
Link to comment
Share on other sites

  Quote

I don't think gui scripts are executed for AI. And in any case you should send that command from the AI itself.

Expand  


They are in different JS contexts and cannot communicate directly. And the game is runnable without any gui.

What the above code does will also break in multiplayer if cheats are not enabled since it relies on sending messages for other players.

As for why there is a method to set starting technologies, well to set starting technologies. Pass what you want when you decide to start a game, or include that in the map JS data. What you seem to be missing is an idea of how all of that interacts, which is at least partially documented on the wiki.

  • Like 1
Link to comment
Share on other sites

  On 11/11/2017 at 8:31 PM, leper said:

As for why there is a method to set starting technologies, well to set starting technologies. Pass what you want when you decide to start a game, or include that in the map JS data. What you seem to be missing is an idea of how all of that interacts, which is at least partially documented on the wiki.

Expand  

That is my point. You have to edit a file just to start on phase_city or with no phase at all. Then you are pretty much stuck with it. If you can add a 'nomad' option to the settings box that would be nice. Might break a lot of maps though. :/ As well as a 'just for mods' init and postInit function.

 

Zoras! I can't wait for the next update. :) Is that a winged whale? That is awesome.

Edited by SirPope
Link to comment
Share on other sites

No. You just have to pass that setting like all other gameAttributes. Nomad for most maps is probably going to happen for RMS, for Skirmish maps that is already unlikely, and Scenario maps are either nomad or aren't.

Why do mods need a specific init? So far everything has worked without one and there hasn't been any good reason to add something that isn't needed.

  • Like 1
Link to comment
Share on other sites

Meant for the AI. An Init for petra. Add to the 'Config.advanced' building variable without needing to actually edit petra for example. Or adjust the queue priority levels after they've been set. Such as not having any farms and only corrals. Make the corrals more important. Or in this case randomly unlock a tech for the AI at the beginning. Additions to the advanced building variable would be the most used. How do you set it to nomad? I want to barricade myself in a corner. I'm a turtle.

Edited by SirPope
All it'd take is an empty function getting passed gamestate to implement.
Link to comment
Share on other sites

File loading order is alphabetical, a mod can just add a few files to actually extend the AI. As you have to add some code to make the AI do what you want, you can just add that to the AI. I suspect patches to make some parts easier to configure for mods are very likely to be accepted.

  • Like 1
Link to comment
Share on other sites

@SirPope  I'm not convinced it is a good idea to try and adapt petra to hyrule in A22. There are big chances that by the time you have something working nicely, A23 will be out and you'll have to redo big parts as there were a lot of changes in the last months.

I would rather advise you to adapt Hyrule to the svn version (which is something which will have to be done anyway, so will be time well spent), and then only adapt petra to hyrule. Then your work won't be vain and you may get some help (i've no time nor interest to debug A22 problems, but would be ready to help on problems in the current version). And as leper said, patches which improve mod support can be added in the svn version.

  • Thanks 1
Link to comment
Share on other sites

@mimo

You're a bit late on that. I already patched it into petra a22 and got it working, corrals/farmstead combos, the several barracks & blacksmiths built (except for the stupid tech in the beginning). I copied petra into the Hyrule folder before I edited it. The only thing I'm missing is to 'auto-select' an option for the AI... and a way to figure out which barracks is better... I'm just randomly choosing the one it can afford and has the least of atm. I've gave up on that irritation and switched back to delenda_est. I've already patched that one.

 

As for the svn, if you look at worker.js, the update function has a massive if, else if, else statement near the bottom of it. You could put some returns; to exit out of the statements a bit quicker. It's not much but that code is pretty much used for everything and constantly. Near the end of the update, when an if statement is reached, the function has ended or is going to end and do nothing during that time. So it's pretty much wasted time to not exit after or during these if statements. There are a few places that could use a tiny microboost similar to that as well. basemanager's checkResourceLevels could use some continues to shoot it along.

 

Link to comment
Share on other sites

  On 12/11/2017 at 1:26 PM, SirPope said:

@mimo

You're a bit late on that. I already patched it into petra a22 and got it working, corrals/farmstead combos, the several barracks & blacksmiths built (except for the stupid tech in the beginning). I copied petra into the Hyrule folder before I edited it. The only thing I'm missing is to 'auto-select' an option for the AI... and a way to figure out which barracks is better... I'm just randomly choosing the one it can afford and has the least of atm. I've gave up on that irritation and switched back to delenda_est. I've already patched that one.

Expand  

ok nice   :)   but still, the important comment i wanted to say is that most of these changes won't apply anymore when A23 is released, and a more durable solution is to do these changes in svn (either directly if not mod-specific, or add some way to ease the modding for the others).

 

  2 hours ago, SirPope said:

As for the svn, if you look at worker.js, the update function has a massive if, else if, else statement near the bottom of it. You could put some returns; to exit out of the statements a bit quicker. It's not much but that code is pretty much used for everything and constantly. Near the end of the update, when an if statement is reached, the function has ended or is going to end and do nothing during that time. So it's pretty much wasted time to not exit after or during these if statements. There are a few places that could use a tiny microboost similar to that as well. basemanager's checkResourceLevels could use some continues to shoot it along.

 

Expand  

I'm not sure there will be any time difference, but i agree such early-return would be better for readability. Patch welcome!

  • Like 2
Link to comment
Share on other sites

  • Stan` pinned this topic

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...