Ability That Damages Actor TP and Restores Enemy HP?

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Hey it's me again with hopefully an easy fix question :)

TP in my game is called Friendship (gee, I wonder what franchise my game is based on....) and I have an enemy (Changelings) who feed off of Friendship. What I want is for their ability 'Drain Friendship' to deal damage to the target character's TP, but then restore the Changeling's HP by the amount of damage dealt to the TP. I've looked around but can't seem to find anything that would quite help me figure this one out.

Is it possible?
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Thanks :) How would I set up the damage formula for this?

I tried "8 + a.mat; a.gainHp(a.mat)" but the ability says "there was no effect" in battle when used. I probably wrote it wrong?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,431
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
that is because of the way the damage formula is eval'd - the damage is always the last number processed, and in your case the last processed number is zero - because the function a.gainHP() has no return value.

try
a.gainHP(a.mat);8+a.mat
instead.

There might be other errors as well (I don't know how that plugin works) but that is one that would be a problem in any damage formula.
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Thanks for the response :) I entered that in and it still says 'there was no effect' :(
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,431
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
has the target already lost HP at that moment? Because you can't gain HP above the maximum.
If that's not it then it might be something with the script, and then I can't help you.
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Yeah they'd already lost HP.

I'll see if it's maybe a case of changing where the script is in the order.

EDIT: I moved the script and now the ability does deal TP damage, but it's always 1 damage instead of the number it should be (8 + a.mat should equal 33 in this instance) and there's no defenses involved. The enemy doesn't appear to be recovering HP either unless it simply doesn't show the popup for that.

EDIT #2: After some searching I am trying this formula:
c = a.mat - b.mdf; if c>0; b.tp -= c; a.gainhp(c); else; 5; end
(With the <tp damage> note tag from Hime's script)
The TP damage works except the popup always says '1' and the battle log also always says 'lost 1 TP' even if they actually lost more. I also can't tell if the enemy is gaining the HP or not because there's no popup for that at all even though there usually is for HP restore.
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
There is no gainhp or gainHP method in the Game_Battler class, nor in it's parent or child classes.
This triggers an error that otherwise would crash your game, but because the damage formula evaluation calls a rescue method on it, it will simply return 0 for the damage in case of errors in the formula.
You probably get 1 damage at the end because you use a minimum damage script that sets the minimum damage to 1? Just guessing here.

In any case, those non-existent methods should be hp += value instead. So, a.hp += a.mat, for example.
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Ah, thank you! I got the base of that formula from another place so I just assumed the gainHp thing was correct. Changed it for your method and the numbers and damage are now displaying properly except the enemy HP gain is still not appearing as floating numbers so I'm not sure if it either isn't actually gaining HP or if for some reason it just won't display the popups. I'm using MogHunters' Damage Popups btw.

I also noticed the actual TP damage isn't right. The damage should be equal to C, but the enemy has a magic stat of 24 and the defender I tested had mdf of 14, meaning roughly 10 TP damage should have happened (with 20% variance) but instead it was 37-40 :S

Here's the updated formula: c = a.mat - b.mdf; if c>0; b.tp -= c; a.hp += c; else; 0; end
Again with Hime's <tp damage> notetag.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,431
Reaction score
7,711
First Language
German
Primarily Uses
RMMV
there is an automatic TP-gain by damage, all actors and enemies gain TP when they are damaged.
Additionally TP has its own charge parameters that modify all TP-gain and TP-damage, so that can also modify the numbers.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
If you use that <tp damage> note-tag, you don't have to decrease the target's tp manually in the damage formula, it will happen automatically.
What you do there now is this:
- Decrease the target's TP by X amount in the damage formula.
- The result of the damage calculation also decreases the target's TP because of that note-tag.
Get rid of that b.tp -= value part, and the TP damage should be closer to what you would expect from your damage formula.

Note that the damage can still be modified by resistances (physical/magical/elemental), by guarding, by critical triggers and by variance, and these are not included in the HP recover part in your damage formula. You can't foresee these in the damage formula, unless you make the variance 0, disable criticals, and set the element to a type without any resistance available in your game (probably "None" or "Normal Attack"). Even if you do this, the target can still reduce the damage by guarding.

The HP recover popups probably won't appear without manually triggering them, since most of these battle popup scripts won't really check what's in your damage formula (and they really can't check for all possible things the users could put there, so that's understandable). No idea how to trigger them manually, though, I never used that popup script before.

@Andar
If he used that note-tag, the damage type is set to TP Damage, and the TP gain from damage only happens from HP damage, so the target's TP should not change from that method, only from the damage itself (and from the damage formula if there is something changing the TP there).
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
I removed the b.tp-=value part and now the target is somehow losing 200+ TP XD I think the boss is rebelling against being nerfed.

Shame about the health popups but understandable as you said, and as long as it IS actually draining health it doesn't matter too much.

This skill's proving to be a little too complicated. I might have to just forgo the faithfulness to source material and have it be simple health drain instead. Hmm, would it be easier to make it a health drain ability that also deals damage to TP? Would a formula for that work better?
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
This is the last thing in your damage formula:
a.hp += c
This will add the calculated value to the user's HP and returns the current HP of the user, which will be the result of the damage calculation, because that's the last thing that happens in your damage formula.

c = a.mat - b.mdf; a.hp += c if c > 0; c
That is how it should be instead.
 

Psykai

Veteran
Veteran
Joined
Dec 8, 2017
Messages
104
Reaction score
4
First Language
English
Primarily Uses
RMVXA
Thanks :) This is what I ended up with in the end:
c = a.mat - b.mdf; a.hp += c; if c > 0; c; else; 5; end
It SEEMS to be working but thought I'd post it to make sure I did it right. The damage appears to be more like what I'd expect now and I assume if it was ever reduced below 0 then the 'else 5' would kick in?
 

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top