Party Mana Heal on MP Cost

fireflyege

So I was thinking how to make a state which heals MP to the party except user when the user spends MP for a spell. Henceforth, I used Yanfly's Reverence code as a reference. This code in particular.

<Custom Action Start Effect>
// Get the user's current HP.
user._reverenceMp = user.mp;
</Custom Action Start Effect>

<Custom Initiate Effect>
// Check if the stored MP value exists.
if (user._reverenceMp !== undefined) {
// If it does, calculate the difference between the user's initial MP and the user's current MP after the cost.
var difference = user._reverenceMp - user.mp;
// Check if the difference is greater than zero...
if (difference > 0) {
// If it is, calculate the amount of HP healed.
var hp = Math.ceil(difference * 20.00);
// Make the user gain that HP.
user.gainHp(hp);
// Play a damage popup.
user.startDamagePopup();
// Clear the damage results.
user.clearResult();
}
user._reverenceMp = undefined;
}
</Custom Initiate Effect>

It works beyond perfect so I and the good people willing to help with the issue made these changes.

<Custom Action Start Effect>
// Get the user's current HP.
user._reverenceMp = user.mp;
</Custom Action Start Effect>

<Custom Initiate Effect>
// Check if the stored MP value exists.
if (user._reverenceMp !== undefined) {
// If it does, calculate the difference between the user's initial MP and the user's current MP after the cost.
var difference = user._reverenceMp - user.mp;
// Check if the difference is greater than zero...
if (difference > 0) {
for(i=0; i < \$gameParty.size()){
if(user.actorId() !== \$gameParty.members().actorId()){
var member = \$gameParty.members();
var mp = Math.ceil(difference * 0.25);
member.gainMp(mp);
member.startDamagePopup();
member.clearResult();
}
}
}
}
</Custom Initiate Effect>

After that point, it goes out of control. The only thing I did was adding the party member count but it gives a Syntax Error. I have been facing this issue for a long time before I finally decided to post here so if anyone would help me with the issue I would be glad.

Trihan

Speedy Scripter
You've set "member" to \$gameParty.members(); in other words, you've stored an array in a variable that's intended to have a single GameActor object.

Wavelength

Edge of Eternity
There are at least a few things wrong, and there may be even more beyond what I describe below.

for(i=0; i < \$gameParty.size()){
You should have a third statement in a for loop to determine what happens each cycle. Usually, i++. Also, I don't think "size" is a method, but rather a property; you might need to remove the parentheses.
Change to:
Code:
``for(i=0; i < \$gameParty.size(); i++){``
and if that doesn't work, remove the parentheses from size()

if(user.actorId() !== \$gameParty.members().actorId()){
actorId is not a property of members(); therefore you can't use that kind of dot notation. I believe members() is an array so you might have meant \$gameParty.members() at position "i", as you can see in the following code block:
Change to:
Code:
``if(user.actorId() !== \$gameParty.members()[i].actorId()){``
(Also, I'm not sure whether actorId is a method; I think it's just a property, so you might need to remove the parentheses after it)

var member = \$gameParty.members();

You've set a variable equal to an array in this line, and then later on you're trying to treat it like a GameBattler (like @Trihan mentioned).
Change to:
Code:
``var member = \$gameParty.members()[i];``

Hopefully this will get you there, but there may be other errors in your scripting as well. Not 100% sure.

Last edited:

Trihan

Speedy Scripter
@Wavelength You'll have to format your change suggestion as a code block, or the square brackets will be treated like BBCode and not show because the forum thinks they were tags.

Chemical Engineer, Game Developer, Using BlinkBoy'
Code:
``\$gameParty.members().actorId()``
should be

Code:
``\$gameParty.members()[i].actorId()``
Inside your for loop all the .members() call should include an index next to it because it returns an array and what you want to use is the member inside the index denoted by the current iteration of "i"

Wavelength

Edge of Eternity
@Wavelength You'll have to format your change suggestion as a code block, or the square brackets will be treated like BBCode and not show because the forum thinks they were tags.
Thanks, Trihan!! Forgot about this - I hate how the forum software does that even when there's no matching end tag to denote that it's formatting!!

I've updated my post accordingly.

It could be the reason for some of the apparent flaws in the original post's tags, too, since those are in Spoilers not Code Blocks. Nevertheless there were still a couple other mistakes as I pointed out, so hopefully that will get us closer to a valid tag.

Chemical Engineer, Game Developer, Using BlinkBoy'
(Also, I'm not sure whether actorId is a method; I think it's just a property, so you might need to remove the parentheses after it)
Both .actorId() and ._actorId should work... ._actorId is a property while .actorId is a function which returns ._actorId

Trihan

Speedy Scripter
It's generally advised to use the wrapper functions instead of the internal variables (the ones beginning with an underscore) as this is a fundamental principle of encapsulation.

Latest Profile Posts

How do you cure sleep problem? It has been 7 months and it's 3 AM now..
Darn you, Seals! Why do you gotta be so cute when on land?
So dragonbones getting laggy xD
I even removed the fingers armatures.

Have to remake this guy after crashing ( corrupted file).

Although limited to only this shop for room decorations, I like this aspect for previewing items.