[VX Ace] Cover State

Discussion in 'RGSSx Script Support' started by Ant1989, Nov 8, 2018.

  1. Ant1989

    Ant1989 Villager Member

    Messages:
    26
    Likes Received:
    0
    First Language:
    Portuguese
    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%?
     
    #1
  2. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    12,546
    Likes Received:
    6,851
    Location:
    Texas
    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.
     
    #2
  3. Sixth

    Sixth Veteran Veteran

    Messages:
    2,008
    Likes Received:
    708
    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
     
    #3
  4. Ant1989

    Ant1989 Villager Member

    Messages:
    26
    Likes Received:
    0
    First Language:
    Portuguese
    Thank you very much.
     
    #4

Share This Page