conditional damage skill

zachb

Warper
Member
Joined
Sep 28, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMVXA
I am working on a skill that will take off 20% of the target's current hp. Just this alone is easy, but I also want to prevent this skill from working on certain enemies (like bosses). I have the following in the damage formula for the skill:

if !(b.isStateResist(42)); b.hp/5; end;

Where the skill checks if the target resists the state or not to prevent the skill from taking off 20% of the target's current hp if it resists. If the target does not resist the state (which in my case is state 42), then the target takes 20% damage of its current hp. Otherwise, the skill does no damage.

It is not working however, and I am not sure why. Any ideas? Using VXA
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
You say you use VXA, but that syntax looks like MV to me (no idea if it is, but it looks like common JS syntax).

You should try this instead:
Code:
b.state_resist?(42) ? 0 : b.hp/5
This does the same thing you wanted, but it's using the correct VXA check, and I shortened the code a bit.
 

zachb

Warper
Member
Joined
Sep 28, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Works great. Thank you. I had used other syntax before in vxa and it worked ok. But maybe not always? The other skill I used using this type of syntax was a skill that would kill you if your level was a multiple of 5.

if (b.level % 5 == 0); b.add_state(1); end;

And it seemed to work. However, if the target has a resistance to state 1 (death) would it cease to work? I have already tried b.setHp(0); instead of b.add_state(1); , but it doesn't work. Probably the syntax I am assuming?

So in VXA syntax I am thinking it would be
b.level % 5 == 0 ? b.setHp(0) : 0
But I tried that and it didn't work. b.add_state(1) works, but if the target has a state % rate of the death state failing, wouldn't it prevent the skill from working? I was thinking b.setHp(0) might bypass any sort of state % rate to the death state failing
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
Where do you get those code bits (b.setHP(0) and b.isStateResist(42))? You seem to be pulling out MV code, and that won't work in VXA, they use entirely different coding languages. Not talking about the if - end parts, those can work, I just like shorter syntax in damage formulas, since that box is very small. Just note that the damage formula expects a numeric value at the end, so if it doesn't get any, there might be issues.

In VXA, you would do something like this:
Code:
b.level % 5 == 0 ? b.hp : 0
This would simply take all HP the target has if it's level is a multiple of 5. You can also use b.mhp if you want the damage to be equal to the targets maximum HP instead (in case you want to show that damage value instead of the current HP).
I have no idea if it will work on targets with KO state resistance, though, never really tested that situation.
 

zachb

Warper
Member
Joined
Sep 28, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Okay. Thank you so much. I guess when researching damage formulas I accidentally found MV code and didn't know it at the time.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top