[Solved (More or Less)] Skill That Deals Recoil Damage

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
As per recommendation, I have decided to make separate threads for each skill type.

*decides to copy & paste*

I have a skill a character uses called "Leap of Faith" that is a 50% success rate that deals double damage. That is as far as I have gotten, however, because what I want for it is to also deal a certain about of damage to the user as well. It's a reckless sort of attack, like a... Body Slam in DQ. That sort of thing. Recoil damage, I believe is what I'm trying to explain.

Any help would be greatly appreciated, thank you~

~ Dragon
 

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
This one is a bit of a tricky one without plugins, so I'll use Yanfly's Damage Core to create it as such

<damage formula>
var recoil = 0.5;
if (Math.random() <= recoil){
value = (a.atk * 4 - b.def * 2) * 2;
user.gainHp(-value * 0.2);
} else {
value = a.atk * 4 - b.def * 2;
user.gainHp(-value * 0.2);
}
</damage formula>
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
Are you using any plugins? Because you'll likely need something like Yanfly's Skill Core for something like this.

http://yanfly.moe/2015/10/13/yep-8-skill-core/

If you're not familiar with how to use plugins, you may want to take some time to learn about them. For now, add the following to the notebox in the Body Slam skill once the plugin is installed:

<Post-Damage Eval>
user.gainHp(Math.floor(-value * 0.25));
user.startDamagePopup();
user.clearResult();
</Post-Damage Eval>

Roughly speaking, this code applies after the user inflicts damage on the target. value refers to the amount of damage the attack inflicted. Math.floor rounds down to the nearest integer (eliminating the possibly of decimals). The number that determines recoil damage is -value * 0.25; if you want a different equation, that's what you want to change.
 

DragonRose35

Scaleything
Veteran
Joined
May 31, 2017
Messages
51
Reaction score
0
First Language
English
Primarily Uses
RMMV
I am unfortunately extremely unfamiliar with plugins and how they work and I am unsure that I would even be able to to begin to understand them. But thank you, for this. I will try it and see if this works.

~ Dragon
 

Countyoungblood

Sleeping Dragon
Veteran
Joined
Dec 9, 2017
Messages
622
Reaction score
403
First Language
English
Primarily Uses
RMVXA
Would this do it?

a.mhp -= (damage formula); damage formula
 

Junane

Veteran
Veteran
Joined
Feb 10, 2018
Messages
86
Reaction score
10
First Language
English
Primarily Uses
RMMV
Would this do it?

a.mhp -= (damage formula); damage formula
Your formula will reduce the actor's maximum HP, not the current HP and also does not account for variance.
 

Countyoungblood

Sleeping Dragon
Veteran
Joined
Dec 9, 2017
Messages
622
Reaction score
403
First Language
English
Primarily Uses
RMVXA
Your formula will reduce the actor's maximum HP, not the current HP and also does not account for variance.
oh,well let me take off the M.

a.hp -= (damage formula); damage formula

seems like a lot of extra work just to add variance but hey maybe OP cares about it.

edit: variance.

did a bit of research and found a pretty easy answer.

a.hp -= (Random.new.rand(1..10) * 0.1 * recoil formula); damage formula

this generates a random number from 1 to 10 then multiplies it by .1 (turns it to a percentage value) then gets multiplied by whatever you want recoil to come from. after that deal damage as you normally would.

if you want 1 to 100 add a couple of zeros. if you want a different variance range change the the X's in rand(x..x) you dont need a plugin just a formula. this was a good challenge for my first week of learning how to use the damage formula. very fun.
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

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
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top