[SOLVED]Multiple conditions Damage Formula, and dual effect in Formula (Damage + add state)

Status
Not open for further replies.

MonsieurClayton

Villager
Member
Joined
Sep 18, 2015
Messages
6
Reaction score
1
First Language
French
Primarily Uses
Hello :)
First of all, sorry for broken english, I'll try to make as less gramatical errors as possible.

I'm working on a skill, but I'm not even sure I can manage to do it with skill formulas.

This spell, let's call it "Arcane Shock", deals damage depending on specific states ("Arcane Stain") applied to the target and applies those specific states if they are not already applied. There are two levels to those states ("Arcane Stain I & Arcane Stain II).

Here is how I'd like it to go :
> Player Character casts "Arcane Shock"
> Check if "Arcane Stain II" is applied to the enemy, if it is : deals 125% damage, refresh "Arcane Stain II"
> If not, check if "Arcane Stain I" is applied to the enemy, if it is : deals 100% damage, applies "Arcane Stain II", removes "Arcane Stain I"
> If not, deals 75% damage, applies "Arcane Stain I"
I tried this formula :
b.isStateAffected(39) ? a.mat * 1.25 : b.isStateAffcted(31) ? a.mat ; b.addState(39) : a.mat * 0.75 ; b.addState(31)
State 31 is "Arcane Stain I" and State 39 is "Arcane Stain II"

I have it specified in "Arcane Stain II" Notes that "Arcane Stain I" is removed when "Arcane Stain II" is applied thanks to Yanfly's Buff & State Core.
I also have <State 39 Turns: +1> in the Skill Note, in order to refresh "Arcane Stain II".

I have two issues with my formula :

Multi-conditions does not seems to work, at least not written like this, as the skill does 0 damage 100% of the time.
Meaning, this, alone, does not work :
b.isStateAffected(40) ? a.mat * 1.25 : b.isStateAffcted(31) ? a.mat : a.mat * 0.75
I don't know how I can deal damage AND add a state at the same time (with formula command) Even with a simple
100; b.addstate(X)
It should deal 100 damage and add state X to the enemy, right ? But it does not work, I guess I just do not know how I should write it.

What should I write in my damage formula for my skill to work as intended ?

Thanks in advance to anyone who could help in any way :D

EDIT : I know I could workaround the damage buff of the spell by making the spell one specific Element and the States changing the weakness to this Element but as I'm learning to do whatever I can with formulas, I'd be happy to find a way to do this with formulas :)
Also, I've no idea yet how to deal with the "Stack" mechanic without formulas (Adding "Arcane Stain I" if no state is already applied and "Arcane Stain II" if "Arcane Stain I" is already applied).

EDIT 2: Yeah, of course I noticed the Thread about formulas 10 minutes after creating this one...Sorry, Maths hurt my brain.
 
Last edited:

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
468
Reaction score
202
First Language
English
Primarily Uses
RMMV
Multi-conditions does not seems to work, at least not written like this, as the skill does 0 damage 100% of the time.
Meaning, this, alone, does not work :

Code:
b.isStateAffected(40) ? a.mat * 1.25 : b.isStateAffcted(31) ? a.mat : a.mat * 0.75
This is correct syntax, but you have a typo there - missing an e in isStateAffected. That's why it's not working.

This might be a place where if statements are easier to understand than if expressions, though. Something like this (I've split it into multiple lines so you can see what's happening, obviously you'd need to put it all on one line for the damage formula box though):

JavaScript:
var r = 1;
if(b.isStateAffected(39)) {
    r = 1.25;
} else if(b.isStateAffected(31)) {
    b.removeState(31);
    b.addState(39);
} else {
    b.addState(31);
    r = 0.75;
}
a.mat * r
 

MonsieurClayton

Villager
Member
Joined
Sep 18, 2015
Messages
6
Reaction score
1
First Language
French
Primarily Uses
Omg that stupid typo... I was persuaded my syntax was wrong.
Thank you very much

And thanks a lot for the more complex code, I can do way more with that !

I'm novice in Java (and simply coding), so I learn through this kind of things.

Thank you again :D
 

HumanNinjaToo

The Cheerful Pessimist
Veteran
Joined
Apr 18, 2013
Messages
1,105
Reaction score
510
First Language
English
Primarily Uses
RMMV
I was just going to add that
100; b.addstate(X)
won't work because the damage has to go last, so it needs to be
b.addState(Id); 100

Also, not sure if just a typo in your post, but you gotta check your caps, your state was not capitalized.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
468
Reaction score
202
First Language
English
Primarily Uses
RMMV
This is JavaScript, not Java, for the record. They are two completely different programming languages.
 

MonsieurClayton

Villager
Member
Joined
Sep 18, 2015
Messages
6
Reaction score
1
First Language
French
Primarily Uses
Hmm I tried with both caps and without, I think. But I must have made a typo somewhere else, I guess.

I'm happy that my understanding of the syntax was correct, tho. I have to be more careful with those pesky little mistakes.

JavaScript, not Java. Noted. As I said, 100% novice :p

Thank you all again :D
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,357
Reaction score
1,518
First Language
English
Primarily Uses
RMMV
Rather than using different states, if you have Buffs & States Core you could use state counters instead to just stack the one state.
 

MonsieurClayton

Villager
Member
Joined
Sep 18, 2015
Messages
6
Reaction score
1
First Language
French
Primarily Uses
Oh I didn't know you could do that.
Anyway, the result is almost the same, right ?

I also have a skill that lenghtens the duration of "Arcane Stain II", I guess that if I did what you said I could extend the duration of the skill, and keep the extended duration when stacking more...
At this point it's more of a balancing issue, but I already have a solution if I have to do that, then :)

Thank you.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,357
Reaction score
1,518
First Language
English
Primarily Uses
RMMV
Yeah, if you already have it working by no means reinvent the wheel here, just pointing out an alternative for future development reference. :)
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
468
Reaction score
202
First Language
English
Primarily Uses
RMMV
There is also a HimeWorks plugin that does something similar to what you wanted - it would allow you to set it up so that applying stain I if it's already applied automatically upgrades it to stain II. I think it was called Placeholder States but I can't quite remember, there are two or three plugins that could be the one I'm thinking of.

But yeah, if you've got it working, no need to reinvent the wheel.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,991
Reaction score
4,739
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

Unifying the code bases across MV and MZ for Haxe!
Anyone who uses Yanfly's Gab Window plugin: are there any features it lacks that you wish it had?
Working on Zelda-like tileset. Should be greatly refined. And tonight extra pave tiles, outward corners, abyss and water...
Is it possible to move posts from the in-progress project forum to completed games? I think I need to message a mod but a bit worried about bothering them

Forum statistics

Threads
100,545
Messages
977,078
Members
132,081
Latest member
Kaezyelnatz
Top