Skill Formula error

Midnight Kitty

Midnight
Veteran
Joined
Jun 18, 2013
Messages
129
Reaction score
14
First Language
English
Primarily Uses
RMMV
The game crashed when I tried to use a healing spell created as so
Code:
if isActor() 300 + (a.mat * v[44]); else 300 + (a.mat * 3) + a.hrg * a.mrg;
Does anybody know where I might have went wrong here?
 

Attachments

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
Is this enabled to target enemies? Just curious as you are checking if either the user or the target is an actor.

As for the formula, you can try this alternative:

if (b.isActor()){300 + (a.mat * v[44])} else {300 + (a.mat * 3) + a.hrg * a.mrg}
 

Landazar

Veteran
Veteran
Joined
Feb 16, 2018
Messages
179
Reaction score
56
First Language
Polish
Primarily Uses
RMMV
Try this

Code:
a.isActor() === true ? (300 + (a.mat * v[44])) : (300 + (a.mat * 3) + a.hrg * a.mrg)
 

Midnight Kitty

Midnight
Veteran
Joined
Jun 18, 2013
Messages
129
Reaction score
14
First Language
English
Primarily Uses
RMMV
Code:
if a.isActor() === true 300 + (a.mat * v[44]); else 300 + (a.mat * 3) + a.hrg * a.mrg;
I tried this fix but it threw up the same error message Landazar.
It is meant to target one chosen ally Junane but enemies can also use the spell.
It worked like this
Code:
if (b.isActor()) 300 + (a.mat * v[44]); else 300 + (a.mat * 3) + a.hrg * a.mrg;
isn't b.isActor meant to check the target though? so I am guessing it would be the same to just put a.isActor within the brackets.
 

Landazar

Veteran
Veteran
Joined
Feb 16, 2018
Messages
179
Reaction score
56
First Language
Polish
Primarily Uses
RMMV
I thought you pasted it directly... without if ... It must looks like that:

ps, a is for your party members in battle, b is for opponents...
 

Midnight Kitty

Midnight
Veteran
Joined
Jun 18, 2013
Messages
129
Reaction score
14
First Language
English
Primarily Uses
RMMV
ps, a is for your party members in battle, b is for opponents...
a stands for attacker and b for the defender so it would carry both ways.

I wasn't looking to find out what it looked like without if.
I noticed the mistake I made with your correction though.

Edit: I retried your method and it still threw up the error message.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Code:
if a.isActor() === true 300 + (a.mat * v[44]); else 300 + (a.mat * 3) + a.hrg * a.mrg;
It's just a syntax error, the conditional statement that is being evaluated needs to be enclosed with parenthesis. And a semi-colon isn't use to separate the 'if' from the 'else', curly braces are used for that.

You can find all of the information on how to construct these here, along with heaps of examples:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
True. If you only have 1 statement under the 'if' and only 1 statement under the 'else', the curly braces are optional. That's helpful in the damage formula because it's easier to read (and the box is so small)
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,523
Reaction score
1,415
First Language
English
Primarily Uses
RMMV
And a semi-colon isn't use to separate the 'if' from the 'else', curly braces are used for that.
In fairness, you only need the curly braces when the if/else statements are working with multiple lines.

Try this

Code:
a.isActor() === true ? (300 + (a.mat * v[44])) : (300 + (a.mat * 3) + a.hrg * a.mrg)
When checking whether something is true or false, you don't need the a.isActor() === true part since a.isActor() already returns true or false. a.isActor() === true is basically asking if (true === true).

---

All that aside, I think this is what the OP is looking for:

Code:
b.isActor() ? 300 + a.mat * v[44] : 300 + a.mat * 3 + a.hrg * a.mrg
Note that you don't put a semicolon at the end of a statement in the damage formula box when you want that statement's result to be used to calculate damage

Edit: Or replace b.isActor with a.isActor if it's supposed to check whether the caster is an actor rather than the target. I got the feeling it was mean to be based on the target though, so I changed the a to b.
 

Midnight Kitty

Midnight
Veteran
Joined
Jun 18, 2013
Messages
129
Reaction score
14
First Language
English
Primarily Uses
RMMV
Edit: Or replace b.isActor with a.isActor if it's supposed to check whether the caster is an actor rather than the target. I got the feeling it was mean to be based on the target though, so I changed the a to b.
It is meant to be based on the user of the spell. So a is what I was looking for.

All that aside, I think this is what the OP is looking for:
Code:
b.isActor() ? 300 + a.mat * v[44] : 300 + a.mat * 3 + a.hrg * a.mrg
I found and fixed the error with
Code:
if (a.isActor()) 500 + (a.mat * v[44]); else 500 + (a.mat * 3) + a.hrg * a.mrg
already.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top