Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> DP3's VXA Code Snippets
diamondandplatin...
post Oct 4 2012, 03:19 PM
Post #1


Level 5
Group Icon

Group: Member
Posts: 72
Type: Writer
RM Skill: Skilled
Rev Points: 45




DP3's VXA Code Snippets
Version: ???
Author: DiamondandPlatinum3
Date: ???



Planned Future Versions
  • It's pretty much guaranteed



Description

These are code snippets I have made over the course of a few months. Figure they may be of use to other people; posting them before I lose track of them in post counts. I know there are a couple I already have. ;9


Instructions
  • All Snippets are to be placed in a script slot between Materials and Main



Scripts

Map does not scroll with Player

CODE
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Map does not scroll with Player
#    !- You are not required to give credit to anyone for this script -!
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script stops the map from scrolling with the player. Its only use
#    is to mimic old Zelda style games where the map would scroll when you
#    would change rooms, otherwise staying still.
#
#    To scroll a map you will have to use the Scroll Map event.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




class Game_Player
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    last_real_x = @real_x
    last_real_y = @real_y
    last_moving = moving?
    move_by_input
    super
    update_vehicle
    update_nonmoving(last_moving) unless moving?
    @followers.update
  end
end



Battle Menu At Top of Screen
CODE
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Battle Menu At Top of Screen
#             Author: DiamondandPlatinum3
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script puts the battle menu at the top of the screen rather than
#    at the bottom where it normally is. It also moves the skill and items
#    box below the battle menu, looks nicer in my opinion.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Create Information Display Viewport
  #--------------------------------------------------------------------------
  alias putwindowabove_civ_fjshr3 create_info_viewport
  def create_info_viewport
    # Call Original Method
    putwindowabove_civ_fjshr3
  
    @info_viewport.rect.y = 0
    @status_window.viewport = @info_viewport
  end
end


#==============================================================================
# ** Window_BattleSkill
#------------------------------------------------------------------------------
#  This window is for selecting skills to use in the battle window.
#==============================================================================

class Window_BattleSkill < Window_SkillList
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     info_viewport : Viewport for displaying information
  #--------------------------------------------------------------------------
  def initialize(help_window, info_viewport)
    y = (info_viewport.rect.height + help_window.height)
    super(0, y, Graphics.width, (((info_viewport.rect.height + y) - (help_window.height + 16))))
    self.visible = false
    @help_window = help_window
    @info_viewport = info_viewport
  end
end



#==============================================================================
# ** Window_BattleItem
#------------------------------------------------------------------------------
#  This window is for selecting items to use in the battle window.
#==============================================================================

class Window_BattleItem < Window_ItemList
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     info_viewport : Viewport for displaying information
  #--------------------------------------------------------------------------
  def initialize(help_window, info_viewport)
    y = (info_viewport.rect.height + help_window.height)
    super(0, y, Graphics.width, (((info_viewport.rect.height + y) - (help_window.height + 16))))
    self.visible = false
    @help_window = help_window
    @info_viewport = info_viewport
  end
end



#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
#  This window shows skill and item explanations along with actor status.
#==============================================================================

class Window_Help < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(line_number = 2)
    if SceneManager.scene_is?(Scene_Battle)
      super(0, 120, Graphics.width, fitting_height(line_number))
    else
      super(0, 0, Graphics.width, fitting_height(line_number))
    end
  end
end



Play BGM on Loading Menu
CODE
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Play BGM on loading menu
#             Author: DiamondandPlatinum3
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script allows you to play BGM on the Loading menu.
#    When you select 'Continue' from the title screen and are taken to the
#    file selection screen, new BGM will play instead of the same title screen
#    music. Similar to Pokemon Gold, Silver, Crystal.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Scene_Load < Scene_File
  #======================================
  #       Editable Region
  #======================================
  BGM_MUSIC_FOR_LOAD_SCREEN  = "Scene6"
  BGM_VOLUME                 = 100
  BGM_PITCH                  = 100
  #======================================




  alias play_music_onloadscreen first_savefile_index
  def first_savefile_index
    RPG::BGM.new(BGM_MUSIC_FOR_LOAD_SCREEN, BGM_VOLUME, BGM_PITCH).play
    play_music_onloadscreen
  end
end



Play SE on Critical Hit

CODE
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Play SE on Critical Hit
#             Author: DiamondandPlatinum3
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script will allow you to play a Sound Effect when any active battler
#    Scores a critical hit.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



class Game_Battler
  #==================================================
  #           EDITABLE REGION
  #==================================================
  CRITICAL_HIT_SE     = "Applause1"
  CRITICAL_HIT_VOLUME = 80
  CRITICAL_HIT_PITCH  = 100
  #==================================================


  #--------------------------------------------------------------------------
  # * Apply Critical
  #--------------------------------------------------------------------------
  alias playsound_oncritical      apply_critical
  #--------------------------------------------------------------------------
  def apply_critical(*args)
    RPG::SE.new(CRITICAL_HIT_SE, CRITICAL_HIT_VOLUME, CRITICAL_HIT_PITCH).play
    return playsound_oncritical(*args)
  end
end



Delay Time Transitions

CODE
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Delay Time Transitions
#             Author: DiamondandPlatinum3
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script will allow you to delay when the title screen and battle
#    scene will enter their phase. Its only usefulness is for sound purposes.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



module QueMusicWaitTime
  #===============================
  #    Editable Region
  #===============================

  TITLESCREEN_WAIT_TIME = 400 # you'll need to play around with this.

  BATTLESCENE_WAIT_TIME = 400 # you'll need to play around with this.

  #===============================

end






class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  alias quemusicwaittime_scntitl_start_47cn37 start
  def start
    # Start Playing Music
    play_title_music

    # Wait for Music
    Graphics.wait(QueMusicWaitTime::TITLESCREEN_WAIT_TIME)
    
    # Run Original Method
    quemusicwaittime_scntitl_start_47cn37  
  end
end



class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  alias quemusicwaittime_scnbttl_start_47cn37 start
  def start
    # Wait For Music
    Graphics.wait(QueMusicWaitTime::BATTLESCENE_WAIT_TIME)
    
    # Run Original Method
    quemusicwaittime_scnbttl_start_47cn37
  end
end



Remove Vehicle Auto-Change BGM

CODE
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Remove Vehicle Auto-change BGM
#             Author: DiamondandPlatinum3
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script will allow you to stop vehicles from changing the bgm that is
#    currently playing via the use of an event switch.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



#///////////////////////////////////////
module DP3_Vehicle_Sound_Options #//////
#///////////////////////////////////////

# The ID of the switch which turns off changing the BGM on all vehicles
Event_Switch_ID = 10    



#//////////////////////////////////////
end #   ..  //    //    //  ..  ..  ///
#//////////////////////////////////////










class Game_Vehicle < Game_Character
  alias dp3_nobgm_during_travel get_on
  def get_on
    if $game_switches[DP3_Vehicle_Sound_Options::Event_Switch_ID]
      @driving = true
      @walk_anime = true
      @step_anime = true
      @walking_bgm = RPG::BGM.last
    else
      dp3_nobgm_during_travel
    end
  end
end



Determine if "in-battle

CODE
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Determine if "in battle"
#             Author: DiamondandPlatinum3
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script will allow you to set an event switch that will turn on if
#    you are in battle, and turn off if you are not.
#    It's useful for changing what an item does if battling compared to if
#    not battling.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



class Scene_Battle < Scene_Base
  #------------------------
  # Editable Part
  #------------------------

  # Event Switch to turn on if in battle
  ITEM_EVENT_SWITCH_ID = 10

  #------------------------













  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  alias evntswitchbtlstart_1g5s start
  def start
    evntswitchbtlstart_1g5s
    $game_switches[ITEM_EVENT_SWITCH_ID] = true
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  alias evntswitchbtlterminate_1g5s terminate
  def terminate
    evntswitchbtlterminate_1g5s
    $game_switches[ITEM_EVENT_SWITCH_ID] = false
  end
end



Control Escape Ratio

CODE
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Control Escape Ratio
#             Author: DiamondandPlatinum3
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#
#    This script will allow you to set a constant rate at which you can escape
#    from battle, as well as setting an item that will guarantee you can
#    escape.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
module DP3ESCAPERATIO
  #=========================================================
  #               EDITABLE REGION
  #=========================================================

  ESCAPE_RATIO              = 25 # out of 100
  GUARANTEE_ESCAPE_ITEM_ID  = 2  # Item ID of item that will guarantee you can escape

  #=========================================================
end







module BattleManager
  #--------------------------------------------------------------------------
  # * Create Escape Ratio
  #--------------------------------------------------------------------------
  def self.make_escape_ratio
    @escape_ratio = DP3ESCAPERATIO::ESCAPE_RATIO
  end
  #--------------------------------------------------------------------------
  # * Modify Escape Ratio ~ New Method
  #--------------------------------------------------------------------------
  def self.mod_escape_ratio( value )
    @escape_ratio = value
  end
  #--------------------------------------------------------------------------
  # * Escape Processing
  #--------------------------------------------------------------------------
  def self.process_escape
    $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
    
    # !-============ Replaced Line ============-! #
    
    success = @preemptive ? true : (rand(100) < @escape_ratio)
    
    # !-=======================================-! #
    
    Sound.play_escape
    if success
      process_abort
    else
      @escape_ratio += 0.1
      $game_message.add('\.' + Vocab::EscapeFailure)
      $game_party.clear_actions
    end
    wait_for_message
    return success
  end
end









class Scene_Battle
  #--------------------------------------------------------------------------
  # * Apply Skill/Item Effect
  #--------------------------------------------------------------------------
  alias dp3_mod_escrat_sb_app_itm_eff_845wc apply_item_effects
  def apply_item_effects(target, item)
    # Change Escape Ratio
    BattleManager.mod_escape_ratio(100) if item.is_a?(RPG::Item) && item.id == DP3ESCAPERATIO::GUARANTEE_ESCAPE_ITEM_ID
    
    # Call Original Method
    dp3_mod_escrat_sb_app_itm_eff_845wc(target, item)
  end
end



Credit
  • DiamondandPlatinum3



Thanks



Author's Notes

I will be posting more here as I finish them.


Terms of Use

Free for use in commercial or non-commercial projects with credit towards me. You may not claim any of these snippets as your own.


__________________________
Go to the top of the page
 
+Quote Post
   
The Welsh Paddy
post Oct 4 2012, 11:47 PM
Post #2


Level 3
Group Icon

Group: Member
Posts: 30
Type: Mapper
RM Skill: Beginner
Rev Points: 35




Nice! There really aren't enough of these kinds of scripts. I think people tend to forget that the addition of smaller features like these can make all the difference when it comes to making a game. I can already think of a number of uses I can put these to. Cheers! smile.gif


__________________________

Sig made by my pal Liz!
Eventing Tutorials
Sorting/Postman Mini-Game
Coming Next: Castle Defense!
Go to the top of the page
 
+Quote Post
   
diamondandplatin...
post Oct 7 2012, 08:53 AM
Post #3


Level 5
Group Icon

Group: Member
Posts: 72
Type: Writer
RM Skill: Skilled
Rev Points: 45




Thank you for the morale boost smile.gif


__________________________
Go to the top of the page
 
+Quote Post
   
amerk
post Oct 8 2012, 01:12 PM
Post #4


Level 56
Group Icon

Group: Global Mod
Posts: 1,784
Type: None
RM Skill: Undisclosed
Rev Points: 15




Awesome, the Escape snippet makes its way to VXA. The map scroll prevention is also a nice tool to have.


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 11:12 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker