• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Help with ability called Brainless

  • 158
    Posts
    6
    Years
    Hello! I need help with another custom Pokemon ability script. It's called Brainless and what it does is that it makes the Pokemon use a random move instead of the one you chose it to do. Example; you tell the Pokemon to use Tackle, but instead of Tackle it uses any of its other moves at random. Idk how to do that, so can someone help me please?
     
    Check out the bolded part in this method:
    Code:
      def pbObedienceCheck?(choice)   # Returns true if Pokémon obeys, false if won't
        return true if choice[0]!=1
        return true if [email protected]
        return true if [email protected]?(@index)
        disobedient = false
        # Pokémon may be disobedient; calculate if it is
        badgelevel = 10*(@battle.pbPlayer.numbadges+1)
        badgelevel = PBExperience::MAXLEVEL if @battle.pbPlayer.numbadges>=8
        move = choice[2]
        if @pokemon.isForeign?(@battle.pbPlayer) && @level>badgelevel
          a = ((@level+badgelevel)*@battle.pbRandom(256)/256).floor
          disobedient |= (a>=badgelevel)
        end
        if self.respond_to?("pbHyperModeObedience")
          disobedient |= !self.pbHyperModeObedience(move)
        end
        return true if !disobedient
        # Pokémon is disobedient; make it do something else
        PBDebug.log("[Disobedience] #{pbThis} disobeyed")
        @effects[PBEffects::Rage] = false
        # Do nothing if using Snore/Sleep Talk
        if self.status==PBStatuses::SLEEP && move.pbCanUseWhileAsleep?
          @battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!",pbThis)) 
          return false
        end
        b = ((@level+badgelevel)*@battle.pbRandom(256)/256).floor
    [B]    # Use another move
        if b<badgelevel
          @battle.pbDisplay(_INTL("{1} ignored orders!",pbThis)) 
          return false if [email protected]?(@index)
          othermoves = []
          for i in 0...4
            next if i==choice[1]
            othermoves[othermoves.length] = i if @battle.pbCanChooseMove?(@index,i,false)
          end
          return false if othermoves.length==0   # No other move to use; do nothing
          newchoice = othermoves[@battle.pbRandom(othermoves.length)]
          choice[1] = newchoice
          choice[2] = @moves[newchoice]
          choice[3] = -1
          return true
        end[/B]
        c = @level-badgelevel
        r = @battle.pbRandom(256)
        # Fall asleep
        if r<c && pbCanSleep?(self,false)
          pbSleepSelf
          @battle.pbDisplay(_INTL("{1} began to nap!",pbThis))
          return false
        end
        r -= c
        # Hurt self in confusion
        if r<c && self.status!=PBStatuses::SLEEP
          @battle.pbDisplay(_INTL("{1} won't obey! It hurt itself in its confusion!",pbThis))
          pbConfusionDamage
          return false
        end
        # Show refusal message and do nothing
        case @battle.pbRandom(4)
        when 0; @battle.pbDisplay(_INTL("{1} won't obey!",pbThis))
        when 1; @battle.pbDisplay(_INTL("{1} turned away!",pbThis))
        when 2; @battle.pbDisplay(_INTL("{1} is loafing around!",pbThis))
        when 3; @battle.pbDisplay(_INTL("{1} pretended not to notice!",pbThis))
        end
        return false
      end
     
    We have Metronome move as well. Check it.
     
    Check out the bolded part in this method:
    Code:
      def pbObedienceCheck?(choice)   # Returns true if Pokémon obeys, false if won't
        return true if choice[0]!=1
        return true if [email protected]
        return true if [email protected]?(@index)
        disobedient = false
        # Pokémon may be disobedient; calculate if it is
        badgelevel = 10*(@battle.pbPlayer.numbadges+1)
        badgelevel = PBExperience::MAXLEVEL if @battle.pbPlayer.numbadges>=8
        move = choice[2]
        if @pokemon.isForeign?(@battle.pbPlayer) && @level>badgelevel
          a = ((@level+badgelevel)*@battle.pbRandom(256)/256).floor
          disobedient |= (a>=badgelevel)
        end
        if self.respond_to?("pbHyperModeObedience")
          disobedient |= !self.pbHyperModeObedience(move)
        end
        return true if !disobedient
        # Pokémon is disobedient; make it do something else
        PBDebug.log("[Disobedience] #{pbThis} disobeyed")
        @effects[PBEffects::Rage] = false
        # Do nothing if using Snore/Sleep Talk
        if self.status==PBStatuses::SLEEP && move.pbCanUseWhileAsleep?
          @battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!",pbThis)) 
          return false
        end
        b = ((@level+badgelevel)*@battle.pbRandom(256)/256).floor
    [B]    # Use another move
        if b<badgelevel
          @battle.pbDisplay(_INTL("{1} ignored orders!",pbThis)) 
          return false if [email protected]?(@index)
          othermoves = []
          for i in 0...4
            next if i==choice[1]
            othermoves[othermoves.length] = i if @battle.pbCanChooseMove?(@index,i,false)
          end
          return false if othermoves.length==0   # No other move to use; do nothing
          newchoice = othermoves[@battle.pbRandom(othermoves.length)]
          choice[1] = newchoice
          choice[2] = @moves[newchoice]
          choice[3] = -1
          return true
        end[/B]
        c = @level-badgelevel
        r = @battle.pbRandom(256)
        # Fall asleep
        if r<c && pbCanSleep?(self,false)
          pbSleepSelf
          @battle.pbDisplay(_INTL("{1} began to nap!",pbThis))
          return false
        end
        r -= c
        # Hurt self in confusion
        if r<c && self.status!=PBStatuses::SLEEP
          @battle.pbDisplay(_INTL("{1} won't obey! It hurt itself in its confusion!",pbThis))
          pbConfusionDamage
          return false
        end
        # Show refusal message and do nothing
        case @battle.pbRandom(4)
        when 0; @battle.pbDisplay(_INTL("{1} won't obey!",pbThis))
        when 1; @battle.pbDisplay(_INTL("{1} turned away!",pbThis))
        when 2; @battle.pbDisplay(_INTL("{1} is loafing around!",pbThis))
        when 3; @battle.pbDisplay(_INTL("{1} pretended not to notice!",pbThis))
        end
        return false
      end

    Okay! What next?
     
    Actually, you know how a Pokemon uses a random move when using Sleep Talk? I don't want it to randomly choose a move it doesn't know.

    You literally just solved your own problem. Just look at Sleep Talk's code and add that as an ability in the sams place where moves like outrage/thrash are auto-chosen
     
    Find this line:
    Code:
    # Force the use of certain moves if they're already being used
     
    You'll have to figure most of this out on your own, especially if you're making complex abilities like this. (By complex I mean more than just a tweak of an existing ability.) If you really don't know any scripting, try to recruit a scripter that can help you. (If you're not yet at a point in your game where you're ready to recruit, write down your ideas for abilities/moves/etc. somewhere so you know what needs to be coded in the future, and code them in after you've recruited someone.) We can point you in the right direction, but you shouldn't expect that we'll fully implement stuff for you.
     
    You'll have to figure most of this out on your own, especially if you're making complex abilities like this. (By complex I mean more than just a tweak of an existing ability.) If you really don't know any scripting, try to recruit a scripter that can help you. (If you're not yet at a point in your game where you're ready to recruit, write down your ideas for abilities/moves/etc. somewhere so you know what needs to be coded in the future, and code them in after you've recruited someone.) We can point you in the right direction, but you shouldn't expect that we'll fully implement stuff for you.

    Okay! So I believe copy Sleep Talk's code? Right?
     
    Okay so here's what I came up with:
    Spoiler:

    Will this work? Is there possibly anyone to test it out for me?
     
    Okay so here's what I came up with:
    Spoiler:

    Will this work? Is there possibly anyone to test it out for me?

    Why don't you test it out. If you have any issues/errors then you can ask us.
     
    Back
    Top