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

I miss collaborations, but I don't know how to find someone to make face parts just to share them with others, and even though I don't like writing or music, I can't trust anyone with writing on my game because it has themes that are easy to mess up, and music needs a clear tone and scenes.
People donating to me for my upcoming birthday so I can pay my team a little. Such angels, I'm so happy. T uT I smile so much my face hurts. Good souls in this world.
Playing Ragnarok Online again is very nostalgic. The last time I played it was 20 years ago, when I was ten-twelve old.
My first mmorpg.^^
A beloved family member passed away due to complication to combat COVID and diabetes. Rest in peace Grandma.

Forum statistics

Threads
105,571
Messages
1,014,716
Members
137,245
Latest member
dashstop
Top