How do I inflict damage on an enemy whilst also simultaneously damaging the wielder?

SuspensionXD

Warper
Member
Joined
Dec 28, 2019
Messages
3
Reaction score
1
First Language
English
Primarily Uses
RMMV
Greetings,

I'm currently creating what should be somewhat of an intuitive weapon known as the double edged sword for various classes in my RPG Maker MV project, but I can't seem to get the intended effect that is proposed in the title. How do I go about making it so that the weapon inflicts double damage to the enemy but as a negative drawback, damages the wielder for the same amount? Any help would be much appreciated!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,434
Reaction score
7,713
First Language
German
Primarily Uses
RMMV
damage formula coding - there is a pinned topic on how to use javascript inside the damage formula for additional effects
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,635
Reaction score
5,116
First Language
English
Primarily Uses
RMVXA
The easiest way would be in the damage formula - for example, you can do something like a.hp -= 50; (damage formula) to deal 50 damage to the attacker, or even a.hp -= (formula based on stats); (damage formula) to scale the the attacker's self-damage up based on, say, his strength stat.

The most "true" way to do damage, allowing things like self-crits and variance to take effect, would be to use Yanfly's Target Core and push the attacker into the targets array using a notetag.
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,531
Reaction score
1,424
First Language
English
Primarily Uses
RMMV
There's another way, one that I like to use, that involves action sequences (also requires a yanfly plugin)

Code:
<Target Action>
</Target Action>
<Whole Action>
perform action
action animation: targets
action animation: user
wait for animation
action effect: targets
action effect: user
death break
perform finish
</Whole Action>
Or if you want a different animation to play on the user, replace "action animation: user" with "animation n: user" where "n" is the animation id you want to play on them. Or remove that line entirely if you want no animation to play on them.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
If you want this to be specific to a weapon, rather than a skill, I'd suggest the following two plugins:
You can then try the following:
  1. On the States tab, make a new state, call it whatever you like, and put this in its notebox:
    Code:
    <Custom Confirm Effect>
    if (value > 0) {
      value *= 2;
      user.gainHp(-value);
    }
    </Custom Confirm Effect>
    I.e. just before the skill formula is applied to the target, multiply outgoing damage by 2 and subtract that amount from the user's current HP. (value is negative for healing.) If you want more conditions, e.g. physical hit skills only (not magical or certain hit), you can add stuff to the if condition:
    Code:
    <Custom Confirm Effect>
    if (value > 0 && this.isPhysical()) {
      value *= 2;
      user.gainHp(-value);
    }
    </Custom Confirm Effect>

  2. Then, on the Weapons tab, find your weapon and put this in its notebox:
    Code:
    <Passive State: x>
    Replace x with the ID of the state you created in step 1. This'll attach the state to the weapon. :kaophew:

  3. Save your project and test! :kaopride:

One more, slightly technical note: I've used gainHp for modifying HP, partly because hp is a read-only property, and partly because gainHp performs a refresh and interfaces with the action result/damage popup stuff. :kaoswt:
 

SuspensionXD

Warper
Member
Joined
Dec 28, 2019
Messages
3
Reaction score
1
First Language
English
Primarily Uses
RMMV
If you want this to be specific to a weapon, rather than a skill, I'd suggest the following two plugins:
You can then try the following:
  1. On the States tab, make a new state, call it whatever you like, and put this in its notebox:
    Code:
    <Custom Confirm Effect>
    if (value > 0) {
    value *= 2;
    user.gainHp(-value);
    }
    </Custom Confirm Effect>
    I.e. just before the skill formula is applied to the target, multiply outgoing damage by 2 and subtract that amount from the user's current HP. (value is negative for healing.) If you want more conditions, e.g. physical hit skills only (not magical or certain hit), you can add stuff to the if condition:
    Code:
    <Custom Confirm Effect>
    if (value > 0 && this.isPhysical()) {
    value *= 2;
    user.gainHp(-value);
    }
    </Custom Confirm Effect>

  2. Then, on the Weapons tab, find your weapon and put this in its notebox:
    Code:
    <Passive State: x>
    Replace x with the ID of the state you created in step 1. This'll attach the state to the weapon. :kaophew:

  3. Save your project and test! :kaopride:

One more, slightly technical note: I've used gainHp for modifying HP, partly because hp is a read-only property, and partly because gainHp performs a refresh and interfaces with the action result/damage popup stuff. :kaoswt:
I've tried this and it works as intended! Thank you so much. On an off topic remark, it would seem as if this has broken one of my troop's basic attacks. I now get "this.battle(...).setup weapon animation is not a function" as an error. Do you happen to know how to resolve this?
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,118
Reaction score
1,526
First Language
EN
Primarily Uses
RMMZ
I've tried this and it works as intended! Thank you so much. On an off topic remark, it would seem as if this has broken one of my troop's basic attacks. I now get "this.battle(...).setup weapon animation is not a function" as an error. Do you happen to know how to resolve this?
Are you using any other plugins? The load order (order of the list in the Plugin Manager) can cause compatibility issues. Yanfly's plugins, for example, should be loaded in the order listed here:
You can simply click+drag plugins in the Plugin Manager to rearrange their order. Also, be sure to save your project before testing, otherwise Plugin Manager changes will not be seen during the test. :)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,540
Members
137,834
Latest member
EverNoir
Top