Help with fire shield state.

Status
Not open for further replies.

BlueCheezus

Villager
Member
Joined
Feb 4, 2020
Messages
5
Reaction score
0
First Language
english
Primarily Uses
RMMV
Hello guys! First post here,
Anyways I was trying to make a fire shield state that has a chance to add burn to attackers.
In these forums I've found this code I'll include below that allows me to add burn to attackers, however I don't want it to happen every time.

<Custom React Effect>

// Check to see if any physical damage is dealt.

if (value > 0 && this.isPhysical()) {

user.addState(x);

}

</Custom React Effect>

I was hoping someone could enlighten me on a way to use random variable in this code that would cause this to
happen only 50% of the time. I am using Yanflys states plugin and many others.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,607
Reaction score
14,329
First Language
English
Primarily Uses
RMVXA

I've moved this thread to Javascript Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
445
Reaction score
209
First Language
English
Primarily Uses
RMMV
Try this:
<Custom React Effect>

// Check to see if any physical damage is dealt.

if (value > 0 && this.isPhysical()) {

var chance = Math.random();

if (chance < .50) {

user.addState(x);

}

}

</Custom React Effect>

The chance line makes the effect trigger 50% of the time.
 

BlueCheezus

Villager
Member
Joined
Feb 4, 2020
Messages
5
Reaction score
0
First Language
english
Primarily Uses
RMMV
awesome! thanks it works perfectly. I love this forum already.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,033
Reaction score
5,333
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Snarkyfork wrote on Trihan's profile.
Hey man, I saw you mention that you do MV javascript work? Just wanted to confirm it before I put you on speed dial. =)
"Man is made by his belief. As he believes, so he is."-Krishna
FastFood in my country is neither fast nor cheap like it's expected to be, but people still buy a lot of it. I don't want to imagine how much of it people would eat if it was.
Started finishing up my bosses and characters...I don't know how long...but its going to take long...

Forum statistics

Threads
107,758
Messages
1,031,951
Members
139,904
Latest member
xana_the_machine
Top