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

MarioWidjaya123 wrote on kyonides's profile.


I thought they were dead, but I wanted to be certain. :kaoback:
Always kind of annoys me to see people complain about ads in their phone applications because people are too lazy to turn on airplane mode when using them.
Bunny girls are the best

Forum statistics

Threads
98,244
Messages
950,666
Members
129,544
Latest member
sensei89
Top