Multiple damage formulas for one skill?

LeeOccleshaw

Stone Dragon Workshop
Veteran
Joined
Jun 9, 2015
Messages
155
Reaction score
82
First Language
English
Primarily Uses
I'm just wondering how or if it is even possible to write damage formulas like this:

if b has state(1) = damage formula 1.
if b has state(2) = damage formula 2.
if b has state(3) = damage formula 3.

and so on... 

I'm basically looking for a universal way of making many of my skills change effects depending on which state has been applied to the enemy beforehand.

Thanks forumers!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,650
Reaction score
13,263
First Language
English
Primarily Uses
RMMV
:D (you know why that's there!)


Depending on how many conditions and how long each formula is, you may be able to do this in the damage formula. If it's too long, you'll need to write a small script to add to Game_Battler that will calculate it for you based on your conditions, and then you make your damage formula call the script.

b.state?(1) ? damage formula 1 : b.state?(2) ? damage formula 2 : b.state?(3) ? damage formula 3 : 0
or

Code:
b.get_state_damage_formula
along with the Game_Battler code. I've never actually done this myself, so if I gave you code, it'd probably be wrong. However there ARE examples of people doing this - maybe if you check the pinned thread on the damage formula, or the "Ruby/RGSSx Questions that don't deserve their own thread" thread, you could find some good examples.
 

LeeOccleshaw

Stone Dragon Workshop
Veteran
Joined
Jun 9, 2015
Messages
155
Reaction score
82
First Language
English
Primarily Uses
:D (you know why that's there!)

Depending on how many conditions and how long each formula is, you may be able to do this in the damage formula. If it's too long, you'll need to write a small script to add to Game_Battler that will calculate it for you based on your conditions, and then you make your damage formula call the script.

b.state?(1) ? damage formula 1 : b.state?(2) ? damage formula 2 : b.state?(3) ? damage formula 3 : 0or
Code:
b.get_state_damage_formula
along with the Game_Battler code. I've never actually done this myself, so if I gave you code, it'd probably be wrong. However there ARE examples of people doing this - maybe if you check the pinned thread on the damage formula, or the "Ruby/RGSSx Questions that don't deserve their own thread" thread, you could find some good examples.
Thanks shquirrel! *throws you a nut*  :D

Thanks for typing it out for me like that - I was hoping you'd be able to string them together in such a way. I will need to go over the 100 character limit because of having 8 states, all linked together, but I believe this is doable with the script that I've already prepared in advance - Yanfly Lunatic Damage . It states that it can be used for that so it should hopefully work...

Thanks again.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,650
Reaction score
13,263
First Language
English
Primarily Uses
RMMV
Can you provide the damage formula for each state? There are other ways of writing it, and you may get away with something much shorter, depending on what you want the calculation to be.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,695
Reaction score
930
First Language
English
Primarily Uses
N/A
I was going to comment this, but by the time I went to submit it it was locked, so as late as I am,

You may want to make use of the ternary operator, which is basically a shorthand if statement usually used for if statements that have conditions and content that are very short. It works as so:

Code:
(condition) ? (when true) : (when false)
For example:

Code:
(b.state?(1)) ? (damage) : (b.state?(2)) ? (damage2) : (b.state?(3)) ? (damage3) : (none of the states are active)
 The more you add onto it, the more annoying it'll be to maintain, but I suppose it's an option for you. Good luck with that~

Note that this works in several programming languages, so learning it is useful.
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,316
Reaction score
816
First Language
English
I've done something similar to this, here's an example:

I put this little script into my database:

class Game_Battler < Game_BattlerBase
def cripple_attack(a,b )
c = 0
e = a.atk * 4.25 - b.def * 2
for d in [2,85,86,87]
if b.state?(d)
c += 1
end
end
return e if c==0
return e * 1.5 if c==1
return e * 2 if c==2
return e * 2.5 if c==3
return e * 3 if c==4
e * 3
end

end
and then in the damage formula, I put: a.cripple_attack(a,b )

What it does is check to see if the enemy has a state (specified by "d"), and increases damage to target for each one comes back as true.

Perhaps playing around with that a bit, you could come up with what you're aiming for.

PS - There is no space after the "b" in the formula, they keep turning into happy face emojis -.-
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,650
Reaction score
13,263
First Language
English
Primarily Uses
RMMV
PS - There is no space after the "b" in the formula, they keep turning into happy face emojis -.-
You avoid that by using the code tag :)
 
Last edited by a moderator:

LeeOccleshaw

Stone Dragon Workshop
Veteran
Joined
Jun 9, 2015
Messages
155
Reaction score
82
First Language
English
Primarily Uses
Thanks for the replies everyone, I'll have to have a play around and see what works best.

I don't have the exact formulas that I'll be using yet but it will pretty much be a standard attack formula ( a.atk * 2 - b.def * 1 ) that simply adds a specific state depending on if another specific state is already on the target.

For example:

You use Skill A which causes the target to become Blinded, then you use Skill B on the following turn, which causes the target to become Shocked. When both of these states are on the target, they essentially add a third state, in this case Startled.

All of the skills that give the initial states will need these tailored damage formulas to determine which third state to add to the target when they are hit by the second state.

Edit3: I'm attempting to add damage into the equation without success, apparently you must add the damage afterwards? When using this formula the states work together fine but no damage is added...

(b.state?(41)) ? (b.add_state(40) + b.add_state(42) + a.atk * 2 - b.def * 1) : (b.add_state(40))
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,650
Reaction score
13,263
First Language
English
Primarily Uses
RMMV
+ means addition, not "and do this as well"
 

LeeOccleshaw

Stone Dragon Workshop
Veteran
Joined
Jun 9, 2015
Messages
155
Reaction score
82
First Language
English
Primarily Uses
What means "and do this as well"? :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,650
Reaction score
13,263
First Language
English
Primarily Uses
RMMV
;


but I don't know if it can be used in that context - maybe if you keep the brackets, and you would also need a damage formula (even if it's 0) for the "else" part
 

Xypher

Veteran
Veteran
Joined
Apr 1, 2012
Messages
148
Reaction score
26
Primarily Uses
try this

Code:
unless b.state?(41); b.add_state(40);0;else;b.add_state(40);b.add_state(42);a.atk * 2 - b.def);end
 
Last edited by a moderator:

LeeOccleshaw

Stone Dragon Workshop
Veteran
Joined
Jun 9, 2015
Messages
155
Reaction score
82
First Language
English
Primarily Uses
Thanks for that Xypher, though, the problem has now developed into something else due to the character limit - at my thread here I'm looking for a way to add the basic state formula into that script (which should allow for me to write a regular damage formula alongside the state additions. Does anyone know how to write regular damage formulas into Yanfly's Lunatic Damage? It seems like my best option for keeping things as simple as possible, I just can't work out how to format the formula within a script rather than the damage formula box.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

is there a script call that return how much turn has passed in battle?
Does anyone find this hard to read?

Enjoying my weekend at home to stay Covid free. How is everyone else doing?
If you enjoy speed mapping for RPG Maker MV check out my YouTube Channel. My latest video includes custom made tiles which makes a simple map look dynamic!

Check out my short game Hikari's World! : Chapter I, on itch.io/games.

Forum statistics

Threads
100,603
Messages
977,725
Members
132,214
Latest member
qwertyben
Top