Diminishing Mana Return

Status
Not open for further replies.

D-D-D-Dan

Veteran
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.

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
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
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

Last edited:

Tiamat-86

old jrpg gamer
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
I use TP for a kind of FF styled desperation/trance system

Wavelength

MSD Strong
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
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
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
ah i hate to do this to you
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
you could try
a.gainMP(Math.ceil((a.mmp-a.mp)/45)); formula

D-D-D-Dan

Veteran
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

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
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
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
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
Cut them all down to 6 and it Works fantastic! Your the best!

Last edited:

Tiamat-86

old jrpg gamer
have guard skill use a MP recovery damage formula using
Math.ceil((a.mmp-a.mp)/12.5)

Kes

Veteran
[closed]IgnoreMe[/closed]

Status
Not open for further replies.

Latest Profile Posts

"I, Giorno Giovanna, have a dream". In all seriousness, spatial BGM feature is now complete for my audio plugin.
Stream will be live shortly with some game development followed by the return of the Interactive Text Adventure after a short hiatus! Feel free to drop by!
Lately, I've taken to smashing random nouns/verbs together as insults. It's sort of amusing how many people don't really know how to respond to that. You bottle shaker!
Would be nice to pick color code that is not exclusively for message event
The Ace attorney series are so great games... But at the same time such a travesty.