• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Akari, Selene, Mint, Solana - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

Allowing and disallowing wild encounters with a switch

Telemetius

Tele*
  • 256
    Posts
    10
    Years
    This must be easy but I'm having a couple problems with my encounter modifier that's supposed to allow/disallow wild encounters when a switch is ON, it basically isn't working at all.

    Events.onWildPokemonCreate+=proc {|sender,e|
    pokemon=e[0]
    if $game_switches[100]
    pbSet(variable,1)
    $PokemonGlobal.nextBattleBGM=nil
    $PokemonGlobal.nextBattleME=nil
    $PokemonGlobal.nextBattleBack=nil
    return true
    end
    }
     
    I believe you can just edit pbCanEncounter?(encounter) and add your conditional statement around "return false if...". Seems much less work to me, and much more organised.
     
    As for answering your question, just alias the "pbCanEncounter?" function and redefine it like so:

    Code:
    alias switch_pbCanEncounter? pbCanEncounter?
    
    def pbCanEncounter?(encounter)
      return false if $game_switches[100]
      
      return switch_pbCanEncounter?(encounter)
    end

    But, why would you want to do that when there's a much more simple way?

    You could just use the built in event function "Change Encounter"

    Spoiler:


    It's literally that simple, and you don't even need to waste a switch.
     
    As for answering your question, just alias the "pbCanEncounter?" function and redefine it like so:

    Code:
    alias switch_pbCanEncounter? pbCanEncounter?
    
    def pbCanEncounter?(encounter)
      return false if $game_switches[100]
      
      return switch_pbCanEncounter?(encounter)
    end

    But, why would you want to do that when there's a much more simple way?

    You could just use the built in event function "Change Encounter"

    Spoiler:


    It's literally that simple, and you don't even need to waste a switch.

    It was meant to start a parallel common event whatever the map I was in but you're right, it's way easier with the built in option.
     
    Back
    Top