TheoAllen

YEA Core

Mar 28th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 42.71 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Ace Core Engine v1.09
  4. # -- Last Updated: 2012.02.19
  5. # -- Level: Easy, Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-CoreEngine"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.02.19 - Bug Fixed: Parallax updating works properly with looping maps.
  17. # 2012.02.10 - Bug Fixed: Forced actions no longer cancel out other actions
  18. #              that have been queued up for later.
  19. # 2012.01.08 - Font resets no longer reset bold and italic to off, but instead
  20. #              to whatever default you've set.
  21. # 2011.12.26 - New Bugfix: When using substitute, allies will no longer take
  22. #              place of low HP allies for friendly skills.
  23. # 2011.12.20 - New Bugfix: Force Action no longer cancels out an actor's queue.
  24. #              Credits to Yami for finding and making the fix for!
  25. #              Switch added for those who want removed forced action battlers.
  26. # 2011.12.15 - Updated for better menu gauge appearance.
  27. # 2011.12.10 - Bug Fixed: Right and bottom sides of the map would show
  28. #              the left and top sides of the map.
  29. #            - Bug Fixed: Viewport sizes didn't refresh from smaller maps.
  30. # 2011.12.07 - New Bugfix: Dual weapon normal attacks will now play both
  31. #              animations without one animation interrupting the other.
  32. # 2011.12.04 - Updated certain GUI extensions for increased screen size.
  33. #            - More efficient digit grouping method credits to TDS.
  34. # 2011.12.01 - Started Script and Finished.
  35. #
  36. #==============================================================================
  37. # ▼ Introduction
  38. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  39. # This is the core engine for Yanfly Engine Ace, made for RPG Maker VX Ace.
  40. # This script provides various changes made to the main engine including bug
  41. # fixes and GUI upgrades.
  42. #
  43. # -----------------------------------------------------------------------------
  44. # Bug Fix: Animation Overlay
  45. # -----------------------------------------------------------------------------
  46. # - It's the same bug from VX. When an all-screen animation is played against a
  47. # group of enemies, the animation bitmap is actually made multiple times, thus
  48. # causing a pretty extreme overlay when there are a lot of enemies on screen.
  49. # This fix will cause the animation to play only once.
  50. #
  51. # -----------------------------------------------------------------------------
  52. # Bug Fix: Animation Interruption
  53. # -----------------------------------------------------------------------------
  54. # - A new bug. When a character dual wields and attacks a single target, if an
  55. # animation lasts too long, it will interrupt and/or halt the next animation
  56. # from occurring. This script will cause the first animation to finish playing
  57. # and then continue forth.
  58. #
  59. # -----------------------------------------------------------------------------
  60. # Bug Fix: Battle Turn Order Fix
  61. # -----------------------------------------------------------------------------
  62. # - Same bug from VX. For those who use the default battle system, once a
  63. # turn's started, the action order for the turn becomes set and unchanged for
  64. # the remainder of that turn. Any changes to a battler's AGI will not be
  65. # altered at all even if the battler were to receive an AGI buff or debuff.
  66. # This fix will cause the speed to be updated properly upon each action.
  67. #
  68. # -----------------------------------------------------------------------------
  69. # Bug Fix: Forced Action Fix
  70. # -----------------------------------------------------------------------------
  71. # - A new bug. When a battler is forced to perform an action, the battler's
  72. # queued action is removed and the battler loses its place in battle. This
  73. # fix will resume queue after a forced action.
  74. #
  75. # -----------------------------------------------------------------------------
  76. # Bug Fix: Gauge Overlap Fix
  77. # -----------------------------------------------------------------------------
  78. # - Same bug from VX. When some values exceed certain amounts, gauges can
  79. # overextend past the width they were originally designed to fit in. This fix
  80. # will prevent any overextending from gauges.
  81. #
  82. # -----------------------------------------------------------------------------
  83. # Bug Fix: Held L and R Menu Scrolling
  84. # -----------------------------------------------------------------------------
  85. # - Before in VX, you can scroll through menus by holding down L and R buttons
  86. # (Q and W on the keyboard) to scroll through menus quickly. This fix will
  87. # re-enable the ability to scroll through menus in such a fashion. Disable it
  88. # in the module if you wish to.
  89. #
  90. # -----------------------------------------------------------------------------
  91. # Bug Fix: Substitute Healing
  92. # -----------------------------------------------------------------------------
  93. # If an actor has the substitute (cover) flag on them, they will attempt to
  94. # take the place of low HP allies when they're the target of attack. However,
  95. # this is also the case for friendly skills such as heal. This script will fix
  96. # it where if a battler targets an ally, no substitutes will take place.
  97. #
  98. # -----------------------------------------------------------------------------
  99. # New Feature: Screen Resolution Size
  100. # -----------------------------------------------------------------------------
  101. # - The screen can now be resized from 544x416 with ease and still support maps
  102. # that are smaller than 544x416. Maps smaller than 544x416 will be centered on
  103. # the screen without having sprites jumping all over the place.
  104. #
  105. # -----------------------------------------------------------------------------
  106. # New Feature: Adjust Animation Speed
  107. # -----------------------------------------------------------------------------
  108. # - RPG Maker VX Ace plays animations at a rate of 15 FPS by default. Speed up
  109. # the animations by changing a simple constant in the module.
  110. #
  111. # -----------------------------------------------------------------------------
  112. # New Feature: GUI Modifications
  113. # -----------------------------------------------------------------------------
  114. # - There are quite a lot of different modifications you can do to the GUI.
  115. # This includes placing outlines around your gauges, changing the colours of
  116. # each individual font aspect, and more. Also, you can change the default font
  117. # setting for your games here.
  118. #
  119. # -----------------------------------------------------------------------------
  120. # New Feature: Numeric Digit Grouping
  121. # -----------------------------------------------------------------------------
  122. # This will change various scenes to display numbers in groups where they are
  123. # separated by a comma every three digits. Thus, a number like 1234567 will
  124. # show up as 1,234,567. This allows for players to read numbers quicker.
  125. #
  126. # And that's all for the bug fixes and features!
  127. #
  128. #==============================================================================
  129. # ▼ Instructions
  130. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  131. # To install this script, open up your script editor and copy/paste this script
  132. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  133. #
  134. #==============================================================================
  135. # ▼ Compatibility
  136. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  137. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  138. # it will run with RPG Maker VX without adjusting.
  139. #
  140. #==============================================================================
  141.  
  142. module YEA
  143.   module CORE
  144.    
  145.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  146.     # - Screen Resolution Size -
  147.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  148.     # RPG Maker VX Ace has the option of having larger width and height for
  149.     # your games. Resizing the width and height will have these changes:
  150.     #
  151.     #              Default   Resized   Min Tiles Default   Min Tiles New
  152.     #    Width       544       640           17                 20
  153.     #    Height      416       480           13                 15
  154.     #
  155.     # * Note: Maximum width is 640 while maximum height is 480.
  156.     #         Minimum width is 110 while maximum height is 10.
  157.     #         These are limitations set by RPG Maker VX Ace's engine.
  158.     #
  159.     # By selecting resize, all of the default menus will have their windows
  160.     # adjusted, but scripts provided by non-Yanfly Engine sources may or may
  161.     # not adjust themselves properly.
  162.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  163.     RESIZE_WIDTH  = 544
  164.     RESIZE_HEIGHT = 416
  165.    
  166.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  167.     # - Adjust Animation Speed -
  168.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  169.     # By default, the animation speed played in battles operates at 15 FPS
  170.     # (frames per second). For those who would like to speed it up, change this
  171.     # constant to one of these values:
  172.     #   RATE   Speed
  173.     #     4      15 fps
  174.     #     3      20 fps
  175.     #     2      30 fps
  176.     #     1      60 fps
  177.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  178.     ANIMATION_RATE = 3
  179.    
  180.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  181.     # - Digit Grouping -
  182.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  183.     # Setting this to true will cause numbers to be grouped together when they
  184.     # are larger than a thousand. For example, 12345 will appear as 12,345.
  185.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  186.     GROUP_DIGITS = false
  187.    
  188.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  189.     # - Font Settings -
  190.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  191.     # Adjust the default font settings for your game here. The various settings
  192.     # will be explained below.
  193.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  194. #~     FONT_NAME = ["VL Gothic", "Verdana", "Arial", "Courier"]
  195.     FONT_NAME = ["Calibri"]
  196.     # This adjusts the fonts used for your game. If the font at the start of
  197.     # the array doesn't exist on the player's computer, it'll use the next one.
  198.     FONT_SIZE = 24       # Adjusts font size. Default: 24
  199.     FONT_BOLD = false   # Makes font bold. Default: false
  200.     FONT_ITALIC = false  # Makes font italic. Default: false
  201.     FONT_SHADOW = false  # Gives font a shadow. Default: false
  202.     FONT_OUTLINE = true  # Gives font an outline. Default: true
  203.     FONT_COLOUR = Color.new(255, 255, 255, 255)   # Default: 255, 255, 255, 255
  204.     FONT_OUTLINE_COLOUR = Color.new(0, 0, 0, 128) # Default:   0,   0,   0, 128
  205.    
  206.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  207.     # - Forced Action Settings -
  208.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  209.     # For those who would like to allow the game to remove a forced action
  210.     # battler from the queue list, use the switch below. If you don't want to
  211.     # use this option, set the switch ID to 0.
  212.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  213.     FORCED_ACTION_REMOVE_SWITCH = 0
  214.    
  215.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  216.     # - Gauge Appearance Settings -
  217.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  218.     # You can modify the way your gauges appear in the game. If you wish for
  219.     # them to have an outline, it's possible. You can also adjust the height
  220.     # of the gauges, too.
  221.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  222.     GAUGE_OUTLINE = true
  223.     GAUGE_HEIGHT = 12
  224.    
  225.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  226.     # - Held L and R Menu Scrolling -
  227.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  228.     # VX gave the ability to scroll through menus quickly through holding the
  229.     # L and R buttons (Q and W on the keyboard). VX Ace disabled it. Now, you
  230.     # can re-enable the ability to scroll faster by setting this constant to
  231.     # true. To disable it, set this constant to false.
  232.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  233.     QUICK_SCROLLING = true
  234.    
  235.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  236.     # - System Text Colours -
  237.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  238.     # Sometimes the system text colours are boring as just orange for HP, blue
  239.     # for MP, and green for TP. Change the values here. Each number corresponds
  240.     # to the colour index of the Window.png skin found in Graphics\System.
  241.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  242.     COLOURS ={
  243.     # :text       => ID
  244.       :normal     =>  0,   # Default:  0
  245.       :system     => 16,   # Default: 16
  246.       :crisis     => 17,   # Default: 17
  247.       :knockout   => 18,   # Default: 18
  248.       :gauge_back => 19,   # Default: 19
  249.       :hp_gauge1  => 28,   # Default: 20
  250.       :hp_gauge2  => 29,   # Default: 21
  251.       :mp_gauge1  => 22,   # Default: 22
  252.       :mp_gauge2  => 23,   # Default: 23
  253.       :mp_cost    => 23,   # Default: 23
  254.       :power_up   => 24,   # Default: 24
  255.       :power_down => 25,   # Default: 25
  256.       :tp_gauge1  => 10,   # Default: 28
  257.       :tp_gauge2  =>  2,   # Default: 29
  258.       :tp_cost    =>  2,   # Default: 29
  259.     } # Do not remove this.
  260.    
  261.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  262.     # - System Text Options -
  263.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  264.     # Here, you can adjust the transparency used for disabled items, the %
  265.     # needed for HP and MP to enter "crisis" mode.
  266.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  267.     TRANSPARENCY = 160   # Adjusts transparency of disabled items. Default: 160
  268.     HP_CRISIS = 0.25     # When HP is considered critical. Default: 0.25
  269.     MP_CRISIS = 0.25     # When MP is considered critical. Default: 0.25
  270.     ITEM_AMOUNT = "×%s"  # The prefix used for item amounts.
  271.    
  272.   end # CORE
  273. end # YEA
  274.  
  275. #==============================================================================
  276. # ▼ Editting anything past this point may potentially result in causing
  277. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  278. # halitosis so edit at your own risk.
  279. #==============================================================================
  280.  
  281. Graphics.resize_screen(YEA::CORE::RESIZE_WIDTH, YEA::CORE::RESIZE_HEIGHT)
  282. Font.default_name = YEA::CORE::FONT_NAME
  283. Font.default_size = YEA::CORE::FONT_SIZE
  284. Font.default_bold = YEA::CORE::FONT_BOLD
  285. Font.default_italic = YEA::CORE::FONT_ITALIC
  286. Font.default_shadow = YEA::CORE::FONT_SHADOW
  287. Font.default_outline = YEA::CORE::FONT_OUTLINE
  288. Font.default_color = YEA::CORE::FONT_COLOUR
  289. Font.default_out_color = YEA::CORE::FONT_OUTLINE_COLOUR
  290.  
  291. #==============================================================================
  292. # ■ Numeric
  293. #==============================================================================
  294.  
  295. class Numeric  
  296.  
  297.   #--------------------------------------------------------------------------
  298.   # new method: group_digits
  299.   #--------------------------------------------------------------------------
  300.   def group
  301.     return self.to_s unless YEA::CORE::GROUP_DIGITS
  302.     self.to_s.gsub(/(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/,'\1,\2')
  303.   end
  304.  
  305. end # Numeric
  306.  
  307. #==============================================================================
  308. # ■ Switch
  309. #==============================================================================
  310.  
  311. module Switch
  312.  
  313.   #--------------------------------------------------------------------------
  314.   # self.forced_action_remove
  315.   #--------------------------------------------------------------------------
  316.   def self.forced_action_remove
  317.     return false if YEA::CORE::FORCED_ACTION_REMOVE_SWITCH <= 0
  318.     return $game_switches[YEA::CORE::FORCED_ACTION_REMOVE_SWITCH]
  319.   end
  320.  
  321. end # Switch
  322.  
  323. #==============================================================================
  324. # ■ BattleManager
  325. #==============================================================================
  326.  
  327. module BattleManager
  328.  
  329.   #--------------------------------------------------------------------------
  330.   # overwrite method: turn_start
  331.   #--------------------------------------------------------------------------
  332.   def self.turn_start
  333.     @phase = :turn
  334.     clear_actor
  335.     $game_troop.increase_turn
  336.     @performed_battlers = []
  337.     make_action_orders
  338.   end
  339.  
  340.   #--------------------------------------------------------------------------
  341.   # overwrite method: next_subject
  342.   #--------------------------------------------------------------------------
  343.   def self.next_subject
  344.     @performed_battlers = [] if @performed_battlers.nil?
  345.     loop do
  346.       @action_battlers -= @performed_battlers
  347.       battler = @action_battlers.shift
  348.       return nil unless battler
  349.       next unless battler.index && battler.alive?
  350.       @performed_battlers.push(battler)
  351.       return battler
  352.     end
  353.   end
  354.  
  355.   #--------------------------------------------------------------------------
  356.   # overwrite method: force_action
  357.   #--------------------------------------------------------------------------
  358.   def self.force_action(battler)
  359.     @action_forced = [] if @action_forced == nil
  360.     @action_forced.push(battler)
  361.     return unless Switch.forced_action_remove
  362.     @action_battlers.delete(battler)
  363.   end
  364.  
  365.   #--------------------------------------------------------------------------
  366.   # overwrite method: action_forced?
  367.   #--------------------------------------------------------------------------
  368.   def self.action_forced?
  369.     @action_forced != nil
  370.   end
  371.  
  372.   #--------------------------------------------------------------------------
  373.   # overwrite method: action_forced_battler
  374.   #--------------------------------------------------------------------------
  375.   def self.action_forced_battler
  376.     @action_forced.shift
  377.   end
  378.  
  379.   #--------------------------------------------------------------------------
  380.   # overwrite method: clear_action_force
  381.   #--------------------------------------------------------------------------
  382.   def self.clear_action_force
  383.     @action_forced = nil if @action_forced.empty?
  384.   end
  385.  
  386. end # BattleManager
  387.  
  388. #==============================================================================
  389. # ■ Game_Battler
  390. #==============================================================================
  391.  
  392. class Game_Battler < Game_BattlerBase
  393.  
  394.   #--------------------------------------------------------------------------
  395.   # public instance variables
  396.   #--------------------------------------------------------------------------
  397.   attr_accessor :pseudo_ani_id
  398.  
  399.   #--------------------------------------------------------------------------
  400.   # alias method: clear_sprite_effects
  401.   #--------------------------------------------------------------------------
  402.   alias game_battler_clear_sprite_effects_ace clear_sprite_effects
  403.   def clear_sprite_effects
  404.     game_battler_clear_sprite_effects_ace
  405.     @pseudo_ani_id = 0
  406.   end
  407.  
  408.   #--------------------------------------------------------------------------
  409.   # alias method: force_action
  410.   #--------------------------------------------------------------------------
  411.   alias game_battler_force_action_ace force_action
  412.   def force_action(skill_id, target_index)
  413.     clone_current_actions
  414.     game_battler_force_action_ace(skill_id, target_index)
  415.   end
  416.  
  417.   #--------------------------------------------------------------------------
  418.   # new method: clone_current_actions
  419.   #--------------------------------------------------------------------------
  420.   def clone_current_actions
  421.     @cloned_actions = @actions.dup
  422.   end
  423.  
  424.   #--------------------------------------------------------------------------
  425.   # new method: restore_cloned_actions
  426.   #--------------------------------------------------------------------------
  427.   def restore_cloned_actions
  428.     return if @cloned_actions.nil?
  429.     @actions = @cloned_actions.dup
  430.     @cloned_actions = nil
  431.   end
  432.  
  433.   #--------------------------------------------------------------------------
  434.   # alias method: on_action_end
  435.   #--------------------------------------------------------------------------
  436.   alias game_battler_on_action_end_ace on_action_end
  437.   def on_action_end
  438.     game_battler_on_action_end_ace
  439.     restore_cloned_actions
  440.   end
  441.  
  442.   #--------------------------------------------------------------------------
  443.   # alias method: on_battle_end
  444.   #--------------------------------------------------------------------------
  445.   alias game_battler_on_battle_end_ace on_battle_end
  446.   def on_battle_end
  447.     game_battler_on_battle_end_ace
  448.     @cloned_actions = nil
  449.   end
  450.  
  451. end # Game_Battler
  452.  
  453. #==============================================================================
  454. # ■ Game_Troop
  455. #==============================================================================
  456.  
  457. class Game_Troop < Game_Unit
  458.  
  459.   #--------------------------------------------------------------------------
  460.   # overwrite method: setup
  461.   #--------------------------------------------------------------------------
  462.   def setup(troop_id)
  463.     clear
  464.     @troop_id = troop_id
  465.     @enemies = []
  466.     troop.members.each do |member|
  467.       next unless $data_enemies[member.enemy_id]
  468.       enemy = Game_Enemy.new(@enemies.size, member.enemy_id)
  469.       enemy.hide if member.hidden
  470.       enemy.screen_x = member.x + (Graphics.width - 544)/2
  471.       enemy.screen_y = member.y + (Graphics.height - 416)
  472.       @enemies.push(enemy)
  473.     end
  474.     init_screen_tone
  475.     make_unique_names
  476.   end
  477.  
  478. end # Game_Troop
  479.  
  480. #==============================================================================
  481. # ■ Game_Map
  482. #==============================================================================
  483.  
  484. class Game_Map
  485.  
  486.   #--------------------------------------------------------------------------
  487.   # overwrite method: scroll_down
  488.   #--------------------------------------------------------------------------
  489.   def scroll_down(distance)
  490.     if loop_vertical?
  491.       @display_y += distance
  492.       @display_y %= @map.height * 256
  493.       @parallax_y += distance if @parallax_loop_y
  494.     else
  495.       last_y = @display_y
  496.       dh = Graphics.height > height * 32 ? height : screen_tile_y
  497.       @display_y = [@display_y + distance, height - dh].min
  498.       @parallax_y += @display_y - last_y
  499.     end
  500.   end
  501.  
  502.   #--------------------------------------------------------------------------
  503.   # overwrite method: scroll_right
  504.   #--------------------------------------------------------------------------
  505.   def scroll_right(distance)
  506.     if loop_horizontal?
  507.       @display_x += distance
  508.       @display_x %= @map.width * 256
  509.       @parallax_x += distance if @parallax_loop_x
  510.     else
  511.       last_x = @display_x
  512.       dw = Graphics.width > width * 32 ? width : screen_tile_x
  513.       @display_x = [@display_x + distance, width - dw].min
  514.       @parallax_x += @display_x - last_x
  515.     end
  516.   end
  517.  
  518. end # Game_Map
  519.  
  520. #==============================================================================
  521. # ■ Game_Event
  522. #==============================================================================
  523.  
  524. class Game_Event < Game_Character
  525.  
  526.   #--------------------------------------------------------------------------
  527.   # overwrite method: near_the_screen?
  528.   #--------------------------------------------------------------------------
  529.   def near_the_screen?(dx = nil, dy = nil)
  530.     dx = [Graphics.width, $game_map.width * 256].min/32 - 5 if dx.nil?
  531.     dy = [Graphics.height, $game_map.height * 256].min/32 - 5 if dy.nil?
  532.     ax = $game_map.adjust_x(@real_x) - Graphics.width / 2 / 32
  533.     ay = $game_map.adjust_y(@real_y) - Graphics.height / 2 / 32
  534.     ax >= -dx && ax <= dx && ay >= -dy && ay <= dy
  535.   end
  536.  
  537. end # Game_Event
  538.  
  539. #==============================================================================
  540. # ■ Sprite_Base
  541. #==============================================================================
  542.  
  543. class Sprite_Base < Sprite
  544.  
  545.   #--------------------------------------------------------------------------
  546.   # overwrite method: set_animation_rate
  547.   #--------------------------------------------------------------------------
  548.   def set_animation_rate
  549.     @ani_rate = YEA::CORE::ANIMATION_RATE
  550.   end
  551.  
  552.   #--------------------------------------------------------------------------
  553.   # new method: start_pseudo_animation
  554.   #--------------------------------------------------------------------------
  555.   def start_pseudo_animation(animation, mirror = false)
  556.     dispose_animation
  557.     @animation = animation
  558.     return if @animation.nil?
  559.     @ani_mirror = mirror
  560.     set_animation_rate
  561.     @ani_duration = @animation.frame_max * @ani_rate + 1
  562.     @ani_sprites = []
  563.   end
  564.  
  565. end # Sprite_Base
  566.  
  567. #==============================================================================
  568. # ■ Sprite_Battler
  569. #==============================================================================
  570.  
  571. class Sprite_Battler < Sprite_Base
  572.  
  573.   #--------------------------------------------------------------------------
  574.   # alias method: setup_new_animation
  575.   #--------------------------------------------------------------------------
  576.   alias sprite_battler_setup_new_animation_ace setup_new_animation
  577.   def setup_new_animation
  578.     sprite_battler_setup_new_animation_ace
  579.     return if @battler.nil?
  580.     return if @battler.pseudo_ani_id.nil?
  581.     return if @battler.pseudo_ani_id <= 0
  582.     animation = $data_animations[@battler.pseudo_ani_id]
  583.     mirror = @battler.animation_mirror
  584.     start_pseudo_animation(animation, mirror)
  585.     @battler.pseudo_ani_id = 0
  586.   end
  587.  
  588. end # Sprite_Battler
  589.  
  590. #==============================================================================
  591. # ■ Spriteset_Map
  592. #==============================================================================
  593.  
  594. class Spriteset_Map
  595.  
  596.   #--------------------------------------------------------------------------
  597.   # overwrite method: create_viewports
  598.   #--------------------------------------------------------------------------
  599.   def create_viewports
  600.     if Graphics.width > $game_map.width * 32 && !$game_map.loop_horizontal?
  601.       dx = (Graphics.width - $game_map.width * 32) / 2
  602.     else
  603.       dx = 0
  604.     end
  605.     dw = [Graphics.width, $game_map.width * 32].min
  606.     dw = Graphics.width if $game_map.loop_horizontal?
  607.     if Graphics.height > $game_map.height * 32 && !$game_map.loop_vertical?
  608.       dy = (Graphics.height - $game_map.height * 32) / 2
  609.     else
  610.       dy = 0
  611.     end
  612.     dh = [Graphics.height, $game_map.height * 32].min
  613.     dh = Graphics.height if $game_map.loop_vertical?
  614.     @viewport1 = Viewport.new(dx, dy, dw, dh)
  615.     @viewport2 = Viewport.new(dx, dy, dw, dh)
  616.     @viewport3 = Viewport.new(dx, dy, dw, dh)
  617.     @viewport2.z = 50
  618.     @viewport3.z = 100
  619.   end
  620.  
  621.   #--------------------------------------------------------------------------
  622.   # new method: update_viewport_sizes
  623.   #--------------------------------------------------------------------------
  624.   def update_viewport_sizes
  625.     if Graphics.width > $game_map.width * 32 && !$game_map.loop_horizontal?
  626.       dx = (Graphics.width - $game_map.width * 32) / 2
  627.     else
  628.       dx = 0
  629.     end
  630.     dw = [Graphics.width, $game_map.width * 32].min
  631.     dw = Graphics.width if $game_map.loop_horizontal?
  632.     if Graphics.height > $game_map.height * 32 && !$game_map.loop_vertical?
  633.       dy = (Graphics.height - $game_map.height * 32) / 2
  634.     else
  635.       dy = 0
  636.     end
  637.     dh = [Graphics.height, $game_map.height * 32].min
  638.     dh = Graphics.height if $game_map.loop_vertical?
  639.     rect = Rect.new(dx, dy, dw, dh)
  640.     for viewport in [@viewport1, @viewport2, @viewport3]
  641.       viewport.rect = rect
  642.     end
  643.   end
  644.  
  645. end # Spriteset_Map
  646.  
  647. #==============================================================================
  648. # ■ Window_Base
  649. #==============================================================================
  650.  
  651. class Window_Base < Window
  652.  
  653.   #--------------------------------------------------------------------------
  654.   # overwrite method: reset_font_settings
  655.   #--------------------------------------------------------------------------
  656.   def reset_font_settings
  657.     change_color(normal_color)
  658.     contents.font.size = Font.default_size
  659.     contents.font.bold = Font.default_bold
  660.     contents.font.italic = Font.default_italic
  661.     contents.font.out_color = Font.default_out_color
  662.   end
  663.  
  664.   #--------------------------------------------------------------------------
  665.   # overwrite methods: color
  666.   #--------------------------------------------------------------------------
  667.   def normal_color;      text_color(YEA::CORE::COLOURS[:normal]);      end;
  668.   def system_color;      text_color(YEA::CORE::COLOURS[:system]);      end;
  669.   def crisis_color;      text_color(YEA::CORE::COLOURS[:crisis]);      end;
  670.   def knockout_color;    text_color(YEA::CORE::COLOURS[:knockout]);    end;
  671.   def gauge_back_color;  text_color(YEA::CORE::COLOURS[:gauge_back]);  end;
  672.   def hp_gauge_color1;   text_color(YEA::CORE::COLOURS[:hp_gauge1]);   end;
  673.   def hp_gauge_color2;   text_color(YEA::CORE::COLOURS[:hp_gauge2]);   end;
  674.   def mp_gauge_color1;   text_color(YEA::CORE::COLOURS[:mp_gauge1]);   end;
  675.   def mp_gauge_color2;   text_color(YEA::CORE::COLOURS[:mp_gauge2]);   end;
  676.   def mp_cost_color;     text_color(YEA::CORE::COLOURS[:mp_cost]);     end;
  677.   def power_up_color;    text_color(YEA::CORE::COLOURS[:power_up]);    end;
  678.   def power_down_color;  text_color(YEA::CORE::COLOURS[:power_down]);  end;
  679.   def tp_gauge_color1;   text_color(YEA::CORE::COLOURS[:tp_gauge1]);   end;
  680.   def tp_gauge_color2;   text_color(YEA::CORE::COLOURS[:tp_gauge2]);   end;
  681.   def tp_cost_color;     text_color(YEA::CORE::COLOURS[:tp_cost]);     end;
  682.  
  683.   #--------------------------------------------------------------------------
  684.   # overwrite method: translucent_alpha
  685.   #--------------------------------------------------------------------------
  686.   def translucent_alpha
  687.     return YEA::CORE::TRANSPARENCY
  688.   end
  689.  
  690.   #--------------------------------------------------------------------------
  691.   # overwrite method: hp_color
  692.   #--------------------------------------------------------------------------
  693.   def hp_color(actor)
  694.     return knockout_color if actor.hp == 0
  695.     return crisis_color if actor.hp < actor.mhp * YEA::CORE::HP_CRISIS
  696.     return normal_color
  697.   end
  698.   #--------------------------------------------------------------------------
  699.   # overwrite method: mp_color
  700.   #--------------------------------------------------------------------------
  701.   def mp_color(actor)
  702.     return crisis_color if actor.mp < actor.mmp * YEA::CORE::MP_CRISIS
  703.     return normal_color
  704.   end
  705.  
  706.   #--------------------------------------------------------------------------
  707.   # overwrite method: draw_gauge
  708.   #--------------------------------------------------------------------------
  709.   def draw_gauge(dx, dy, dw, rate, color1, color2)
  710.     dw -= 2 if YEA::CORE::GAUGE_OUTLINE
  711.     fill_w = [(dw * rate).to_i, dw].min
  712.     gauge_h = YEA::CORE::GAUGE_HEIGHT
  713.     gauge_y = dy + line_height - 2 - gauge_h
  714.     if YEA::CORE::GAUGE_OUTLINE
  715.       outline_colour = gauge_back_color
  716.       outline_colour.alpha = translucent_alpha
  717.       contents.fill_rect(dx, gauge_y-1, dw+2, gauge_h+2, outline_colour)
  718.       dx += 1
  719.     end
  720.     contents.fill_rect(dx, gauge_y, dw, gauge_h, gauge_back_color)
  721.     contents.gradient_fill_rect(dx, gauge_y, fill_w, gauge_h, color1, color2)
  722.   end
  723.  
  724.   #--------------------------------------------------------------------------
  725.   # overwrite method: draw_actor_level
  726.   #--------------------------------------------------------------------------
  727.   def draw_actor_level(actor, dx, dy)
  728.     change_color(system_color)
  729.     draw_text(dx, dy, 32, line_height, Vocab::level_a)
  730.     change_color(normal_color)
  731.     draw_text(dx + 32, dy, 24, line_height, actor.level.group, 2)
  732.   end
  733.  
  734.   #--------------------------------------------------------------------------
  735.   # overwrite method: draw_current_and_max_values
  736.   #--------------------------------------------------------------------------
  737.   def draw_current_and_max_values(dx, dy, dw, current, max, color1, color2)
  738.     total = current.group + "/" + max.group
  739.     if dw < text_size(total).width + text_size(Vocab.hp).width
  740.       change_color(color1)
  741.       draw_text(dx, dy, dw, line_height, current.group, 2)
  742.     else
  743.       xr = dx + text_size(Vocab.hp).width
  744.       dw -= text_size(Vocab.hp).width
  745.       change_color(color2)
  746.       text = "/" + max.group
  747.       draw_text(xr, dy, dw, line_height, text, 2)
  748.       dw -= text_size(text).width
  749.       change_color(color1)
  750.       draw_text(xr, dy, dw, line_height, current.group, 2)
  751.     end
  752.   end
  753.  
  754.   #--------------------------------------------------------------------------
  755.   # overwrite method: draw_actor_tp
  756.   #--------------------------------------------------------------------------
  757.   def draw_actor_tp(actor, x, y, width = 124)
  758.     draw_gauge(x, y, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
  759.     change_color(system_color)
  760.     draw_text(x, y, 30, line_height, Vocab::tp_a)
  761.     change_color(tp_color(actor))
  762.     draw_text(x + width - 42, y, 42, line_height, actor.tp.to_i.group, 2)
  763.   end
  764.  
  765.   #--------------------------------------------------------------------------
  766.   # overwrite method: draw_actor_param
  767.   #--------------------------------------------------------------------------
  768.   def draw_actor_param(actor, x, y, param_id)
  769.     change_color(system_color)
  770.     draw_text(x, y, 120, line_height, Vocab::param(param_id))
  771.     change_color(normal_color)
  772.     draw_text(x + 120, y, 36, line_height, actor.param(param_id).group, 2)
  773.   end
  774.  
  775.   #--------------------------------------------------------------------------
  776.   # overwrite method: draw_currency_value
  777.   #--------------------------------------------------------------------------
  778.   def draw_currency_value(value, unit, x, y, width)
  779.     cx = text_size(unit).width
  780.     change_color(normal_color)
  781.     draw_text(x, y, width - cx - 2, line_height, value.group, 2)
  782.     change_color(system_color)
  783.     draw_text(x, y, width, line_height, unit, 2)
  784.   end
  785.  
  786.   #--------------------------------------------------------------------------
  787.   # overwrite method: draw_actor_simple_status
  788.   #--------------------------------------------------------------------------
  789.   def draw_actor_simple_status(actor, dx, dy)
  790.     draw_actor_name(actor, dx, dy)
  791.     draw_actor_level(actor, dx, dy + line_height * 1)
  792.     draw_actor_icons(actor, dx, dy + line_height * 2)
  793.     dw = contents.width - dx - 124
  794.     draw_actor_class(actor, dx + 120, dy, dw)
  795.     draw_actor_hp(actor, dx + 120, dy + line_height * 1, dw)
  796.     draw_actor_mp(actor, dx + 120, dy + line_height * 2, dw)
  797.   end
  798.  
  799. end # Window_Base
  800.  
  801. #==============================================================================
  802. # ■ Window_Selectable
  803. #==============================================================================
  804.  
  805. class Window_Selectable < Window_Base
  806.  
  807.   #--------------------------------------------------------------------------
  808.   # overwrite method: process_cursor_move
  809.   #--------------------------------------------------------------------------
  810.   if YEA::CORE::QUICK_SCROLLING
  811.   def process_cursor_move
  812.     return unless cursor_movable?
  813.     last_index = @index
  814.     cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
  815.     cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
  816.     cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
  817.     cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
  818.     cursor_pagedown   if !handle?(:pagedown) && Input.repeat?(:R)
  819.     cursor_pageup     if !handle?(:pageup)   && Input.repeat?(:L)
  820.     Sound.play_cursor if @index != last_index
  821.   end
  822.   end # YEA::CORE::QUICK_SCROLLING
  823.  
  824. end # Window_Selectable
  825.  
  826. #==============================================================================
  827. # ■ Window_ItemList
  828. #==============================================================================
  829.  
  830. class Window_ItemList < Window_Selectable
  831.  
  832.   #--------------------------------------------------------------------------
  833.   # overwrite method: draw_item
  834.   #--------------------------------------------------------------------------
  835.   def draw_item(index)
  836.     item = @data[index]
  837.     return if item.nil?
  838.     rect = item_rect(index)
  839.     rect.width -= 4
  840.     draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
  841.     draw_item_number(rect, item)
  842.   end
  843.  
  844.   #--------------------------------------------------------------------------
  845.   # overwrite method: draw_item_number
  846.   #--------------------------------------------------------------------------
  847.   def draw_item_number(rect, item)
  848.     text = sprintf(YEA::CORE::ITEM_AMOUNT, $game_party.item_number(item).group)
  849.     draw_text(rect, text, 2)
  850.   end
  851.  
  852. end # Window_ItemList
  853.  
  854. #==============================================================================
  855. # ■ Window_SkillList
  856. #==============================================================================
  857.  
  858. class Window_SkillList < Window_Selectable
  859.  
  860.   #--------------------------------------------------------------------------
  861.   # draw_item
  862.   #--------------------------------------------------------------------------
  863.   def draw_item(index)
  864.     skill = @data[index]
  865.     return if skill.nil?
  866.     rect = item_rect(index)
  867.     rect.width -= 4
  868.     draw_item_name(skill, rect.x, rect.y, enable?(skill), rect.width - 24)
  869.     draw_skill_cost(rect, skill)
  870.   end
  871.  
  872. end # Window_SkillList
  873.  
  874. #==============================================================================
  875. # ■ Window_Status
  876. #==============================================================================
  877.  
  878. class Window_Status < Window_Selectable
  879.  
  880.   #--------------------------------------------------------------------------
  881.   # overwrite method: draw_exp_info
  882.   #--------------------------------------------------------------------------
  883.   def draw_exp_info(x, y)
  884.     s1 = @actor.max_level? ? "-------" : @actor.exp
  885.     s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
  886.     s_next = sprintf(Vocab::ExpNext, Vocab::level)
  887.     change_color(system_color)
  888.     draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
  889.     draw_text(x, y + line_height * 2, 180, line_height, s_next)
  890.     change_color(normal_color)
  891.     s1 = s1.group if s1.is_a?(Integer)
  892.     s2 = s2.group if s2.is_a?(Integer)
  893.     draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
  894.     draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
  895.   end
  896.  
  897. end # Window_Status
  898.  
  899. #==============================================================================
  900. # ■ Window_ShopBuy
  901. #==============================================================================
  902.  
  903. class Window_ShopBuy < Window_Selectable
  904.  
  905.   #--------------------------------------------------------------------------
  906.   # overwrite method: draw_item
  907.   #--------------------------------------------------------------------------
  908.   def draw_item(index)
  909.     item = @data[index]
  910.     rect = item_rect(index)
  911.     draw_item_name(item, rect.x, rect.y, enable?(item))
  912.     rect.width -= 4
  913.     draw_text(rect, price(item).group, 2)
  914.   end
  915.  
  916. end # Window_ShopBuy
  917.  
  918. #==============================================================================
  919. # ■ Scene_Map
  920. #==============================================================================
  921.  
  922. class Scene_Map < Scene_Base
  923.  
  924.   #--------------------------------------------------------------------------
  925.   # alias method: post_transfer
  926.   #--------------------------------------------------------------------------
  927.   alias scene_map_post_transfer_ace post_transfer
  928.   def post_transfer
  929.     @spriteset.update_viewport_sizes
  930.     scene_map_post_transfer_ace
  931.   end
  932.  
  933. end # Scene_Map
  934.  
  935. #==============================================================================
  936. # ■ Scene_Battle
  937. #==============================================================================
  938.  
  939. class Scene_Battle < Scene_Base
  940.  
  941.   #--------------------------------------------------------------------------
  942.   # alias method: check_substitute
  943.   #--------------------------------------------------------------------------
  944.   alias scene_battle_check_substitute_ace check_substitute
  945.   def check_substitute(target, item)
  946.     return false if @subject.actor? == target.actor?
  947.     return scene_battle_check_substitute_ace(target, item)
  948.   end
  949.  
  950.   #--------------------------------------------------------------------------
  951.   # overwrite method: process_forced_action
  952.   #--------------------------------------------------------------------------
  953.   def process_forced_action
  954.     while BattleManager.action_forced?
  955.       last_subject = @subject
  956.       @subject = BattleManager.action_forced_battler
  957.       process_action
  958.       @subject = last_subject
  959.       BattleManager.clear_action_force
  960.     end
  961.   end
  962.  
  963.   #--------------------------------------------------------------------------
  964.   # overwrite method: show_attack_animation
  965.   #--------------------------------------------------------------------------
  966.   def show_attack_animation(targets)
  967.     if @subject.actor?
  968.       show_normal_animation(targets, @subject.atk_animation_id1, false)
  969.       wait_for_animation
  970.       show_normal_animation(targets, @subject.atk_animation_id2, true)
  971.     else
  972.       Sound.play_enemy_attack
  973.       abs_wait_short
  974.     end
  975.   end
  976.  
  977.   #--------------------------------------------------------------------------
  978.   # overwrite method: show_normal_animation
  979.   #--------------------------------------------------------------------------
  980.   def show_normal_animation(targets, animation_id, mirror = false)
  981.     animation = $data_animations[animation_id]
  982.     return if animation.nil?
  983.     ani_check = false
  984.     targets.each do |target|
  985.       if ani_check && target.animation_id <= 0
  986.         target.pseudo_ani_id = animation_id
  987.       else
  988.         target.animation_id = animation_id
  989.       end
  990.       target.animation_mirror = mirror
  991.       abs_wait_short unless animation.to_screen?
  992.       ani_check = true if animation.to_screen?
  993.     end
  994.     abs_wait_short if animation.to_screen?
  995.   end
  996.  
  997. end # Scene_Battle
  998.  
  999. #==============================================================================
  1000. #
  1001. # ▼ End of File
  1002. #
  1003. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment