Yanfly Battle Java Assistance

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
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.
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
Try 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.
 

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
Thanks for the help but that line of code crashed my game for some reason...
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
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?
 

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
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.
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
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.
 

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
<Post-Damage Eval>

if (target.elementRate(5) > 1) {

target.addState(8);

}

</Post-Damage Eval>
 

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
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.
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
Maybe your plugins need to be rearranged. Can you show an image of your plugin list?
 

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
Sorry about the amount of pictures but it was the only way to fit them all on here.
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
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.
 

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
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.
 

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
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>
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
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.
 

AdamSakuru

[Null_Value]
Veteran
Joined
Mar 14, 2014
Messages
314
Reaction score
171
First Language
English
Primarily Uses
N/A
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); }
}
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
146
First Language
English
Primarily Uses
RMMV
@AdamSakuru yes that's how you would do it.

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);
 

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
Oh my gosh thank you Naveed. Haha I just checked and I think that solved my issue.
 

RPG Samurai

Veteran
Veteran
Joined
May 16, 2014
Messages
31
Reaction score
1
First Language
English
Primarily Uses
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.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top