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.
Terrain Tag Common Event Triggering - by: albertfish

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 83
Detective Scrotes
Terrain Tag Common Event Triggering
Version: 1.2
Author: albertfish
Date: December 13, 2009 (of most recent version)

Version History


  • Version 1.2: December 13, 2009
         - Changed over to Scene_Map to eliminate any problems with the spriteset being drawn when the player can't move
  • Version 1.1: December 13, 2009
         - Added new control features
              - Ability to repeat the common event call if needed
              - Ability to set a pause between repeated event calls
  • Version 1.0: December 12, 2009
         - Initial release

Description


This script triggers the common event equal to the terrain tag you are currently on. This script only calls the common event once until you move to another tile, unless you enter the repeat command.

Features

  • Call common events by terrain id number
  • Customize how to call the events

Screenshots

This is a non-visual script, it is however a functional one. No screenshots can represent the features of this script.

Instructions

Usage instructions are contained within the initial comments of the script. To install, simply place  above main.

Script


Code: [Select]
#==============================================================================
# ** Terrain Tag Common Event Triggering
#------------------------------------------------------------------------------
# * Created by: albertfish
# * Version: 1.2
# * Last edited: December 13, 2009
#------------------------------------------------------------------------------
#  Version History:
#    Version 1.2: December 13, 2009
#      - Changed over to Scene_Map to eliminate any problems with the spriteset
#        being drawn when the player can't move
#    Version 1.1: December 13, 2009
#      - Added new control features
#          - Ability to repeat the common event call if needed
#          - Ability to set a pause between repeated event calls
#    Version 1.0: December 12, 2009
#      - Initial release
#------------------------------------------------------------------------------
#  Description:
#    This script triggers the common event equal to the terrain tag you are
#    currently on. This script only calls the common event once until you
#    move to another tile, unless you enter the repeat command.
#------------------------------------------------------------------------------
#  Usage Instructions:
#    This script will call all common events from 1 to @final_tag. You may
#    edit this value to it's max ammount (7).
#    To set the common event to repeat, place a comment in the common event
#    and type repeat. To set a pause for repeated event calls, type a comment
#    as follows:
#        wait #
#    This will tell the script to wait for # of frames before repeating. For
#    example, wait 40 should repeat the script 1 time per second. This
#    depends on the refresh rate, which is by default 40.
#------------------------------------------------------------------------------
#  Install Instructions:
#    Place this script above the main script and below the default scripts.
#==============================================================================

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
  alias af_ttcet_sm_main main
  def main
    @final_tag = 7
    @repeat = false
    @wait = 0
    @prev_x = $game_player.x
    @prev_y = $game_player.y
    af_ttcet_sm_main
  end
  alias af_ttcet_sm_update update
  def update
    af_ttcet_sm_update
    x = $game_player.x
    y = $game_player.y
    tag = $game_map.terrain_tag(x, y)
    @repeat = false
    if $data_common_events[tag] != nil
      if tag > 0 && tag <= [7, @final_tag].min
        list = $data_common_events[tag].list
        for i in 0...list.size
          if (list[i].code == 108 || list[i].code == 408) &&
              list[i].parameters[0] == "repeat"
            @repeat = true
          elsif (list[i].code == 108 || list[i].code == 408) &&
                list[i].parameters[0][0, 4] == "wait" && @wait == -1
            @wait = list[i].parameters[0][5, list[i].parameters[0].size - 5].to_i
          end
        end
        if @wait == 0 && (@repeat || x != @prev_x || y != @prev_y)
          $game_temp.common_event_id = tag
          @wait = -1
        elsif @wait > 0
          @wait -= 1
        end
      end
    end
    if x != @prev_x || y != @prev_y
      @wait = 0
    end
    @prev_x = x
    @prev_y = y
  end
end

Credit


  • albertfish

Thanks

  • gameface101 for the request.

Support


If you discover any bugs with this script, please send me a PM describing the problem and when it happens.

Known Compatibility Issues

May be incompatible with scripts that terrain tags for specific functions.

Demo


No available demo.

Author's Notes


Enjoy, there are many uses for this script! Hopefully people have some creative uses for it.

Restrictions

You may use this in your game commercial or non-commercial as long as proper credit is given.
« Last Edit: December 14, 2009, 03:51:26 PM by albertfish »

*
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
that's a cool idea. Moved to database

***
Rep:
Level 83
X-PLAT!
@albertfish - to me the words "super nifty" best describe this kick@$$ script.
you are most awesome for whipping this up! => + <=

the trigger between terrain tags and common events
can be used in so many ways!

~ falling! (pitfalls cliffs edges)
~ swimming! (in the shallow to even drowning in the deep)

Talk about a more interactive landscape!
~ sinking in the sand
~walking slower in the mud,
~burned by lava
~slippery on ice

"all made easy"

-it's really up to how well you can set up your common events.

going forward...
all of my projects will reserve common events 1-7
all because of this super nifty script. ^,^