How can I add state considering target's state rate in Yanfly action sequence?

chanfi

Villager
Member
Joined
Jun 18, 2016
Messages
8
Reaction score
0
First Language
korean
Primarily Uses
In Yanlfy Action Sequence,


I set the note like that below.


<target action>


action list ....


and


if (target.result().isHit() === true)


add state 23: target


end


</target action>


In this case, 'add state 23: target' is add state 23  unconditionally.


That is, this add state command ignores the target's state rate!


How can I add state considering target's state rate?


For reference, I can't use original add state in skill effect because the state's trait changed by conditions in state note box.


And that state is below.


State 23 : use Yanlfy Buff & state core


<Custom Apply Effect>


var x = target.def;


if ($gameVariables.value(86) === 1 || $gameVariables.value(86) === 2 || $gameVariables.value(86) === 3 || $gameVariables.value(86) === 4) {


x *= 0.15;


} else if ($gameVariables.value(86) === 5) {


x *= 0.20;


}


target.minusDef(x);


</Custom Apply Effect>


<Custom Remove Effect>


target.addDef(x);


</Custom Remove Effect>


Please help me. Thank you.
 

Quickdraws

Regular
Regular
Joined
May 31, 2013
Messages
55
Reaction score
9
First Language
English
Primarily Uses
Your questions a bit confusing but ill take a shot at it. Basically your trying to use javascript functions in YF action sequences in order to do so you need to use an


eval tag like this:          EVAL: javascript here.....    


Now one way to add the state based on the enemy target's state rate would belike this:    Code must all be on one single long line for it to work. placing this after a  "action effect" tag would be appropriate.


eval: var roll = Math.randomInt(100) + 1; var chance = target.stateRate(23) * 100; if (roll <= chance && target.result().isHit() === true) {target.addState(23)};


Now the breakdown explanation.


var roll = Math.randomInt(100) + 1;    ////       random number roll like normally occurring for state affected chance


var chance = target.stateRate(23) * 100;   /////   Targets state rate is a returned as a decimal need multiply it by a hundred for comparison to roll so 80% resist would be 0.8 * 100 = 80


if (roll <= chance && target.result().isHit() === true) {target.addState(23)};   if roll is less then resist chance and attack is hit add the desired state 23 in this case.


Voila it should work like a charm now hopefully did for me when I tested it.


Hope this helps and remember and javascript functions needs  ---->     eval:   java script here; code broken up with semi colons ; all on a single line to work in action sequences tags
 
Last edited by a moderator:

chanfi

Villager
Member
Joined
Jun 18, 2016
Messages
8
Reaction score
0
First Language
korean
Primarily Uses
Your questions a bit confusing but ill take a shot at it. Basically your trying to use javascript functions in YF action sequences in order to do so you need to use an


eval tag like this:          EVAL: javascript here.....    


Now one way to add the state based on the enemy target's state rate would belike this:    Code must all be on one single long line for it to work. placing this after a  "action effect" tag would be appropriate.


eval: var roll = Math.randomInt(100) + 1; var chance = target.stateRate(23) * 100; if (roll <= chance && target.result().isHit() === true) {target.addState(23)};


Now the breakdown explanation.


var roll = Math.randomInt(100) + 1;    ////       random number roll like normally occurring for state affected chance


var chance = target.stateRate(23) * 100;   /////   Targets state rate is a returned as a decimal need multiply it by a hundred for comparison to roll so 80% resist would be 0.8 * 100 = 80


if (roll <= chance && target.result().isHit() === true) {target.addState(23)};   if roll is less then resist chance and attack is hit add the desired state 23 in this case.


Voila it should work like a charm now hopefully did for me when I tested it.


Hope this helps and remember and javascript functions needs  ---->     eval:   java script here; code broken up with semi colons ; all on a single line to work in action sequences tags

Very nice! It is clearly done!


Thank you very much. You have explained what I want to exactly.


I really appreciate your kind explanation.


but I am confused because there is an error when I typing above eval code.


And there is no error when I copy and Paste above eval code.


Maybe I missed something.
 
Last edited by a moderator:

Quickdraws

Regular
Regular
Joined
May 31, 2013
Messages
55
Reaction score
9
First Language
English
Primarily Uses
couldn't say if you get an error when you type it and not when you paste my code..... maybe you made a typo lol not sure but if it works it works. The biggest thing with


eval: is the entirety of the code needs to be on 1 line even though above it appears on two the auto formatting on forums wont allow one continuous line and you need the semi colons to add like a line break between code sections.
 

Latest Threads

Latest Posts

Latest Profile Posts

Me trying art tutorials be like:
Artist: Okay guys, you're just going to want to start with a simple circle as your base
Me: Man, mine looks nothing like the picture
Sqaure.png
This the second update for my picture, "Reflection of Many Hearts." The new characters featured on the sides of the picture are as followed: Liridona (girl in green), Draven (the guy with white hair and horns), Nathaniel (the blonde guy in purple) and Adele (the woman with her hair in an elaborate hairstyle) These characters are featured in my game, "One's Desolation" an adventure horror game.Reflection of Many Hearts Part 2 - Copy.jpg
Illustration.png
I think I'm getting closer to having a good battler sprite.
Though animating is still a bit intimidating...
First monster pack out and someone already bought one o_O Surprising.
Cooled my head; now am back to working on my game.

Forum statistics

Threads
134,746
Messages
1,250,250
Members
177,501
Latest member
Rafa_232124442
Top