RMMV Trying to make a state: scaling defense bonus from barrier points

dreamless

Villager
Member
Joined
Jun 5, 2023
Messages
16
Reaction score
2
First Language
English
Primarily Uses
RMMV
I have Yanfly Buffs & States core, as well as Yanfly Absorption Barrier. I'm trying to make it so that, as long as any battler has barrier points, they receive a defense bonus = 1/2 their remaining barrier points. I have the following code:

Code:
<Custom Parameters>
def = $battler.barrierPoints() / 5;
</Custom Parameters>

on the Barrier State set by the plugin, but it doesn't seem to be doing anything. I'm pretty new to js so I think my code is definitely wrong but i'm not sure what to do from here
 

Shaz

Keeper of the Nuts
Global Mod
Joined
Mar 2, 2012
Messages
46,153
Reaction score
16,960
First Language
English
Primarily Uses
RMMV

I've moved this thread to Plugin Support. Thank you.

 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,262
Reaction score
9,250
First Language
English
Primarily Uses
RMMV
Code:
<Custom Parameters>
def = $battler.barrierPoints() / 5;
</Custom Parameters>
Here are the incorrect things:

1 - Custom Parameters is an Equip Core notetag, it won't work on a state

2 - Where did you see $battler ? The example script calls in the Absorption Barrier documentation just say battler

3 - That battler is just a placeholder, you need to replace it with a reference to an actual battler; e.g. the Buffs & States Core says you have access to user for the battler the state is on.

However, even with those things fixed, I don't know of any Yanfly notetag that will dynamically calculate its bonus, changing as your barrier points change.

You can look at @Eliaquim's Dynamic Parameters plugin, but I'm not sure those are dynamic in terms of recalculating during gameplay, or just dynamic meaning the bonus the state gives will be calculated in-game when it's applied, not predefined as one number in your notetag.

You might have to have code in your state that sees when you've taken damage, removes then reapplies the state that grants defense, so it can recalculate based on the new barrier points value.
 

dreamless

Villager
Member
Joined
Jun 5, 2023
Messages
16
Reaction score
2
First Language
English
Primarily Uses
RMMV
or just dynamic meaning the bonus the state gives will be calculated in-game when it's applied, not predefined as one number in your notetag.

After thinking about it, I think this behavior would work better in my game anyways. Do I instead use something like
Code:
<def Flat: +user.barrierpoints() / whatever>
?
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,262
Reaction score
9,250
First Language
English
Primarily Uses
RMMV
No. When a notetag gives you a spot to type something in (such as x), it is expecting you to provide a numeric value, or whatever it describes in the instructions.

Notetag fields can't take code unless they explicitly tell you they can.

I'm not familiar with a Yanfly notetag that can use code to give a parameter boost. You might try Quasi's Param Plus.
 

dreamless

Villager
Member
Joined
Jun 5, 2023
Messages
16
Reaction score
2
First Language
English
Primarily Uses
RMMV
Is it possible to use this bit of code from Buffs & States core:

Code:
  <Custom Apply Effect>
   code
   code
  </Custom Apply Effect>
  The code in between these notetags will run when the state is added onto
  a battler. The code will process after the state is actually applied.

to check the user's barrier points & then apply a bonus, just right there at the start of a battle? But if I did that, it would persist when the state goes away, wouldn't it?

It seems like the Eliaquim plugin might do what I'm looking for but I'm not sure how I'd call the user's barrier points in that plugin.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,262
Reaction score
9,250
First Language
English
Primarily Uses
RMMV
Is it possible to use this bit of code from Buffs & States core...to check the user's barrier points & then apply a bonus, just right there at the start of a battle?
It doesn't have anything inherently to do with the start of a battle, but yes, when the state is applied.

But if I did that, it would persist when the state goes away, wouldn't it?
Correct, you'd need to reverse it with a Custom Remove Effect.

It seems like the Eliaquim plugin might do what I'm looking for but I'm not sure how I'd call the user's barrier points in that plugin.
The exact same way you do anyplace else. Code is code :wink: The instructions say you can use "this" to refer to the actor in question.

So you'd make a template where def adds Math.round(this.barrierPoints()/5) then put the notetag for that template in your state.

The Math.round() is to keep it an integer.
 

Tray

Regular
Regular
Joined
Sep 7, 2018
Messages
50
Reaction score
10
First Language
English
Primarily Uses
RMMV
I don't know anywhere near as much as turan lol and he's helped me with quite a few skill set ups so id go with him on stuff.

but if you want the state to refresh bassed on new stats that change through battle you could also place it in a

<Custom Regenerate Effect>
code
</Custom Regenerate Effect>

tag and then iditify the user/caster with the origin. if you want it to track only the caster of the skill/spell. Also as turan pointed out user. will pull form the person the state is on. With that tag the code is refreshed each time the monster or player would gain hp, mp, tp from states so if your stats change between then it will then change the bonuse given to you
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,262
Reaction score
9,250
First Language
English
Primarily Uses
RMMV
tag and then iditify the user/caster with the origin.
I'm not sure what that means, origin is an included variable with Yanfly's Buffs & States Core.

With that tag the code is refreshed each time the monster or player would gain hp, mp, tp from states so if your stats change between then it will then change the bonuse given to you
That's not quite correct. That code will execute during the regeneration phase, which is a specific time at the end of the battler's turn.

So you could use that to remove and re-add a state at the end of that battler's turn, and keep it updated that way. But it won't do anything if they get hit or receive additional barriers during anyone else's actions.
 

Tray

Regular
Regular
Joined
Sep 7, 2018
Messages
50
Reaction score
10
First Language
English
Primarily Uses
RMMV
I did note it does when HP, MP, TP does lol

but you can combine them use the apply tag to apply what you want from the start , Then use a react effect to trigger when your hit, then use the Regenerate Effect to update at the end of the turn i dio this for several of my skills and it closely does what he is wanting. There is also turn effect and select effect that could also work in his case to update if the battler is selected then use a remove effect for when it is removed/wears off

Outside of that im not sure how much closer he could get to what he's looking for lol

as for origin. he is using buff and state core so lol but yes this is something added with that plugin though it does work in other plugin commands longs you have the buff and state core on. Using origin it tracks the character that cast/used/placed the skill so this way it wll always refere to the stats of that character

for example part of one of my skills (this is only a small segment as it is about 13 lines long and has 7 diffrent if statments)
var user = origin; var elementId = 7; var elementRate = target.elementRate(elementId); var damage = Math.floor(user.mat / 10) + 25;

that's part of the Regenerate Effect for my skill. i also have an apply effect then a react effect then i also have the extra drops which then have lines added to this lol. Then a remove effect to finish it off. As i said use them in combination xD Unfortunately I've never used the barrier plugin so cant do much for that but as i mentioned i did do this with the extra drops plugin and several others for that matter such as the DoT plugin and Element and instant cast plugins
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,262
Reaction score
9,250
First Language
English
Primarily Uses
RMMV
but you can combine them use the apply tag to apply what you want from the start , Then use a react effect to trigger when your hit, then use the Regenerate Effect to update at the end of the turn
I don't understand why you'd duplicate the effort/code. If you have a React Effect that does it every time the battler gets hit, there's nothing to update in the Regenerate.

var user = origin; var elementId = 7; var elementRate = target.elementRate(elementId); var damage = Math.floor(user.mat / 10) + 25;
That's not broken, but it's also not good practice. Since there's already a user variable, declaring a new one over it with the same name is considered bad practice because you could end up using the wrong variable name someplace and doing something you don't want.

I don't know how that's easier than just doing Math.floor(origin.mat/10)...
 

dreamless

Villager
Member
Joined
Jun 5, 2023
Messages
16
Reaction score
2
First Language
English
Primarily Uses
RMMV
Incidentally, Eliaquim's Dynamic Parameters do recalculate during gameplay, by default! So I'm using it that way after all. Thanks!
 

Tray

Regular
Regular
Joined
Sep 7, 2018
Messages
50
Reaction score
10
First Language
English
Primarily Uses
RMMV
Its not well its not fully duplicating in the react and regen effect. Though in the react effect it does check the magic attack. The react effects checks for other things that's not in the regen effect and does other things suck as recoil damage and animations that are different then in the regen. So yes there are 1 or 2 parts that are duplicated they each do very different things lol.

depending on what his game is like might need to update things at different parts. Like mine example there are things that happen at the start of the turn things that happen when monsters hit and then things that happen at the end of a turn so all 3 are needed + things to happen if state is removed lol

i was using as an example that he could mix and match the different tags to do different things to simulate the effect he's looking for.

as for the var user = origin

as i said I'm still learning haha to me if i finally get something to work i go with it and that is what i got when it finally started to work. Though i do see your point and I'm going to change that segment to as you suggested lol the original code i was just using user but that wasn't working as i wanted. It changed from the caster to the monster if the state was placed on the monster which i didn't want i always wanted it to referee to the caster. i also tried a. and b. every one always changed to the monster. Someone then suggest defining user that way and it worked soo that's why i stuck with it lol

I know there are things to avoid and such also documenting everything is good practice which i have started doing

---------------------------------------------------------------------------------------------------------

@op

glad to see you got it working xD
 
Last edited:

Latest Threads

Latest Profile Posts

Me: "Who the heck would play a game with no stakes, no enemies, and all you do is raise and breed bees?"
Later after playing it. - "Holy crap, I didn't know it was 1:30. Where'd my time go?"
The site is being slow and funky again. IS SOMEONE CRAFTING POEMS?!
So yeah, @TRIDIUM @TESTOSTERONE, I wuz like, "What do they mean by borderline and boundaries?"

And then, y'all know this girl?

actress1.png

alice_bikini.png

The clothes? They're just a, um, quick edit. :kaoswt:
I've uploaded the opening cutscene from my game to my channel. It basically introduces us to the first three characters, and what their relationships are:
Cosmic Inferno: Opening dialogue
I don't want to start a panic...but everyone, check the color of your milk!
IMG_20231002_082329.jpg

Forum statistics

Threads
135,021
Messages
1,253,018
Members
177,952
Latest member
gomeisan
Top