Page 2 of 2

Re: Resources.cfg

Posted: Mon Aug 28, 2017 9:08 am
by Turley
Ok I write it a bit more clear, as you would implement such a function in escript:

Code: Select all

Function HarvestRessource(resource, x, y, b, n, realm)
Var avail_units := GetUnits(resource, x, y, realm);
Var temp := avail_units / b;
If (temp > n)
  temp := n;
Endif
DepleteUnits(resource, x, y, realm, temp*b);
Return temp * b;
Endfunction
GetUnits and DepleteUnits are just simple functions per coordinate you store the cfg entry available_units and subtract from it plus regenerate them over time.

So b can be interpreted as the cost and n is the maximum amount of such a "cost-block".
In the simplest example you want something like maximum 5 units with a cost of 1 each would need 1,5 as param. It results/depletes 0-5
Or something like get maximum 3 units with a cost of 10 each means as params 10,3. This means possible results/depletions are 0,10,20,30

Re: Resources.cfg

Posted: Mon Aug 28, 2017 9:37 am
by Yukiko
OK. So 'n' represents the upper boundary of the cost to harvest. If I have understood it correctly then that's all I wanted to know. Maybe my math skills are too limited and someone more skilled than me could look at the equation and understand what 'n' represents. Thanks Turley. Hopefully I understood it correctly. :)

Re: Resources.cfg

Posted: Mon Aug 28, 2017 11:08 am
by Yukiko
Turley answered my question on Discord so I thought I'd post it here.

You either get the full b *n or b * a number between 1 and n or you get 0 depending on the availability of resources. It leaves whatever remains of the resource.