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

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Advanced Areas
Version: 1.5
Author: modern algebra
Date: September 26, 2008

Version History


  • Version 1.5 - September 26, 2008 - added the ability to contain randomly moving events to an area
  • Version 1.0 - March 12, 2008

Description


Adds a couple of options to areas. If anyone has any ideas for more, please tell me.

Features

  • NEW - Allows you to contain an event to an area or group of areas
  • Allows you to marry an in-game switch to an area, thus allowing it to be turned on and off at will. This can be useful if say, after some event in your game, like a volcano erupting, you want different monsters to pop up
  • Allows you to set an encounter step for each area. Where two areas conflict, it takes the smallest encounter step

Screenshots

N/A

Instructions

See inside the script

Script


Code: [Select]
#==============================================================================
#  Advanced Areas
#  Version 1.5
#  Author: modern algebra (rmrk.net)
#  Date: September 26, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#    Set up the database below in the Editable Regions. Both are set up in the
#   same way, and they look like this:
#
#      when id
#        rate/switch = value
#
#    You only need to set it if it is not default. If an area has no switch,
#   then don't set it up. If you want the encounter step to be the same as
#   the parent map, then do not set it up. In any case, just so we are clear,
#   I provided a few examples in the Editable Regions. Feel free to
#   replace/delete them once you know what you're doing.
#
#    To restrict events so that they cannot move outside of a given area or
#   areas, then all you need to do is place a comment on the first line of any
#   page of the event you want to restrict, and in that comment put this:
#   \AREA[area id]. If you want him to be able to move freely in more than one
#   area, then you can put as many of those codes there as there are areas he
#   can move in. Thus, if an event had this in his comment:
#
#       \Area[1]\AreA[5]\AREA[9]
#
#     Then that event would have free passage in the Areas 1, 5, and 9, but
#   would not be able to move outside of them.
#==============================================================================

#==============================================================================
# ** RPG::Area
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of changes:
#    new methods - encounter_step, active?
#==============================================================================

class RPG::Area
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Encounter Rate
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def encounter_step
    rate = $game_map.encounter_step
    # Branch by ID
    case @id
    #----------------------------------------------------------------------
    #  EDITABLE REGION
    #----------------------------------------------------------------------
    when 1
      rate = 10
    when 3
      rate = 15
    #----------------------------------------------------------------------
    #  END EDITABLE REGION
    #----------------------------------------------------------------------
    end
    return rate
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Active?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def active?
    switch = 0
    case @id
    #----------------------------------------------------------------------
    #  EDITABLE REGION                                                    
    #----------------------------------------------------------------------
    when 1
      switch = 1
    when 4
      switch = 1
    #----------------------------------------------------------------------
    #  END EDITABLE REGION
    #----------------------------------------------------------------------
    end
    return true if switch == 0
    return $game_switches[switch]
  end
end

#==============================================================================
# ** Game_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased method - encounter_step
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Encounter Step
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_advncd_areas_step_encntr encounter_step
  def encounter_step
    # Get original Map Encounter Step
    encounter_rates = [modalg_advncd_areas_step_encntr]
    # Get all the areas the player is in. For ne
    $data_areas.values.each { |i| encounter_rates.push (i.encounter_step) if i.map_id == @map && $game_player.in_area? (i) }
    return encounter_rates.min
  end
end

#==============================================================================
# ** Game_Player
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased methods - in_area?
#==============================================================================

class Game_Player
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * In Area?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_advnced_areas_area_in? in_area?
  def in_area? (area)
    return false unless area.active?
    modalg_advnced_areas_area_in? (area)
  end
end

==============================================================================
# ** Game_Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    aliased methods - setup, passable?
#    new method - in_area?
#==============================================================================

class Game_Event < Game_Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Event page setup
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_stp_advarea_contain_nfg5 setup
  def setup(new_page)
    @areas.nil? ? @areas = [] : @areas.clear
    # If new page is real
    if new_page != nil
      first_command = new_page.list[0].dup
      # If first line is a comment
      if first_command.code == 108
        loop do
          slice = first_command.parameters[0].slice! (/\\AREA\[(\d+)\]/i) { "" }
          slice == nil ? break : @areas.push ($1.to_i)
        end
      end
    end
    modalg_stp_advarea_contain_nfg5 (new_page)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Determine if Passable
  #     x : x-coordinate
  #     y : y-coordinate
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_contain_areas_adv_pass_hfe passable?
  def passable?(x, y)
    return modalg_contain_areas_adv_pass_hfe (x, y) if @areas == nil || @areas.empty?
    in_area = false
    @areas.each { |i|
      # If within one of the areas, it is passable
      in_area = in_area? ($data_areas[i], x, y)
      break if in_area
    }
    return in_area && modalg_contain_areas_adv_pass_hfe (x, y)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Determine if in Area (Transferred from Game_Player
  #     area : Area data (RPG::Area)
  #     x : x-coordinate
  #     y : y-coordinate
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def in_area?(area, x, y)
    return false if area == nil
    return false unless area.active?
    return false if $game_map.map_id != area.map_id
    return false if x < area.rect.x
    return false if y < area.rect.y
    return false if x >= area.rect.x + area.rect.width
    return false if y >= area.rect.y + area.rect.height
    return true
  end
end

Credit


  • modern algebra

Thanks

  • Jensen for the request

Support


Just post here if you have any errors. I will try to fix them. If you have any ideas about good options to add to the areas, please post here and if I think they are good I will write them in.

Known Compatibility Issues

No known compatibility issues.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: February 11, 2010, 09:52:14 PM by Modern Algebra »

**
Rep:
Level 86
Nice Script :)

and pretty neat, too.

This will be really useful for game that has some situation happens in game and change enemy~

***
Rep:
Level 87
ohheythar :O
Kind of like World of Warcraft; Threat.
The higher your level, the lower levels won't attack you but higher levels will.
It has differences though...

pokeball :)OfflineMale
********
Cheese
Rep:
Level 95
?
Modern, you rock!
Watch out for: HaloOfTheSun

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Kind of like World of Warcraft; Threat.
The higher your level, the lower levels won't attack you but higher levels will.
It has differences though...

That actually sounds more like this script: http://rmrk.net/index.php/topic,24610.0.html

The two are compatible.


Nice Script :)

and pretty neat, too.

This will be really useful for game that has some situation happens in game and change enemy~
Modern, you rock!

Thanks :)
« Last Edit: March 15, 2008, 06:16:41 PM by modern algebra »

********
Shadow Knight
Rep:
Level 91
Ruin that brick wall!
Project of the Month winner for October 2008
Be kind, everyone you meet is fighting a hard battle.

**
Rep: +0/-0Level 86
What's with these people?!?
Oo This will be extremely useful. Do you sit at the computer and endlessly script? XD

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Updated to Version 1.5

You can now contain randomly moving events to an area or group of areas.

**
Rep:
Level 87
Hello, still in the pocess of trying to understand how this script works. I mean what is the use of rate/switch = #? I thought it was for when you stepped inside an area, to turn the switch on. It brings me to my second question, is there any way to update the script to turn a specific switch on when you step inside that area, and/or off when you leave?

Relieves ideas through Rmvx, all the while training to become an enthusiastic pain of a technician in the system's back-side.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
rate is the encounter rate within that area.

switch is the switch that turns on that area. For instance, if you wanted to have a volcano erupt in your game and then have special monsters appear in that vicinity only, you would need to make a new map. With this, you can have the area be ther all along and just not active, then once the volcano erupts you can turn the switch on and the area will be made active.

As for turning a switch on when you enter an area, yes that is possible, but not currently with this script. I could make it if you like, but I'd like to know the reason why you would want such a feature.

**
Rep:
Level 87
Edit: Request removed. Thanks Modern, even silence teaches a lesson.
« Last Edit: December 16, 2008, 11:56:35 PM by brutebasher9 »

Relieves ideas through Rmvx, all the while training to become an enthusiastic pain of a technician in the system's back-side.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
eh? I'm just seeing this topic now. What did you ask for?

**
Rep:
Level 87
Erm..To put the request in a nutshell, it was the possible feature of setting a switch on or off, mainly on, depending on if an event is inside an area ID or not. If  you'd like, I could send you a demo of what I'd like to use it for.

Thanks for your time and patience, Modern.  :)

Relieves ideas through Rmvx, all the while training to become an enthusiastic pain of a technician in the system's back-side.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Oh right. I think I remember reading that, but I forgot. Yeah, it's possible, but I should warn you that I have to use other computers for internet right now, so I won't be able to upload any work I do until after Christmas. It might be an idea to do this through events.

$game_player.in_area? ($data_areas[<area ID>]) is the code for checking if the player is in an area I believe.

If you did a parallel process on the maps where you needed it, you could save which area you are in currently with a variable and have an event that looks like this:

Code: [Select]
Conditional Branch: $game_player.in_area? ($data_areas[$game_variables[x]])
Else
  # Check All other Areas like so:
  Conditional Branch: $game_player.in_area? ($data_areas[y])
    Change BGM
    Variable[x] = y
  Branch END
  # ANd so on for all areas on the map
Branch END
Wait: 2 frames

**
Rep:
Level 87
Hey, sorry for the long wait with replies. I've seen this and tried it before, on the 20th and got thes ame error as before. For some reason, when I enabled the check for areas (when in or out of one, to enable the parallel process to check) it resulted in an error in the script. The error message showed the following in bold:

Script 'Advanced Areas' line 113: NoMethodError occured.

undefined method 'active?' for nil:NilClass


Thanks again for your time and patience, Modern Algebra.

Relieves ideas through Rmvx, all the while training to become an enthusiastic pain of a technician in the system's back-side.