The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: albertfish on December 13, 2009, 08:10:21 PM

Title: Terrain Tag Common Event Triggering - by: albertfish
Post by: albertfish on December 13, 2009, 08:10:21 PM
Terrain Tag Common Event Triggering
Version: 1.2
Author: albertfish
Date: December 13, 2009 (of most recent version)

Version History



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


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



Thanks


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.
Title: Re: Terrain Tag Common Event Triggering - by: albertfish
Post by: modern algebra on December 16, 2009, 02:48:26 PM
that's a cool idea. Moved to database
Title: Re: Terrain Tag Common Event Triggering - by: albertfish
Post by: gameface101 on December 24, 2009, 06:01:14 AM
@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. ^,^