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

Stream will be live shortly! I will be beginning a play-through of Resident Evil 4! Feel free to drop by!

1st iteration on castle interior in Tiled.
I've started up Pillars of Eternity. It's interesting how the game does a "select choice" cutscene using still image art for dramatic flair. I wonder if that might work for my RPGMaker project.
The self-righteous indignation of family when you expect them to pay back money you've leant to them never ceases to amaze me.
Gamedev for relaxing? yes or no?

Forum statistics

Threads
107,743
Messages
1,031,785
Members
139,882
Latest member
Wasteland_Hero
Top