The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Tutorial Multiple Surf Themes

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.

Reply
 
Thread Tools
  #1    
Old August 2nd, 2017 (8:54 AM).
silentgamer64 silentgamer64 is offline
     
    Join Date: Feb 2015
    Posts: 96
    As we all know, default essentials only allows us to define one surf theme for our entire game. But if you plan on having more than one region with different surf themes, or maybe just feel like having a different surf theme for a certain map, there is no way to accomplish this.

    I was able to play around with a few of the scripts and figured out how to define the surf theme in each map's metadata. Please bear with me as there are multiple steps to this process.

    1. In MiscData around line 114, add the highlighted line of code to this section:
    Spoiler:
    Code:
    NonGlobalTypes={
         "Outdoor"=>[MetadataOutdoor,"b"],
         "ShowArea"=>[MetadataShowArea,"b"],
         "Bicycle"=>[MetadataBicycle,"b"],
         "BicycleAlways"=>[MetadataBicycleAlways,"b"],
         "HealingSpot"=>[MetadataHealingSpot,"uuu"],
         "Weather"=>[MetadataWeather,"eu",:PBFieldWeather],
         "MapPosition"=>[MetadataMapPosition,"uuu"],
         "DiveMap"=>[MetadataDiveMap,"u"],
         "DarkMap"=>[MetadataDarkMap,"b"],
         "SafariMap"=>[MetadataSafariMap,"b"],
         "SnapEdges"=>[MetadataSnapEdges,"b"],
         "Dungeon"=>[MetadataDungeon,"b"],
         "BattleBack"=>[MetadataBattleBack,"s"],
         "WildBattleBGM"=>[MetadataMapWildBattleBGM,"s"],
         "TrainerBattleBGM"=>[MetadataMapTrainerBattleBGM,"s"],
         "WildVictoryME"=>[MetadataMapWildVictoryME,"s"],
         "TrainerVictoryME"=>[MetadataMapTrainerVictoryME,"s"],
         "MapSize"=>[MetadataMapSize,"us"],
         "SurfTheme"=>[MetadataSurfTheme,"s"],
      }


    2. In Editor around line 3509, add the highlighted lines of code to this section:
    Spoiler:
    Code:
    LOCALMAPS=[
       ["Outdoor",BooleanProperty,
            _INTL("If true, this map is an outdoor map and will be tinted according to time of day.")],
       ["ShowArea",BooleanProperty,
           _INTL("If true, the game will display the map's name upon entry.")],
       ["Bicycle",BooleanProperty,
           _INTL("If true, the bicycle can be used on this map.")],
       ["BicycleAlways",BooleanProperty,
           _INTL("If true, the bicycle will be mounted automatically on this map and cannot be dismounted.")],
       ["HealingSpot",MapCoordsProperty,
            _INTL("Map ID of this Pokemon Center's town, and X and Y coordinates of its entrance within that town.")],
       ["Weather",WeatherEffectProperty,
           _INTL("Weather conditions in effect for this map.")],
       ["MapPosition",RegionMapCoordsProperty,
           _INTL("Identifies the point on the regional map for this map.")],
       ["DiveMap",MapProperty,
           _INTL("Specifies the underwater layer of this map. Use only if this map has deep water.")],
       ["DarkMap",BooleanProperty,
           _INTL("If true, this map is dark and a circle of light appears around the player. Flash can be used to expand the circle.")],
       ["SafariMap",BooleanProperty,
           _INTL("If true, this map is part of the Safari Zone (both indoor and outdoor). Not to be used in the reception desk.")],
       ["SnapEdges",BooleanProperty,
           _INTL("If true, when the player goes near this map's edge, the game doesn't center the player as usual.")],
       ["Dungeon",BooleanProperty,
           _INTL("If true, this map has a randomly generated layout. See the wiki for more information.")],
       ["BattleBack",StringProperty,
           _INTL("PNG files named 'battlebgXXX', 'enemybaseXXX', 'playerbaseXXX' in Battlebacks folder, where XXX is this property's value.")],
       ["WildBattleBGM",BGMProperty,
           _INTL("Default BGM for wild Pokémon battles on this map.")],
       ["TrainerBattleBGM",BGMProperty,
           _INTL("Default BGM for trainer battles on this map.")],
       ["WildVictoryME",MEProperty,
           _INTL("Default ME played after winning a wild Pokémon battle on this map.")],
       ["TrainerVictoryME",MEProperty,
           _INTL("Default ME played after winning a Trainer battle on this map.")],
       ["MapSize",MapSizeProperty,
           _INTL("The width of the map in Town Map squares, and a string indicating which squares are part of this map.")],
       ["SurfTheme",BGMProperty,
           _INTL("Default Surf theme on this map.")],
    ]

    This will add a new field in the map's metadata for the map's surf theme.

    3. PSystem_Utilities around line 1478-1481 insert the highlighted code underneath the def pbGetWildBattleBGM block:

    Spoiler:
    Code:
    def pbGetWildBattleBGM(species)
      if $PokemonGlobal.nextBattleBGM
        return $PokemonGlobal.nextBattleBGM.clone
      end
      ret=nil
      if !ret && $game_map
        # Check map-specific metadata
        music=pbGetMetadata($game_map.map_id,MetadataMapWildBattleBGM)
        if music && music!=""
          ret=pbStringToAudioFile(music)
        end
      end
      if !ret
        # Check global metadata
        music=pbGetMetadata(0,MetadataWildBattleBGM)
        if music && music!=""
          ret=pbStringToAudioFile(music)
        end
      end
      ret=pbStringToAudioFile("002-Battle02") if !ret
      return ret
    end
    
    def pbGetSurfTheme
      ret=nil
      if !ret && $game_map
        # Check map-specific metadata
        music=pbGetMetadata($game_map.map_id,MetadataSurfTheme)
        if music && music!=""
          ret=pbStringToAudioFile(music)
        end
      end
      if !ret
        # Check global metadata
        music=pbGetMetadata(0,MetadataSurfBGM)
        if music && music!=""
          ret=pbStringToAudioFile(music)
        end
      end
      ret=pbStringToAudioFile("002-Battle02") if !ret
      return ret
    end
    
    def pbGetWildVictoryME


    4. In PField_HiddenMoves around line 500, comment out surfbgm=pbGetMetadata(0,MetadataSurfBGM) and add the line surfbgm=pbGetSurfTheme underneath it:

    Spoiler:
    Code:
    def Kernel.pbSurf
      if $game_player.pbHasDependentEvents?
        return false
      end
      if $DEBUG ||
        (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
        movefinder=Kernel.pbCheckMove(:SURF)
        if $DEBUG || movefinder
          if Kernel.pbConfirmMessage(_INTL("The water is a deep blue...\nWould you like to surf on it?"))
            speciesname=!movefinder ? $Trainer.name : movefinder.name
            Kernel.pbMessage(_INTL("{1} used Surf!",speciesname))
            pbHiddenMoveAnimation(movefinder)
            #surfbgm=pbGetMetadata(0,MetadataSurfBGM)
            surfbgm=pbGetSurfTheme
            pbCueBGM(surfbgm,0.5) if surfbgm
            pbStartSurfing()
            return true
          end
        end
      end
      return false
    end


    5. In PField_Field around line 1990 comment out the line surfbgm=pbGetMetadata($game_map.map_id,MetadataSurfTheme) and insert the line surfbgm=pbGetSurfTheme underneath it for BOTH pbAutoplayOnTransition AND FOR pbAutoplayOnSave YOU MUST DO THIS FOR BOTH OR ELSE THE SURF THEME WILL NOT PLAY CORRECTLY.

    Spoiler:
    Code:
    def pbAutoplayOnTransition
      #surfbgm=pbGetMetadata($game_map.map_id,MetadataSurfTheme)
      surfbgm=pbGetSurfTheme
      if $PokemonGlobal.surfing && surfbgm
        pbBGMPlay(surfbgm)
      else
        $game_map.autoplayAsCue
      end
    end
    
    def pbAutoplayOnSave
      #surfbgm=pbGetMetadata($game_map.map_id,MetadataSurfTheme)
      surfbgm=pbGetSurfTheme
      if $PokemonGlobal.surfing && surfbgm
        pbBGMPlay(surfbgm)
      else
        $game_map.autoplay
      end
    end


    That should be all you need to change. Now when you go into the editor and edit each map's metadata, there should be an extra field at the bottom of the list for the surf theme of that map.



    WARNING: If you decide to go with this method, you will have to define a surf theme for every map that contains a surfable body of water. Otherwise it may not play anything when you surf.
    Reply With Quote
      #2    
    Old October 16th, 2017 (12:21 PM).
    Ulithium_Dragon's Avatar
    Ulithium_Dragon Ulithium_Dragon is offline
       
      Join Date: Jul 2015
      Gender: Male
      Nature: Timid
      Posts: 87
      Very nice! You forgot one thing, though:

      In MiscData, you need to initialize "MetadataSurfTheme". So around line 75~ you gotta add this:
      Code:
      MetadataMapWildVictoryME    = 16
      MetadataMapTrainerVictoryME = 17
      MetadataMapSize             = 18
      MetadataSurfTheme           = 19
      I assume you just forgot to mention this part. :]
      __________________

      [PokéMounts] [Warp Tile Animation Tutorial] [Fall Down Hole Animation Tutorial] [PokéCenter Monitor Icons] [Dependent Events Use Running Sprites]
      Reply With Quote
      Reply

      Quick Reply

      Join the conversation!

      Create an account to post a reply in this thread, participate in other discussions, and more!

      Create a PokéCommunity Account
      Thread Tools

      Posting Rules
      You may not post new threads
      You may not post replies
      You may not post attachments
      You may not edit your posts

      BB code is On
      Smilies are On
      [IMG] code is On
      HTML code is Off

      Forum Jump


      All times are GMT -8. The time now is 12:13 PM.