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

Always in bush and in water

  • 315
    Posts
    4
    Years
    UPDATED TO VERSION 1.2

    This script is based on "Always on bush" by KleinStudio

    FEATURES: This script is based on "Always on bush" by KleinStudio, see wahpokemon.com and pokemonfangames.com
    • game_characters don't stay on bushes nor on water, which could be useful for overworld encounters in water.
    • bug concerning sand-tiles (since version 1.1, fixed by भाग्य ज्योति - thank you for your help).
    • bug concerning map borders (since version 1.2).

    INSTALLATION:
    1. Insert a new script file above main in the RPGMakerXP script editor. Name it always_on_bush & copy the code in the following spoiler section into it.
      Spoiler:
    2. If you use Pokemon Essentials v19 then modify the code as described in following spoiler section (thanks to Cony)
      Spoiler:
     
    Last edited:
    This script is based on "Always on bush" by KleinStudio

    However there is some additional editing by me to assure that it is drag and drop and to assure that game_characters don't stay on water.
    This might be useful for overworld encounters in water.

    Installation: As simple as it can be. Insert a new script file above main in the RPGMakerXP script editor. Name it always_on_bush & copy this code into it.

    Code:
    #===============================================================================
    # Always on bush by KleinStudio
    # wahpokemon (dot) com
    # pokemonfangames (dot) com
    #
    # additional editing by derFischae 
    # to assure that game_characters don't stay on water
    # which could be useful for overworld encounters in water.
    #
    # Installation: As simple as it can be. Insert a new script file above main in
    # the RPGMakerXP script editor. Name it always_on_bush & copy this code into it.
    #===============================================================================
    
    #===============================================================================
    # overrides the method bush_depth in the class Game_Character
    #===============================================================================
    
    class Game_Character
    # The original code
    #  def bush_depth
    #    return 0 if @tile_id>0 or @always_on_top
    #    if @jump_count <= 0
    #      xbehind=(@direction==4) ? @x+1 : (@direction==6) ? @x-1 : @x
    #      ybehind=(@direction==8) ? @y+1 : (@direction==2) ? @y-1 : @y
    #      return 32 if self.map.deepBush?(@x,@y) and self.map.deepBush?(xbehind,ybehind)
    #      return 12 if self.map.bush?(@x,@y) and !moving?
    #    end
    #    return 0
    #  end
    
    # Die von KleinStudio geaenderte Version
      def bush_depth
        if @tile_id > 0 or @always_on_top
          return 0
        end
        xnext=(@direction==4) ? @x-1 : (@direction==6) ? @x+1 : @x
        ynext=(@direction==8) ? @y-1 : (@direction==2) ? @y+1 : @y
    
        xbehind=(@direction==4) ? @x+1 : (@direction==6) ? @x-1 : @x
        ybehind=(@direction==8) ? @y+1 : (@direction==2) ? @y-1 : @y
    
        if @jump_count <= 0 and self.map.bush?(@x, @y) and 
          !self.map.bush?(xbehind, ybehind) and !moving?
          return 12 
        elsif @jump_count <= 0 and self.map.bush?(@x, @y) and
          self.map.bush?(xbehind, ybehind)
          return 12
        # Hier habe ich etwas fuer das wasser hinzugefuegt
        elsif @jump_count <= 0 and self.map.water?(@x, @y) and 
          !self.map.water?(xbehind, ybehind) and !moving?
          return 12 
        elsif @jump_count <= 0 and self.map.water?(@x, @y) and
          self.map.water?(xbehind, ybehind)
          return 12
        else
          return 0
        end
      end
    end
    
    #===============================================================================
    # overrides the method bush_depth in the class Game_Player
    #===============================================================================
    
    class Game_Player < Game_Character
      def bush_depth
        return 0 if @tile_id > 0 or @always_on_top
        xbehind=(@direction==4) ? @x+1 : (@direction==6) ? @x-1 : @x
        ybehind=(@direction==8) ? @y+1 : (@direction==2) ? @y-1 : @y
        if !$game_map.valid?(@x,@y) || !$game_map.valid?(xbehind,ybehind)
          return 0 if !$MapFactory
          newhere=$MapFactory.getNewMap(@x,@y)
          newbehind=$MapFactory.getNewMap(xbehind,ybehind)
          if $game_map.valid?(@x,@y)
            heremap=self.map; herex=@x; herey=@y
          elsif newhere && newhere[0]
            heremap=newhere[0]; herex=newhere[1]; herey=newhere[2]
          else
            return 0
          end
          if $game_map.valid?(xbehind,ybehind)
            behindmap=self.map; behindx=xbehind; behindy=ybehind
          elsif newbehind && newbehind[0]
            behindmap=newbehind[0]; behindx=newbehind[1]; behindy=newbehind[2]
          else
            return 0
          end
          if @jump_count <= 0 and heremap.deepBush?(herex, herey) and
                                  behindmap.deepBush?(behindx, behindy)
            return 32
          elsif @jump_count <= 0 and heremap.bush?(herex, herey) and !moving?
            return 12
          else
            return 0
          end
        else
          if @tile_id > 0 or @always_on_top
            return 0
          end
          xnext=(@direction==4) ? @x-1 : (@direction==6) ? @x+1 : @x
          ynext=(@direction==8) ? @y-1 : (@direction==2) ? @y+1 : @y
    
          xbehind=(@direction==4) ? @x+1 : (@direction==6) ? @x-1 : @x
          ybehind=(@direction==8) ? @y+1 : (@direction==2) ? @y-1 : @y
    
          if @jump_count <= 0 and self.map.bush?(@x, @y) and 
            !self.map.bush?(xbehind, ybehind) and !moving?
            return 12 
          elsif @jump_count <= 0 and self.map.bush?(@x, @y) and
            self.map.bush?(xbehind, ybehind)
            return 12
          else
            return 0
          end
        end
      end
    end
    
    #===============================================================================
    # adds new method water?(x,y) to the class Game-Map (originally defined in script Game_Map)
    #===============================================================================
    
    class Game_Map
      def water?(x,y)
        if @map_id != 0
          for i in [2, 1, 0]
            tile_id = data[x, y, i]
            if tile_id == nil
              return false
            elsif PBTerrain.isBridge?(@terrain_tags[tile_id]) && $PokemonGlobal &&
                  $PokemonGlobal.bridge>0
              return false
            elsif #@passages[tile_id] & 0x40 == 0x40 &&
                 (@terrain_tags[tile_id]==PBTerrain::Water ||
                  @terrain_tags[tile_id]==PBTerrain::StillWater ||
                  @terrain_tags[tile_id]==PBTerrain::DeepWater ||
                  @terrain_tags[tile_id]==PBTerrain::WaterfallCrest ||
                  @terrain_tags[tile_id]==PBTerrain::Waterfall)
              return true
            end
          end
        end
        return false
      end
    end

    A fantastic script. But, can you modify your script to show complete sprites of Pokemon with Type-Flying or Ability-Levitate. Because, it looks very bad when we surf and see pidgeotto swimming too.
     
    A fantastic script. But, can you modify your script to show complete sprites of Pokemon with Type-Flying or Ability-Levitate. Because, it looks very bad when we surf and see pidgeotto swimming too.

    RpgMakerXP doesn't know what a placed event does before the event gets activated during runtime. So for example, you can place two events on the map. Both events have the same Koffing sprite and will cause a wild battle with Koffing. But one of them has the ability levitate and the over doesn't have that ability. RpgMakerXP can't decide which of the 2 events have this ability and need to fly above water. But you can set it manually for that one event. Simply set the "allways on top" flag in the event editor.

    There is another thing you have to think about. There are flying pokemon which have an walking animation as there overworld sprite, for example the ordinary sprite for Pidgy. It would look strange if these pokemon won't sink in water and still walk on that. RpgMakerXP can't decide by its own which flying pokemon need to be on top of water and which should be in water. But you can manually, by setting the "allways on top" flag. By the way, pokemon with flying sprite should also fly above grass and not in grass.

    Let's think about Lapras. It's sprite is already a swimming sprite. The sprite should not sink into water but stay above. So there are also non-flying, non-levitate pokemon which have to be above water.

    So with normal usage of pokemon essentials, the only thing to do is checking the "allways on top" flag. It gets more complicate if you use scripts, that generate events on its own. For example the visible overworld wild encounter script https://www.pokecommunity.com/threads/429019 does that.
    Then you need to tell the script which at runtime generated events needs the "allways on top" flag set to true and which one not.

    Or, here I come up with a even better solution. You can add a list containing all names of sprites which should not sink on water and stand above grass.
    The list has to be done only once and depends on your sprites. So this also works for fakemon sprites.

    Add the following code
    Code:
    ONTOPSPRITES = ["150", "150s"] # default []
    #contains the names of sprites which shall not sink in water and shall levitate above grass.
    For example Mew leviatates above ground and water and its sprites in Graphics/Characters are "150.png" and "150s.png", then include the strings "150" and "150s" (including the "-signs)
    in the settings script section of Pokemon Essentials or at the top of the allways in bush and water script and fill in all the names of sprites which shall not sink in water and shall levitate above grass. See in the code section how to do this.

    Then, replace the three code snippets
    Code:
    if @tile_id > 0 or @always_on_top
    in the allways in bush and water script by
    Code:
    if @tile_id > 0 or @always_on_top or ONTOPSPRITES.include?(@character_name)

    This should work. I haven't tested it. So I would be glad if you let me know that it works.
     
    No,no , I mean the folowers. The Pokemons following us. I dont want to see the Followers with Flying type and levitate show half sprites. I know LOL that RPGMAKERXP dont know anything about Pokemons. I want that this script of yours show complete sprites of flying and levitated follower pokemons. Or should I edit it in the Following Script by Mej71? Or it can be editted here?
     
    This script is based on "Always on bush" by KleinStudio

    However there is some additional editing by me to assure that it is drag and drop and to assure that game_characters don't stay on water.
    This might be useful for overworld encounters in water.

    Can you make a condition that checks the pokemon type and ability and then only runs your script? I am learning so dont mind if I said something wrong or irrelevant.
     
    Can you make a condition that checks the pokemon type and ability and then only runs your script? I am learning so dont mind if I said something wrong or irrelevant.

    It is not possible that this script can check the pokemon type or the ability. This script can only check the parameters of a Game_Character, Game_Event or Game_Player. This includes a character_name or it's position on the map or it's move route for example. But it can't check the pokemon type nor an ability, since these events are just Game_Characters or Game_Events but not PokeBattle_Pokemon and don't have these parameters.

    So that's way I come up with that list. You have to check other parameters and decide which bush_depth you need on that parameters. And the best way seems to be the character_name, since the character_name corresponds to the sprite you use (with a walk or fly movement).

    Concerning Follower Pokemon by Mej71. If you followed the instructions in https://www.pokecommunity.com/threads/360846 then you made an event named by "Dependent". Maybe you can check for this name and return 0 for follower pokemon in water. Simply replace this line of code
    Code:
    # Hier habe ich etwas fuer das wasser hinzugefuegt
    by
    Code:
    elsif @name == "Dependent"
          return 0
    in the allways in bush and water script.
    I haven't tried it, and can't try it by my own, since I don't use follower pokemon. So I would be glad to hear if it works.

    By the way, I thought that follower pokemon return into its pokeball while surfing.
     
    Add the following code
    Code:
    ONTOPSPRITES = ["150", "150s"] # default []
    #contains the names of sprites which shall not sink in water and shall levitate above grass.
    For example Mew leviatates above ground and water and its sprites in Graphics/Characters are "150.png" and "150s.png", then include the strings "150" and "150s" (including the "-signs)
    in the settings script section of Pokemon Essentials or at the top of the allways in bush and water script and fill in all the names of sprites which shall not sink in water and shall levitate above grass. See in the code section how to do this.

    Then, replace the three code snippets
    Code:
    if @tile_id > 0 or @always_on_top
    in the allways in bush and water script by
    Code:
    if @tile_id > 0 or @always_on_top or ONTOPSPRITES.include?(@character_name)

    This should work. I haven't tested it. So I would be glad if you let me know that it works.

    Yes, this workd like a charm. Thank you DerFischae.

    Concerning Follower Pokemon by Mej71. If you followed the instructions in https://www.pokecommunity.com/threads/360846 then you made an event named by "Dependent". Maybe you can check for this name and return 0 for follower pokemon in water. Simply replace this line of code
    Code:
    # Hier habe ich etwas fuer das wasser hinzugefuegt
    by
    Code:
    elsif @name == "Dependent"
          return 0
    in the allways in bush and water script.
    I haven't tried it, and can't try it by my own, since I don't use follower pokemon. So I would be glad to hear if it works.

    I cant understand what you said. Probably this line- # Hier habe ich etwas fuer das wasser hinzugefuegt
     
    Yes, this workd like a charm. Thank you DerFischae.



    I cant understand what you said. Probably this line- # Hier habe ich etwas fuer das wasser hinzugefuegt

    The line of code in the allways in bush and water
    is a commentary in ruby. I forgot to remove or translate it. It's written in german, meaning "Here, I added something for water". This line of code is not relevant in the script and can be removed. If you want that follower pokemon in water don't sink, then you can add the following code
    Code:
    elsif @name == "Dependent"
          return 0
    right below that german commentary.
    With this modification, this script searches for an event named Dependent, which is the event of your follower pokemon, and sets that this event sinks 0 in water.
    Since the solution with the list ONTOPSPRITES works fine, you can keep it with that solution.
     
    Sorry to bother you again. Btut here is my Pikachu hidden in a sand (and there is water under sand). Please somehow disable your script from working on sand tiles.
    [PokeCommunity.com] Always in bush and in water

    The diglett looks comfortable, but it might sink.
    [PokeCommunity.com] Always in bush and in water
     
    Sorry to bother you again. Btut here is my Pikachu hidden in a sand (and there is water under sand). Please somehow disable your script from working on sand tiles.
    [PokeCommunity.com] Always in bush and in water

    The diglett looks comfortable, but it might sink.
    [PokeCommunity.com] Always in bush and in water

    It's a Terrain Tag issue. Those sand tiles are using the Water Terrain Tag. You can see how 'isBridge?' is used in the script and add a new Terrain Tag which has same Terrain Properties as Water but is exempted from the underwater script.
     
    I solved the problem. I edited the script so that Pokemons dont sink in Sand.
    You might add it in the main post.
    Search
    Code:
    elsif PBTerrain.isBridge?(@terrain_tags[tile_id]) && $PokemonGlobal &&
                  $PokemonGlobal.bridge>0
              return false
    And add this below it-
    Code:
    elsif (@terrain_tags[tile_id]==PBTerrain::Sand)
              return false

    Thank you for your work. I added it to the main post.
     
    Last edited:
    [Sun Mar 14 15:52:55 Eastern Daylight Time 2021]
    [Pokémon Essentials version 18.1.dev]
    Exception: TypeError
    Message: no implicit conversion from nil to integer

    Backtrace:
    Game_Map:277:in `[]'
    Game_Map:277:in `bush?'
    Game_Map:275:in `each'
    Game_Map:275:in `bush?'
    always_on_bush:43:in `bush_depth'
    Sprite_Character:102:in `shadow_update'
    Sprite_DynamicShadows:157:in `update_or'
    Tilemap_Perspective:434:in `follow_update'
    Follower_Main:974:in `update'
    Follower_Main:1084:in `update'

    I think there might be a problem with the Always in bush and in water script cause I'm getting this error. Is this because I'm using a follow pokemon script?

    Indeed, there was an error in the script. This crash can happen if there is a Game_Character at the border of the map. Now, I corrected the bug and updated the "always in bush and in water" script to version 1.2.
     
    To use this in v19 just override the first
    Code:
    class Game_Character
    with
    Code:
    class Game_Player < Game_Character
     
    Can't seem to make it work in v19.1 :(

    Did exactly what you said (copy + paste script into new "always_on_bush" script section right above main and replaced the line of code) but the Pokémon still spawn on top of the water instead of sinking in and the Pokémon in grass still hover over it while taking steps, any ideas how to fix it? I'm not getting any errors, it just doesn't do anything :/
     
    Can't seem to make it work in v19.1 :(

    Did exactly what you said (copy + paste script into new "always_on_bush" script section right above main and replaced the line of code) but the Pokémon still spawn on top of the water instead of sinking in and the Pokémon in grass still hover over it while taking steps, any ideas how to fix it? I'm not getting any errors, it just doesn't do anything :/

    This script is for PE v17.2. It is by default not compatible with v19.1.
    v19.1 does not read out the code in the script section anymore. So if you want to update the script, to make it work with v19.2, then you have to rewrite it as a plugin and place it in a new folder in the plugins folder of your directory.

    For more informations about plugins read the comment about plugin folder here: https://github.com/Maruno17/pokemon...ta/Scripts/001_Technical/005_PluginManager.rb
     
    Back
    Top