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)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

GOBBLE GOBBLE! Happy thanksgiving.
Oh no. That moment when you try to fix something you modified in your game, like, a year ago but didn't want to fix then, and you now have no idea what you even did. Me right now, trying to figure out why my gold window is over stretched?
LittlePIGGY wrote on atreyoray's profile.
Where are you TT^TT
We need ARP_InGameManual for MZ
Oh my gosh. Thank you, Macy's! Thank you so much! You have made me very happy!

Forum statistics

Threads
105,550
Messages
1,014,568
Members
137,225
Latest member
Eryndor
Top