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

Veteran
Veteran
Joined
May 31, 2013
Messages
55
Reaction score
8
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

Veteran
Veteran
Joined
May 31, 2013
Messages
55
Reaction score
8
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.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

My spirit can be so easily wounded by most things that nobody thinks twice about. It may be not a big deal to you, but it means EVERYTHING to me!
I have to make a custom tree for my FSM game and I'm nervous I won't get it right.
Finally got the tablet picture! :LZSsmile:
Working hard on my Mode7 interiors in between calls at work!
A good idea rise a moment before falling asleep, and survive the second coffee the day next morning.

Forum statistics

Threads
97,918
Messages
947,871
Members
129,163
Latest member
Merglu
Top