I would like to make a skill that, when used by an enemy on a given actor, adds an armor to the player's inventory - but only if the player doesn't already have that armor, as it's supposed to be unique. I have a feeling that the Yanfly Skill Core is the proper plugin for this, but I don't know exactly what code should go in the notetag. Any help would be greatly appreciated.
How to have skill give armor on hit?
RPG Maker MV Supportno need - this can be done with a common event attached to the skill.
the only drawback is that if that skill is used in the last turn of combat it will not happen due to combat ending before the common event is processed. you really need a plugin if that is a problem.
the only drawback is that if that skill is used in the last turn of combat it will not happen due to combat ending before the common event is processed. you really need a plugin if that is a problem.
If you have more yanfly plugins, then with the ItemCore plugin you can make the item unique by default, making it impossible to obtain a second copy. (Simply by baking the max 1)
Then make the damage formula:
Code:
$gameParty.gainItem($dataArmors[X], Y) ; Z
Replace X, Y and Z with:
X: Armor ID
Y: Amount (in this case 1)
Z: Your damage formula
I didn't test this, but it should work.
bad idea
there are two problems with this when using the damage formula:
1) the item will always be added, it completely ignores the test if the actor has the armor.
2) the item can be gained multiple times even if the skill is not used
the damage formula is always executed when the engine tries to find the best skill to use on special occasions, but only the damage itself is negated for the tests.
that is one of the disadvantages on using damage eval for other purposes than damage: the other purposes will happen even if the engine only tries to simulate the damage.
Problem 1: Could it not first check if there is already 1 armor and then just skip it if it is?
@Arctica theoretically yes
but that check is a bit long in javascript, and the damage formula in the editor has a limited length.
it can be done that way (and would partially solve the second problem as well), but only if that is a single case. If the OP wants to use this in several variants instead of as a single easter egg or special story case, then it becomes difficult handling things that way.
but that check is a bit long in javascript, and the damage formula in the editor has a limited length.
it can be done that way (and would partially solve the second problem as well), but only if that is a single case. If the OP wants to use this in several variants instead of as a single easter egg or special story case, then it becomes difficult handling things that way.
I've posted this before but one of the reasons it's a bad idea is this:
Stop Putting Mechanics in Damage Formulas - Yanfly.moe Wiki
Personally, I would use the <Custom Execution> notetag instead. Put in w/e conditionals you want etc... There's also the <Before Eval> and <After Eval> notetags as well. I assume you have Yanfly plugins, cuz that's where those notetags are from.
That problem shouldn't exist if the itemcore is used and the max for that item is set to 1. My solution was meant to be used in combination with the itemcore plugin.
I wouldn't know about problem 2, I'd have to put that at the test... But problem 1 should be prevented if the itemcore is used to make it an unique item.
---
I guess the skillcore can indeed be used to add the item, and still use the itemcore to make it a unique weapon. Then the damage formula wouldn't be needed at all. Well... Other than doing damage. 😛
Original thread: https://forums.rpgmakerweb.com/threads/how-to-have-skill-give-armor-on-hit.149142/