Jump to content

How to modify 0 A.D.?


Nescio
 Share

Recommended Posts

23 hours ago, Nescio said:

60. Currently 0 A.D. has “Wonder” and “Capture the Relic” victory conditions. I've been pondering about adding another, similar one, winning by centre count, e.g. control at least 10 centres for 10 minutes. Moving catafalques inside a heavily fortified base or concentrating your forces around a wonder is easier than protecting a number of centres with distances in between.

Unfortunately I have no idea what has to be done to implement it. Any suggestions?

I like the idea! I haven't really dug into it, but the victory conditions itself can be found in: `simulation/data/settings/victory_conditions`, whilst the scripts they refer to are located in `maps/scripts`.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
5 hours ago, Nescio said:

There are many hotkeys already in game, probably more than a normal person can remember.

However, I'd like to have one more: pressing `Home` to cycle through your centres. Any suggestions on how to implement that?

I would suggest looking at how hotkey.selection.idleunit is implemented.

First you need to add the hotkey definition to default.cfg.  Then you would implement something like findIdleUnit in binaries/data/mods/public/gui/session/input.js.

Here are a few tickets covering this feature: #1899, #1492. You might be able to reuse some or all of those patches.

  • Like 1
Link to comment
Share on other sites

On 7/19/2019 at 11:09 AM, Nescio said:

However, I'd like to have one more: pressing `Home` to cycle through your centres. Any suggestions on how to implement that? 

Probably will add this to my mod in the next version. As historic_bruno said there are already patches with it implemented on trac.

Link to comment
Share on other sites

7 hours ago, Nescio said:

Yeah, but that file is outside the public/ folder, so I'm not sure how that could be done with a mod?

You have access to the following functions in JS (see JSInterface_ConfigDB.cpp):

bool Engine.ConfigDB_HasChanges(namespace)
bool Engine.ConfigDB_SetChanges(namespace, bool)
string Engine.ConfigDB_GetValue(namespace, key)
bool Engine.ConfigDB_CreateValue(namespace, key, value)
bool Engine.ConfigDB_RemoveValue(namespace, key)
bool Engine.ConfigDB_WriteFile(namespace, path)
bool Engine.ConfigDB_WriteValueToFile(namespace, key, value, path)
bool Engine.ConfigDB_SetFile(namespace, path)
bool Engine.ConfigDB_Reload(namespace)

For namespace, I guess "mod" is most appropriate. I think you could check if your new hotkey(s) are set yet in mod.cfg (mod namespace) and if not, set the defaults. Also check out the options GUI implementation.

Note: this isn't ideal -- each mod should have its own separate config.

  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

62. If I understand correctly, elevation (from terrain, position, and entity's <Attack/Ranged/ElevationBonus>) increases effective maximum range (simulation/components/Attack.js: `Attack.prototype.GetRange`). However, I'd like it to also improve ranged attack damage; e.g. an archer standing on a wall 11.5 above the ground would inflict +23% damage on someone below. I guess it might actually be quite easy to do, but my understanding of JavaScript is rather limited.

Link to comment
Share on other sites

7 minutes ago, Nescio said:

62. If I understand correctly, elevation (from terrain, position, and entity's <Attack/Ranged/ElevationBonus>) increases effective maximum range (simulation/components/Attack.js: `Attack.prototype.GetRange`). However, I'd like it to also improve ranged attack damage; e.g. an archer standing on a wall 11.5 above the ground would inflict +23% damage on someone below. I guess it might actually be quite easy to do, but my understanding of JavaScript is rather limited.

D781 I plan on revising that next month. (To also include melee attacks.)

  • Like 1
Link to comment
Share on other sites

On 8/9/2019 at 12:40 PM, Nescio said:

62. If I understand correctly, elevation (from terrain, position, and entity's <Attack/Ranged/ElevationBonus>) increases effective maximum range (simulation/components/Attack.js: `Attack.prototype.GetRange`). However, I'd like it to also improve ranged attack damage; e.g. an archer standing on a wall 11.5 above the ground would inflict +23% damage on someone below. I guess it might actually be quite easy to do, but my understanding of JavaScript is rather limited.

Is this because of the trajectory/gravity adding force to the projectile? 

While the height bonus cannot currently be implemented (on hills or elevations), the wall attack bonus can certainly be implemented right now. 

Edited by wowgetoffyourcellphone
Link to comment
Share on other sites

  • 2 weeks later...

Another idea I'd like to try out but have no idea how to implement:

63. Instead of a player population setting, have a world population setting; each surviving player is then entitled to a 1/n share. E.g. a four player game with a world population of 600: all players have a maximum population limit of 150 at start; one player is defeated, the others can now have up to 200; then another is defeated, both survivors up to 300. Methinks this would provide an interesting dynamic (do you keep weak players alive to prevent stronger opponents from training more units?) while avoiding performance issues and improving realism.

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

@Nescio I saw on your feature wish list that the distance limit for buildings applies to all players?

In `BuildRestrictions.js` after line 242 add:

let players = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetAllPlayers();

Then at lines 255 and 267 (the range queries) replace

[cmpPlayer.GetPlayerID()]

with

players

. That should do the job :)

Link to comment
Share on other sites

28 minutes ago, Freagarach said:

@Nescio I saw on your feature wish list that the distance limit for buildings applies to all players?

In `BuildRestrictions.js` after line 242 add:


let players = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetAllPlayers();

Then at lines 255 and 267 (the range queries) replace


[cmpPlayer.GetPlayerID()]

with


players

. That should do the job :)

Maybe could be translated in a gamemode ?

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
On 10/21/2019 at 8:50 AM, Freagarach said:

@Nescio I saw on your feature wish list that the distance limit for buildings applies to all players?

In `BuildRestrictions.js` after line 242 add:


let players = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetAllPlayers();

Then at lines 255 and 267 (the range queries) replace


[cmpPlayer.GetPlayerID()]

with


players

. That should do the job :)

Thanks! That was quite easy, the AI isn't complaining either, and it's nice in combination with capturable foundations, so I've incorporated in my 0abc mod.

  • Like 1
Link to comment
Share on other sites

On 8/22/2019 at 7:40 PM, Nescio said:

Another idea I'd like to try out but have no idea how to implement:

63. Instead of a player population setting, have a world population setting; each surviving player is then entitled to a 1/n share. E.g. a four player game with a world population of 600: all players have a maximum population limit of 150 at start; one player is defeated, the others can now have up to 200; then another is defeated, both survivors up to 300. Methinks this would provide an interesting dynamic (do you keep weak players alive to prevent stronger opponents from training more units?) while avoiding performance issues and improving realism.

D2426.

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Two other things I'd like to try out, without knowing how to implement them:

64. If you delete a foundation that's x (e.g. 60%) completed, you only get 1 - x (i.e. 40%) of the resource costs back, instead of the full amount.

65. Newly placed foundations start with some health, e.g. 10% of maximum, rather than just 1.

Link to comment
Share on other sites

24 minutes ago, Nescio said:

Two other things I'd like to try out, without knowing how to implement them:

64. If you delete a foundation that's x (e.g. 60%) completed, you only get 1 - x (i.e. 40%) of the resource costs back, instead of the full amount.

Perhaps that's what you are looking for: https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/Foundation.js#L88

Link to comment
Share on other sites

Indeed what @fatherbushido said, it can also be seen there that that feature should already be present in vanilla?

44 minutes ago, Nescio said:

65. Newly placed foundations start with some health, e.g. 10% of maximum, rather than just 1.

It is defined in templates/special/filter/foundation.xml that foundations start with 1 HP. One can set the health in Foundation.js in the function InitialiseConstruction. E.g.:

Spoiler

	let cmpHealth = Engine.QueryInterface(this.entity, IID_Health);
	if (cmpHealth)
		cmpHealth.SetHitpoints(cmpHealth.GetMaxHitpoints() * 0.1);

Should do the trick.

 

Link to comment
Share on other sites

31 minutes ago, fatherbushido said:

Perhaps that's what you are looking for: https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/Foundation.js#L88

Yes, it is, thank you for pointing out. What I wanted is actually already implemented. Now I wonder why I assumed it wasn't, and feel a bit dumb.

66. An option to deconstruct structures, which returns some resources but takes some time.

Link to comment
Share on other sites

1 minute ago, Freagarach said:

It is defined in templates/special/filter/foundation.xml that foundations start with 1 HP. One can set the health in Foundation.js in the function InitialiseConstruction. E.g.:

  Reveal hidden contents


	let cmpHealth = Engine.QueryInterface(this.entity, IID_Health);
	if (cmpHealth)
		cmpHealth.SetHitpoints(cmpHealth.GetMaxHitpoints() * 0.1);

Should do the trick.

 

Thanks! Would it also be possible to define the starting value (or percentage) in the templates, rather than fixing it at 10% for everything? E.g. corral starting with 5% of 500, i.e. 25, and the field with 20% of 250, i.e. 50.

Link to comment
Share on other sites

It will be easy to do after the autobuild patch gets in (https://code.wildfiregames.com/D2492). Currently foundation component (the one where you'd define that value) are added to buildings at runtime under the form of filters (defined in templates/special/filters) and it's buggy to set values there.  Once the buildable component has been set, it will be a few lines of code :)

  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...

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