Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #==============================================================================
  2. # ** Victor Engine - Basic Module
  3. #------------------------------------------------------------------------------
  4. # Author : Victor Sant
  5. #
  6. # Version History:
  7. #  v 1.00 - 2011.12.19 > First release
  8. #  v 1.01 - 2011.12.21 > Added Event Troop notes
  9. #  v 1.02 - 2011.12.22 > Added character frames value
  10. #  v 1.03 - 2011.12.30 > Added Actor and Enemy notes
  11. #  v 1.04 - 2012.01.01 > Added party average level and map actors
  12. #  v 1.05 - 2012.01.04 > Compatibility with Characters Scripts
  13. #  v 1.06 - 2012.01.07 > Compatibility with Fog and Light Effect
  14. #                      > Added new Sprite Character functions
  15. #  v 1.07 - 2012.01.11 > Compatibility with Control Text and Codes
  16. #  v 1.08 - 2012.01.13 > Compatibility with Trait Control
  17. #  v 1.09 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”
  18. #  v 1.10 - 2012.01.18 > Compatibility with Automatic Battlers
  19. #  v 1.11 - 2012.01.26 > Compatibility with Followers Options
  20. #                        Compatibility with Animated Battle beta
  21. #  v 1.12 - 2012.02.08 > Compatibility with Animated Battle
  22. #  v 1.13 - 2012.02.18 > Fix for non RTP dependant encrypted projects
  23. #  v 1.14 - 2012.03.11 > Better version handling and required messages
  24. #  v 1.15 - 2012.03.11 > Added level variable for enemies (to avoid crashes)
  25. #  v 1.16 - 2012.03.21 > Compatibility with Follower Control
  26. #  v 1.17 - 2012.03.22 > Compatibility with Follower Control new method
  27. #  v 1.18 - 2012.03.22 > Added Battler Types tag support
  28. #  v 1.19 - 2012.05.20 > Compatibility with Map Turn Battle
  29. #  v 1.20 - 2012.05.21 > Fix for older RMVXa versions
  30. #  v 1.21 - 2012.05.29 > Compatibility with Pixel Movement
  31. #  v 1.22 - 2012.07.02 > Compatibility with Terrain States
  32. #  v 1.23 - 2012.07.03 > Fix for Pixel Movement
  33. #  v 1.24 - 2012.07.17 > Compatibility with Critical Hit Effects
  34. #  v 1.25 - 2012.07.24 > Compatibility with Moving Plaforms
  35. #  v 1.26 - 2012.07.30 > Compatibility with Automatic Battlers
  36. #  v 1.27 - 2012.08.01 > Compatibility with Custom Slip Effect
  37. #  v 1.28 - 2012.08.01 > Compatibility with Custom Slip Effect v 1.01
  38. #  v 1.29 - 2012.11.03 > Fixed returning value division by 0 error.
  39. #  v 1.30 - 2012.12.13 > Compatibility with State Graphics
  40. #  v 1.31 - 2012.12.16 > Compatibility with Active Time Battle
  41. #  v 1.32 - 2012.12.24 > Compatibility with Active Time Battle v 1.01
  42. #  v 1.33 - 2012.12.30 > Compatibility with Leap Attack
  43. #  v 1.34 - 2013.01.07 > Compatibility with Critical Hit Effects v 1.01
  44. #  v 1.35 - 2013.02.13 > Compatibility with Cooperation Skills
  45. #------------------------------------------------------------------------------
  46. #   This is the basic script for the system from Victory Engine and is
  47. # required to use the scripts from the engine. This script offer some new
  48. # functions to be used within many scripts of the engine.
  49. #------------------------------------------------------------------------------
  50. # Compatibility
  51. #   Required for the Victor Engine
  52. #
  53. # * Overwrite methods
  54. #   class << Cache
  55. #     def self.character(filename)
  56. #
  57. #   class Sprite_Character < Sprite_Base
  58. #     def set_character_bitmap
  59. #
  60. #   class Game_Battler < Game_BattlerBase
  61. #     def item_effect_recover_hp(user, item, effect)
  62. #     def item_effect_recover_mp(user, item, effect)
  63. #     def item_effect_gain_tp
  64. #
  65. # * Alias methods
  66. #   class Game_Interpreter
  67. #     def command_108
  68. #
  69. #   class Window_Base < Window
  70. #     def convert_escape_characters(text)
  71. #
  72. #------------------------------------------------------------------------------
  73. # Instructions:
  74. #  To instal the script, open you script editor and paste this script on
  75. #  a new section bellow the Materials section.
  76. #
  77. #------------------------------------------------------------------------------
  78. # New functions
  79. #
  80. # * Random number between two vales
  81. #   rand_between(min, max)
  82. #    min : min value
  83. #    max : max value
  84. #   Can be called from any class, this method return an random value between
  85. #   two specific numbers
  86. #
  87. # * Random array value
  88. #   <Array>.random
  89. #   <Array>.random!
  90. #   Returns a random object from the array, the method .random! is destructive,
  91. #   removing the value returned from the array.
  92. #
  93. # * Sum of the numeric values of a array
  94. #   <Array>.sum
  95. #   Returns the sum of all numeric values
  96. #
  97. # * Average of all numeric values from the array
  98. #   <Array>.average(float = false)
  99. #    float : float flag
  100. #   Returns the average of all numeric values, if floa is true, the value
  101. #   returned is a float, otherwise it's a integer.
  102. #
  103. # * Note for events
  104. #   <Event>.note
  105. #   By default, events doesn't have note boxes. This command allows to use
  106. #   comments as note boxes, following the same format as the ones on the
  107. #   database. Returns all comments on the active page of the event.
  108. #
  109. # * Comment calls
  110. #   <Event>.comment_call
  111. #   Another function for comment boxes, by default, they have absolutely no
  112. #   effect in game when called. But this method allows to make the comment
  113. #   box to behave like an script call, but with the versatility of the
  114. #   note boxes. Remember that the commands will only take effect if there
  115. #   is scripts to respond to the comment code.
  116. #
  117. #==============================================================================
  118.  
  119. #==============================================================================
  120. # ** Victor Engine
  121. #------------------------------------------------------------------------------
  122. #   Setting module for the Victor Engine
  123. #==============================================================================
  124.  
  125. module Victor_Engine
  126.   #--------------------------------------------------------------------------
  127.   # * New method: required_script
  128.   #--------------------------------------------------------------------------
  129.   def self.required_script(name, req, version, type = 0)
  130.     if type != :bellow && (!$imported[req] || $imported[req] < version)
  131.       msg = "The script '%s' requires the script\n"
  132.       case type
  133.       when :above
  134.         msg += "'%s' v%s or higher above it to work properly\n"
  135.       else
  136.         msg += "'%s' v%s or higher to work properly\n"
  137.       end
  138.       msg += "Go to http://victorenginescripts.wordpress.com/ to download this script."
  139.       self.exit_message(msg, name, req, version)
  140.     elsif type == :bellow && $imported[req]
  141.       msg =  "The script '%s' requires the script\n"
  142.       msg += "'%s' to be put bellow it\n"
  143.       msg += "move the scripts to the proper position"
  144.       self.exit_message(msg, name, req, version)
  145.     end
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # * New method: exit_message
  149.   #--------------------------------------------------------------------------
  150.   def self.exit_message(message, name, req, version)
  151.     name = self.script_name(name)
  152.     req  = self.script_name(req)
  153.     msgbox(sprintf(message, name, req, version))
  154.     exit
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # * New method: script_name
  158.   #--------------------------------------------------------------------------
  159.   def self.script_name(name, ext = "VE")
  160.     name = name.to_s.gsub("_", " ").upcase.split
  161.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  162.     name.join(" ")
  163.   end
  164. end
  165.  
  166. $imported ||= {}
  167. $imported[:ve_basic_module] = 1.35
  168.  
  169. #==============================================================================
  170. # ** Object
  171. #------------------------------------------------------------------------------
  172. #  This class is the superclass of all other classes.
  173. #==============================================================================
  174.  
  175. class Object
  176.   #--------------------------------------------------------------------------
  177.   # * Include setting module
  178.   #--------------------------------------------------------------------------
  179.   include Victor_Engine
  180.   #-------------------------------------------------------------------------
  181.   # * New method: rand_between
  182.   #-------------------------------------------------------------------------
  183.   def rand_between(min, max)
  184.     min + rand(max - min + 1)
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # * New method: numeric?
  188.   #--------------------------------------------------------------------------
  189.   def numeric?
  190.     return false
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # * New method: string?
  194.   #--------------------------------------------------------------------------
  195.   def string?
  196.     return false
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # * New method: array?
  200.   #--------------------------------------------------------------------------
  201.   def array?
  202.     return false
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # * New method: float?
  206.   #--------------------------------------------------------------------------
  207.   def float?
  208.     return false
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # * New method: symbol?
  212.   #--------------------------------------------------------------------------
  213.   def symbol?
  214.     return false
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # * New method: item?
  218.   #--------------------------------------------------------------------------
  219.   def item?
  220.     return false
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # * New method: skill?
  224.   #--------------------------------------------------------------------------
  225.   def skill?
  226.     return false
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # * New method: file_exist?
  230.   #--------------------------------------------------------------------------
  231.   def file_exist?(path, filename)
  232.     $file_list ||= {}
  233.     $file_list[path + filename] ||= file_test(path, filename)
  234.     $file_list[path + filename]
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * New method: get_file_list
  238.   #--------------------------------------------------------------------------
  239.   def file_test(path, filename)
  240.     bitmap = Cache.load_bitmap(path, filename) rescue nil
  241.     bitmap ? true : false
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # * New method: character_exist?
  245.   #--------------------------------------------------------------------------
  246.   def character_exist?(filename)
  247.     file_exist?("Graphics/Characters/", filename)
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # * New method: battler_exist?
  251.   #--------------------------------------------------------------------------
  252.   def battler_exist?(filename)
  253.     file_exist?("Graphics/Battlers/", filename)
  254.   end
  255.   #--------------------------------------------------------------------------
  256.   # * New method: face_exist?
  257.   #--------------------------------------------------------------------------
  258.   def face_exist?(filename)
  259.     file_exist?("Graphics/Faces/", filename)
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # * New method: get_filename
  263.   #--------------------------------------------------------------------------
  264.   def get_filename
  265.     "[\"'“‘]([^\"'”‘”’]+)[\"'”’]"
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # * New method: get_all_values
  269.   #--------------------------------------------------------------------------
  270.   def get_all_values(value1, value2 = nil)
  271.     value2 = value1 unless value2
  272.     /<#{value1}>((?:[^<]|<[^\/])*)<\/#{value2}>/im
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # * New method: make_symbol
  276.   #--------------------------------------------------------------------------
  277.   def make_symbol(string)
  278.     string.downcase.gsub(" ", "_").to_sym
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # * New method: make_string
  282.   #--------------------------------------------------------------------------
  283.   def make_string(symbol)
  284.     symbol.to_s.gsub("_", " ").upcase
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # * New method: returning_value
  288.   #--------------------------------------------------------------------------
  289.   def returning_value(i, x)
  290.     y = [x * 2, 1].max
  291.     i % y  >= x ? (x * 2) - i % y : i % y
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # New method: in_rect?
  295.   #--------------------------------------------------------------------------
  296.   def in_rect?(w, h, x1, y1, x2, y2, fx = 0)
  297.     aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  298.     bx > ax - aw && bx < ax + aw && by > ay - ah && by < ay + ah
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # New method: in_radius?
  302.   #--------------------------------------------------------------------------
  303.   def in_radius?(w, h, x1, y1, x2, y2, fx = 0)
  304.     aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
  305.     ((bx - ax) ** 2 / aw ** 2) + ((by - ay) ** 2 / ah ** 2) <= 1
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # New method: setup_area
  309.   #--------------------------------------------------------------------------
  310.   def setup_area(w, h, x1, y1, x2, y2, fx)
  311.     aw = w
  312.     ah = h * aw
  313.     ax = x1
  314.     ay = y1
  315.     bx = x2
  316.     by = y2
  317.     bx += fx / 4 if ax > bx
  318.     bx -= fx / 4 if ax < bx
  319.     [aw, ah, ax, ay, bx, by]
  320.   end
  321.   #--------------------------------------------------------------------------
  322.   # * New method: get_param_id
  323.   #--------------------------------------------------------------------------
  324.   def get_param_id(text)
  325.     case text.upcase
  326.     when "MAXHP", "HP" then 0
  327.     when "MAXMP", "MP" then 1
  328.     when "ATK" then 2
  329.     when "DEF" then 3
  330.     when "MAT" then 4
  331.     when "MDF" then 5
  332.     when "AGI" then 6
  333.     when "LUK" then 7
  334.     end
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # * New method: get_param_text
  338.   #--------------------------------------------------------------------------
  339.   def get_param_text(id)
  340.     case id
  341.     when 0 then "HP"
  342.     when 1 then "MP"
  343.     when 2 then "ATK"
  344.     when 3 then "DEF"
  345.     when 4 then "MAT"
  346.     when 5 then "MDF"
  347.     when 6 then "AGI"
  348.     when 7 then "LUK"
  349.     end
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # * New method: get_xparam_id
  353.   #--------------------------------------------------------------------------
  354.   def get_xparam_id(text)
  355.     case text.upcase
  356.     when "HIT" then 0
  357.     when "EVA" then 1
  358.     when "CRI" then 2
  359.     when "CEV" then 3
  360.     when "MEV" then 4
  361.     when "MRF" then 5
  362.     when "CNT" then 6
  363.     when "HRG" then 7
  364.     when "MRG" then 8
  365.     when "TRG" then 9
  366.     end
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # * New method: get_xparam_text
  370.   #--------------------------------------------------------------------------
  371.   def get_xparam_text(id)
  372.     case id
  373.     when 0 then "HIT"
  374.     when 1 then "EVA"
  375.     when 2 then "CRI"
  376.     when 3 then "CEV"
  377.     when 4 then "MEV"
  378.     when 5 then "MRF"
  379.     when 6 then "CNT"
  380.     when 7 then "HRG"
  381.     when 8 then "MRG"
  382.     when 9 then "TRG"
  383.     end
  384.   end
  385.   #--------------------------------------------------------------------------
  386.   # * New method: get_sparam_id
  387.   #--------------------------------------------------------------------------
  388.   def get_sparam_id(text)
  389.     case text.upcase
  390.     when "TGR" then 0
  391.     when "GRD" then 1
  392.     when "REC" then 2
  393.     when "PHA" then 3
  394.     when "MCR" then 4
  395.     when "TCR" then 5
  396.     when "PDR" then 6
  397.     when "MDR" then 7
  398.     when "FDR" then 8
  399.     when "EXR" then 9
  400.     end
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # * New method: get_sparam_text
  404.   #--------------------------------------------------------------------------
  405.   def get_sparam_text(id)
  406.     case id
  407.     when 0 then "TGR"
  408.     when 1 then "GRD"
  409.     when 2 then "REC"
  410.     when 3 then "PHA"
  411.     when 4 then "MCR"
  412.     when 5 then "TCR"
  413.     when 6 then "PDR"
  414.     when 7 then "MDR"
  415.     when 8 then "FDR"
  416.     when 9 then "EXR"
  417.     end
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # * New method: get_cond
  421.   #--------------------------------------------------------------------------
  422.   def get_cond(text)
  423.     case text.upcase
  424.     when "HIGHER"    then ">"
  425.     when "LOWER"     then "<"
  426.     when "EQUAL"     then "=="
  427.     when "DIFFERENT" then "!="
  428.     else "!="
  429.     end
  430.   end
  431. end
  432.  
  433. #==============================================================================
  434. # ** String
  435. #------------------------------------------------------------------------------
  436. #  The string class. Can handle character sequences of arbitrary lengths.
  437. #==============================================================================
  438.  
  439. class String
  440.   #--------------------------------------------------------------------------
  441.   # * New method: string?
  442.   #--------------------------------------------------------------------------
  443.   def string?
  444.     return true
  445.   end
  446. end
  447.  
  448. #==============================================================================
  449. # ** String
  450. #------------------------------------------------------------------------------
  451. #  The class that represents symbols.
  452. #==============================================================================
  453.  
  454. class Symbol
  455.   #--------------------------------------------------------------------------
  456.   # * New method: symbol?
  457.   #--------------------------------------------------------------------------
  458.   def symbol?
  459.     return true
  460.   end
  461. end
  462.  
  463. #==============================================================================
  464. # ** Numeric
  465. #------------------------------------------------------------------------------
  466. #  This is the abstract class for numbers.
  467. #==============================================================================
  468.  
  469. class Numeric
  470.   #--------------------------------------------------------------------------
  471.   # * New method: numeric?
  472.   #--------------------------------------------------------------------------
  473.   def numeric?
  474.     return true
  475.   end
  476.   #--------------------------------------------------------------------------
  477.   # * New method: ceil?
  478.   #--------------------------------------------------------------------------
  479.   def ceil?
  480.     return false
  481.   end
  482.   #--------------------------------------------------------------------------
  483.   # * New method: to_ceil
  484.   #--------------------------------------------------------------------------
  485.   def to_ceil
  486.     self > 0 ? self.abs.ceil : -self.abs.ceil
  487.   end
  488. end
  489.  
  490. #==============================================================================
  491. # ** Float
  492. #------------------------------------------------------------------------------
  493. #  This is the abstract class for the floating point values.
  494. #==============================================================================
  495.  
  496. class Float
  497.   #--------------------------------------------------------------------------
  498.   # * New method: float?
  499.   #--------------------------------------------------------------------------
  500.   def float?
  501.     return true
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # * New method: ceil?
  505.   #--------------------------------------------------------------------------
  506.   def ceil?
  507.     self != self.ceil
  508.   end
  509. end
  510.  
  511. #==============================================================================
  512. # ** Array    
  513. #------------------------------------------------------------------------------
  514. #  This class store arbitrary Ruby objects.
  515. #==============================================================================
  516.  
  517. class Array
  518.   #--------------------------------------------------------------------------
  519.   # * New method: array?
  520.   #--------------------------------------------------------------------------
  521.   def array?
  522.     return true
  523.   end
  524.   #-------------------------------------------------------------------------
  525.   # * New method: random
  526.   #-------------------------------------------------------------------------
  527.   def random
  528.     self[rand(size)]
  529.   end
  530.   #-------------------------------------------------------------------------
  531.   # * New method: random!
  532.   #-------------------------------------------------------------------------
  533.   def random!
  534.     self.delete_at(rand(size))
  535.   end
  536.   #---------------------------------------------------------------------------
  537.   # * New method: sum
  538.   #---------------------------------------------------------------------------
  539.   def sum
  540.     self.inject(0) {|r, n| r += (n.numeric? ? n : 0)}
  541.   end
  542.   #---------------------------------------------------------------------------
  543.   # * New method: average
  544.   #---------------------------------------------------------------------------
  545.   def average(float = false)
  546.     self.sum / [(float ? size.to_f : size.to_i), 1].max
  547.   end
  548.   #---------------------------------------------------------------------------
  549.   # * New method: next_item
  550.   #---------------------------------------------------------------------------
  551.   def next_item
  552.     item = self.shift
  553.     self.push(item)
  554.     item
  555.   end
  556.   #---------------------------------------------------------------------------
  557.   # * New method: previous_item
  558.   #---------------------------------------------------------------------------
  559.   def previous_item
  560.     item = self.pop
  561.     self.unshift(item)
  562.     item
  563.   end
  564. end
  565.  
  566. #==============================================================================
  567. # ** RPG::Troop::Page
  568. #------------------------------------------------------------------------------
  569. #  This is the data class for battle events (pages).
  570. #==============================================================================
  571.  
  572. class RPG::Troop::Page
  573.   #--------------------------------------------------------------------------
  574.   # * New method: note
  575.   #--------------------------------------------------------------------------
  576.   def note
  577.     return "" if !@list || @list.size <= 0
  578.     comment_list = []
  579.     @list.each do |item|
  580.       next unless item && (item.code == 108 || item.code == 408)
  581.       comment_list.push(item.parameters[0])
  582.     end
  583.     comment_list.join("\r\n")
  584.   end
  585. end
  586.  
  587. #==============================================================================
  588. # ** RPG::UsableItem
  589. #------------------------------------------------------------------------------
  590. #  This is the superclass for skills and items.
  591. #==============================================================================
  592.  
  593. class RPG::UsableItem < RPG::BaseItem
  594.   #--------------------------------------------------------------------------
  595.   # * New method: for_all_targets?
  596.   #--------------------------------------------------------------------------
  597.   def for_all_targets?
  598.     return false
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # * New method: element_set
  602.   #--------------------------------------------------------------------------
  603.   def element_set
  604.     [damage.element_id]
  605.   end
  606. end
  607.  
  608. #==============================================================================
  609. # ** RPG::Skill
  610. #------------------------------------------------------------------------------
  611. #  This is the data class for skills.
  612. #==============================================================================
  613.  
  614. class RPG::Skill < RPG::UsableItem
  615.   #--------------------------------------------------------------------------
  616.   # * New method: item?
  617.   #--------------------------------------------------------------------------
  618.   def item?
  619.     return false
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # * New method: skill?
  623.   #--------------------------------------------------------------------------
  624.   def skill?
  625.     return true
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   # * New method: type_set
  629.   #--------------------------------------------------------------------------
  630.   def type_set
  631.     [stype_id]
  632.   end  
  633. end
  634.  
  635. #==============================================================================
  636. # ** RPG::Item
  637. #------------------------------------------------------------------------------
  638. #  This is the data class for items.
  639. #==============================================================================
  640.  
  641. class RPG::Item < RPG::UsableItem
  642.   #--------------------------------------------------------------------------
  643.   # * New method: item?
  644.   #--------------------------------------------------------------------------
  645.   def item?
  646.     return true
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # * New method: skill?
  650.   #--------------------------------------------------------------------------
  651.   def skill?
  652.     return false
  653.   end
  654.   #--------------------------------------------------------------------------
  655.   # * New method: type_set
  656.   #--------------------------------------------------------------------------
  657.   def type_set
  658.     [itype_id]
  659.   end
  660. end
  661.  
  662. #==============================================================================
  663. # ** Cache
  664. #------------------------------------------------------------------------------
  665. #  This module loads each of graphics, creates a Bitmap object, and retains it.
  666. # To speed up load times and conserve memory, this module holds the created
  667. # Bitmap object in the internal hash, allowing the program to return
  668. # preexisting objects when the same bitmap is requested again.
  669. #==============================================================================
  670.  
  671. class << Cache
  672.   #--------------------------------------------------------------------------
  673.   # * Overwrite method: character
  674.   #--------------------------------------------------------------------------
  675.   def character(filename, hue = 0)
  676.     load_bitmap("Graphics/Characters/", filename, hue)
  677.   end
  678.   #--------------------------------------------------------------------------
  679.   # * New method: cache
  680.   #--------------------------------------------------------------------------
  681.   def cache
  682.     @cache
  683.   end
  684. end
  685.  
  686. #==============================================================================
  687. # ** BattleManager
  688. #------------------------------------------------------------------------------
  689. #  This module handles the battle processing
  690. #==============================================================================
  691.  
  692. class << BattleManager
  693.   #--------------------------------------------------------------------------
  694.   # * New method: all_battle_members
  695.   #--------------------------------------------------------------------------
  696.   def all_battle_members
  697.     $game_party.members + $game_troop.members
  698.   end
  699.   #--------------------------------------------------------------------------
  700.   # * New method: all_dead_members
  701.   #--------------------------------------------------------------------------
  702.   def all_dead_members
  703.     $game_party.dead_members + $game_troop.dead_members
  704.   end
  705.   #--------------------------------------------------------------------------
  706.   # * New method: all_movable_members
  707.   #--------------------------------------------------------------------------
  708.   def all_movable_members
  709.     $game_party.movable_members + $game_troop.movable_members
  710.   end
  711. end
  712.  
  713. #==============================================================================
  714. # ** Game_BattlerBase
  715. #------------------------------------------------------------------------------
  716. #  This class handles battlers. It's used as a superclass of the Game_Battler
  717. # classes.
  718. #==============================================================================
  719.  
  720. class Game_BattlerBase
  721.   #--------------------------------------------------------------------------
  722.   # * Public Instance Variables
  723.   #--------------------------------------------------------------------------
  724.   attr_reader   :buffs
  725.   #--------------------------------------------------------------------------
  726.   # * New method: get_param
  727.   #--------------------------------------------------------------------------
  728.   def get_param(text)
  729.     case text.upcase
  730.     when "MAXHP" then self.mhp
  731.     when "MAXMP" then self.mmp
  732.     when "MAXTP" then self.max_tp
  733.     else eval("self.#{text.downcase}")
  734.     end
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # * New method: type
  738.   #--------------------------------------------------------------------------
  739.   def type
  740.     list = []
  741.     get_all_notes.scan(/<BATTLER TYPE: ((?:\w+ *,? *)+)>/i) do
  742.       $1.scan(/(\d+)/i) { list.push(make_symbol($1)) }
  743.     end
  744.     list.uniq
  745.   end
  746.   #--------------------------------------------------------------------------
  747.   # * New method: danger?
  748.   #--------------------------------------------------------------------------
  749.   def danger?
  750.     hp < mhp * 25 / 100
  751.   end
  752.   #--------------------------------------------------------------------------
  753.   # * New method: sprite
  754.   #--------------------------------------------------------------------------
  755.   def sprite
  756.     valid = SceneManager.scene_is?(Scene_Battle) && SceneManager.scene.spriteset
  757.     valid ? SceneManager.scene.spriteset.sprite(self) : nil
  758.   end
  759.   #--------------------------------------------------------------------------
  760.   # * New method: element_set
  761.   #--------------------------------------------------------------------------
  762.   def element_set(item)
  763.     element_set  = item.element_set
  764.     element_set += atk_elements if item.damage.element_id < 0
  765.     element_set.delete(0)
  766.     element_set.compact
  767.   end
  768.   #--------------------------------------------------------------------------
  769.   # * New method: add_state_normal
  770.   #--------------------------------------------------------------------------
  771.   def add_state_normal(state_id, rate = 1, user = self)
  772.     chance  = rate
  773.     chance *= state_rate(state_id)
  774.     chance *= luk_effect_rate(user)
  775.     add_state(state_id) if rand < chance
  776.   end
  777.   #--------------------------------------------------------------------------
  778.   # * New method: damaged?
  779.   #--------------------------------------------------------------------------
  780.   def damaged?
  781.     @result.hp_damage != 0 || @result.mp_damage != 0 || @result.tp_damage != 0
  782.   end
  783.   #--------------------------------------------------------------------------
  784.   # * New method: mtp
  785.   #--------------------------------------------------------------------------
  786.   def mtp
  787.     return 100
  788.   end
  789. end
  790.  
  791. #==============================================================================
  792. # ** Game_Battler
  793. #------------------------------------------------------------------------------
  794. #  This class deals with battlers. It's used as a superclass of the Game_Actor
  795. # and Game_Enemy classes.
  796. #==============================================================================
  797.  
  798. class Game_Battler < Game_BattlerBase
  799.   #--------------------------------------------------------------------------
  800.   # * Overwrite method: item_effect_recover_hp
  801.   #--------------------------------------------------------------------------
  802.   def item_effect_recover_hp(user, item, effect)
  803.     value = item_value_recover_hp(user, item, effect).to_i
  804.     @result.hp_damage -= value
  805.     @result.success    = true
  806.     self.hp += value
  807.   end
  808.   #--------------------------------------------------------------------------
  809.   # * Overwrite method: item_effect_recover_mp
  810.   #--------------------------------------------------------------------------
  811.   def item_effect_recover_mp(user, item, effect)
  812.     value = item_value_recover_mp(user, item, effect).to_i
  813.     @result.mp_damage -= value
  814.     @result.success    = true if value != 0
  815.     self.mp += value
  816.   end
  817.   #--------------------------------------------------------------------------
  818.   # * Overwrite method: item_effect_gain_tp
  819.   #--------------------------------------------------------------------------
  820.   def item_effect_gain_tp(user, item, effect)
  821.     value    = item_value_recover_tp(user, item, effect)
  822.     self.tp += value
  823.   end
  824.   #--------------------------------------------------------------------------
  825.   # * New method: item_value_recover_hp
  826.   #--------------------------------------------------------------------------
  827.   def item_value_recover_hp(user, item, effect)
  828.     value  = (mhp * effect.value1 + effect.value2) * rec
  829.     value *= user.pha if item.is_a?(RPG::Item)
  830.     value
  831.   end
  832.   #--------------------------------------------------------------------------
  833.   # * New method: item_value_recover_mp
  834.   #--------------------------------------------------------------------------
  835.   def item_value_recover_mp(user, item, effect)
  836.     value  = (mmp * effect.value1 + effect.value2) * rec
  837.     value *= user.pha if item.is_a?(RPG::Item)
  838.     value
  839.   end
  840.   #--------------------------------------------------------------------------
  841.   # * New method: item_value_recover_tp
  842.   #--------------------------------------------------------------------------
  843.   def item_value_recover_tp(user, item, effect)
  844.     effect.value1.to_i
  845.   end
  846.   #--------------------------------------------------------------------------
  847.   # * New method: cri_rate
  848.   #--------------------------------------------------------------------------
  849.   def cri_rate(user, item)
  850.     user.cri
  851.   end
  852.   #--------------------------------------------------------------------------
  853.   # * New method: cri_eva
  854.   #--------------------------------------------------------------------------
  855.   def cri_eva(user, item)
  856.     cev
  857.   end
  858.   #--------------------------------------------------------------------------
  859.   # * New method: setup_critical
  860.   #--------------------------------------------------------------------------
  861.   def setup_critical(user, item)
  862.     cri_rate(user, item) * (1 - cri_eva(user, item))
  863.   end
  864. end
  865.  
  866. #==============================================================================
  867. # ** Game_Enemy
  868. #------------------------------------------------------------------------------
  869. #  This class handles enemy characters. It's used within the Game_Troop class
  870. # ($game_troop).
  871. #==============================================================================
  872.  
  873. class Game_Enemy < Game_Battler
  874.   #--------------------------------------------------------------------------
  875.   # * New method: id
  876.   #--------------------------------------------------------------------------
  877.   def id
  878.     @enemy_id
  879.   end
  880.   #--------------------------------------------------------------------------
  881.   # * New method: note
  882.   #--------------------------------------------------------------------------
  883.   def note
  884.     enemy ? enemy.note : ""
  885.   end
  886.   #--------------------------------------------------------------------------
  887.   # * New method: get_all_notes
  888.   #--------------------------------------------------------------------------
  889.   def get_all_notes(*args)
  890.     notes  = ""
  891.     notes += note if !args.include?(:self)
  892.     states.compact.each {|state| notes += state.note } if !args.include?(:state)
  893.     notes
  894.   end
  895.   #--------------------------------------------------------------------------
  896.   # * New method: get_all_objects
  897.   #--------------------------------------------------------------------------
  898.   def get_all_objects(*args)
  899.     result = []
  900.     result += [self] if !args.include?(:self)
  901.     result += states.compact if !args.include?(:state)
  902.     result
  903.   end
  904.   #--------------------------------------------------------------------------
  905.   # * New method: level
  906.   #--------------------------------------------------------------------------
  907.   def level
  908.     return 1
  909.   end
  910.   #--------------------------------------------------------------------------
  911.   # * New method: skill_learn?
  912.   #--------------------------------------------------------------------------
  913.   def skill_learn?(skill)
  914.     skill.skill? && skills.include?(skill)
  915.   end
  916.   #--------------------------------------------------------------------------
  917.   # * New method: skills
  918.   #--------------------------------------------------------------------------
  919.   def skills
  920.     (enemy_actions | added_skills).sort.collect {|id| $data_skills[id] }
  921.   end
  922.   #--------------------------------------------------------------------------
  923.   # * New method: enemy_actions
  924.   #--------------------------------------------------------------------------
  925.   def enemy_actions
  926.     enemy.actions.collect {|action| action.skill_id }
  927.   end
  928. end
  929.  
  930. #==============================================================================
  931. # ** Game_Actor
  932. #------------------------------------------------------------------------------
  933. #  This class handles actors. It's used within the Game_Actors class
  934. # ($game_actors) and referenced by the Game_Party class ($game_party).
  935. #==============================================================================
  936.  
  937. class Game_Actor < Game_Battler
  938.   #--------------------------------------------------------------------------
  939.   # * New method: note
  940.   #--------------------------------------------------------------------------
  941.   def note
  942.     actor ? actor.note : ""
  943.   end
  944.   #--------------------------------------------------------------------------
  945.   # * New method: hue
  946.   #--------------------------------------------------------------------------
  947.   def hue
  948.     @hue ? @hue : 0
  949.   end
  950.   #--------------------------------------------------------------------------
  951.   # * New method: get_all_notes
  952.   #--------------------------------------------------------------------------
  953.   def get_all_notes(*args)
  954.     notes = ""
  955.     notes += note if !args.include?(:self)
  956.     notes += self.class.note if !args.include?(:class)
  957.     equips.compact.each {|equip| notes += equip.note } if !args.include?(:equip)
  958.     states.compact.each {|state| notes += state.note } if !args.include?(:state)
  959.     notes
  960.   end
  961.   #--------------------------------------------------------------------------
  962.   # * New method: get_all_objects
  963.   #--------------------------------------------------------------------------
  964.   def get_all_objects(*args)
  965.     result = []
  966.     result += [self] if !args.include?(:self)
  967.     result += [self.class]   if !args.include?(:class)
  968.     result += equips.compact if !args.include?(:equip)
  969.     result += states.compact if !args.include?(:state)
  970.     result
  971.   end
  972.   #--------------------------------------------------------------------------
  973.   # * New method: in_active_party?
  974.   #--------------------------------------------------------------------------
  975.   def in_active_party?
  976.     $game_party.battle_members.include?(self)
  977.   end
  978.   #--------------------------------------------------------------------------
  979.   # * New method: in_reserve_party?
  980.   #--------------------------------------------------------------------------
  981.   def in_reserve_party?
  982.     $game_party.reserve_members.include?(self)
  983.   end
  984.   #--------------------------------------------------------------------------
  985.   # * New method: in_party?
  986.   #--------------------------------------------------------------------------
  987.   def in_party?
  988.     $game_party.all_members.include?(self)
  989.   end
  990.   #--------------------------------------------------------------------------
  991.   # * New method: map_animation
  992.   #--------------------------------------------------------------------------
  993.   def map_animation(id)
  994.     $game_map.actors.each do |member|
  995.       member.animation_id = id if member.actor == self
  996.     end
  997.   end
  998.   #--------------------------------------------------------------------------
  999.   # * New method: on_damage_floor
  1000.   #--------------------------------------------------------------------------
  1001.   def on_damage_floor?
  1002.     $game_player.on_damage_floor?
  1003.   end
  1004. end
  1005.  
  1006. #==============================================================================
  1007. # ** Game_Unit
  1008. #------------------------------------------------------------------------------
  1009. #  This class handles units. It's used as a superclass of the Game_Party and
  1010. # Game_Troop classes.
  1011. #==============================================================================
  1012.  
  1013. class Game_Unit
  1014.   #--------------------------------------------------------------------------
  1015.   # * New method: refresh
  1016.   #--------------------------------------------------------------------------
  1017.   def refresh
  1018.     members.each {|member| member.refresh }
  1019.   end
  1020. end
  1021.  
  1022. #==============================================================================
  1023. # ** Game_Party
  1024. #------------------------------------------------------------------------------
  1025. #  This class handles the party. It includes information on amount of gold
  1026. # and items. The instance of this class is referenced by $game_party.
  1027. #==============================================================================
  1028.  
  1029. class Game_Party < Game_Unit
  1030.   #--------------------------------------------------------------------------
  1031.   # * New method: average_level
  1032.   #--------------------------------------------------------------------------
  1033.   def average_level
  1034.     battle_members.collect {|actor| actor.level }.average
  1035.   end
  1036.   #--------------------------------------------------------------------------
  1037.   # * New method: reserve_members
  1038.   #--------------------------------------------------------------------------
  1039.   def reserve_members
  1040.     all_members - battle_members
  1041.   end
  1042. end
  1043.  
  1044. #==============================================================================
  1045. # ** Game_Map
  1046. #------------------------------------------------------------------------------
  1047. #  This class handles maps. It includes scrolling and passage determination
  1048. # functions. The instance of this class is referenced by $game_map.
  1049. #==============================================================================
  1050.  
  1051. class Game_Map
  1052.   #--------------------------------------------------------------------------
  1053.   # * New method: event_list
  1054.   #--------------------------------------------------------------------------
  1055.   def event_list
  1056.     events.values
  1057.   end
  1058.   #--------------------------------------------------------------------------
  1059.   # * New method: note
  1060.   #--------------------------------------------------------------------------
  1061.   def note
  1062.     @map ? @map.note : ""
  1063.   end
  1064.   #--------------------------------------------------------------------------
  1065.   # * New method: vehicles
  1066.   #--------------------------------------------------------------------------
  1067.   def vehicles
  1068.     @vehicles
  1069.   end
  1070.   #--------------------------------------------------------------------------
  1071.   # * New method: map_events
  1072.   #--------------------------------------------------------------------------
  1073.   def map_events
  1074.     @map.events
  1075.   end
  1076.   #--------------------------------------------------------------------------
  1077.   # * New method: actors
  1078.   #--------------------------------------------------------------------------
  1079.   def actors
  1080.     [$game_player] + $game_player.followers.visible_followers
  1081.   end
  1082. end
  1083.  
  1084. #==============================================================================
  1085. # ** Game_CharacterBase
  1086. #------------------------------------------------------------------------------
  1087. #  This class deals with characters. Common to all characters, stores basic
  1088. # data, such as coordinates and graphics. It's used as a superclass of the
  1089. # Game_Character class.
  1090. #==============================================================================
  1091.  
  1092. class Game_CharacterBase
  1093.   #--------------------------------------------------------------------------
  1094.   # * Public Instance Variables
  1095.   #--------------------------------------------------------------------------
  1096.   attr_accessor :move_speed
  1097.   attr_accessor :move_frequency
  1098.   #--------------------------------------------------------------------------
  1099.   # * New method: player?
  1100.   #--------------------------------------------------------------------------
  1101.   def player?
  1102.     return false
  1103.   end
  1104.   #--------------------------------------------------------------------------
  1105.   # * New method: event?
  1106.   #--------------------------------------------------------------------------
  1107.   def event?
  1108.     return false
  1109.   end
  1110.   #--------------------------------------------------------------------------
  1111.   # * New method: follower?
  1112.   #--------------------------------------------------------------------------
  1113.   def follower?
  1114.     return false
  1115.   end
  1116.   #--------------------------------------------------------------------------
  1117.   # * New method: vehicle?
  1118.   #--------------------------------------------------------------------------
  1119.   def vehicle?
  1120.     return false
  1121.   end
  1122.   #--------------------------------------------------------------------------
  1123.   # * New method: frames
  1124.   #--------------------------------------------------------------------------
  1125.   def frames
  1126.     return 3
  1127.   end
  1128.   #--------------------------------------------------------------------------
  1129.   # * New method: hue
  1130.   #--------------------------------------------------------------------------
  1131.   def hue
  1132.     @hue ? @hue : 0
  1133.   end
  1134. end
  1135.  
  1136. #==============================================================================
  1137. # ** Game_Character
  1138. #------------------------------------------------------------------------------
  1139. #  This class deals with characters. It's used as a superclass of the
  1140. # Game_Player and Game_Event classes.
  1141. #==============================================================================
  1142.  
  1143. class Game_Character < Game_CharacterBase
  1144.   #--------------------------------------------------------------------------
  1145.   # * New method: move_toward_position
  1146.   #--------------------------------------------------------------------------
  1147.   def move_toward_position(x, y)
  1148.     sx = distance_x_from(x)
  1149.     sy = distance_y_from(y)
  1150.     if sx.abs > sy.abs
  1151.       move_straight(sx > 0 ? 4 : 6)
  1152.       move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
  1153.     elsif sy != 0
  1154.       move_straight(sy > 0 ? 8 : 2)
  1155.       move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
  1156.     end
  1157.   end
  1158.   #--------------------------------------------------------------------------
  1159.   # * New method: move_toward_position
  1160.   #--------------------------------------------------------------------------
  1161.   def turn_toward_position(x, y)
  1162.     sx = distance_x_from(x)
  1163.     sy = distance_y_from(y)
  1164.     if sx.abs > sy.abs
  1165.       set_direction(sx > 0 ? 4 : 6)
  1166.     elsif sy != 0
  1167.       set_direction(sy > 0 ? 8 : 2)
  1168.     end
  1169.   end
  1170. end
  1171.  
  1172. #==============================================================================
  1173. # ** Game_Player
  1174. #------------------------------------------------------------------------------
  1175. #  This class handles the player.
  1176. # The instance of this class is referenced by $game_map.
  1177. #==============================================================================
  1178.  
  1179. class Game_Player < Game_Character
  1180.   #--------------------------------------------------------------------------
  1181.   # * New method: player?
  1182.   #--------------------------------------------------------------------------
  1183.   def player?
  1184.     return true
  1185.   end
  1186.   #--------------------------------------------------------------------------
  1187.   # * New method: perform_transfer
  1188.   #--------------------------------------------------------------------------
  1189.   def new_map_id
  1190.     @new_map_id
  1191.   end
  1192.   #--------------------------------------------------------------------------
  1193.   # * New method: hue
  1194.   #--------------------------------------------------------------------------
  1195.   def hue
  1196.     actor ? actor.hue : 0
  1197.   end
  1198. end
  1199.  
  1200. #==============================================================================
  1201. # ** Game_Follower
  1202. #------------------------------------------------------------------------------
  1203. #  This class handles the followers. Followers are the actors of the party
  1204. # that follows the leader in a line. It's used within the Game_Followers class.
  1205. #==============================================================================
  1206.  
  1207. class Game_Follower < Game_Character
  1208.   #--------------------------------------------------------------------------
  1209.   # * New method: follower?
  1210.   #--------------------------------------------------------------------------
  1211.   def follower?
  1212.     return true
  1213.   end
  1214.   #--------------------------------------------------------------------------
  1215.   # * New method: index
  1216.   #--------------------------------------------------------------------------
  1217.   def index
  1218.     @member_index
  1219.   end
  1220.   #--------------------------------------------------------------------------
  1221.   # * New method: gathering?
  1222.   #--------------------------------------------------------------------------
  1223.   def gathering?
  1224.     $game_player.followers.gathering? && !gather?
  1225.   end
  1226. end
  1227.  
  1228. #==============================================================================
  1229. # ** Game_Followers
  1230. #------------------------------------------------------------------------------
  1231. #  This class handles the followers. It's a wrapper for the built-in class
  1232. # "Array." It's used within the Game_Player class.
  1233. #==============================================================================
  1234.  
  1235. class Game_Followers
  1236.   #--------------------------------------------------------------------------
  1237.   # * New method: get_actor
  1238.   #--------------------------------------------------------------------------
  1239.   def get_actor(id)
  1240.     list = [$game_player] + visible_followers
  1241.     list.select {|follower| follower.actor && follower.actor.id == id }.first
  1242.   end
  1243.   #--------------------------------------------------------------------------
  1244.   # * Method fix: visble_folloers
  1245.   #--------------------------------------------------------------------------
  1246.   unless method_defined?(:visible_followers)
  1247.     def visible_followers; visible_folloers; end
  1248.   end
  1249. end
  1250.  
  1251. #==============================================================================
  1252. # ** Game_Vehicle
  1253. #------------------------------------------------------------------------------
  1254. #  This class handles vehicles. It's used within the Game_Map class. If there
  1255. # are no vehicles on the current map, the coordinates is set to (-1,-1).
  1256. #==============================================================================
  1257.  
  1258. class Game_Vehicle < Game_Character
  1259.   #--------------------------------------------------------------------------
  1260.   # * New method: vehicle?
  1261.   #--------------------------------------------------------------------------
  1262.   def vehicle?
  1263.     return true
  1264.   end
  1265.   #--------------------------------------------------------------------------
  1266.   # * New method: map_id
  1267.   #--------------------------------------------------------------------------
  1268.   def map_id
  1269.     @map_id
  1270.   end
  1271.   #--------------------------------------------------------------------------
  1272.   # * New method: type
  1273.   #--------------------------------------------------------------------------
  1274.   def type
  1275.     @type
  1276.   end
  1277.   #--------------------------------------------------------------------------
  1278.   # * New method: aerial?
  1279.   #--------------------------------------------------------------------------
  1280.   def aerial?
  1281.     type == :airship
  1282.   end
  1283.   #--------------------------------------------------------------------------
  1284.   # * New method: above?
  1285.   #--------------------------------------------------------------------------
  1286.   def above?
  1287.     aerial?
  1288.   end
  1289. end
  1290.  
  1291. #==============================================================================
  1292. # ** Game_Event
  1293. #------------------------------------------------------------------------------
  1294. #  This class deals with events. It handles functions including event page
  1295. # switching via condition determinants, and running parallel process events.
  1296. # It's used within the Game_Map class.
  1297. #==============================================================================
  1298.  
  1299. class Game_Event < Game_Character
  1300.   #--------------------------------------------------------------------------
  1301.   # * New method: name
  1302.   #--------------------------------------------------------------------------
  1303.   def name
  1304.     @event.name
  1305.   end
  1306.   #--------------------------------------------------------------------------
  1307.   # * New method: event?
  1308.   #--------------------------------------------------------------------------
  1309.   def event?
  1310.     return true
  1311.   end
  1312.   #--------------------------------------------------------------------------
  1313.   # * New method: erased?
  1314.   #--------------------------------------------------------------------------
  1315.   def erased?
  1316.     @erased
  1317.   end
  1318.   #--------------------------------------------------------------------------
  1319.   # * New method: note
  1320.   #--------------------------------------------------------------------------
  1321.   def note
  1322.     return ""     if !@page || !@page.list || @page.list.size <= 0
  1323.     return @notes if @notes && @page.list == @note_page
  1324.     @note_page = @page.list.dup
  1325.     comment_list = []
  1326.     @page.list.each do |item|
  1327.       next unless item && (item.code == 108 || item.code == 408)
  1328.       comment_list.push(item.parameters[0])
  1329.     end
  1330.     @notes = comment_list.join("\r\n")
  1331.     @notes
  1332.   end  
  1333. end
  1334.  
  1335. #==============================================================================
  1336. # ** Game_Interpreter
  1337. #------------------------------------------------------------------------------
  1338. #  An interpreter for executing event commands. This class is used within the
  1339. # Game_Map, Game_Troop, and Game_Event classes.
  1340. #==============================================================================
  1341.  
  1342. class Game_Interpreter
  1343.   #--------------------------------------------------------------------------
  1344.   # * Alias method: command_108
  1345.   #--------------------------------------------------------------------------
  1346.   alias :command_108_ve_basic_module :command_108
  1347.   def command_108
  1348.     command_108_ve_basic_module
  1349.     comment_call
  1350.   end
  1351.   #--------------------------------------------------------------------------
  1352.   # * New method: comment_call
  1353.   #--------------------------------------------------------------------------
  1354.   def comment_call
  1355.   end
  1356.   #--------------------------------------------------------------------------
  1357.   # * New method: note
  1358.   #--------------------------------------------------------------------------
  1359.   def note
  1360.     @comments ? @comments.join("\r\n") : ""
  1361.   end
  1362. end
  1363.  
  1364. #==============================================================================
  1365. # ** Game_Animation
  1366. #------------------------------------------------------------------------------
  1367. #  Classe that handles Animation data
  1368. #==============================================================================
  1369.  
  1370. class Game_Animation
  1371.   #--------------------------------------------------------------------------
  1372.   # * Public Instance Variables
  1373.   #--------------------------------------------------------------------------
  1374.   attr_accessor :ox
  1375.   attr_accessor :oy
  1376.   attr_accessor :rate
  1377.   attr_accessor :zoom
  1378.   attr_accessor :loop
  1379.   attr_accessor :type
  1380.   attr_accessor :map_x
  1381.   attr_accessor :map_y
  1382.   attr_accessor :mirror
  1383.   attr_accessor :follow
  1384.   attr_accessor :height
  1385.   attr_accessor :bitmap1
  1386.   attr_accessor :bitmap2
  1387.   attr_accessor :sprites
  1388.   attr_accessor :duration
  1389.   attr_accessor :direction
  1390.   attr_accessor :duplicated
  1391.   #--------------------------------------------------------------------------
  1392.   # * New method: initialize
  1393.   #--------------------------------------------------------------------------
  1394.   def initialize(animation, mirror, user = nil)
  1395.     @animation = animation
  1396.     @rate      = animation.name =~ /<RATE: ([+-]?\d+)>/i ? [$1.to_i, 1].max : 4
  1397.     @zoom      = animation.name =~ /<ZOOM: (\d+)%?>/i ? $1.to_i / 100.0 : 1.0
  1398.     @follow    = animation.name =~ /<FOLLOW>/i ? true : false
  1399.     @mirror    = mirror
  1400.     @duration  = frame_max * @rate
  1401.     @direction = user.anim_direction if user
  1402.     @sprites   = []
  1403.     bellow     = animation.name =~ /<BELLOW>/i
  1404.     above      = animation.name =~ /<ABOVE>/i
  1405.     @height    = bellow ? -1 : above ? 300 : 1
  1406.   end
  1407.   #--------------------------------------------------------------------------
  1408.   # * New method: data
  1409.   #--------------------------------------------------------------------------  
  1410.   def data
  1411.     @animation
  1412.   end
  1413.   #--------------------------------------------------------------------------
  1414.   # * New method: id
  1415.   #--------------------------------------------------------------------------  
  1416.   def id
  1417.     @animation.id
  1418.   end
  1419.   #--------------------------------------------------------------------------
  1420.   # * New method: name
  1421.   #--------------------------------------------------------------------------  
  1422.   def name
  1423.     @animation.name
  1424.   end
  1425.   #--------------------------------------------------------------------------
  1426.   # * New method: frame_max
  1427.   #--------------------------------------------------------------------------
  1428.   def frame_max
  1429.     @animation.frame_max
  1430.   end
  1431.   #--------------------------------------------------------------------------
  1432.   # * New method: position
  1433.   #--------------------------------------------------------------------------
  1434.   def position
  1435.     @animation.position
  1436.   end
  1437.   #--------------------------------------------------------------------------
  1438.   # * New method: animation1_name
  1439.   #--------------------------------------------------------------------------
  1440.   def animation1_name
  1441.     @animation.animation1_name
  1442.   end
  1443.   #--------------------------------------------------------------------------
  1444.   # * New method: animation2_name
  1445.   #--------------------------------------------------------------------------
  1446.   def animation2_name
  1447.     @animation.animation2_name
  1448.   end
  1449.   #--------------------------------------------------------------------------
  1450.   # * New method: animation1_hue
  1451.   #--------------------------------------------------------------------------
  1452.   def animation1_hue
  1453.     @animation.animation1_hue
  1454.   end
  1455.   #--------------------------------------------------------------------------
  1456.   # * New method: animation2_hue
  1457.   #--------------------------------------------------------------------------
  1458.   def animation2_hue
  1459.     @animation.animation2_hue
  1460.   end
  1461.   #--------------------------------------------------------------------------
  1462.   # * New method: frames
  1463.   #--------------------------------------------------------------------------
  1464.   def frames
  1465.     @animation.frames
  1466.   end
  1467.   #--------------------------------------------------------------------------
  1468.   # * New method: timings
  1469.   #--------------------------------------------------------------------------
  1470.   def timings
  1471.     @animation.timings
  1472.   end
  1473. end
  1474.  
  1475. #==============================================================================
  1476. # ** Sprite_Character
  1477. #------------------------------------------------------------------------------
  1478. #  This sprite is used to display characters. It observes a instance of the
  1479. # Game_Character class and automatically changes sprite conditions.
  1480. #==============================================================================
  1481.  
  1482. class Sprite_Character < Sprite_Base
  1483.   #--------------------------------------------------------------------------
  1484.   # * Overwrite method: set_character_bitmap
  1485.   #--------------------------------------------------------------------------
  1486.   def set_character_bitmap
  1487.     update_character_info
  1488.     set_bitmap
  1489.     set_bitmap_position
  1490.   end
  1491.   #--------------------------------------------------------------------------
  1492.   # * New method: center_y
  1493.   #--------------------------------------------------------------------------
  1494.   def actor?
  1495.     @character.is_a?(Game_Player) || @character.is_a?(Game_Follower)
  1496.   end
  1497.   #--------------------------------------------------------------------------
  1498.   # * New method: center_y
  1499.   #--------------------------------------------------------------------------
  1500.   def actor
  1501.     actor? ? @character.actor : nil
  1502.   end
  1503.   #--------------------------------------------------------------------------
  1504.   # * New method: update_character_info
  1505.   #--------------------------------------------------------------------------
  1506.   def update_character_info
  1507.   end
  1508.   #--------------------------------------------------------------------------
  1509.   # * New method: hue
  1510.   #--------------------------------------------------------------------------
  1511.   def hue
  1512.     @character.hue
  1513.   end
  1514.   #--------------------------------------------------------------------------
  1515.   # * New method: set_bitmap
  1516.   #--------------------------------------------------------------------------
  1517.   def set_bitmap
  1518.     self.bitmap = Cache.character(set_bitmap_name, hue)
  1519.   end
  1520.   #--------------------------------------------------------------------------
  1521.   # * New method: set_bitmap_name
  1522.   #--------------------------------------------------------------------------
  1523.   def set_bitmap_name
  1524.     @character_name
  1525.   end
  1526.   #--------------------------------------------------------------------------
  1527.   # * New method: set_bitmap_position
  1528.   #--------------------------------------------------------------------------
  1529.   def set_bitmap_position
  1530.     sign = get_sign
  1531.     if sign && sign.include?('$')
  1532.       @cw = bitmap.width / @character.frames
  1533.       @ch = bitmap.height / 4
  1534.     else
  1535.       @cw = bitmap.width / (@character.frames * 4)
  1536.       @ch = bitmap.height / 8
  1537.     end
  1538.     self.ox = @cw / 2
  1539.     self.oy = @ch
  1540.   end
  1541.   #--------------------------------------------------------------------------
  1542.   # * New method: get_sign
  1543.   #--------------------------------------------------------------------------
  1544.   def get_sign
  1545.     @character_name[/^[\!\$]./]
  1546.   end
  1547. end
  1548.  
  1549. #==============================================================================
  1550. # ** Sprite_Battler
  1551. #------------------------------------------------------------------------------
  1552. #  This sprite is used to display battlers. It observes a instance of the
  1553. # Game_Battler class and automatically changes sprite conditions.
  1554. #==============================================================================
  1555.  
  1556. class Sprite_Battler < Sprite_Base
  1557.   #--------------------------------------------------------------------------
  1558.   # * Public Instance Variables
  1559.   #--------------------------------------------------------------------------
  1560.   attr_accessor :dmg_mirror
  1561.   #--------------------------------------------------------------------------
  1562.   # * New method: center_x
  1563.   #--------------------------------------------------------------------------
  1564.   def center_x
  1565.     self.ox
  1566.   end
  1567.   #--------------------------------------------------------------------------
  1568.   # * New method: center_y
  1569.   #--------------------------------------------------------------------------
  1570.   def center_y
  1571.     self.oy / 2
  1572.   end
  1573. end
  1574.  
  1575. #==============================================================================
  1576. # ** Spriteset_Battle
  1577. #------------------------------------------------------------------------------
  1578. #  This class brings together battle screen sprites. It's used within the
  1579. # Scene_Battle class.
  1580. #==============================================================================
  1581.  
  1582. class Spriteset_Battle
  1583.   #--------------------------------------------------------------------------
  1584.   # * Public Instance Variables
  1585.   #--------------------------------------------------------------------------
  1586.   attr_reader   :viewport1
  1587.   #--------------------------------------------------------------------------
  1588.   # * New method: sprite
  1589.   #--------------------------------------------------------------------------
  1590.   def sprite(subject)
  1591.     battler_sprites.compact.select {|sprite| sprite.battler == subject }.first
  1592.   end
  1593. end
  1594.  
  1595. #==============================================================================
  1596. # ** Window_Base
  1597. #------------------------------------------------------------------------------
  1598. #  This is a superclass of all windows in the game.
  1599. #==============================================================================
  1600.  
  1601. class Window_Base < Window
  1602.   #--------------------------------------------------------------------------
  1603.   # * Alias method: convert_escape_characters
  1604.   #--------------------------------------------------------------------------
  1605.   alias :convert_escape_ve_basic_module :convert_escape_characters
  1606.   def convert_escape_characters(text)
  1607.     result = text.to_s.clone
  1608.     result = text_replace(result)
  1609.     result = convert_escape_ve_basic_module(text)
  1610.     result
  1611.   end
  1612.   #--------------------------------------------------------------------------
  1613.   # * New method: text_replace
  1614.   #--------------------------------------------------------------------------
  1615.   def text_replace(result)
  1616.     result.gsub!(/\r/) { "" }
  1617.     result.gsub!(/\\/) { "\e" }
  1618.     result
  1619.   end
  1620. end
  1621.  
  1622. #==============================================================================
  1623. # ** Scene_Battle
  1624. #------------------------------------------------------------------------------
  1625. #  This class performs battle screen processing.
  1626. #==============================================================================
  1627.  
  1628. class Scene_Battle < Scene_Base
  1629.   #--------------------------------------------------------------------------
  1630.   # * Public Instance Variables
  1631.   #--------------------------------------------------------------------------
  1632.   attr_reader   :subject
  1633.   attr_reader   :spriteset
  1634. end
  1635.  
  1636. #==============================================================================
  1637. # ** Scene_Battle
  1638. #------------------------------------------------------------------------------
  1639. #  This class performs map screen processing.
  1640. #==============================================================================
  1641.  
  1642. class Scene_Map < Scene_Base
  1643.   #--------------------------------------------------------------------------
  1644.   # * Public Instance Variables
  1645.   #--------------------------------------------------------------------------
  1646.   attr_reader   :spriteset
  1647. end