Weapon that has a chance to also hurt you.

As the title says, I want to make a weapon that has a small chance to also deal damage to the character its equipped to when attacking. At the moment the only way I could think to do this is by having the weapon call a common event every time its attacked with, but is there an easier way to do this?

This is my first post, so if it's in the wrong place, sorry.
Is there a reason not to use a common event? Unless there are a lot of weapons like this, but they all have different side effects.
The easiest way to use this is to use Yanfly's Auto Passive States and Buffs & States Core, both free plugins.

You'd have the weapon give a passive state, then in that state put this (this example is if you want a 10% chance to take 25 damage):
Code:
<Custom Establish Effect>
if (Math.random()<0.1)
    user.gainHp(-25);
</Custom Establish Effect>

Is there a reason not to use a common event?
Doing things with common events in skills can be kinda wonky. For one thing, they run after the skill has finished, which can create a weird effect (you do your attack, hurt the enemy, go back to your place in formation, then take damage).

It also doesn't have any native way to refer to the actor that used the skill, so you'd have to do something like cause the skill to apply a placeholder state to the user, then in the event loop through the party to look for someone with that state. Then check to see if they're actually wielding this specific weapon, apply the damage, remove the state.

Additionally, even though the OP said it, there isn't a way to attach a common event to a weapon to execute when it's attacked with. You'd have to put this adding a state and calling the common event on every freaking skill in your game that uses weapons.

It's generally more (and in this case way more) convoluted than other options.
Code:
Code:
<Custom Establish Effect>
if (Math.random()<0.1)
    user.gainHp(-25);
</Custom Establish Effect>
This works, but I'd suggest a check to ensure that it actually is an attack, otherwise it may activate when healing an ally (unless that's your intention?).

Code:
<Custom Establish Effect>
if (Math.random()<0.1 && this.isHpEffect() && value >= 0)

    user.gainHp(-25);

</Custom Establish Effect>
Doing things with common events in skills can be kinda wonky. For one thing, they run after the skill has finished, which can create a weird effect (you do your attack, hurt the enemy, go back to your place in formation, then take damage).

It also doesn't have any native way to refer to the actor that used the skill, so you'd have to do something like cause the skill to apply a placeholder state to the user, then in the event loop through the party to look for someone with that state. Then check to see if they're actually wielding this specific weapon, apply the damage, remove the state.

Additionally, even though the OP said it, there isn't a way to attach a common event to a weapon to execute when it's attacked with. You'd have to put this adding a state and calling the common event on every freaking skill in your game that uses weapons.

It's generally more (and in this case way more) convoluted than other options.

Assuming it only needs to work for one weapon, it shouldn't be all that complicated. I don't see a problem with it executing after the attack, unless you want the actor's death to stop the attack, or for aesthetic reasons.

You don't really need to mess with states, since you can set a conditional branch to check who is wielding the weapon. If it's a weapon exclusive to one user, you can just check if that actor is using the weapon.

And if you don't want to clutter your common events, you can build a custom attack skill and use the Weapon Skill plugin.

I'm not saying this is the most elegant approach, but for one weapon, particularly one wielded by one actor, it might be the easiest.
I don't see a problem with it executing after the attack, unless you want the actor's death to stop the attack, or for aesthetic reasons.
That's a pretty big aesthetic - I think most people would find it very odd-looking to see a cursed weapon drain your energy several seconds after you used it 😛
You don't really need to mess with states, since you can set a conditional branch to check who is wielding the weapon. If it's a weapon exclusive to one user, you can just check if that actor is using the weapon.
That's making presumptions - the OP never said that only one actor could use this weapon.
And if you don't want to clutter your common events, you can build a custom attack skill and use the Weapon Skill plugin.
1 - by Weapon Skill I presume you mean Weapon Unleash. That's much more limiting than what I described, as it would then only work properly with that replaced attack. What happens to the rest of the skills the character knows? The curse doesn't function with them, or your whole character build is sealed with that weapon?

2 - If you're going to resort to a plugin, why not use my solution with two lines of code and it just works?
I'm not saying this is the most elegant approach, but for one weapon, particularly one wielded by one actor, it might be the easiest.
Again, you're presuming that it can only be wielded by one actor. And I don't know how you measure the easiness of downloading and installing the two plugins, but it's pretty darned easy...and the actual code for the passive state is fewer lines than you would need in a common event, never mind that there'd be no need to add the event call to multiple skills.

In any event, whether or not you could achieve it another way, your question was if there was a reason not to use a common event, and I gave several. I didn't say it was impossible to do, or that no one would want to do it that way, but there are definitely reasons that people, generically, would not want to.

This works, but I'd suggest a check to ensure that it actually is an attack
Thanks for the catch...I was pretty much falling asleep 😛
I didn't presume it would only be wielded by one character, I just imagined that as one possible scenario.

Weapon Skill is a plugin that comes free with MV.
Weapon Skill is a plugin that comes free with MV.
Ah, thanks. It has the exact same cons I described, though 😉
It just makes a different ID your "attack," it doesn't affect other skills. that can be a plus or a minus, depending on the desired behavior.

So anyway, installing two plugins and creating a custom status isn't EASIER, it's just a different solution. If the Common Event's behavior is already what I want, that's definitely easier. If I want a very specific behavior it doesn't do, then a plugin makes sense.

Original thread: https://forums.rpgmakerweb.com/threads/weapon-that-has-a-chance-to-also-hurt-you.143731/