Block damage, like when using a shield

kovak

Silverguard
Veteran
Joined
Apr 3, 2016
Messages
1,256
Reaction score
1,558
First Language
PT - EN
Primarily Uses
RMMV
So, i've found this example of block damage using YEP Auto Passive State, but i wanted it to reduce damage instead of setting it to 0.

 

Code:
[COLOR=rgb(0,0,136)]<Custom[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]React[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]Effect[/COLOR][COLOR=rgb(0,0,136)]>[/COLOR][COLOR=rgb(0,0,0)]
//just replace 50/100 with the percentage. 
if(Math.random()>50/100) {
    target.startAnimation(53);
    value = 0;
}
[/COLOR][COLOR=rgb(0,0,136)]</Custom[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]React[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]Effect[/COLOR][COLOR=rgb(0,0,136)]>[/COLOR]
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,696
Reaction score
3,005
First Language
Tagalog
Primarily Uses
RMVXA
change the 0...
 

kovak

Silverguard
Veteran
Joined
Apr 3, 2016
Messages
1,256
Reaction score
1,558
First Language
PT - EN
Primarily Uses
RMMV
I did and the actor took damage equals to the value
 

Quickdraws

Veteran
Veteran
Joined
May 31, 2013
Messages
55
Reaction score
8
First Language
English
Primarily Uses
I use something like this its a bit more elaborate this adds a chance to block, flat value reduction, and a percentage damage reduction; furthermore, I use have it so if user is afflicted with certain other states it modifies those values like say a cripple state reduces block chance and value or something of the sort.


<Custom React Effect>


var roll = Math.randomInt(100) + 1;


var blchance = 25;   // This is the chance for block to occur;


var blvalue = 10;     // This is a flat value reduction


var blred = 0.80;          //This is a percentage based reduction.


if (user.isStateAffected(23) || user.isStateAffected(3) || user.isStateAffected(6) || user.isStateAffected(167)) {


blchance -= 5;               // Reduces block chance


blvalue -= 10;          /// If user has certain states will reduce flat block values


blred += 0.45;             /// Reduces effectiveness damage reduction percentage


}


if (user.isStateAffected(55) || user.isStateAffected(15) || user.isStateAffected(36)) {


blchance  += 15;              // Increasesblock chance


blvalue += 10;                /// If user has certain states will increase block value


blred -= 0.15;               // Increases effectiveness  damage reduction percentage


}


if (roll <= blchance) {


value = value - blvalue;


value = Math.floor(value * blred);


if (value < 0) {


 value = 0    /// prevent value from being less than 0


}


user.startAnimation(256);     ///start animation


}


</Custom React Effect>


Hope this helps or gives you some ideas
 
Last edited by a moderator:

kovak

Silverguard
Veteran
Joined
Apr 3, 2016
Messages
1,256
Reaction score
1,558
First Language
PT - EN
Primarily Uses
RMMV

Wavelength

Edge of Eternity
Global Mod
Joined
Jul 22, 2014
Messages
4,968
Reaction score
4,148
First Language
English
Primarily Uses
RMVXA
Instead of "value = 0" you can do something like "value -= 10" to reduce damage by 10 or "value /= 2" to reduce damage by half.


If you're asking for a "shield" in the sense of LoL where it runs out after you take a certain amount of damage, that requires more complex scripting.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,696
Reaction score
3,005
First Language
Tagalog
Primarily Uses
RMVXA
Ofc if you remove 0 it will deal damage equal to value... What I meant was you change it to whatever value you need.
 
Last edited by a moderator:

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

Latest Threads

Latest Profile Posts

The end is near. The end is near. The MV era will be passed and people will look the forum about new RPG maker all days. ;_;[Election day all over again] Let accept that you will probably not what you want completely.
C&C Remastered comes out tomorrow! Hyped! Already have it preinstalled on Steam.
Its ironic, how often a person can have something smart to say, when their arrogance is originating from an internal vacuum where emotional intelligence belongs.
Parallax mapping is time consuming...
Let's purchase th... WAIT! Just in time ehehehe.

Forum statistics

Threads
98,152
Messages
949,737
Members
129,438
Latest member
Tsuna976
Top