Resources.cfg

Here you can post threads specific to the current release of the core (099)

Moderator: POL Developer

Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Resources.cfg

Post by Alwir »

Hi there,

sorry, but i can't find, how work "Capacity" in this cfg
I mean in
Region Background
{
UnitsPerArea 2
SecondsPerRegrow 3600
Capacity 100000
Range 0 0 7144 4095
}

Can anybody tell about this, please?
gh0sterZA
Neophyte Poster
Posts: 35
Joined: Thu Nov 19, 2015 11:36 am
Location: Cape Town

Re: Resources.cfg

Post by gh0sterZA »

Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

I saw that )))

But there no explain about Capacity and how capacity works.

I was setting 2000 and 2000000 and no difference be

ps and i saw sources of core where capacity sets (resource.cpp), but i don't know C++ enough
Therefore i have asked to tell me about this )))

sometime respawn adds one unit in tile, sometime adds full UnitsPerArea.

I think it is depended from area of range(numbers of tiles from LandTiles) and capacity, but i can't understand how
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Resources.cfg

Post by Yukiko »

I agree with Alwir but I would add that we need a more indepth or detailed explanation of the resource system, particularly the formulas involved. The explanation in the docs is somewhat ambitious.
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

Some strange things )))

I was digging area 6x6
Config:
Region Mountain NW of Wrong
{
UnitsPerArea 5
SecondsPerRegrow 600
Capacity 200000
Range 1935 55 1999 118
}
[08/26 23:08:20] [scripts/textcmd/test/test4.ecl]: 17006367 0 0 ore exist: 5 timer: 0 <<< START
...
[08/26 23:11:16] [scripts/textcmd/test/test4.ecl]: 17006367 5 5 ore exist: 180 timer: 175
[08/26 23:30:22] [scripts/textcmd/test/test4.ecl]: 17006367 1982 104area ore counter is alive, timer: 1319 all ore: 180
[08/26 23:31:23] [scripts/textcmd/test/test4.ecl]: 17006367 0 0 ore exist: 181 timer: 1379 <<FIRST GROW (1200 sec!!! not 600, ok maybe spawner have own cycle with 600 sec)
[08/26 23:31:28] [scripts/textcmd/test/test4.ecl]: 17006367 0 1 ore exist: 182 timer: 1384
....
[08/26 23:34:18] [scripts/textcmd/test/test4.ecl]: 17006367 5 5 ore exist: 216 timer: 1554
[08/26 23:40:23] [scripts/textcmd/test/test4.ecl]: 17006367 1982 104area ore counter is alive, timer: 1919 all ore: 216
[08/26 23:41:25] [scripts/textcmd/test/test4.ecl]: 17006367 0 0 ore exist: 217 timer: 1980 <<< SECOND GROW (600 sec!!!)


second try
Region Mountain NW of Wrong
{
UnitsPerArea 5
SecondsPerRegrow 600
Capacity 2000
Range 1935 55 1999 118
}

[08/27 00:00:00] [scripts/textcmd/test/test4.ecl]: 17004050 0 0 ore exist: 5 timer: 0<<< START
...
[08/27 00:01:00] [scripts/textcmd/test/test4.ecl]: 17004050 5 5 ore exist: 180 timer: 175
[08/27 00:13:07] [scripts/textcmd/test/test4.ecl]: 17004050 1983 102area ore counter is alive, timer: 901 all ore: 180
[08/27 00:14:08] [scripts/textcmd/test/test4.ecl]: 17004050 0 0 ore exist: 181 timer: 961<<FIRST GROW (960sec!!! not 600)
....
[08/27 00:17:03] [scripts/textcmd/test/test4.ecl]: 17004050 5 5 ore exist: 216 timer: 1136
[08/27 00:23:08] [scripts/textcmd/test/test4.ecl]: 17004050 1983 102area ore counter is alive, timer: 1501 all ore: 216
[08/27 00:24:09] [scripts/textcmd/test/test4.ecl]: 17004050 0 0 ore exist: 217 timer: 1560 <<SECOND GROW (600 sec)
...
[08/27 00:27:04] [scripts/textcmd/test/test4.ecl]: 17004050 5 5 ore exist: 252 timer: 1735
[08/27 00:27:09] [scripts/textcmd/test/test4.ecl]: 17004050 1983 102area ore counter is alive, timer: 1740 all ore: 252

third try Attention! SecondsPerRegrow 1200)))
Region Mountain NW of Wrong
{
UnitsPerArea 5
SecondsPerRegrow 1200
Capacity 2000
Range 1935 55 1999 118
}

[08/27 01:00:43] [scripts/textcmd/test/test4.ecl]: 17032845 0 0 ore exist: 5 timer: 0<<< START
...
[08/27 01:03:38] [scripts/textcmd/test/test4.ecl]: 17032845 5 5 ore exist: 180 timer: 175
...
[08/27 04:00:10] [scripts/textcmd/test/test4.ecl]: 17032845 1983 104area ore counter is alive, timer: 10740 all ore: 180
0 resource grow. 3 hours! have to 1200 sec, realy? )))
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Resources.cfg

Post by Turley »

First of all: Posting loglines from a unknown command is pretty senseless.
Second: every 10minutes the resources in the world get regenerated. Since it can only regenerate full units having a secondsperregen value bigger then 600 leads to none resources regen at all ( 600 / 1200 = 0 )
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

Sorry I would to explain. This was script, which emulates to digging the area 6х6

Code: Select all

program testore(who)
var targ:=TargetCoordinates(who);
detach();
var timer:=ReadGameClock();
var counter:=0;

while (1)
	var x,y;
	for (x:=0;x<=5;x+=1)
		for (y:=0;y<=5;y+=1)
			var num := HarvestResource( "ore", targ.x+x, targ.y+y, 1, 5, targ.realm);
			if (num)
				counter:=counter+num;
				syslog(getPid()+" "+x+" "+y+" ore exist: "+counter+" timer: "+(ReadGameClock()-timer));
				sleep(5);
				continue;
			endif
		endfor
	endfor
	syslog(getPid()+" "+targ.x+" "+targ.y+"area ore counter is alive, timer: "+(ReadGameClock()-timer)+" all ore: "+counter);
	sleep(60);
endwhile
endprogram
second:
mmm.... from docs:
Example: this file is for wood resources, and UnitsPerArea is 15. This means I can get a maximum of 15 wood from a tree until the resources 'regrow'. I could define another region that has very plentiful, or fast growing trees and adjust the UnitsPerArea and SecondsPerRegrow accordingly.
get maximum of 15 wood until regrow? What does it mean? I think this means what the resources grow 15 unit in SecondsPerRegrow sec. The all docs about this wrong? Or maybe i'm a fool((( sorry

Ok thanks for the answer. I understand about the 600sec. Finally) If it would be 100 sec, we can regrow 600/100 = 6 unit, etc.
But i still can't understand about the capacity )

But it is very very low for real shard with small online (((
Can you fix it for more interval?



PS Thanks for the answer, again. You have helped me great!

PPS sorry for my English :shame:
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Resources.cfg

Post by Turley »

Capacity is undocumented since it's an unused feature, no idea what the plan was.
Thus what counts is the unitsperarea which defines how much resources per coordinate exists and secondsperregrow which defines how long it takes till a unit gets refreshed.

Every 10minutes each region gets regenerated:
Units to regrow = (now - lastregen time) / secondsperregrow

For example secondsperregrow=300
600/300 = 2 units
Every 10minutes 2 units will regrow in this area per coordinate.
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

Cool! Thank you very much!

Please, consider about increasing timeline of regrow it's very important thing for the economics of shards
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Resources.cfg

Post by Turley »

If I understood you correctly you want faster regenrate?
That is possible without changing anything.
Set SecondsperRegrow to e.g. 1 and you get:
600 units per 10 minutes
If that is not enough you can remove this cfg entry and you get every 10 minutes the full unitsperarea.
The only limitiation is in the other direction which means sendsperregrow maximum value is 600 so 1 unit per 10minutes.
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

No no
I want slower reneration! More slower regeneration

Now we have min 1 per 600sec. I need 1 per hour or 2 hours
I think something about use of decimal in core. For example
UnitsPerArea 10
SecondsPerRegrow 3600

600/3600=0.16(6) every 600sec and when it will be more 1.0, add 1 unit to tile

now we have 600/3600=0 and thats all

For example i want to do some area with very very rare resources. Mithril in Trinsic mountains for example )))) But big problem is another.
With 1 unit per 600sec macrosers will dig it very fast.
1 unit per 600sec = 144unit per tile from day(24 hours)
1 macroser dig 1 tile 3 sec = 200 tiles on cycle (600 sec)
144*200 = 28 800 units of resources in the day per 1 char. If player have 10 chars it is 288 000 unit of resources per day! With small online without competition it's the very big value

On my shard players can create caves and mines and dig beneath the ground and grow trees, therefore constraint of area don't help

I don't want close macroses and we can't close all macroses. But live player can go to another area with full stock of ore, macroser can too, but exists NPC and PK and another problem for char without player

of course we can increase time for "dig" 10sec on the tile but for live players it's no cool
of course we can increase needed resources for craft 1 stool from 10000 wood but for live players....
of course i can do it from e-script but for many tiles and region it will be hard for server
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

Maybe turn on capacity?
Region GoodRegion
{
UnitsPerArea 3
SecondsPerRegrow 3600
Capacity 50000
Range 10 20 110 120
}

area of region = 110-10 * 120-20 = 10000
max units per tile in area = Capacity / area of region = 50000/10000 = 5 in the tile

we have main cycle for grow 600 sec. Ok it's good

every 600 sec we add 600 on region in field time_from_grow
if (time_from_grow>=SecondsPerRegrow) {
time_from_grow-=SecondsPerRegrow;
grow tile on UnitsPerArea value
} else {
time_from_grow+=600;
}

and we will have any time for grow not only 600sec, and more settings for resources spawner without big changes in core
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Resources.cfg

Post by Turley »

Why not simply use more then one Ressource unit to create one of your rare items? The parameters of Harvest() are not fixed they can be altered ;)
So instead of harvest only one unit if you eg harvest 10units this should result in something like:
Secondsperregrow=600 -> one unit per 10minutes
One successful harvest with a cost of 10units every 100minutes.
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

Yes, but HarvestResource() harvest maximum. i mean if in the tile 1 unit HarvestResource( "ore", targ.x, targ.y, 10, 1, targ.realm) returns 1,
end since 600 sec in this tile will be 1 unit and harvest return 1; and then and then

if you mean check
if Harvest return > N

but every time when somebody only TRY harvest units the counter of unit in tile will be reset and since 600sec we have 1 unit per tile
And we will never have resources in common places
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Resources.cfg

Post by Turley »

I couldn't test it on a real shard so i only tested the functionality in resource.cpp and it works as expected:
You used 10 and 1 as parameter for harvesteresource()
That means harvest at the cost of 10 maximum on time.
The Formular is:
a=avail_units / n
if a> m
a=m
return a*n

If you have eg 10 units available this results in :
10/10=1
->1*10=10

Or 5 available units:
5/10=0
->0*10=0

Or 20:
20/10=2
->1*10=10 (2 is bigger 1)

Thus it will harvest and return only 0 or 10
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

O! Thank you. I understood that.

You are my hero! :)

But now, i should consider all the configs depending on the value in the script. It's not cool :(

UnitsPerArea 6
SecondsPerRegrow 600

with 3,1 in Harvest, realy it means grow in 1800 sec.... or 5,1 = 3000sec it's cool... or 10,1 = 6000sec it's very good

but it also means i can't use UnitsPerArea below 10 or i have to change value in Harvest, try to find out region by coordinates or something else...

Nevertheless thank you for help!
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Resources.cfg

Post by Turley »

Isn't the harvest cost specific to your resource?
Why not simply add one or both harvest parameters into the resource.cfg and use them in escript?
This way you have all the logic in one spot.
E.g:
veryuniqueresource.cfg
Global {
Landtile/objtype definitions
Maybe only very special objtypes to have full control where this can be harvest
}
Region somewhere
{
// The following leads to one harvest success every 2hours per coordinate
UnitsPerArea 12
SecondsPerRegrow 600
Range X y
// Read the following via escript as the two parameters for harvestresource
UnitCost 12
MaxAmount 1
}
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

Yes it's good try for "the mythril in Trinsic" but not good attempt for constraint and control all resources.
Preloading all parametres from the config is very good too. But my shard very big with many scripts and small online )))) Full server occupies 2.5gb RAM )) with all the features.
I can load this into the memory, but I don't like this idea ))))

Reading and parsing config from escript is very costly operation. If do it in script which very often used, it's very load processor

but it's my problem ))) I think up something )
Thank you! You help me very very great.
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Resources.cfg

Post by Turley »

If you are concerned about memory usage you should try PolCore(). internal (2);
Damn I really need to give it a better name...
This creates a memoryusage.log in the log folder, a CSV file basically.
It's just an estimation of the ram usage each component has. (On my shard its has around 500mb missing in this list of about 1.9gb according to 'top', most likely due to padding and alignment plus a few currently unknown stuff in memory)
There you will most likely see that the biggest part of the ram usage is due to objects. Configs and scripts have only very few MB in ram.
So I wouldn't think about how much such a cfg uses in ram.
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

Yes, you are right!
I will try this
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Resources.cfg

Post by Yukiko »

I have a question.
In the formula:
a=avail_units / n
if a> m
a=m
return a*n
What are the values n and m? They are not defined.
Alwir
New User
Posts: 27
Joined: Sat Aug 26, 2017 2:50 am

Re: Resources.cfg

Post by Alwir »

https://docs.polserver.com/pol099/fullf ... stResource

HarvestResource( resource, x, y, M, N, realm := _DEFAULT_REALM )
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Resources.cfg

Post by Yukiko »

The docs still don't explain what 'n' represents in the statement HarvestResource( resource, x, y, b, n, realm := _DEFAULT_REALM ). Does it represent the 'n'umber of things you'd like to harvest or what? And what about the 'm' in the equation above?
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Resources.cfg

Post by Turley »

n is the first parameter m the second.
Sorry I should have used the names how they are defined in the module and not how they are internally.
So b==n and n==m
Escript version of the Formular:
a=avail_units / b
if a> n
a=n
return a*b
Hope now it's clear what every parameter means
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Resources.cfg

Post by Yukiko »

I'm sorry Turley but maybe I'm not seeing it clearly. What exactly does n represent? Is it just some arbitrary random number that I plug in to the equation? I mean a is clearly defined as 'a'vailable units. I guess I'll ask it this way :If 'a' represents the word "available" what word does 'n' represent? Doesn't every variable represent some known or unknown quantity that has a name? Sorry I'm so ignorant about this.
Post Reply