Author Topic: Terrain Tag Common Event Triggering - by: albertfish  (Read 862 times)

0 Members and 1 Guest are viewing this topic.
albertfish Male
**
Rep: +22/-0
Offline Offline
Level 54 (88%)
Detective Scrotes
Terrain Tag Common Event Triggering - by: albertfish
« on: December 13, 2009, 03:10:21 PM »

  • 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, 10:51:26 AM by albertfish »
    modern algebra Male
    *
    Rep: +336/-113
    Online Online
    Level 79 (49%)
    Re: Terrain Tag Common Event Triggering - by: albertfish
    « Reply #1 on: December 16, 2009, 09:48:26 AM »

  • that's a cool idea. Moved to database


    gameface101
    ***
    Rep: +243/-1308
    Offline Offline
    Level 56 (02%)
    less talk, more action
    Re: Terrain Tag Common Event Triggering - by: albertfish
    « Reply #2 on: December 24, 2009, 01: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. ^,^
     

    hi

    RMRK.net Theme Super Ultra Mega Beta

    Follow RMRK on Twitter Ask RMRK Questions on Formspring Get RMRK Updates via Windows Live

    Page created in 0.207 seconds with 19 queries.