The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: lauronpegason on January 09, 2014, 04:11:19 PM

Title: [VX] Changing the Critical Hit Formula
Post by: lauronpegason on January 09, 2014, 04:11:19 PM
Hi, everyone. I have one request and one question. As specified in the subject of this topic, I'm using RPG Maker VX (not Ace). I'll start with the request.

Request: changing the critical hit damage formula, editing Mithran's Critical Skills v 1.4 Script.

I am using a script affecting critical strikes and I am trying to change a formula, taking the critical damage multiplier down from 2 to 1.5 (meaning that critical strikes should deal 50% increased damage/healing, not 100%).

The formula used in the script is the following:

Code: [Select]
@hp_damage *= 2 if @critical

What I want is to make the multiplier 1.5. I tried changing it to:

Code: [Select]
@hp_damage *= 1.5 if @critical

but that would often create decimals which cannot be shown properly. Decimals wouldn't make sense anyway, but I am also using SBS Battle System (yes, Tankentai), so the project simply has no way to show the output numbers. Having said all that, for what I can tell, the calculations seem correct. I tried to round up the results, but using:

Code: [Select]
@hp_damage *= (1.5).floor if @critical
Or "(1.5).ceil"

resulted as if I put in just 1 as a multiplier. I don't know that much about scripting, unfortunately, so I tried working my way around it, test after test, trying "== damage.floor*3/2", or "*= 3/2" and such. It seems that the closest I could get to was my first attempt: "*= 1.5 if @critical". I tried googling the language used to modify calculations and formulas, I couldn't find anything to solve this myself.

If you need it, here is the full Script: Mithran's Critical Skills v 1.4 (http://www.rpgmakervx.net/index.php?showtopic=6417). Thank you.


Question: is there a way to make something happen when dealing a critical strike?

This is not really a request, because I am not asking you guys to come up with a script to add this feature. If you thought about this, or know ways to make this work, even through common events, let me know. I have been googling and searching forums for scripts affecting critical strikes. All scripts won't go further than changing the critical strike chance, but that's not enough. Of course, if you can think of a simple script to add this feature, and if you believe that this feature is something people would use, be my guest and write the script down, but to be honest I see this as a lot of work.
Title: Re: [VX] Changing the Critical Hit Formula
Post by: modern algebra on January 09, 2014, 05:21:15 PM
For your request, you were very close. Try this:

Code: [Select]
@hp_damage = (@hp_damage * 1.5).floor
Title: Re: [VX] Changing the Critical Hit Formula
Post by: Mangomight on January 09, 2014, 05:31:13 PM
Try: 

@hp_damage += (@hp_damage / 2)) if @critical;

answer to the 2nd question, use an "if" statement somewhere in your code, like:

 if @critical { do something }
Title: Re: [VX] Changing the Critical Hit Formula
Post by: lauronpegason on January 09, 2014, 05:57:28 PM
Thanks a lot. Both of you!