Guest User

Untitled

a guest
Jul 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.65 KB | None | 0 0
  1.  
  2. #-------------------------------------------------------------------------------
  3. #  Chrono Cross Color Field
  4. #  version 1.1
  5. #  by U-Division of ICU Gigasoft
  6. #
  7. #  What is does:
  8. #  -faithfully recreates the skill Color system from the Squaresoft
  9. #   game Chrono Cross
  10. #  -Each skill is assigned a color (or none at all) through elements,
  11. #   and whenver a skill is used it's "color" is added to the battle's
  12. #   color field. The more of a certain color there is, the more
  13. #   powerful the skill of that color becomes.  The field can hold up
  14. #   to a certain number of colors at a time
  15. #  -An extra bonus (or penalty) if the color field is completely one color
  16. #
  17. #  Installation
  18. #  -You need a CF_X.png where X is the ID of the color for every color in the
  19. #   icons folder
  20. #  -Put script above main
  21. #-------------------------------------------------------------------------------
  22.  
  23. #-------------------------------------------------------------------------------
  24. #  Color Field Battel Modifier Configuartion
  25. #-------------------------------------------------------------------------------
  26.  
  27. CF_COLOR_BONUS = 0.10
  28. #Rate of increase of power for each color the battler's
  29. #currently used skill on field. Set to 0 to disable.
  30.  
  31. CF_ANTI_PENALTY = 0.10
  32. #Rate of decrease of power for each anti-color of the battler's
  33. #currently used skill's color on field. Set to 0 to disable.
  34.  
  35. CF_FULL_BONUS = 0.50
  36. #The extra bonus given when the color of the battler's skill completely
  37. #fills the field.
  38.  
  39. CF_FULL_PENALTY = 0.50
  40. #The extra subtraction given when the anti-color of the battler's skill
  41. #completely fills the field.
  42.  
  43.  
  44.  
  45. #-------------------------------------------------------------------------------
  46. #  Color & Color Field Configuration
  47. #-------------------------------------------------------------------------------
  48. #
  49. #Using the ELEMENT ID fill out the hash like this
  50. #   CF_ELEM_COLORS = {
  51. #   element_id => color_id,
  52. #   element_id => color_id,
  53. #   ...
  54. #   }
  55. CF_ELEM_COLORS = {
  56. 17 => 0,
  57. 18 => 1,
  58. 19 => 2,
  59. 20 => 3,
  60. 21 => 4,
  61. 22 => 5,
  62. }
  63.  
  64. CF_FIELD_MAX = 6
  65. #Set this to the number of colors, or however many colors you want to be
  66. #remembered.
  67.  
  68.  
  69. #-------------------------------------------------------------------------------
  70. #  Anti Color Configuration
  71. #-------------------------------------------------------------------------------
  72. #
  73. #Using the COLOR ID (as in not the element ID) fill out the hash like this
  74. #   CF_ELEM_ANTI_COLORS = {
  75. #   color_id => anti_color_id,
  76. #   color_id => anti_color_id,
  77. #   ...
  78. #   }
  79. CF_ELEM_ANTI_COLORS = {
  80. 0 => 1,
  81. 1 => 0,
  82. 2 => 3,
  83. 3 => 2,
  84. 4 => 5,
  85. 5 => 6,
  86. }
  87.  
  88. #-------------------------------------------------------------------------------
  89. #  Special Color Effects
  90. #-------------------------------------------------------------------------------
  91. #
  92. # Using the ELEMENT ID fill out the hash like this
  93. #   CF_ELEM_SFX = {
  94. #   element_id => effect,
  95. #   element_id=> effect,
  96. #   ...
  97. #   }
  98. #
  99. #   replace "effect" with one of the following
  100. #  
  101. #   1 : sets the entire field to the color of this skill
  102. #  -1 : sets the entire field to the anti-color of this skill
  103. #   2 : adds an extra color of the skill to the field
  104. #  -2 : adds an extra anti-color of the skill to the field
  105. #   0 : resets the color field to all blank
  106. #
  107. CF_ELEM_SFX = {
  108. 23 => -1,
  109. 24 => 1,
  110. 25 => 0,
  111. 26 => -2,
  112. 27 => 2,
  113. }
  114.  
  115.  
  116. module Kernel
  117.   def CF_getColor(element_id)
  118.     id = CF_ELEM_COLORS[element_id]
  119.     id = -1 if id == nil
  120.     return id
  121.   end
  122.  
  123.   def CF_getColorFromSet(elementarray)
  124.   for element_id in elementarray
  125.     id = CF_ELEM_COLORS[element_id]
  126.     id = -1 if id == nil
  127.     return id if id != -1
  128.   end
  129.   return -1
  130.   end
  131.  
  132.   def CF_hasColor?(element_id)
  133.     return (getColor(element_id) != -1)
  134.   end
  135.  
  136.   def CF_antiColor(color)
  137.     return CF_ELEM_ANTI_COLORS[color] if CF_ELEM_ANTI_COLORS.has_key?(color)
  138.     return -1
  139.   end
  140.  
  141.   def CF_getSFXFromSet(elementarray)
  142.     sfx_array = []
  143.     for element_id in elementarray
  144.       sfx_array.push(CF_ELEM_SFX[element_id]) if CF_ELEM_SFX.has_key?(element_id)
  145.     end
  146.     return sfx_array
  147.     end
  148. end
  149.  
  150.  
  151. #-------------------------------------------------------------------------------
  152. #  RPG::Skill
  153. #  new methods:
  154. #      color(color)      :returns the skills color
  155. #      hasColor?         :returns whether or not the skill has a color
  156. #-------------------------------------------------------------------------------
  157.  
  158. module RPG
  159.   class Skill
  160.    
  161.     def color
  162.       color_elems = []
  163.       for e in element_set
  164.         color_elems.push(e) if CF_ELEM_COLORS.include?(e)
  165.       end
  166.       color_elems.push(0) if color_elems.empty?
  167.       return CF_getColor(color_elems[0])
  168.     end
  169.  
  170.     def hasColor?
  171.       return (color != -1)
  172.     end
  173.    
  174.     def special_type_skill?
  175.       effect_set = CF_getSFXFromSet(element_set)
  176.       return effect_set.include?(-2) || effect_set.include?(-1) || effect_set.include?(0)
  177.     end
  178.    
  179.     end
  180.   end
  181.  
  182. #-------------------------------------------------------------------------------
  183. #  Scene_Battle
  184. #  new methods:
  185. #      add_color(color)      :adds color to color field
  186. #      refresh_color_field   :redraws the icons
  187. #      reset_color_field     :resets color field
  188. #      color_boost(color)    :calculates the damage modifier
  189. #-------------------------------------------------------------------------------
  190.  
  191. class Scene_Battle
  192.   attr_accessor :color_set
  193.   attr_accessor :color_max
  194.   attr_accessor :active_battler
  195.  
  196. alias :_orig_main :main
  197. def main
  198.   @color_set = []
  199.   @color_max = CF_FIELD_MAX
  200.   @color_icons = Window_ColorField.new(@color_set)
  201.   _orig_main
  202.   @color_icons.dispose
  203. end
  204.  
  205. def add_color(color)
  206.   if @color_set.size == @color_max
  207.     @color_set.pop
  208.   end
  209.   @color_set.unshift(color)
  210. end
  211.  
  212. def refresh_color_field
  213.     @color_icons.refresh(@color_set)
  214. end
  215.  
  216. def reset_color_field
  217.   @color_set = []
  218.   refresh_color_field
  219. end
  220.  
  221. def set_color_field(new_color)
  222.   for i in 0 ... @color_set.size
  223.     @color_set = new_color
  224.     end
  225. end
  226.  
  227. def color_boost(color)
  228.   mod =  1.00
  229.   count = 0
  230.   anti_count = 0
  231.   anti_color = CF_antiColor(color)
  232.   return mod if @color_set == nil
  233.    for color_field in @color_set
  234.      mod += CF_COLOR_BONUS  if color_field == color
  235.      mod -= CF_ANTI_PENALTY if color_field == anti_color
  236.      count += 1 if color_field == color
  237.      count -= 1 if color_field == anti_color
  238.    end
  239.   mod += CF_FULL_BONUS if count == @color_max
  240.   mod -= CF_FULL_PENALTY if count == -@color_max
  241.   mod = 0.01 if mod < 0.01
  242.  return mod
  243. end
  244.  
  245. end
  246.  
  247. #--------------------------------------------------------------------------
  248. # Game_Battler
  249. #---------------------------------------------------------------------------
  250. class Game_Battler
  251.  
  252. #alias :elements_max_rate :elements_correct
  253. alias :_orig_elements_max_rate :elements_max_rate
  254. def elements_max_rate(element_set)
  255.   weakest = _orig_elements_max_rate(element_set)
  256.   if $scene.is_a?(Scene_Battle)
  257.     color = CF_getColorFromSet(element_set)
  258.     mod = $scene.color_boost(color)
  259.     weakest = Integer(weakest*mod)
  260.     skill_id = $scene.active_battler.action.skill_id
  261.     skill = nil
  262.     skill = $data_skills[skill_id] if skill_id > 0
  263.       if skill != nil
  264.         skill_color_field_fx(skill_id,color)
  265.       end
  266.     if skill != nil && skill.special_type_skill?
  267.     $scene.add_color(CF_antiColor(color))
  268.       else
  269.     $scene.add_color(color) if color != -1
  270.     end
  271.     $scene.refresh_color_field
  272.   end
  273.   return weakest
  274. end
  275.  
  276. def skill_color_field_fx(skill_id, color)
  277.   elem_set = $data_skills[skill_id].element_set
  278.   effect_set = CF_getSFXFromSet(elem_set)
  279.   for cfx in effect_set
  280.     cf_set(cfx,color)
  281.   end
  282. end
  283.  
  284. def cf_set(type, color)
  285.   case type
  286.   when 0
  287.     $scene.reset_color_field
  288.   when -1
  289.     if color != -1
  290.     $scene.set_color_field(CF_antiColor(color))
  291.     end
  292.   when 1
  293.     if color != -1
  294.     $scene.set_color_field(color)
  295.     end
  296.   when 2
  297.     if color != -1
  298.     $scene.add_color(color)
  299.     end
  300.   when -2
  301.     if color != -1
  302.     $scene.add_color(CF_antiColor(color))
  303.     end
  304.   end
  305.  
  306. end
  307.  
  308. end
  309.  
  310. #--------------------------------------------------------------------------
  311. # Window_ColorField
  312. #   Displays the Color icons
  313. #   CF_WINDOW_X = The X Position of the window
  314. #   CF_WINDOW_Y = The Y Position of the window
  315. #--------------------------------------------------------------------------
  316.  
  317. class Window_ColorField < Window_Base
  318.  
  319.   CF_WINDOW_X = 0 #Default is 0
  320.   CF_WINDOW_Y = 0 #Default is 0
  321.  
  322.   #--------------------------------------------------------------------------
  323.   # * Object Initialization
  324.   #--------------------------------------------------------------------------
  325.   def initialize(color_set)
  326.     super(CF_WINDOW_X, CF_WINDOW_Y, 640, 64)
  327.     self.contents = Bitmap.new(width - 32, height - 32)
  328.     self.opacity = 0
  329.     self.z -= 10
  330.     refresh(color_set)
  331.   end
  332.  
  333.   #--------------------------------------------------------------------------
  334.   # * Tambahan RoronoaZ
  335.   #--------------------------------------------------------------------------
  336.   def
  337.     @gambar = Sprite.new
  338.     @gambar.bitmap = Cache.picture("BulletBG")
  339.     @gambar.x = 0
  340.     @gambar.y = 0
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # * Refresh
  344.   #--------------------------------------------------------------------------
  345.   def refresh(color_set)
  346.     self.contents.clear
  347.     return if color_set == nil
  348.      count = 0
  349.       for i in color_set
  350.        color_image = "CF_" + i.to_s
  351.        bitmap = Cache.picture(color_image)
  352.        self.contents.blt(x + count*24, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  353.        count += 1
  354.      end
  355.   end
  356. end
Add Comment
Please, Sign In to add comment