RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VX] Recognizing an Area in script.

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 69
RMRK Junior
Ok, so I want to make a skill that recognizes that your in an area (where you load encounters for random battles) and it will display a window that tells the player what monsters are in the area. ( Sort of a tracking skill ).  Sorry about the many questions.. but can someone tell me how to get it so that the script realizes what area your in?

**
Rep:
Level 83
To recognize in which area you are , you can use my script :
http://rmrk.net/index.php/topic,34614.0.html
But it don't tell what monsters are in this area .
You can use my scripts freely . but not for commercial use .
:ccbync:
Don't encrypt your game !!!
Want to give me credit ? Easy ,add me in your game :

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
Although there are a lot of scripts that could tell you what area that your character is in (dricc's AreaPlus, BulletXT's Do_Something_In_Area; MA has an area script as well), I don't think any return what monsters are in that area without a little editing. I just so happened to have my Local Area scriplets laying around, so I tossed something together for you. I'll leave the building of the tracking window to you. I've commented in several places to show where things should go.



Code: [Select]
class Game_Map
 
  attr_accessor :local_areas
 
  #--------------------------------------------------------------------------
  # * Initialize                                                    [ Alias ]
  #--------------------------------------------------------------------------
  alias ex_local_areas_gm_initialize initialize unless $@
  def initialize
    ex_local_areas_gm_initialize
    @local_areas = []
  end
 
  #--------------------------------------------------------------------------
  # * Setup                                                         [ Alias ]
  #     map_id : map ID
  #--------------------------------------------------------------------------
  alias ex_local_areas_gm_setup setup unless $@
  def setup(*args)
    ex_local_areas_gm_setup(*args)
    load_local_areas
  end
 
  #--------------------------------------------------------------------------
  # * Frame Update                                                  [ Alias ]
  #--------------------------------------------------------------------------
  alias ex_gm_update update unless $@
  def update
    ex_gm_update
    # We'll narrow down where the request is coming from first before we
    # do any further code.
    #
    # Maybe even do an 'if' statement to encapsulate the 'case' statement
    # as well. Have the 'Tracking' skill set a variable and check against
    # that before it proceeds. That would keep the game from checking
    # @map_id endlessly without real need.
    case @map_id
      # When a request comes from the Map with an ID of 1 ...
      #  (Right click on the map underneath the main project folder, then click
      #  on 'Map Properties'. Look at the title bar and it will say what ID the
      #  map has.)
      when 1
        # When the player is within a certain area and is not moving ...
        if $game_player.within_local_area?("AreaName") and
           $game_player.moving? == false

          # 'Tracking' Window Pop-Up here.
          # Remember that this area gets updated around 60 times each second,
          # so have another 'if' statement to check if the 'Tracking' window is
          # already open before the script tries to open another one.
          #
          # Array of Troop names can be returned by using the following :
          #
          # $game_map.get_area_encounters("AreaName")

        end

    end
  end

  #--------------------------------------------------------------------------
  # * Load Local Areas                                                [ New ]
  #--------------------------------------------------------------------------
  def load_local_areas
    @local_areas.clear
    for area in $data_areas.values
      @local_areas.push(area) if @map_id == area.map_id
    end
  end

  #--------------------------------------------------------------------------
  # * Get Local Area                                                  [ New ]
  #   area_name      - Name of Area
  #   param          - [0] Returns an <Area> object.
  #                  - [1] Returns the Area ID number.
  #-------------------------------------------------------------------------- 
  def get_local_area(area_name, param)
    for area in @local_areas
      if area.name == area_name
        case param
          when 0
            return area
          when 1
            return @local_areas.index(area)
        end
      end
    end
    return false
  end

  #--------------------------------------------------------------------------
  # * Get Area Encounters                                             [ New ]
  #   area_name      - Name of Area
  #--------------------------------------------------------------------------
  def get_area_encounters(area_name)
    area_data       = get_local_area(area_name, 1)
    area_encounters = @local_areas[area_data].encounter_list
    troop_names     = []
    for troop in area_encounters
      troop_names.push($data_troops[troop].name)
    end
    return troop_names
  end
 
end


class Game_Player < Game_Character

  #--------------------------------------------------------------------------
  # * Within Local Area?                                              [ New ]
  #   area_name      - Name of Area
  #--------------------------------------------------------------------------
  def within_local_area?(area_name)
    area_data = $game_map.get_local_area(area_name, 0)
    return false unless area_data
    return in_area?(area_data)
  end

end
« Last Edit: July 13, 2011, 08:16:55 PM by Exhydra »

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

***
Rep:
Level 69
RMRK Junior
Thank you again, Exhydra, your a life saver, I'll play with it later. :)  I'm sure I'll have more questions so I'll prolly post again later when I'm messing around with it.  Thanks again!

**
Rep:
Level 68
Infinite imagination
Wouw, this seems really cool :D I'd love to see what comes out of this :)

***
Rep:
Level 69
RMRK Junior
Yes, what I'm going to be working on is a script that gets called upon using a skill, such as "Tracking" or "Knowledge: Nature",  I want it to recognize the area your in and display text saying what monsters in the area.  My game will be composed of a d20 skill system that allows you to level up skills in certain talents and up the percentage chance that they will work. 

The tracking skill will be useful for people in finding where the monsters are that they need that drop items for my crafting skills and synthesis shops.