The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: TDS on September 02, 2011, 02:14:35 AM

Title: Idle title intro
Post by: TDS on September 02, 2011, 02:14:35 AM
Idle Title intro
Version: 1.0
Author: TDS
Date: September 1, 2011

Version History



Description


Allows you to start a map for an intro after idling for a preset period of time in the title screen.

Features



Instructions

They're in the script.

Script


Code: [Select]
#==============================================================================
# ** TDS Idle Title Intro
#    Ver: 1.0
#------------------------------------------------------------------------------
#  * Description:
#  This script allows you to make an intro start after an amount of time has
#  passed idling in the title screen.
#------------------------------------------------------------------------------
#  * Features:
#  Starts a map after a while idling in the title screen.
#  Interrupts intro in the map if desired.
#------------------------------------------------------------------------------
#  * Instructions:
#  Edit the constants below the script information to set it up how you want.
#------------------------------------------------------------------------------
#  * Notes:
#  To make a good automatic intro make sure to use \! \^ commands in the text
#  box and use the "Return to title" event command at the end of your intro.
#------------------------------------------------------------------------------
#  * New Methods:
#  Scene_Title:
#  - reset_idle_intro_counter?
#    ^ Used to determine if any input has happened to interrupt the idle intro.
#  - start_idle_intro
#    ^ Used to start the idle intro in the map.
#
#  Scene_Map:
#  - interrupt_idle_intro?
#    ^ Used to interrupt the idle intro in the map and return to title.
#------------------------------------------------------------------------------
#  * Aliased Methods:
#  Game_Temp:
#  - initialize
#    ^ Aliased to initialize the viewing idle intro flag.
#
#  Scene_Title:
#  - initialize
#    ^ Aliased to initialize the idle intro counter.
#  - update
#    ^ Aliased to process the idle intro values and methods.
#
#  Scene_Map:
#  - update
#    ^ Aliased to process the idle intro interruption methods.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================

#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
# Idle Title Intro Wait (in frames)
IDLE_TITLE_INTRO_WAIT = 700
# Idle Title Intro Start Map ID
IDLE_TITLE_INTRO_START_MAP_ID = 1
# Idle Title Intro Start X Position
IDLE_TITLE_INTRO_START_X = 0 
# Idle Title Intro Start Y Position 
IDLE_TITLE_INTRO_START_Y = 0
# Idle Title Intro Start Screen Tone
IDLE_TITLE_INTRO_START_SCREEN_TONE = Tone.new(0, 0, 0, 0)
# If Idle Titlle intro in map can be interrupted once started
CAN_INTERRUPT_MAP_INDLE_TITLE_INTRO = true
# Array of Idle Interrupt Keys
IDLE_INTERRUPT_KEYS = [Input::A, Input::B, Input::C, Input::X, Input::Y,
Input::Z, Input::L, Input::R, Input::DOWN, Input::LEFT, Input::RIGHT,
Input::UP, Input::SHIFT, Input::CTRL, Input::ALT] 

#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  This class handles temporary data that is not included with save data.
# The instance of this class is referenced by $game_temp.
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_idle_title_intro_game_temp_initialize     initialize    unless $@ 
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :viewing_idle_title_intro    # Viewing Idle Title Intro Flag 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Run Original Method
    tds_idle_title_intro_game_temp_initialize
    # Set Viewing Title Idle intro flag to false
    @viewing_idle_title_intro = false
  end
end


#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs the title screen processing.
#==============================================================================

class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_idle_title_intro_scene_title_initialize    initialize   unless $@
  alias tds_idle_title_intro_scene_title_update        update       unless $@ 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Run Original Method
    tds_idle_title_intro_scene_title_initialize
    # Set Idle Intro Counter Initial Value
    @idle_intro_counter = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Run Original Method
    tds_idle_title_intro_scene_title_update
    # Reset Idle Intro Counter
    @idle_intro_counter = 0 if reset_idle_intro_counter?
    # Increase Idle Intro Counter
    @idle_intro_counter += 1
    # Start Idle Intro Idle Intro Counter is equal or more to idle intro wait
    start_idle_intro if @idle_intro_counter >= IDLE_TITLE_INTRO_WAIT
  end
  #--------------------------------------------------------------------------
  # * Determine if idle title intro counter is to be reset
  #--------------------------------------------------------------------------
  def reset_idle_intro_counter?
    # Go Through Idle Interrup Keys
    IDLE_INTERRUPT_KEYS.each {|key|
      # Return true if Interrupt key has been pressed
      return true if Input.trigger?(key) or Input.press?(key) or Input.repeat?(key)
    }   
    # Return false by default
    return false
  end
  #--------------------------------------------------------------------------
  # * Start Idle Intro
  #--------------------------------------------------------------------------
  def start_idle_intro
    # Initial party
    $game_party.setup_starting_members
    # Initial map position
    $game_map.setup(IDLE_TITLE_INTRO_START_MAP_ID)
    $game_player.moveto(IDLE_TITLE_INTRO_START_X, IDLE_TITLE_INTRO_START_Y)
    $game_player.refresh
    $scene = Scene_Map.new
    # Start Game Map Tone change
    $game_map.screen.start_tone_change(IDLE_TITLE_INTRO_START_SCREEN_TONE, 0)
    # Set Viewing Idle Intro flag to true
    $game_temp.viewing_idle_title_intro = true
    RPG::BGM.fade(1500)
    close_command_window if @command_window != nil
    Graphics.fadeout(60)
    Graphics.wait(40)
    Graphics.frame_count = 0
    RPG::BGM.stop
    $game_map.autoplay
  end
end


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

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_idle_title_intro_scene_map_update         update        unless $@   
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Run Original Method
    tds_idle_title_intro_scene_map_update
    # Call title If Viewing Idle Intro and idle intro is interrupted
    call_title if $game_temp.viewing_idle_title_intro and interrupt_idle_intro?
  end   
  #--------------------------------------------------------------------------
  # * Determine if idle intro should be interrupted
  #--------------------------------------------------------------------------
  def interrupt_idle_intro?
    # Return false if Idle Intro cannot be interrupted
    return false if !CAN_INTERRUPT_MAP_INDLE_TITLE_INTRO
    # Go Through Idle Interrup Keys
    IDLE_INTERRUPT_KEYS.each {|key|
      # Return true if Interrupt key has been pressed
      return true if Input.trigger?(key) or Input.press?(key) or Input.repeat?(key)
    }
    # Return false by default
    return false
  end 
end

Credit



Support


On this topic.

Known Compatibility Issues

There could be some compatibility issues with other custom title screen scripts.


Author's Notes


To make a good automatic intro make sure to use \! \^ commands in the text box and use the "Return to title" event command at the end of your intro.

Restrictions

Only for use in non-commercial games.
Title: Re: Idle title intro
Post by: Adon on October 03, 2011, 09:05:42 PM
This is actually a pretty good thing to have! Good job!
Title: Re: Idle title intro
Post by: modern algebra on October 03, 2011, 09:09:02 PM
Yeah, this looks great TDS. I don't know how I missed it earlier.
Title: Re: Idle title intro
Post by: Tulat on January 04, 2012, 08:07:12 AM
This looked cool so I thought I would try it, but...
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi302.photobucket.com%2Falbums%2Fnn113%2FTulat%2FError.png&hash=4bd023e9258fc3d76ec6d93741a1d1ddfb87d0f8)

Apparently it clashes with something in Jet's time system.
It could be something simple but I don't understand enough to fix this.
Any ideas? The line is...
"if $game_time.map_infos[$game_map.map_id].indoors? || $game_time.map_infos[$game_map.map_id].no_tint?"

The map I set it to was outside.. so why would it even clash with this?
Title: Re: Idle title intro
Post by: TDS on January 04, 2012, 08:36:40 AM
That is a strange bug, if you could provide a small demo with the bug I'll get right on fixing it.

I suspect it has something to do with how the intro is started from the title screen and not creating the $game_time global variable.
Title: Re: Idle title intro
Post by: Tulat on January 04, 2012, 06:34:12 PM
Wow you replied fast.
I made a demo that replicates this bug, with only your Idle title and Jet's time system scripts.
http://www.megaupload.com/?d=4MKPHXTK (http://www.megaupload.com/?d=4MKPHXTK)
Thanks for replying so quick. :]
Title: Re: Idle title intro
Post by: TDS on January 04, 2012, 07:36:13 PM
This should work.

Code: [Select]
#==============================================================================
# ** TDS Idle Title Intro
#     Ver: 1.0
#      by TDS
#------------------------------------------------------------------------------
#  * Description:
#  This script allows you to make an intro start after an amount of time has
#  passed idling in the title screen.
#------------------------------------------------------------------------------
#  * Features:
#  Starts a map after a while idling in the title screen.
#  Interrupts intro in the map if desired.
#------------------------------------------------------------------------------
#  * Instructions:
#  Edit the constants below the script information to set it up how you want.
#------------------------------------------------------------------------------
#  * Notes:
#  To make a good automatic intro make sure to use \! \^ commands in the text
#  box and use the "Return to title" event command at the end of your intro.
#------------------------------------------------------------------------------
#  * New Methods:
#  Scene_Title:
#  - reset_idle_intro_counter?
#    ^ Used to determine if any input has happened to interrupt the idle intro.
#  - start_idle_intro
#    ^ Used to start the idle intro in the map.
#
#  Scene_Map:
#  - interrupt_idle_intro?
#    ^ Used to interrupt the idle intro in the map and return to title.
#------------------------------------------------------------------------------
#  * Aliased Methods:
#  Game_Temp:
#  - initialize
#    ^ Aliased to initialize the viewing idle intro flag.
#
#  Scene_Title:
#  - initialize
#    ^ Aliased to initialize the idle intro counter.
#  - update
#    ^ Aliased to process the idle intro values and methods.
#
#  Scene_Map:
#  - update
#    ^ Aliased to process the idle intro interruption methods.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================

#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
# Idle Title Intro Wait (in frames)
IDLE_TITLE_INTRO_WAIT = 700
# Idle Title Intro Start Map ID
IDLE_TITLE_INTRO_START_MAP_ID = 1
# Idle Title Intro Start X Position
IDLE_TITLE_INTRO_START_X = 0 
# Idle Title Intro Start Y Position 
IDLE_TITLE_INTRO_START_Y = 0
# Idle Title Intro Start Screen Tone
IDLE_TITLE_INTRO_START_SCREEN_TONE = Tone.new(0, 0, 0, 0)
# If Idle Titlle intro in map can be interrupted once started
CAN_INTERRUPT_MAP_INDLE_TITLE_INTRO = true
# Array of Idle Interrupt Keys
IDLE_INTERRUPT_KEYS = [Input::A, Input::B, Input::C, Input::X, Input::Y,
Input::Z, Input::L, Input::R, Input::DOWN, Input::LEFT, Input::RIGHT,
Input::UP, Input::SHIFT, Input::CTRL, Input::ALT] 

#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  This class handles temporary data that is not included with save data.
# The instance of this class is referenced by $game_temp.
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_idle_title_intro_game_temp_initialize     initialize    unless $@ 
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :viewing_idle_title_intro    # Viewing Idle Title Intro Flag 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Run Original Method
    tds_idle_title_intro_game_temp_initialize
    # Set Viewing Title Idle intro flag to false
    @viewing_idle_title_intro = false
  end
end


#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs the title screen processing.
#==============================================================================

class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_idle_title_intro_scene_title_initialize    initialize   unless $@
  alias tds_idle_title_intro_scene_title_update        update       unless $@ 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Run Original Method
    tds_idle_title_intro_scene_title_initialize
    # Set Idle Intro Counter Initial Value
    @idle_intro_counter = 0
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Run Original Method
    tds_idle_title_intro_scene_title_update
    # Reset Idle Intro Counter
    @idle_intro_counter = 0 if reset_idle_intro_counter?
    # Increase Idle Intro Counter
    @idle_intro_counter += 1
    # Start Idle Intro Idle Intro Counter is equal or more to idle intro wait
    start_idle_intro if @idle_intro_counter >= IDLE_TITLE_INTRO_WAIT
  end
  #--------------------------------------------------------------------------
  # * Determine if idle title intro counter is to be reset
  #--------------------------------------------------------------------------
  def reset_idle_intro_counter?
    # Go Through Idle Interrup Keys
    IDLE_INTERRUPT_KEYS.each {|key|
      # Return true if Interrupt key has been pressed
      return true if Input.trigger?(key) or Input.press?(key) or Input.repeat?(key)
    }   
    # Return false by default
    return false
  end
  #--------------------------------------------------------------------------
  # * Start Idle Intro
  #--------------------------------------------------------------------------
  def start_idle_intro
    # Add Game Time Global Variable
    $game_time = Game_Time.new   
    # Initial party
    $game_party.setup_starting_members
    # Initial map position
    $game_map.setup(IDLE_TITLE_INTRO_START_MAP_ID)
    $game_player.moveto(IDLE_TITLE_INTRO_START_X, IDLE_TITLE_INTRO_START_Y)
    $game_player.refresh
    $scene = Scene_Map.new
    # Start Game Map Tone change
    $game_map.screen.start_tone_change(IDLE_TITLE_INTRO_START_SCREEN_TONE, 0)
    # Set Viewing Idle Intro flag to true
    $game_temp.viewing_idle_title_intro = true
    RPG::BGM.fade(1500)
    close_command_window if @command_window != nil
    Graphics.fadeout(60)
    Graphics.wait(40)
    Graphics.frame_count = 0
    RPG::BGM.stop
    $game_map.autoplay
  end
end


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

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_idle_title_intro_scene_map_update         update        unless $@   
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Run Original Method
    tds_idle_title_intro_scene_map_update
    # Call title If Viewing Idle Intro and idle intro is interrupted
    call_title if $game_temp.viewing_idle_title_intro and interrupt_idle_intro?
  end   
  #--------------------------------------------------------------------------
  # * Determine if idle intro should be interrupted
  #--------------------------------------------------------------------------
  def interrupt_idle_intro?
    # Return false if Idle Intro cannot be interrupted
    return false if !CAN_INTERRUPT_MAP_INDLE_TITLE_INTRO
    # Go Through Idle Interrup Keys
    IDLE_INTERRUPT_KEYS.each {|key|
      # Return true if Interrupt key has been pressed
      return true if Input.trigger?(key) or Input.press?(key) or Input.repeat?(key)
    }
    # Return false by default
    return false
  end 
end

The time object is created when the intro starts to avoid any errors, so the time HUD will be visible. I don't know if you could make it not visible not visible by a switch or something.
Title: Re: Idle title intro
Post by: Tulat on January 04, 2012, 08:04:09 PM
Just tried it, it works perfectly now.
Thanks.  ;D