SHARE
TWEET

Ao no Kiseki CBS 3

kirinelf Apr 2nd, 2012 1,258 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. # ■ Ao no Kiseki Custom Battle System 13_2 Display Configuration
  3. #   @version 0.22 12/01/27
  4. #   @author Saba Kan
  5. #   @translator kirinelf
  6. #------------------------------------------------------------------------------
  7. #  This is where you can edit the various display options.
  8. #==============================================================================
  9. module Saba
  10.   module Kiseki
  11.     # The number of pixels from the left border to place the order bar.
  12.     MARGIN_LEFT = 10
  13.    
  14.     # The number of pixels from the top border to place the order bar.
  15.     MARGIN_TOP = 10
  16.    
  17.     # Margins between the current active unit and the next unit in the order bar.
  18.     MARGIN_CURRENT_BOTTOM = 10
  19.    
  20.     # Margins between units in the order bar.
  21.     UNIT_INTERVAL = 32
  22.    
  23.     # Number of pixels to the right units are placed during turn order previews.
  24.     INSERT_DISTANCE = 32
  25.    
  26.     # What to display on the order bar for delay during actor's turn.
  27.     # 0: Shows the text: DELAY
  28.     # 1: Clock Icon
  29.     DELAY_DISPLAY_TYPE = 0
  30.    
  31.     # Height of the order bar in pixels.
  32.     ORDER_BAR_HEIGHT = 460
  33.    
  34.     # Cancel Messages
  35.     CANCEL_MSG         = "%s's %s has been interrupted!"
  36.     FAIL_CANCEL_MSG    = "%s's %s hasn't been interrupted."
  37.     ANTI_CANCEL_MSG    = "%s's %s can't be interrupted."
  38.    
  39.     # Delay Messages
  40.     DELAY_ENEMY_MSG    =  "%s has been delayed %s turns!"
  41.     DELAY_ACTOR_MSG    =  "%s has been delayed %s turns!"
  42.     HASTE_ENEMY_MSG    =  "%s has sped up %s turns!"
  43.     HASTE_ACTOR_MSG    =  "%s has sped up %s turns!"
  44.     ANTI_DELAY_MSG     =  "%s can't be delayed."
  45.     FAIL_DELAY_MSG     =  "%s wasn't delayed."
  46.   end
  47. end
  48.  
  49. #=========================================================================
  50. # Do not edit anything under this line unless you know what you're doing!
  51. #=========================================================================
  52.  
  53. #==============================================================================
  54. # ■ Spriteset_BattleUnit
  55. #------------------------------------------------------------------------------
  56. #  画面左の待ち時間バー上に表示するユニットです
  57. #==============================================================================
  58.  
  59. class Spriteset_BattleUnit
  60.   include Saba::Kiseki
  61.  
  62.   TARGET_ENEMY_COLOR = Color.new(255, 0, 0, 255)
  63.   TARGET_ACTOR_COLOR = Color.new(0, 0, 255, 255)
  64.   #--------------------------------------------------------------------------
  65.   # ○ オブジェクト初期化
  66.   #--------------------------------------------------------------------------
  67.   def initialize(viewport, unit)
  68.     super
  69.     @viewport = viewport
  70.     @unit = unit
  71.     @battler = unit.battler
  72.     @forecast = false
  73.    
  74.     @layers = []
  75.    
  76.     create_bg_layer
  77.     create_char_layer
  78.     create_char_select_layer
  79.     create_marker_layer
  80.     create_targeted_layer
  81.     create_arrow_layer
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ○ 背景レイヤの作成
  85.   #--------------------------------------------------------------------------
  86.   def create_bg_layer
  87.     @bg_layer = Sprite_Base.new(@viewport)
  88.     @bg_layer.bitmap = Bitmap.new(64, 64)
  89.     if @battler.actor?
  90.       border = Cache.system("UnitBorder")
  91.     else
  92.       border = Cache.system("UnitBorder2")
  93.     end
  94.     @bg_layer.bitmap.blt(0, 0, border, border.rect)
  95.     @bg_layer.z = 1
  96.    
  97.     @layers.push(@bg_layer)
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ○ キャラレイヤの作成
  101.   #--------------------------------------------------------------------------
  102.   def create_char_layer
  103.     @char_layer = Sprite_Base.new(@viewport)
  104.     @char_layer.bitmap = Bitmap.new(32, 32)
  105.     @char_layer.z = 2
  106.     init_graphic
  107.     draw_character(@char_layer, @graphic_name, @graphic_index)
  108.     @layers.push(@char_layer)
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ○ キャラ選択レイヤの作成
  112.   #--------------------------------------------------------------------------
  113.   def create_char_select_layer
  114.     @char_select_layer = Sprite_Base.new(@viewport)
  115.     @char_select_layer.bitmap = Bitmap.new(32, 32)
  116.     @char_select_layer.z = 3
  117.     draw_character(@char_select_layer, @graphic_name, @graphic_index)
  118.     @char_select_layer.blend_type = 1
  119.     if @battler.actor?
  120.       @char_select_layer.color = TARGET_ACTOR_COLOR
  121.     else
  122.       @char_select_layer.color = TARGET_ENEMY_COLOR
  123.     end
  124.     @layers.push(@char_select_layer)
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ○ マーカーレイヤの作成
  128.   #--------------------------------------------------------------------------
  129.   def create_marker_layer
  130.     @marker_layer = Sprite_Base.new(@viewport)
  131.     @marker_layer.bitmap = Bitmap.new(32, 32)
  132.     @marker_layer.z = 4
  133.     marker = Cache.system("ActionMarker")
  134.     @marker_layer.bitmap.blt(0, 0, marker, marker.rect)
  135.     @marker_layer.visible = false
  136.     @layers.push(@marker_layer)
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ○ 駆動の対象レイヤの作成
  140.   #--------------------------------------------------------------------------
  141.   def create_targeted_layer
  142.     @targeted_layer = Sprite_Base.new(@viewport)
  143.     @targeted_layer.bitmap = Bitmap.new(32, 32)
  144.     @targeted_layer.z = 5
  145.     marker = Cache.system("Targeted")
  146.     @targeted_layer.bitmap.blt(0, 0, marker, marker.rect)
  147.     @targeted_layer.visible = false
  148.     @layers.push(@targeted_layer)
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # ○ 矢印レイヤの作成
  152.   #--------------------------------------------------------------------------
  153.   def create_arrow_layer
  154.     @arrow_layer = Sprite_Base.new(@viewport)
  155.     @arrow_layer.bitmap = Bitmap.new(64, 32)
  156.     @arrow_layer.z = 6
  157.     arrow = Cache.system("ForecastArrow")
  158.     @arrow_layer.bitmap.blt(0, 0, arrow, arrow.rect)
  159.     @layers.push(@arrow_layer)
  160.    
  161.     @arrow_index = 12
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ○ 解放
  165.   #--------------------------------------------------------------------------
  166.   def dispose
  167.     @layers.each do |layer|
  168.       layer.bitmap.dispose
  169.       layer.dispose
  170.     end
  171.  
  172.     @forecast_sprite.dispose if @forecast_sprite
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ○ フレーム更新
  176.   #--------------------------------------------------------------------------
  177.   def update
  178.     x = @unit.x + MARGIN_LEFT
  179.     y = @unit.y + MARGIN_TOP
  180.    
  181.     @layers.each do |layer|
  182.       layer.x = x
  183.       layer.y = y
  184.       layer.update
  185.     end
  186.  
  187.     @arrow_layer.x += @arrow_index
  188.     @arrow_layer.visible = @unit.forecast
  189.     @arrow_index -= 0.25
  190.     @arrow_index = 12 if @arrow_index == 0
  191.  
  192.     @char_select_layer.visible = @unit.selected
  193.     @marker_layer.visible = @unit.operate
  194.     @targeted_layer.visible = @unit.targeted
  195.  
  196.     update_forecast
  197.     update_opacity
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # ○ 使用するグラフィックを決定します。
  201.   #--------------------------------------------------------------------------
  202.   def init_graphic
  203.     if @battler.actor?
  204.       @graphic_name = @battler.character_name
  205.       @graphic_index = @battler.character_index
  206.     else
  207.       @graphic_name = enemy_graphic_name
  208.       @graphic_index = enemy_graphic_index
  209.     end
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ○ 行動予測を更新
  213.   #--------------------------------------------------------------------------
  214.   def update_forecast
  215.     if @forecast_sprite
  216.       @forecast_sprite.update
  217.       @forecast_sprite.visible = BattleManager.phase == :input
  218.     end
  219.     return if @forecast == @unit.forecast
  220.    
  221.     if @unit.forecast
  222.       @forecast_sprite = Sprite_Forecast.new(@viewport, @unit)
  223.     else
  224.       @forecast_sprite.dispose
  225.       @forecast_sprite = nil
  226.     end
  227.     @forecast = @unit.forecast
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ○ キャラクターグラフィックを描画します。
  231.   #--------------------------------------------------------------------------
  232.   def draw_character(layer, character_name, character_index)
  233.     bitmap = Cache.character(character_name)
  234.     sign = character_name[/^[\!\$]./]
  235.     if sign && sign.include?('$')
  236.       cw = bitmap.width / 3
  237.       ch = bitmap.height / 4
  238.     else
  239.       cw = bitmap.width / 12
  240.       ch = bitmap.height / 8
  241.     end
  242.     n = character_index
  243.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  244.     layer.bitmap.blt(0, 0, bitmap, src_rect)
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ○ 行動待ちマーカーを描画します。
  248.   #--------------------------------------------------------------------------
  249.   def draw_action_marker
  250.     bitmap = Cache.system("ActionMarker")
  251.     @char_layer.bitmap.blt(0, 0, bitmap, bitmap.rect)
  252.   end
  253.   #--------------------------------------------------------------------------
  254.   # ○ 透明度を更新します。
  255.   #--------------------------------------------------------------------------
  256.   def update_opacity
  257.     opacity  = 255 - @unit.x * 8
  258.     @arrow_layer.opacity = opacity
  259.     @bg_layer.opacity    = opacity
  260.     @char_layer.opacity  = opacity
  261.     @forecast_sprite.opacity    = opacity if @forecast_sprite
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # ○ バトラーが敵エネミーの場合、使用するグラフィック名を初期化します。
  265.   #--------------------------------------------------------------------------
  266.   def enemy_graphic_name
  267.     marker = Saba::Kiseki::GRAPHIC_MARKER
  268.     graphic = get_ex_value_with_index(@battler.enemy, marker, 0)
  269.     if graphic == nil
  270.       return Saba::Kiseki::DEFAULT_MONSTER_GRAPHIC_NAME
  271.     else
  272.       return graphic
  273.     end
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ○ バトラーが敵エネミーの場合、使用するグラフィック内のインデックスを初期化します。
  277.   #--------------------------------------------------------------------------
  278.   def enemy_graphic_index
  279.     marker = Saba::Kiseki::GRAPHIC_MARKER
  280.     index = get_ex_value_with_index(@battler.enemy, marker, 1)
  281.     if index == nil
  282.       return Saba::Kiseki::DEFAULT_MONSTER_GRAPHIC_INDEX
  283.     else
  284.       return index.to_i
  285.     end
  286.   end
  287.   def get_ex_value_with_index(item, name, index)
  288.     item.note.split(/[\r\n]+/).each do |line|
  289.     elements = line.split(/\s+/)
  290.       next if elements.size <= index + 1
  291.       next unless elements[0] == name
  292.       return elements[index + 1]
  293.     end
  294.     return nil
  295.   end
  296. end
  297.  
  298.  
  299. #==============================================================================
  300. # ■ Sprite_Forecast
  301. #------------------------------------------------------------------------------
  302. #  待ち時間表示です。Delay XX というあれ
  303. #==============================================================================
  304.  
  305. class Sprite_Forecast < Sprite_Base
  306.   include Saba::Kiseki
  307.   #--------------------------------------------------------------------------
  308.   # ● オブジェクト初期化
  309.   #--------------------------------------------------------------------------
  310.   def initialize(viewport, unit)
  311.     super(viewport)
  312.     @unit = unit
  313.     self.bitmap = Bitmap.new(120, 50)
  314.     @anime_index = 0
  315.     @wait_count = 0
  316.     refresh
  317.     update
  318.     self.z = 5
  319.   end
  320.   def refresh
  321.     self.bitmap.clear
  322.    
  323.     if DELAY_DISPLAY_TYPE == 0
  324.       delay = Cache.system("Delay")
  325.       self.bitmap.font.size = 20
  326.       self.bitmap.blt(0, 0, delay, delay.rect)
  327.       self.bitmap.draw_text(41, 6, 58, 24, @unit.delay_time.to_s, 1)
  328.     else
  329.       delay = Cache.system("Delay2")
  330.       self.bitmap.font.size = 20
  331.       self.bitmap.blt(0, 0, delay, delay.rect)
  332.       clock = Cache.system("icon_clock")
  333.       x = @anime_index % 4 * clock.width / 4
  334.       y = @anime_index / 4 * clock.height / 2
  335.      
  336.       rect = Rect.new(x, y, clock.width / 4, clock.height / 2)
  337.       self.bitmap.blt(3, 3, clock, rect)
  338.       self.bitmap.draw_text(14, 5, 58, 22, @unit.delay_time.to_s, 1)
  339.     end
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # ● 解放
  343.   #--------------------------------------------------------------------------
  344.   def dispose
  345.     self.bitmap.dispose
  346.     super
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # ● フレーム更新
  350.   #--------------------------------------------------------------------------
  351.   def update
  352.     super
  353.     self.x = @unit.x + Saba::Kiseki::MARGIN_LEFT + 45
  354.     self.y = @unit.y + Saba::Kiseki::MARGIN_TOP
  355.     next_anime
  356.   end
  357.   def next_anime
  358.     @wait_count += 1
  359.     if @wait_count > 6
  360.       @anime_index += 1
  361.       @anime_index = 0 if @anime_index == 8
  362.       @wait_count = 0
  363.       refresh
  364.     end
  365.   end
  366. end
  367.  
  368.  
  369.  
  370. #==============================================================================
  371. # ■ Spriteset_Kiseki
  372. #------------------------------------------------------------------------------
  373. #  待ち時間バーの背景や、先頭キャラの枠など
  374. #==============================================================================
  375.  
  376. class Spriteset_Kiseki
  377.   include Saba::Kiseki
  378.   #--------------------------------------------------------------------------
  379.   # ○ オブジェクト初期化
  380.   #--------------------------------------------------------------------------
  381.   def initialize(viewport)
  382.     super
  383.     @bg_layer = Sprite_Base.new(viewport)
  384.     @bg_layer.bitmap = Cache.system("OrderLine")
  385.     @bg_layer.z = 0
  386.     @bg_layer.x = 10
  387.     @bg_layer.src_rect.height = ORDER_BAR_HEIGHT
  388.    
  389.     @window_layer = Sprite_Base.new(viewport)
  390.     @window_layer.bitmap = Cache.system("ActiveWindow")
  391.     @window_layer.z = 7
  392.     @window_layer.x = 2
  393.     @window_layer.y = 3
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # ○ 解放
  397.   #--------------------------------------------------------------------------
  398.   def dispose
  399.     @bg_layer.dispose
  400.     @window_layer.dispose
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # ○ フレーム更新
  404.   #--------------------------------------------------------------------------
  405.   def update
  406.     @bg_layer.update
  407.     @window_layer.update
  408.   end
  409. end
  410.  
  411.  
  412.  
  413. class Window_BattleLog
  414.   include Saba::Kiseki
  415.     #--------------------------------------------------------------------------
  416.   # ● 失敗の表示
  417.   #--------------------------------------------------------------------------
  418.   alias saba_kiseki_battle_display_failure display_failure
  419.   def display_failure(target, item)
  420.     if target.result.hit? && !target.result.success
  421.       saba_kiseki_battle_display_failure(target, item)
  422.     end
  423.     display_cancel(target, item)
  424.     display_delay(target, item)
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # ○ アイテム準備の表示
  428.   #--------------------------------------------------------------------------
  429.   def display_prepare_item(target, item)
  430.     text = sprintf(item.prepare_msg, target.name, item.name)
  431.     add_text(text)
  432.     wait
  433.     wait
  434.     wait
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # ○ キャンセルの表示
  438.   #--------------------------------------------------------------------------
  439.   def display_cancel(target, item)
  440.     unit = OrderManager.find_unit(target)
  441.     return unless unit
  442.     usable_item = unit.usable_item
  443.     return if usable_item == nil
  444.     if target.result.cancel
  445.       return unless CANCEL_MSG
  446.       text = sprintf(CANCEL_MSG, target.name, usable_item.name)
  447.       add_text(text)
  448.       wait
  449.     elsif target.result.fail_cancel
  450.       return unless FAIL_CANCEL_MSG
  451.       text = sprintf(FAIL_CANCEL_MSG, target.name, usable_item.name)
  452.       add_text(text)
  453.       wait
  454.     elsif target.result.anti_cancel
  455.       return unless ANTI_CANCEL_MSG
  456.       text = sprintf(ANTI_CANCEL_MSG, target.name, usable_item.name)
  457.       add_text(text)
  458.       wait
  459.     end
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ○ ディレイの表示
  463.   #--------------------------------------------------------------------------
  464.   def display_delay(target, item)
  465.     delay = target.result.delay_count
  466.     if delay > 0
  467.       if target.actor?
  468.         return unless DELAY_ACTOR_MSG
  469.         text = sprintf(DELAY_ACTOR_MSG, target.name, delay.to_s)
  470.       else
  471.         return unless DELAY_ENEMY_MSG
  472.         text = sprintf(DELAY_ENEMY_MSG, target.name, delay.to_s)
  473.       end
  474.       add_text(text)
  475.       wait
  476.     elsif delay < 0
  477.       if target.actor?
  478.         return unless HASTE_ACTOR_MSG
  479.         text = sprintf(HASTE_ACTOR_MSG, target.name, delay.abs.to_s)
  480.       else
  481.         return unless HASTE_ENEMY_MSG
  482.         text = sprintf(HASTE_ENEMY_MSG, target.name, delay.abs.to_s)
  483.       end
  484.       add_text(text)
  485.       wait
  486.     elsif target.result.fail_delay
  487.       return unless FAIL_DELAY_MSG
  488.       text = sprintf(FAIL_DELAY_MSG, target.name)
  489.       add_text(text)
  490.       wait
  491.     elsif target.result.anti_delay
  492.       return unless ANTI_DELAY_MSG
  493.       text = sprintf(ANTI_DELAY_MSG, target.name)
  494.       add_text(text)
  495.       wait
  496.     end
  497.   end
  498. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top