Jump to content

How to modify 0 A.D.?


Nescio
 Share

Recommended Posts

6 hours ago, wowgetoffyourcellphone said:

;)

?

16 hours ago, Nescio said:

45. Anyone able to explain why selling resources works but buying not, after I added silver?

This still annoys me.

16 hours ago, Nescio said:

And in which file can I replace the bribary cost of 500 metal with 250 silver?

Found it: templates/special/spy.xml It's not the first time I repeatedly overlooked that important special/ folder...

7 hours ago, fatherbushido said:

48. Yes that's this one. (The tooltip should be change accordingly as those modifications are already handled in Template.js).

Don't consider that patch as officialy recommended. It is not reviewed.

(For example, take care of rounding issues, if you use only integers addition it will be fine).

It does seem to work:screenshot0001.thumb.png.611c32e8791aaa286803a1d3523b0f12.png

However, 5*1.5=7.5 and resources are integers, so I suppose the code of that patch ought to be improved. Nevertheless, I actually only intend to avoid multiplicating loot and just use only adding integers.

7 hours ago, fatherbushido said:

45. Your modified files are on github?

They are now: https://github.com/0abc/0abc-unified

Link to comment
Share on other sites

3 minutes ago, fatherbushido said:

45. What did you exactly with the barter component in the last two commits?

Nothing. I tried out if including an unchanged https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/Barter.js would help; it didn't, therefore I removed that file from my mod.

Link to comment
Share on other sites

2 hours ago, fatherbushido said:

Well, did you add the bartermultiplier for silver resource in the player template?

(special/player.xml)

Great, that's it, many thanks for pointing it out, silver now works!

2 hours ago, Nescio said:

It's not the first time I repeatedly overlooked that important special/ folder...

 

Although buying and selling seems to work, I still get a warning I don't understand whenever I start or load a game:

WARNING: JavaScript warning: simulation/components/Barter.js line 45 reference to undefined property multiplier.buy[resource]

Furthermore, I still want to disable bartering resources other than silver directly; only silver ought to be used for buying or selling other resources.

Edited by Nescio
one more thing
Link to comment
Share on other sites

On 24/10/2017 at 4:54 PM, Nescio said:

Although buying and selling seems to work, I still get a warning I don't understand whenever I start or load a game:


WARNING: JavaScript warning: simulation/components/Barter.js line 45 reference to undefined property multiplier.buy[resource]

Furthermore, I still want to disable bartering resources other than silver directly; only silver ought to be used for buying or selling other resources.

That's a really annoying bug.

When putting warn(uneval(this.template.BarterMultiplier)) in the Init of the Player component, we see that the 5th resources is not taken into account. I hope it's because we miss something when using the resource feature (that would be the best).

I will read the doc on trac.

edit: I can't understand right now. Let's say it's magical since we find an explication.

Link to comment
Share on other sites

On 25/10/2017 at 6:19 PM, leper said:

#643.

Many thanks, that's what I needed! I'm currently working on displaying resources (and gatherer numbers) in a separate panel, arranged vertically.

4 hours ago, fatherbushido said:

Do you work on svn or a22?

The latest stable release, i.e. A22.

4 hours ago, fatherbushido said:

Ah forget that, you have to edit the special/player_gaia.xml files

@Nescio

And another file I overlooked, many thanks for pointing it out! That annoying warning has now disappeared (finally!).

 

Still on my silver-to-do list:

  • fix trader gain at 100% silver
  • disable directly bartering resources other than silver; only silver should be used for buying and selling other resources
  • remove the market requirement for bartering resources
  • redesign the resource and barter and trade GUI panels

 

 

 

Just in case anyone else intends to start adding resources, you need:

  • to create:
    • art/textures/ui/session/icons/resources/{newresource}.png
    • art/textures/ui/session/icons/resources/{newresource}_small.png
    • simulation/data/resources/{newresource}.json
  • to edit:
    • gui/common/setup_resources.xml
    • gui/session/selection_panels.js
    • gui/session/selection_panels_left/barter_panel.xml
    • gui/session/top_panel/resources.xml
    • simulation/templates/special/player.xml
    • simulation/templates/special/player_gaia.xml
    • simulation/templates/template_structure.xml
  • https://trac.wildfiregames.com/wiki/ModdingResources is helpful but apparently incomplete; it does not mention the player files
Edited by Nescio
ce
Link to comment
Share on other sites

2 hours ago, Nescio said:

Many thanks, that's what I needed! I'm currently working on displaying resources (and gatherer numbers) in a separate panel, arranged vertically.

The latest stable release, i.e. A22.

And another file I overlooked, many thanks for pointing it out! That annoying warning has now disappeared (finally!).

 

Still on my silver-to-do list:

  • fix trader gain at 100% silver
  • disable directly bartering resources other than silver; only silver should be used for buying and selling other resources
  • remove the market requirement for bartering resources
  • redesign the resource and barter and trade GUI panels

 

 

 

Just in case anyone else intends to start adding resources, you need:

  • to create:
    • art/textures/ui/session/icons/resources/{newresource}.png
    • art/textures/ui/session/icons/resources/{newresource}_small.png
    • simulation/data/resources/{newresource}.json
  • to edit:
    • gui/common/setup_resources.xml
    • gui/session/selection_panels.js
    • gui/session/selection_panels_left/barter_panel.xml
    • gui/session/top_panel/resources.xml
    • simulation/templates/special/player.xml
    • simulation/templates/special/player_gaia.xml
    • simulation/templates/template_structure.xml
  • https://trac.wildfiregames.com/wiki/ModdingResources is helpful but apparently incomplete; it does not mention the player files

Could you complete the wiki entry?

(It's free to edit...)

  • Like 1
Link to comment
Share on other sites

On 27/10/2017 at 2:30 PM, Imarok said:

Could you complete the wiki entry?

(It's free to edit...)

And I've largely rewritten the page, expanding and updating the parts on changing, removing, and adding resources from the game; I've left the “gathering” section unaltered (I've no experience with this (silver is intended to be not directly gatherable)); information on the AI and maps is also absent. Anyone interested in improving the page further, do not hesitate to edit it (I'm done with it now).

On 25/10/2017 at 6:19 PM, leper said:

#643.

So I've attempted to include this over-five-years-old proposed patch into my mod, and although I didn't get any error messages after including the js parts into the simulation/components/ files (which was surprising, because I didn't really know what I was doing), I've not succeeded in actually displaying current gatherer numbers; the gui has simply changed too much, and amongst other things, resources are no longer hardcoded individually. For now I've shelved this idea, my programming skills are simply too limited.

I would really appreciate it if someone with more coding experience could eventually update #643 and include it into 0 A.D. I don't think I'm the only one who considers displaying gatherer numbers useful.

 

 

45. Detaching the minimap from the central panel was surprisingly easy; moving the resources from the top panel to a new, separate panel turned out to be unexpectedly difficult. Apparently I'm overlooking something somewhere. Perhaps someone could help me by pointing out what I have to do to create a new (vertically arranged panel, e.g.:

(x1,y1) --- (x2, y1)
  | resource[1] |
  | resource[2] |
  | resource[3] |
  | resource[4] |
  | resource[5] |
(x1,y2) --- (x2, y2)

 

 

50. 0 A.D.'s AI is flexible in some respects: it trains new units, it researches new technologies, and it acquires and spends silver (0abc's new resource). Unfortunately it seems the AI is not capable of handling new or renamed structures. Apparently buildings are hardcoded somewhere in the AI files. 

Now, how to make the AI actually use new structures?

On 25/10/2017 at 4:36 PM, Grugnas said:

can i ask here questions relative to AI behavior modify?

(Apparently I'm not the only one who would appreciate an introduction to how the AI works.)

Structure changes I've implemented:

  • made the fortress a purely defensive structure (the AI builds them)
    • moved heroes to the centre (the AI trains them)
    • moved siege weapons to siege workshops (surprisingly the AI builds these)
    • moved war elephants to elephant stables (I haven't seen any of these)
    • moved champions to military halls, see below (the AI doesn't use them)
  • separated the military docks into
    • economic docks (resource dropsite, trade route market, constructs fishing boats, merchant ships, war barges, and fire ships)
    • military shipyards (constructs war galleys)
  • separated the barracks into:
    • infantry barracks
    • cavalry stables
    • camel stables
  • created a military hall (structures which trains most of a faction's champions)
    • gymnasium (athen), tavern (gaul), hall (pers), syssiton (spart) are merged and renamed into hall
    • also created halls for cart, mace, ptol, sele
  • renamed Persian adapana into palace and also added a palace for the Mauryans

With a few exceptions, the AI does not seem to be capable of handling these. Ideally structures shouldn't be hardcoded in the AI files, allowing the AI to be flexible (as it is with units and technologies). Realistically, a guide to explain how to make the AI actually use new structures would already be great, not only for me, but also for many other mods (e.g. HC, VP, DE).

Furthermore, this is also important for the default game; the Art team is creating many new structures; besides, I've never seen the AI actually building dog kennels, walls, and wonders. If the AI would be capable of handling all available structures, 0 A.D. would undoubtedly be a much more enjoyable game.

 

Link to comment
Share on other sites

AI never upgrades towers, shich struggle me into an eventual building upgrade ( matter of fact seleucid reforms are made through technology pair ).

I simply managed to avoid AI from hunting chicknes with not cavalry units and gathering fruits with infantry ( they stay idle though ).

Link to comment
Share on other sites

Currently I'm working on a new resource panel gui (again). Here is the code of the resources.xml file:

<?xml version="1.0" encoding="utf-8"?>
<object name="resourceCounts" size="0 32 116 244" sprite="genericPanel" type="image">
  <repeat count="5">
    <object name="resource[n]" size="0 6 108 46" type="image" style="resourceCounter" tooltip_style="sessionToolTipBold">
      <object size="4 4 36 36" type="image" name="resource[n]_icon" ghost="true"/>
      <object size="32 0 100%-4 100%-4" type="text" style="resourceText" name="resource[n]_count"/>
    </object>
  </repeat>
</object>

This results into:

screenshot0001.thumb.png.cecb0927ba726ae85a580c3cc92547a4.png

Now I want to list the resources vertically (to the left of the minimap), instead of horizontally. Although I guess it's probably not that difficult, I can't figure out how to achieve that. Any suggestions?

Link to comment
Share on other sites

You will have to create a verticallySpaceObjects functions that is quite similar to the currently existing horizontallySpaceObjects (gui/common/functions_utility.js), then change the call to that in gui/common/sessions.js to place the resource objects. I think the former or something quite similar to it might be in one of s0600204's patches or branches. The latter will be hard to maintain, so it would be best if you first moved that part into another file that just does that.

And after you have done that you will notice that the population icon and counter will not be aligned properly. Mostly because that is handled slightly differently from the other "real" resources, so it might make sense to change that so that that specific hard-coding isn't needed anymore.

Link to comment
Share on other sites

In case it wasn't clear, you could most likely also add the verticallySpaceObjects function to another js file that is loaded (read a new one), and I'm quite sure if you'd factor out the piece of code that's aligning the resources into some function and place that in a new file, then the latter is quite likely to be accepted if submitted as a patch. Will also help with future updates where you don't have to figure out what you changed in some files. And if that isn't possible at least add the unmodified file in a commit, then have another commit with the changes only.

  • Like 1
Link to comment
Share on other sites

Now you've lost me, I'm afraid. What exactly do you want me to put into a patch? All I did was inserting a new verticallySpaceObjects into functions_utility.js and subsequently changed a few lines in sessions.js

3 hours ago, leper said:

And if that isn't possible at least add the unmodified file in a commit, then have another commit with the changes only.

Which file(s) do you mean exactly?

Link to comment
Share on other sites

Moving the part that does the layout of the resource objects into a function and calling that from the function where you replaced horizontallySpaceObjects with verticallySpaceObjects. Possibly placing that in some other file if you want to. Mostly so in your mod (or someone else in a mod) can just replace that new function without having to ship a modified copy of session.js.

You added full copies of session.js and functions_utility.js to your mod, with small modifications. This is going to be hard to maintain. If the only thing you actually ship in your mod are two script files, one with the verticallySpaceObjects function, and one with the modified placement/layout function (which needs that part to be split from the function it is currently in), then the amount of work you will have to do when you upgrade to the next release will be reduced by a lot.

  • Like 2
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...