Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Grass Or Bush Script + (Anti-) Rare Candy Scriplet

Grass Or Bush Script - GOBS
&
(Anti-) Rare Candy Scriplet
by Kyonides-Arkanthos



Features

This script lets you fight / encounter monsters in a Pokemon fashion by walking only in grass or bush tiles only.

The newest version (1.0.1) now offers the possibility to create 7 different "monster areas" in any map. Please read the built in instructions to learn more about this new feature. You may also disable the script for some specific maps like Pokemon-like dungeons if deemed necessary.



Instructions

Check the script, it includes comments for a reason.

Script

Version 1.0.1
[rgss]#  Grass Or Bush Scriptlet - GOBS
#  by Kyonides-Arkanthos
#  v 1.0.1 - 08.24.2010
#  v 1.0.0 - 08.11.2010
 
#  At the Database window on the Tilesets tab you can set some tiles
#  bush flag on and / or set their terrain tag number between 1 and 7.
#  This will simulate the existence of Monster Areas in your game.
 
#  You can also let the RPG Maker XP monster encounter system work as
#  usual in any (Pokemon-like) dungeons.
 
module GrassOrBush
  # Enter all (dungeons) MapIDs where monster encounters are enabled
  ENCOUNTERS_ENABLED = []
  # Monsters Area : [ MapID, Terrain Tag ] => Monsters : [ Monster Troop IDs ]
  MONSTERS = {
    [1,1] => [1..3],
    [1,2] => [4,5,6,8],
  }
end
 
class Game_Player
  def grass_or_bush?
    GrassOrBush::ENCOUNTERS_ENABLED[$game_map.map_id] or
    $game_map.bush?(@x, @y) or $game_map.terrain_tag(@x, @y) > 0
  end
 
  def update
    # If tile has a bush flag or a grass terrain tag, encounters are allowed
    $game_system.encounter_disabled = grass_or_bush? ? false : true
    last_moving = moving?
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      case Input.dir4
      when 2; move_down
      when 4; move_left
      when 6; move_right
      when 8; move_up
      end
    end
    last_real_x = @real_x
    last_real_y = @real_y
    super
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
      $game_map.scroll_down(@real_y - last_real_y)
    elsif @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
      $game_map.scroll_left(last_real_x - @real_x)
    elsif @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
      $game_map.scroll_right(@real_x - last_real_x)
    elsif @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
      $game_map.scroll_up(last_real_y - @real_y)
    end
    unless moving?
      if last_moving
        result = check_event_trigger_here([1,2])
        if result == false
          # Disregard if debug mode is ON and ctrl key was pressed
          unless $DEBUG and Input.press?(Input::CTRL)
            # Encounter countdown will work if Encounters are allowed
            if @encounter_count > 0 and !$game_system.encounter_disabled
              @encounter_count -= 1
            end
          end
        end
      end
      if Input.trigger?(Input::C)
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
      end
    end
  end
end
 
class Game_Map
  def encounter_list
    tag = terrain_tag($game_player.x, $game_player.y)
    monsters = GrassOrBush::MONSTERS[[@map_id, tag]]
    monsters = monsters[0].to_a if monsters[0].is_a?(Range)
    return monsters
  end
end
[/rgss]

Version 1.0.0
[rgss]#  Grass Or Bushes Scriptlet - GOBS
#  by Kyonides-Arkanthos
#  v 1.0.0 - 08.11.2010
 
#  At the Database window on the Tilesets tab you can either...
#      set a specific tile or tiles bush flag on
#  or...
#      pick a terrain tag number between 1 and 7 for one or two tiles
 
#  If you chose the former, edit the TERRAIN_TAG value accordingly (see below)
class Game_Player
  TERRAIN_TAG = 1
  def tile_is_grass_or_bush?
    $game_map.bush?(@x, @y) or TERRAIN_TAG == $game_map.terrain_tag(@x, @y)
  end
 
  def update
    # If tile has a bush flag or a grass terrain tag, encounters are allowed
    $game_system.encounter_disabled = tile_is_grass_or_bush? ? false : true
    last_moving = moving?
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      case Input.dir4
      when 2; move_down
      when 4; move_left
      when 6; move_right
      when 8; move_up
      end
    end
    last_real_x = @real_x
    last_real_y = @real_y
    super
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
      $game_map.scroll_down(@real_y - last_real_y)
    elsif @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
      $game_map.scroll_left(last_real_x - @real_x)
    elsif @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
      $game_map.scroll_right(@real_x - last_real_x)
    elsif @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
      $game_map.scroll_up(last_real_y - @real_y)
    end
    unless moving?
      if last_moving
        result = check_event_trigger_here([1,2])
        if result == false
          # Disregard if debug mode is ON and ctrl key was pressed
          unless $DEBUG and Input.press?(Input::CTRL)
            # Encounter countdown will work if Encounters are allowed
            if @encounter_count > 0 and !$game_system.encounter_disabled
              @encounter_count -= 1
            end
          end
        end
      end
      if Input.trigger?(Input::C)
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
      end
    end
  end
end
[/rgss]
_____________________________________________________________

Remember I also provided you with a Rare Candy (and Anti Rare Candy) Scriptlet for your Pokemon games.
_____________________________________________________________

Features

Here you can find 2 versions of the same scriptlet that will allow you to use an item to level up or down your hero at will.

Instructions

Go to the items database and create 1 or 2 new items (just in case you want to add the Anti Rare Candy one, too). Make sure their scopes are equal to One Ally. The rest if up to you. Later copy either one of the scriptlets and testplay your game.

Scriptlets

Rare Candy Only Version

[rgss]module MoreEffects
  RARE_CANDY_ID = 33
end
 
class Game_Battler
  alias kyon_rare_candy_game_battler_item_effect item_effect
  def item_effect(item)
    if item.id == MoreEffects::RARE_CANDY_ID && item.scope == 3 &&
      self.level < 99 && self.hp > 0
      self.level += 1
      return true
    end
    kyon_rare_candy_game_battler_item_effect(item)
  end
end
[/rgss]


Rare Candy + Anti Rare Candy Version

[rgss]module MoreEffects
  # IDS de Caramelo Raro, Anti Caramelo Raro
  CANDIES_IDS = [33, 34]
end
 
class Game_Battler
  alias kyon_rare_candy_game_battler_item_effect item_effect
  def item_effect(item)
    if ((item.id == MoreEffects::CANDIES_IDS[0] && self.level < 99) or
      (item.id == MoreEffects::CANDIES_IDS[1] && self.level > 1)) &&
      item.scope == 3 && self.hp > 0
      self.level += item.id == MoreEffects::CANDIES_IDS[0] ? +1 : -1
      return true
    end
    kyon_rare_candy_game_battler_item_effect(item)
  end
end
[/rgss]

Rare and Anti Rare Candy Version with Restrictions
[rgss]module MoreEffects
  # Rare Candy & Anti Rare Candy IDS
  CANDIES_IDS = [33, 34]
  LVLUPDOWN_LIMITS = [5,5]
end
 
class Game_Actor
  include MoreEffects
  alias kyon_pkmn_candies_setup setup
  alias kyon_rare_candy_game_battler_item_effect item_effect
  def setup(actor_id)
    kyon_pkmn_candies_setup(actor_id)
    @candies_limits = CANDIES_LVLUPDOWN_LIMIT
  end
 
  def item_effect(item)
    if item.scope == 3 && self.hp > 0
      if CANDIES_IDS.include?(item.id) && @level.between?(1, 99)
        index, level = CANDIES_IDS.index(item.id), @level
        return false if LVLUPDOWN_LIMITS[index] == 0
        @candies_limits[index] -= 1 if LVLUPDOWN_LIMITS[index] != -1
        return false if @candies_limits[index] == 0
        @level += 1 if index == 0 and @level < 99
        @level -= 1 if index == 1 and @level > 1
        return level == @level
      end
    end
    kyon_rare_candy_game_battler_item_effect(item)
  end
end
[/rgss]

Author's Notes

Yeah, I know these are some extremely simple but useful scriptlets.
 

regi

Sponsor

I'm surprised we haven't seen one of these with the number of Pokemon enthusiasts. Nice script.

A few comments: shouldn't you include a "return" in "def tile_is_grass_or_bush?" Also, instead of overwriting Game_Player update, wouldn't an alias do the job while allowing for better compatibility?
 
Well, the answers are No and No.

return is optional in Ruby and RGSS(2). Ruby always return the last line (ignoring the "end" lines of course).

If I used an alias in Game_Player#update it'd have always substracted 1 to @encounter_count before my second modification (inside unless $DEBUG and Input.press?(Input::CTRL)) could be executed, which is exactly what I had to avoid to make it work as any Pokemaniac would have expected. So I had no choice but to modify it w/o aliasing it.

I mean, whenever you need to modify something in the middle of an existing method, you can't use alias at all because the additions to the aliased methods could only be executed before or after the original one is executed.
 

regi

Sponsor

Ah, didn't realize you'd made a second change to the method. And about the return, you learn something new every day.

Last question: as you're modifying the default "Encounter Disable" method (Game_System) within the update method, wouldn't the event command to disable them be useless? It's not a huge deal, but perhaps someone wanted to remove encounters on a house's front yard lawn.
 
Obviously it'd be useless because the house map should neither have a single tile with a bush flag turned on nor a grass terrain tag (this one is just a single number between 1 and 7). Unless some Pokemaniac really wants to setup their map the wrong way, there's no need to manually disable the encounters via eventing. They should just follow the script instructions and that's pretty much all.

Pokemon games included one or more tiles for the soil (no monster encounters allowed), one grass tile and one tall grass tile. There's not such thing a front or back yard full of grass or tall grass where you can't meet a Pokemon.
 
Sure but who cares? Really, how many people dislike eventing like I do? Of course, people who are used to event anything wouldn't need it, but I don't care. I provided you with a scripted option. It's all about options or choices. So if you want to tell us about that event demo, then go ahead and post it in the Eventer's Corner subforum if it isn't there already but don't lose your time posting it here. Eventers wouldn't find it here.
 
I just added a new version of the Rare and Anti Rare Candy scriptlet, this one also includes a method to restrict the number of times a Pokemon? would be able to level up or down.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top