iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
3 Pages V   1 2 3 >  
Reply to this topicStart new topic
> Mithran's Snippet Repository, Collection of small scripts, request scripts, and patches.
Mithran
post Jul 31 2009, 11:41 PM
Post #1


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




Mithran's Snippet Repository


Introduction
Many of these you may have already seen. Some of them, you may not have. Some are recent, others are old. Here I have placed many of scripts or snippets that I never felt like making a new 'Completed Scripts' post for. Most of them are fairly self explanatory. There may be full scripts that have some of these features, but I thought I would share this anyway. Unless otherwise noted, these snippets should be highly compatable with just about anything that doesn't do the exact same thing. If not otherwise noted, they should be able to go anywhere in the materials section of the script editor and work fine.

List:

For my actual full scripts, links are in my signature.
Scripts marked *PATCH* will not work without the noted complete script.

Monster Base Resistances
Spoiler:
CODE
# Use the note tag on an enemy to set his element rate to a specific value.
# Install: Place this script above all other custom scripts, but below default
# scripts.  
# <element rate id : value>
# replace id with the element id you are changing
# replace value with the rate of the element
# negative values may be used, for example, -100 is absorb 100%
# This alters the BASE element rate of that element, before other scripts take
# place (if installed correctly)

class Game_Enemy < Game_Battler
  alias element_rate_orig_elementnote element_rate
  def element_rate(element_id)
    if enemy.note =~ /<element\s?rate\s?#{element_id}\s?\:\s?([-]?\d+)>/i
      result = $1.to_i
      states.each { |state| result /= 2 if state.element_set.include?(element_id) }
      return result
    end
    return element_rate_orig_elementnote(element_id)
  end
end


Disable Prior Actor
Spoiler:
CODE
# Disable Prior Actor by Mithran
# Disables use of "B" button to cancel and return to prior actor in battle
# Insert on a page in the materials section above main.

module DisablePriorActor
  DISABLE = false
  # If set to true, disables going back to previous actor with B button
  # If set to false, actors are able to use "B" go back normally
end

class Scene_Battle < Scene_Base
    
  alias update_actor_command_selection_DPA update_actor_command_selection
  def update_actor_command_selection
    if DisablePriorActor::DISABLE && Input.trigger?(Input::B)
      Sound.play_buzzer
      return
    end
    update_actor_command_selection_DPA
  end
  
end


Dead Member Gain Exp
Spoiler:
CODE
# Dead Member Gain Exp
# Modify the amount of exp a dead party member recieves after battle
# setting the number to 0 will mean that they gain no exp, as in default
# Incompatable with other scripts that do the same thing, of course

module Mithran
  DEAD_EXP_PCT = 0
  # The percentage of exp a dead party member recieves
end

class Scene_Battle
  alias display_level_up_before_deadmembers display_level_up
  def display_level_up
    display_level_up_before_deadmembers
    exp = $game_troop.exp_total
    for actor in $game_party.dead_members
      actor.gain_exp(exp * Mithran::DEAD_EXP_PCT / 100, true)
    end
    wait_for_message
  end
end


Global Sell Ratio Modify
Spoiler:
CODE
# Shop Sell Modify
# By Mithran
# Modifies the global sell back amount.
# I may do something with this later, so please do not redistribute at this point.

module SellPrice
  SELL_PCT = 33.333
  # The percent of the buy price you would like to sell for. Setting this to
  # false disables the script.
  # It can also be written as simple math, but make sure you use decimals
  # in the denominator
  # Example:
  # SELL_PCT = 100 / 3
  # Sell percent is 33 percent versus
  # SELL_PCT = 100 / 3.0
  # Sell percent is 33.333333_ percent, or one third.
  # Rounds to the nearest whole number when price is determined.
  COMPATABILITY_METHOD = true
  # If set to true, a different method will be used for compatability.  The gold
  # window may show a different number for one frame (one sixtieth of a second)
  # if you use this option.  If your script is clashing with another script,
  # move this script lower on the list and set this to true.
end

class Scene_Shop < Scene_Base
  alias update_sell_selection_sellfix update_sell_selection
  def update_sell_selection
    update_sell_selection_sellfix
    if SellPrice::SELL_PCT && Input.trigger?(Input::C) && @item != nil
      max = $game_party.item_number(@item)
      @number_window.set(@item, max, (@item.price * SellPrice::SELL_PCT / 100).round)
    end
  end
  
  alias decide_number_input_sellfix decide_number_input
  def decide_number_input
    if @command_window.index == 1 && SellPrice::SELL_PCT
      Sound.play_shop
      @number_window.active = false
      @number_window.visible = false
      $game_party.gain_gold(@number_window.number * (@item.price * SellPrice::SELL_PCT / 100).round)
      $game_party.lose_item(@item, @number_window.number)
      @gold_window.refresh
      @sell_window.refresh
      @status_window.refresh
      @sell_window.active = true
      @sell_window.visible = true
      @status_window.visible = false
    else
      decide_number_input_sellfix
    end
  end
  
  if SellPrice::COMPATABILITY_METHOD
  def decide_number_input
    decide_number_input_sellfix
    if @command_window.index == 1 && SellPrice::SELL_PCT
      $game_party.lose_gold(@number_window.number * (@item.price / 2))
      $game_party.gain_gold(@number_window.number * (@item.price * SellPrice::SELL_PCT / 100).round)
      @gold_window.refresh
    end
  end
  end # end if

end


Class Change Unlearn/Inherit
Spoiler:
CODE
# Class Change Unlearn/Inherit
# By Mithran
# Install: Insert on a seperate page above main and set the two options in the
# module.

module ClassChangeUnlearn
  UNLEARN = true
  # makes actors unlearn all previous class skills on class change
  RELEARN = true
  # makes characters learn all skills they 'missed' for previous levels on class
  # change
end

class Game_Actor < Game_Battler
  
  alias class_id_unlearn= class_id=
  def class_id=(class_id)
    clear_class_learnings if ClassChangeUnlearn::UNLEARN
    self.class_id_unlearn = class_id
    inherit_class_learnings if ClassChangeUnlearn::RELEARN
  end

  def clear_class_learnings
    for i in self.class.learnings
      forget_skill(i.skill_id) if i.level <= @level
    end
  end
  
  def inherit_class_learnings
    for i in self.class.learnings
      learn_skill(i.skill_id) if i.level <= @level
    end
  end
  
end


Restrict Actor Item Usage
Spoiler:
CODE
# Exclude an actor or class from an item effect
# By Mithran
# Please do not resdistribute without asking!
# This restricts item usage of actors.
# In battle, this prevents any excluded actors or classes from using or being
# targeted by the item.
# In the menu screen, this will prevent the item from being used at all if none
# of the targets can be affected by it.

# Type <NO ACTOR n> in the notes field of an item where n is the actor id of
# the actor you want to exclude from the item effect
# Type <REQ ACTOR n> in the notes field of an item where n is the actor id of
# the actor you want to REQUIRE for the item effect
# Seperate multiple actor ids with commas

# Example:
# <NO ACTOR 1, 2, 4>
# The item would have no effect on Ralph, Ulrika, and Ylva.
# <REQ ACTOR 3>
# The item would only effect Bennett.

# Type <NO CLASS n> in the notes field of an item where n is the class id of
# the class you want to exclude from the item effect
# Type <REQ CLASS n> in the notes field of an item where n is the class id of
# the class you want to REQUIRE for the item effect
# Seperate class actor ids with commas

# <NO CLASS 1, 3>
# The item would have no effect on Paladins or Priests.
# <REQ CLASS 6>
# The item would only affect Dark Knights.

# If you restrict by both actor and class, BOTH will be required to get the item
# to work.

# ALL CAPS is required for these note tags

class Game_Battler
  alias item_effect_exclude_actor item_effect
  def item_effect(user, item)
    if actor?
      if item.exclude_actor(self)
        clear_action_results
        if $game_temp.in_battle
          @missed = true
          # so the failure message will display
        else
          @skipped = true
          # so the item will buzz and not be consumed
        end
        return
      end
    end
    item_effect_exclude_actor(user, item)
  end
  
end    
      
      
class RPG::Item
  def actor_exclude_list
    if note =~ /<NO\s?ACTOR\s?(\d+(,\s*\d+)?)>/
      x = $1.scan(/\d+/)
      result = []
      x.each_index { |i|
      result[i] = x[i].to_i
      }
      return result
    else
      return []
    end
  end

  def class_exclude_list
    if note =~ /<NO\s?CLASS\s?(\d+(,\s*\d+)?)>/
      x = $1.scan(/\d+/)
      result = []
      x.each_index { |i|
      result[i] = x[i].to_i
      }
      return result
    else
      return []
    end
  end
  
  def actor_require_list
    if note =~ /<REQ\s?ACTOR\s?(\d+(,\s*\d+)?)>/
      x = $1.scan(/\d+/)
      result = []
      x.each_index { |i|
      result[i] = x[i].to_i
      }
      return result
    else
      return []
    end
  end

  def class_require_list
    if note =~ /<REQ\s?CLASS\s?(\d+(,\s*\d+)?)>/
      x = $1.scan(/\d+/)
      result = []
      x.each_index { |i|
      result[i] = x[i].to_i
      }
      return result
    else
      return []
    end
  end
  
  def exclude_actor(actor)
    return true if !actor.is_a?(Game_Actor)
    return actor_exclude_list.include?(actor.id) || class_exclude_list.include?(actor.class_id) ||
      (!actor_require_list.empty? && !actor_require_list.include?(actor.id)) ||
      (!class_require_list.empty? && !class_require_list.include?(actor.class_id))
  end
  
end

class Scene_Battle < Scene_Base
  alias update_item_selection_exclude_actor update_item_selection
  def update_item_selection
    actor = @active_battler
    actor = @commander if @commander
    $game_temp.acs_item_selector = actor
    if @item_window != nil && @item_window.item != nil && @item_window.item.exclude_actor(actor) && Input.trigger?(Input::C)
      Sound.play_buzzer
      $game_temp.acs_item_selector = nil
      return
    end
    update_item_selection_exclude_actor
    $game_temp.acs_item_selector = nil
  end
  
  alias start_item_selection_exclude_actor start_item_selection
  def start_item_selection
    actor = @active_battler
    actor = @commander if @commander
    $game_temp.acs_item_selector = actor
    start_item_selection_exclude_actor
    $game_temp.acs_item_selector = nil
  end
  
  alias update_target_actor_selection_exclude_actor update_target_actor_selection
  def update_target_actor_selection
    if @item_window != nil && @item_window.item != nil && Input.trigger?(Input::C)
      actor = $game_party.members[@target_actor_window.index]
      if @item_window.item.exclude_actor(actor)
        Sound.play_buzzer
        return
      end
    end
    update_target_actor_selection_exclude_actor
  end

end

class Window_Item < Window_Selectable
  alias enable_exclude_actor enable?
  def enable?(item)
    return false if item != nil && $game_temp.in_battle && item.exclude_actor($game_temp.acs_item_selector)
    return enable_exclude_actor(item)
  end
end

class Game_Temp
  attr_accessor :acs_item_selector
end


Name by Party Index
Spoiler:
CODE
# sub name by party index. by Mithran
# Many message systems already have this.  Simple plug and play script replaces
# \p[#] with the name of the party member in that index.
# Indexes start at 0 and count up.  \p[0] gives the name of the party leader

class Window_Message < Window_Selectable
  alias convert_special_characters_partyindexnames convert_special_characters
  def convert_special_characters
    convert_special_characters_partyindexnames
    @text.gsub!(/\\P\[([0-9]+)\]/i) { $game_party.members[$1.to_i].nil? ? "unknown" : $game_party.members[$1.to_i].name }
  end
end


NoWeapon Select
Spoiler:
CODE
# Noweapon select
# by Mithran
# disables selecting of Weapon in equip scene
# set hide weapon to true to hide it completely
# Please do not redistribute without asking!

module NoWeaponSelect
  SCRIPT_USE = true # set to false to disable this script
  HIDE_WEAPON = false # set to true to show the weapon, but it will not be
  # selectable to be changed.
end

if NoWeaponSelect::SCRIPT_USE
class Window_Equip < Window_Selectable
  
  def update_cursor
    @index = 1 if @index == 0
    @index -= 1 if NoWeaponSelect::HIDE_WEAPON
    super
    @index += 1 if NoWeaponSelect::HIDE_WEAPON
  end

  def cursor_up(wrap = false)
    @index = 0 if @index == 1 && wrap
    super(wrap)
    @index = 1 if @index == 0
  end
  
  alias refresh_skipweapon refresh
  def refresh
    refresh_skipweapon
    if NoWeaponSelect::HIDE_WEAPON
      hgt = 0
      @item_max.times do hgt += WLH end
      buf = self.contents.clone
      rect = item_rect(1).clone
      rect.height = hgt
      self.contents.clear
      self.contents.blt(item_rect(0).x, item_rect(0).y, buf, rect)
      buf.dispose
    end
  end
  
end

class Scene_Equip
  
  alias initialize_skipweapon initialize
  def initialize(actor_index = 0, equip_index = 1)
    equip_index = 1 if equip_index == 0
    initialize_skipweapon(actor_index, equip_index)
  end
  
end
end


Actor Permanent Exp Link
Spoiler:
CODE
# Actor Exp Link
# By Mithran
# Links the Experience levels of two or more actors exactly.  If you want to
# link their levels, make sure they use the same exp tables.
# Simply put all the actors you want to link the exp of in a set of square
# brackets at the location noted below
# You may have several sets of actors with linked exp.  Cross-linking will not
# work, however (eg., linking [1, 2] and [2, 3] will not link 1 to 3)

# Install: Insert in the script editor above main and below default scripts.

module Mithran
  module ExpLink
    #links an actor's exp to another actors exp
    #if one's exp is changed, so is the others
    EXP_LINKS = [ # Do not alter this line
    # Add your actor exp link pairings below here
    # in a set of square brackets, put in all the actor ids you want to link
    # Format = [actorid1, actorid2, ... actor_id]
    # use a new line and new set of brackets between each one, dont forget the
    # comma after each set of brackets
#    [1, 2, 3, 4], # copy this line to use as a template
    # Links Ralph, Ulrika, Bennett and Ylva's xp.  Works even if they arent in
    # the party.
    # You may comment out or delete the above example as necessary
    
    # Add your sets of brackets above this line
    ] # Do not alter this line
  end
end

class Game_Actor
  alias change_exp_explink change_exp
  def change_exp(exp, show)
    change_exp_explink(exp, show)
    Mithran::ExpLink::EXP_LINKS.each { |ary|
      if ary.include?(self.id)
        ary.each { |a_id| $game_actors[a_id].change_exp_explink(exp, false) unless $game_actors[a_id].nil? or $game_actors[a_id] == self }
      end
    }
  end
end


Event Approach Detect
Spoiler:
CODE
# Event approach detect
# by Mithran
# In a conditional branch, use the advanced > Script command
# approach_detect(id1, id2)
# replace id1 and id2 with the event ids of the events you are testing
# this will return true if event 1 is approaching event 2
# if id 2 is omitted, it will refer to 'this event'
# Example:
# approach_detect(5)
# in a conditional branch will be true if event with id 5 is adjacent to and
# facing this event.

class Game_Interpreter
  def approach_detect(event_id1, event_id2 = 0)
    char1 = get_character(event_id1)
    char2 = get_character(event_id2)
    return false if char1.nil? or char2.nil?
    return char2.approach_detect(char1)
  end
end

class Game_Character
  def approach_detect(char)
    front_x = $game_map.x_with_direction(char.x, char.direction)
    front_y = $game_map.y_with_direction(char.y, char.direction)
    return true if [front_x, front_y] == [self.x, self.y]
    return false    
  end
end


Switch Save / Reset
Spoiler:
CODE
# Resets the self switches on a map
# By Mithran
# Useful for a puzzle type game, so you can still use self switches without
# having to reset them all if you need to reset the puzzle
# use the advanced > Script command
# reset_self_switches
# all self switches used by any event on the map will be set to false.

# Global switches or variables:
# You can explicitly save variables or switches at a certain point and
# reset them back to their saved positions at a later time by using the
# following Advanced > Script event commands:

# save_switches
# save_variables
# reset_switches
# reset_variables

class Game_Interpreter
  def reset_self_switches(map_id = 0)
    event_keys = []    
    if map_id == 0
      event_keys = $game_map.events.keys
      map_id = $game_map.map_id
    else
      event_keys = load_data(sprintf("Data/Map%03d.rvdata", map_id)).events.keys
    end
    event_keys.each { |event_id|
    for letter in "A".."D"
      $game_self_switches[[map_id, event_id, letter]] = false
    end
    }
  end
    
  # using Marshal to 'deep clone' the objects since their data arrays will remain
  # linked otherwise
  
  def save_switches
    $game_system.saved_switches = Marshal.load(Marshal.dump($game_switches))
  end
  
  def save_variables
    $game_system.saved_variables = Marshal.load(Marshal.dump($game_variables))
  end
  
  def reset_switches
    $game_switches = Marshal.load(Marshal.dump($game_system.saved_switches)) unless $game_system.saved_switches.nil?
  end
  
  def reset_variables
    $game_variables = Marshal.load(Marshal.dump($game_system.saved_variables)) unless $game_system.saved_variables.nil?
  end
  
end

class Game_System
  attr_accessor (:saved_switches, :saved_variables)
end


Kill Event Processing
Spoiler:
CODE
# Kill processing - event command that ends processing in the current event
# and ALL referring events.  
# originally by Mithran
# Use the as an advanced > Script event command
# kill_processing

class Game_Interpreter
  attr_accessor :next_kill_process
  
  def kill_processing
    if @main
      command_end # clears the event list, unlocks the event
    else
      @list = nil # clears the event list
      @next_kill_process = true # sets the next event up to be cleared
    end
  end
  
  alias update_KillProcess update
  def update
    update_KillProcess
    if @child_interpreter != nil && @child_interpreter.next_kill_process
      # sets kill processing flag
      self.kill_processing
      @child_interpreter = nil
    end
  end
  
  alias running_KillProcess running?
  def running?
    # tricks the system into thinking the event is still running until its
    # referring event can also be cleared
    return true if @next_kill_process
    return running_KillProcess
  end

end


Save Actor ID / Enemy Index
Spoiler:
CODE
# Save Actor ID  / Enemy Index
# By Mithran
# Saves the Actor ID of a skill or item USER into the variable of choice.
# For use with common events.
# You can use conditional branches to figure out what you want your triggered
# common event to do.
# If the user of a skill is an enemy, the saved index will be the negative value
# of their troop index.  
  # eg., 0 = troop index 0, or enemy 1
  # 1 = troop index 1, or enemy 2
  # etc., etc
# If an item is used in the 'item screen', the variable is set to the id of the
# actor who it is used on.  Actors are considered to use the items on themselves
# in this scene.  If the item is used without a target, or the target is the
# whole party, this variable is set to -100.
  
# other commands

# <NOMENUEVENT>
# all caps, no spaces required
# put this in the note field of a item or skill to make it not be able to trigger
# the common event from the menu screen.

# <NOBATTLEEVENT>
# all caps, no spaces required
# put this in the note field of a item or skill to make it not be able to trigger
# the common event from battle.

module SaveActorID
  VARIABLE_ID = 33
  # Change this to the varialbe ID you want to store the id of the last actor
  # to use a skill or item
  # if an enemy used a skill, this will be set to the negative value of their
  # troop index
end

class Scene_Battle
  alias execute_action_skill_last_actor execute_action_skill
  def execute_action_skill
    remember_actor_id
    execute_action_skill_last_actor
  end
  
  alias execute_action_item_last_actor execute_action_item
  def execute_action_item
    remember_actor_id
    execute_action_item_last_actor
  end
  
  def remember_actor_id
    if @active_battler.actor?
      $game_variables[SaveActorID::VARIABLE_ID] = @active_battler.id
    else
      $game_variables[SaveActorID::VARIABLE_ID] = -@active_battler.index
    end    
  end
  
end

class Scene_Skill
  alias determine_skill_last_actor determine_skill
  def determine_skill
    $game_variables[SaveActorID::VARIABLE_ID] = @actor.id
    determine_skill_last_actor
  end
end

class Scene_Item
  
  alias determine_target_last_actor determine_target
  def determine_target
    # because items in this window are used by the individual actors on themselves...
    if @item.for_all?
      $game_variables[SaveActorID::VARIABLE_ID] = -100
      # if the item was used on everyone, set the variable to -100
    else
      $game_variables[SaveActorID::VARIABLE_ID] = $game_party.members[@target_window.index].id
      # if the item was used on a specific actor, the user is this actor
    end
    determine_target_last_actor
  end

  alias determine_item_last_actor determine_item
  def determine_item
    $game_variables[SaveActorID::VARIABLE_ID] = -100
    # some items can be used without selecting a target at all, in which case
    # the variable is set to -100
    determine_item_last_actor
  end
  
end


class RPG::UsableItem
  alias common_event_id_lastactor common_event_id
  def common_event_id
    if !$game_temp.in_battle && self.no_menu_event
      return 0
    elsif $game_temp.in_battle && self.no_battle_event
      return 0
    else
      return common_event_id_lastactor
    end
  end
  
  def no_menu_event
    return true if self.note =~ /<NOMENUEVENT>/
    return false
  end
  
  def no_battle_event
    return true if self.note =~ /<NOBATTLEEVENT>/
    return false
  end
  
end


Limit Shopbuy
Spoiler:
CODE
# Limit Sell Items to Buy Item Selections
# by Mithran
# completely plug & play, just place above main in script editor
# If this script is on, shops will only sell items they can buy

module Mithran
  LIMIT_SELL_ITEMS = false
  # change this to false to disable this script
end

if Mithran::LIMIT_SELL_ITEMS
class Window_ShopSell < Window_Item
  alias include_limitsell include?
  def include?(item)
    return false if $game_temp.shop_goods == nil
    return false if item == nil
    for pair in $game_temp.shop_goods
      if item.is_a?(RPG::Item)
        return true if pair[0] == 0 && pair[1] == item.id
      elsif item.is_a?(RPG::Weapon)
        return true if pair[0] == 1 && pair[1] == item.id        
      elsif item.is_a?(RPG::Armor)
        return true if pair[0] == 2 && pair[1] == item.id
      end
    end
    return false
  end
end
end


Perserve HP/MP percentages when leveling
Spoiler:
CODE
# Keep HP and MP percent when changing levels
# By Mithran
# Insert in the materials section of the script editor.

module Mithran
  module LvlHpMpPct
    USE_HP = true
    # turn this to false to stop perserving hp percent
    USE_MP = true
    # turn this to false to stop perserving mp percent
    USE_LEVEL_DOWN = true
    # turn this to false to stop modifying hp and/or mp when leveling down
  end
end

class Game_Actor < Game_Battler
  
  alias change_exp_before_perserve_pct change_exp
  def change_exp(*args)
    last_level = @level
    old_hp_pct = hp * 100 / maxhp
    old_mp_pct = maxmp != 0 ? mp * 100 / maxmp : 0
    change_exp_before_perserve_pct(*args)
    if @level > last_level or (@level < last_level && Mithran::LvlHpMpPct::USE_LEVEL_DOWN)
      self.hp = maxhp * old_hp_pct / 100 if Mithran::LvlHpMpPct::USE_HP
      self.mp = maxmp * old_mp_pct / 100 if Mithran::LvlHpMpPct::USE_MP
    end
  end
  
end


No Unequip to Empty Slot
Spoiler:
CODE
# No Unequip to empty item slot
# By Mithran
# Simply Set up the items slots you want to never been empty in the module.
# These slots will not allow the user to unequip an item in that slot to nothing.
# This prevents the slot from ever being empty.

module Mithran
  module NoUnequip
    NO_UNEQUIP_EMPTY_TYPES = [-1, 3]
    # Encase in brackets and use a comma to seperate each entry.
    # Above example: Weapon and accessory will not be unequippable to nothing.  
    # Equipment can be changed normally otherwise.
    # Change above as you see fit, but do not delete the line.  If you want
    # all items to be removeable normally, use this line instead:
    NO_UNEQUIP_EMPTY_TYPES = []
    # Types
    # -1 = weapon, 0 = shield, 1 = helm, 2 = body, 3 = accessory
    # If additional types are added by a script, such as KGC EquipExtension
    # the numbers for extra equipment types should match what is set up in that
    # script
        
  end
end

class Window_EquipItem < Window_Item
  include Mithran::NoUnequip
  alias include_nounequip include?
  def include?(item)
    if item == nil
      return false if NO_UNEQUIP_EMPTY_TYPES.include?(@equip_type - 1)
    end
    return include_nounequip(item)
  end
end

class Scene_Equip < Scene_Base
  alias update_equip_selection_nounequip update_equip_selection
  def update_equip_selection
    if @item_window.item_max == 0 && Input.trigger?(Input::C)
      Sound.play_buzzer
      return
    else
      update_equip_selection_nounequip
    end
  end
end


HP/MP/Cri Equipment Quickfixes (2 scripts in 1)
Spoiler:
CODE
# Modify maxhp /maxmp on items
# By Mithran
# In the items note field, type:
# <MAXHP (+or-) n>
# or
# <MAXMP (+or-) n>
# Where n is the amount you want to increase maxhp or mp by
# use + to add and - to subtract
# Examples:
# <MAXHP + 100> adds 100 HP
# <MAXHP - 100> subtracts 100 HP
# <MAXMP 200> adds 200 MP (defaults to plus if no sign is given)
# all caps is required

# adding a percent sign to the end adds based on the players base maxhp or maxmp:
# <MAXMP + 25%>
# adds 25% to the battlers max MP
# <MAXMP - 100%>
# base maxMP becomes zero, unless added directly by another piece of equipment

# Insert this script on its own page in the script editor in materials.

class RPG::BaseItem
  def maxhp_QF
    if note =~ /<MAXHP\s?([-+])?\s?(\d+)>/
      if $1 == "-"
        return -$2.to_i
      else
        return $2.to_i
      end
    end
    return 0
  end

  def maxmp_QF
    if note =~ /<MAXMP\s?([-+])?\s?(\d+)>/
      if $1 == "-"
        return -$2.to_i
      else
        return $2.to_i
      end
    end
    return 0
  end
  
  def maxhp_rate_QF
    if note =~ /<MAXHP\s?([-+])?\s?(\d+)%>/
      if $1 == "-"
        return -$2.to_i
      else
        return $2.to_i
      end
    end
    return 0
  end

  def maxmp_rate_QF
    if note =~ /<MAXMP\s?([-+])?\s?(\d+)%>/
      if $1 == "-"
        return -$2.to_i
      else
        return $2.to_i
      end
    end
    return 0
  end

end

class Game_Battler
  alias maxhp_QF_equip maxhp
  def maxhp
    n = maxhp_QF_equip
    return n unless actor?
    for item in equips.compact
      n += item.maxhp_QF
    end
    for item in equips.compact
      n += maxhp_QF_equip * (item.maxhp_rate_QF / 100.0)
    end
    n = n.round
    n = [[n, maxhp_limit].min, 1].max
    @hp = n if @hp > n
    return n
  end
  
  unless method_defined?(:maxmp_limit)
  def maxmp_limit
    return 9999
  end
  end
  
  alias maxmp_QF_equip maxmp
  def maxmp
    n = maxmp_QF_equip
    return n unless actor?
    for item in equips.compact
      n += item.maxmp_QF
    end
    for item in equips.compact
      n += maxmp_QF_equip * (item.maxmp_rate_QF / 100.0)
    end
    n = n.round
    n = [[n, maxmp_limit].min, 0].max
    @mp = n if @mp > n
    return n
  end
  
end

# Alter Crit Rate QuickFix
# Put the note tag <CRI +n> in equipment fields or enemy note tags to alter
# their crit.  Replace n with the number you want to boost crit by.  Caps is
# required.
# Author gives permission to use this whereever, no credit needed.

class Game_Actor < Game_Battler
  alias cri_QF_alter_cri cri
  def cri
    n = cri_QF_alter_cri
    for item in equips.compact
      if item.note =~ /<CRI \+(\d+)>/
        n += $1.to_i
      end
    end
    return n
  end
end

class Game_Enemy < Game_Battler
  alias cri_QF_alter_cri cri
  def cri
    n = cri_QF_alter_cri
    if enemy.note =~ /<CRI \+(\d+)>/
      n += $1.to_i
    end
    return n
  end
end


Change Class State
Spoiler:
CODE
# Swap Class With State
# v 2.0 By Mithran
# use the note tag in the state:
# <class state n>
# where n is the new class id
# if the class is invalid, the class will not be changed
# If you layer multiple states with this effect, the last one applied will take
# effect.
# If you layer multiple states that transform to the same class, and one
# is removed, the class will revert.
# Note: Conditional Autostates (or other autostates) cannot be class change
# states.  It must be a state that is added, because the class change occurs
# when the state is added.  Using a conditional autostate's activation to remove
# the state is fine, if you have the patch listed below.
# Install: Insert above main in materials section of the script editor.

class Game_Actor
  
  alias setup_ClassStateSwap setup
  def setup(actor_id)
    # sets up the actor and saves the real class id into a variable
    setup_ClassStateSwap(actor_id)
    @true_class_id = @class_id
  end
  
  def state_class_id
    # a wrapper for @true_class_id
    # returns the latest applied state class, if it exisits, as a class id
    # if it doesn not, returns the true class id
    @state_class_ids ||= []
    return @true_class_id ||= @class_id if @state_class_ids[0].nil?
    return @state_class_ids[0]
  end

  alias :class_id_ClassStateSwap= :class_id=
  def class_id=(new_class_id)
    self.class_id_ClassStateSwap = new_class_id
    unless @state_class_swapping
      # true class id is only changed if the class change occurs outside
      # of state_class_swap
      @true_class_id = new_class_id
      for i in @states.clone
        # removes all class swap states on a normal class change
        remove_state(i) if $data_states[i].class_swap
      end
    end
  end

  def state_class_swap(new_class_id)
    # a wrapper for class change    
    # ensures that the real class id remains untouched
    @state_class_swapping = true
    self.class_id = new_class_id # executes class change to new class
    @state_class_swapping = false
    # all normal class change code is executed
    # Because the @state_class_swapping variable is set, true class id remains
    # untouched
  end

  def check_classstates
    if self.state_class_id != self.class.id
      self.state_class_swap(self.state_class_id)
    end
  end
  
end

class RPG::State
  
  def class_swap
    if note =~ /<class state (\d+)>/i
      # parses the note, if the correct note is found, returns the number at the
      # end
      n = $1.to_i
      return n if $data_classes[n] != nil
    end
    return false
  end
  
end
    
class Game_Battler
  alias add_state_ClassStateSwap add_state
  def add_state(state_id)
    return add_state_ClassStateSwap(state_id) unless actor?
    # wrapper for add state, cuts short if run on an enemy
    @state_class_ids ||= [] # creates an array if the variable is false or nil
    add_state_ClassStateSwap(state_id) # run original add state
    state = $data_states[state_id]
    return if state.nil?
    if state.class_swap
      @state_class_ids.unshift(state.class_swap).uniq!
      # add the fake class to the array
    end
    check_classstates
  end

  alias remove_state_ClassStateSwap remove_state
  def remove_state(state_id)
    return remove_state_ClassStateSwap(state_id) unless actor?
    # wrapper for remove state, cuts short if run on an enemy
    @state_class_ids ||= [] # creates an array if the variable is false or nil
    remove_state_ClassStateSwap(state_id) # run original remove state
    state = $data_states[state_id]
    return if state.nil?
    if state.class_swap # if the note tag on the state is present
      @state_class_ids.delete(state.class_swap) # remove the fake class from array
    end
    check_classstates
  end
  
end


Class States removal by Conditional Autostate *PATCH*
Spoiler:
CODE
# A small patch for compatability between conditional autostates and Class States
# This patch only makes it so that if an autostate becoming active forcibly
# removes a 'class state', the class change goes with it.
# Class States themselves still cannot be autostates
# This patch goes directly below conditional autostates and should not be used
# unless it is installed
class Game_Battler
  def remove_state_from_autostate(state_id)
    if state_id == 1 and @hp == 0         # If it is incapacitated (state 1)
      @hp = 1                             # Change HP to 1
    end
    @states.delete(state_id)              # Remove the ID from the @states
    @state_turns.delete(state_id)         # Remove from the @state_turns
    return unless actor?
    @state_class_ids ||= [] # creates an array if the variable is false or nil
    state = $data_states[state_id]
    return if state.nil?
    if state.class_swap # if the note tag on the state is present
      @state_class_ids.delete(state.class_swap) # remove the fake class from array
    end
    check_classstates
  end
end


Example Hud
Spoiler:
CODE
# Extremely Simple Hud (with comments) by Mithran
# Turn the switch on to activate the HUD
# Unedited, this will display a portrait, HP, and MP of the lead actor in the
# upper left hand corner of the screen (while the switch is on)
# Feel free to edit, distribute, and otherwise alter this as you see fit.
# No credit is needed for usage.  However, if you post it unedited, please do
  # not claim it as your own work.
  
# Install: Insert above main in the materials section of the script editor.

module HudUp
  SWITCH_ID = 22
  # turn this switch on to activate the hud
end

class Window_HUD < Window_Base
  def initialize(actor)
    # initialize - run when the object is created
    # in this case, the intialize takes one argument, and it should be an actor
    # this actor is saved in the window internally, so we can easily reference
    # them.
    @actor = actor
    super(20, 20, 152, 176) # (x, y, width, height)
    # the window is created 20 pixles to the right of the left hand side of the
    # screen, 20 pixles down from the top, 152 pixels wide, 176 pixels high
    self.visible = $game_switches[HudUp::SWITCH_ID] # sets visibility to the switch state
    refresh # draws everything in the window
  end

  def refresh
    if @actor.nil?  # window becomes invisible if the actor is not valid
      self.visible = false
      return
    end
    self.contents.clear # clears window
    draw_actor_face(@actor, 0, 0) # controls where face is drawn
    draw_actor_hp(@actor, 0, 96) # controls where hp is drawn
    draw_actor_mp(@actor, 0, 96 + WLH) # controls where mp is drawn
    @last_hp = @actor.hp
    @last_mp = @actor.mp
    @last_face = @actor.face_name
    @last_face_index = @actor.face_index
    # above - sets a bunch of window instance variables to the values
    # that we are tracking.  If any of these values change, we need to re-draw
    # the window contents.  This is checked in the update method below.
    # However, if they remain the same, we skip the redraw so we dont lag.
  end

  def update
    super # run update method of Window_Base
    return if @actor.nil? # do not update further if no actor is associated
    self.visible = $game_switches[HudUp::SWITCH_ID] # sets visibility to the switch state
    return unless self.visible # no further checks are needed if the window is not seen
    if @last_hp != @actor.hp or @last_mp != @actor.mp or @last_face != @actor.face_name or @last_face_index != @actor.face_index
      # checks if any of the values do not match the other values
      refresh
    end
  end
  
  attr_reader :actor # makes the instance variable @actor able to be seen outside the current scope
  
#~   def actor
#~     @actor
#~   end
  
  def actor=(new_actor) # assingment method
    # allows a new value to be assigned to @actor from outside the current scope
    if (new_actor.is_a?(Game_Actor) or new_actor.nil?) && @actor != new_actor
      # assignment will only occur if the given variable is an actor or nil
      # assignment will also only occur if the new actor differs from the old one
      @actor = new_actor
      refresh # on assignment, automatically refresh the window
    end
  end
  
end

class Scene_Map
  alias start_HudUp start # alias - create a copy of the method
  def start
     @hud_window = Window_HUD.new($game_party.members[0]) # create the window
     # index 0 of party members is being used as the argument here, therefore
     # we are creating a window that references the party leader
     start_HudUp # run original start
  end

  alias terminate_HudUp terminate # alias - create a copy of the method
  def terminate
     # aliased terminate of map scene, disposes hud window
     @hud_window.dispose
     terminate_HudUp
  end

  alias update_HudUp update # alias - create a copy of the method
  def update # frame update, run once per frame
    if $game_party.members[0] != @hud_window.actor
      # compare the current party leader to the hud window's actor
      # if they differ
      @hud_window.actor = $game_party.members[0]
      # make the window reference the new actor.
    end
    @hud_window.update # update the hud window.  Handles refreshing if data has
    # changed.
    update_HudUp
  end
end


Eva Bonus from Agi
Spoiler:
CODE
# Install: Insert in materials section of the script editor.
# Feel free to edit and repost as you see fit.  Please do not
# repost the unedited version and take credit, however.
module AgiToEva
  APPE = 15
  # Agility Points Per Evasion - how many agility points you need for a single
  # evasion point bonus.  Always rounds down.
  EFA_CAP = 50
  # Evasion From Agility Cap - max amount of EVA points can be added by atility
  
  EVA_CAP = 1000
  # True Max EVA cap, recommend you just cap out the bonus agility and keep raw
  # eva numbers low instead of having a true hard cap
  # having this over 100 essentially means no cap
end

class Game_Actor
  
  alias eva_before_agi eva
  def eva
    n = eva_before_agi # get raw evasion
    raw_agi = [actor.parameters[5, @level] + @agi_plus, 0].max
    # get raw agi, agility without equipment or states, minimum of 0
    bonus_eva = [raw_agi / AgiToEva::APPE, AgiToEva::EFA_CAP].min
    # get bonus eva, capped at EFA_CAP
    n += bonus_eva # add agi bonus eva
    n = [n, AgiToEva::EVA_CAP].min # reduces agi to the absolute cap, if necessary
    return n # returns the modified evasion
  end
  
end

class Game_Enemy
  
  alias eva_before_agi eva
  def eva
    n = eva_before_agi # get raw evasion
    raw_agi = [enemy.agi + @agi_plus, 0].max
    # get raw agi, agility without states, minimum of 0
    bonus_eva = [raw_agi / AgiToEva::APPE, AgiToEva::EFA_CAP].min
    # get bonus eva, capped at EFA_CAP
    n += bonus_eva # add agi bonus eva
    n = [n, AgiToEva::EVA_CAP].min # reduces agi to the absolute cap, if necessary
    return n # returns the modified evasion
  end
  
end


Skip Title
Spoiler:
CODE
# Skip Title
# By Mithran
# tons of these have been done, this is just my version
# only works in playtest
module Mithran
  SKIP_TITLE = false
  # turn this to false to reenable title
end

class Scene_Title
  alias main_skiptitle main unless $@
  def main
    if Mithran::SKIP_TITLE && $TEST && !$BTEST
      skip_title
      return
    end
    main_skiptitle
  end
  
  def skip_title
    load_database
    create_game_objects
    confirm_player_location
    $game_party.setup_starting_members            # Initial party
    $game_map.setup($data_system.start_map_id)    # Initial map position
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    $game_player.refresh
    $scene = Scene_Map.new
    Graphics.frame_count = 0
    RPG::BGM.stop
    $game_map.autoplay
  end

end


Player Turn In Place
Spoiler:
CODE
# Player turn in place
# By Mithran
# Install: Import the script in the materials section.
# Usage: Hold down the specificed button to make the player turn in place instead of moving.

module TurnInPlace
  USE_KEY = true # change to false to disable key
  KEY = Input::ALT # Key used to force a turn in place
  TAP = true # if set to true, tapping a direction will turn in place instead of moving
  TAP_FRAMES = 5 # how many frames must the button be held before moving
  # 60 frames = 1 second
  # The default (5) is less than a tenth of a second.  Please do not come back saying
  # it does not work before checking that you may be pressing the button too long.
  # (also ignored if dashing, or continually moving in the same direction)
end

class Game_Player < Game_Character
  ['up', 'down', 'left', 'right'].each { |dir|
  aStr = %Q(
  alias move_#{dir}_turn_in_place move_#{dir}
  def move_#{dir}(turn_ok = true)
    if @tap_dir != Input.dir4 && @mv_by_input_trig
      @tap_dir = Input.dir4
      @last_move = nil
      @tap_frames = 0
    end
    @tap_frames = 0 unless @mv_by_input_trig
    if @mv_by_input_trig && TurnInPlace::USE_KEY && Input.press?(TurnInPlace::KEY)
      turn_#{dir} if turn_ok
      return
    end
    if @mv_by_input_trig && TurnInPlace::TAP && Input.press?(Input::#{dir.upcase})
      turn_#{dir} if turn_ok
      @tap_frames ||= 0
      @tap_frames += 1
      if @tap_frames > TurnInPlace::TAP_FRAMES or @last_move == Input.dir4 or dash?
        @tap_frames = 0
      else
        return
      end
    end
    move_#{dir}_turn_in_place(turn_ok)
    @last_move = @direction
  end
  )
  module_eval(aStr)
  }
  
  alias move_by_input_turn_in_place move_by_input
  def move_by_input
    @mv_by_input_trig = true
    move_by_input_turn_in_place
    @mv_by_input_trig = false
  end
end


Player Turn In Place (KGC 8dir)
Spoiler:
CODE
# Player turn in place (KGC_8Dir Verson)
# By Mithran
# Install: Import the script in the materials section, below KGC_8dir
# Usage: Hold down the specificed button to make the player turn in place instead of moving.

module TurnInPlace
  USE_KEY = true # change to false to disable key
  KEY = Input::ALT # Key used to force a turn in place
  TAP = true # if set to true, tapping a direction will turn in place instead of moving
  TAP_FRAMES = 5 # how many frames must the button be held before moving
  # 60 frames = 1 second
  # The default (5) is less than a tenth of a second.  Please do not come back saying
  # it does not work before checking that you may be pressing the button too long.
  # (also ignored if dashing, or continually moving in the same direction)
end

class Game_Player < Game_Character
  ['up', 'down', 'left', 'right'].each { |dir|
  aStr = %Q(
  alias move_#{dir}_turn_in_place move_#{dir}
  def move_#{dir}(turn_ok = true)
    return if @dbl_move_stop
    if @tap_dir != Input.dir8 && @mv_by_input_trig
      @tap_dir = Input.dir8
      @last_move = nil
      @tap_frames = 0
    end
    @tap_frames = 0 unless @mv_by_input_trig
    if @mv_by_input_trig && TurnInPlace::USE_KEY && Input.press?(TurnInPlace::KEY)
      set_direction(Input.dir8) if turn_ok
      return
    end
    if @mv_by_input_trig && TurnInPlace::TAP && Input.press?(Input::#{dir.upcase})
      set_direction(Input.dir8) if turn_ok
      @tap_frames ||= 0
      @tap_frames += 1
      if @tap_frames > TurnInPlace::TAP_FRAMES or @last_move == Input.dir8 or dash?
        @tap_frames = 0
      else
        @dbl_move_stop = true
        return
      end
    end
    move_#{dir}_turn_in_place(turn_ok)
    @last_move = @mv_by_input_trig ? Input.dir8 : nil
  end
  )
  module_eval(aStr)
  }
  
  alias move_by_input_turn_in_place move_by_input
  def move_by_input
    @mv_by_input_trig = true
    move_by_input_turn_in_place
    @reserved_move = nil if (@tap_frames ||= 0) != 0 or (TurnInPlace::USE_KEY && Input.press?(TurnInPlace::KEY))
    # do not reserve moves if you are turning in place
    @dbl_move_stop = false # kills the flag to stop double movement
    @mv_by_input_trig = false
  end
end


Advanced Force Action
Spoiler:
CODE
# Advanced forced action
# by Mithran
# Use an Advanced > Script event command to trigger
# use a seperate 'script' entry for each one

# format is:
# force_action(A, B, C, D, E)
# replace A with the group you want to pick the actor or enemy out of
#  -1 = target actors by index
#   0 = target enemies by troop index
#   1 = target actors by party index

# replace B with the index of the actor or enemy you want to pick
# for troop and party, the index number starts at zero
# (eg., default party is 0 Ralph, 1 Ulrika, 2 Bennett, 3 Ylva)
# actor index starts at 1
# (eg., default party is 1 Ralph, 2 Ulrika, 3 Bennett, 4 Ylva)

# Replace C with the kind of action you want to force
# 0 = basic
# 1 = skill
# 2 = item  *
# *ignored on enemies  
# *Item is still consumed, but it is not checked before using.  May change this later.

# Replace D with the id of the action you want to perform
# if C is basic (0)
#  0 - attack
#  1 - guard
#  2 - escape*
#  3 - wait
# *escape is ignored on actors
# if C is skill or item
#  the id of the item or skill you are selecting to force

# Replace E with the index of the target you want to force to
# -2 = select the last target*
# -1 = choose a random target
#  0 or above = pick the selected group index
# *if the previous action had no target, this forced action will be ignored

# Example:
# force_action(-1, 1, 1, 2, -2)
# forces Ralph (if he is in the party) to use double attack on the last enemy he
# targeted

module Mithran
  module ForceAction
    module_function
    def force_action(group, index_id, kind, basic_id, target_id, scope_change = false)
      battler = nil
      if group == -1
        battler = $game_actors[index_id]
        return if !$game_party.members.include?(battler)
      elsif group == 0
        battler = $game_troop[index_id]
      else
        battler = $game_party[index_id]
      end
      return if battler.nil?
      return if !battler.exist?
      case kind
      when 1
        skill = $data_skills[basic_id]
        return if skill.nil?
        battler.action.set_skill(basic_id)
      when 2
        item = $data_items[basic_id]
        return if item.nil?
        return if !battler.actor?
        battler.action.set_item(basic_id)
      else
        case basic_id
        when 0  # Attack
          battler.action.set_attack
        when 1  # Guard
          battler.action.set_guard
        when 2  # Escape
          battler.action.kind = 0
          if battler.actor?
            battler.action.basic = 3
          else
            battler.action.basic = 2
          end
        else  # Wait
          battler.action.kind = 0
          battler.action.basic = 3
        end
      end
      case target_id
      when -2
        battler.action.decide_last_target
      when -1
        battler.action.decide_random_target
      when 0..99
        battler.action.target_index = target_id
      end
      battler.action.forcing = true
      $game_troop.forcing_battler = battler
      @wait_count += 1
    end
  end
end

class Game_Interpreter
  include Mithran::ForceAction
end


Once Per Battle Skill
Spoiler:
CODE
# Once per battle skill
# by Mithran
# Add the note tag <ONCE> to a skill to restrict it to being used only one time in that battle.

class RPG::BaseItem
  def once_per_battle?
    return false
  end
end

class RPG::Skill
  def once_per_battle?
    return self.note =~ /<ONCE>/
  end
end

class Game_Battler
  attr_accessor :used_skills
  alias skill_can_use_xone skill_can_use?
  def skill_can_use?(skill)
    if $game_temp.in_battle
      return false if skill.once_per_battle? and used_skills.include?(skill.id)
    end
    return skill_can_use_xone(skill)
  end
  def used_skills
    @used_skills = [] if @used_skills == nil
    return @used_skills
  end
end

class Scene_Battle
  alias execute_action_skill_xone execute_action_skill
  def execute_action_skill
    skill = @active_battler.action.skill
    if skill.once_per_battle?
      @active_battler.used_skills.push(skill.id) unless @active_battler.used_skills.include?(skill.id)
    end
    execute_action_skill_xone
  end
  
  alias process_battle_start_xone process_battle_start
  def process_battle_start
    clear_used_skills
    process_battle_start_xone
  end
  
  def clear_used_skills
    all = $game_party.members + $game_troop.members
    all.each { |member|
    member.used_skills = []
    }
  end
  
  alias terminate_xone terminate
  def terminate
    clear_used_skills
    terminate_xone
  end
end


Clock Window Draw (HUD)
Spoiler:
CODE
# Variable Clock Window Draw
# By Mithran
# Initially Requested by Klex1992
# Additional features requested by metaknight2000
# Draws a clock on the Map scene with 'hours' and 'minutes'
# The clock is either based off two variables, which the user must manually update,
# or is automatically updated with Kylock Time System.
# : symbol blinks on and off
# Set the options in the module
# The "X" button (keyboard A) toggles clock window position on screen in game
# The user is responsible for updating the variables used for the clock.
# See the module for customization options.
# Install: Insert in the materials section of the script editor above main.
# Goes below Kylock Time System, on the scripts list if used.
# Please do not redistribute without asking!

# Event Commands
# Event > Advanced > Script (type exactly how shown, without the leading #)

# hide_clock
# Hides the clock window.

# show_clock
# Shows the clock window.

# set_clock_position(n)
# n = 1, 2, 3, 4, or 0.  Sets the clock to the appropraite screen position, shown
# below.

module DrawClock
  KYLOCK_TIME_SYSTEM = false
  # Setting this to true will sync the clock to the time of the Kylock Time System
  # If this setting is true, ignore the variable settings below.
  HIDE_LEADING_0HR = false
  # Set this option to true to hide a leading zero on the 'hours' portion of the
  # clock.  If set to false, the format will be HH:MM
  
  MINS_VAR_ID = 61
  # Variable ID of minutes
  HOURS_VAR_ID = 62
  # Variable ID of hours
  POSITION = 2
  # Initial position
  # 1 = upper left
  # 2 = lower left
  # 3 = upper right
  # 4 = lower right
  # if set to 0, the clock is not shown until the "X" button is pressed
  # (keyboard A)
  INITIAL_HIDE = false
  # Clock hide value on startup.  When set to true, the clock his hidden.
  # If set to false, the clock is shown from the first map screen.
  
  SHOW_WINDOW = true
  # If set to false, no window will be drawn around the clock.  
  # If set to true, the normal windowskin window will be shown.
  BACK_OPACITY = 100
  # The opacity value of the back of the window.  
  # 200 is default window transparency (slightly transparent), 255 is max
  # The lower the value, the more transparent the window back is.
  # If set to 0, the back is completely transparent.
  # This only applies if the window is not already hidden in the above option.
  CUSTOM_SKIN = false
  # The name of your custom window skin, if applicable, in quotes.  
  # Windowskin must be imported into Graphics\System folder.
  # Setting this option to false (without quotes) uses the default skin
  # Example: CUSTOM_SKIN = "WindowA"
  
  FIX_POSITION = false
  # If set to true, the clock position will not be moveable by the "X" button
  # It may still be moved through the script command.
  BLINK_INTERVAL = 120
  # The ":" blink interval, in frames.  If set to 0, blinking is disabled.
  # 120 frames is approximately 2 seconds (1 second on, 1 second off)
  # Blinking is completely disabled if set to 0
end

#====================== DO NOT CHANGE ANYTHING BELOW HERE ======================

class Scene_Map < Scene_Base
  attr_reader :clock_window
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  alias start_clock start
  def start
    start_clock
    @clock_window = Window_Clock.new($game_system.clock_draw_posx, $game_system.clock_draw_posy)
    @clock_window.openness = 0 if $game_system.clock_draw_pos == 0
  end
  
  def clock_draw_posx
    return DrawClock::POSITION
  end

  def clock_draw_posy
    return DrawClock::POSITION
  end
  
  alias update_clock update
  def update
    if Input.trigger?(Input::X) && !DrawClock::FIX_POSITION
      @clock_window.shift_pos if @clock_window.visible
    end
    @clock_window.update
    update_clock
  end
  
  alias terminate_clock terminate
  def terminate
    @clock_window.dispose
    terminate_clock
  end
end

class Window_Clock < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, 12 * 5 + 32, WLH + 32 - 12)
    self.windowskin = Cache.system(DrawClock::CUSTOM_SKIN) if DrawClock::CUSTOM_SKIN
    self.opacity = 0 unless DrawClock::SHOW_WINDOW
    self.back_opacity = DrawClock::BACK_OPACITY if DrawClock::BACK_OPACITY
    if DrawClock::KYLOCK_TIME_SYSTEM && KTS::AMPM
      self.width += 30
      create_contents
    end
    update
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_time
  end
  
  def update
    super
    self.visible = !$game_system.hide_clock
    if self.openness == 0 && $game_system.clock_draw_pos > 0
      self.x = $game_system.clock_draw_posx
      self.y = $game_system.clock_draw_posy
      self.open
    end
    update_clock if self.openness > 0
  end
  
  def shift_pos
    last_pos = $game_system.clock_draw_pos
    $game_system.clock_draw_pos += 1
    if $game_system.clock_draw_pos > 4
      $game_system.clock_draw_pos = 0
    end
    self.close if last_pos != $game_system.clock_draw_pos
    update
  end
  
  def set_pos(n)
    last_pos = $game_system.clock_draw_pos
    $game_system.clock_draw_pos = n
    if $game_system.clock_draw_pos > 4
      $game_system.clock_draw_pos = 0
    end
    self.close if last_pos != $game_system.clock_draw_pos
    update
  end
  
  def update_clock
    last_mins = @mins
    last_hrs = @hrs
    last_ampm = @ampm
    @mins = $game_variables[DrawClock::MINS_VAR_ID]
    @hrs = $game_variables[DrawClock::HOURS_VAR_ID]
    if DrawClock::KYLOCK_TIME_SYSTEM
      @mins = $kts.minutes
      @hrs = $kts.hours
      @ampm = $kts.getTime[-2, 2] if KTS::AMPM
    end
    @blink_counter ||= 0
    @blink_counter += 1
    if DrawClock::BLINK_INTERVAL > 0
      @blink_counter %= DrawClock::BLINK_INTERVAL
    else
      @blink_counter = 0
    end
    last_dots_on = @dots_on
    if @blink_counter <= DrawClock::BLINK_INTERVAL / 2
      @dots_on = true
    else
      @dots_on = false
    end
    if (last_dots_on != @dots_on) || (last_mins != @mins) || (last_hrs != @hrs) || (last_ampm != @ampm)
      refresh
    end
  end
    
  def draw_time
    mins = @mins
    hrs = @hrs
    sep = @dots_on ? ":" : " "
    if mins < 10
      mins = "0" + mins.to_s
    else
      mins = mins.to_s
    end
    if hrs < 10
      hrs = "0" + hrs.to_s unless DrawClock::HIDE_LEADING_0HR
    else
      hrs = hrs.to_s
    end
    cw = 12
    self.contents.draw_text(0 - 1, 0 - 7, cw * 2, WLH, hrs, 2)
    self.contents.draw_text(0 + (cw * 2) - 2, 0 - 7, cw, WLH, sep, 2)
    self.contents.draw_text(0 + (cw * 3) - 2, 0 - 7, cw * 2, WLH, mins, 2)
    if DrawClock::KYLOCK_TIME_SYSTEM && KTS::AMPM
      self.contents.draw_text(0 + (cw * 5.5) - 2, 0 - 7, cw * 2.5, WLH, @ampm)
    end
  end
    
end

class Game_System
  attr_accessor :clock_draw_pos
  attr_accessor :hide_clock
  
  def hide_clock
    @hide_clock = DrawClock::INITIAL_HIDE if @hide_clock == nil
    return @hide_clock
  end
  
  def clock_draw_pos
    @clock_draw_pos ||= DrawClock::POSITION
    return @clock_draw_pos
  end
  
  def clock_draw_posx
    posx = 32
    posy = 416 - 32 - 16 - 16
    case clock_draw_pos
    when 1
      posx = 32
      posy = 32
    when 2
      posx = 32
      posy = 416 - 32 - 16 - 16
    when 3
      posx = 544 - 32 - (12 * 5) - 32
      posy = 32
      posx -= 12 * 3 if DrawClock::KYLOCK_TIME_SYSTEM && KTS::AMPM
    when 4
      posx = 544 - 32 - (12 * 5) - 32
      posx -= 12 * 3 if DrawClock::KYLOCK_TIME_SYSTEM && KTS::AMPM
    end
    return posx
  end
  
  def clock_draw_posy
    posx = 32
    posy = 416 - 32 - 16 - 16
    case clock_draw_pos
    when 1
      posy = 32
    when 2
      posx = 32
      posy = 416 - 32 - 16 - 16      
    when 3
      posx = 544 - 32 - (12 * 5) - 32
      posy = 32
    when 4
      posx = 544 - 32 - (12 * 5) - 32
    end
    return posy
  end
  
end

class Game_Interpreter
  def hide_clock
    $game_system.hide_clock = true
  end
  
  def set_clock_position(n)
    if $scene.is_a?(Scene_Map)
      $scene.clock_window.set_pos(n)
    else
      $game_system.clock_draw_pos = n
    end
  end
  
  def show_clock
    $game_system.hide_clock = false
  end
end

class Kylock_Time_System
  attr_reader (:minutes, :hours)
end


Battle Equip Window
Spoiler:
CODE
# Battle Equip v 1.0
# By Mithran at RMVX.net
# Please do not redistribute without asking.
# Enables changing of equipment freely in battle.
# Use the "X" button (Keyboard A) during actor command selection to open the
# window.  
# Compatable with some SBS and ATBs.
# Install: Insert in materials above main and below custom battle system scripts.
# To enable battle equip during play, use the Event Advanced > Script command:
# $game_system.enable_battle_equip = true
# To disable during play, use the Event Advanced > Script command:
# $game_system.enable_battle_equip = false

module Mithran
  module BattleEquip
    ENABLE = true
    # If set to false, equip in battle will be enabled.
    USE_BUZZ = true
    # If set to false, no buzzer sound will be played when trying to use the
    # battle equip command if it is disabled.  This only applies to the buzzer
    # for the intial opening of the equipment window, if the above option is
    # set to false.
  end
end

$imported ||= {}
$imported["BattleEquip"] = true

class Scene_Battle < Scene_Base
  alias update_orig_battlequip update
  def update
    if @equip_item_window != nil
      super
      update_equipitem_window
    elsif @equip_window != nil
      super
      update_equip_window
    else
      update_orig_battlequip
    end
  end
  
  alias update_basic_battlequip update_basic
  def update_basic(main = false)
    if defined?(N02)
      if @equip_item_window != nil || @equip_window != nil
        update_basic_atb_fix(main)
      else
        update_basic_battlequip(main)
      end
    else
      update_basic_battlequip(main)
    end
  end
  
  def update_basic_atb_fix(main = false)
    Graphics.update unless main     # Update game screen
    Input.update unless main        # Update input information
    $game_system.update             # Update timer
    $game_troop.update              # Update enemy group
    @spriteset.update               # Update sprite set
    @message_window.update          # Update message window
  end
  
  def update_equip_window
    update_basic(true)
    update_info_viewport
    @equip_window.update
    @equip_window.active = true if @equip_window.openness == 255
    if $game_message.visible
      @info_viewport.visible = false
      @message_window.visible = true
    end
    unless $game_message.visible
      update_equip_selection
    end
  end

  def update_equipitem_window
    update_basic(true)
    update_info_viewport
    @equip_item_window.update
    @equip_item_window.active = true if @equip_item_window.openness == 255
    if $game_message.visible
      @info_viewport.visible = false
      @message_window.visible = true
    end
    unless $game_message.visible
      update_equipitem_selection
    end
  end
  
  def update_equip_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @equip_window.active = false
      @equip_window.dispose
      @equip_window = nil
      @actor_command_window.active = true
    elsif Input.trigger?(Input::C) || Input.trigger?(Input::X)
      if @equipper_selected.fix_equipment
        Sound.play_buzzer
      else
        @equip_window.active = false
        create_equip_item_window
        @equip_item_window.openness = 0
        if @equip_item_window.item_max == 0
          Sound.play_buzzer
          @equip_item_window.dispose
          @equip_item_window = nil
        else
          Sound.play_decision
          @equip_item_window.open
          @equip_item_window.index = 0
        end
      end
    end
  end
  
  def create_equip_item_window
    selected = @active_battler
    selected = @commander if @commander
    type = @equip_window.index
    if $imported["EquipExtension"] && @equip_window.index > 0
      type = selected.equip_type[@equip_window.index - 1] + 1
    end
    if selected.two_swords_style && type == 1
      type = 0
    end
    @equip_item_window = Window_EquipItem.new(0, 0, Graphics.width, Graphics.height - @actor_command_window.height, selected, type)
  end
  
  def update_equipitem_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @equip_window.active = true
      @equip_item_window.active = false
      @equip_item_window.dispose
      @equip_item_window = nil
    elsif Input.trigger?(Input::C) || Input.trigger?(Input::X)
      Sound.play_equip
      @equipper_selected.change_equip(@equip_window.index, @equip_item_window.item)
      @equip_window.active = true
      @equip_item_window.active = false
      @equip_item_window.dispose
      @equip_item_window = nil
      @equip_window.refresh
    end
  end
  
  alias update_actor_command_selection_battleequip update_actor_command_selection
  def update_actor_command_selection
    if Input.trigger?(Input::X)
      if $game_system.enable_battle_equip
        Sound.play_decision
        start_equip_selection
      else
        Sound.play_buzzer if Mithran::BattleEquip::USE_BUZZ
      end
      return
    end
    update_actor_command_selection_battleequip
  end
  
  def start_equip_selection
    @equipper_selected = @active_battler
    @equipper_selected = @commander if @commander
    @equip_window = Window_Equip.new(208, 56, @equipper_selected)
    @equip_window.height = @actor_command_window.height
    @equip_window.y = Graphics.height - @equip_window.height
    @equip_window.x = Graphics.width - @equip_window.width - @actor_command_window.width
    @equip_window.index = 0
    @equip_window.openness = 0
    @equip_window.open
    @actor_command_window.active = false
  end

end

class Game_System
  attr_accessor :enable_battle_equip
  def enable_battle_equip
    @enable_battle_equip = Mithran::BattleEquip::ENABLE if @enable_battle_equip == nil
    return @enable_battle_equip
  end
end


Equip All Item
Spoiler:
CODE
# Equip all Item
# Set an item to equip all
# By Mithran
# v 1.0 (Tested)
# to use, put <EQUIPALL> in the note tag of an armor (shield, accessory, etc) or weapon
# must be all caps

class RPG::BaseItem
  def equip_all?
    return self.note =~ /<EQUIPALL>/    
  end
end

class Game_Actor < Game_Battler
  
  alias change_equip_orig_mith_EA change_equip
  def change_equip(equip_type, item, test = false)
    change_equip_orig_mith_EA(equip_type, item, test)
    check_equips unless test
  end
  
  def check_equips
    equips.each_index { |i| # Remove unequippable items
      change_equip_orig_mith_EA(i, nil) unless equippable?(equips[i])
    }
  end
  
  alias equippable_orig_mith_EA? equippable?
  def equippable?(item)
    return false unless item.is_a?(RPG::Weapon) or item.is_a?(RPG::Armor)
    return true if equip_all?
    equippable_orig_mith_EA?(item)
  end
  
  def equip_all?
    for item in self.equips.compact
      return true if item.equip_all?
    end
    return false    
  end

end


KGC Limitbreak: Larger Numbers Unsquished *PATCH*
Spoiler:
CODE
# 5 Digit HP/MP and 4 digit paramter draw fix
# By Mithran
# Requested by Deccy Bon
# for use with KGC Limitbreak
# (this is a very old script.  There are better ways to do this, yes.
# feel free to edit and use this however you like)
# Throw it in matierals.

class Window_Base < Window
  alias draw_actor_hp_orig_mith draw_actor_hp
  def draw_actor_hp(actor, x, y, width = 120)
    if actor.maxhp > 9999
      draw_actor_hp_fivedigit(actor, x, y, width)
    else
      draw_actor_hp_orig_mith(actor, x, y, width)
    end
  end
  def draw_actor_hp_fivedigit(actor, x, y, width = 120)
    draw_actor_hp_gauge(actor, x, y, width)
    self.contents.font.color = system_color
    if actor.hp <= 9999
      self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)
    end
    self.contents.font.color = hp_color(actor)
    last_font_size = self.contents.font.size
    xr = x + width
    if width < 120
      self.contents.font.color = system_color
      if actor.hp > 9999
        self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)
      end
      self.contents.font.color = hp_color(actor)
      last_font_size = self.contents.font.size
      self.contents.draw_text(xr - (actor.hp.to_s.size * 11), y, actor.mp.to_s.size * 11, WLH, actor.hp, 1)
    else
      self.contents.draw_text(xr - 55, y, 55, WLH, actor.maxhp, 2)
      self.contents.draw_text(xr - 55 - 6, y, 8, WLH, "/", 2)
      self.contents.draw_text(xr - 55 - 5 - 55, y, 55, WLH, actor.hp, 2)
    end
  end
  alias draw_actor_mp_orig_mith draw_actor_mp
  def draw_actor_mp(actor, x, y, width = 120)
    if actor.maxmp > 9999
      draw_actor_mp_fivedigit(actor, x, y, width)
    else
      draw_actor_mp_orig_mith(actor, x, y, width)
    end
  end
  def draw_actor_mp_fivedigit(actor, x, y, width = 120)
    draw_actor_mp_gauge(actor, x, y, width)
    self.contents.font.color = system_color
    if actor.mp <= 9999
      self.contents.draw_text(x, y, 30, WLH, Vocab::mp_a)
    end
    self.contents.font.color = mp_color(actor)
    last_font_size = self.contents.font.size
    xr = x + width
    if width < 120
    self.contents.font.color = system_color
      if actor.mp > 9999
        self.contents.draw_text(x, y, 30, WLH, Vocab::mp_a)
      end
      self.contents.font.color = mp_color(actor)
      last_font_size = self.contents.font.size
      self.contents.draw_text(xr - (actor.mp.to_s.size * 11), y, actor.mp.to_s.size * 11, WLH, actor.mp, 1)
    else
      self.contents.draw_text(xr - 55, y, 55, WLH, actor.maxmp, 2)
      self.contents.draw_text(xr - 65, y, 11, WLH, "/", 2)
      self.contents.draw_text(xr - 120, y, 55, WLH, actor.mp, 2)
    end
  end
  alias draw_actor_parameter_orig_mith draw_actor_parameter
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = Vocab::atk
      parameter_value = actor.atk
    when 1
      parameter_name = Vocab::def
      parameter_value = actor.def
    when 2
      parameter_name = Vocab::spi
      parameter_value = actor.spi
    when 3
      parameter_name = Vocab::agi
      parameter_value = actor.agi
    end
    if parameter_value > 999
      draw_actor_parameter_fourdigit(x, y, parameter_name, parameter_value)
    else
      draw_actor_parameter_orig_mith(actor, x, y, type)
    end
  end
  def draw_actor_parameter_fourdigit(x, y, parameter_name, parameter_value)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 108, WLH, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 108, y, 48, WLH, parameter_value, 2)
  end
end

class Window_EquipStatus < Window_Base
  alias draw_parameter_orig_mith draw_parameter
  def draw_parameter(x, y, type)
    if $imported["LimitBreak"] && KGC::LimitBreak::ACTOR_PARAMETER_LIMIT > 999
      draw_parameter_fourdigit(x, y, type)
    else
      draw_parameter_orig_mith(x, y, type)
    end
  end
  def draw_parameter_fourdigit(x, y, type)
    case type
    when 0
      name = Vocab::atk
      value = @actor.atk
      new_value = @new_atk
    when 1
      name = Vocab::def
      value = @actor.def
      new_value = @new_def
    when 2
      name = Vocab::spi
      value = @actor.spi
      new_value = @new_spi
    when 3
      name = Vocab::agi
      value = @actor.agi
      new_value = @new_agi
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x + 4, y, 80, WLH, name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 90 - 30, y, 30 + 15, WLH, value, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(x + 122 - 15, y, 20, WLH, ">", 1)
    if new_value != nil
      self.contents.font.color = new_parameter_color(value, new_value)
      self.contents.draw_text(x + 142 - 15, y, 30 + 15, WLH, new_value, 2)
    end
  end
end


KGC Steal: Instant Death when stolen *PATCH*
Spoiler:
CODE
# Instant death when stolen from (KGC Steal)
# This strange little snippet makes an enemy die if they are successfully stolen
# from.  Yeah, thats it.  Only works with KGC Steal.  Insert below KGC Steal.

class Scene_Battle
  alias display_steal_item_instadeath display_steal_item
  def display_steal_item(*args)
    target = args[0]
    stolen = !(target.stolen_object.nil? || target.stolen_object == :no_item)
    display_steal_item_instadeath(*args)
    if stolen && target.is_a?(Game_Enemy)
      target.add_state(1)
      target.instance_eval { @added_states.push(1) }
    end
  end
end


KGC_EquipLearnSkill: AP gain from skill use *PATCH*
Spoiler:
CODE
# KGC_EquipLearnSkill AP gain by skill use
# Patch by Mithran
# place directly below KGC EquipLearnSkill
# Skills will gain the specificed amount of AP in the used skill only every
# time that skill is used.

module GainAP
  SKILL_AP_GAIN = 1
  # amount of ap gained per skill use
end

class Game_Temp
  attr_accessor :ap_earning_actor
end

class Scene_Battle < Scene_Base
  alias execute_action_skill_gain_AP execute_action_skill
  def execute_action_skill
    if @active_battler.actor?
      actor = @active_battler
      skill = $data_skills[actor.action.skill_id]
      if actor.can_gain_ap_skills.include?(skill)
        actor.change_ap(skill, actor.skill_ap(skill.id) + GainAP::SKILL_AP_GAIN)
      end
    end
    execute_action_skill_gain_AP
  end
  alias battle_end_gain_AP battle_end
  def battle_end(result)
    for actor in $game_party.members
      actor.display_full_ap_skills(actor.learned_by_ap_skills) unless actor.learned_by_ap_skills.empty?
      wait_for_message
      actor.learned_by_ap_skills = []
    end
    battle_end_gain_AP(result)
  end
end

class Game_Actor < Game_Battler
  attr_writer :learned_by_ap_skills
  
  def learned_by_ap_skills
    @learned_by_ap_skills ||= []
    return @learned_by_ap_skills
  end
  
  alias change_ap_gain_AP change_ap
  def change_ap(skill, ap)
    @skill_ap = [] if @skill_ap == nil
    was_full = ap_full?(skill)
    change_ap_gain_AP(skill, ap)
    if !was_full and ap_full?(skill)
      @learned_by_ap_skills ||= []
      @learned_by_ap_skills.push(skill)
    end
  end
end


Enelvon's Resist System: Bugfixes *PATCH*
Spoiler:
CODE
# Patch for Enelvon's Resist System
# Patch by Mithran
# Bugfix: Fixes an issue where states that do not modify resist drop it to 1
# Bugfix: Enabled KGC Limitbreak for the actual actor resist stat instead of
# just the database value
# Install: Insert below Enelvon's Resist System

class Game_Actor
  def res
    n = [base_res + @res_plus, 1].max
    states.each { |s| n *= s.res_rate / 100.0 }
    n = [[Integer(n), 1].max, parameter_limit].min
    return n
  end
  
  def parameter_limit; 999; end unless method_defined?(:parameter_limit)
  
end
  
class RPG::State
  def res_rate; self.note =~ /<AFFECT_RES (\d+)>/ ? $1.to_i : 100; end
end


Enelvon's resistance / luck scripts + Syvkal's Menu Bar *PATCH*
Spoiler:
CODE
# Patch for Enelvon's resistance / luck scripts and Syvkal's Menu Bar
# script order is menu bars > resisistance and luck scripts > this patch

class Window_Base < Window
  # SET UP RES AND LUCK COLORS HERE
  
  RESCOLOR1 = 5
  RESCOLOR2 = 3
  
  LCKCOLOR1 = 5
  LCKCOLOR2 = 3
  
  alias draw_actor_parameter_gauge_resfix draw_actor_parameter_gauge
  def draw_actor_parameter_gauge(actor, x, y, type, width = 160, vertical = false)
    if type <= 3 && type >= 0
      return draw_actor_parameter_gauge_resfix(actor, x, y, type, width, vertical)
    end
    case type
    when 4
      return unless defined?(actor.res)
      e1 = actor.res
      gc1 = RESCOLOR1.is_a?(Integer) ? text_color(RESCOLOR1) : RESCOLOR1
      gc2 = RESCOLOR2.is_a?(Integer) ? text_color(RESCOLOR2) : RESCOLOR2      
    when 5
      return unless defined?(actor.lck)
      e1 = actor.lck
      gc1 = LCKCOLOR1.is_a?(Integer) ? text_color(LCKCOLOR1) : LCKCOLOR1
      gc2 = LCKCOLOR2.is_a?(Integer) ? text_color(LCKCOLOR2) : LCKCOLOR2            
    else
      return
    end
    e2 = P_MAX
    rate = [e1.to_f / e2.to_f, 1].min
    gw = width * [e1.to_f / e2.to_f, 1].min
    r = gc2.red * rate
    g = (gc2.green - 72) * rate
    b = gc2.blue  * rate
    a = gc2.alpha
    w = vertical ? 6 : width; h = vertical ? width : 6
    PARSLANT ? self.contents.cogwheel_fill_slant(x, y + WLH - 8, gw, w, h, gc1, Color.new(r, g, b, a), vertical) :
    self.contents.cogwheel_fill_rect(x, y + WLH - 8, gw, w, h, gc1, Color.new(r, g, b, a), vertical)
  end
end


Save / Load Switch
Spoiler:
CODE
# Switch on save/ load
# By Mithran
# turns OFF a switch on a successful save
# turn ON a switch each time a game is loaded
# Setting either switch id to 0 will disable it from being used

# Must Save At Least Once - How to use:
# Make a common event.  This event will do nothing but open save screen.
# Set the condition switch to the save switch specified below, and autorun.
# When you get to an event where you must save, have this event turn ON the switch.
# If you exit the save screen without saving, the switch will still be on and
# it will put you back in the save screen.  If you desire, you can set a conditional branch
# to show a message after the save if the switch is still set.
# If you have saved, the switch is turned off, the event exits normally.

# Event on Load - How to use:
# Make a common event.  This event will do whatever you need to do every time
# the game is loaded.
# Set the condition switch to the switch specified below, and autorun.
# As soon as the game is loaded, this event is run.  Be sure to turn the switch
# OFF manually by the end of the event, or it will loop continually.
# Alternatively, you can use a map event for only the areas where you want the
# load event to run.

class Scene_File
  SAVE_SWITCH_ID = 122
  LOAD_SWITCH_ID = 123
  
  alias do_save_switchoff do_save
  def do_save
    $game_switches[SAVE_SWITCH_ID] = false if SAVE_SWITCH_ID > 0
    do_save_switchoff
  end
  
  alias do_load_switchon do_load
  def do_load
    do_load_switchon
    $game_switches[LOAD_SWITCH_ID] = true if LOAD_SWITCH_ID > 0
  end

end


Vehicle BGS Play
Spoiler:
CODE
# Vehicle BGS Play
# by Mithran
# Just change the entries below to the filenames of the BGS you want to play
# Everything is set up below, just change the values in the parenthesis
# on the lines that says < EDIT THIS LINE
# replacing with a blank file name ""
# will prevent any BGS from playing for this vehicle.

class Game_Vehicle
  
  alias get_on_bgsplay get_on
  def get_on
    get_on_bgsplay
    @last_bgs = RPG::BGS.last # saves currently playing BGS
    RPG::BGS.stop # stops bgs
    case @type
    when 0 # boat
      RPG::BGS.new("River", 80, 100).play # < EDIT THIS LINE
      # play BGS "River" at 80% volume and 100% pitch when getting on boat
    when 1 # ship
      RPG::BGS.new("Sea", 80, 100).play # < EDIT THIS LINE
      # play BGS "Sea" at 80% volume and 100% pitch when getting on ship
    when 2 # airship
      RPG::BGS.new("Wind", 80, 100).play # < EDIT THIS LINE
      # play BGS "Wind" at 80% volume and 100% pitch when getting on airship
    end
  end

  
  alias get_off_bgsplay get_off
  def get_off
    get_off_bgsplay # gets off vehicle
    RPG::BGS.stop # stops BGS
    @last_bgs.play # plays saved BGS
  end
  
end


Attack Common Event
Spoiler:
CODE
# normal attack common event
# By Mithran
# In the note tag for enemy or weapons, type <common_event_id 0>
# replace the 0 with the id of the commmon event to be run after the attack
# if you have my snippet for Actor ID / Enemy Index saved when item or skill is used
# it will now also remember the id of the last attacker from a normal attack

class RPG::Weapon
  def common_event_id
    return self.note =~ /<common[\s_]?event[\s_]?id\s*(\d+)>/i ? $1.to_i : 0
  end
end

class RPG::Enemy
  def common_event_id
    return self.note =~ /<common[\s_]?event[\s_]?id\s*(\d+)>/i ? $1.to_i : 0
  end
end

class Game_Battler
  def attack_common_event_id
    if actor?
      for weapon in weapons.compact
        return weapon.common_event_id if weapon.common_event_id > 0
      end
      return 0
    else
      return enemy.common_event_id
    end
  end
end

class Scene_Battle
  alias execute_action_attack_weapon_common_event execute_action_attack
  def execute_action_attack
    $game_temp.common_event_id = @active_battler.attack_common_event_id
    remember_actor_id if type.method_defined?(:remember_actor_id)
    execute_action_attack_weapon_common_event
  end
end


Swap HP/MP State
Spoiler:
CODE
# Swap HP/MP State
# By Mithran
# Designate a state which, when applied, will swap the user and target's HP or MP.
# The state message will be shown when it is applied, but the state itself is
# never actually applied.
# Done through states so you can easily change the probability of success.
# put <SWAP MP> in the note box of the state to swap MP
# put <SWAP HP> in the note box of the state to swap HP
# using both will work
# Install: Insert above main

class Game_Battler
  alias add_state_swaphpmp add_state
  def add_state(state_id)
    state = $data_states[state_id]
    if @tmp_swaphpmp_user != nil && state != nil # nil checks
      if state.swap_mp?
        @tmp_swaphpmp_user.mp, self.mp = self.mp, @tmp_swaphpmp_user.mp
      end
      if state.swap_hp?
        @tmp_swaphpmp_user.hp, self.hp = self.hp, @tmp_swaphpmp_user.hp
      end
      return if state.swap_mp? or state.swap_hp? # state will not actually be added
    end
    add_state_swaphpmp(state_id)
  end
  
  ["item_effect", "skill_effect", "attack_effect"].each { |mname|
  aStr = %Q(
  alias #{mname}_swaphpmp #{mname}
  def #{mname}(*args)
    @tmp_swaphpmp_user = args[0]
    #{mname}_swaphpmp(*args)
    @tmp_swaphpmp_user = nil
  end
  )
  module_eval(aStr)
  }
  
end

class RPG::State
  def swap_mp?; self.note =~ /<SWAP MP>/; end
  def swap_hp?; self.note =~ /<SWAP HP>/; end
end


Extend Class Learnings
Spoiler:
CODE
# Extend Class Learnings by Mithran
# A snippet to allow default skill learn-by-level for levels beyond 99.
# This script does NOT break the level limit, but it is compatable with those
# that do.  Install: Place below the script that does the level limit breaking.

module ExtendedLearnings
  EXTRA_CLASS_LEARNINGS = Hash.new { Array.new } # Do not modify
  # EXTRA_CLASS_LEARNINGS[class_id] = [
  #[  [skill_id, level], [skill, level]... ]
  
  EXTRA_CLASS_LEARNINGS[1] = [ # dont forget the extra set of brackets around the whole set
  [81, 108], [83, 128], # you may put line breaks after each pair for reading convenience
  ]# dont forget the extra set of brackets around the whole set
  # example: Ralph will learn skill 81 at level 108, and skill 83 at 128
  
end

class Scene_Title
  
  alias load_database_before_extended_learnings load_database
  def load_database
    load_database_before_extended_learnings
    add_extra_class_learnings
  end
  
  alias load_bt_database_before_extended_learnings load_bt_database
  def load_bt_database
    load_bt_database_before_extended_learnings
    add_extra_class_learnings
  end
  
  def add_extra_class_learnings
    ExtendedLearnings::EXTRA_CLASS_LEARNINGS.each_pair { |i, v|
    next if $data_classes[i].nil?
    for ary in v
      l = RPG::Class::Learning.new
      l.level = ary[1].nil? ? 0 : ary[1]
      l.skill_id = ary[0].nil? ? 0 : ary[0]
      next if l.level.zero? or l.skill_id.zero?
      $data_classes[i].learnings << l
    end
    }
  end
  
end


Remove Party Command Window
Spoiler:
CODE
# Remove Party Command Window
# Makes the party command window in the default battle system completely
# inaccessible and hidden from the interface

# Install: Insert above main in the materials section.

module Mithran
  module RPCW
    ACTIVATE = true # change to false to deactivate script
  end
end
    
class Scene_Battle
  alias start_party_command_selection_remove_party_command start_party_command_selection
  def start_party_command_selection
    start_party_command_selection_remove_party_command
    if Mithran::RPCW::ACTIVATE
      @info_viewport.ox = 128
      @party_command_window.active = false
      next_actor unless $game_troop.surprise or not $game_party.inputable?
    end
  end
  
  alias start_main_remove_party_command start_main
  def start_main
    start_main_remove_party_command
    @info_viewport.ox = 128 if Mithran::RPCW::ACTIVATE
  end
end


Huge Character Graphic instead of Actor Face
Spoiler:
CODE
# Huge Character Sprite instead of Actor Face
# by Mithran
# Draws a blown up character map sprite instead of an actor face
# Works with most custom menu and status screen scripts.
# Only works in windows that use draw_actor_face.
# Install: Insert below all other custom scripts that deal with windows, above main.

module Mithran
  module DCHS
    ENABLE = true # change to false to disable script
    SUFFIX_EXT = "" # suffix added to the character name to get the actual graphics file
    # leave as "" if you want to use the normal walking graphic
    LEGAL_WINDOWS = [Window_MenuStatus, Window_Status, Window_NameEdit]
    # which windows should face be swapped for character graphic?
    # use the actual names of the windows, no quotes
    PIXEL_PADDING = 20
    # amount of extra padding to give the sprite over the area where a face would
    # normally be drawn.  Larger number = smaller sprite.  Do not set above 90.
    STRETCH = false
    # if set to true, a sprite that is not exactly square will be stretched to fit
    # the area.  If set to false, the sprite's width and height will be scaled equally
    # to still fit in the area.
    POSITION = 0
    # The position of the character graphic based on the reserved space for the
    # face
    # 0 = center x/y
    # 1 = upper left
    # 2 = upper right
    # 3 = lower left
    # 4 = lower right
  end
end


class Window_Base
  def draw_actor_huge(actor, x, y, size)
    character_name, character_index = actor.character_name, actor.character_index
    character_name += Mithran::DCHS::SUFFIX_EXT || ""
    return if character_name == nil
    bitmap = Cache.character(character_name)
    sign = character_name[/^[\!\$]./]
    if sign != nil and sign.include?('$')
      cw = bitmap.width / 3
      ch = bitmap.height / 4
    else
      cw = bitmap.width / 12
      ch = bitmap.height / 8
    end
    # get the width and height of the character graphic
    # (copied from normal character draw)
    n = character_index
    # get the index of the graphic
    src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
    # get the rect containing the graphic
    aw = ah = size - Mithran::DCHS::PIXEL_PADDING
    # actual height and actual width are the proposed size minus the padding
    if !Mithran::DCHS::STRETCH && cw != ch # if stretch is disabled
      ratio = cw / (ch * 1.0) # calculate the ratio
      ratio > 1 ? ah *= (1 / ratio) : aw *= ratio
      # adjust the actual width or height accordingly, so the aspect ratio is preserved
    end
    ax = case Mithran::DCHS::POSITION # set coordinate x
    when 1, 3; x # upper left, lower left
    when 2, 4; x + size - aw # upper right, lower right
    else; x + (size - aw) / 2; end # center
    ay = case Mithran::DCHS::POSITION # set coordinate y
    when 1, 2; y # upper left, upper right
    when 3, 4; y + size - ah # lower left, lower right
    else; y + (size - ah) / 2; end # center
    dest_rect = Rect.new(ax, ay, aw, ah)
    # destination rect - use the caculated coordinates, width, and height
    self.contents.stretch_blt(dest_rect, bitmap, src_rect)
    # perform a stretch blt, using the character graphic as the source, and the
    # calculated area (based on where the face would have been drawn) as a destination
  end

  def self.redef_draw_actor_face
    self.module_eval {
    def draw_actor_face(actor, x, y, size = 96)
      Mithran::DCHS::ENABLE ? draw_actor_huge(actor, x, y, size) : super
    end
  }
  end

end

Mithran::DCHS::LEGAL_WINDOWS.each { |w| w.redef_draw_actor_face }


Battle System Switch
Spoiler:
CODE
# Experimental Snippet - Switch Battle System
# By Mithran
# Switch between Tankentai and default (or another simple custom battle system)
# by turning on a switch
# Install: Insert above Tankentai scripts, below default.  If another battle script
# is attempted, insert it above this script.

module DefBat
  SWITCH_ID = 1
  # turn this switch on to revert to the default battle system
end

clone_classes = ["Scene_Battle", "Sprite_Battler", "Spriteset_Battle"]

clone_classes.each { |cls|
  aStr = %Q(
  #{cls}Classic = #{cls}.clone
  class #{cls}
    class << self
      alias new_tankentai new
      def new(*args)
        if #{cls} == Scene_Battle
          Game_Enemy.unmod_battler
          Game_Actor.unmod_battler
        end
        return #{cls}Classic.new(*args) if $game_switches[DefBat::SWITCH_ID]
        return new_tankentai(*args)
      end
    end
  end
  )
  eval(aStr)
}
class Game_Enemy
  alias perform_collapse_classic perform_collapse
  def self.unmod_battler
    module_eval {
    if $game_switches[DefBat::SWITCH_ID]
      alias perform_collapse_tankentai perform_collapse if !method_defined?(:perform_collapse_tankentai)
      def perform_collapse; perform_collapse_classic; end
    elsif method_defined?(:perform_collapse_tankentai)
      def perform_collapse; perform_collapse_tankentai; end
    end
      }
  end  
  
end
class Game_Actor
  alias perform_collapse_classic perform_collapse
  def self.unmod_battler
    module_eval {
    if $game_switches[DefBat::SWITCH_ID]
      alias perform_collapse_tankentai collapse if !method_defined?(:perform_collapse_tankentai)
      def perform_collapse; perform_collapse_classic; end
    elsif method_defined?(:perform_collapse_tankentai)
      def perform_collapse; perform_collapse_tankentai; end
    end
      }
  end
end


Shortcut to "Guard" Option in Battle
Spoiler:
CODE
# Shortcut to "Guard" option in battle
# By Mithran
# Install: Insert below any custom battle system scripts.  Should work with Tankentai SBS and Zifee Wait Battle Gauge.

module Mithran
  GUARD_BUTTON = Input::X # button to use for guard
  # This is the controller button, not keyboard key.
  # see the RPG Maker VX helpfile for valid buttons
end

class Scene_Battle
  
  alias update_actor_command_selection_guardbutton update_actor_command_selection
  def update_actor_command_selection
    actor = defined?(::N02) ? @commander : @active_battler # tankentai ATB support
    actor = @select_battler if @select_battler # Zifee WBG support
    if Input.trigger?(Mithran::GUARD_BUTTON) && (defined?(::ZiiN7) ? @actor_command_window.command_movable? : true) # Zifee WBG Support
      Sound.play_decision
      actor.action.set_guard
      defined?(::N02) ? end_command : next_actor # tankentai ATB support
      return
    end
    update_actor_command_selection_guardbutton
  end
  
end


Random Confusion Targets
Spoiler:
CODE
# Random Confusion Targets
# By Mithran
# adds the following option to the 'always attack allies' (confusion) state
# <CONFUSION TARGET ENEMY nn>
# will make confusion target enemies at an a percent chance, otherwise, it will target
# allies as normal.  replace nn with the percent you want to use
# only works if the current restrction level is 3 (an always attack state is
# applied and no other more restrictive states are applied)
# If more than one confusion state is applied, normal priority will determine
# which one is used (first the priority setting, then the states id).
# Install: Insert in the Materials section above main, below any custom battle systems or targeting changes.

class Game_BattleAction
  alias make_attack_targets_rcconf make_attack_targets
  def make_attack_targets
    setup_temp_conf
    targets = make_attack_targets_rcconf
    clear_temp_conf
    return targets
  end
  
  def setup_temp_conf
    conf_state = battler.conf_state
    return if conf_state.nil?
    enemy_attack = conf_state.ally_attack_chance < rand(100)
    if enemy_attack
      battler.temp_conf = false
      battler.temp_berz = true
      # temporarily swaps the 'berserker' and 'confusion' checks on the battler
      # confusion will make them attack enemies, berserker allies
    else
      battler.temp_conf = true
      battler.temp_berz = false
    end
  end
  
  def clear_temp_conf
    battler.temp_conf = nil
    battler.temp_berz = nil
  end
  
end


class Game_Battler
  attr_accessor :temp_conf
  attr_accessor :temp_berz
  
  alias confusion_orig_swapconf confusion?
  def confusion?
    return @temp_conf unless @temp_conf.nil?
    return confusion_orig_swapconf
  end
  
  alias berserker_orig_swapconf berserker?
  def berserker?
    return @temp_berz unless @temp_berz.nil?
    return berserker_orig_swapconf
  end
  
  def conf_state
    states.each { |s| return s if s.restriction == 3}
    return nil
  end
  
end

class RPG::State
  def ally_attack_chance
    self.note =~ /<CONFUSION TARGET ENEMY (\d+)>/i ? 100 - $1.to_i : 100
  end
end


Use Any Weapon (at a cost)
Spoiler:
CODE
# Use any weapon, but if not normally useable characters atk is reduced to a percentage of normal
# Install: Place on a new page in Materials section of the script editor, above main.

class Game_Actor
  UNUSABLE_WEAPON_ATK_RATE = 60 # percentage of actors atk is reduced to if an
  # 'unusable' weapon is equipped
  # 100 = not reduced, 0 = reduced to minimum
  
  alias equippable_before_useanyweapon equippable?
  def equippable?(item)
    return true if item.is_a?(RPG::Weapon)
    return equippable_before_useanyweapon(item)
  end

  alias base_atk_useanyweapon base_atk
  def base_atk
    n = base_atk_useanyweapon # real base atk
    n = n * UNUSABLE_WEAPON_ATK_RATE / 100 if weapons.compact.find {|w| not equippable_before_useanyweapon(w)}
    return n
  end
  
end


Display Variable as Currency
Spoiler:
CODE
# Display variable as currency value
# by Mithran
# The box normally used to display gold can be used to display other value.
# Use the text code:
# \VW[n] (\VW needs to be in caps)
# where n is the id of the variable you want to have pop up in the currency box.
# The settings in the module below will determine which term/icon is drawn to the
# right of the box.
# Should be compatable with custom message systems, so long as they dont use the
# above text code.
# This should be placed below the custom message system if used.

module CurrencyVar
  VAR_DISPLAY_TEXTS = [] # do not alter
  # use numbers for icon ids, or strings for text
  VAR_DISPLAY_TEXTS[7] = 63 # variable 7 uses icon 63
  VAR_DISPLAY_TEXTS[8] = "CASH" # varialbe 8 uses the term CASH
  VAR_DISPLAY_TEXTS[9] = 64 # variable 9 uses icon 64
end

class Window_Base
  include CurrencyVar
  
  alias draw_currency_value_goldvar draw_currency_value
  def draw_currency_value(*args)
    var_id = $game_temp.gold_w_display.shift
    if var_id.nil? or var_id == 0
      draw_currency_value_goldvar(*args)
    else
      draw_var_currency_value(var_id, *args[1..3])
    end
  end
    
  
  def draw_var_currency_value(var_id, x, y, width)
    term = VAR_DISPLAY_TEXTS[var_id]
    cx = term.is_a?(Fixnum) ? 24 : contents.text_size(term).width
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width-cx-2, WLH, $game_variables[var_id], 2)
    self.contents.font.color = system_color
    if term.is_a?(Fixnum)
      draw_icon(term, (x + width - cx), y)
    else
      self.contents.draw_text(x, y, width, WLH, term, 2)
    end
  end

end

class Window_Message
  alias convert_special_characters_goldvar convert_special_characters
  def convert_special_characters
    @text.scan(/(?:\\VW\[([0-9]+)\]|\\G)/) {$game_temp.gold_w_display << $1.to_i}    
    convert_special_characters_goldvar
    @text.gsub!(/\\VW\[([0-9]+)\]/) { "\x02" }
  end
end


class Game_Temp
  def gold_w_display
    @gold_w_display ||= []
  end
end


Auto Difficulty Adjustment of KGC Daynight *PATCH*
Spoiler:
CODE
# Auto Difficulty Adjustment for KGC_DayNight
# patch by Mithran
# Setup the attributes you would like to be modified in the ATTRIBUTES secton.
# Setup how much you would like the attributes modified by in the RATE_PROC
# section.  
# The phase number is its order in the PHASE setting of the KGC_DayNight script
# 0 being the first setting and count up from there.  
# The rate number is considered the percentage of the default amount.  100 means
# no change.
# If you want a monster to be exempt from this script, put
# <NO DN EFFECT>
# in the note box for the enemy.  
# Install: Insert below KGC_Daynight, above main.

module DayNightDifficulty

  LOCK_DIFFICULTY = true
# if set to true, enemy stats will be locked in based on the time the battle starts.
# If set to false, enemy stats will change dynaimically if time phase changes in battle
  
  ATTRIBUTES = [ "atk", "def", "spi", "agi", "maxhp", "maxmp", "exp", "gold"]
  # all the attributes affected.  hit and eva can be added here, but I decided not
  # to as the effects could range from non existent to imbalancing
  # keep in mind that everything is rounded to the nearest integer, so lower
  # stat enemies may have no changes.

  RATE_PROC = lambda { |phase| # do not edit this line
  case phase # do not edit this line
  when 0 # phase 0 (noon)
    100 # stat rate is 100% (unchanged)
  when 1 # phase 1 (afternoon)
    110 # stat rate is 110%
  when 2 # phase 2 (night)
    130 # stat rate is 130%
  when 3 # phase 3 (morning)
    90 # stat rate is 90%
#~   when 4 # < you can add as many as you need if you have more phases
#~     150
  else # phase is not any of the above
    100
  end # < end must stay here
  } # do not edit this line
    
  NO_EFFECT_TAG = /<NO DN EFFECT>/ # note tag used to exempt the enemy from having
  # this should not be edited unless there is a conflic

end

class RPG::Enemy
  
  def no_dn_diff
    return note =~ DayNightDifficulty::NO_EFFECT_TAG ? true : false
  end
  
  DayNightDifficulty::ATTRIBUTES.each { |mn|
  mn = (mn.is_a?(Symbol) or mn.is_a?(Fixnum)) ? mn.id2name : mn.to_s
  aStr = %Q(
if method_defined?(:#{mn}) && !method_defined?(:#{mn}_orig_dndiff)
  alias #{mn}_orig_dndiff #{mn}
  def #{mn}(*args)
    (#{mn}_orig_dndiff(*args) * dn_stat_rate / 100.0).round
  end
end
  )
  module_eval(aStr)
  }
  
  def dn_stat_rate
    no_dn_diff ? 100 : DayNightDifficulty::RATE_PROC.call($game_temp.dn_locked)
  end
  
end

class Scene_Battle
  alias start_dndiff start
  def start
    $game_temp.dn_locked = $game_system.daynight_phase if DayNightDifficulty::LOCK_DIFFICULTY
    start_dndiff
  end

  alias terminate_dndiff terminate
  def terminate
   terminate_dndiff
   $game_temp.dn_locked = nil
  end

end

class Game_Temp
attr_writer :dn_locked

  def dn_locked
    @dn_locked.nil? ? $game_system.daynight_phase : @dn_locked
  end
end


Event Move Like a Vehicle
Spoiler:
CODE
# Event move like a vehicle.
# by Mithran
# Restricts an event's movement pattern to within water/shallow water, just like
# a boat/ship.  Also has the option to 'float' over all tiles (but not through
# other events, if you want this, just use 'through')

# Usage: Insert one of the following in a comment on an event page.  While on this
# page, the event's acceptable tiles will be altered.  
# The tags are PAGE SPECIFIC, each page can be different, and any page without
# the tags will walk normally.

# <VEHICLE MOVE 0>
# Move like a boat.

# <VEHICLE MOVE 1>
# Move like a ship.

# <VEHICLE MOVE 2>
# Move over any tile, but still collide with characters.
# *If you want truly like an airship, simply check the 'through' box.

# If no tag is present on any given page, the event will walk normally.

# Install: Insert above main and below any scripts that affect movement.

class Game_Character
  alias map_passable_orig_vehiclemove map_passable?
  def map_passable?(x, y)
    case @vehicle_move
    when 0  # Same as Boat
      return $game_map.boat_passable?(x, y)
    when 1  # Same as Ship
      return $game_map.ship_passable?(x, y)
    when 2  # Floating (cannot fly over other characters)
      return true
    else    # Walking, normal move
      return map_passable_orig_vehiclemove(x, y)
    end
  end
  
end

class Game_Event
  alias setup_orig_vehiclemove setup
  def setup(new_page)
    @vehicle_move = nil
    setup_orig_vehiclemove(new_page)
    if @list != nil
      @list.compact.each { |command|
      next unless command.code == 108 or command.code == 408
      @vehicle_move = $1.to_i if command.parameters[0] =~ /<VEHICLE MOVE (\d+)>/ # match tag in comments
       }
    end
  end
end


Save Complete Popup
Spoiler:
CODE
# Save confirmation popup
# By Mithran
# Makes a small window popup indicating the game has been saved, after it has been
# saved.
# Install: Insert below any custom file systems.  Should work with most
# custom file systems.

class Scene_File
  SAVE_CONFIRM_CAPTION = "Saved!"
  SAVE_CONFIRM_LENGTH = 120 # Max length in frames for the confirmed window to stay
  BLUR_BEFORE_CONFIRM_CAP = false
  # If set to true, the file screen will blur into the background before showing
  # the save confirmation box
  alias do_save_orig_popconfirm do_save
  def do_save
    do_save_orig_popconfirm
    @save_done = true
  end

  alias terminate_orig_popconfirm terminate
  def terminate
    if @save_done
      bp = Graphics.snap_to_bitmap
      bp.blur  if BLUR_BEFORE_CONFIRM_CAP
      bs = Sprite.new
      bs.bitmap = bp
    end
    terminate_orig_popconfirm
    if @save_done
      save_done_popup
      bs.dispose
    end
  end
  
  def save_done_popup
    Graphics.transition(0)
    create_save_done_window
    update_save_done_window
    close_save_done_window
    Graphics.freeze
  end
  
  def create_save_done_window
    tw = Bitmap.new(32, 32).text_size(SAVE_CONFIRM_CAPTION).width
    @save_done_window = Window_Base.new(0, 0, tw + 32, Window_Base::WLH + 32)
    @save_done_window.openness = 0
    @save_done_window.contents.draw_text(0, 0, tw, Window_Base::WLH, SAVE_CONFIRM_CAPTION)
    @save_done_window.x = (Graphics.width - @save_done_window.width) / 2
    @save_done_window.y = (Graphics.height - @save_done_window.height) / 2
    @save_done_window.open
  end
  
  def update_save_done_window
    sl = 0
    while sl < SAVE_CONFIRM_LENGTH
      Graphics.update
      Input.update
      @save_done_window.update
      sl += 1 unless @save_done_window.openness < 255
      break if Input.trigger?(Input::C)
    end
  end
  
  def close_save_done_window
    @save_done_window.close
    while @save_done_window.openness > 0
      Graphics.update; @save_done_window.update
    end
    @save_done_window.dispose
  end
  
end


Lock Music
Spoiler:
CODE
# Lock BGM/ME
# by Mithran at RMVX.net
# Prevents ANYTHING from changing the BGM or ME while the music lock flag is set.  
# Music lock is turned off automatically on Game Over or going to Title screen.

# To prevent music from being changed, use the Advanced > Script Command
# music_lock(true)

# To resume music playing, use the event command
# music_lock(false)

# If music lock is on when the game is saved, the locked music will play
# when the game is loaded and music lock will remain set until specifially unset.

class Game_Interpreter
  def music_lock(bln = true)
    $game_system.music_lock = bln
  end
end

class Game_System
  attr_accessor :music_lock
  
  def music_lock
    @music_lock ||= false
    return @music_lock
  end
  
end

class RPG::BGM
  unless $@
  alias play_musiclock play
  def play
    return if $game_system.music_lock if $game_system
    play_musiclock
  end

  class << self
    alias stop_musiclock stop
    def stop
      return if $game_system.music_lock if $game_system
      stop_musiclock
    end
    
    alias fade_musiclock fade
    def fade(*args)
      return if $game_system.music_lock if $game_system
      fade_musiclock(*args)
    end      
  end
  end

end
    
class RPG::ME
  unless $@
  alias play_musiclock play
  def play
    return if $game_system.music_lock if $game_system
    play_musiclock
  end
  
  class << self
    alias stop_musiclock stop
    def stop
      return if $game_system.music_lock if $game_system
      stop_musiclock
    end
    
    alias fade_musiclock fade
    def fade(*args)
      return if $game_system.music_lock if $game_system
      fade_musiclock(*args)
    end
  end
  end

end
    
class Scene_Gameover
  unless $@
  alias initialize_musiclock initialize
  def initialize
    $game_system.music_lock = false
    initialize_musiclock
  end
  end
end

module Audio
  unless $@
  class << self
    alias bgm_play_musiclock bgm_play
    def bgm_play(*args)
      return if $game_system.music_lock if $game_system
      bgm_play_musiclock(*args)
    end
    
    alias bgm_stop_musiclock bgm_stop
    def bgm_stop
      return if $game_system.music_lock if $game_system
      bgm_stop_musiclock
    end
    
    alias bgm_fade_musiclock bgm_fade
    def bgm_fade(*args)
      return if $game_system.music_lock if $game_system
      bgm_fade_musiclock(*args)
    end
  
    alias me_play_musiclock me_play
    def me_play(*args)
      return if $game_system.music_lock if $game_system
      me_play_musiclock(*args)
    end
    
    alias me_stop_musiclock me_stop
    def me_stop
      return if $game_system.music_lock if $game_system
      me_stop_musiclock
    end
    
    alias me_fade_musiclock me_fade
    def me_fade(*args)
      return if $game_system.music_lock if $game_system
      me_fade_musiclock(*args)
    end

  end
  end

end

class Scene_File < Scene_Base
  alias do_load_musiclock do_load
  def do_load
    @temp_musiclock = nil
    do_load_musiclock
    $game_system.music_lock = @temp_musiclock if @temp_musiclock != nil
  end
  
  alias read_save_data_musiclock read_save_data
  def read_save_data(file)
    read_save_data_musiclock(file)
    @temp_musiclock = $game_system.music_lock
    $game_system.music_lock = false
  end
end


Load Menu As Title
Spoiler:
CODE
# Load Menu as Title
# By Mithran
# Requested by Epic Ancient
# If no files are present, skips straight to new game.
# If files are present, skips to load screen.  The title image will be in the
# background and the music will play.  There is an option for new game here.
# Install: Place in materials and above main.  Must go below any save systems.
# Works with: Wora NSS, default save system.

module Load_Title
  
  WORA_NSS_INTEGRATE = false # change to true to activate
  # Patch for Load Menu as Title (Included)
# For Wora NSS Only.  Instead of having a seperate box appear when you enter the
# scene to select 'new game', it is an option at the bottom of the file list.

end

class Scene_Title < Scene_Base
  def main
    if $BTEST                         # If battle test
      battle_test                     # Start battle test
    else                              # If normal play
      start
      if $cmd_new_game # if new game option was selected from load screen
        @continue_enabled = false # set the variable to false, which will send
        # it directly to a new game
        $cmd_new_game = false # unset the switch, so it is not repeated if you
        # go back to the title
      end
      @continue_enabled ? $scene = Scene_File.new(false, true, false) : command_new_game
      # straight to file scene if there are files, otherwise, new game
      terminate
    end
  end
  
  alias play_title_music_disb play_title_music
  def play_title_music
    play_title_music_disb if @continue_enabled # only play title music if going straight to file screen
  end
  
  alias command_new_game_tdisb command_new_game
  def command_new_game
    $cmd_ng_disb = true # new globals have to be used because all globals used
    # in game are overwritten
    command_new_game_tdisb
    $cmd_ng_disb = false
  end
  
end

class << Sound
  alias play_decision_disb play_decision unless $@
  def play_decision
    play_decision_disb unless $cmd_ng_disb # cursor sound is disabled when new game command is executed
  end
end

class << Graphics
  alias wait_disb wait unless $@
  def wait(*args)
    wait_disb(*args) unless $cmd_ng_disb # wait is disabled when new game command is executed
  end
  
  alias fadeout_disb fadeout unless $@
  def fadeout(*args)
    fadeout_disb(*args) unless $cmd_ng_disb # fadeout is disabled when new game command is executed
  end
end

class Scene_File
  alias start_addnewgameopt start
  def start
    start_addnewgameopt
    create_new_game_command_window if !@saving
  end
  
  def create_new_game_command_window
    @new_game_cmd_window = Window_Command.new(172, [Vocab.continue, Vocab.new_game])
    @new_game_cmd_window.x = (Graphics.width - @new_game_cmd_window.width) / 2
    @new_game_cmd_window.y = (Graphics.height - @new_game_cmd_window.height) / 2
  end
  
  alias update_addnewgameopt update
  def update
    if @new_game_cmd_window != nil
      @new_game_cmd_window.update
      if Input.trigger?(Input::C)
        Sound.play_decision
        (@new_game_cmd_window.index == 0) ? destroy_new_game_command_window :
          do_new_game
      elsif Input.trigger?(Input::B)
        @from_title ? Sound.play_buzzer : Sound.play_cancel
        return_scene
      end
      return
    end
    if Input.trigger?(Input::B) && @confirm_window.nil? && @new_game_cmd_window.nil?
      Sound.play_decision
      create_new_game_command_window
      return
    end
    update_addnewgameopt
  end
  
  def destroy_new_game_command_window
    @new_game_cmd_window.dispose
    @new_game_cmd_window = nil
  end
  
  def do_new_game
    destroy_new_game_command_window unless @new_game_cmd_window.nil?
    $scene = Scene_Title.new
    RPG::BGM.fade(1500)
    Graphics.fadeout(60)
    Graphics.wait(40)
    $cmd_new_game = true
  end
  
  alias return_scene_notitle return_scene
  def return_scene
    return if @from_title
    return_scene_notitle
  end
end

if Load_Title::WORA_NSS_INTEGRATE # patch for the option to appear in line
class Scene_File
  def start
    $game_temp.show_ng_wora_nss = !@saving
    start_addnewgameopt
  end
  
  def update
    update_addnewgameopt
  end
  
  alias update_savefile_selection_newgameopt update_savefile_selection
  def update_savefile_selection
    if Input.trigger?(Input::C) && !@saving && @last_slot_index == MAX_SAVE_SLOT
      Sound.play_decision
      do_new_game
      return
    end
    update_savefile_selection_newgameopt
  end
  
end

class Window_SlotList < Window_Command
  
  def initialize(*args)
    args[1].push(Vocab.new_game) if $game_temp.show_ng_wora_nss
    super(*args)
  end
  
end

class Game_Temp
  attr_accessor :show_ng_wora_nss
end
end # if Load_Title:WORA_NSS_INTEGRATE


Credit and Thanks
- Mithran
- Anyone who requested any of these (there are so many!)

FAQ
Q: You did this one thing, and I don't see it here.
A: I wont be posting every single snippet that I have ever written here. Some I plan to go back to later and overhaul or change completely. If you think I have omitted something that you know of that would be useful to the general populace, PM me about it and I'll think about adding it here.

Q: Does your script X work with script Y?
A: Probably. Try it first. If you have a specific problem, then let me know about it.

Q: How do I install a script?
A: Reference the RMVX help file, the editor itself, or a tutorial. Please dont ask this here, it has been gone over multiple times.

Q: I found a bug.
A: Please report it in detail, including the line it crashed on (if applicable), the full error description, and what other scripts you are using. Note that I might not be able to fix every single issue.

Q: Will you do X script for me?
A: This is not the place for requests. Make your own thread in the Scripts Request forum.

Q: Soandso already did this script, and it does this too!
A: Feel free to use the other script, then. If it makes you feel better, I'll be glad to take mine down. (not really)

Q: Will you do a demo?
A: Doubtful. Most of these snippets are plug and play and were created to address a single issue. Some will conflict with certain scripts, and others require the full scripts. It should be easy enough to grab what you need from this list.

Author's Notes
Credit as you see fit. Please do not post unedited versions of these scripts on other sites, if you want to reference them, link here.

This post has been edited by Mithran: Jan 1 2010, 09:48 PM


--------------------
Go to the top of the page
 
+Quote Post
   
Tofuman
post Aug 1 2009, 12:05 AM
Post #2



Group Icon


Type: Undisclosed




OMG... There are so many useful scripts so my eyes are spinning... wacko.gif
Thx Mithran!!
One Suggestion, For the once per battle skill script, can you make an option so you can use twice per battle or three times per battle and so on...

This post has been edited by Tofuman: Aug 1 2009, 12:13 AM
Go to the top of the page
 
+Quote Post
   
Svoltzilla
post Aug 1 2009, 12:11 AM
Post #3


But soon enough you will care by the time I'm done.
Group Icon


Type: Musician
Alignment: True Neutral




This is a great collection of scripts Mithran. I especially like the Change Class State one, it gives me some cool ideas.


--------------------
Click here to find some great resources and VX help. Click here to listen to my music.



Other great games:
Gettin' Dizzy! by MrAnonymous
Ravenwood Horror by Min Chan
Go to the top of the page
 
+Quote Post
   
Kinan
post Aug 1 2009, 08:33 AM
Post #4



Group Icon


Type: Undisclosed




Really nice collection Mithran-senpai. I like it, especially the Once-per-battle script.

I'll be reporting bugs if I find any! biggrin.gif

Thanks again!


--------------------
Tutorials by me

====================
Current Project:
Spoiler:

Working Title: "Crystal Remnant"
Started Working: 29/7/2011
Go to the top of the page
 
+Quote Post
   
Mithran
post Dec 31 2009, 02:28 AM
Post #5


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




Time for a quick update, I think.

Since my last bump, I've added over a dozen more. Most of them were already released for requests posts, some of them in PMs. I've also updated a couple (namely, Player Turn in Place) and formatted the original post a bit better.

Enjoy.


--------------------
Go to the top of the page
 
+Quote Post
   
Loaded
post Dec 31 2009, 02:31 AM
Post #6


Professional Plunderer
Group Icon


Type: Spriter




Wow, A lot of great snippets! biggrin.gif
Thanks!


--------------------
Go to the top of the page
 
+Quote Post
   
ZeroManArmy
post Jan 1 2010, 06:51 PM
Post #7


Click the Pokémon Banner!
Group Icon


Type: Undisclosed
Alignment: Chaotic Neutral




Your Player Turn In Place script Nulls out Wall Tile Extension script. I can walk an everything when I have that one in.


--------------------
Go to the top of the page
 
+Quote Post
   
Kinan
post Jan 1 2010, 08:40 PM
Post #8



Group Icon


Type: Undisclosed




Hey Mithran.

Just reporting an incompatable script with the Player Turn In Place script. Looks like it doesn't really go well with the KGC_Dash_8DirMove script. Kinda expected it but dunno if this can be fixed. Would like it though. smile.gif


--------------------
Tutorials by me

====================
Current Project:
Spoiler:

Working Title: "Crystal Remnant"
Started Working: 29/7/2011
Go to the top of the page
 
+Quote Post
   
ZeroManArmy
post Jan 1 2010, 09:05 PM
Post #9


Click the Pokémon Banner!
Group Icon


Type: Undisclosed
Alignment: Chaotic Neutral




It has some compatibilty issues yes. If were lucky he will fix them for us or make patches.


--------------------
Go to the top of the page
 
+Quote Post
   
Mithran
post Jan 1 2010, 09:47 PM
Post #10


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




@kinan - I did a KGC_8Dir version for you. KGC 8dir handles movement input a bit oddly, so this probably wont work with other 8 dir systems. If anyone else needs an 8 dir version, please link me the 8 dir script you are using.

@ZeroManArmy - Place my snippet below the Wall Extension Script. I tested it in the demo, it works like this, so if you continue to experience problems there might be another conflict.


--------------------
Go to the top of the page
 
+Quote Post
   
ZeroManArmy
post Jan 1 2010, 09:53 PM
Post #11


Click the Pokémon Banner!
Group Icon


Type: Undisclosed
Alignment: Chaotic Neutral




QUOTE (Mithran @ Jan 1 2010, 04:47 PM) *
@kinan - I did a KGC_8Dir version for you. KGC 8dir handles movement input a bit oddly, so this probably wont work with other 8 dir systems. If anyone else needs an 8 dir version, please link me the 8 dir script you are using.

@ZeroManArmy - Place my snippet below the Wall Extension Script. I tested it in the demo, it works like this, so if you continue to experience problems there might be another conflict.


You a godesend Mith! Thanks so much!


--------------------
Go to the top of the page
 
+Quote Post
   
R P G
post Jan 3 2010, 07:50 AM
Post #12



Group Icon






You know... for some reason, the names Mithran and BigEd781 seems to stick out everytime I think about RPG Maker VX scripts (me atleast). Even though these are little scripts, they improve your gameplay A LOT compared to those HUGE scripts.

And these little scripts are the reason why. You are awesome Mithran (you too BigEd781)!


--------------------

Purple's hott. She's hott.
Go to the top of the page
 
+Quote Post
   
Ookie Panda
post Jan 3 2010, 09:02 AM
Post #13


Infecting RMVX.net with "OwO" since 2009
Group Icon


Type: Artist
Alignment: Unaligned




Mithran yu are amazing~
verinaise!
might come in handy, some of these biggrin.gif


--------------------

This is where Ookie's at. Let's build another community together!
Go to the top of the page
 
+Quote Post
   
klaaa
post Jan 17 2010, 09:08 PM
Post #14



Group Icon


Type: Undisclosed




I tried the Advance Force Action, but I've a question:

Is there any way to force every member of a party to use different skills in the same time?

Imagine 4 guys using 4 different elemental attacks contemporaneously, but if one of them is dead, the other have to do the same "group move" without him... that's what I would like to do for example

Thanks
Go to the top of the page
 
+Quote Post
   
Mithran
post Jan 18 2010, 01:52 AM
Post #15


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




Force action only supports one actor at any given time due to the way the underlying command works. If you wanted to have the attacks go off in sequence, you can just use the command on each party member but put a wait (1 frame) in between each script command so the attacks execute before the next one is set up. Dead party members will be skipped, so you dont need to worry about that, either.


--------------------
Go to the top of the page
 
+Quote Post
   
crzybstrd
post Jan 24 2010, 03:25 AM
Post #16



Group Icon


Type: Undisclosed
Alignment: Chaotic Neutral




I would love to see a demo of your Class Change State script. I don't fully understand your instructions in the script.
Go to the top of the page
 
+Quote Post
   
Shadonn
post Jan 31 2010, 01:51 AM
Post #17


Jerk In A Box
Group Icon


Type: Writer
Alignment: Lawful Good




Hey Mith. I was looking at some of your scripts and found myself interested in your Clock draw snippet. If you don't mind helping me out (once more lol) I was wondering how would I get it set up to run off KGC Day/Night? KGC Day/Night stores it's data into two variables. The first is Phase. And the next is Days passed. I've thought about switching over to Kylock's script but there seems to be a lot of problems with it. Thanks


--------------------
In a state of writing limbo...
Go to the top of the page
 
+Quote Post
   
Mithran
post Jan 31 2010, 02:31 AM
Post #18


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




QUOTE (Shadonn @ Jan 30 2010, 05:51 PM) *
Hey Mith. I was looking at some of your scripts and found myself interested in your Clock draw snippet. If you don't mind helping me out (once more lol) I was wondering how would I get it set up to run off KGC Day/Night? KGC Day/Night stores it's data into two variables. The first is Phase. And the next is Days passed. I've thought about switching over to Kylock's script but there seems to be a lot of problems with it. Thanks


KGC Daynight doesn't really have a time unless you are using real time mode, otherwise, it goes off steps taken. If you are using realtime mode, place this below the clock window script and set KYLOCK_TIME_SYSTEM to true (even though you are using the KGC script)

Spoiler:
CODE
class Window_Clock
  def update_clock
    last_mins = @mins
    last_hrs = @hrs
    last_ampm = @ampm
    @mins = $game_variables[DrawClock::MINS_VAR_ID]
    @hrs = $game_variables[DrawClock::HOURS_VAR_ID]
    if DrawClock::KYLOCK_TIME_SYSTEM
      t = Time.now
      @mins = t.min
      @hrs = t.hour
      if @hrs >= 12
        @ampm = "PM"
        @hrs -= 12
      else
        @ampm = "AM"
      end
      @hrs = 12 if @hrs == 0
   end
    @blink_counter ||= 0
    @blink_counter += 1
    if DrawClock::BLINK_INTERVAL > 0
      @blink_counter %= DrawClock::BLINK_INTERVAL
    else
      @blink_counter = 0
    end
    last_dots_on = @dots_on
    if @blink_counter <= DrawClock::BLINK_INTERVAL / 2
      @dots_on = true
    else
      @dots_on = false
    end
    if (last_dots_on != @dots_on) || (last_mins != @mins) || (last_hrs != @hrs) || (last_ampm != @ampm)
      refresh
    end
  end
end


--------------------
Go to the top of the page
 
+Quote Post
   
Grandehoug
post Feb 12 2010, 01:11 AM
Post #19


Ahzrukhal
Group Icon


Type: Undisclosed
Alignment: Unaligned




I have a question about your Enlarged Graphic for face snippet.
Is there anyway for that to be adopted to messages, let's say by using \N[n] to work with corresponding actor id?
Go to the top of the page
 
+Quote Post
   
Mithran
post Feb 12 2010, 03:23 AM
Post #20


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




QUOTE (Grandehoug @ Feb 11 2010, 05:11 PM) *
I have a question about your Enlarged Graphic for face snippet.
Is there anyway for that to be adopted to messages, let's say by using \N[n] to work with corresponding actor id?


Place this below the Draw Huge Character snippet. Use \HCS[id] to set which graphic to use. Overrides whatever face is there, if there was any.

Spoiler:
CODE
# Supplment for Huge Character Sprite Instead of Actor Face
# for the message window
# use /HCS[ID] in the message window to set which sprite to use
# replacing ID with the id of the actor
# or 0 for the current party leader
# Requires Draw Huge Character Sprite Instead of Actor Face for the
# 'draw_actor_huge' method

class Window_Message
  alias convert_special_characters_addface convert_special_characters
  def convert_special_characters
    convert_special_characters_addface
    @text.gsub!(/\\HCS\[(\-?[0-9]+)\]/i) { $game_temp.face_buffer_00125 = $1.to_i
    $game_message.face_name = " "
    "" }
  end

end

class Game_Temp; attr_accessor :face_buffer_00125; end
  
class Window_Base
  alias draw_face_orig_hugechar_message draw_face
  def draw_face(*args)
    if self.is_a?(Window_Message) && $game_temp.face_buffer_00125 != nil
      2.times { args.shift }
      buf = $game_temp.face_buffer_00125
      if buf > 0
        args.unshift($game_actors[buf])
      else
        args.unshift($game_party.members[-buf])
      end
      $game_temp.face_buffer_00125 = nil
      return if args[0].nil?
      args[3] ||= 96
      draw_actor_huge(*args)
      return
    end
    draw_face_orig_hugechar_message(*args)
  end
  
end


--------------------
Go to the top of the page
 
+Quote Post
   

3 Pages V   1 2 3 >
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: 29th August 2014 - 11:09 AM

RPGMakerVX.net is an Privacy Policy, Legal.