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.
[VXA] Event-Based Regions & Terrains

0 Members and 2 Guests 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
Event-Based Regions & Terrains
Version: 1.0.0
Author: modern algebra
Date: 2014 April 23

Version History


  • <Version 1.0.0> 2014.04.23 - Original Release

Description


This script allows you to assign a region ID and/or terrain tag to any event. When this is done, any tile upon which that event steps will inherit that region ID and/or terrain tag for as long as the event is present on it. If more than one event with this feature is on the same tile, then it will have the region ID or terrain tag which is highest.

Features

  • Allows you to create moving regions or terrains.
  • Can be turned on and off simply by switching the event to another page, thus allowing for tiles that change terrain and region over time

Instructions

Insert this script into the Script Editor (F11), below Materials but still above Main.

Script


Code: [Select]
#==============================================================================
#    Event-Based Regions & Terrains
#    Version: 1.0.0
#    Author: modern algebra (rmrk.net)
#    Date: 23 April 2014
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to assign a region ID and/or terrain tag to any
#   event. When this is done, any tile upon which that event steps will inherit
#   that region ID and/or terrain tag for as long as the event is present on
#   it. If more than one event with this feature is on the same tile, then it
#   will have the region ID or terrain tag which is highest.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Insert this script into its own slot in the Script Editor, below Materials
#   but still above Main.
#
#    In order to assign a region ID to an event, create a comment in the first
#   event command of the page and use the following code:
#
#      \region[x]
#
#   Replace x with any integer from 1-63.
#
#    In order to assign a terrain tag to an event, make a comment the first
#   event command of the page and use the following code:
#
#      \terrain[x]
#
#   Replace x with any integer from 0-7, or higher if using a script that
#   permits that.
#
#    The region ID and terrain tag will apply only for the page in which they
#   are created. Once a new page is active, they will revert.
#==============================================================================

$imported = {} unless $imported
$imported[:MA_EventBasedRegions] = true

#==============================================================================
# ** Game_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - terrain_tag; region_id
#    new method - get_event_region
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Terrain Tag
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maebr_terntag_7uj2 terrain_tag
  def terrain_tag(x, y, *args, &block)
    event_tt = maebr_event_var(x, y, :maebr_terrain_tag)
    return event_tt if event_tt > 0
    maebr_terntag_7uj2(x, y, *args, &block) # Call Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Region ID
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maebr_reginid_5sr9 region_id
  def region_id(x, y, *args, &block)
    event_rid = maebr_event_var(x, y, :maebr_region_id)
    return event_rid if event_rid > 0
    maebr_reginid_5sr9(x, y, *args, &block) # Call Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Event-Based Variable for Region ID or Terrain Tag
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maebr_event_var(x, y, var)
    ([0] + events_xy(x,y).collect { |event| event.send(var) }).max
  end
end

#==============================================================================
# ** Game_Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new public instance variables - maebr_region_id; maebr_terrain_tag
#    aliased methods - init_public_members; setup_page_settings;
#      clear_page_settings
#==============================================================================

class Game_Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor(:maebr_region_id, :maebr_terrain_tag)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize Public Members
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maebr_inizpublcmems_8bn3 init_public_members
  def init_public_members(*args, &block)
    maebr_inizpublcmems_8bn3(*args, &block) # Call Original Method
    @maebr_region_id = 0
    @maebr_terrain_tag = 0
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Clear Event Page Settings
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maebr_clrpagesets_3vw4 clear_page_settings
  def clear_page_settings(*args, &block)
    maebr_clrpagesets_3vw4(*args, &block) # Call Original Method
    @maebr_region_id = 0
    @maebr_terrain_tag = 0
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Up Event Page Settings
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maebr_setppagttings_4cu6 setup_page_settings
  def setup_page_settings(*args, &block) # Call Original Method
    maebr_setppagttings_4cu6(*args, &block)
    # Collect first Comment
    first_comment, i = "", 0
    while !@list[i].nil? && (@list[i].code == 108 || @list[i].code == 408)
      first_comment += @list[i].parameters[0] + "\n"
      i += 1
    end
    @maebr_region_id = first_comment[/\\REGION\s*\[\s*(\d+)\s*\]/im] ? $1.to_i : 0
    @maebr_terrain_tag = first_comment[/\\TERRAIN\s*\[\s*(\d+)\s*\]/im] ? $1.to_i : 0
  end
end

Credit


  • modern algebra

Thanks

  • Fizzly, for the request

Support


Please post in this topic at RMRK.net if you have any questions, suggestions, error reports, or comments about this script. It is perfectly fine to post here even if this topic has not been posted in for a very long time.

Please do not message me privately, as any concerns you have are likely shared by others and they will benefit from our correspondence being public. Additionally, I am occasionally absent, and posting publicly will allow other members to assist you when I am unable to do so quickly.

Known Compatibility Issues

I am currently unaware of any compatibility bugs, but if you are using this script with my Terrain Features script, then how it interacts with the terrain substitution feature depends on whether it is above or below it. If below it, then you should just set \terrain[] directly to the tag, even if it is > 7. If above it, you should set it to whatever tag is substituted for the tag you want.

Terms of Use


I adopt the Terms of Use for RMVXA Scripts Database.
« Last Edit: April 23, 2014, 11:43:10 AM by modern algebra »

***
Rep:
Level 89
Works like a charm, modern! You're the best. Definitely credit you. Thank you!

Edit: Btw I'm using so many other scripts and it still works!  :tpg:

Edit: Oookay, found a bug! Teleport doesn't works. I mean that build-in teleport command, screen just goes black and nothing happens. Could you please check this out?
« Last Edit: April 23, 2014, 09:37:05 PM by Fizzly »
Regards,
Mike

*
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
It works for me when I try it in a demo with just my script, so it might be an incompatibility. Can you try and recreate the issue in a new project and share that with me?

***
Rep:
Level 89
Of course, I'll check this out when I'll return home and let you know. Thank you.

Edit: Yes, my bad. It is some scripts incompatibility, i'll try to find with which one. Thanks!
« Last Edit: April 24, 2014, 08:59:52 PM by Fizzly »
Regards,
Mike

*
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
Any luck?

***
Rep:
Level 89
Sorry for the late reply, but didn't found which one causes problem - just removed a lot of them. But now it works! :)
Regards,
Mike