Bigace360

Warrior Core Engine XP

Mar 1st, 2013
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 59.05 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # ■ Warrior Engine - XP Core Engine v1.32
  3. # ■ Author : Bigace360
  4. #==============================================================================
  5. # ■ Version History:
  6. # v 1.00 - < 05.30.2012 >
  7. #   ▼ First relase
  8. #
  9. # v 1.12 - < 09.13.2012 >
  10. #   ▼ Upgrade: Improve Coding
  11. #   ▼ Split the TP Guage from the Engine
  12. #   ▼ Added Encounter Fix
  13. #
  14. # v 1.13 - < 09.27.2012 >
  15. #   ▼ Improved Coding
  16. #
  17. # v 1.15 - < 10.02.2012 >
  18. #   ▼ Improved Coding
  19. #   ▼ Overworked Gold and Steps windows to add Numeric.group
  20. #
  21. # v 1.32 - < 02.08.2013 >
  22. #   ▼ Added MP Death
  23. #   ▼ Added One HP Revival after battle
  24. #   ▼ Actors name can turn red if below a certain percentage now
  25. #   ▼ Upgrade: Added 5 more colors to the Color class
  26. #==============================================================================
  27. # ■ Introduction
  28. #   This is the basic script for the system from Warrior Engine and is
  29. # required to use the scripts from the engine. This script offer some new
  30. # functions to be used within many scripts of the engine. The Engine was create
  31. # to add features that are present in RPG Maker VX/VXAce and including bug
  32. # fixes and GUI upgrades.
  33. =begin
  34. # -----------------------------------------------------------------------------
  35. # Bug Fix: Interpreter Fix
  36. # -----------------------------------------------------------------------------
  37. # The script here fixes the multi-line issue with the call script command and
  38. # improves the execution of the wait idea. For those who don't know. If the call
  39. # script evaluates to false then the event waits a frame before running the
  40. # script call again. (Consider it like Repeat next frame)
  41. #
  42. # If the script call was on multiple lines there was a single frame wait before
  43. # it continued with the next event commands. This script fixes this issue so it
  44. # wait whether single-line or multi-line.
  45. #
  46. # -----------------------------------------------------------------------------
  47. # Bug Fix: Encounter Fix
  48. # -----------------------------------------------------------------------------
  49. # This script is more or less a fix to the default rmxp encounter rate. How many
  50. # people have noticed that when they set the encounter step of the map to
  51. # something like 30, they’ll encounter monsters after 4 or 5 steps or something
  52. # bizarre like that? Well, this script fixes that. The default rmxp encounter
  53. # rate makes it so that the encounter step that you put for the map will be the
  54. # most amounts of steps it’ll take to encounter another monster. The default
  55. # script gets a random number from 1 to the number you chose plus 1. This script
  56. # gets a more reasonable number from the encounter step that you chose. So let
  57. # say that you put in 30, you’ll probably get something around 25 – 35.
  58. #
  59. # -----------------------------------------------------------------------------
  60. # New Feature: HALF_MP_ID and NO_MP_ID
  61. # -----------------------------------------------------------------------------
  62. # You can now have half or no mp states, just go to the database and add that
  63. # state, then come back to the module and change the ID to the state.
  64. #
  65. # -----------------------------------------------------------------------------
  66. # New Feature: Draw Actor Face
  67. # -----------------------------------------------------------------------------
  68. # You can now add actors faces by adding them to the picture folder by there
  69. # actor name. You can call the script into any window with this call:
  70.  
  71. draw_actor_face(actor, x, y [,size = 96])
  72.  
  73. # Note: You can ommite whats in the bracket if you don't want to change the
  74. # size. Just make sure the brackets aren't actually in the real code.
  75. #
  76. # -----------------------------------------------------------------------------
  77. # New Feature: Gradient Draw Text
  78. # -----------------------------------------------------------------------------
  79.  
  80. == Example ==
  81. If You want to see your text with gradient colors, use this code:
  82. class Window_Base
  83.   #--------------------------------------------------------------------------
  84.   # * Draw Name
  85.   #     actor : actor
  86.   #     x     : draw spot x-coordinate
  87.   #     y     : draw spot y-coordinate
  88.   #--------------------------------------------------------------------------
  89.   def draw_actor_name(actor, x, y)
  90.         gradient_text(x, y, 64, 32, actor.name, Color.new(255,0,0),
  91.             Color.new(0,255,0), 0, false)
  92.   end
  93. end
  94.  
  95. # -----------------------------------------------------------------------------
  96. # New Feature: Numeric Digit Grouping
  97. # -----------------------------------------------------------------------------
  98. # This will change various scenes to display numbers in groups where they are
  99. # separated by a comma every three digits. Thus, a number like 1234567 will
  100. # show up as 1,234,567. This allows for players to read numbers quicker.
  101. #
  102. # -----------------------------------------------------------------------------
  103. # New Feature: GUI Modifications
  104. # -----------------------------------------------------------------------------
  105. # - There are quite a lot of different modifications you can do to the GUI. This
  106. # includes adding bars to HP and SP, adding Shadow and Outline to Font, changing
  107. # the colours of each individual font aspect, and more. Also, you can change the
  108. # default font setting for your games here.
  109. #
  110. # -----------------------------------------------------------------------------
  111. # New Methods: class Color
  112. # -----------------------------------------------------------------------------
  113. # * This Set Defines the Basic Colors
  114. #--------------------------------------------------------------
  115. Color.red
  116. Color.pink
  117. Color.orange
  118. Color.cyan
  119. Color.magenta
  120. Color.green
  121. Color.blue
  122. Color.yellow
  123. Color.purple
  124. Color.orange
  125. Color.white
  126. Color.black    
  127. Color.gray
  128. Color.light_gray
  129. Color.dark_gray
  130. Color.clear
  131. Color.normal
  132. Color.disabled
  133. Color.system
  134. Color.crisis
  135. Color.knockout
  136.  
  137. #--------------------------------------------------------------
  138. # * Name      : Color Between
  139. #   Info      : Gets Color Between Two colors given the percent
  140. #--------------------------------------------------------------
  141. Color.color_between(color_a, color_b, percent = 0.5)
  142.  
  143. #--------------------------------------------------------------
  144. #   Name      : Get Color
  145. #   Info      : Gets a Color
  146. #   Call Info : Integer Value the color code to get
  147. #   Comment   : 0: Clear 1: Red 2: Blue 3:Yellow 4: Purple 5:Orange 6:Green
  148. #               7:White 8: Black - 10 for lighter + 10 for darker
  149. #--------------------------------------------------------------
  150. Color.get_color(value)
  151.  
  152. # -----------------------------------------------------------------------------
  153. # New Methods: class Array
  154. # -----------------------------------------------------------------------------
  155.  * Random array value
  156.    <Array>.random
  157.    <Array>.random!
  158.    Returns a random object from the array, the method .random! is destructive,
  159.    removing the value returned from the array.
  160.  
  161.  * Sum of the numeric values of a array
  162.    <Array>.sum
  163.    Returns the sum of all numeric values
  164.  
  165.  * Product of the numeric values of a array
  166.    <Array>.product
  167.    Returns the product of all values in the array
  168.  
  169.  * Avarage of all numeric values from the array
  170.    <Array>.average(float = false)
  171.     float : float flag
  172.    Returns the average of all numeric values, if floa is true, the value
  173.    returned is a float, otherwise it's a integer.
  174.  
  175.  * Returns the Geometric Mean of all values in the array
  176.    <Array>.geometric_average(float = false)
  177.    Zero To One Arguments Defaults to False
  178.    Boolean to_float if true always returns a Float else always returns an
  179.    Integer regardless of the Types in the array              
  180.  
  181.  
  182. =end
  183. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  184. #                                  SECTIONS                                    #
  185. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  186. #  ■ Game_Objects
  187. # ** Warrior_Engine Module
  188. # ** RPG Module
  189. # ** Graphic Module
  190. # ** Array
  191. # ** Bitmap
  192. # ** Color
  193. # ** Font
  194. # ** Numeric
  195. # ** Game_Battler
  196. # ** Game_Actor
  197. # ** Game_Enemy
  198. # ** Game_Party
  199. # ** Game_Player
  200. #
  201. #  ■ Windows
  202. # ** Window_Base
  203. # ** Window_Selectable
  204. # ** Window_Gold
  205. # ** Window_Steps
  206. # ** Window_Item
  207. # ** Window_Skill
  208. # ** Window_ShopBuy
  209. # ** Window_ShopSell
  210. # ** Window_BattleStatus
  211. #
  212. #  ■ Scenes
  213. # ** Interpreter
  214. # ** Scene_Battle
  215. # ** Scene_Skill
  216. #
  217. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  218. #                     Script Conflicts and Compatability                       #
  219. #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  220. # This script is made strictly for RPG Maker XP. There would be no need to add
  221. # this to RPG Maker VX/VXace as majority of the features already exist.
  222. #
  223. # ● Alias methods
  224. #   class Bitmap
  225. #     def draw_text(*args)
  226. #
  227. #   class Font
  228. #     def initialize(*args)
  229. #
  230. #   class Window_Base
  231. #     def draw_actor_state
  232. #    
  233. # ● Overwrite methods
  234. #   class Game_Battler
  235. #     def skill_can_use?
  236. #     def dead?
  237. #    
  238. #   class Game_Player
  239. #     def make_encounter_count
  240. #    
  241. #   class Window_Base
  242. #     def normal_color
  243. #     def disabled_color
  244. #     def system_color
  245. #     def crisis_color
  246. #     def knockout_color
  247. #     def draw_actor_name(actor, x, y, width = 120)
  248. #     def draw_actor_hp(actor, x, y, width = 130)
  249. #     def draw_actor_sp(actor, x, y, width = 130)
  250. #     def draw_actor_exp(draw_actor_exp(actor, x, y, width = 144)
  251. #     def draw_item_name(item, x, y, enabled = true, width = 212)
  252. #    
  253. #   class Window_Item  
  254. #     def draw_item
  255. #    
  256. #   class Window_Skill  
  257. #     def draw_item
  258. #    
  259. #   class Window_ShopBuy
  260. #     def draw_item
  261. #    
  262. #   class Window_ShopSell
  263. #     def draw_item
  264. #    
  265. #   class Window_BattleStatus  
  266. #     def refresh
  267. #  
  268. #   class Window_Gold
  269. #     def refresh
  270. #
  271. #   class Window_Steps
  272. #     def refresh  
  273. #
  274. #   class Interpreter
  275. #     def command_355
  276. #
  277. #   class Scene_Skill
  278. #     def update_target
  279. #  
  280. #
  281. # Due to the rewrite in most of these classes, this Engine should be above all
  282. # other of my custom scripts and below Scene_Debug.
  283. #
  284. # For info on script order go here:
  285. # http://bigaceworld.wordpress.com/tutorials/script-order/
  286. #==============================================================================
  287. # ▼ Instructions
  288. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  289. # To install this script, open up your script editor and copy/paste this script
  290. # to an open slot below Debug but above Main. Remember to save.
  291. #
  292. # Edit the settings in the module below as you see fit.
  293. #
  294. #==============================================================================
  295. # ■ Special Thanks:
  296. # Bigace360 ~ For creating the engine
  297. #==============================================================================
  298. #
  299. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  300. # ■ Warrior Engine (Setting module for the Warrior Engine)
  301. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  302. module Warrior_Engine
  303.     #=============================================================================
  304.     # ▼ Warning DO NOT TOUCH THIS MODULE, altering this will ruin any chances of
  305.     #   any script that requires this engine to run.
  306.     #
  307.     # For Configurations go to Module Core below this one.
  308.     #=============================================================================
  309.     module MESSAGE
  310.         #--------------------------------------------------------------------------
  311.         # * New method: required_script
  312.         #--------------------------------------------------------------------------
  313.         def self.required_script(name, req, version, type = 0)
  314.             if type != :bellow && (!$ace_script[req] || $ace_script[req] < version)
  315.                 msg = "The script '%s' requires the script\n"
  316.                 case type
  317.                 when :above then msg += "'%s' v%s or higher above it to work properly\n"
  318.                 else             msg += "'%s' v%s or higher to work properly\n"
  319.                 end
  320.                 msg += "Go to http://bigaceworld.wordpress.com/ to download this script."
  321.                 self.exit_message(msg, name, req, version)
  322.             elsif type == :bellow && $ace_script[req]
  323.                 msg =  "The script '%s' requires the script\n"
  324.                 msg += "'%s' to be put bellow it\n"
  325.                 msg += "move the scripts to the proper position"
  326.                 self.exit_message(msg, name, req, version)
  327.             end
  328.         end
  329.         #--------------------------------------------------------------------------
  330.         # * New method: exit_message
  331.         #--------------------------------------------------------------------------
  332.         def self.exit_message(message, name, req, version)
  333.             name = self.script_name(name)
  334.             req  = self.script_name(req)
  335.             print(sprintf(message, name, req, version))
  336.             exit
  337.         end
  338.         #--------------------------------------------------------------------------
  339.         # * New method: script_name
  340.         #--------------------------------------------------------------------------
  341.         def self.script_name(name, ext = "WE")
  342.             name = name.to_s.gsub("_", " ").upcase.split
  343.             name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  344.             name.join(" ")
  345.         end
  346.     end
  347.     #=============================================================================
  348.     # ▼ BEGIN CONFIGURATIONS HERE BELOW
  349.     #=============================================================================
  350.     module CORE
  351.         #--------------------------------------------------------------------------
  352.         # - Interpreter command_355 fix -
  353.         #--------------------------------------------------------------------------
  354.         # The script now waits on :wait. (And FalseClass for compatibility reasons)
  355.         # It is easy to change what call script should wait on. :wait conveys it's
  356.         # purpose much better than simply false and scripts accidentally evaluating
  357.         # to :wait is much less likely to happen than for false.
  358.         #--------------------------------------------------------------------------
  359.         SCRIPT_WAIT_RESULTS = [:wait, FalseClass]
  360.         #--------------------------------------------------------------------------
  361.         # - Change Default Font -
  362.         #--------------------------------------------------------------------------
  363.         # This allows you to change the default font if that's what you wish to do
  364.         # with your game. This array orders the fonts by priority. If the player
  365.         # lacks the font in the front of the array, the game will skip that font
  366.         # and choose the next available font in line.
  367.         #--------------------------------------------------------------------------
  368.         DEFAULT ={
  369.             # Default Fonts: ["Arial"]
  370.             :name => ["UmePlus Gothic", "Arial", "Verdana", "Courier New"],
  371.             # Adjusts font size. Default: 22
  372.             :size => 18,
  373.             # Makes font bold. Default: false
  374.             :bold => false,
  375.             # Makes font italic. Default: false
  376.             :italic => false,
  377.             # Default: 255, 255, 255, 255
  378.             :colour => Color.new(255, 255, 255, 255),
  379.             # Gives font a shadow. Default: false
  380.             :shadow => true,
  381.             # Gives font an outline. Default: true
  382.             :outline => true,
  383.             # Default:  0, 0, 0, 128
  384.             :outline_color => Color.new(0, 0, 0, 128),
  385.         }
  386.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  387.         # - State Images -
  388.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    
  389.         # If true it turns the states from words to images. Just place an icon in
  390.         # the icon folder with the same name as the state in the database.
  391.         # The larger the width, the more icons appear, make sure it's a multiple of
  392.         # 24 or you'll probably only have half of an icon appear.
  393.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  394.         STATE ={
  395.             :image => true,
  396.             :width => 240,
  397.         }
  398.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  399.         # - SHOW FACE -
  400.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    
  401.         # if true it allows for the face image to appear. Just in case you don't
  402.         # have a face image to begin with.
  403.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    
  404.         SHOW_FACE = true
  405.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  406.         # - Digit Grouping -
  407.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  408.         # Setting this to true will cause numbers to be grouped together when they
  409.         # are larger than a thousand. For example, 12345 will appear as 12,345.
  410.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  411.         GROUP_DIGITS = true
  412.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  413.         # - Danger? - (HP % that show low HP Animation)
  414.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  415.         Danger_Value = 25
  416.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  417.         # - death_state? - (Get State ID of K.O.)
  418.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  419.         DEATH_STATE_ID = 1
  420.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  421.         # - half_mp - (Get State ID of half_mp)
  422.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  423.         HALF_MP_ID = 17
  424.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  425.         # - no_mp - (Get State ID of no_mp)
  426.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    
  427.         NO_MP_ID = 18
  428.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  429.         # - MP Death - (Kill actor if mp reachs 0)
  430.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  431.         MP_DEATH = false
  432.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  433.         # - 1 HP Revival - (Dead actors are returned to 1 HP after battle)
  434.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  435.         HP1_REVIVE = false
  436.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  437.         # - NAME_ALERT - (When Hp goes below the crisis limit, name text changes color)
  438.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  439.         NAME_ALERT = true
  440.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  441.         # - System Text Options -
  442.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  443.         # Here, you can adjust the transparency used for disabled items, the %
  444.         # needed for HP and MP to enter "crisis" mode.
  445.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  446.         TRANSPARENCY = 160   # Adjusts transparency of disabled items. Default: 160
  447.         HP_CRISIS = 0.25     # When HP is considered critical. Default: 0.25
  448.         MP_CRISIS = 0.25     # When MP is considered critical. Default: 0.25       
  449.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  450.         # - HP/MP Gauge Settings -
  451.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  452.         # You can modify the way your gauges appear in the game. If you wish for
  453.         # them to have an outline, it's possible. Adjust how the Gauges appears for
  454.         # the Warrior Engine here. This includes the text display, the colour of the
  455.         # gauges, and more. Adjust it all here.
  456.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-    
  457.         #If false, it returns them to their original methods
  458.         DRAW_GUAGES = true
  459.         GAUGE_OUTLINE = true
  460.         # Colours for HP/MP gauges.
  461.         #------------------------------------
  462.         HP_COLOR1 = Color.new(224, 128, 64)
  463.         HP_COLOR2 = Color.new(240, 192, 64)
  464.         #------------------------------------
  465.         SP_Color1 = Color.new(64, 128, 192)
  466.         SP_COLOR2 = Color.new(64, 192, 240)
  467.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  468.         # - EXP Gauge Settings -
  469.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  470.         # Adjust how the EXP Gauge appears for the Warrior Engine here. This
  471.         # includes the text display, the font size, the colour of the gauges, and
  472.         # more. Adjust it all here. Note: make sure Draw_Gauge is true before
  473.         # touching this section.
  474.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  475.         # Text used for EXP
  476.         EXP_TEXT     = "EXP"      
  477.         # The way EXP percentage will be displayed.
  478.         EXP_PERCENT  = "%1.2f%%"    
  479.         # Text to replace percentage when max level.
  480.         MAX_LVL_TEXT = "MAX LEVEL"  
  481.         # Colours for exp gauge.
  482.         EXP_GAUGE1   = Color.new(0, 160, 16)
  483.         EXP_GAUGE2   = Color.new(102, 204, 64)
  484.        
  485.         #===========================================================================
  486.         # ▼ Editting anything past this point may potentially result in causing
  487.         # computer damage, incontinence, explosion of user's head, coma, death,
  488.         # and/or halitosis so edit at your own risk.
  489.         #===========================================================================
  490.        
  491.         module_function
  492.         #--------------------------------------------------------------------------
  493.         # convert_integer_array
  494.         #--------------------------------------------------------------------------
  495.         def convert_integer_array(array)
  496.             result = []
  497.             array.each { |i|
  498.                 case i
  499.                 when Range; result |= i.to_a
  500.                 when Integer; result |= [i]
  501.                 end }
  502.             return result
  503.         end
  504.        
  505.         #--------------------------------------------------------------------------
  506.         # full_convert_hash
  507.         #--------------------------------------------------------------------------
  508.         def full_convert_hash(hash)
  509.             result = {}
  510.             hash.each {|key| result[key[0]] = convert_integer_array(key[1])}
  511.             return result
  512.         end
  513.     end # CORE
  514. end # Warrior_Engine
  515. #=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  516. #                         ▼ Import to Global Hash ▼                            #
  517. ($ace_script ||= {})[:ace_warrior_module] = 1.32
  518. #=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  519. # ■ Hidden Default Font Classes
  520. #=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  521. Font.default_name =   Warrior_Engine::CORE::DEFAULT[:name]
  522. Font.default_size =   Warrior_Engine::CORE::DEFAULT[:size]
  523. Font.default_bold =   Warrior_Engine::CORE::DEFAULT[:bold]
  524. Font.default_italic = Warrior_Engine::CORE::DEFAULT[:italic]
  525. Font.default_color =  Warrior_Engine::CORE::DEFAULT[:colour]
  526.  
  527. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  528. # ■ Object (This class is the superclass of all other classes.)
  529. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  530. class Object
  531.     include Warrior_Engine::MESSAGE
  532. end
  533.  
  534. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  535. # ■ Graphics Module
  536. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  537. module Graphics
  538.     @@fadeout_ace = Viewport.new(0,0,640,480)
  539.     @@fadeout_ace.z = 0x3FFFFFFF
  540.     @@fadeout_ace.color = Color.new(0,0,0,0)
  541.     def self.brightness; return (255 - @@fadeout_ace.color.alpha); end
  542.     def self.brightness=(value)
  543.         value = [[value, 0].max, 255].min
  544.         @@fadeout_ace.color.alpha = 255 - value
  545.     end
  546.     def self.fadein(frames)
  547.         return if frames <= 0
  548.         curvalue = self.brightness
  549.         count    = (255 - self.brightness)
  550.         frames.times do |i|
  551.             self.brightness = curvalue + (count * i / frames)
  552.             self.update
  553.         end
  554.     end
  555.     def self.fadeout(frames)
  556.         return if frames <= 0
  557.         curvalue = self.brightness
  558.         count    = self.brightness
  559.         frames.times do |i|
  560.             self.brightness = curvalue - (count * i / frames)
  561.             self.update
  562.         end
  563.     end
  564.     def self.wait(frames)
  565.         return if frames <= 0
  566.         frames.times {|i| self.update}
  567.     end
  568. end
  569.  
  570. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  571. # ■ Array    
  572. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  573. class Array
  574.     #-------------------------------------------------------------------------
  575.     # * Random (Returns a Random element in the array)
  576.     #-------------------------------------------------------------------------
  577.     def random; return self[rand(size)]; end
  578.     #-------------------------------------------------------------------------
  579.     # * Random! (Returns and Deletes a Random element in the array)
  580.     #-------------------------------------------------------------------------
  581.     def random!; return delete_at(rand(size));end
  582.     #---------------------------------------------------------------------------
  583.     # * Sum (Sums all values in the array)
  584.     #---------------------------------------------------------------------------
  585.     def sum
  586.         n = 0                               # Initialize local variable n
  587.         each {|num| n += num} # Sum Up Values in Array
  588.         return n                            # Return number
  589.     end
  590.     #---------------------------------------------------------------------------
  591.     # * Product (Returns the product of all values in the array)
  592.     #---------------------------------------------------------------------------
  593.     def product
  594.         n = 1                               # Setup N initialize to 1
  595.         each {|num| n *= num} # Run Through and Find Product
  596.         return n                            # Return Product
  597.     end
  598.     #---------------------------------------------------------------------------
  599.     # * Average (Averages all values in the array)
  600.     #   Call Info : Zero To One Arguments Defaults to False
  601.     #               Boolean float if true always returns a Float else returns a
  602.     #               Float or a Integer depending on the Types in the array
  603.     #---------------------------------------------------------------------------
  604.     def average(float = false)
  605.         self.sum / [(float ? size.to_f : size.to_i), 1].max
  606.     end
  607.     #---------------------------------------------------------------------------
  608.     # * Geometric Average (Returns the Geometric Mean of all values in the array)
  609.     #   Call Info : Zero To One Arguments Defaults to False
  610.     #               Boolean to_float if true always returns a Float else
  611.     #               always returns an Integer regardless of the Types in the
  612.     #               array
  613.     #---------------------------------------------------------------------------
  614.     def geometric_average(float = false)
  615.         # Return 0 if empty
  616.         return 0 if empty?
  617.         # Get Geometric Average
  618.         average = product ** (1.0 / size)
  619.         # If Float return average else convert to integer
  620.         return (float ? average : average.to_i)
  621.     end
  622. end
  623.  
  624. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  625. # ■ Bitmap
  626. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  627. class Bitmap
  628.     def clear_rect(*args)
  629.         color = Color.clear
  630.         args << color
  631.         fill_rect(*args)
  632.     end
  633.     #--------------------------------------------------------------------------
  634.     # Name:   gradient_fill_rect(*args)
  635.     # Author: Kellesedee
  636.     #--------------------------------------------------------------------------
  637.     def gradient_fill_rect(*args)
  638.         if args[0].is_a?(Rect)
  639.             x, y, width, height = args[0].x,
  640.             args[0].y,
  641.             args[0].width,
  642.             args[0].height
  643.             color1 = args[1].dup
  644.             color2 = args[2]
  645.             vertical = args[3]
  646.         else
  647.             x, y, width, height = args[0..3]
  648.             color1 = args[4].dup
  649.             color2 = args[5]
  650.             vertical = args[6]
  651.         end
  652.         dr, dg, db, da = color2.red - color1.red,
  653.         color2.green - color1.green,
  654.         color2.blue  - color1.blue,
  655.         color2.alpha - color1.alpha
  656.         start_rgba = [color1.red, color1.green, color1.blue, color1.alpha]
  657.         if vertical
  658.             dr, dg, db, da = dr / height, dg / height, db / height, da / height
  659.             (y...(y + height)).each do |i|
  660.                 fill_rect(x, i, width, 1, color1)
  661.                 start_rgba[0] = [start_rgba[0] + dr, 0].max
  662.                 start_rgba[1] = [start_rgba[1] + dg, 0].max
  663.                 start_rgba[2] = [start_rgba[2] + db, 0].max
  664.                 start_rgba[3] = [start_rgba[3] + da, 0].max
  665.                 color1.set(*start_rgba)
  666.             end
  667.         else
  668.             dr, dg, db, da = dr / width, dg / width, db / width, da / width
  669.             (x...(x + width)).each do |i|
  670.                 fill_rect(i, y, 1, height, color1)
  671.                 start_rgba[0] = [start_rgba[0] + dr, 0].max
  672.                 start_rgba[1] = [start_rgba[1] + dg, 0].max
  673.                 start_rgba[2] = [start_rgba[2] + db, 0].max
  674.                 start_rgba[3] = [start_rgba[3] + da, 0].max
  675.                 color1.set(*start_rgba)
  676.             end
  677.         end
  678.     end
  679.     #--------------------------------------------------------------------------
  680.     # Name:   gradient_draw_rect(*args)
  681.     # Author: Ramiro
  682.     #--------------------------------------------------------------------------
  683.     def gradient_draw_text(*args)
  684.         if args[0].is_a?(Rect)
  685.             x = args[0].x
  686.             y = args[0].y
  687.             w = args[0].width
  688.             h = args[0].height
  689.             text = args[1]
  690.             color1 = args[2]
  691.             color2 = args[3]
  692.             aling = args[4] if args[4]
  693.             vertical = args[5] if args[5]
  694.         else
  695.             x = args[0]
  696.             y = args[1]
  697.             w = args[2]
  698.             h = args[3]
  699.             text = args[4]
  700.             color1 = args[5]
  701.             color2 = args[6]
  702.             aling = args[7]   if args[7]
  703.             vertical = args[8] if args[8]
  704.         end  
  705.         aling = 0 if !aling
  706.         vertical = false if !vertical
  707.         text_bmp = Bitmap.new(w,h)
  708.         text_bmp.font.name = font.name
  709.         text_bmp.font.size = font.size
  710.         text_bmp.font.shadow = false  if text_bmp.font.respond_to?("shadow")
  711.         text_bmp.font.outline = false if text_bmp.font.respond_to?("outline")
  712.         text_bmp.font.border = false  if text_bmp.font.respond_to?("border")
  713.         text_bmp.font.bold = font.bold
  714.         text_bmp.font.italic = font.italic
  715.         text_bmp.draw_text(0,0,w,h,text,aling)
  716.         gradient_bmp = Bitmap.new(w,h)
  717.         gradient_bmp.gradient_fill_rect(0, 0, w, h, color1, color2, vertical)
  718.         for x2 in 0...w
  719.             for y2 in 0...h
  720.                 alpha_txt = text_bmp.get_pixel(x2,y2).alpha
  721.                 if alpha_txt > 0
  722.                     c = gradient_bmp.get_pixel(x2,y2)
  723.                     c.alpha = alpha_txt
  724.                     text_bmp.set_pixel(x2,y2,c)
  725.                 end
  726.             end
  727.         end
  728.         draw_text(x,y,w,h,text,aling)
  729.         blt(x,y,text_bmp,Rect.new(0,0,w,h))
  730.     end  
  731.     alias :warrior_draw_text :draw_text unless $@
  732.     def draw_text(*args)
  733.         if self.font.shadow
  734.             orig_color = self.font.color.dup
  735.             self.font.color = Color.new(0, 0, 0, 100)
  736.             if args[0].is_a?(Rect)
  737.                 x = args[0].x + 2
  738.                 y = args[0].y + 2
  739.                 w = args[0].width
  740.                 h = args[0].height
  741.                 text  = args[1]
  742.                 align = args[2]
  743.             else
  744.                 x = args[0] + 2
  745.                 y = args[1] + 2
  746.                 w = args[2]
  747.                 h = args[3]
  748.                 text  = args[4]
  749.                 align = args[5]
  750.             end
  751.             align = 0 if align.nil?
  752.             self.warrior_draw_text(x, y, w, h, text, align)
  753.             self.font.color = orig_color
  754.         end
  755.         if self.font.outline
  756.             orig_color = self.font.color.dup
  757.             self.font.color = self.font.outline_color
  758.             if args[0].is_a?(Rect)
  759.                 x = args[0].x
  760.                 y = args[0].y
  761.                 w = args[0].width
  762.                 h = args[0].height
  763.                 text  = args[1]
  764.                 align = args[2]
  765.             else
  766.                 x = args[0]
  767.                 y = args[1]
  768.                 w = args[2]
  769.                 h = args[3]
  770.                 text  = args[4]
  771.                 align = args[5]
  772.             end
  773.             align = 0 if align.nil?
  774.             self.warrior_draw_text(x + 1, y, w, h, text, align)
  775.             self.warrior_draw_text(x - 1, y, w, h, text, align)
  776.             self.warrior_draw_text(x, y + 1, w, h, text, align)
  777.             self.warrior_draw_text(x, y - 1, w, h, text, align)
  778.             self.warrior_draw_text(x + 1, y + 1, w, h, text, align)
  779.             self.warrior_draw_text(x + 1, y - 1, w, h, text, align)
  780.             self.warrior_draw_text(x - 1, y - 1, w, h, text, align)
  781.             self.warrior_draw_text(x - 1, y + 1, w, h, text, align)
  782.             self.font.color = orig_color
  783.         end
  784.         self.warrior_draw_text(*args)
  785.     end
  786. end
  787.  
  788. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  789. # ■ Color
  790. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  791. class Color
  792.     #-------------------------------------------------------------------------
  793.     # * This Set Defines the Basic Colors so now you can do Color.(color)
  794.     #-------------------------------------------------------------------------  
  795.     def self.red;        return Color.new(255, 0, 0);          end
  796.     def self.pink;       return Color.new(255, 175, 175);      end
  797.     def self.green;      return Color.new(0, 128, 0);          end
  798.     def self.blue;       return Color.new(0, 0, 255);          end
  799.     def self.yellow;     return Color.new(255, 255, 0);        end
  800.     def self.purple;     return Color.new(128, 0, 128);        end
  801.     def self.orange;     return Color.new(255, 128, 0);        end
  802.     def self.white;      return Color.new(255, 255, 255);      end
  803.     def self.black;      return Color.new(0, 0, 0);            end
  804.     def self.gray;       return Color.new(128, 128, 128);      end
  805.     def self.light_gray; return Color.new(192,192,192);        end
  806.     def self.dark_gray;  return Color.new(64,64,64);           end
  807.     def self.cyan;       return Color.new(0,255,255);          end
  808.     def self.magenta;    return Color.new(255,255,0);          end
  809.     def self.clear;      return Color.new(0, 0, 0, 0);         end
  810.     def Color.normal;    return Color.new(255, 255, 255, 255); end
  811.     def Color.disabled;  return Color.new(255, 255, 255, 128); end
  812.     def Color.system;    return Color.new(192, 224, 255, 255); end
  813.     def Color.crisis;    return Color.new(255, 255, 64, 255);  end
  814.     def Color.knockout;  return Color.new(255, 64, 0);         end
  815.     #-------------------------------------------------------------------------
  816.     # * Name      : Color Between
  817.     #   Info      : Gets Color Between Two colors given the percent
  818.     #   Author    : SephirothSpawn
  819.     #   Call Info : Start Color, Finish Color, Percent
  820.     #-------------------------------------------------------------------------
  821.     @color_between = {}
  822.     def self.color_between(color_a, color_b, percent = 0.5)
  823.         # Gets Save Key
  824.         key = [color_a, color_b, percent]
  825.         return @color_between[key] if @color_between.has_key?(key)
  826.         # Calculates New Color
  827.         r = Integer(color_a.red   + (color_b.red   - color_a.red)   * percent)
  828.         g = Integer(color_a.green + (color_b.green - color_a.green) * percent)
  829.         b = Integer(color_a.blue  + (color_b.blue  - color_a.blue)  * percent)
  830.         a = Integer(color_a.alpha + (color_b.alpha - color_a.alpha) * percent)
  831.         # Saves Color
  832.         @color_between[key] = Color.new(r, g, b, a)
  833.         # Returns Color
  834.         return @color_between[key]
  835.     end
  836.     #-------------------------------------------------------------------------
  837.     #   Name      : Get Color
  838.     #   Info      : Gets a Color
  839.     #   Author    : Trickster
  840.     #   Call Info : Integer Value the color code to get
  841.     #   Comment   : 0: Clear 1: Red 2: Blue 3:Yellow 4: Purple 5:Orange 6:Green
  842.     #               7:White 8: Black - 10 for lighter + 10 for darker
  843.     #-------------------------------------------------------------------------
  844.     def self.get_color(value)
  845.         # Convert to 0-8
  846.         color_value = value < 0 ? value + 10 : value % 10
  847.         # Branch According to number
  848.         case color_value
  849.         when 0 then return                        # Clear
  850.         when 1 then r = 255; g = 0;   b = 0       # Red
  851.         when 2 then r = 0;   g = 0;   b = 255     # Blue
  852.         when 3 then r = 255; g = 255; b = 0       # Yellow
  853.         when 4 then r = 255; g = 0;   b = 255     # Purple
  854.         when 5 then r = 255; g = 128; b = 0       # Orange
  855.         when 6 then r = 0;   g = 255; b = 0       # Green
  856.         when 7 then r = 255; g = 255; b = 255     # White
  857.         when 8 then r = 0;   g = 0;   b = 0       # Black
  858.         end
  859.         # Convert if Lighter/Darker
  860.         if value < 0;     r += 64; g += 64; b += 64
  861.         elsif value > 10; r -= 64; g -= 64; b -= 64
  862.         end
  863.         # Correction
  864.         r = [[0,r].max, 255].min
  865.         g = [[0,g].max, 255].min
  866.         b = [[0,b].max, 255].min
  867.         return Color.new(r,g,b)
  868.     end
  869. end
  870.  
  871. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  872. # ■ Font
  873. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  874. class Font
  875.     @@default_shadow        = Warrior_Engine::CORE::DEFAULT[:shadow]
  876.     @@default_outline       = Warrior_Engine::CORE::DEFAULT[:outline]
  877.     @@default_outline_color = Warrior_Engine::CORE::DEFAULT[:outline_color]
  878.     attr_accessor(:shadow_color, :outline_color)
  879.     attr_reader(:shadow, :outline)
  880.     alias warrior_engine_int initialize unless $@
  881.     def initialize(*args)
  882.         warrior_engine_int(*args)
  883.         @shadow = @@default_shadow
  884.         @outline, @outline_color = @@default_outline, @@default_outline_color
  885.     end
  886.     def self.default_shadow=(bool)
  887.         @@default_shadow  = bool
  888.         @@default_outline = false unless bool == false
  889.     end
  890.     def self.default_shadow; return @@default_shadow; end
  891.     def self.default_outline=(bool)
  892.         @@default_outline = bool
  893.         @@default_shadow  = false unless bool == false
  894.     end
  895.     def self.default_outline; return @@default_outline; end
  896.     def self.default_outline_color=(color)
  897.         raise(TypeError, 'Cannot use a non Color object for color.') unless color.ialign?(Color)
  898.         @@default_outline_color = color
  899.     end
  900.     def self.default_outline_color; return @@default_outline_color; end
  901.     def shadow=(bool)
  902.         @shadow = bool
  903.         @outline = false unless bool == false
  904.     end
  905.     def outline=(bool)
  906.         @shadow = false unless bool == false
  907.         @outline = bool
  908.     end
  909. end
  910.  
  911. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  912. # ■ Numeric
  913. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  914. class Numeric
  915.     def group
  916.         return self.to_s unless Warrior_Engine::CORE::GROUP_DIGITS
  917.         self.to_s.gsub(/(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/,'\1,\2')
  918.     end
  919. end
  920.  
  921. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  922. # ■  Game_Battler
  923. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  924. class Game_Battler
  925.     include Warrior_Engine::CORE
  926.     def danger?;      return @hp <= ((self.maxhp * Danger_Value)/ 100); end
  927.     def death_state?; state?(DEATH_STATE_ID);                           end
  928.     def alive?;       exist? && !death_state?;                          end
  929.     def silent?;      return (!@hidden && restriction == 1);            end
  930.     def dead?        
  931.         exist? && death_state?    
  932.         return unless MP_DEATH
  933.         return ((@hp == 0 || @sp == 0) && !@immortal)
  934.     end
  935.     # ---------------------------------------------------------------------------
  936.     def half_sp_cost
  937.         return state?(HALF_MP_ID)
  938.     end
  939.     def no_sp_cost
  940.         return state?(NO_MP_ID)
  941.     end
  942.     def calc_sp_cost(skill)
  943.         half_sp_cost ? (skill.sp_cost / 2) : no_sp_cost ? (skill.sp_cost * 0) : skill.sp_cost
  944.     end
  945.     def pay_skill_cost(skill)
  946.         self.sp -= calc_sp_cost(skill)
  947.     end
  948.     # ---------------------------------------------------------------------------
  949.     def skill_can_use?(skill_id)
  950.         skill = $data_skills[skill_id]
  951.         return if skill.nil?
  952.         return false if calc_sp_cost(skill) >= sp
  953.         return false if dead?
  954.         return false if silent? && skill.spi_f == 0
  955.         if $game_temp.in_battle
  956.             return (skill.occasion == 0 || skill.occasion == 1)
  957.         else return (skill.occasion == 0 || skill.occasion == 2)
  958.         end
  959.     end
  960. end
  961.  
  962. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  963. # ■ Game_Actor
  964. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  965. class Game_Actor < Game_Battler  
  966.     def actor?
  967.         return true
  968.     end
  969.     def actor
  970.         return $data_actors[@actor_id]
  971.     end
  972.     def max_level
  973.         return actor.final_level
  974.     end
  975.     def max_level?
  976.         @level >= max_level
  977.     end
  978.     def weapons
  979.         result = [$data_weapons[@weapon_id]]
  980.         return result
  981.     end
  982.     def armors
  983.         result = []
  984.         (1..4).each {|i| eval("result << $data_armors[@armor#{i}_id]")}
  985.         return result
  986.     end
  987.     def equips;  return weapons + armors;         end
  988.     def now_exp; return @exp - @exp_list[@level]; end
  989.     def next_exp
  990.         return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  991.     end
  992.     #-----------------------------------------------------------
  993.     def hp_rate;  @hp.to_f / maxhp;                           end
  994.     def sp_rate;  maxsp > 0 ? @sp.to_f / maxsp : 0;           end
  995.     def exp_rate; next_exp > 0 ? now_exp.to_f / next_exp : 0; end
  996. end
  997.  
  998. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  999. # ■ Game_Enemy
  1000. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1001. class Game_Enemy < Game_Battler
  1002.     def actor?
  1003.         return false
  1004.     end
  1005. end
  1006.  
  1007. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1008. # ■ Game_Party
  1009. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1010. class Game_Party
  1011.     def items
  1012.         result = []
  1013.         @items.keys.sort.each {|i| result << $data_items[i] if @items[i] > 0}
  1014.         @weapons.keys.sort.each {|i| result << $data_weapons[i] if @weapons[i] > 0}
  1015.         @armors.keys.sort.each {|i| result << $data_armors[i] if @armors[i] > 0}
  1016.         return result
  1017.     end
  1018. end
  1019.  
  1020. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1021. # ■ Game_Player
  1022. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1023. class Game_Player < Game_Character
  1024.     def make_encounter_count
  1025.         return if $game_map.map_id == 0
  1026.         n = $game_map.encounter_step
  1027.         o = $game_map.encounter_step/2
  1028.         p = $game_map.encounter_step + o
  1029.         p.times {|i| @encounter_count = i}
  1030.         if @encounter_count > n + 10
  1031.             @encounter_count -= 5
  1032.             return unless @encounter_count > n + 10
  1033.             @encounter_count -= 5
  1034.             @encounter_count -= 5 if @encounter_count > n + 10
  1035.         elsif @encounter_count < n - 10
  1036.             @encounter_count += 5
  1037.             return unless @encounter_count < n - 10
  1038.             @encounter_count += 5
  1039.             @encounter_count += 5 if @encounter_count < n - 10
  1040.         end
  1041.     end
  1042. end
  1043.  
  1044. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1045. # ■ Window_Base
  1046. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1047. class Window_Base < Window
  1048.     include Warrior_Engine::CORE
  1049.     alias :ace_draw_actor_state :draw_actor_state
  1050.     def draw_text(*args);     contents.draw_text(*args);          end
  1051.     def text_size(str);       contents.text_size(str);              end
  1052.     def gradient_text(*args); contents.gradient_draw_text(*args); end
  1053.     def gauge_back_color;  return Color.new(32, 32, 64); end
  1054.     def hp_gauge_color1;   return HP_COLOR1;             end
  1055.     def hp_gauge_color2;   return HP_COLOR2;             end
  1056.     def sp_gauge_color1;   return SP_Color1;             end
  1057.     def sp_gauge_color2;   return SP_COLOR2;             end
  1058.     def exp_gauge1;              return EXP_GAUGE1;                      end
  1059.     def exp_gauge2;              return EXP_GAUGE2;                  end
  1060.     def translucent_alpha; return TRANSPARENCY;          end
  1061.     def normal_color;      return Color.normal;          end
  1062.     def disabled_color;    return Color.disabled;        end
  1063.     def system_color;      return Color.system;          end
  1064.     def crisis_color;      return Color.crisis;          end
  1065.     def knockout_color;    return Color.knockout;        end
  1066.     def hp_color(actor)
  1067.         return knockout_color if actor.hp == 0
  1068.         return crisis_color   if actor.hp < actor.maxhp * HP_CRISIS
  1069.         return normal_color
  1070.     end
  1071.     def sp_color(actor)
  1072.         return crisis_color if actor.sp < actor.maxsp * MP_CRISIS
  1073.         return normal_color
  1074.     end
  1075.     def show; self.visible = true;  self; end
  1076.     def hide; self.visible = false; self; end
  1077.     def activate;   self.active = true;  self; end
  1078.     def deactivate; self.active = false; self; end
  1079.     def line_height;       return 32;  end
  1080.     def standard_padding;  return 16;  end
  1081.     def translucent_alpha; return 160; end
  1082.     def fitting_height(line_number)
  1083.         (line_number * line_height) + (standard_padding * 2)
  1084.     end
  1085.     def draw_actor_name(actor, x, y, width = 120)
  1086.         change_color(NAME_ALERT ? hp_color(actor) : normal_color)
  1087.         draw_text(x, y, width, line_height, actor.name)
  1088.     end
  1089.     def draw_actor_hp(actor, x, y, width = 130)
  1090.         bar_y = -24 + y + (Font.default_size * 2 /3)
  1091.         if DRAW_GUAGES
  1092.             draw_gauge(x, bar_y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  1093.         end
  1094.         contents.font.size = 17
  1095.         change_color(system_color)
  1096.         draw_text(x, bar_y+12, 30, 32, $data_system.words.hp)
  1097.         draw_current_and_max_values(x, bar_y+12, width, actor.hp.group,
  1098.             actor.maxhp.group, hp_color(actor), normal_color)
  1099.         reset_font_settings
  1100.     end
  1101.     def draw_actor_sp(actor, x, y, width = 130)
  1102.         bar_y = -24 + y + (Font.default_size * 2 /3)
  1103.         if DRAW_GUAGES
  1104.             draw_gauge(x, bar_y, width, actor.sp_rate, sp_gauge_color1, sp_gauge_color2)
  1105.         end
  1106.         contents.font.size = 17
  1107.         change_color(system_color)
  1108.         draw_text(x, bar_y+12, 30, 32, $data_system.words.sp)
  1109.         draw_current_and_max_values(x, bar_y+12, width, actor.sp.group,  
  1110.             actor.maxsp.group, sp_color(actor), normal_color)
  1111.         reset_font_settings
  1112.     end
  1113.     def draw_actor_exp(actor, x, y, width = 144)
  1114.         if DRAW_GUAGES
  1115.             return draw_warrior_actor_exp(actor, x, y, width)
  1116.         else return draw_ace_actor_exp(actor, x, y, width)
  1117.         end
  1118.     end
  1119.     def draw_ace_actor_exp(actor, x, y, width = 130)
  1120.         s1 = actor.now_exp; s2 = actor.next_exp
  1121.         change_color(system_color)
  1122.         draw_text(x, y, self.width, 32, EXP_TEXT)
  1123.         dx = text_size(EXP_TEXT).width
  1124.         change_color(normal_color)
  1125.         s1 = s1.group if s1.is_a?(Integer); s2 = s2.group if s2.is_a?(Integer)
  1126.         draw_text(x + (dx*1.5), y, width, 32, "#{s1} / #{s2}", 1)
  1127.     end
  1128.     def draw_warrior_actor_exp(actor, x, y, width = 130)
  1129.         bar_y = -24 + y + (Font.default_size * 2 /3)
  1130.         draw_gauge(x, bar_y, width, actor.exp_rate, exp_gauge1, exp_gauge2)
  1131.         contents.font.size = 17
  1132.         change_color(system_color)
  1133.         draw_text(x, bar_y+12, self.width, 32, EXP_TEXT)
  1134.         change_color(normal_color)
  1135.         xr = x + width
  1136.         if actor.next_exp == 0
  1137.             text = MAX_LVL_TEXT
  1138.         else text = sprintf(EXP_PERCENT, actor.now_exp * 100.0 / actor.next_exp)
  1139.         end
  1140.         draw_text(x, bar_y+12, width, 32, text, 2)
  1141.         reset_font_settings
  1142.     end
  1143.     def draw_exp_gauge(dx, dy, dw, rate, color1, color2)
  1144.         dw += 2 if GAUGE_OUTLINE
  1145.         fill_w = (actor.next_exp == 0 ? dw : [(dw * rate).to_i, dw].min)
  1146.         warrior_guage(dx, dy, dw, rate, fill_w, color1, color2)
  1147.     end
  1148.     def draw_gauge(dx, dy, dw, rate, color1, color2)
  1149.         dw -= 2 if GAUGE_OUTLINE
  1150.         fill_w = [(dw * rate).to_i, dw].min
  1151.         warrior_guage(dx, dy, dw, rate, fill_w, color1, color2)
  1152.     end
  1153.     def warrior_guage(dx, dy, dw, rate, fill_w, color1, color2, dh = 12)
  1154.         gauge_h = dh
  1155.         gauge_y = dy + 24
  1156.         if GAUGE_OUTLINE
  1157.             outline_colour = gauge_back_color
  1158.             outline_colour.alpha = translucent_alpha
  1159.             contents.fill_rect(dx, gauge_y-1, dw+2, gauge_h+2, outline_colour)         
  1160.             dx += 1
  1161.         end
  1162.         contents.fill_rect(dx, gauge_y, dw, gauge_h, gauge_back_color)
  1163.         contents.gradient_fill_rect(dx, gauge_y, fill_w, gauge_h, color1, color2)
  1164.     end
  1165.     def draw_current_and_max_values(x, y, width, current, max, color1, color2)
  1166.         change_color(color1)
  1167.         xr = x + width
  1168.         if width < 120
  1169.             draw_text(xr - 44, y, 44, 32, current, 2)
  1170.         else
  1171.             draw_text(xr - 99, y, 44, 32, current, 2)
  1172.             change_color(color2)
  1173.             draw_text(xr - 55, y, 11, 32, "/", 2)
  1174.             draw_text(xr - 44, y, 44, 32, max, 2)
  1175.         end
  1176.     end
  1177.     def draw_actor_face(actor, x, y, size = 96)
  1178.         bitmap = RPG::Cache.picture(actor.name)
  1179.         return if bitmap.nil?
  1180.         cw, ch = bitmap.width, bitmap.height
  1181.         if size > 0
  1182.             dst_cw = dst_ch = size
  1183.         else dst_cw, dst_ch = bitmap.width, bitmap.height
  1184.         end
  1185.         dst_rect = Rect.new(x, y, dst_cw, dst_ch)
  1186.         src_rect = Rect.new(0, 0, cw, ch)
  1187.         self.contents.stretch_blt(dst_rect, bitmap, src_rect)
  1188.     end
  1189.     def draw_item_name(item, x, y, enabled = true, width = 212)
  1190.         return unless item
  1191.         draw_icon(item.icon_name, x, y + 4, enabled)
  1192.         change_color(normal_color, enabled)
  1193.         draw_text(x + 25, y, width, 32, item.name)
  1194.     end
  1195.     def draw_icon(icon_index, x, y, enabled = true)
  1196.         bitmap = RPG::Cache.icon(icon_index)
  1197.         rect = Rect.new(0, 0, 24, 24)
  1198.         self.contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  1199.     end
  1200.     def draw_actor_state(actor, x, y, width = STATE[:width])
  1201.         return ace_draw_actor_state(actor, x, y, 120) unless STATE[:image]
  1202.         count = 0
  1203.         states = actor.states.clone
  1204.         states.sort! {|a, b| $data_states[b].rating <=> $data_states[a].rating}
  1205.         states.each do |state|
  1206.             next if $data_states[state].name == 0
  1207.             draw_icon($data_states[state].name, x + 24 * count, y+4)
  1208.             count += 1
  1209.             break if (24 * count > width - 24)
  1210.         end
  1211.         reset_font_settings
  1212.     end
  1213.     def change_color(color, enabled = true)
  1214.         contents.font.color = color
  1215.         contents.font.color.alpha = translucent_alpha unless enabled
  1216.     end
  1217.     def reset_font_settings
  1218.         change_color(normal_color)
  1219.         contents.font.size          = Font.default_size
  1220.         contents.font.bold          = Font.default_bold
  1221.         contents.font.italic        = Font.default_italic
  1222.         contents.font.outline_color = Font.default_outline_color
  1223.     end
  1224.     def draw_currency_value(name, value, x, y, width)
  1225.         cx = text_size(name).width
  1226.         change_color(normal_color)
  1227.         draw_text(x, y, width-cx-2, 32, value.group, 2)
  1228.         change_color(system_color)
  1229.         draw_text(x, y, width, 32, name, 2)
  1230.     end
  1231.     def draw_item_number(item)
  1232.         case item
  1233.         when RPG::Item then number = $game_party.item_number(item.id)
  1234.         when RPG::Weapon then number = $game_party.weapon_number(item.id)
  1235.         when RPG::Armor then number = $game_party.armor_number(item.id)
  1236.         end
  1237.         return number
  1238.     end
  1239. end
  1240.  
  1241. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1242. # ■ Window_Selectable
  1243. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1244. class Window_Selectable < Window_Base
  1245.     attr_reader   :item_max                 # item count
  1246.     alias :ace_selectable_warrior_init :initialize unless $@
  1247.     def initialize(*args)
  1248.         ace_selectable_warrior_init(*args)
  1249.         @spacing = 32
  1250.     end
  1251.     def select(index); self.index = index if index; end
  1252.     def unselect;      self.index = -1;             end
  1253.     def col_max(n);    return @column_max = n;      end
  1254.     def item_rect(index)
  1255.         rect = Rect.new(0, 0, 0, 0)
  1256.         rect.width = (contents.width + @spacing) / @column_max - @spacing
  1257.         rect.height = 32
  1258.         rect.y = index / @column_max * 32
  1259.         rect.x = index % @column_max * (rect.width + @spacing)
  1260.         return rect
  1261.     end
  1262.     def item_rect_for_text(index)
  1263.         rect = item_rect(index)
  1264.         rect.x += 4
  1265.         rect.width -= 8
  1266.         return rect
  1267.     end
  1268.     def clear_item(index)
  1269.         contents.clear_rect(item_rect(index))
  1270.     end
  1271.     def index=(index)
  1272.         @index = index
  1273.         update_cursor_rect
  1274.         call_update_help
  1275.     end
  1276.     def help_window=(help_window)
  1277.         @help_window = help_window
  1278.         call_update_help
  1279.     end
  1280.     def horizontal?
  1281.         page_row_max == 1
  1282.     end
  1283.     def call_update_help
  1284.         update_help if self.active && @help_window
  1285.     end
  1286.     def update
  1287.         super
  1288.         process_cursor_move
  1289.         update_cursor_rect
  1290.         call_update_help
  1291.     end
  1292.     def cursor_movable?; self.active && @item_max > 0 && @index >= 0; end
  1293.     def process_cursor_move
  1294.         return unless cursor_movable?
  1295.         last_index = @index
  1296.         cursor_down (Input.trigger?(Input::DOWN))    if Input.repeat?(Input::DOWN)
  1297.         cursor_up   (Input.trigger?(Input::UP))    if Input.repeat?(Input::UP)
  1298.         cursor_right(Input.trigger?(Input::RIGHT)) if Input.repeat?(Input::RIGHT)
  1299.         cursor_left (Input.trigger? (Input::LEFT)) if Input.repeat?(Input::LEFT)
  1300.         cursor_pagedown if Input.repeat?(Input::R)
  1301.         cursor_pageup     if Input.repeat?(Input::L)
  1302.         $game_system.se_play($data_system.cursor_se) if @index != last_index       
  1303.     end
  1304.     def cursor_down(wrap = false)
  1305.         if (@column_max == 1 && wrap) || (@index < @item_max - @column_max)
  1306.             select((@index + @column_max) % @item_max)
  1307.         end    
  1308.     end
  1309.     def cursor_up(wrap = false)
  1310.         if (@column_max == 1 && wrap) || (@index >= @column_max)
  1311.             select((@index - @column_max + @item_max) % @item_max)
  1312.         end    
  1313.     end
  1314.     def cursor_right(wrap = false)
  1315.         if (@column_max >= 2) && (@index < @item_max - 1 || (wrap && horizontal?))
  1316.             select((@index + 1) % @item_max)
  1317.         end
  1318.     end
  1319.     def cursor_left(wrap = false)
  1320.         if (@column_max >= 2) && (@index > 0 || (wrap && horizontal?))
  1321.             select((@index - 1 + @item_max) % @item_max)
  1322.         end
  1323.     end
  1324.     def cursor_pagedown
  1325.         if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
  1326.             self.top_row += self.page_row_max
  1327.             select([@index + self.page_item_max, @item_max - 1].min)
  1328.         end
  1329.     end
  1330.     def cursor_pageup
  1331.         if self.top_row > 0
  1332.             self.top_row -= self.page_row_max
  1333.             select([@index - self.page_item_max, 0].max)
  1334.         end    
  1335.     end
  1336. end
  1337.  
  1338. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1339. # ■ Window_Gold
  1340. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1341. class Window_Gold < Window_Base
  1342.     def refresh
  1343.         contents.clear
  1344.         draw_currency_value(currency_unit, value, dx, 0, content_width)
  1345.     end
  1346.     def dx; return 4; end
  1347.     def content_width; return contents.width - 8; end
  1348.     def value; $game_party.gold; end
  1349.     def currency_unit; $data_system.words.gold; end
  1350. end
  1351.  
  1352. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1353. # ■ Window_Steps
  1354. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1355. class Window_Steps < Window_Base
  1356.     def refresh
  1357.         contents.clear
  1358.         change_color(system_color)
  1359.         draw_text(4, 0, 120, 32, currency_unit)
  1360.         change_color(normal_color)
  1361.         draw_text(4, 32, 120, 32, value.group, 2)
  1362.     end
  1363.     def value; $game_party.steps; end
  1364.     def currency_unit; "Step Count"; end
  1365. end
  1366.  
  1367. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1368. # ■ Window_Item
  1369. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1370. class Window_Item < Window_Selectable
  1371.     def enable?(item)
  1372.         item.is_a?(RPG::Item) && $game_party.item_can_use?(item.id)
  1373.     end
  1374.     def draw_item(index)
  1375.         rect = item_rect(index)
  1376.         contents.clear_rect(rect)
  1377.         item = @data[index]
  1378.         return if item.nil?
  1379.         number = draw_item_number(item)
  1380.         enabled = enable?(item)
  1381.         rect.width -= 4
  1382.         draw_item_name(item, rect.x, rect.y, enabled)
  1383.         draw_text(rect, sprintf(":%2d", number), 2)
  1384.     end
  1385. end
  1386.  
  1387. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1388. # ■ Window_Skill
  1389. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1390. class Window_Skill < Window_Selectable
  1391.     def enable?(skill)
  1392.         @actor.skill_can_use?(skill.id)
  1393.     end
  1394.     def draw_item(index)
  1395.         skill = @data[index]
  1396.         return if skill.nil?
  1397.         rect = item_rect(index)
  1398.         rect.width -= 4
  1399.         draw_item_name(skill, rect.x, rect.y, enable?(skill))
  1400.         draw_skill_cost(rect, skill)
  1401.     end
  1402.     def draw_skill_cost(rect, skill)
  1403.         return unless @actor.calc_sp_cost(skill) > 0
  1404.         colour = Color.color_between(Color.blue, Color.normal)
  1405.         change_color(colour, enable?(skill))
  1406.         cost = @actor.calc_sp_cost(skill)
  1407.         text = sprintf("%s%s", cost.group, $data_system.words.sp)
  1408.         draw_text(rect, text, 2)
  1409.         cx = text_size(text).width + 4
  1410.         rect.width -= cx
  1411.     end
  1412. end
  1413.  
  1414. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1415. # ■ Window_ShopBuy
  1416. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1417. class Window_ShopBuy < Window_Selectable
  1418.     def draw_item(index)
  1419.         item = @data[index]
  1420.         number = draw_item_number(item)
  1421.         enabled = (item.price <= $game_party.gold && number < 99)
  1422.         rect = item_rect(index)
  1423.         contents.clear_rect(rect)
  1424.         draw_item_name(item, rect.x, rect.y, enabled)
  1425.         rect.width -= 4
  1426.         draw_text(rect, item.price, 2)
  1427.     end
  1428. end
  1429.  
  1430. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1431. # ■ Window_ShopSell
  1432. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1433. unless $ace_script[:scene_shopbase]
  1434.     class Window_ShopSell < Window_Selectable
  1435.         def enable?(item)
  1436.             return (item.price > 0)
  1437.         end
  1438.         def draw_item(index)
  1439.             rect = item_rect(index)
  1440.             contents.clear_rect(rect)
  1441.             item = @data[index]
  1442.             return if item.nil?
  1443.             number = draw_item_number(item)
  1444.             enabled = enable?(item)
  1445.             rect.width -= 4
  1446.             draw_item_name(item, rect.x, rect.y, enabled)
  1447.             draw_text(rect, sprintf(":%2d", number), 2)
  1448.         end
  1449.     end
  1450. end
  1451.  
  1452. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1453. # ■ Window_BattleStatus
  1454. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1455. class Window_BattleStatus < Window_Base
  1456.     def refresh
  1457.         contents.clear
  1458.         @item_max = $game_party.actors.size
  1459.         ($game_party.actors.size).times do |i|
  1460.             actor = $game_party.actors[i]
  1461.             actor_x = i * 160 + 4
  1462.             width = 124
  1463.             contents.font.size = 18
  1464.             draw_actor_name(actor, actor_x, 0)
  1465.             draw_level_state(actor, actor_x, i)
  1466.             gx = 11
  1467.             contents.font.size = 16
  1468.             draw_actor_hp(actor, actor_x, line_height+gx, width)
  1469.             actor.skills.size.times {|i| @skill = $data_skills[actor.skills[i]]}
  1470.             draw_sp(actor, actor_x, width)
  1471.         end
  1472.     end
  1473.     def draw_sp(actor, actor_x, width)
  1474.         draw_actor_sp(actor, actor_x, line_height*2, width)
  1475.     end
  1476.     def line_height; return 24; end
  1477.     def draw_level_state(actor, x, i)
  1478.         if @level_up_flags[i]
  1479.             change_color(normal_color)
  1480.             draw_text(x, 96, 120, 32, "LEVEL UP!")
  1481.         else
  1482.             draw_actor_state(actor, x, 96)
  1483.         end    
  1484.     end
  1485.     def draw_current_and_max_values(dx, dy, dw, current, max, color1)
  1486.         change_color(color1)
  1487.         draw_text(dx, dy, dw, line_height, current.group, 2)
  1488.     end
  1489.     def draw_actor_hp(actor, dx, dy, width = 124)
  1490.         draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  1491.         change_color(system_color)
  1492.         cy = (Font.default_size - contents.font.size) / 2 + 15
  1493.         draw_text(dx+2, dy+cy, 30, 24, $data_system.words.hp)
  1494.         draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.maxhp,
  1495.             hp_color(actor))
  1496.     end
  1497.     def draw_actor_sp(actor, dx, dy, width = 124)
  1498.         draw_gauge(dx, dy, width, actor.sp_rate, sp_gauge_color1, sp_gauge_color2)
  1499.         change_color(system_color)
  1500.         cy = (Font.default_size - contents.font.size) / 2 + 15
  1501.         draw_text(dx+2, dy+cy, 30, line_height, $data_system.words.sp)
  1502.         draw_current_and_max_values(dx, dy+cy, width, actor.sp, actor.maxsp,
  1503.             sp_color(actor))
  1504.     end
  1505. end
  1506.  
  1507. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1508. # ■ Interpreter
  1509. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1510. class Interpreter
  1511.     def command_355
  1512.         script = @list[@index].parameters[0] + "\n"
  1513.         current_index = @index
  1514.         loop do
  1515.             if @list[@index+1].code == 655
  1516.                 script += @list[@index+1].parameters[0] + "\n"
  1517.             else break
  1518.             end
  1519.             @index += 1
  1520.         end
  1521.         result = eval(script)
  1522.         if Warrior_Engine::CORE::SCRIPT_WAIT_RESULTS.include?(result)
  1523.             @index = current_index
  1524.             return false
  1525.         end
  1526.         return true
  1527.     end
  1528. end
  1529.  
  1530. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1531. # ■ Scene_Skill
  1532. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1533. class Scene_Skill
  1534.     def update_target
  1535.         if Input.trigger?(Input::B)
  1536.             $game_system.se_play($data_system.cancel_se)
  1537.             @skill_window.activate
  1538.             @target_window.deactivate.hide
  1539.         elsif Input.trigger?(Input::C)
  1540.             if !@actor.skill_can_use?(@skill.id)
  1541.                 $game_system.se_play($data_system.buzzer_se)
  1542.             else determine_target
  1543.             end
  1544.         end
  1545.     end
  1546.     def determine_target
  1547.         if @target_window.index == -1
  1548.             used = false
  1549.             $game_party.actors.each {|actor| used |= i.skill_effect(@actor, @skill)}
  1550.         elsif @target_window.index <= -2
  1551.             target = $game_party.actors[@target_window.index + 10]
  1552.             used = target.skill_effect(@actor, @skill)
  1553.         elsif @target_window.index >= 0
  1554.             target = $game_party.actors[@target_window.index]
  1555.             used = target.skill_effect(@actor, @skill)
  1556.         end
  1557.         if used
  1558.             use_skill_nontarget
  1559.         else $game_system.se_play($data_system.buzzer_se)
  1560.         end
  1561.     end
  1562.     def use_skill_nontarget
  1563.         $game_system.se_play(@skill.menu_se)
  1564.         @actor.pay_skill_cost(@skill)
  1565.         @status_window.refresh
  1566.         @skill_window.refresh
  1567.         @target_window.refresh
  1568.         if $game_party.all_dead?
  1569.             $scene = Scene_Gameover.new
  1570.         elsif @skill.common_event_id > 0
  1571.             $game_temp.common_event_id = @skill.common_event_id
  1572.             $scene = Scene_Map.new
  1573.         end
  1574.     end
  1575. end
  1576.  
  1577. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  1578. # ■ Scene_Battle
  1579. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  1580. class Scene_Battle
  1581.     alias :ace_warrior_battle_end :battle_end
  1582.     def battle_end(result)
  1583.         ace_warrior_battle_end(result)
  1584.         if Warrior_Engine::CORE::HP1_REVIVE &&
  1585.             $game_party.actors.any? {|actor| actor.dead?}
  1586.             $game_party.actors.each_index do |i|
  1587.                 $game_party.actors[i].hp = 1 if $game_party.actors[i].dead?
  1588.             end
  1589.         end
  1590.     end
  1591. end
Advertisement
Add Comment
Please, Sign In to add comment