Diminishing Mana Return

Status
Not open for further replies.

D-D-D-Dan

Veteran
Veteran
Joined
Mar 30, 2019
Messages
52
Reaction score
5
First Language
English
Primarily Uses
RMMV
Hey there, I have a issue setting something up.
I have my combat system setup that you start every encounter with 0 mana.
Basic skills generate mana and abilites spend it.
Maximum Mana is capped at 150. The regen part all works perfectly fine.

Now I would like to add Diminishing Return to my mana generation.
something like ( (max_mana - current_mana) / x) * variable
What I want to achieve is if Actor A has over X amount of mana generated the next basic skill will generate less mana
and if Actor A drops below X amount of mana generation is back to base value.

I figured i could do this via damage formula but i think thats a bust.
So i thought I would do it via common event.
But i cant seem to get it working.
Anyone have a Idea?
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,488
Reaction score
4,958
First Language
English
Primarily Uses
RMVXA
I've done a lot of diminishing returns stuff, but I'm unclear about what kind of curve you are trying to implement. Could you give several examples (the more the better) of how much mana a character has, how much base mana a skill should regen, and what the final value should be based on the combination of the two? If I can understand exactly what you want to do, I'm confident I can give you either a formula or a common event that would accomplish it.
 

D-D-D-Dan

Veteran
Veteran
Joined
Mar 30, 2019
Messages
52
Reaction score
5
First Language
English
Primarily Uses
RMMV
Awesome!
At the start of combat all actors have 0 mana.
All classes have a set of several basic attacks that generate 4 mana each while guard generates 12 (This is all working).

I want there to be deminishing return on generation once a actor reaches 16 mana.

I hope you understand what i mean :kaoswt:
 
Last edited:

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
435
Reaction score
175
First Language
english
Primarily Uses
RMMV
ive seen this done easy with passive states and TP Charge Rate.
but not with MP because only has MP Cost reduction.
there a reason you cant swap the 2?
 

D-D-D-Dan

Veteran
Veteran
Joined
Mar 30, 2019
Messages
52
Reaction score
5
First Language
English
Primarily Uses
RMMV
I use TP for a kind of FF styled desperation/trance system
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,488
Reaction score
4,958
First Language
English
Primarily Uses
RMVXA
I was hoping you would give me a flow of the mana curve (e.g. how sharply it should fall off at certain levels beyond 16), but I can make a curve for you that may work. Beyond 16 mana, you'd want the mana gain to fall off, but without ever reaching zero, so the idea is to divide the threshold (16 mana) by the amount of mana the character has, and a constant (like 20) can be added to both sides to make the effect less punishing if desired.

I would suggest the formula:
  • If Mana <= 16: Base Value
  • If Mana > 16: Base Value * ((16 + 20) / (Mana + 20))
In a skill formula, I believe that would be: BASEMANAGAIN * (16 + 20) / (Math.max(16, a.mp) + 20)
(Replace BASEMANAGAIN with the base value that the actor would gain when below 16 mana)

To create an entire formula, you would use: c = BASEMANAGAIN * (16 + 20) / (Math.max(16, a.mp) + 20); a.gainMp(Math.ceil(c)); DAMAGEFORMULA

You can increase or decrease the "20" values to your liking - just make sure that you change both 20's to the same number, or the elegance of the curve will be lost.

(Edited this post to reflect the correct use of the gainMp function, and also to round up in order to avoid decimal MP gains. The formula given here should work now.)
 
Last edited:

D-D-D-Dan

Veteran
Veteran
Joined
Mar 30, 2019
Messages
52
Reaction score
5
First Language
English
Primarily Uses
RMMV
alright ill give it a go and report back.
Thanks!

Edit: So I gave it a try and it doesnt seem to do anything.
Maybe you can give the formula a look to see if i made a oopsie?
a.gainMp(Math.floor(a.mmp * 0.03)); c = 4 * (16 + 20) / (Math.max(16, a.mp) + 20); a.mp += c; 4 + (a.atk * 0.5) - (b.def * 0.25)

I tried with and without var i tried moving the first 2 parts around and for good measure i changed a.mp to a.mmp but the output never changed always got dmg + 4 mana gain
 
Last edited:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,488
Reaction score
4,958
First Language
English
Primarily Uses
RMVXA
Get rid of a.gainMp(Math.floor(a.mmp * 0.03)); and if that also doesn't work then try adding var before the first c. If that also doesn't work, let me know and I'll play around with it in-engine tomorrow.
 
Last edited:

D-D-D-Dan

Veteran
Veteran
Joined
Mar 30, 2019
Messages
52
Reaction score
5
First Language
English
Primarily Uses
RMMV
ah i hate to do this to you :kaocry:
var c = 4 * (16 + 20) / (Math.max(16, a.mp) + 20); a.mp += c; 4 + (a.atk * 0.5) - (b.def * 0.25)
is the formula i now put in and it does not generate or deduct any mana
tried it with and without the var
 

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
435
Reaction score
175
First Language
english
Primarily Uses
RMMV
you could try
a.gainMP(Math.ceil((a.mmp-a.mp)/45)); formula
 

D-D-D-Dan

Veteran
Veteran
Joined
Mar 30, 2019
Messages
52
Reaction score
5
First Language
English
Primarily Uses
RMMV
a.gainMP(Math.ceil((a.mmp-a.mp)/45)); formula
throws out the error that a.gainMP is not a function

But thanks for helping :D

I also tried (Math.floor(a.mmp - a.mp) /4) * 0.12;
which doesnt crash the game but it also does nothing

wait why does it throw out that one as error but my other one works?
time to investigate

Edit:
Found the culprit it was the capital P causing the issue!
It works (to a extent). The first reduction starts at 16 reducing from 4 to 3
next reduction kicks in at 60 reducing it to 2

Edit 2: how would this work with guard though?
 
Last edited:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,488
Reaction score
4,958
First Language
English
Primarily Uses
RMVXA
I went ahead and tried my formula in MV and got the same thing you're seeing - no MP gain at all. Playing around with things a little, I realized my mistake was the use of directly setting a.mp using the += operator (an approach that would work in Ace and most libraries thanks to setter methods). Instead, it's apparently necessary to use the gainMp function.

After testing using that function, everything works as I'd want it to, except that you can gain a decimal amount of MP - obviously we don't want that, so I added the Math.ceil function to round up (allowing the skill to always gain at least 1 MP).

As such, I've edited my original post to include a formula that should definitely work for you in-game. Let me know if it still doesn't!

Example of a damage formula that will work in-game:
c = 4 * (16 + 20) / (Math.max(16, a.mp) + 20); a.gainMp(Math.ceil(c)); 100 + a.mat * 2 - b.mdf * 2
 
Last edited:

D-D-D-Dan

Veteran
Veteran
Joined
Mar 30, 2019
Messages
52
Reaction score
5
First Language
English
Primarily Uses
RMMV
It works! But the diminishing return doesnt start until 30 what value do i have to change? (sorry havent slept yet...)

and any idea how i can add this or something like this to guard?
either im missing something or you cant add a formula to guard without it
crashing. I assume ill have to do this via js or event somehow?

oh and thanks a ton!
 
Last edited:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,488
Reaction score
4,958
First Language
English
Primarily Uses
RMVXA
It works! But the diminishing return doesnt start until 30 what value do i have to change? (sorry havent slept yet...)
Change both instances of the number 16.

and any idea how i can add this or something like this to guard?

either im missing something or you cant add a formula to guard without it
crashing. I assume ill have to do this via js or event somehow?
I would think you could just change the Guard skill in your database. You can make it an "MP Recover" (instead of "None") type skill and simply type the formula into the formula box; for example:
12 * (30 + 20) / (Math.max(30, a.mp) + 20)

Admittedly I've never tried adding a formula to Guard in MV, so there may be some kind of hard-coded behavior that causes issues when you try this, but I wouldn't expect that to be the case. (If it is, though, what I'd probably do is look into a plugin that removes the Guard command, and make its functionality into an ordinary free Skill instead, increasing MP and applying the Guard state.)

oh and thanks a ton!
You're very welcome!
 

D-D-D-Dan

Veteran
Veteran
Joined
Mar 30, 2019
Messages
52
Reaction score
5
First Language
English
Primarily Uses
RMMV
Cut them all down to 6 and it Works fantastic! Your the best!
 
Last edited:

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
435
Reaction score
175
First Language
english
Primarily Uses
RMMV
have guard skill use a MP recovery damage formula using
Math.ceil((a.mmp-a.mp)/12.5)
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,277
Reaction score
11,673
First Language
English
Primarily Uses
RMVXA
[closed]IgnoreMe[/closed]
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Hello folks, I'm an old member deciding to reenter the forum. Greetings :D
When a parent (of a less than adult aged child) is like
"Oh, I'm like a friend to my child. We're friends."
I'm like
"Oh, that kid's gonna suck...."
Baby tiger gets a belly rub! ^.^
Ami
--- Friendship System ---

(F.Mage and F.Healer's FP is 100)
F.Mage: We did it! we can beat the monster easily!
F.Healer: With the Friendship System,we got stronger thanks to you F.Mage (Hugging)
F.Mage: (Blushing) Ahh...don't say like that. we are Best Friend Forever.
(In Distand)
M.Mage: They look happy...
M.Healer: Yeah...always like that...

Forum statistics

Threads
103,287
Messages
998,596
Members
134,798
Latest member
evilperm
Top