查看: 3861|回复: 4

[转载] 【来地球村逛逛】守护精灵之神降系统

[复制链接]
梦石
0
星屑
67
在线时间
140 小时
注册时间
2012-2-6
回帖
351
发表于 2012-3-16 10:29:29 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 杂兵天下 于 2012-3-16 14:33 编辑

来源yamiworld.wordpress.com
  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Ace - Basic Module
  4. # -- Last Updated: 2012.03.13
  5. # -- Level: Nothing
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

  9. $imported = {} if $imported.nil?
  10. $imported["YSE-BasicModule"] = true

  11. #==============================================================================
  12. # ¥ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.03.13 - Remove requirements mechanic.
  15. # 2012.03.11 - Change in requirements mechanic.
  16. # 2012.03.02 - Added Message Box.
  17. # 2012.03.01 - Started and Finished Script.
  18. #
  19. #==============================================================================
  20. # ¥ Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # This script provides many methods for Yami Engine Ace.
  23. #
  24. # * Feature:
  25. #   - Save and Load data files. (2012.03.01)
  26. #
  27. # * Misc:
  28. #   - Make random string.       (2012.03.01)
  29. #   - Make hash.                (2012.03.01)
  30. #   - Win32API Message Box.     (2012.03.02)
  31. #
  32. #==============================================================================
  33. # ¥ Instructions
  34. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  35. # To install this script, open up your script editor and copy/paste this script
  36. # to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
  37. #
  38. #==============================================================================
  39. # ¥ Compatibility
  40. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  41. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  42. # it will run with RPG Maker VX without adjusting.
  43. #
  44. #==============================================================================

  45. #==============================================================================
  46. # ¥ Configuration
  47. #==============================================================================

  48. module YSE
  49.   
  50.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  51.   # - External Data Configuration -
  52.   #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  53.   DATA_CONFIGURATION = { # Start here.
  54.     :ext        =>  "rvdata2",  # Data File Extension.
  55.     :salt       =>  "D6*&wg7O",# Salt. Make an unique phrase here.
  56.                                  # Must be at least 2 characters.
  57.     :comp_level =>  9,           # Level from 1 to 9. Best Speed at 1, Best
  58.                                  # Compress at 9.
  59.   } # Do not delete this.
  60.   
  61. end

  62. #==============================================================================
  63. # ¥ Editting anything past this point may potentially result in causing
  64. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  65. # halitosis so edit at your own risk.
  66. #==============================================================================

  67. #==============================================================================
  68. # ¡ YSE - Basic Module
  69. #==============================================================================

  70. module YSE
  71.   
  72.   #--------------------------------------------------------------------------
  73.   # message_box
  74.   #--------------------------------------------------------------------------
  75.   def self.message_box(title, message)
  76.     api = Win32API.new('user32','MessageBox',['L', 'P', 'P', 'L'],'I')  
  77.     api.call(0,message,title,0)  
  78.   end
  79.   
  80.   #--------------------------------------------------------------------------
  81.   # charset
  82.   #--------------------------------------------------------------------------
  83.   def self.charset
  84.     result = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"
  85.     result
  86.   end
  87.   
  88.   #--------------------------------------------------------------------------
  89.   # make_random_string
  90.   #--------------------------------------------------------------------------
  91.   def self.make_random_string(length = 6)
  92.     result = ""
  93.     while result.size < length
  94.       result << charset[rand(charset.size)]
  95.     end
  96.     result
  97.   end
  98.   
  99.   #--------------------------------------------------------------------------
  100.   # make_filename
  101.   #--------------------------------------------------------------------------
  102.   def self.make_filename(filename, dir = "")
  103.     ext = DATA_CONFIGURATION[:ext]
  104.     result = "#{dir}/#{filename}.#{ext}"
  105.     result
  106.   end
  107.   
  108.   #--------------------------------------------------------------------------
  109.   # compress_data
  110.   #--------------------------------------------------------------------------
  111.   def self.compress_data(data, comp_level = nil)
  112.     compress_level = comp_level.nil? ? DATA_CONFIGURATION[:comp_level] : comp_level
  113.     result = Zlib::Deflate.deflate(Marshal.dump(data), compress_level)
  114.     result
  115.   end
  116.   
  117.   #--------------------------------------------------------------------------
  118.   # decompress_data
  119.   #--------------------------------------------------------------------------
  120.   def self.decompress_data(data)
  121.     result = Zlib::Inflate.inflate(Marshal.load(data))
  122.     result
  123.   end
  124.   
  125.   #--------------------------------------------------------------------------
  126.   # make_hash
  127.   #--------------------------------------------------------------------------
  128.   def self.make_hash(string = "")
  129.     salt = DATA_CONFIGURATION[:salt]
  130.     if salt.size < 2; salt = make_random_string(8); end
  131.     result = string.crypt(salt)
  132.     result
  133.   end
  134.   
  135.   #--------------------------------------------------------------------------
  136.   # save_data
  137.   #--------------------------------------------------------------------------
  138.   def self.save_data(filename, data_hash)
  139.     File.open(filename, "wb") do |file|
  140.       Marshal.dump(compress_data(data_hash), file)
  141.     end
  142.     return true
  143.   end
  144.   
  145.   #--------------------------------------------------------------------------
  146.   # save_data
  147.   #--------------------------------------------------------------------------
  148.   def self.load_data(filename, method, index = 0)
  149.     File.open(filename, "rb") do |file|
  150.       index.times { Marshal.load(file) }
  151.       method.call(Marshal.load(decompress_data(file)))
  152.     end
  153.     return true
  154.   end
  155.   
  156.   #--------------------------------------------------------------------------
  157.   # save_data
  158.   #--------------------------------------------------------------------------
  159.   def self.patch_start
  160.     return unless $imported["YSE-PatchSystem"]
  161.     SceneManager.call(Scene_Patch_YSE)
  162.   end
  163.   
  164. end # YSE - Basic Module

  165. #==============================================================================
  166. # ¡ System Errors
  167. #==============================================================================

  168. if YSE::DATA_CONFIGURATION[:salt].size < 2
  169.   YSE.message_box("YSE - Basic Module", "Salt must have at least 2 characters.")
  170.   exit
  171. end

  172. #==============================================================================
  173. #
  174. # ¥ End of File
  175. #
  176. #==============================================================================
复制代码
必须以上脚本的支持才能运行!!!!
[pre lang="ruby" line="1"]#==============================================================================
#
# ▼ Yami Engine Ace - Guardian Series
# -- Script: Guardian Basic
# -- Last Updated: 2012.03.11
# -- Level: Easy
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YSE-GuardianBasic"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.03.11 - Finished Script.
# 2012.03.05 - Started Script.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script gives you a notetag for Actors to make them be guardians. An actor
# marked as guardian is not shown in default menu, battle, but will be available
# for other scripts in Guardian Series.
#
# This script also contains two basic windows for Guardians:
#   - Window Guardians List. Class Window_MenuGuardian
#   - Window Guardian Small Status. Class Window_StatusGuardian
#
# -----------------------------------------------------------------------------
# Actor Notetags - These notetags go in the actor notebox in the database.
# -----------------------------------------------------------------------------
# <guardian>
# This notetag marks an actor as a guardian.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YSE
  module GUARDIAN
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Mechanic Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ALL_GUARDIAN_GAIN_EXP     = false
   
  end
end

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

#==============================================================================
# ■ Regular Expression
#==============================================================================

module YSE
  module REGEXP
    module ACTOR
      GUARDIAN = /<(?:GUARDIAN)>/i
    end # ACTOR
  end # REGEXP
end # YSE

#==============================================================================
# ■ BattleManager
#==============================================================================

module BattleManager
  
  #--------------------------------------------------------------------------
  # alias method: gain_exp
  #--------------------------------------------------------------------------
  class <<self; alias yse_gain_exp_gb gain_exp; end
  def self.gain_exp
    $game_party.guardians.each do |guardian|
      guardian.gain_exp($game_troop.exp_total) if YSE::GUARDIAN::ALL_GUARDIAN_GAIN_EXP
    end
    yse_gain_exp_gb
  end
  
end # BattleManager

#==============================================================================
# ■ Game_Temp
#==============================================================================

class Game_Temp
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :scene_gmenu_id
  
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias yse_initialize_gb initialize
  def initialize
    yse_initialize_gb
    @scene_gmenu_id = 0
  end
  
end # Game_Temp

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_ysegb load_database; end
  def self.load_database
    load_database_ysegb
    load_notetags_ysegb
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_ysegb
  #--------------------------------------------------------------------------
  def self.load_notetags_ysegb
    group = $data_actors
    for obj in group
      next if obj.nil?
      obj.load_notetags_ysegb
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Actor
#==============================================================================

class RPG::Actor < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :is_guardian

  #--------------------------------------------------------------------------
  # new method: load_notetags_ysegb
  #--------------------------------------------------------------------------
  def load_notetags_ysegb
    @is_guardian = false
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YSE::REGEXP::ACTOR::GUARDIAN
        @is_guardian = true
      end
    } # self.note.split
    #---
  end
  
end # RPG::Actor

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  
  #--------------------------------------------------------------------------
  # new method: guardian?
  #--------------------------------------------------------------------------
  def guardian?
    return actor.is_guardian
  end
  
  #--------------------------------------------------------------------------
  # new method: guardian_index
  #--------------------------------------------------------------------------
  def guardian_index
    $game_party.guardians.index(self)
  end
  
end # Game_Actor

#==============================================================================
# ■ Game_Party
#==============================================================================

class Game_Party < Game_Unit
  
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------  
  alias yse_initialize_gb initialize
  def initialize
    yse_initialize_gb
    @guardians = []
  end
  
  #--------------------------------------------------------------------------
  # alias method: all_members
  #--------------------------------------------------------------------------
  alias yse_all_members_gb all_members
  def all_members
    @actors.each {|id|
      if $game_actors[id].guardian?; @actors.delete(id); add_actor(id); end
    }
    yse_all_members_gb
  end
  
  #--------------------------------------------------------------------------
  # new method: guardians
  #--------------------------------------------------------------------------  
  def guardians
    @guardians.collect {|id| $game_actors[id] }
  end
  
  #--------------------------------------------------------------------------
  # alias method: add_actor
  #--------------------------------------------------------------------------  
  alias yse_add_actor_gb add_actor
  def add_actor(actor_id)
    if $game_actors[actor_id].guardian?
      @guardians.push(actor_id) unless @guardians.include?(actor_id)
      return
    end
    yse_add_actor_gb(actor_id)
  end
  
  #--------------------------------------------------------------------------
  # new method: menu_guardian
  #--------------------------------------------------------------------------  
  def menu_guardian
    $game_actors[$game_temp.scene_gmenu_id].nil? ? guardians[0] : $game_actors[$game_temp.scene_gmenu_id]
  end
  
  #--------------------------------------------------------------------------
  # new method: menu_guardian_next
  #--------------------------------------------------------------------------  
  def menu_guardian_next
    index = guardians.index(menu_actor) || -1
    index = (index + 1) % guardians.size
    self.menu_actor = guardians[index]
  end
  
  #--------------------------------------------------------------------------
  # new method: menu_guardian_prev
  #--------------------------------------------------------------------------  
  def menu_guardian_prev
    index = guardians.index(menu_actor) || 1
    index = (index + guardians.size - 1) % guardians.size
    self.menu_actor = guardians[index]
  end
  
  #--------------------------------------------------------------------------
  # alias method: menu_actor_next
  #--------------------------------------------------------------------------
  alias yse_menu_actor_next_gb menu_actor_next
  def menu_actor_next
    if @guardians.include?(menu_actor.id)
      menu_guardian_next
    else
      yse_menu_actor_next_gb
    end
  end
  
  #--------------------------------------------------------------------------
  # alias method: menu_actor_prev
  #--------------------------------------------------------------------------
  alias yse_menu_actor_prev_gb menu_actor_prev
  def menu_actor_prev
    if @guardians.include?(menu_actor.id)
      menu_guardian_prev
    else
      yse_menu_actor_prev_gb
    end
  end
  
end # Game_Party

#==============================================================================
# ■ Window_MenuGuardian
#==============================================================================

class Window_MenuGuardian < Window_Selectable
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, window_width, Graphics.height - y)
    refresh
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width
  end
  
  #--------------------------------------------------------------------------
  # item_max
  #--------------------------------------------------------------------------
  def item_max
    $game_party.guardians.size
  end
  
  #--------------------------------------------------------------------------
  # col_max
  #--------------------------------------------------------------------------
  def col_max
    2
  end
  
  #--------------------------------------------------------------------------
  # process_ok
  #--------------------------------------------------------------------------
  def process_ok
    $game_party.menu_actor = $game_party.guardians[index]
    $game_temp.scene_gmenu_id = $game_party.guardians[index].id
    super
  end
  
  #--------------------------------------------------------------------------
  # draw_item
  #--------------------------------------------------------------------------
  def draw_item(index)
    guardian = $game_party.guardians[index]
    rect = item_rect(index)
    face_rect = Rect.new(rect.x + 1, rect.y + 1, item_height - 2, item_height - 2)
    draw_guardian_name(guardian, rect.x, rect.y, rect.width)
    draw_thumb_face(guardian, face_rect)
    draw_guardian_status(guardian, rect.x, rect.y, rect.width)
  end
  
  #--------------------------------------------------------------------------
  # draw_thumb_face
  #--------------------------------------------------------------------------
  def draw_thumb_face(actor, dest_rect)
    bitmap = Cache.face(actor.face_name)
    rect = Rect.new(actor.face_index % 4 * 96, actor.face_index / 4 * 96, 96, 96)
    bitmap.blur
    contents.stretch_blt(dest_rect, bitmap, rect, enable?(actor) ? 255 : translucent_alpha)
    bitmap.dispose
  end
  
  #--------------------------------------------------------------------------
  # draw_guardian_name
  #--------------------------------------------------------------------------
  def draw_guardian_name(actor, dx, dy, dw)
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)
    contents.fill_rect(rect, colour)
    change_color(system_color, enable?(actor))
    draw_text(dx + item_height + 2, dy, dw, line_height, actor.name)
  end
  
  #--------------------------------------------------------------------------
  # draw_guardian_status
  #--------------------------------------------------------------------------
  def draw_guardian_status(actor, dx, dy, dw)
    change_color(normal_color, enable?(actor))
    draw_text(dx, dy, dw, line_height, Vocab::level_a + actor.level.to_s, 2)
  end
  
  #--------------------------------------------------------------------------
  # enabled
  #--------------------------------------------------------------------------
  def enable?(actor = nil)
    return true
  end
  
  #--------------------------------------------------------------------------
  # update_help
  #--------------------------------------------------------------------------
  alias yse_call_update_help_gb call_update_help
  def call_update_help
    yse_call_update_help_gb
    return if @status_window.nil?
    return if $game_party.guardians.size == 0
    item = index < 0 ? $game_party.menu_guardian : $game_party.guardians[index]
    @status_window.guardian = item
  end
  
  #--------------------------------------------------------------------------
  # update_help
  #--------------------------------------------------------------------------
  def update_help
    @help_window.clear
    item = index < 0 ? $game_party.menu_guardian : $game_party.guardians[index]
    @help_window.set_item(item)
  end
  
  #--------------------------------------------------------------------------
  # select_last
  #--------------------------------------------------------------------------
  def select_last
    select($game_party.menu_guardian.guardian_index)
  end
  
  #--------------------------------------------------------------------------
  # status_window=
  #--------------------------------------------------------------------------
  def status_window=(status_window)
    @status_window = status_window
    item = index < 0 ? $game_party.menu_guardian : $game_party.guardians[index]
    @status_window.guardian = item
  end
  
end # Window_MenuGuardian

#==============================================================================
# ■ Window_StatusGuardian
#==============================================================================

class Window_StatusGuardian < Window_Base
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(dx, dy)
    @guardian = $game_party.menu_guardian
    super(dx, dy, window_width, fitting_height(4))
    refresh
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; return Graphics.width - 160; end
  
  #--------------------------------------------------------------------------
  # guardian=
  #--------------------------------------------------------------------------
  def guardian=(guardian)
    return if @guardian == guardian
    @guardian = guardian
    refresh
  end
  
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    return unless @guardian
    draw_actor_face(@guardian, 0, 0)
    colour = Color.new(0, 0, 0, translucent_alpha / 2)
    rect = Rect.new(0, line_height * 3 + 2, 106, line_height-2)
    contents.fill_rect(rect, colour)
    draw_actor_name(@guardian, 0, line_height * 3 + 1, 108)
    dw = (contents.width - 108) / 2
    dx = 108
    draw_actor_param(0, dx, line_height * 0, dw)
    draw_actor_param(1, dx + dw, line_height * 0, dw)
    draw_actor_param(2, dx, line_height * 1, dw)
    draw_actor_param(3, dx + dw, line_height * 1, dw)
    draw_actor_param(4, dx, line_height * 2, dw)
    draw_actor_param(5, dx + dw, line_height * 2, dw)
    draw_actor_param(6, dx, line_height * 3, dw)
    draw_actor_param(7, dx + dw, line_height * 3, dw)
  end
  
  #--------------------------------------------------------------------------
  # draw_actor_param
  #--------------------------------------------------------------------------
  def draw_actor_param(param_id, dx, dy, dw)
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)
    contents.fill_rect(rect, colour)
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::param(param_id))
    change_color(normal_color)
    draw_text(dx+4, dy, dw-8, line_height, @guardian.param(param_id).to_s, 2)
  end
  
end # Window_StatusGuardian

#==============================================================================
#
# ▼ End of File
#
#==============================================================================
#==============================================================================
#
# ▼ Yami Engine Ace - Guardian Series
# -- Script: Guardian Menu
# -- Last Updated: 2012.03.13
# -- Level: Easy
# -- Requires: YSE - Guardian Basic
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YSE-GuardianMenu"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.03.13 - Finished Script.
# 2012.03.11 - Started Script.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Manages menu commands for Guardian. This Menu will be separate with Main Menu
# for actor. Can be called by Main Menu.
# If you have Yanfly Engine Ace - Menu Engine, You must add a custom command
# which calls Handler Method :command_guardian.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YSE
  module GUARDIAN_MENU
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Command Window Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # This section adjusts the commands that appear in the command window used
    # for the status screen. Rearrange the commands, add new ones, remove them
    # as you see fit.
    #
    # -------------------------------------------------------------------------
    # :command         Description
    # -------------------------------------------------------------------------
    # :status          Calls Scene_Status scene.
    # :skill           Calls Scene_Skill scene.
    # :equip           Calls Scene_Equip scene.
    #
    # :gpair           Calls Guardian Pairing.
    #                  Require YSE - Guardian Pairing.
    #
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    COMMANDS = [ # The order at which the menu items are shown.
    # [    :command,    "Display"],
      [    :status,      "状态"],
      [    :skill,       "技能"],
      [    :equip,       "装备"],
      [    :gpair,       "神之降临"],
    # [    :custom1,     "Custom"],
    # [    :custom2,     "motsuC"],
    ] # Do not remove this.
   
    #--------------------------------------------------------------------------
    # - Menu Custom Commands -
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # For those who use scripts to that may produce unique effects for the
    # status menu, use this hash to manage the custom commands for the Status
    # Command Window. You can disable certain commands or prevent them from
    # appearing by using switches. If you don't wish to bind them to a switch,
    # set the proper switch to 0 for it to have no impact.
    #--------------------------------------------------------------------------
    CUSTOM_STATUS_COMMANDS = {
    # :command => [EnableSwitch, ShowSwitch, Handler Method],
      :custom1 => [           0,          0, :command_name1],
      :custom2 => [           0,          0, :command_name2],
    } # Do not remove this.
   
    # These Configurations contain visual and vocab things.
    VOCAB_MENU = "守护神"    # Command Display in Main Menu.
    MENU_ENABLE_SWITCH = 0      # Set to 0 if don't wanna use this function.
   
  end
end

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

#==============================================================================
# ■ Vocab
#==============================================================================

module Vocab
  GuardianMenu = YSE::GUARDIAN_MENU::VOCAB_MENU
end

#==============================================================================
# ■ Game_Temp
#==============================================================================

class Game_Temp
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :guardian_menu_command
  
end # Game_Temp

#==============================================================================
# ■ Window_MenuCommand
#==============================================================================

class Window_MenuCommand < Window_Command
  
  #--------------------------------------------------------------------------
  # alias method: make_command_list
  #--------------------------------------------------------------------------
  alias yse_add_main_commands_gm add_main_commands
  def add_main_commands
    yse_add_main_commands_gm
    add_guardian_commands unless $imported["YEA-AceMenuEngine"]
  end
  
  #--------------------------------------------------------------------------
  # new method: guardian_command_enabled
  #--------------------------------------------------------------------------
  def guardian_command_enabled
    return false if $game_party.guardians.size == 0
    return true if YSE::GUARDIAN_MENU::MENU_ENABLE_SWITCH <= 0
    return $game_switches[YSE::GUARDIAN_MENU::MENU_ENABLE_SWITCH]
  end

  #--------------------------------------------------------------------------
  # new method: add_guardian_commands
  #--------------------------------------------------------------------------
  def add_guardian_commands
    add_command(Vocab::GuardianMenu,   :guardian,   guardian_command_enabled)
  end
  
end # Window_MenuCommand

#==============================================================================
# ■ Scene_Menu
#==============================================================================

class Scene_Menu < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # alias method: create_command_window
  #--------------------------------------------------------------------------
  alias yse_create_command_window_gm create_command_window
  def create_command_window
    yse_create_command_window_gm
    @command_window.set_handler(:guardian, method(:command_guardian))
  end
  
  #--------------------------------------------------------------------------
  # new method: command_guardian
  #--------------------------------------------------------------------------
  def command_guardian
    SceneManager.call(Scene_GuardianMenu)
  end
  
end # Scene_Menu

#==============================================================================
# ■ Window_GuardianMenuCommand
#==============================================================================

class Window_GuardianMenuCommand < Window_Command
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(dx, dy)
    super(dx, dy)
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; return 160; end
  
  #--------------------------------------------------------------------------
  # visible_line_number
  #--------------------------------------------------------------------------
  def visible_line_number; return 4; end
   
  #--------------------------------------------------------------------------
  # alignment
  #--------------------------------------------------------------------------
  def alignment; return 1; end
  
  #--------------------------------------------------------------------------
  # ok_enabled?
  #--------------------------------------------------------------------------
  def ok_enabled?
    return handle?(current_symbol)
  end
  
  #--------------------------------------------------------------------------
  # process_ok
  #--------------------------------------------------------------------------
  def process_ok
    $game_temp.guardian_menu_command = self.index
    super
  end
  
  #--------------------------------------------------------------------------
  # make_command_list
  #--------------------------------------------------------------------------
  def make_command_list
    for command in YSE::GUARDIAN_MENU::COMMANDS
      case command[0]
      #--- Default ---
      when :status, :items, :skill, :equip
        add_command(command[1], command[0], $game_party.guardians.size > 0)
      #--- Imported ---
      when :gpair
        add_command(command[1], command[0], $game_party.guardians.size > 0)
      #--- Custom Commands ---
      else
        process_custom_command(command)
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # process_custom_command
  #--------------------------------------------------------------------------
  def process_custom_command(command)
    return unless YSE::GUARDIAN_MENU::CUSTOM_STATUS_COMMANDS.include?(command[0])
    show = YSE::GUARDIAN_MENU::CUSTOM_STATUS_COMMANDS[command[0]][1]
    continue = show <= 0 ? true : $game_switches[show]
    return unless continue
    text = command[1]
    switch = YSE::GUARDIAN_MENU::CUSTOM_STATUS_COMMANDS[command[0]][0]
    enabled = switch <= 0 ? true : $game_switches[switch]
    add_command(text, command[0], enabled)
  end
  
end # Window_GuardianMenuCommand

#==============================================================================
# ■ Scene_GuardianMenu
#==============================================================================

class Scene_GuardianMenu < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # start
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_command_window
    create_status_window
    create_guardian_window
    create_actor_window
  end
  
  #--------------------------------------------------------------------------
  # create_command_window
  #--------------------------------------------------------------------------
  def create_command_window
    wy = @help_window.height
    @command_window = Window_GuardianMenuCommand.new(0, wy)
    @command_window.viewport = @viewport
    @command_window.set_handler(:cancel,   method(:return_scene))
    @command_window.set_handler(:skill,     method(:command_personal))
    @command_window.set_handler(:equip,     method(:command_personal))
    @command_window.set_handler(:status,    method(:command_personal))
    if $imported["YSE-GuardianPairing"]
      @command_window.set_handler(:gpair, method(:command_personal_actor))
    end
    process_custom_status_commands
    if $game_temp.guardian_menu_command
      @command_window.index = $game_temp.guardian_menu_command
      $game_temp.guardian_menu_command = nil
    end
  end
   
  #--------------------------------------------------------------------------
  # create_status_window
  #--------------------------------------------------------------------------
  def create_status_window
    wy = @help_window.height
    @status_window = Window_StatusGuardian.new(@command_window.width, wy)
    @status_window.viewport = @viewport
  end
  
  #--------------------------------------------------------------------------
  # create_guardian_window
  #--------------------------------------------------------------------------
  def create_guardian_window
    wy = @command_window.height + @command_window.y
    @guardian_window = Window_MenuGuardian.new(0, wy)
    @guardian_window.viewport = @viewport
    @guardian_window.help_window = @help_window
    @guardian_window.update_help
    @guardian_window.status_window = @status_window
  end
  
  #--------------------------------------------------------------------------
  # create_actor_window
  #--------------------------------------------------------------------------
  def create_actor_window
    @actor_window = Window_MenuActor.new
    @actor_window.viewport = @viewport
    @actor_window.set_handler(:ok,     method(:on_actor_ok))
    @actor_window.set_handler(:cancel, method(:on_actor_cancel))
  end
  
  #--------------------------------------------------------------------------
  # command_personal
  #--------------------------------------------------------------------------
  def command_personal
    @guardian_window.activate
    @guardian_window.select_last
    @guardian_window.set_handler(:ok,     method(:on_personal_ok))
    @guardian_window.set_handler(:cancel, method(:on_personal_cancel))
  end
  
  #--------------------------------------------------------------------------
  # command_personal_actor
  #--------------------------------------------------------------------------
  def command_personal_actor
    @actor_window.x = Graphics.width - @actor_window.width
    @actor_window.show.activate
    @actor_window.select_last
  end
  
  #--------------------------------------------------------------------------
  # on_personal_ok
  #--------------------------------------------------------------------------
  def on_personal_ok
    case @command_window.current_symbol
    when :skill
      SceneManager.call(Scene_Skill)
    when :equip
      SceneManager.call(Scene_Equip)
    when :status
      SceneManager.call(Scene_Status)
    end
  end
  
  #--------------------------------------------------------------------------
  # on_personal_cancel
  #--------------------------------------------------------------------------
  def on_personal_cancel
    @guardian_window.unselect
    @command_window.activate
  end
  
  #--------------------------------------------------------------------------
  # on_actor_ok
  #--------------------------------------------------------------------------
  def on_actor_ok
    case @command_window.current_symbol
    #--- Imported ---
    when :gpair
      SceneManager.call(Scene_GuardianPairing)
    end
  end
  
  #--------------------------------------------------------------------------
  # on_actor_cancel
  #--------------------------------------------------------------------------
  def on_actor_cancel
    @actor_window.hide.deactivate
    @command_window.activate
  end
  
  #--------------------------------------------------------------------------
  # process_custom_status_commands
  #--------------------------------------------------------------------------
  def process_custom_status_commands
    commands = YSE::GUARDIAN_MENU::COMMANDS
    custom_commands = YSE::GUARDIAN_MENU::CUSTOM_STATUS_COMMANDS
    for command in commands
      next unless custom_commands.include?(command[0])
      called_method = custom_commands[command[0]][2]
      @command_window.set_handler(command[0], method(called_method))
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: command_guardian_pairing
  #--------------------------------------------------------------------------
  def command_guardian_pairing
    SceneManager.call(Scene_GuardianPairing)
  end
  
  #--------------------------------------------------------------------------
  # command_name1
  #--------------------------------------------------------------------------
  def command_name1
    # Do nothing
  end
  
  #--------------------------------------------------------------------------
  # command_name2
  #--------------------------------------------------------------------------
  def command_name2
    # Do nothing
  end
  
end # Scene_GuardianMenu

#==============================================================================
#
# ▼ End of File
#
#==============================================================================
#==============================================================================
#
# ▼ Yami Engine Ace - Guardian Series
# -- Script: Guardian Pairing
# -- Last Updated: 2012.03.15
# -- Level: Easy
# -- Requires: YSE - Guardian Basic
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YSE-GuardianPairing"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.03.15 - Separated Boosting Attributes feature.
#            - Changed a little in visuals.
# 2012.03.14 - Finished Script.
# 2012.03.13 - Started Script.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This scripts provides "Equip Guardian to Actor" Feature for Guardians.
# If you have YSE - Guardian Menu in scripts list, You must add :gpair to
# Guardian Menu commands to show Pairing Menu.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YSE
  module GUARDIAN_PAIRING
   
    # These Configurations contain visual and vocab things.
    PAIRED_GUARDIAN = "%s"
    NON_PAIRED = "没有神降"
    VOCAB_MENU = "神之降临"    # Command Display in Main Menu.
    MENU_ENABLE_SWITCH = 0      # Set to 0 if don't wanna use this function.
   
    COMMANDS = [ # The order at which the menu items are shown.
      [    :pair,            "准备神降"], # Pairing command.
      [    :unpair,       "解除神降"], # Un-Pairing command
    ] # Do not remove this.
   
  end
end

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

#==============================================================================
# ■ Vocab
#==============================================================================

module Vocab
  GuardianPairingMenu = YSE::GUARDIAN_PAIRING::VOCAB_MENU
  PairedGuardian = YSE::GUARDIAN_PAIRING::PAIRED_GUARDIAN
  NonPaired = YSE::GUARDIAN_PAIRING::NON_PAIRED
end

#==============================================================================
# ■ Game_Temp
#==============================================================================

class Game_Temp
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :guardian_pairing_menu_command
  
end # Game_Temp

#==============================================================================
# ■ Window_MenuCommand
#==============================================================================

class Window_MenuCommand < Window_Command
  
  #--------------------------------------------------------------------------
  # alias method: make_command_list
  #--------------------------------------------------------------------------
  alias yse_add_main_commands_gp add_main_commands
  def add_main_commands
    yse_add_main_commands_gp
    add_guardian_pairing_commands unless $imported["YEA-AceMenuEngine"]
  end
  
  #--------------------------------------------------------------------------
  # new method: guardian_command_enabled
  #--------------------------------------------------------------------------
  def guardian_pairing_command_enabled
    return false if $game_party.guardians.size == 0
    return true if YSE::GUARDIAN_PAIRING::MENU_ENABLE_SWITCH <= 0
    return $game_switches[YSE::GUARDIAN_PAIRING::MENU_ENABLE_SWITCH]
  end

  #--------------------------------------------------------------------------
  # new method: add_guardian_pairing_commands
  #--------------------------------------------------------------------------
  def add_guardian_pairing_commands
    return if $imported["YSE-GuardianMenu"]
    add_command(Vocab::GuardianPairingMenu,   :gpair,   guardian_pairing_command_enabled)
  end
  
end # Window_MenuCommand

#==============================================================================
# ■ Scene_Menu
#==============================================================================

class Scene_Menu < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # alias method: create_command_window
  #--------------------------------------------------------------------------
  alias yse_create_command_window_gp create_command_window
  def create_command_window
    yse_create_command_window_gp
    @command_window.set_handler(:gpair, method(:command_personal))
  end
  
  #--------------------------------------------------------------------------
  # alias method: on_personal_ok
  #--------------------------------------------------------------------------
  alias yse_on_personal_ok_gp on_personal_ok
  def on_personal_ok
    case @command_window.current_symbol
    when :gpair
      $game_party.target_actor = $game_party.members[@status_window.index]
      SceneManager.call(Scene_GuardianPairing)
    else
      yse_on_personal_ok_gp
    end
  end
  
end # Scene_Menu

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :pair_actor

  #--------------------------------------------------------------------------
  # alias method: setup
  #--------------------------------------------------------------------------
  alias yse_setup_gp setup
  def setup(actor_id)
    @guardians = []
    @pair_actor = nil
    yse_setup_gp(actor_id)
    clear_guardians
  end
  
  #--------------------------------------------------------------------------
  # new method: guardians
  #--------------------------------------------------------------------------
  def guardians
    @guardians.collect {|id| $game_actors[id] }
  end

  #--------------------------------------------------------------------------
  # new method: paired_actor
  #--------------------------------------------------------------------------
  def paired_actor
    @pair_actor.nil? ? nil : $game_actors[@pair_actor]
  end
  
  #--------------------------------------------------------------------------
  # new method: first_guardian
  #--------------------------------------------------------------------------
  def first_guardian
    guardians[0]
  end
  
  #--------------------------------------------------------------------------
  # new method: is_pair?
  #--------------------------------------------------------------------------
  def is_pair?
    guardian? ? !@pair_actor.nil? : guardians.size > 0
  end
  
  #--------------------------------------------------------------------------
  # new method: is_pair?
  #--------------------------------------------------------------------------
  def force_pair(guardian)
    @guardians.clear
    @guardians.push(guardian.id) if guardian
    @guardians.compact!
    refresh
  end
  
  #--------------------------------------------------------------------------
  # new method: is_pair?
  #--------------------------------------------------------------------------
  def pair(guardian)
    return if guardians.include?(guardian)
    clear_guardians
    @guardians.push(guardian.id)
    guardian.pair_actor = self.id
    refresh
  end
  
  #--------------------------------------------------------------------------
  # new method: clear_guardians
  #--------------------------------------------------------------------------
  def clear_guardians
    guardians.each { |g| g.pair_actor = nil }
    @guardians.clear
  end
   
  #--------------------------------------------------------------------------
  # alias method: gain_exp
  #--------------------------------------------------------------------------
  alias yse_gain_exp_gp gain_exp
  def gain_exp(exp)
    yse_gain_exp_gp(exp)
    return if guardian?
    guardians.each { |guardian|
      guardian.gain_guardian_exp(guardian, exp)
    }
  end
  
  #--------------------------------------------------------------------------
  # new method: gain_guardian_exp
  #--------------------------------------------------------------------------
  def gain_guardian_exp(guardian,exp)
    return if YSE::GUARDIAN::ALL_GUARDIAN_GAIN_EXP
    guardian.gain_exp(exp)
  end
  
end # Game_Actor

#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base < Window
  
  #--------------------------------------------------------------------------
  # new method: draw_actor_guardian
  #--------------------------------------------------------------------------
  def draw_actor_guardian(actor, x, y, width = 180)
    change_color(normal_color)
    str = Vocab::PairedGuardian
    if actor.guardian?
      name = actor.paired_actor.nil? ? Vocab::NonPaired : actor.paired_actor.name
    else
      name = actor.first_guardian.nil? ? Vocab::NonPaired : actor.first_guardian.name
    end
    str =  sprintf(str, name)
    draw_text(x, y, width, line_height, str, 2)
  end
  
end # Window_Base
  
#==============================================================================
# ■ Window_GuardianPairingMenuCommand
#==============================================================================

class Window_GuardianPairingMenuCommand < Window_Command
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(dx, dy)
    super(dx, dy)
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; return 160; end
  
  #--------------------------------------------------------------------------
  # visible_line_number
  #--------------------------------------------------------------------------
  def visible_line_number; return 4; end
   
  #--------------------------------------------------------------------------
  # alignment
  #--------------------------------------------------------------------------
  def alignment; return 1; end
  
  #--------------------------------------------------------------------------
  # ok_enabled?
  #--------------------------------------------------------------------------
  def ok_enabled?
    return handle?(current_symbol)
  end
  
  #--------------------------------------------------------------------------
  # process_ok
  #--------------------------------------------------------------------------
  def process_ok
    $game_temp.guardian_pairing_menu_command = self.index
    super
  end
  
  #--------------------------------------------------------------------------
  # make_command_list
  #--------------------------------------------------------------------------
  def make_command_list
    for command in YSE::GUARDIAN_PAIRING::COMMANDS
      enable = command[0] == :pair ? $game_party.guardians.size > 0 : $game_party.target_actor.is_pair?
      add_command(command[1], command[0], enable)
    end
  end
  
end # Window_GuardianPairingMenuCommand

#==============================================================================
# ■ Window_MenuGuardianPair
#==============================================================================

class Window_MenuGuardianPair < Window_MenuGuardian
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width
  end
  
  #--------------------------------------------------------------------------
  # col_max
  #--------------------------------------------------------------------------
  def col_max
    2
  end
  
  #--------------------------------------------------------------------------
  # unpair=
  #--------------------------------------------------------------------------
  def unpair=(flag)
    @unpair = flag
    refresh
  end
  
  #--------------------------------------------------------------------------
  # enable?
  #--------------------------------------------------------------------------
  def enable?(actor)
    @unpair ? actor.is_pair? : !actor.is_pair?
  end
  
  #--------------------------------------------------------------------------
  # current_item_enabled?
  #--------------------------------------------------------------------------
  def current_item_enabled?
    enable?($game_party.guardians[index])
  end
  
  #--------------------------------------------------------------------------
  # draw_guardian_status
  #--------------------------------------------------------------------------
  def draw_guardian_status(actor, dx, dy, dw)
    change_color(normal_color)
    draw_actor_guardian(actor, dx, dy, dw)
  end
  
end # Window_MenuGuardianPair

#==============================================================================
# ■ Window_PairingStatus
#==============================================================================

class Window_PairingStatus < Window_SkillStatus
  
  #--------------------------------------------------------------------------
  # draw_actor_simple_status
  #--------------------------------------------------------------------------
  def draw_actor_simple_status(actor, dx, dy)
    draw_actor_name(actor, dx, dy)
    draw_actor_level(actor, dx, dy + line_height * 1)
    dw = contents.width - dx - 124
    draw_actor_guardian(actor, dx + 120, dy, dw)
    draw_actor_hp(actor, dx + 120, dy + line_height * 1, dw)
    draw_actor_mp(actor, dx + 120, dy + line_height * 2, dw)
  end
  
end # Window_PairingStatus

#==============================================================================
# ■ Scene_GuardianPairing
#==============================================================================

class Scene_GuardianPairing < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # start
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_command_window
    create_status_window
    create_guardian_window
  end
  
  #--------------------------------------------------------------------------
  # create_command_window
  #--------------------------------------------------------------------------
  def create_command_window
    wy = @help_window.height
    @command_window = Window_GuardianPairingMenuCommand.new(0, wy)
    @command_window.viewport = @viewport
    @command_window.set_handler(:cancel,   method(:return_scene))
    @command_window.set_handler(:pair,   method(:command_pair))
    @command_window.set_handler(:unpair,   method(:command_unpair))
    if $game_temp.guardian_pairing_menu_command
      @command_window.index = $game_temp.guardian_pairing_menu_command
      $game_temp.guardian_pairing_menu_command = nil
    end
  end
  
  #--------------------------------------------------------------------------
  # create_status_window
  #--------------------------------------------------------------------------
  def create_status_window
    wy = @help_window.height
    @status_window = Window_PairingStatus.new(@command_window.width, wy)
    @status_window.viewport = @viewport
    @status_window.actor = $game_party.target_actor
  end
  
  #--------------------------------------------------------------------------
  # create_guardian_window
  #--------------------------------------------------------------------------
  def create_guardian_window
    wx = $imported["YSE-GuardianBoostStats"] ? 232 : 0
    wy = @command_window.height + @command_window.y
    @guardian_window = Window_MenuGuardianPair.new(wx, wy)
    @guardian_window.viewport = @viewport
    @guardian_window.help_window = @help_window
    @guardian_window.update_help
  end
  
  #--------------------------------------------------------------------------
  # command_actor
  #--------------------------------------------------------------------------
  def command_unpair
    process_unpair
  end
  
  #--------------------------------------------------------------------------
  # command_pair
  #--------------------------------------------------------------------------
  def command_pair
    @guardian_window.activate
    @guardian_window.select_last
    @guardian_window.set_handler(:ok,     method(:on_guardian_ok))
    @guardian_window.set_handler(:cancel, method(:on_guardian_cancel))
  end
  
  #--------------------------------------------------------------------------
  # on_guardian_ok
  #--------------------------------------------------------------------------
  def on_guardian_ok
    case @command_window.current_symbol
    when :pair
      if not $game_party.menu_actor.is_pair?
        process_pair
      else
        Sound.play_buzzer
      end
    when :unpair
      if $game_party.target_actor.is_pair?
        process_unpair
      else
        Sound.play_buzzer
      end
    end
    @guardian_window.unpair = false
  end
  
  #--------------------------------------------------------------------------
  # on_guardian_cancel
  #--------------------------------------------------------------------------
  def on_guardian_cancel
    @guardian_window.unselect
    @guardian_window.unpair = false
    @command_window.activate
  end
  
  #--------------------------------------------------------------------------
  # process_pair
  #--------------------------------------------------------------------------
  def process_pair
    $game_party.target_actor.pair($game_party.menu_actor)
    @command_window.refresh
    @guardian_window.activate
    @guardian_window.select_last
    @status_window.refresh
  end
  
  #--------------------------------------------------------------------------
  # process_unpair
  #--------------------------------------------------------------------------
  def process_unpair
    $game_party.target_actor.clear_guardians
    @command_window.refresh
    @command_window.activate
    @guardian_window.refresh
    @status_window.refresh
  end
  
end # Scene_GuardianPairing

#==============================================================================
#
# ▼ End of File
#
#==============================================================================
#==============================================================================
#
# ¥ Yami Engine Ace - Guardian Series
# -- Script: Guardian Boost Stats
# -- Last Updated: 2012.03.15
# -- Level: Easy
# -- Requires: YSE - Guardian Pairing
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YSE-GuardianBoostStats"] = true

#==============================================================================
# ¥ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.03.15 - Started and Finished Script.
#
#==============================================================================
# ¥ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script provides a new feature for YSE - Guardian Pairing, which boost
# stats for an actor by Guardian's attributes.
#
#==============================================================================
# ¥ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
#
#==============================================================================
# ¥ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YSE
  module GUARDIAN_PAIRING
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Attributes Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # This section adjusts the stats plus and traits plus of actor who paired
    # with a guardian.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ATTRIBUTES = { # Start.
      :stats      =>  true, # Stats injection
      :traits     =>  true, # Traits injection
      :skills     =>  true, # Skills injection
    } # Done.
    PARAMVAR = 0.2
  end
end  

#==============================================================================
# ¥ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

#==============================================================================
# ¡ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  
  #--------------------------------------------------------------------------
  # alias method: param_plus
  #--------------------------------------------------------------------------
  alias yse_param_plus_gbs param_plus
  def param_plus(param_id)
    return yse_param_plus_gbs(param_id) unless YSE::GUARDIAN_PAIRING::ATTRIBUTES[:stats]
    return yse_param_plus_gbs(param_id) if guardian?
    guardians.compact.inject(yse_param_plus_gbs(param_id)) {|r, item| r += item.param(param_id)*YSE::GUARDIAN_PAIRING::PARAMVAR }
  end
  
  #--------------------------------------------------------------------------
  # alias method: feature_objects
  #--------------------------------------------------------------------------
  alias yse_feature_objects_gbs feature_objects
  def feature_objects
    return yse_feature_objects_gbs unless YSE::GUARDIAN_PAIRING::ATTRIBUTES[:traits]
    return yse_feature_objects_gbs if guardian?
    result = yse_feature_objects_gbs
    guardians.each { |g| result += g.feature_objects }
    result
  end
  
  #--------------------------------------------------------------------------
  # alias method: skills
  #--------------------------------------------------------------------------
  alias yse_skills_gbs skills
  def skills
    return yse_skills_gbs unless YSE::GUARDIAN_PAIRING::ATTRIBUTES[:skills]
    return yse_skills_gbs if guardian?
    result = yse_skills_gbs
    guardians.each { |g| result = result | g.skills }
    result
  end
  
end # Game_Actor

#==============================================================================
# ¡ Window_MenuGuardianPair
#==============================================================================

class Window_MenuGuardianPair < Window_MenuGuardian
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width - 232
  end
  
  #--------------------------------------------------------------------------
  # col_max
  #--------------------------------------------------------------------------
  def col_max
    1
  end
  
  #--------------------------------------------------------------------------
  # actor_status=
  #--------------------------------------------------------------------------
  def actor_status=(actor_status)
    @actor_status = actor_status
  end
  
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    update_actor_status
  end
  
  #--------------------------------------------------------------------------
  # update_actor_status
  #--------------------------------------------------------------------------
  def update_actor_status
    return unless @actor_status
    return unless $game_party.guardians[index]
    return @actor_status.clear_temp if index < 0
    item = $game_party.guardians[index]
    @actor_status.set_temp_actor(item)
  end
  
end # Window_MenuGuardianPair

#==============================================================================
# ¡ Window_GuardianPairStatus
#==============================================================================

class Window_GuardianPairStatus < Window_Base
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y, window_width, Graphics.height - y)
    @actor = $game_party.target_actor
    temp_actor = Marshal.load(Marshal.dump(@actor))
    @temp_actor = temp_actor
    refresh
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width
    232
  end

  #--------------------------------------------------------------------------
  # visible_line_number
  #--------------------------------------------------------------------------
  def visible_line_number
    return 8
  end
  
  #--------------------------------------------------------------------------
  # actor
  #--------------------------------------------------------------------------
  def actor
    @actor
  end
  
  #--------------------------------------------------------------------------
  # set_temp_actor
  #--------------------------------------------------------------------------
  def set_temp_actor(guardian)
    return unless @temp_actor
    return if @temp_actor.guardians.include?(guardian)
    @temp_actor.force_pair(guardian)
    refresh
  end
  
  #--------------------------------------------------------------------------
  # clear_temp
  #--------------------------------------------------------------------------
  def clear_temp
    temp_actor = Marshal.load(Marshal.dump(@actor))
    @temp_actor = temp_actor
    refresh
  end
  
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    8.times { |i| draw_actor_param(i, 0, line_height * i, contents_width) }
  end
  
  #--------------------------------------------------------------------------
  # draw_actor_param
  #--------------------------------------------------------------------------
  def draw_actor_param(param_id, dx, dy, dw)
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)
    contents.fill_rect(rect, colour)
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::param(param_id))
    change_color(normal_color)
    draw_text(dx+4, dy, dw-8, line_height, changed_param(param_id), 2)
  end
  
  #--------------------------------------------------------------------------
  # changed_param
  #--------------------------------------------------------------------------
  def changed_param(param_id)
    result = ""
    result += @actor.param(param_id).to_s
    return result if @temp_actor.nil?
    return result if @temp_actor.guardians == @actor.guardians
    result += "¨ " + @temp_actor.param(param_id).to_s
    return result
  end

end # Window_GuardianPairStatus

#==============================================================================
# ¡ Scene_GuardianPairing
#==============================================================================

class Scene_GuardianPairing < Scene_MenuBase
  
  #--------------------------------------------------------------------------
  # alias method: start
  #--------------------------------------------------------------------------
  alias yse_start_gbs start
  def start
    yse_start_gbs
    create_actor_status_window
  end

  #--------------------------------------------------------------------------
  # new method: create_actor_status_window
  #--------------------------------------------------------------------------
  def create_actor_status_window
    wx = 0
    wy = @command_window.height + @command_window.y
    @actor_status_window = Window_GuardianPairStatus.new(wx, wy)
    @actor_status_window.viewport = @viewport
    @guardian_window.actor_status = @actor_status_window
  end
  
  #--------------------------------------------------------------------------
  # alias method: process_pair
  #--------------------------------------------------------------------------
  alias yse_process_pair_gbs process_pair
  def process_pair
    yse_process_pair_gbs
    @actor_status_window.refresh
  end
  
  #--------------------------------------------------------------------------
  # alias method: process_unpair
  #--------------------------------------------------------------------------
  alias yse_process_unpair_gbs process_unpair
  def process_unpair
    yse_process_unpair_gbs
    @actor_status_window.refresh
  end
  
end # Scene_GuardianPairing

#==============================================================================
#
# ¥ End of File
#
#==============================================================================[/pre]
以上是主模块!角色如果要设置为守护精灵,备注里写<guardian>
然后就可以进行神降了

点评

请问那个备注在哪里啊?  发表于 2012-3-20 17:52

评分

参与人数 1星屑 +40 收起 理由
无双sxa + 40 感谢分享。

查看全部评分

梦石
0
星屑
64
在线时间
294 小时
注册时间
2011-7-31
回帖
647
发表于 2012-3-24 15:35:56 | 显示全部楼层
什么意思= =不明白

点评

就是召唤精灵或是神兽伙伴一起战斗吧。  发表于 2012-3-24 16:01
如果繁华被摧毁,就让我好好地睡.....
回复

使用道具 举报

梦石
0
星屑
45
在线时间
138 小时
注册时间
2011-11-15
回帖
210
发表于 2012-3-26 20:15:53 | 显示全部楼层
太狠了吧,这么长,看着就崩
具体能做点什么尼,英文看不懂
回复

使用道具 举报

梦石
0
星屑
77
在线时间
12 小时
注册时间
2012-10-19
回帖
11
发表于 2013-3-16 11:33:25 | 显示全部楼层
不明白,是召唤伙伴吗???
不用这么费劲吧…………

点评

你挖坟了。  发表于 2013-3-17 09:29
回复

使用道具 举报

彭格列I世

梦石
0
星屑
168
在线时间
566 小时
注册时间
2012-8-17
回帖
1539
发表于 2013-4-3 12:45:50 | 显示全部楼层
完全用事件就可以了吧?

赏金猎人 -- Bounty Hunter 预告贴(点击图片或者这里进入)
交流群组:321810846

小刀的论坛!!点击这里!
小刀的论坛!!点击这里!
小刀的论坛!!点击这里!
小刀的论坛!!点击这里!
小刀的论坛!!点击这里!
小刀的论坛!!点击这里!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部