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

Bored Code Guy
Veteran
Joined
Feb 16, 2016
Messages
481
Reaction score
227
First Language
English
Primarily Uses
RMMZ
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

Bored Code Guy
Veteran
Joined
Feb 16, 2016
Messages
481
Reaction score
227
First Language
English
Primarily Uses
RMMZ
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

Bored Code Guy
Veteran
Joined
Feb 16, 2016
Messages
481
Reaction score
227
First Language
English
Primarily Uses
RMMZ
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

Bored Code Guy
Veteran
Joined
Feb 16, 2016
Messages
481
Reaction score
227
First Language
English
Primarily Uses
RMMZ
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
Screenshot (43).png Screenshot (43).png
 

Attachments

  • Screenshot (44).png
    Screenshot (44).png
    625.3 KB · Views: 0
  • Screenshot (45).png
    Screenshot (45).png
    592.4 KB · Views: 0

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

Bored Code Guy
Veteran
Joined
Feb 16, 2016
Messages
481
Reaction score
227
First Language
English
Primarily Uses
RMMZ
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
149
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
172
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
149
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.
 

Latest Threads

Latest Posts

Latest Profile Posts

Made this sign for a you-know-what type of business, completely from scratch.
Gotta admit, i'm extremely proud of it.

image.png
After 7 months of really hard work and then 6 months of lazing around and procrastinating with adding the final touches my game is finally complete! Not bad considering that a year ago I didn't really even know about variables. Thanks to everyone who helped with questions and assets! Feels good to have a game under my belt! Ep2 (also self contained) may possibly come in the future!
I just made a breakthrough in my Battlecore problem where the Abort Battle command wouldn't work after using a Custom Action Sequence skill. It seems that Abort Battle can't be the last command in the event.
Before, the event was ordered (Dialogue -> Abort Battle). But having the message appear LAST fixed it.
(Abort Battle -> Dialogue)
"Does anyone remember the new year 2022? yeah, that was like yesterday. Wait, what do you mean by '2022 is almost over'?"
kuestsdynamisxp001.jpg


Just a glimpse of how Kuests Dynamis XP would look like.

Forum statistics

Threads
126,886
Messages
1,182,077
Members
166,675
Latest member
OPOPOP
Top