Setting a minimum damage using percentages.

Status
Not open for further replies.

CWells

Storyteller/Artist
Veteran
Joined
Apr 22, 2013
Messages
731
Reaction score
40
First Language
English
Primarily Uses
Can you set a minimum damage using percent? If for example I don't want "No Damage" being the result from a large increase between defense and offense. Can it be done?
 

Euphoria

Veteran
Veteran
Joined
Jun 27, 2013
Messages
378
Reaction score
93
First Language
English
Primarily Uses
Kread-EX wrote this little code:

class RPG::UsableItem::Damage alias_method:)krx_one_ruid_eval, :eval) def eval(a, b, v) damage = krx_one_ruid_eval(a, b, v) damage = 1 if damage == 0 && sign == 1 damage endendShould work. And credit Kread-EX

It will set anything that does no damage to 1 damage.
 
Last edited by a moderator:

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
damage = [a.atk * 4 - b.def * 2, x].max 

Where "x" = the minimum damage you want that attack to ever do.

This can be useful for attacks that you want to do a minimum amount of damage, no matter what the enemy defense is.

For example: An attack that will NEVER do less than 100 damage:

damage = [a.atk * 4 - b.def * 2, 100].max 
 

CWells

Storyteller/Artist
Veteran
Joined
Apr 22, 2013
Messages
731
Reaction score
40
First Language
English
Primarily Uses
Well there goes two things I learned. Thanks. I'll take the script and note the formula trick.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,841
Reaction score
14,032
First Language
English
Primarily Uses
RMMV
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.

Latest Threads

Latest Profile Posts

Looking back at some sketches, and game design documents on my PC dated summer of 2015. I started development with the release of MZ, but in 2015, I felt a strong desire to make a game out of the blue. I remember feeling sad for no apparent reason, and all these ideas rushed into my head. Now that I think about it, since that day, everything has become easier to do on my PC . . . it’s very creepy.
Everything's going to be alright! We're all in this together. <3
Aaaaannd published my game's tech demo. :D

Feel free to download and play it. And give feedback!
Hey everyone, we know that the edit bar is missing. We're working on it. You can talk about it in the announcement here: https://forums.rpgmakerweb.com/index.php?threads/forum-errors-missing-edit-bar-etc.132715/
So, explain why we can no longer use BBC code or smilies in our posts? This sparks much sadness...

Forum statistics

Threads
107,794
Messages
1,032,263
Members
139,941
Latest member
Finley
Top