Help - Search - Members - Calendar
Full Version: Common events to apply in battle?
RPG RPG Revolution Forums > Game Engines > RPG Maker VX Ace Discussion
Icenick99
I want a time system in my game, I found a system that uses common events but in battle the time does not change. I assume I need a script? How can I make it so that time will pass when the player is in battle?
Night_Runner
I didn't read the whole thing properly, so I've made a time script.

CODE
#==============================================================================
# ** VXAce: Night_Runner's Permanent Time Script.
#------------------------------------------------------------------------------
# History:
#  Date Created: 10/April/2012
#  Created for: Icenick99
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=56149
#
# Description:
#  This script will constantly update defined variables (lines 34 - 39),
#   like you would expect from a time system.
#  The time is updated every time the graphics updates.
#
# How to Install:
#  Copy this entire script. In your game's editor select Tools >>
#  Script Editor.
#  Along the left side scroll to the bottom, right click on 'Main Process'
#  and select 'Insert'.
#  Paste in the window on the right.
#==============================================================================



#==============================================================================
# ** Graphics
#------------------------------------------------------------------------------
#  Edited to update variables every frame.
#==============================================================================

module Graphics
  #--------------------------------------------------------------------------
  # * Customisation
  #--------------------------------------------------------------------------
  SECOND_VARIABLE = 10
  MINUTE_VARIABLE = 11
  HOUR_VARIABLE   = 12
  DAY_VARIABLE    = 13
  MONTH_VARIABLE  = 14
  YEAR_VARIABLE   = 15
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  class << self
    alias nr_timeCount_update  update  unless $@
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def self.update(*args)
    # Run the original update
    nr_timeCount_update(*args)
    # Do nothing if the variables don't exist (title screen)
    return if $game_variables.nil?
    # Increment the seconds variable
    $game_variables[SECOND_VARIABLE] += 1
    # If the seconds has reached a full minute
    if $game_variables[SECOND_VARIABLE] >= 60
      # Reset the seconds
      $game_variables[SECOND_VARIABLE] = 0
      # Increment the minutes variable
      $game_variables[MINUTE_VARIABLE] += 1
      # If the minutes variable has reached a full hour
      if $game_variables[MINUTE_VARIABLE] >= 60
        # Reset the minutes
        $game_variables[MINUTE_VARIABLE] = 0
        # Increment the hours
        $game_variables[HOUR_VARIABLE] += 1
        # If the hours variable has reached a full day
        if $game_variables[HOUR_VARIABLE] >= 24
          # Reset the hours
          $game_variables[HOUR_VARIABLE] = 0
          # Increment the days
          $game_variables[DAY_VARIABLE] += 1
          # If the days variable has reached a full month
          if $game_variables[DAY_VARIABLE] > 30
            # Reset the days
            $game_variables[DAY_VARIABLE] = 1
            # Increment the months
            $game_variables[MONTH_VARIABLE] += 1
            # If the months variable has reached a full year
            if $game_variables[MONTH_VARIABLE] > 12
              # Reset the days
              $game_variables[DAY_VARIABLE] = 1
              # Increment the years
              $game_variables[YEAR_VARIABLE] += 1
            end
          end
        end
      end
    end
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


Have a second script, read the description and see which one you prefer happy.gif

CODE
#==============================================================================
# ** VXAce: Night_Runner's Common Events During Battle.
#------------------------------------------------------------------------------
# History:
#  Date Created: 10/April/2012
#  Created for: Icenick99
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=56149
#
# Description:
#  This script will run a common event during battle, as it would on the map.
#  < Please don't try to abuse this script, it's only designed to update
#    a variable, nothing fancy.
#  />.
#
# How to Install:
#  Copy this entire script. In your game's editor select Tools >>
#  Script Editor.
#  Along the left side scroll to the bottom, right click on 'Main Process'
#  and select 'Insert'.
#  Paste in the window on the right.
#
# How to Use:
#  Set the ID of the common event to run during battle on line xx (by
#  default it runs common event 1 during battle).
#==============================================================================



#==============================================================================
# ** Customisation
#==============================================================================

module NR_BattleCommonEvent
  Event_ID = 1
end



#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  Edited to run a common event in the background.
#==============================================================================

class Scene_Battle
  alias nr_commoneventBattle_start  start  unless $@
  alias nr_commoneventBattle_update  update  unless $@
  def start(*args)
    # Create the common event
    @common_event = Game_CommonEvent.new(NR_BattleCommonEvent::Event_ID)
    # Run the original start
    nr_commoneventBattle_start(*args)
  end
  def update(*args)
    # Update the common event
    @common_event.update
    # Run the original update
    nr_commoneventBattle_update(*args)
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================
Icenick99
Thanks!!!!!!!!!
biggrin.gif
bulmabriefs144
QUOTE (Icenick99 @ Apr 9 2012, 05:05 PM) *
I want a time system in my game, I found a system that uses common events but in battle the time does not change. I assume I need a script? How can I make it so that time will pass when the player is in battle?


You people and scripts. Just wait until battle's over. Why do you need complete real-time? If you really must have such a system, try this. Make an end of turn, Turn event. Variable +1 Battle Minutes, Exit Event. Have a line of code in your time system, that adds Battle Minutes to your minutes, and then afterwards clears Battle Minutes to 0. (It'll work outside the battle). 30 turns will be 30 minutes, and that's good enough for Mana Khemia.
Icenick99
QUOTE (bulmabriefs144 @ Apr 11 2012, 06:29 PM) *
QUOTE (Icenick99 @ Apr 9 2012, 05:05 PM) *
I want a time system in my game, I found a system that uses common events but in battle the time does not change. I assume I need a script? How can I make it so that time will pass when the player is in battle?


You people and scripts. Just wait until battle's over. Why do you need complete real-time? If you really must have such a system, try this. Make an end of turn, Turn event. Variable +1 Battle Minutes, Exit Event. Have a line of code in your time system, that adds Battle Minutes to your minutes, and then afterwards clears Battle Minutes to 0. (It'll work outside the battle). 30 turns will be 30 minutes, and that's good enough for Mana Khemia.


I never enough though for that...
Thanks for sharing but this works nicely smile.gif
Pharonix
QUOTE (bulmabriefs144 @ Apr 11 2012, 07:29 PM) *
QUOTE (Icenick99 @ Apr 9 2012, 05:05 PM) *
I want a time system in my game, I found a system that uses common events but in battle the time does not change. I assume I need a script? How can I make it so that time will pass when the player is in battle?


You people and scripts. Just wait until battle's over. Why do you need complete real-time? If you really must have such a system, try this. Make an end of turn, Turn event. Variable +1 Battle Minutes, Exit Event. Have a line of code in your time system, that adds Battle Minutes to your minutes, and then afterwards clears Battle Minutes to 0. (It'll work outside the battle). 30 turns will be 30 minutes, and that's good enough for Mana Khemia.


And if you use Yanfly's base troop events, this works perfectly

Just realized that if you have an Evented Time system like me,
that if you use a MOMENT condition in your troop, then call your time system common event,
then it will continuously work.

I tested it myself and it works fine. started a battle at game time 19:00 and finished it at 21:00 (Two minutes real-time) and the time system updated correctly.
This works best of course like I said.. With Yanfly's base troop events. So you only need to make it once.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.