• 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.

Getting a Sound Effect to play for Overworld Weather

Derxwna Kapsyla

Derxwna "The Badman" Kapsyla
437
Posts
12
Years
  • Like in the Pokemon games proper, this script modification will allow you to have background sound for when weather is going on. After hours of Trial and Error, we got it working decently. Credit goes to Mugendai for getting the script working.

    To get the script working, go to the Script Section "Game_Screen", and look for the following line: def weather(type, power, duration). Once you find it, that entire section needs to be overwritten with the following code.
    Code:
    def weather(type, power, duration)
        @weather_type_target = type
        if @weather_type_target == 0 # None
          pbBGSFade(duration)
        elsif @weather_type_target == 1 # Rain
          pbBGSPlay("Rain")
        elsif @weather_type_target == 2 # Storm
          pbBGSPlay("Storm")
        elsif @weather_type_target == 3 # Snow
          pbBGSPlay("Snow")
        elsif @weather_type_target == 4 # Sandstorm
          pbBGSPlay("Sandstorm")
        elsif @weather_type_target == 5 # Sunny
          pbBGSPlay("Sunny") # is this one honestly even necessary? What could possibly play for Sunny Weather? Ah well, it's there if needed.
        end
        if @weather_type_target != 0
          @weather_type = @weather_type_target
        end
        if @weather_type_target == 0
          @weather_max_target = 0.0
        else
          @weather_max_target = (power + 1) * 4.0
        end
        @weather_duration = duration
        if @weather_duration == 0
          @weather_type = @weather_type_target
          @weather_max = @weather_max_target
        end
      end

    Do note, you will need sound files for "Rain", "Storm", "Snow", "Sandstorm", and "Sunny". I've provided a download link to the Rain audio file I have. It's free to use, made off an online generator. This way you can test it in-game proper without needing to create a new file.

    I would suggest putting a fade in for the audio file, as the audio starts playing right away as soon as the map loads. However, due to it being BGS, the audio file will loop.

    Small defect: it may cause some lag on older machines when transitioning between maps. On newer machines, no errors were reported.

    I don't think I forgot anything. If I did, I'll be sure to have Mugendai include it in a follow-up post.

    The script is, as expected, free to use. Make use of it how you will. Enjoy!
     

    Derxwna Kapsyla

    Derxwna "The Badman" Kapsyla
    437
    Posts
    12
    Years
  • Coincidentally enough, Luka answered the thread after I posted the tutorial. I even told Mugendai about it last night, and we laughed it off:
    [07:13:46] <Derxwna> Wow
    [07:13:49] <Derxwna> Mugendai
    [07:13:56] <Derxwna> An alternate method to getting weather working
    [07:14:01] <Derxwna> AFTER I post the tutorial

    So when I posted it, it was still unanswered. Nevertheless, it would be wrong to amend this post with Luka's idea, since it was his method. Mugendai devised this method of his own time and knowledge, and gave me permission to post it up here.
    [05:45:56] <Derxwna> Mugendai
    [05:46:02] <Mugendai> ?
    [05:46:12] <Derxwna> You don't mind if I post the tutorial about how to get Weather Sounds working, do you?
    [05:46:21] <Mugendai> go ahead

    Honestly, for me, I just like giving back to the community. If I have an answer to one of my own questions, even if it's not a big deal, I like to post the answer for people who may potentially run across the scenario in the future. This seemed like a potential thing people would be curious about, so I dropped the method Mugendai crafted here on the forums to benefit others.
    Sorry if I seemed a bit defensive in this post, I probably misinterpreted the tone of your post, but I also don't want people to think I'm taking credit for something Luka came up with - the last thing I want to do is be branded a thief in this community!
     

    Luka S.J.

    Jealous Croatian
    1,270
    Posts
    15
    Years
  • Sorry if I seemed a bit defensive in this post, I probably misinterpreted the tone of your post, but I also don't want people to think I'm taking credit for something Luka came up with - the last thing I want to do is be branded a thief in this community!

    Timestamps prove everything man. I didn't see this thread when I posted the stuff in your Question thread. I did see it later though, and I saw that you posted this like an hour before I gave my answer, I just left my post up anyway. So don't worry, it's all good
     

    Derxwna Kapsyla

    Derxwna "The Badman" Kapsyla
    437
    Posts
    12
    Years
  • Timestamps prove everything man. I didn't see this thread when I posted the stuff in your Question thread. I did see it later though, and I saw that you posted this like an hour before I gave my answer, I just left my post up anyway. So don't worry, it's all good

    I like to keep things timestamped for good reason, documentation of events and chronicling purposes. They also come in handy when proving events dd happen when they happened.
    Your method you posted on the thread was a valid suggestion. Had we not already figured something out, I'd probably have given it a whirl. Didn't wanna make a comment about how we already figured it out, I thought it'd be rude if I pointed it out. Nevertheless, more than one method is always good.
     
    6
    Posts
    4
    Years
    • Age 25
    • Seen Nov 28, 2023
    For anybody needing help with installation for v20+, you'll want to head to the script section Game_Screen and search for the line
    def weather(type, power, duration)
    as you had to before for earlier versions of Essentials. You'll replace the four lines of code there with the following:
    Code:
    def weather(type, power, duration)
        @weather_type     = GameData::Weather.get(type).id
        if weather_type == :None
          pbBGSFade(duration)
        elsif weather_type == :Rain
          pbBGSPlay("Rain.ogg")
        elsif weather_type == :Storm
          pbBGSPlay("Storm.ogg")
        elsif weather_type == :Snow
          pbBGSPlay("Snow.ogg")
        elsif weather_type == :Blizzard
          pbBGSPlay("Blizzard.ogg")
        elsif weather_type == :Sandstorm
          pbBGSPlay("Sandstorm.ogg")
        elsif weather_type == :HeavyRain
          pbBGSPlay("HeavyRain.ogg")
        elsif weather_type == :Sun
          pbBGSPlay("Sunny.ogg")
        elsif weather_type == :Fog
          pbBGSPlay("Fog.ogg")
        end
        if weather_type != 0
           weather_type = @weather_type
        end
        if weather_type == 0
           weather_max = 0.0
        else
           @weather_max = (power + 1) * RPG::Weather::MAX_SPRITES / 10
        end
        @weather_duration = duration # In 1/20ths of a seconds
        if weather_duration == 0
          weather_type = @weather_type
          weather_max = @weather_max
        end
      end
    For pbBGSFade(duration), duration is to be replaced by the time you want it to take for the BGS to fade out. For example, you could input 1.0 for a second long fade. If you want it to fade out instantly, you could either input 0.0 or simply replace the pbBGSFade with pbBGSStop. The duration input still applies to pbBGSStop.

    It should be noted that you don't need a BGS file for each Overworld weather, nor do you have to leave in their parts of the code. Honestly, I have no idea what you'd even put in as a BGS for Fog, Sunlight, or Snow, but if you have something for it, the code is there for you to implement and use.

    Also, immediately after applying this edit and booting up your game, if you're in a map that experiences weather in your current save, the audio won't work right away. You need to leave the map first before the weather's BGS will sound for that map.
     
    Back
    Top