Page 1 of 1

Adding a min vaue to ActorResource interface

Posted: Tue Feb 01, 2011 6:19 pm
by yufra
This started when I noticed equilbrium sustains were once again broken by meditating (well not broken, but the sustain cost disappeared). The obvious long-term fix is to add a minimum value to the ActorResource interface and have equilibrium raise that instead of decreasing the maximum as other sustains do. I also have added min/max arguments to the defineResource function, which default to 0 and 100 as currently expected in ToME. Finally I changed all of the postUseTalent sustain changes to actually use incMax/incMin functions instead of directly changing the maximum value. This is because the incMax/incMin functions now bound the current value as well. I think this code was already somewhere else for the decreasing of minimum values, and I will look for it later to remove the redundancy. The first version of the patch can be found here: http://pastebin.com/EpqhHXK5.

I have tested that using Icy Skin from 0 equilibrium properly increases equilibrium to 30, and that you cannot then meditate below 30. After removing Icky Skin you can meditate back down to 0, so that seems to work well. The question is if there are any other bugs introduced in other resources, and I will be testing that soon.

Re: Adding a min vaue to ActorResource interface

Posted: Tue Feb 01, 2011 11:15 pm
by Marcotte
I thought that this was the intended behavior...

As for adding the min value, it would indeed be very handy for many uses. For instance, a module could want to allow a resource to go negative (like HP in a D&D module where death comes only at -10 HP).

Re: Adding a min vaue to ActorResource interface

Posted: Wed Feb 02, 2011 12:24 am
by yufra
Marcotte wrote:I thought that this was the intended behavior...
I assume you are talking about my description of testing Icy Skin. Yes, the test works as intended but if you try this out in beta19 you will see that it does not work that way.

Re: Adding a min vaue to ActorResource interface

Posted: Wed Feb 02, 2011 1:46 am
by Marcotte
yufra wrote:
Marcotte wrote:I thought that this was the intended behavior...
I assume you are talking about my description of testing Icy Skin. Yes, the test works as intended but if you try this out in beta19 you will see that it does not work that way.
No, I meant the say that I thought that the beta19 behavior (meditation being able to reset equilibrium to zero while sustains are active) is the intended behavior.

Whether that is true or not, is another question altogether.

Re: Adding a min vaue to ActorResource interface

Posted: Wed Feb 02, 2011 2:36 am
by yufra
Marcotte wrote: No, I meant the say that I thought that the beta19 behavior (meditation being able to reset equilibrium to zero while sustains are active) is the intended behavior.

Whether that is true or not, is another question altogether.
Ah, I understand now. No, you are not supposed to be able to go below the "sustained equilibrium." The sustained talents are supposed to carry some sort of permanent cost along with them, and in most cases they reduce the total amount of a resource you can have or have a constant resource drain. The behavior in beta19 that you describe is effectively "sustains for free", where you can set it, meditate and now be running around without any permanent cost but having a permanent bonus. Previous versions of this bug have been found and fixed, but it is broken again in beta19. The original post outlined a permanent way to fix this problem as well as extend the ActorResource interface to make such resources easier to handle in the future.

Re: Adding a min vaue to ActorResource interface

Posted: Thu Feb 03, 2011 1:33 am
by edge2054
This patch broke Paradox (caps it at 100) and I'm guessing it's doing the same to Equilibrium (though I haven't checked and it's much less of an issue).

Re: Adding a min vaue to ActorResource interface

Posted: Thu Feb 03, 2011 1:54 am
by Marcotte
I haven't tested it, but changing

Code: Select all

max = max or 100
by

Code: Select all

max = (max == nil) and 100 or max
should do the trick.

Re: Adding a min vaue to ActorResource interface

Posted: Thu Feb 03, 2011 4:15 am
by edge2054
Tested it. Seems to work good.

Re: Adding a min vaue to ActorResource interface

Posted: Thu Feb 03, 2011 7:01 am
by yufra
Thanks Marcotte, I sent the patch to DG.