[VX Ace] Cover State

● ARCHIVED · READ-ONLY
Started by Ant1989 4 posts View original ↗
  1. 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%?
  2. @Ant1989 I've split your question into it's own post. Next time, please do not ask a question in someone else's topic.
  3. You could try something like this:
    Spoiler
    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::
    Spoiler
    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
  4. Thank you very much.