(Answered) Damage enemy and self?

Alright. So. More questions. I keep finding formulas that don't seem to do as I would expect (I am beginning to assume many of these are from older RPG Makers).


Skill that does damage to the target and you take 1/4 of that damage:


r = a.atk * 2 - b.def; a.hp -= r / 4; r


That's the formula I found. The -= part doesn't make much sense to me, but I went with it anyway. lol


I modified it for my own purposes to:


r = (100+((a.level/4)*(a.atk/10)))*2.25; a.hp -= r / 4; r


But whichever formula I use it won't deal damage to the actor using it. Damages the target just fine.


*edit* Answer thanks to Ogouka:


a.gainHp(Math.floor(-0.25*(damage_formula))); damage_formula
Poked around and found this that might work for you. Just so you know, there is a specific thread for damage formulae where you should probably be directing this particular type of question.


a.gainHp(Math.floor(-0.25*(damage_formula))); damage_formula
 
That worked perfectly. Also I did not know about that thread. I was just using the search option for whatever my question was. If I didn't see it within the first 2-3 pages of posts I would just make a post. lol


Thank you very much for the formula, as well as the knowledge of that thread. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/answered-damage-enemy-and-self.60102/