[VX Ace] Cover State

Ant1989

Veteran
Veteran
Joined
Nov 30, 2013
Messages
36
Reaction score
1
First Language
Portuguese
Primarily Uses
I'm making a cover state that allow a enemy tank to cover a boss, but I wanted to make it to only work 75% of the time, and in 25% it should fail and the tank shound't cover.

I did this in the code

Code:
def check_substitute(target, item)
    target.hp < target.mhp / 3 && (!item || !item.certain?)
  end
What line I have to add to include a chance of 75% for the enemy to cover instead of 100%?
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,377
Reaction score
8,536
First Language
English
Primarily Uses
RMMV
@Ant1989 I've split your question into it's own post. Next time, please do not ask a question in someone else's topic.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
You could try something like this:
Code:
  def check_substitute(target, item)
    target.hp < target.mhp / 3 && (!item || !item.certain?) && 0.75 > rand
  end
But if you do this in the default script where you found these lines, it will work for actors and enemies alike.
If you want this 75% only for enemies, you will have to add some extra checks too::
Code:
  def check_substitute(target, item)
    if @subject.is_a?(Game_Enemy) && target.is_a?(Game_Enemy)
      return false unless 0.75 > rand
    end
    target.hp < target.mhp / 3 && (!item || !item.certain?)
  end

Of course, I didn't test any of these. :D
 

Ant1989

Veteran
Veteran
Joined
Nov 30, 2013
Messages
36
Reaction score
1
First Language
Portuguese
Primarily Uses
Thank you very much.
 

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,467
Members
137,821
Latest member
Capterson
Top