State Common Events

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by Helladen, Jan 6, 2015.

  1. Helladen

    Helladen Deviant Designer Veteran

    Messages:
    635
    Likes Received:
    183
    Location:
    United States of America
    First Language:
    English
    Introduction
    This is a script I wrote that allows you to call Common Events when a State is added or removed. It's very useful, if you want to control the state's functionality more so than default system allows via turn start/end counters.
     
     
    Optional
    Common Events may not work in battle for you, if they do not then please use this script and follow the screenshots below.
    Hime - Scene Interpreter
     
     
    Screenshots

    [​IMG]
     
     
    [​IMG]
     
     
    Script
    Dropbox
     
     
    Commercial
    My script can be used in any project, all I require is credit. Hime's script is not allowed in commercial projects without permission. Special thanks to Fomar0153 and Hime for their notetag guide.
     
    Last edited by a moderator: Jan 8, 2015
    #1
    JiM83 and Tsukihime like this.
  2. Kenen

    Kenen Veteran Veteran

    Messages:
    252
    Likes Received:
    151
    First Language:
    English
    Primarily Uses:
    RMMV
    This is beyond useful for battle mechanic enthusiasts like myself. Bookmarking. Thank you!
     
    #2
    Helladen likes this.
  3. Helladen

    Helladen Deviant Designer Veteran

    Messages:
    635
    Likes Received:
    183
    Location:
    United States of America
    First Language:
    English
    Thanks! :)  It was requested by someone else, I didn't come up with the idea.

    Although, my requirements changed - Hime's script may not be required although it is still useful if you want more control without having to get own dirty with the Script Editor, so this works for even commercial projects.
     
    Last edited by a moderator: Jan 9, 2015
    #3
  4. Banjo

    Banjo Veteran Veteran

    Messages:
    60
    Likes Received:
    11
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMVXA
    Does anyone have a working link for this script please?

    I've been looking everywhere for it, but any post by the author (either as Aeirex or Helladen) has the same broken Dropbox link and no way to get the script.
     
    #4
  5. Vis_Mage

    Vis_Mage Novice Magician Veteran

    Messages:
    364
    Likes Received:
    135
    Location:
    Ridge Island
    First Language:
    English
    Primarily Uses:
    RMVXA
    Here you go, I just happened to have an old copy in one of my projects:

    Code:
    #==============================================================================
    # ▼ State Common Events
    # -- Author: Aeirex
    # -- Version: 1.0.0
    # -- Last Updated: 2015.01.06
    # -- Level: Easy
    # -- Requires: Hime - Scene Interpreter
    #==============================================================================
    
    #==============================================================================
    # ■ Script Import
    #==============================================================================
    $imported = {} if $imported.nil?
    $imported["AE-StateCommonEvents"] = true
    #==============================================================================
    
    #==============================================================================
    # ▼ Introduction
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # This is a basic state script which allows common event injection to states.
    #==============================================================================
    
    #==============================================================================
    # ■ Configuration
    #==============================================================================
    module AeirexStateHelper
      InCombat = false # States will only call a Common Event in combat.
    end
    #==============================================================================
    
    #==============================================================================
    # ▼ Instructions
    # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    # Use these tags in States.
    # <add common event: #>
    # <remove common event: #>
    #
    # Add common event will trigger when a State is added. It will only process the
    # common event after it is added and not before.
    #
    # Remove common event will trigger when a State is removed. It will only process
    # the common event after it is removed and not before.
    #
    # This script relies on Hime - Scene Interpreter since RPG Maker VX ACE lacks
    # global Common Events and are restricted to only process on the game map.
    # Menus and battles do not work with common events, so this script is required
    # for this script to work. You need to follow the instructions of the script,
    # to specify which scene that the common event will open in.
    #==============================================================================
    
    #==============================================================================
    # * States
    #==============================================================================
    class RPG::State
      #------------------------------------------------------------------------
      # * new add state: common event
      #------------------------------------------------------------------------
      def add_common_event
        if @add_common_event.nil?
          if @note =~ /<add common event: (.*)>/i
            @add_common_event = $1.to_i
          else
            @add_common_event = 0
          end
        end
        
        @add_common_event
      end
    
      #------------------------------------------------------------------------
      # * new remove state: common event
      #------------------------------------------------------------------------
      def remove_common_event
        if @remove_common_event.nil?
          if @note =~ /<remove common event: (.*)>/i
            @remove_common_event = $1.to_i
          else
            @remove_common_event = 0
          end
        end
        
        @remove_common_event
      end
     
    end
    
    #==============================================================================
    # * Game_Battler
    #==============================================================================
    class Game_Battler < Game_BattlerBase   
      #------------------------------------------------------------------------
      # * alias method: add_state
      #------------------------------------------------------------------------
      alias add_state_ace add_state
      def add_state(state_id)   
        add_state_ace(state_id)
    
        # Call the common event only if in battle
        if !AeirexStateHelper::InCombat || $game_party.in_battle
          $game_temp.reserve_common_event($data_states[state_id].add_common_event)
        end
      end
     
      #------------------------------------------------------------------------
      # * alias method: erase_state
      #------------------------------------------------------------------------
      alias erase_state_ace erase_state
      def erase_state(state_id)   
        erase_state_ace(state_id)
    
        # Call the common event only if in battle
        if !AeirexStateHelper::InCombat || $game_party.in_battle
          $game_temp.reserve_common_event($data_states[state_id].remove_common_event)
        end
      end
     
    end
    
    #==============================================================================
    # ▼ End of File
    #==============================================================================
     
    #5
    Banjo likes this.
  6. Banjo

    Banjo Veteran Veteran

    Messages:
    60
    Likes Received:
    11
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMVXA
    Thanks SO much for that! I'm glad that script can be preserved for others to use in future, too.
     
    #6

Share This Page