Help - Search - Members - Calendar
Full Version: DP3's VX Code Snippets
RPG RPG Revolution Forums > Scripting > Script Submissions > RGSS2-Submissions
diamondandplatinum3
DP3's VX 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


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     = "Applause"
  CRITICAL_HIT_VOLUME = 80
  CRITICAL_HIT_PITCH  = 100
  #==================================================
  
  
  
  alias playsound_oncritical make_attack_damage_value
  def make_attack_damage_value(*args)
    playsound_oncritical(*args)
    RPG::SE.new(CRITICAL_HIT_SE, CRITICAL_HIT_VOLUME, CRITICAL_HIT_PITCH).play if @critical
  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
  #--------------------------------------------------------------------------
  def start
    super
    load_database                     # Load database
    create_game_objects               # Create game objects
    check_continue                    # Determine if continue is enabled
    play_title_music                  # Play title screen music
    Graphics.wait(QueMusicWaitTime::TITLESCREEN_WAIT_TIME) # Que for music
    create_title_graphic              # Create title graphic
    create_command_window             # Create command window    
  end
end



class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    Graphics.wait(QueMusicWaitTime::BATTLESCENE_WAIT_TIME)
    $game_temp.in_battle = true
    @spriteset = Spriteset_Battle.new
    @message_window = Window_BattleMessage.new
    @action_battlers = []
    create_info_viewport
  end
end




Remove Ship Auto-change BGM
CODE
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#             Remove Ship 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] == true
      @driving = true
      @walk_anime = true
      @step_anime = true
      if @type == 2               # If airship
        @priority_type = 2        # Change priority to "Above Characters"
      end
    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.
#    Its 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.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~








class Scene_Battle
  
  #=========================================================
  #               EDITABLE REGION
  #=========================================================
  
  ESCAPE_RATIO              = 25 # out of 100
  GUARANTEE_ESCAPE_ITEM_ID  = 2  # Item ID of item that will guarantee you can escape
  
  #=========================================================
  
  
  
  
  
  
  
  
  #--------------------------------------------------------------------------
  # * Create Escape Ratio
  #--------------------------------------------------------------------------
  def make_escape_ratio
    @escape_ratio = ESCAPE_RATIO
  end
  
  
  #--------------------------------------------------------------------------
  # * Execute Battle Action: Item
  #--------------------------------------------------------------------------
  alias dp3_mod_escrat_sb_exec_act_itm_845wc execute_action_item
  def execute_action_item
    # Call Original Method
    dp3_mod_escrat_sb_exec_act_itm_845wc
    
    @escape_ratio = 100 if @active_battler.action.item.id == GUARANTEE_ESCAPE_ITEM_ID
  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.
amerk
Nice, thanks for sharing this. So to confirm the Escape ratio, I could potentially have it set to 100 # out of 100 if I want a person to escape each time. If so, thanks for that, I've been wanting something like that since it makes no sense to me to force a battle if the player doesn't want to fight, assuming escaping is an option.
diamondandplatinum3
Yep smile.gif if you set it to 100, the player can escape every battle without fail; provided the player CAN actually escape from battle in the first place though.
amerk
Then like I said, awesome. It's the one thing I've always hated, being caught in the middle of a dungeon with no way to save, and having to head off to school or work or wherever, and having to crawl back out of the dungeon in a hurry, but getting hit by random encounters with no means of assured escape.

This may make randome encounters a bit more enjoyable for the casual gamer.
hainkiwanki
I see that you've put all your scripts in one topic and I like them all smile.gif Great job
diamondandplatinum3
Not quite all of them, just the smaller ones smile.gif But thank you.
amerk
Small snippets are always fun. Back in the glory days of VX, there were a lot of these. I tend to enjoy the small snippets more so than the large codes since they generally add small flavor to a game without overcomplicating things.
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.