Damage formula that returns healing? I need help.

TKarver13

Villager
Member
Joined
Jul 24, 2020
Messages
10
Reaction score
6
First Language
English
Primarily Uses
RMMV
Using RMMV, No Plugins, Vanilla AF.

So I'm trying to write a formula that returns healing to (a) after dealing damage to (b) , the healing is mathed based on the damage inflicted. (Essentially a life-steal, but.. not)

Something like this, correct me please:

Type: HP Damage

((a.atk + a.mat) - b.mdf) ; (gainHp((a.atk + a.mat) - b.mdf)/9)
For this Example: My atk is 24, Mat is 6, Target has 10 Mdef

So math SHOULD look like this
((24 + 6) - 10) ; (gainHp((24 + 6) - 10)/9)

Which returns
20 ; gainHp 2

For some reason it does 0 dmg? and it also doesnt heal.... what did I do wrong
 
Last edited:

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
place your dmg value into a variable, then call it at the end of your skill. You also didn't specify a target to gain hp


dmg = (a.atk + a.mat) - b.mdf; a.gainHp(dmg / 9); dmg;


you also may want to round the healing value to fix some ugly number displays
 

TKarver13

Villager
Member
Joined
Jul 24, 2020
Messages
10
Reaction score
6
First Language
English
Primarily Uses
RMMV
place your dmg value into a variable, then call it at the end of your skill. You also didn't specify a target to gain hp


dmg = (a.atk + a.mat) - b.mdf; a.gainHp(dmg / 9); dmg;


you also may want to round the healing value to fix some ugly number displays
Thank You!
This worked!

dmg = (a.atk + a.mat) - b.mdf; a.gainHp(Math.ceil(dmg / 9)); dmg;

Returned 20 damage, 3 healing

aghh im so happy.
A side question, is there a way to define a variable using damage? Like var= (a.atk + a.mat) ?
 

TKarver13

Villager
Member
Joined
Jul 24, 2020
Messages
10
Reaction score
6
First Language
English
Primarily Uses
RMMV
Another Problem I'm having::
I'm using this script

JavaScript:
var party = $gameParty.battleMembers().filter(function(member) { return member.isAlive() });
party.forEach(function(member) {
var action = new Game_Action(member, true)
action.setSkill(skillId)
return action.apply(member) })
BattleManager.refreshStatus();
party.forEach(function(member) { member.startDamagePopup() })
SceneManager._scene._logWindow.startAction(BattleManager.actor(), action, party)
SceneManager._scene._logWindow.clear()

its returning as ' action is not defined '
Yes I copy pasted from another site, I cheated, but I didn't see any need to change anything, as "var action =" looks like its being defined..
This is a dummy comment event meant to cast a skill on each party member, once its called. I'm also noticing a (skillId) that has no value, I can't find how to define that either
 

AdeptusUK

Veteran
Veteran
Joined
May 27, 2020
Messages
63
Reaction score
15
First Language
English
Primarily Uses
RMMV
Replace skillid with the number of the skill you want to use in the database. Currently the script is looking for a skillid of 'skillid' which won't exist (unless you've not.posted the whole script)
 

Latest Threads

Latest Posts

Latest Profile Posts

Chilling out while toodling around someone's painstaking Minecraft recreation of Disneyland. It is mind-boggling and probably as close as I'll ever be to going.
>Testing with fonts change.
>Tries installing a plugin. Doesn't work.
>Tries changing the plugin commands. Doesn't work.
>Tries installing another plugin. Doesn't work.
>Changes a few more plugin commands. Doesn't work.
>Goes directly to the gamefont file and changes the src. Works.

YYEEEAAAAHHHAAAA

Perseverance is key, bois and girls.
What Reviews say on RPG Maker MZ?
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

Forum statistics

Threads
107,806
Messages
1,032,349
Members
139,952
Latest member
4kWave
Top