Author Topic: "OR" tags in Unit+Resource+Upgrade Requirements  (Read 992 times)

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
"OR" tags in Unit+Resource+Upgrade Requirements
« on: 7 November 2011, 04:06:41 »
Hi I was wondering if we could make it so that you could have options for requirements, for example having a unit worth 100 gold OR 300 stone?

A perfect example is in my Annex mod. If you remember There is a unit called "Falcon" that's listed twice in the refinery. That is because i wanted her to be recruit-able after EITHER A tech lab OR Silo are produced. The only way around this is to list that unit in two separate commands each with its own requirement, but looks strange to see a unit listed twice. Another new unit in Annex has the same requirements of either Tech lab OR Silo to be produced. 

Maybe an <or/> command between two requirements would help? Any other ideas?
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: "OR" tags in Unit+Resource+Upgrade Requirements
« Reply #1 on: 7 November 2011, 04:37:25 »
Hmm, the proposed syntax seems rather messy/limited. It wouldn't give any way to imply needing two out of three things, for example. What if we had the concept of multiple different requirements, and only one would be used? So for example, in the unit XML:

Single list of requirements (as we have it now):
Code: [Select]
<unit-requirements/>
<upgrade-requirements />
<resource-requirements>
<resource name="gold" amount="100" />
<resource name="stone" amount="300" />
<resource name="wood" amount="150" />
</resource-requirements>

Multiple lists of requirements:
Code: [Select]
<production-requirements>
<requirements>
<unit-requirements>
<unit name="blacksmith" />
</unit-requirements>
<upgrade-requirements />
<resource-requirements>
<resource name="gold" amount="100" />
<resource name="food" amount="1" />
</resource-requirements>
</requirements>
<requirements>
<unit-requirements>
<unit name="barracks" />
</unit-requirements>
<upgrade-requirements />
<resource-requirements>
<resource name="gold" amount="100" />
<resource name="food" amount="1" />
</resource-requirements>
</requirements>
</production-requirements>

In this above example, the unit has two separate "lists" of requirements. Both require the same resources (100 gold and 1 food), but differ in what building is needed: either a blacksmith or barracks. This system would be far more versatile: since perhaps one way to produce a unit is with an advanced upgrade, or alternatively, they can expend more resources to produce the unit (MegaGlest does not yet support cost modifier in upgrades).

The requirements would be read from top to bottom, so if the first <requirements> tag uses less resources but has an upgrade requirement, while the second requirements tag uses more resources but doesn't require that upgrade; the first would be checked first. If the player has that upgrade, it will use that list of requirements, while if they do not, it will try to use the second. Thus, the order of the requirements tag would be important. If the requirement tags in this example were switched in order, it wouldn't matter if you had the upgrade in question or not, since you'd always usually meet the first requirement instead (unless you don't have enough resources).

The requirements would each be shown as separate tooltips, separated by the word "OR" on a new line. So for the top example, the tooltip might say:
Quote
Requirements:
Blacksmith
100 Gold
1 Food

OR

Barracks
100 Gold
1 Food

Overall, using this type of syntax would be able to do what Ishmaru needs, without restricting the system to those simple instances, allowing future mods to be less linear.
« Last Edit: 18 June 2016, 13:21:00 by filux »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: "OR" tags in Unit+Resource+Upgrade Requirements
« Reply #2 on: 7 November 2011, 14:09:37 »
This could also be a cool way of having an upgrade that reduces cost. For example, either you can satisfy the upgrade requirement or else you pay more.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: "OR" tags in Unit+Resource+Upgrade Requirements
« Reply #3 on: 8 November 2011, 13:54:25 »
requirements are set for different classes:

upgrade requirements
unit requirements
resource requirements

If you try to display this in a flat way, things will get confusing for the player.
What you can do is:
Code: [Select]
Requirements:

Blacksmith OR Barracks
100 Gold OR 100 Gold AND 150 Wood
1 Food AND 1 Energy OR 2 Food AND 2 ENERGY

But all this might confuse the player. I don't like it that much, but if someone shows a a good mod and really wants it ...  8)
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: "OR" tags in Unit+Resource+Upgrade Requirements
« Reply #4 on: 8 November 2011, 22:54:25 »
requirements are set for different classes:

upgrade requirements
unit requirements
resource requirements

If you try to display this in a flat way, things will get confusing for the player.
What you can do is:
Code: [Select]
Requirements:

Blacksmith OR Barracks
100 Gold OR 100 Gold AND 150 Wood
1 Food AND 1 Energy OR 2 Food AND 2 ENERGY

But all this might confuse the player.
I think your way is far more confusing. Listing the full requirements as a list also would be more advantageous in several situations. After all, in the instance of reducing the price of a unit if they have an upgrade, what would you say then? "My upgrade OR..." Or with long lists of resources ("300 gold AND 250 wood AND 200 stone AND 2 food OR 400 gold AND 100 wood AND 200 stone AND 2 food"). You don't have very much horizontal space in the unit infobox, but lots of vertical space. And I have no idea what you mean by a "flat" way.

I don't like it that much, but if someone shows a a good mod and really wants it ...  8)
I thought ishmaru's mod is pretty darn good. Graphic-wise, it beats out every other MegaGlest mod hands down, and has very unique gameplay from most other MegaGlest mods.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: "OR" tags in Unit+Resource+Upgrade Requirements
« Reply #5 on: 11 November 2011, 23:13:02 »
Perhaps we could cycle the requirements display, every few seconds, showing each purchase option. That would be the least confusing/space taking option.

Screen example:
In this case Roman training camp is 150 gold 100 stone 50 wood OR 100 gold 100 stone and Forum Upgrade:



So it would look like the normal requirements system but would cycle every few seconds while mouseover.

I don't like it that much, but if someone shows a a good mod and really wants it ...  8)
Thanks Titi!

Edit: fixed broken image
« Last Edit: 14 November 2011, 03:11:26 by Ishmaru »
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer