I'm trying to make a skill where the enemy would lose 100 mana and the user would get 20% increased magical attack. The problem is, it doesn't seem to work. The formula for the attack is: a.addState(0021); 100 + a.mat * 4 - b.mdf * 2. The state is not added to the attack and the MP damage is random, not 100. I'm new to RPG Maker, if anyone could help me solve this issue I'd be grateful.
"addState" in damage formula doesn't seem to work
RPG Maker MV Support0021, with leading zeroes, is interpreted as an octal (base 8) number: you're telling it to add state ID 17 instead.Randomness is due to the skill's Variance setting, default 20%. It's just under the formula box, next to the "Critical Hits: Yes/No" option.
Try this instead:
a.addState(21); 100 + a.mat * 4 - b.mdf * 2Or, if you just want it to do 100 damage, ignoring the attacker's
mat param and the defender's mdf param, try this:a.addState(21); 100Regardless, be careful if the skill can be used by actors with an Auto Battle trait: Auto Battle evaluates the formula of each available skill to decide which one to use.
Welcome!
I had a whole thing typed up and caethyril posted it first 😛
I will add: it's better to use something like Yanfly's Skill Core and put this as a Post-Damage Eval notetag.
I had a whole thing typed up and caethyril posted it first 😛
I will add: it's better to use something like Yanfly's Skill Core and put this as a Post-Damage Eval notetag.
Well, I forgot to mention that I've tried both "0021" and "21". Both of them didn't work. The variance is at 0%.
I don't like using plugins, but if this won't work then I might consider using it.
The formula is only evaluated if the skill hits. The "to hit" roll depends on the Hit Type:

If that still doesn't work, consider sharing a screenshot of your skill page in the database.
- Physical Hit - checks attacker's Hit Rate, then defender's Evasion Rate.
- Magical Hit - checks defender's Magic Evasion.
- Certain Hit - always hits.

If that still doesn't work, consider sharing a screenshot of your skill page in the database.
I always had it set to "Certain hit". My character does hit the enemy, but the state is never applied.
Make sure that state 21 is the one you think it is. That you don't have anything on the actor that would give them State Resist against 21. Does the state have an icon so you'll know it's applied?
I didn't put an icon on it but in messages tab i put some random stuff so the game will tell me if it's applied. I don't recall the actor having anything that would make him resistant to state 21.
Huh...
Just to make sure: are you are using any plugins? If you have recently added, disabled, or removed any plugins, remember to save your project to apply Plugin Manager changes before testing.
For testing purposes, give the state an icon: that way you can be certain exactly when the state is present. Doing so will let you see if it's a problem with a State Resist trait or the actual state's traits.
addState ignores state rates, so I think State Resist is the only relevant trait here.Just to make sure: are you are using any plugins? If you have recently added, disabled, or removed any plugins, remember to save your project to apply Plugin Manager changes before testing.
For testing purposes, give the state an icon: that way you can be certain exactly when the state is present. Doing so will let you see if it's a problem with a State Resist trait or the actual state's traits.
- If the state is getting added, a screenshot of its page in the database might help.
- If the state is not getting added, check all trait sources for the user. For an actor, that means checking the Actor, Class, State, Weapon, and Armor database tabs. If any of those have a "State Resist: 21" trait then the actor will not be able to have that state.
So I chose the scope to be "the user", and somehow it worked. The state go applied to the actor, but the thing is the actor lost the MP, not the enemy.
Here's the state's page, for testing purposes i just put random stuff there.
I suggest again you look at the enemy in the database. Or make sure plugins are turned off for a test. There has to be something on the enemy that's preventing the state from applying.
Alright, now I've found out that the state is getting applied, but it seems to have no effect except from draining mana, what I mean is that it doesn't increase the user's magical attack. The actor even seemed to deal more damage without the state applied. Is there anything wrong with the state's traits?
Well, that's what you put on it. It says M.Attack * 20%. That will always be a smaller number than what you started with, that's how percentages work. If your enemy had MAT 10 and you put this state on, 20% of 10 is a MAT of 2.
If you want to increase a parameter, it has to be a percentage over 100%.
I'm very confused about the entire thread up until this point - the state wasn't being applied, but now it is? What changed?
I think the state was always being applied, but I didn't notice because the percentage was a low number and I thought that the game will tell me that the state was applied to the actor through the messages tab, but it turns out it didn't. I put a high number in the percentages and it seems to work now. Sorry, I'm new to RPG Maker and I'm confused about how some of the stuff work. Thank you for your time.
That's why I asked above if it had an icon for you to visually confirm that the state was on there.
I don't use the battle log, but I don't think the messages on the state get displayed if you hijack the process by calling addState() in the damage formula - they pop up when you use the Effects list on a skill.
Glad you got it working.
I don't use the battle log, but I don't think the messages on the state get displayed if you hijack the process by calling addState() in the damage formula - they pop up when you use the Effects list on a skill.
Glad you got it working.
addState does interface with the battler's action result. However, by default when logging the result (Window_BattleLog.prototype.displayActionResults), the engine typically only checks the target, not the subject. It checks the subject for damage popups, e.g. for Drain HP/MP, but not for added/removed states etc. That's probably why the state's "add" message didn't show up. I forgot about that, would've mentioned it earlier otherwise. 😴Original thread: https://forums.rpgmakerweb.com/threads/addstate-in-damage-formula-doesnt-seem-to-work.154775/