Hello. I managed to recieve some great help the last time I posted a problem so I'm going to try here again. I'm using Yanfly's Battle Plugins and had a question regarding the <Post-Damage Eval> function. I'm trying to create a skill where if you hit an enemy's elemental weakness (Defined by if an enemy has less than 100% resistance to an element) with a skill; It will then add a state to the foe using the post damage eval code. Problem is I don't exactly know how or even if that is possible to write the code to do that. For example if I have a fire spell. I cast it on a rat; the rat is weak to it, deals normal additional damage and also inflicts burn state. That's what I'm trying to do in a nutshell. Hope that makes sense.
Yanfly Battle Java Assistance
Javascript/Plugin SupportTry something like this in the skill notetag:
<Post-Damage Eval>
if (target.elementRate(fireID) > 1) {
target.addState(stateID);
}
</Post-Damage Eval>
Keep in mind that element rates in the RPG Maker code uses 1 as no weakness or resistance to an element. So 0.5 would be resistance, while 1.5 would be a weakness.
<Post-Damage Eval>
if (target.elementRate(fireID) > 1) {
target.addState(stateID);
}
</Post-Damage Eval>
Keep in mind that element rates in the RPG Maker code uses 1 as no weakness or resistance to an element. So 0.5 would be resistance, while 1.5 would be a weakness.
Thanks for the help but that line of code crashed my game for some reason...
Did it give an error? Maybe I should have clarified before, but FireID should be replaced by the ID number of the fire element, and StateID should be replaced by the ID number of the state applied.
If that didn't help, what kind of error did you get exactly?
If that didn't help, what kind of error did you get exactly?
Yeah I figured out that Fire ID and State ID meant the ID's for both. I did that. My error was "Syntax Error: Unexpected Token {". I don't get what's happening when that happens. I can only the assume the code either conflicted with a plugin or something else maybe.
Usually, that means there's a typo somewhere in the code. What exactly does your notetag say right now? Ideally, copy and paste the whole notetag.
<Post-Damage Eval>
if (target.elementRate(5) > 1) {
target.addState(8);
}
</Post-Damage Eval>
if (target.elementRate(5) > 1) {
target.addState(8);
}
</Post-Damage Eval>
Okay I just tested it without the code and I think it might be a coding error on my end. I can't figure out from where though.
Maybe your plugins need to be rearranged. Can you show an image of your plugin list?
Sorry about the amount of pictures but it was the only way to fit them all on here.
Some of the plugins are out of order, and that may be causing issues. Some of the problems include:
Base Parameter Control needed to make Class Base Parameters work correctly, should go directly above
Battle Status Window out of place, should be between Battle Select Cursor and Buffs & States Core
Event Encounter Aid out of place, should be near the bottom with utility plugins
Item Plugins should be this order: Item Core, Item Disassemble, Item Categories, Item Picture Images, Item Requirements, rest as is
I'm guessing a few more plugins are below what is shown, so make sure the rest are in the right order. Yanfly's plugin page should show the correct order.
Base Parameter Control needed to make Class Base Parameters work correctly, should go directly above
Battle Status Window out of place, should be between Battle Select Cursor and Buffs & States Core
Event Encounter Aid out of place, should be near the bottom with utility plugins
Item Plugins should be this order: Item Core, Item Disassemble, Item Categories, Item Picture Images, Item Requirements, rest as is
I'm guessing a few more plugins are below what is shown, so make sure the rest are in the right order. Yanfly's plugin page should show the correct order.
Okay. Well rearanged a few of them. This project is pretty old and as a result some of the plugins got shuffled about. Made the changes and am going to try again.
Well I tried again and got the same error. Maybe I should post all the code I'm using for the skill to clarify a few things.
<Cooldown: 2>
<Cooldown Steps: 10>
<Row Only: 4>
<Cast Animation: 0>
<Select Conditions>
Row 1 Only
</Select Conditions>
<target action>
motion swing: user
animation 122: user, mirror
wait: 20
motion spell: user
wait for animation
action animation
wait: 60
action effect
wait for animation
<\target action>
<Post-Damage Eval>
if (target.elementRate(5) > 1) {
target.addState(8);
}
</Post-Damage Eval>
<Custom Requirement>
if (user.isStateAffected(45)) {
value = true;
} else {
value = false;
}
</Custom Requirement>
<Cooldown: 2>
<Cooldown Steps: 10>
<Row Only: 4>
<Cast Animation: 0>
<Select Conditions>
Row 1 Only
</Select Conditions>
<target action>
motion swing: user
animation 122: user, mirror
wait: 20
motion spell: user
wait for animation
action animation
wait: 60
action effect
wait for animation
<\target action>
<Post-Damage Eval>
if (target.elementRate(5) > 1) {
target.addState(8);
}
</Post-Damage Eval>
<Custom Requirement>
if (user.isStateAffected(45)) {
value = true;
} else {
value = false;
}
</Custom Requirement>
You closed the target action sequence using <\target action> whereas is should be </target action>. Maybe that's the problem in the code. Make the change and try again.
On topic question, is this how you would get it to add the state if a random number check passes? (so it checks for both that and the weakness)
// Set the bonus success rate.
var bonusStateRate = 0.50;
// Make a random number check to see if bonus passes...
if (Math.random() < bonusStateRate) {
// If Number passes and the enemy is weak to the element, give the state
if (target.elementRate(fireID) > 1) {
target.addState(stateID); }
}
// Set the bonus success rate.
var bonusStateRate = 0.50;
// Make a random number check to see if bonus passes...
if (Math.random() < bonusStateRate) {
// If Number passes and the enemy is weak to the element, give the state
if (target.elementRate(fireID) > 1) {
target.addState(stateID); }
}
@AdamSakuru yes that's how you would do it.
You could shorten the code for convenience if you wanted to, although its not necessary.
You could shorten the code for convenience if you wanted to, although its not necessary.
Code:
var bonusStateRate = 0.50;
if (Math.random() < bonusStateRate && target.elementRate(fireID) > 1) target.addState(stateID);
Oh my gosh thank you Naveed. Haha I just checked and I think that solved my issue.
Well now I have a new problem though. The burn state that got added doesn't go down in turns for some reason... Is there a way to make it function as though a normal state was afflicted. What's happening is that the state that was added via the code won't go away after the usual amount of turns happens. I don't understand why.
Original thread: https://forums.rpgmakerweb.com/threads/yanfly-battle-java-assistance.80286/


