• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • The Eevee Expo Game Jam has concluded! 🎉 Head on over to the game jam forum to play through the games.
    Don't forget to come back September 21st to vote for your favorites!
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!
Resource icon

Resource Ambient Pokémon Cries 2017-07-21

Vendily submitted a new resource:

Ambient Pokémon Cries - Hear the Pokémon on the route

A 100% Plug-and-Play script for v16.2, it plays a random cry of a Pokémon on the route from all available encounter types, time allowing, every minute, plus/minus rand(5) seconds (but that's the default, play with the constants, yeah)
Optionally, it allows you to disable and enable the cries with a switch.
Place it in any script section under PField_Field, because it uses the Events Module, which is defined in PField_Field, and it will give an error otherwise.

Read more about this resource...
 
You know what? I am sad to see no one comment on this. This is a fun attachment that I appreciate hat you made. I always like this idea tbh because it let's you have a hint on what species live on the route. So I have to say thank you.
 
It's nice I would like to use it but I just have Essentials v.17.2 (without debug mode, idk why) and I need this, it would be nice if you could do this for 17.2 too, thanks in advance
 
It's nice I would like to use it but I just have Essentials v.17.2 (without debug mode, idk why) and I need this, it would be nice if you could do this for 17.2 too, thanks in advance
Well, I don't know why you are missing Debug mode (did you click the playtest button from RMXP?) but as far as I can tell, this script still works in v17.2. Luckily, this script wasn't affected by any of the changes between the versions.
 
Verified working for v18.1! Thanks Vendily for making this, it really adds to the game.
 
Fixed up this script for V19 if anyone is interested


Ruby:
Expand Collapse Copy
#===============================================================================
# * Ambient Pokémon Cries - by Vendily
# Modified by SpaceWestern
#===============================================================================
# This script plays random cries of pokémon that can be encountered on the map
#  for ambiance. It does not activate for maps that don't have pokemon,
#  and optionally only when a switch is active.
# To ensure you get no errors, this script must be under PField_Field. It can
#  be anywhere but it must be under that section. (It's because it uses the
#  Events Module, which is defined in PField_Field)
#===============================================================================
# * The time between cries in seconds (arbitrarily default 60)
# * The variance in time for cries in seconds (arbitrarily default +/-rand(5))
# * The Global Switch that is checked to see if ambiance should be used, set
#      to -1 to always play ambiance if possible
# * The volume to play the cry at (default 65)
# * If the game should play roamer cries, which are the only cries that play
#    should one be found on the current map (default true)
#===============================================================================
TIME_BETWEEN_CRIES  = 30
RANDOM_TIME_FACTOR  = 5
AMBIANCE_SWITCH     = -1
CRY_VOLUME          = 65
CRY_ROAMERS         = true

class PokemonEncounters
  def pbAllValidEncounterTypes(mapID)
    data = GameData::Encounter.get(mapID, $PokemonGlobal.encounter_version)
    enclist= Marshal.load(Marshal.dump(data.types))
    ret=[]
    enclist.each{|enclist|
      ret.push(enclist)
    }
    return ret
  end
end

class PokemonTemp
  attr_accessor :lastCryTime
end

def pbPlayAmbiance
  if AMBIANCE_SWITCH<0 || $game_switches[AMBIANCE_SWITCH]
    roam=[]
    if CRY_ROAMERS
      for i in 0...Settings::ROAMING_SPECIES.length
        poke=Settings::ROAMING_SPECIES[i]
        species=getID(GameData::Species,poke[0])
        next if !species || species<=0
        if $game_switches[poke[2]] && $Overworld_RoamingPokemon.roamPokemon[i]!=true
          currentArea=$Overworld_RoamingPokemon.roamPosition[i]
          if !currentArea
            $Overworld_RoamingPokemon.roamPosition[i]=keys[rand(keys.length)]
            currentArea=$Overworld_RoamingPokemon.roamPosition[i]
          end
          roamermeta=pbGetMetadata(currentArea,MetadataMapPosition)
          possiblemaps=[]
          mapinfos=$RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
          for j in 1...mapinfos.length
            jmeta=pbGetMetadata(j,MetadataMapPosition)
            if mapinfos[j] && mapinfos[j].name==$game_map.name &&
              roamermeta && jmeta && roamermeta[0]==jmeta[0]
              possiblemaps.push(j)   # Any map with same name as roamer's current map
            end
          end
          if possiblemaps.include?(currentArea) && pbRoamingMethodAllowed(poke[3])
            # Change encounter to species and level, with BGM on end
            roam.push(species)
          end
        end
      end
    end
    
    if roam.length>0
      #play a random roaming cry
      Pokemon.play_cry(roam[rand(roam.length)], 0, CRY_VOLUME, 100)
    else
      # enctypes will be the full set of lists of all encounters listed by type
      # the first index within each index (ie. enctypes[x][0] will be the actual
      # type of encounter (Land, Water, OldRod, etc.)
      enctypes=$PokemonEncounters.pbAllValidEncounterTypes($game_map.map_id) rescue []
      
      if enctypes && enctypes.length>0
        invalenc=true       
        while invalenc
          # This grabs one of the encounter types from the available options
          enc=enctypes[rand(enctypes.length)]
          
          # This checks to make sure that if it grabbed night it is night, and
          # the same for morning and day
          if (enc[0]=="LandNight" && !PBDayNight.isNight?) ||
             (enc[0]=="LandDay" && !PBDayNight.isDay?) ||
             (enc[0]=="LandMorning" && !PBDayNight.isMorning?)
          else
            invalenc=false
          end
        end
        # This grabs an individual cry from the chosen encounter type list
        crypoke = enc[1][rand(enc[1].length)][1]
      end
      if crypoke
        Pokemon.play_cry(crypoke, 0, CRY_VOLUME, 100)
      end
    end
  end
end

Events.onMapUpdate+=proc {|sender,e|   # Ambiance check
  now=pbGetTimeNow
 
  # This makes sure that the timer doesn't get confused when you load a save
  # Without this, it will always cry when you load in
  if $PokemonTemp.lastCryTime==nil
    $PokemonTemp.lastCryTime = now
  end
 
  last=$PokemonTemp.lastCryTime
  if !last || (now-last>(TIME_BETWEEN_CRIES+((rand(2)==0 ? -1 : 1)*rand(RANDOM_TIME_FACTOR))))
    pbPlayAmbiance
    $PokemonTemp.lastCryTime=now
  end
}
 
Fixed up this script for V19 if anyone is interested


Ruby:
Expand Collapse Copy
#===============================================================================
# * Ambient Pokémon Cries - by Vendily
# Modified by SpaceWestern
#===============================================================================
# This script plays random cries of pokémon that can be encountered on the map
#  for ambiance. It does not activate for maps that don't have pokemon,
#  and optionally only when a switch is active.
# To ensure you get no errors, this script must be under PField_Field. It can
#  be anywhere but it must be under that section. (It's because it uses the
#  Events Module, which is defined in PField_Field)
#===============================================================================
# * The time between cries in seconds (arbitrarily default 60)
# * The variance in time for cries in seconds (arbitrarily default +/-rand(5))
# * The Global Switch that is checked to see if ambiance should be used, set
#      to -1 to always play ambiance if possible
# * The volume to play the cry at (default 65)
# * If the game should play roamer cries, which are the only cries that play
#    should one be found on the current map (default true)
#===============================================================================
TIME_BETWEEN_CRIES  = 30
RANDOM_TIME_FACTOR  = 5
AMBIANCE_SWITCH     = -1
CRY_VOLUME          = 65
CRY_ROAMERS         = true

class PokemonEncounters
  def pbAllValidEncounterTypes(mapID)
    data = GameData::Encounter.get(mapID, $PokemonGlobal.encounter_version)
    enclist= Marshal.load(Marshal.dump(data.types))
    ret=[]
    enclist.each{|enclist|
      ret.push(enclist)
    }
    return ret
  end
end

class PokemonTemp
  attr_accessor :lastCryTime
end

def pbPlayAmbiance
  if AMBIANCE_SWITCH<0 || $game_switches[AMBIANCE_SWITCH]
    roam=[]
    if CRY_ROAMERS
      for i in 0...Settings::ROAMING_SPECIES.length
        poke=Settings::ROAMING_SPECIES[i]
        species=getID(GameData::Species,poke[0])
        next if !species || species<=0
        if $game_switches[poke[2]] && $Overworld_RoamingPokemon.roamPokemon[i]!=true
          currentArea=$Overworld_RoamingPokemon.roamPosition[i]
          if !currentArea
            $Overworld_RoamingPokemon.roamPosition[i]=keys[rand(keys.length)]
            currentArea=$Overworld_RoamingPokemon.roamPosition[i]
          end
          roamermeta=pbGetMetadata(currentArea,MetadataMapPosition)
          possiblemaps=[]
          mapinfos=$RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
          for j in 1...mapinfos.length
            jmeta=pbGetMetadata(j,MetadataMapPosition)
            if mapinfos[j] && mapinfos[j].name==$game_map.name &&
              roamermeta && jmeta && roamermeta[0]==jmeta[0]
              possiblemaps.push(j)   # Any map with same name as roamer's current map
            end
          end
          if possiblemaps.include?(currentArea) && pbRoamingMethodAllowed(poke[3])
            # Change encounter to species and level, with BGM on end
            roam.push(species)
          end
        end
      end
    end
   
    if roam.length>0
      #play a random roaming cry
      Pokemon.play_cry(roam[rand(roam.length)], 0, CRY_VOLUME, 100)
    else
      # enctypes will be the full set of lists of all encounters listed by type
      # the first index within each index (ie. enctypes[x][0] will be the actual
      # type of encounter (Land, Water, OldRod, etc.)
      enctypes=$PokemonEncounters.pbAllValidEncounterTypes($game_map.map_id) rescue []
     
      if enctypes && enctypes.length>0
        invalenc=true      
        while invalenc
          # This grabs one of the encounter types from the available options
          enc=enctypes[rand(enctypes.length)]
         
          # This checks to make sure that if it grabbed night it is night, and
          # the same for morning and day
          if (enc[0]=="LandNight" && !PBDayNight.isNight?) ||
             (enc[0]=="LandDay" && !PBDayNight.isDay?) ||
             (enc[0]=="LandMorning" && !PBDayNight.isMorning?)
          else
            invalenc=false
          end
        end
        # This grabs an individual cry from the chosen encounter type list
        crypoke = enc[1][rand(enc[1].length)][1]
      end
      if crypoke
        Pokemon.play_cry(crypoke, 0, CRY_VOLUME, 100)
      end
    end
  end
end

Events.onMapUpdate+=proc {|sender,e|   # Ambiance check
  now=pbGetTimeNow
 
  # This makes sure that the timer doesn't get confused when you load a save
  # Without this, it will always cry when you load in
  if $PokemonTemp.lastCryTime==nil
    $PokemonTemp.lastCryTime = now
  end
 
  last=$PokemonTemp.lastCryTime
  if !last || (now-last>(TIME_BETWEEN_CRIES+((rand(2)==0 ? -1 : 1)*rand(RANDOM_TIME_FACTOR))))
    pbPlayAmbiance
    $PokemonTemp.lastCryTime=now
  end
}
ty! It works perfectly :)
 
I think I've fixed this for v21.1. I'm a novice at coding but hope it works for everyone! :P (Some of these changes may have been unnecessary - so let me know)
Ruby:
Expand Collapse Copy
#===============================================================================
# * Ambient Pokémon Cries - by Vendily
# Modified by SpaceWestern for v19, Modified by MauGamesLOL for v21.1
#===============================================================================
# This script plays random cries of pokémon that can be encountered on the map
#  for ambiance. It does not activate for maps that don't have pokemon,
#  and optionally only when a switch is active.
# To ensure you get no errors, this script must be under PField_Field. It can
#  be anywhere but it must be under that section. (It's because it uses the
#  Events Module, which is defined in PField_Field)
#===============================================================================
# * The time between cries in seconds (arbitrarily default 60)
# * The variance in time for cries in seconds (arbitrarily default +/-rand(5))
# * The Global Switch that is checked to see if ambiance should be used, set
#      to -1 to always play ambiance if possible
# * The volume to play the cry at (default 65)
# * If the game should play roamer cries, which are the only cries that play
#    should one be found on the current map (default true)
#===============================================================================
module AmbientPokemonCries
  TIME_BETWEEN_CRIES  = 30
  RANDOM_TIME_FACTOR  = 5
  AMBIANCE_SWITCH     = -1
  CRY_VOLUME          = 25
  CRY_ROAMERS         = true
end

class PokemonEncounters
  def pbAllValidEncounterTypes(mapID)
    data = GameData::Encounter.get(mapID, $PokemonGlobal.encounter_version)
    enclist= Marshal.load(Marshal.dump(data.types))
    ret=[]
    enclist.each{|enclist|
      ret.push(enclist)
    }
    return ret
  end
end

class Game_Temp
  attr_accessor :last_cry_time
end

def pbPlayAmbiance
  if AmbientPokemonCries::AMBIANCE_SWITCH<0 || $game_switches[AmbientPokemonCries::AMBIANCE_SWITCH]
    roam=[]
    if AmbientPokemonCries::CRY_ROAMERS
      for i in 0...Settings::ROAMING_SPECIES.length
        poke=Settings::ROAMING_SPECIES[i]
        species=getID(GameData::Species,poke[0])
        next if !species || species<=0
        if $game_switches[poke[2]] && $Overworld_RoamingPokemon.roamPokemon[i]!=true
          currentArea=$Overworld_RoamingPokemon.roamPosition[i]
          if !currentArea
            $Overworld_RoamingPokemon.roamPosition[i]=keys[rand(keys.length)]
            currentArea=$Overworld_RoamingPokemon.roamPosition[i]
          end
          roamermeta=pbGetMetadata(currentArea,MetadataMapPosition)
          possiblemaps=[]
          mapinfos=$RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
          for j in 1...mapinfos.length
            jmeta=pbGetMetadata(j,MetadataMapPosition)
            if mapinfos[j] && mapinfos[j].name==$game_map.name &&
              roamermeta && jmeta && roamermeta[0]==jmeta[0]
              possiblemaps.push(j)   # Any map with same name as roamer's current map
            end
          end
          if possiblemaps.include?(currentArea) && pbRoamingMethodAllowed(poke[3])
            # Change encounter to species and level, with BGM on end
            roam.push(species)
          end
        end
      end
    end
    
    if roam.length>0
      #play a random roaming cry
      Pokemon.play_cry(roam[rand(roam.length)], 0, AmbientPokemonCries::CRY_VOLUME, 100)
    else
      # enctypes will be the full set of lists of all encounters listed by type
      # the first index within each index (ie. enctypes[x][0] will be the actual
      # type of encounter (Land, Water, OldRod, etc.)
      enctypes=$PokemonEncounters.pbAllValidEncounterTypes($game_map.map_id) rescue []
      
      if enctypes && enctypes.length>0
        invalenc=true       
        while invalenc
          # This grabs one of the encounter types from the available options
          enc=enctypes[rand(enctypes.length)]
          
          # This checks to make sure that if it grabbed night it is night, and
          # the same for morning and day
          if (enc[0]=="LandNight" && !PBDayNight.isNight?) ||
             (enc[0]=="LandDay" && !PBDayNight.isDay?) ||
             (enc[0]=="LandMorning" && !PBDayNight.isMorning?)
          else
            invalenc=false
          end
        end
        # This grabs an individual cry from the chosen encounter type list
        crypoke = enc[1][rand(enc[1].length)][1]
      end
      if crypoke
        Pokemon.play_cry(crypoke, 0, AmbientPokemonCries::CRY_VOLUME, 100)
      end
    end
  end
end

EventHandlers.add(:on_frame_update, :pokemon_ambiance_check,   # Ambiance check
proc {
  now = pbGetTimeNow # If you are using FL's Unreal Time, change to Time.now. (MauGamesLOL)
  # This makes sure that the timer doesn't get confused when you load a save
  # Without this, it will always cry when you load in
  if $game_temp.last_cry_time == nil
    $game_temp.last_cry_time = now
  end
  last = $game_temp.last_cry_time
  if !last || (now-last>(AmbientPokemonCries::TIME_BETWEEN_CRIES+((rand(2)==0 ? -1 : 1)*rand(AmbientPokemonCries::RANDOM_TIME_FACTOR))))
    pbPlayAmbiance
    $game_temp.last_cry_time = now
  end
}
)
 
Works great! Is there a way to exclude an encounter list? ie i want to disable water encounters and make it land only
 
Added further randomization to level of sound and time, with tight fine tuning available if anyone wants. Vars can be renamed, I just use temp_ for variables that only get called in maybe 1 or 2 locations
I think I've fixed this for v21.1. I'm a novice at coding but hope it works for everyone! :P (Some of these changes may have been unnecessary - so let me know)
Ruby:
Expand Collapse Copy
#===============================================================================
# * Ambient Pokémon Cries - by Vendily
# Modified by SpaceWestern for v19, Modified by MauGamesLOL for v21.1
#===============================================================================
# This script plays random cries of pokémon that can be encountered on the map
#  for ambiance. It does not activate for maps that don't have pokemon,
#  and optionally only when a switch is active.
# To ensure you get no errors, this script must be under PField_Field. It can
#  be anywhere but it must be under that section. (It's because it uses the
#  Events Module, which is defined in PField_Field)
#===============================================================================
# * The time between cries in seconds (arbitrarily default 60)
# * The variance in time for cries in seconds (arbitrarily default +/-rand(5))
# * The Global Switch that is checked to see if ambiance should be used, set
#      to -1 to always play ambiance if possible
# * The volume to play the cry at (default 65)
# * If the game should play roamer cries, which are the only cries that play
#    should one be found on the current map (default true)
#===============================================================================
module AmbientPokemonCries
  temp_time = [
    90, 90, 90,
    120, 120, 120, 120, 120,
    150, 150, 150,
    180, 180
    ]
  temp_vol = [
    100, 100, 100,
    125, 125, 125, 125, 125,
    150, 150, 150
    ]
  TIME_BETWEEN_CRIES  = temp_time.sample
  RANDOM_TIME_FACTOR  = 15
  AMBIANCE_SWITCH     = -1
  CRY_VOLUME          = temp_vol.sample
  CRY_ROAMERS         = true
end

{... remaining code here ...}
 
Back
Top