Author Topic: How do farms work?  (Read 5882 times)

helldiver

  • Guest
How do farms work?
« on: 16 June 2012, 20:22:32 »
I've cracked my brain trying to understand farms, but the more I look at the XML file the more confused I get.

Can someone explain how farms work currently in vanilla Glest/GAE?

Do they regenerate the food stored back to 20?

I know each time you build a farm you gain 20 food to your total. So when you make a unit you lose 1(or whatever) food from that total?

In particular, what's going on here?
    <resource-requirements>
      <resource name="gold" amount="100"/>
      <resource name="wood" amount="150"/>
      <resource name="stone" amount="50"/>
      <resource name="food" amount="-10"/>
    </resource-requirements>
    <resources-stored>
      <resource name="food" amount="20"/>
    </resources-stored>

-Why is there a negative 10 under Food amount for resource requirements?

-Resources stored 20, does this get regenerated back to 20 after I use up some of the food to produce units?

From Food.xml
<resource>
  <image path="images/food.bmp"/>
  <type value="consumable">
    <interval value="30"/>
  </type>
</resource>

-Is Interval Value how frequently each unit uses up a food?

-If that's the case, what controls how food is brought back in? Does a player need to build more farms/livestock to keep food positive?

The reason I'm asking, is that in my game food will be a static resource (like wood, gold, etc), except that I want the farms to slowly produce it or trickle it in during a game. Units only use up food the first time you build them (like gold or any other static resource).



Next;

If you notice on the resource bar above you see something like Stone 400/1500. I know 400 is the current amount I'm holding. But what is the 1500? Is that the maximum I can hold?

If so, how do I change that, or how do I remove the limit?

One of the resources in project Ethos is Crowns. These are only used to buy "hero" type units. These are very limited and become more or less strategic objectives on the map (hence the large question mark above them, which will be effect later on).

For testing purposes I gave my starting tech, 1 crown to start with (the peasants or not complete so I can't currently gather from chests, yet). However I'm noticing 1/0 meaning I have 1 in hand over a max of 0? How do I change the maximum you can have?

Thanks again for any help you folks can offer.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: How do farms work?
« Reply #1 on: 17 June 2012, 01:00:48 »
Farms don't make the food. They give a tiny +20 food on construction, but the bulk of food is made from producing cows and pigs. Take a look at their XMLs, as well as the produce skill/command in the farm, which is used to allow farms to make these two animals.
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

helldiver

  • Guest
Re: How do farms work?
« Reply #2 on: 17 June 2012, 08:24:07 »
So I can simply move the code from a cow/pig onto the farm itself then. I didn't think to look at the cows/pigs xml, that probably was the answer I was looking for, thanks so much.

I looked at the Cow.xml file and I don't understand how it produces food at an interval.

    <resource-requirements>
      <resource name="gold" amount="95"/>
      <resource name="food" amount="-10"/>

So when I make a cow I get 10 food right? How does the food regenerate? In other words, what XML file, function, etc. Determines how much food is regenerated and at what speed? Is that hardcoded in the engine?

Ok I understand the storage system now, but is it possible for me to remove it completely? In other words I don't want to see 100/120 500/1500 and so on. I simply want the player to see how much of a resource he has. Would I have to recompile the engine for that?

I can set maximum amounts like 99999 (to avoid overflow errors?) in the starting build that's not a problem. But I don't want that second number to be visible in the GUI.

silnarm

  • Local Moderator
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: How do farms work?
« Reply #3 on: 17 June 2012, 08:35:58 »
The consumable resource's 'interval' determines how frequently 'costs' are applied.  Both negative and positive costs are applied each interval, a negative cost is of course how you produce consumables.

The tech farm does produce food, 10 food every 30 seconds (on normal game speed).

From farm.xml 'resource-requirements':
<resource name="food" amount="-10"/>

and from pig.xml 'resource-requirements'
<resource name="food" amount="-5"/>

There is no difference here except in the amount produced.

Consumable resources must also be stored, like all resources, and this is where the farm and pig/cow differ, the farm allows you to store 20 more food, the pig/cow simply produce.
Glest Advanced Engine - Code Monkey

Timeline | Downloads

helldiver

  • Guest
Re: How do farms work?
« Reply #4 on: 17 June 2012, 10:42:37 »
Alright, thank you guys for everything. You answered all of my questions.

lazyanttu

  • Guest
Re: How do farms work?
« Reply #5 on: 18 June 2012, 10:22:03 »
If I remember correctly, if you run out of consumable resource, all units using that resource start taking damage (was it 1/3?) if remember correctly. I'm currently not on my own computer, and this computer doesn't have Glest (or any of its forks), so I can't test it.

Can the amount of damage be set somehow?

helldiver

  • Guest
Re: How do farms work?
« Reply #6 on: 18 June 2012, 23:10:08 »
ok, so simply make food be a normal resource like Wood/Gold and simply declare farms with a -10 under requirement like the cows and such. That should allow food to regenerate? Or does the Negative under requirements only work for Consumable type resources?

For example, could I create some magical building that generates wood?

That should give me the functionality I'm looking for without having to mess with the source code correct?

superfood.xml
<resource>
  <image path="images/superfood.bmp"/>
  <type value="static"/>
</resource>

Then, my farms would have code such as:

<resource-requirements>
  <resource name="wood" amount="100"/>
  <resource name="stone" amount="100"/>
  <resource name="superfood" amount="-10"/>
</resource-requirements>

Does that work? Would the farms trickle in 10 food ever so often?

I'm going off the way Energy works.

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: How do farms work?
« Reply #7 on: 19 June 2012, 22:35:02 »
Static can be used for food, sure. It'd end up being like Magic's energy resource. You might also want to set the recoup-cost value to false (see XML/Resource). Or perhaps not. I just never understood how we get multiple "food" from a single animal. Sure, you can milk cows, but that won't feed you properly. If you want that army to keep moving, you'd going to be running a slaughterhouse, not a petting zoo.

Static would technically get rid of that maximum number on resources, but static resources can only be given from commands (namely produce, build, and generate, the latter being specifically for resource production). Thus, that means no mining gold on the map. As for a building to produce resources, it's possible to give a regenerate command that would produce resources without producing an actual unit. There's no way (yet) to automatically produce resources at intervals, but such a command would be the closest way to go. Think of it like manually producing cows (etc) but just receiving the resources, no actual cow.

Of course, what MoLAoS said works too, but scenarios-only is an awfully big restriction. I'd personally hope to be able to use some degree of Lua commands directly in the unit XML, allowing us to do things like timer controlled resource or unit production, giving certain commands automatically when conditions are met and so on, but that's something for another day.
« Last Edit: 18 June 2016, 18:17:28 by filux »
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

lazyanttu

  • Guest
Re: How do farms work?
« Reply #8 on: 20 June 2012, 12:51:36 »
it is indeed 1/3 damage. i suspect it can't be set, but my computer crashed so my source files aren't currently open.

I don't know IF this is too off-topic, but it would be great IF it could be SET. I guess it is just ole variable on the source code. Do you have any idea how it could be done?

silnarm

  • Local Moderator
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: How do farms work?
« Reply #9 on: 20 June 2012, 15:54:30 »
Infinite storage would indeed be a relatively simple addition, barring any unforeseen problems that make it less simple than it seems, I'll add it (for all resource types) imminently.

Changing the damage done when consumables are lacking seems like it shouldn't be overly cumbersome either, will have a look and report back (in a day or two).
Glest Advanced Engine - Code Monkey

Timeline | Downloads

lazyanttu

  • Guest
Re: How do farms work?
« Reply #10 on: 21 June 2012, 23:56:47 »
Infinite storage would indeed be a relatively simple addition, barring any unforeseen problems that make it less simple than it seems, I'll add it (for all resource types) imminently.

Changing the damage done when consumables are lacking seems like it shouldn't be overly cumbersome either, will have a look and report back (in a day or two).

Great! I had designed an undead faction which pop cap system was "dark magic" and once it runs out, the undead army starts collapsing. However I wanted to have the interval to be rather short (every 3 seconds), so the 1/3 is way too much. I wanted that the units slowly but steadily die, so the player has opportunity to save the situation if their pop cap providers are destroyed.

Sorry for strange upper case letters in previous post. I sent it from my phone and it turned some short words into upper case for some strange reason...

silnarm

  • Local Moderator
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: How do farms work?
« Reply #11 on: 24 June 2012, 07:37:10 »
To remove storage rules for a resource,

Code: [Select]
<resource>
   ...
   <infinite-store value="true" />
   ...
</resource>

To set the damage done per interval for missing consumables,
Code: [Select]
<resource>
   <type value="consumable">
   ...
   <damage absolute="x" percent="y" />
   ...
</resource>

Either an absolute, a percent, or both may be present. (note that 'percent' isn't super-accurate, because of fixed point math).

Glest Advanced Engine - Code Monkey

Timeline | Downloads

lazyanttu

  • Guest
Re: How do farms work?
« Reply #12 on: 25 June 2012, 08:40:57 »
To remove storage rules for a resource,

Code: [Select]
<resource>
   ...
   <infinite-store value="true" />
   ...
</resource>

To set the damage done per interval for missing consumables,
Code: [Select]
<resource>
   <type value="consumable">
   ...
   <damage absolute="x" percent="y" />
   ...
</resource>

Either an absolute, a percent, or both may be present. (note that 'percent' isn't super-accurate, because of fixed point math).

Great! Where I can get the latest version which includes this attribute? :)

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: How do farms work?
« Reply #13 on: 25 June 2012, 12:01:53 »
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

Yggdrasil

  • Local Moderator
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
Re: How do farms work?
« Reply #14 on: 26 June 2012, 13:52:58 »
Compile it yourself.
Even then it won't work, because it's not in the master branch where you land in after cloning. You have to switch to the branch 0.4.x before compiling. Or wait for a release...

silnarm

  • Local Moderator
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: How do farms work?
« Reply #15 on: 5 July 2012, 09:55:47 »
0.4.x is merged back to master now, so master has it (and some other new goodies) and compiling yourself would be preferable anyway, as 0.4 won't have the new stuff in master...

Will release another 0.4 beta imminently, for windows only, I'll probably spend another week or so testing & hunting bugs on *nix.
Glest Advanced Engine - Code Monkey

Timeline | Downloads

 

anything