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

3am me: So how do you feel about a character inviting their own character portrait to a tea party? =D

3pm me: //facepalms
I turned 17 two months ago and I feel like I've grown (personality-wise) more in this 1 year than all the 16 years I had lived combined.
Ugh, I may have been cumbersomely eventing a bunch of stuff I could have easily done changing the tileset "Passage (4 dir)" and "Ladder" options. Oops :D
I have no idea why some of the program "splash screen" always on top. E.g, RMMZ loading screen stuck on the top blocking anything I want to do until it fully loaded. What is even the purpose?
One of the secret places in the game.

Forum statistics

Threads
107,644
Messages
1,031,107
Members
139,766
Latest member
lincore
Top