• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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] Weather based encounter type not working...(v. 17)

40
Posts
8
Years
  • So i'm trying to add a gen8-style encounter method to my game where certain weather conditions will cause different pokemon to appear. Thought it'd be pretty straightforward, but after doing the scripting and changing the encounters data file, i'm not encountering any Pokémon in the grass. I tried using Sweet Scent, and THAT seems to work fine, though. So the problem seems to be that the game just isn't detecting that random encounters should happen when you take steps in the grass. This only happens when the relevant weather is in effect, the old "LandDay, LandNight, etc" encounters work fine still. Here's what I changed in the scripts (I put "#" by the lines I added or changed):

    Code:
    module EncounterTypes
      Land            = 0
      Cave            = 1
      Water           = 2
      RockSmash       = 3
      OldRod          = 4
      GoodRod         = 5
      SuperRod        = 6
      HeadbuttLow     = 7
      HeadbuttHigh    = 8
      LandMorning     = 9
      LandDay         = 10
      LandNight       = 11
      BugContest      = 12
      RainMorn        = 13 #
      RainDay         = 14 #
      RainNight       = 15 #
      Names = [
         "Land",
         "Cave",
         "Water",
         "RockSmash",
         "OldRod",
         "GoodRod",
         "SuperRod",
         "HeadbuttLow",
         "HeadbuttHigh",
         "LandMorning",
         "LandDay",
         "LandNight",
         "BugContest",
         "RainMorn", #
         "RainDay", #
         "RainNight" #
      ]
      EnctypeChances = [
         [20,20,10,10,10,10,5,5,4,4,1,1],
         [20,20,10,10,10,10,5,5,4,4,1,1],
         [60,30,5,4,1],
         [60,30,5,4,1],
         [70,30],
         [60,20,20],
         [40,40,15,4,1],
         [30,25,20,10,5,5,4,1],
         [30,25,20,10,5,5,4,1],
         [20,20,10,10,10,10,5,5,4,4,1,1],
         [20,20,10,10,10,10,5,5,4,4,1,1],
         [20,20,10,10,10,10,5,5,4,4,1,1],
         [20,20,10,10,10,10,5,5,4,4,1,1],
         [20,20,10,10,10,10,5,5,4,4,1,1], #
         [20,20,10,10,10,10,5,5,4,4,1,1], #
         [20,20,10,10,10,10,5,5,4,4,1,1] #
      ]
      EnctypeDensities   =      [25,10,10,0,0,0,0,0,0,25,25,25,25,25,25,25] #
      EnctypeCompileDens = [ 1, 2, 3,0,0,0,0,0,0, 1, 1, 1, 1, 1, 1, 1] #
    end

    Code:
    def isGrass?
      return false if @density==nil
      return (@enctypes[EncounterTypes::Land] ||
                   @enctypes[EncounterTypes::LandMorning] ||
                   @enctypes[EncounterTypes::LandDay] ||
                   @enctypes[EncounterTypes::LandNight] ||
                   @enctypes[EncounterTypes::RainMorn] || #
                   @enctypes[EncounterTypes::RainDay] || #
                   @enctypes[EncounterTypes::RainNight] #
                   @enctypes[EncounterTypes::BugContest]) ? true : false
     end
    
     def isRegularGrass?
       return false if @density==nil
       return (@enctypes[EncounterTypes::Land] ||
                     @enctypes[EncounterTypes::LandMorning] ||
                     @enctypes[EncounterTypes::LandDay] ||
                     @enctypes[EncounterTypes::LandNight] ||
                     @enctypes[EncounterTypes::RainMorn] || #
                     @enctypes[EncounterTypes::RainDay] || #
                     @enctypes[EncounterTypes::RainNight]) ? true : false #
     end

    Code:
    def pbEncounterType
        if $PokemonGlobal && $PokemonGlobal.surfing
          return EncounterTypes::Water
        elsif self.isCave?
          return EncounterTypes::Cave
        elsif self.isGrass?
          time = pbGetTimeNow
          enctype = EncounterTypes::Land
          enctype = EncounterTypes::LandNight if self.hasEncounter?(EncounterTypes::LandNight) && PBDayNight.isNight?(time)
          enctype = EncounterTypes::LandDay if self.hasEncounter?(EncounterTypes::LandDay) && PBDayNight.isDay?(time)
          enctype = EncounterTypes::LandMorning if self.hasEncounter?(EncounterTypes::LandMorning) && PBDayNight.isMorning?(time)
          case $game_screen.weather_type #
          when PBFieldWeather::Rain #|| PBFieldWeather::HeavyRain #
            enctype = EncounterTypes::RainNight if self.hasEncounter?(EncounterTypes::RainNight) && PBDayNight.isNight?(time) #
            enctype = EncounterTypes::RainDay if self.hasEncounter?(EncounterTypes::RainDay) && PBDayNight.isDay?(time) #
            enctype = EncounterTypes::RainMorn if self.hasEncounter?(EncounterTypes::RainMorn) && PBDayNight.isMorning?(time) #
          end #
          if pbInBugContest? && self.hasEncounter?(EncounterTypes::BugContest)
            enctype = EncounterTypes::BugContest
          end
          return enctype
        end
        return -1
      end

    I didn't make any other changes in PField_Encounters. What did I do wrong?
     
    40
    Posts
    8
    Years
  • Nope, didn't fix it. I actually DO have that "||" in my code, but didn't copy it over into my post by mistake. Something else must be wrong. It would make sense that something is wrong in "def isGrass?" though, since the game doesn't seem to recognize that the player is walking through grass, but I can't see what might be wrong...
     
    40
    Posts
    8
    Years
  • Well that IS helpful in a way, cuz now I know it was some other change I made that screwed this up, lol. Maybe when I was still experimenting with scripting I unintentionally changed something i shouldn't have? I'll let you know when I figure out what's wrong.
     
    40
    Posts
    8
    Years
  • Haha, so i figured out what was wrong! Apparently running "Compile Data" from the debug menu is all that it took :|. I always forget that that's there, lol.
     
    Back
    Top