Help with fire shield state.

Status
Not open for further replies.

BlueCheezus

Warper
Member
Joined
Feb 4, 2020
Messages
2
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,112
Reaction score
13,613
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
437
Reaction score
196
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

Warper
Member
Joined
Feb 4, 2020
Messages
2
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
6,766
Reaction score
4,610
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.

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

Latest Threads

Latest Posts

Latest Profile Posts


It's my cute little ghost~
Minecraft Dungeons is a great example of a game that's much simpler than other games in its genre but almost as equally immersive and fun to play. Lotta RPGmaker devs could learn from that lesson.
Well, it's been a while since the last time I came here... Is there a JS scripting FAQ? I'd like to know what it's capable of achieving, and how :rswt
I love the Time Fantasy tiles, but haven't played anything made with it yet. Can anyone recommend me something?
Vote for what I show more indepth on Twitter tomorrow from the MZ default resources

Forum statistics

Threads
99,367
Messages
964,519
Members
130,979
Latest member
rpgmakernoob
Top