Like the title says I'd like to create a drain spell that only heals for a percentage of the damage it does and haven't found a script that does it. Can this be done? I'll be very thankful if you could help me.
Drain only recovers a % of the damage it does
RGSS3 Script RequestsThis isn't the most accurate way to go about things, but it is simple.
dmg = \damage formula\ ; a.hp += [dmg * \float\, 0].max.to_i ; dmg
Where \damage formula\ is... the damage formula, and \float\ is a decimal representing the percentage of health to be restored.
For example, if we had a skill that absorbs 20% health from the damage it deals..
dmg = \damage formula\ ; a.hp += [dmg * \float\, 0].max.to_i ; dmg
Where \damage formula\ is... the damage formula, and \float\ is a decimal representing the percentage of health to be restored.
For example, if we had a skill that absorbs 20% health from the damage it deals..
Code:
dmg = a.atk * 12 - b.def * 7 ; a.hp += [dmg * 0.2, 0].max.to_i ; dmg
Sorry to say, I tried your formula and it does no damage. Are you sure it's correct?
I'm positive it is. The second example works fine if pasted into the damage formula box of a skill.
Could you provide an example of what you did? Any minor error in syntax can return nil values.
It's ok, someone at rmc provided me with a script that does exactly what I wanted, thanks and sorry for the trouble 🙂
Just dropped in to say that Rinobi's way will not be accurate at all.
The damage formula is the first thing which is evaluated in the damage calculations.
If you only base your drain formula on that one, your drain formula will NOT count in the following (pretty important) factors:
- Elemental resistances
- Damage type resistances (magic/physical)
- Damage variance
- Critical damage rate
- Guard rate
- Recovery rate (if it's a healing skill)
- Any other changes coming from custom scripts
So, a skill could do 0 damage on a target (due to the target being immune to physical damage, for example), yet the user will gain HP regardless based on the drain formula.
And yeah, Yanfly made a script which does exactly this (and others made some too).
The damage formula is the first thing which is evaluated in the damage calculations.
If you only base your drain formula on that one, your drain formula will NOT count in the following (pretty important) factors:
- Elemental resistances
- Damage type resistances (magic/physical)
- Damage variance
- Critical damage rate
- Guard rate
- Recovery rate (if it's a healing skill)
- Any other changes coming from custom scripts
So, a skill could do 0 damage on a target (due to the target being immune to physical damage, for example), yet the user will gain HP regardless based on the drain formula.
And yeah, Yanfly made a script which does exactly this (and others made some too).
Original thread: https://forums.rpgmakerweb.com/threads/drain-only-recovers-a-of-the-damage-it-does.64336/