neonblack

Djinn System v1.1b

Jan 14th, 2013
943
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##-----------------------------------------------------------------------------
  2. ## Djinn System v1.1b
  3. ## Created by Neon Black
  4. ##
  5. ## Only for non-commercial use.  See full terms of use and contact info at:
  6. ## http://cphouseset.wordpress.com/liscense-and-terms-of-use/
  7. ##----------------------------------------------------------------------------##
  8.                                                                               ##
  9. ##----------------------------------------------------------------------------##
  10. ##    Revision Info:
  11. ## v1.1b - 8.19.2013
  12. ##  Fixed a small issue with djinn equip types
  13. ## v1.1a - 6.16.2013
  14. ##  Fixed an issue related to equip item parameters
  15. ## v1.1 - 1.20.2013
  16. ##  Addressed some lag issues
  17. ##  Added SE for a djinn ending cooldown on the map
  18. ## v1.0a - 1.14.2013
  19. ##  Minor changes related to CPBE
  20. ## v1.0 - 1.8.2013
  21. ##  Wrote and debugged main script
  22. ##----------------------------------------------------------------------------##
  23.                                                                               ##
  24. $imported = {} if $imported.nil?                                              ##
  25. $imported["CP_DJINN"] = 1.1                                                   ##
  26.                                                                               ##
  27. ##----------------------------------------------------------------------------##
  28. ##    Instructions:
  29. ## Place this script in the script editor below "Materials" and above "Main".
  30. ## This scipt allows you to make either weapons or armour that act as djinn
  31. ## similar to the djinn system from Golden Sun.  These djinn can be added or
  32. ## removed from the party just like any other item using the event commands and
  33. ## pretty much act like any normal piece of equipment while equipped.
  34. ##
  35. ## This script has 2 script call commands that can be used to give the party
  36. ## new "summons" similar to the summons that use djinn from Golden Sun as well
  37. ## as a few tags used by both skills and equips to set summons and djinn.
  38. ##
  39. ##    Tags:
  40. ## <fire djinn 80>
  41. ##  - Used to tag weapons or armour and cause them to become djinn.  The number
  42. ##    is the skill that is used when the djinn is "released" in battle.  The
  43. ##    word "fire" is the djinn's element.  Elements are defined in the config
  44. ##    section.  Check there for more info on elements.
  45. ##
  46. ## <summon> -and- </summon>
  47. ##  - Used to tag a skill and cause it to become a summon.  Summon skills will
  48. ##    appear in the summon skill menu as long as the party is able to use the
  49. ##    skill.  Between these two tags you would place the djinn element and a
  50. ##    number to tell the script what elements are required to use the skill.
  51. ##    Example of a skill that requires 2 fire djinn and 1 water djinn:
  52. ##
  53. ##       <summon>
  54. ##       2 fire
  55. ##       1 water
  56. ##       </summon>
  57. ##
  58. ##    Script Calls:
  59. ## add_djinn_summon(4)
  60. ##  - Adds summon skill with an id of "4" to the list of summons.  If the skill
  61. ##    is not tagged with the tags above, it will not appear in the list.
  62. ##
  63. ## remove_djinn_summon(4)
  64. ##  - Removes the summon skill with the id of "4".  Any number can be used on
  65. ##    both of these script calls.
  66. ##
  67. ##    Command Tags:
  68. ## If you are using CP's Battle Engine version 1.2 or higher, you will need to
  69. ## add command tags to allow the djinn and djinn summon commands to work.
  70. ## These tags may be added to ABILITIES hash in the script, or in the command
  71. ## block in actor/class notetags.  The commands are as follows:
  72. ##
  73. ##   <commands>
  74. ##   :djinn
  75. ##   :djinn_summon
  76. ##   </commands>
  77. ##
  78. ## :djinn
  79. ##  - Adds the djinn command to the actor's command window.
  80. ## :djinn_summon
  81. ##  - Adds the djinn summon command to the actor's command window.
  82. ##
  83. ##----------------------------------------------------------------------------##
  84.                                                                               ##
  85. module CP    # Do not touch                                                   ##
  86. module DJINN #  these lines.                                                  ##
  87.                                                                               ##
  88. ##----------------------------------------------------------------------------##
  89. ##    Config:
  90. ## The config options are below.  You can set these depending on the flavour of
  91. ## your game.  Each option is explained in a bit more detail above it.
  92. ##
  93. ##------
  94.  
  95. # If this is set to true, djinn are taken from the list of weapons.  If this is
  96. # set to false, djinn are taken from the list of armours.
  97. DJINN_WEAPONS = false
  98.  
  99. # The elements and the associated icon IDs.  Element names are used by every
  100. # aspect of the game.  These are NOT case sensative and as such, both "FIRE"
  101. # and "fire" would mean the same thing.  Icon IDs are used by the floating
  102. # djinn box in battle and nowhere else.  Make sure each element is set up
  103. # properly to avoid errors.
  104. ELEMENTS ={
  105.  
  106. # "Name"  => ID,
  107.   "Fire"  => 187,
  108.   "Ice"   => 188,
  109.   "Earth" => 189,
  110.   "Light" => 190,
  111.  
  112. }
  113.  
  114. # These are the names of the Djinn and Summon commands in battle and the Djinn
  115. # option in the main menu.
  116. DJINN_COMM = "Djinn"
  117. SUMMON_COMM = "Summon"
  118. MENU_NAME = "Djinn"
  119.  
  120. # This string is the text that appears on the floating djinn box above where
  121. # the icons of the free djinn are displayed.
  122. DJINN_BOX = "Free Djinn"
  123.  
  124. # These are the battle log strings that appear when certain actions are
  125. # performed in battle.  You can use the tags <djinn> and <actor> in them to
  126. # display the name of the djinn or person related to the djinn.
  127. RELEASE_DJINN = '<actor> releases <djinn>!'
  128. EQUIP_DJINN = '<djinn> was set back to <actor>.'
  129. SUMMON_FAIL = 'But there were not enough Djinn....'
  130.  
  131. # These are the texts to display when the help box is displayed in CPBE v1.2 or
  132. # higher.  Remember that you can use \n for a new line.
  133. DJINN_HELP = "Release a djinn to activate it's special effect."
  134. SUMMON_HELP = "Use standby djinn to summon a powerful entity."
  135.  
  136. # This is the animation played when a djinn on cooldown is re-equipped to a
  137. # player in battle.  If a viewed battle system is used, this /should/ display
  138. # the animation itself, otherwise, just the sounds are played.
  139. EQUIP_ANIM = 107
  140.  
  141. # This is the SE that plays when a djinn is re-equipped while walking around on
  142. # the map.  The second value is the volume and the third value is the pitch.
  143. EQUIP_SE = ["Saint9", 80, 100]
  144.  
  145. # The number of turns a djinn remains on standby after being used for a summon.
  146. # Base turns is the number of turns the first djinn of each element takes to
  147. # come off of cooldown.  Added turn is added to the base turns for each
  148. # additional djinn of an element to be used.  For example, if several fire
  149. # djinn are used for a summon, the first one would be on cooldown for 2 turns,
  150. # the second for 3, the third for 4, etc.  Finally, step turns is the number of
  151. # steps required outside of battle to reduce the cooldown by 1 turn.
  152. BASE_TURNS = 2
  153. ADDED_TURN = 1
  154. STEP_TURNS = 20
  155.  
  156. # The height of character sprites.  This is used by the djinn scene in the main
  157. # menu.  If you are using sprites taller than the default sprites, this value
  158. # will need to be increased.
  159. CHARA_HEIGHT = 32
  160.  
  161. # The base summons the party has at the start of the game.  Place each ID in
  162. # followed by a comma.
  163. BASE_SUMMONS = [128, 129, 130, 131, 132, 133, 134, 135]
  164.  
  165. ##----------------------------------------------------------------------------##
  166.                                                                               ##
  167.                                                                               ##
  168. ##----------------------------------------------------------------------------##
  169. ## The following lines are the actual core code of the script.  While you are
  170. ## certainly invited to look, modifying it may result in undesirable results.
  171. ## Modify at your own risk!
  172. ###----------------------------------------------------------------------------
  173.  
  174.  
  175. ## Used to get the base arrays for skills and djinn items.
  176. def self.summons
  177.   temp = $data_skills.select {|s| next unless s; s.summon?}
  178.   return temp.select {|s| $game_system.d_summon_ids.include?(s.id)}
  179. end
  180.  
  181. def self.djinn_base
  182.   return DJINN_WEAPONS ? $data_weapons : $data_armors
  183. end
  184.  
  185. SUMMONRS = /<summon>/i
  186. SUMMONRE = /<\/summon>/i
  187. SUMMONTC = /(\d+) (.+)/i
  188. DJINNID  = /<(.+) djinn (\d+)>/i
  189.  
  190. end
  191. end
  192.  
  193. ## Creates djinn type items and summons.
  194. class RPG::Skill < RPG::UsableItem
  195.   def summon?
  196.     get_summon_djinn if @summon.nil?
  197.     return @summon
  198.   end
  199.  
  200.   def djinn_cost
  201.     get_summon_djinn if @djinn.nil?
  202.     return @djinn
  203.   end
  204.  
  205.   def get_summon_djinn
  206.     @summon = false; @djinn = {}
  207.     stag = false
  208.     self.note.split(/[\r\n]+/).each do |line|
  209.       case line
  210.       when CP::DJINN::SUMMONRS
  211.         @summon = true
  212.         stag = true
  213.       when CP::DJINN::SUMMONTC
  214.         next unless stag
  215.         @djinn[$2.to_s.downcase] = $1.to_i
  216.       when CP::DJINN::SUMMONRE
  217.         break
  218.       end
  219.     end
  220.   end
  221. end
  222.  
  223. class RPG::BaseItem
  224.   def djinn?
  225.     return false unless self.is_a?(CP::DJINN::DJINN_WEAPONS ? RPG::Weapon : RPG::Armor)
  226.     get_djinn_state if @djinn_id.nil?
  227.     return @djinn_id > 0 || @djinn_type != "CP"
  228.   end
  229.  
  230.   def djinn_id
  231.     get_djinn_state if @djinn_id.nil?
  232.     return @djinn_id
  233.   end
  234.  
  235.   def djinn_type
  236.     get_djinn_state if @djinn_type.nil?
  237.     return @djinn_type
  238.   end
  239.  
  240.   def get_djinn_state
  241.     @djinn_type = "CP"; @djinn_id = 0
  242.     self.note.split(/[\r\n]+/).each do |line|
  243.       case line
  244.       when CP::DJINN::DJINNID
  245.         @djinn_type = $1.to_s.downcase
  246.         @djinn_id = $2.to_i
  247.       end
  248.     end
  249.   end
  250. end
  251.  
  252. ## Allows retrieval of the djinn summon array.
  253. class Game_System
  254.   def d_summon_ids
  255.     @d_summons = CP::DJINN::BASE_SUMMONS if @d_summons.nil?
  256.     return @d_summons
  257.   end
  258.  
  259.   def add_d_summon(id)
  260.     d_summon_ids
  261.     @d_summons.push(id) unless @d_summons.include?(id)
  262.   end
  263.  
  264.   def rem_d_summon(id)
  265.     d_summon_ids
  266.     @d_summons -= [id]
  267.   end
  268. end
  269.  
  270. ## Allows the array to be added to and removed from.
  271. class Game_Interpreter
  272.   def add_djinn_summon(id)
  273.     $game_system.add_d_summon(id)
  274.   end
  275.  
  276.   def remove_djinn_summon(id)
  277.     $game_system.rem_d_summon(id)
  278.   end
  279. end
  280.  
  281. class Game_Party
  282.   ## Counts djinn cooldown steps, but not "perfectly".
  283.   alias cp_djinn_p_walk on_player_walk
  284.   def on_player_walk
  285.     cp_djinn_p_walk
  286.     @djinn_walk = 0 if @djinn_walk.nil?
  287.     @djinn_walk += 1
  288.     if @djinn_walk >= CP::DJINN::STEP_TURNS
  289.       val = update_djinn_masks(true)
  290.       @djinn_walk -= CP::DJINN::STEP_TURNS
  291.       RPG::SE.new(*CP::DJINN::EQUIP_SE).play unless val.empty?
  292.     end
  293.   end
  294.  
  295.   ## Gets the IDs of all djinn in the party.
  296.   def djinn
  297.     get_all_djinn if @all_djinn.nil?
  298.     return @all_djinn
  299.   end
  300.  
  301.   def get_all_djinn
  302.     list = all_items.select {|item| item.djinn?}
  303.     @all_djinn = list.collect {|item| item.id}
  304.   end
  305.  
  306.   ## Organized djinn across all characters.
  307.   def organize_djinn
  308.     get_all_djinn
  309.     update_djinn_masks
  310.     list = floating_djinn
  311.     temp = list.select {|i| djinn.include?(i)}
  312.     members.each do |mem|
  313.       if mem.djinn.size > max_djinn
  314.         (mem.djinn.size - max_djinn).times do
  315.           temp.push(mem.pop_djinn)
  316.         end
  317.       elsif mem.djinn.size < max_djinn - 1
  318.         (max_djinn - (mem.djinn.size + 1)).times do
  319.           break if temp.empty?
  320.           mem.add_djinn(temp.pop)
  321.         end
  322.       end
  323.     end
  324.     temp.each do |dj|
  325.       members.each do |mem|
  326.         next if mem.djinn.size == max_djinn
  327.         mem.add_djinn(dj)
  328.         break
  329.       end
  330.       return if temp.empty?
  331.     end
  332.   end
  333.  
  334.   ## Swaps djinn between two characters.
  335.   def swap_djinn(index1, index2)
  336.     actor1 = members[index1 % members.size]
  337.     dj1    = index1 / members.size
  338.     actor2 = members[index2 % members.size]
  339.     dj2    = index2 / members.size
  340.     actor1.djinn[dj1], actor2.djinn[dj2] = actor2.djinn[dj2], actor1.djinn[dj1]
  341.     actor1.update_djinn
  342.     actor2.update_djinn
  343.   end
  344.  
  345.   ## Gets the max djinn a single character can hold.
  346.   def max_djinn
  347.     i = djinn.size / members.size
  348.     i += 1 if djinn.size % members.size != 0
  349.     return i
  350.   end
  351.  
  352.   ## Checks for djinn not equipped to current party members.
  353.   def floating_djinn
  354.     list = []
  355.     members.each do |mem|
  356.       next if mem.djinn.empty?
  357.       list += mem.djinn
  358.     end
  359.     return djinn - list
  360.   end
  361.  
  362.   ## Checks for djinn currently not equipped.
  363.   def free_djinn(element)
  364.     i = 0
  365.     djinn_masks.each do |dj, ary|
  366.       next unless CP::DJINN.djinn_base[dj].djinn_type == element.downcase
  367.       i += 1 if ary[0] == :removed
  368.     end
  369.     return i
  370.   end
  371.  
  372.   ## Checks for free djinn and subtracts for pending summons.
  373.   def free_djinn_minus_used(element)
  374.     i = free_djinn(element)
  375.     battle_members.each do |mem|
  376.       mem.actions.each do |act|
  377.         next if act.nil? || !act.dsummon?
  378.         next unless act.item.djinn_cost[element.downcase]
  379.         return i if BattleManager.actor.input == act
  380.         i -= act.item.djinn_cost[element.downcase]
  381.       end
  382.     end
  383.     return i
  384.   end
  385.  
  386.   ## Checks if djinn cost can be paid and returns true.  Else, returns false.
  387.   def pay_djinn_cost(actor, skill)
  388.     payment = {}
  389.     cost = skill.djinn_cost.clone
  390.     cost.keys.each {|k| payment[k] = []}
  391.     actor.djinn.each do |djinn|
  392.       next unless djinn_masks[djinn][0] == :removed
  393.       dj = CP::DJINN.djinn_base[djinn]
  394.       next unless cost.include?(dj.djinn_type) && cost[dj.djinn_type] > 0
  395.       payment[dj.djinn_type].push(djinn)
  396.       cost[dj.djinn_type] -= 1
  397.     end
  398.     all_members.each do |mem|
  399.       next if mem == actor
  400.       mem.djinn.each do |djinn|
  401.         next unless djinn_masks[djinn][0] == :removed
  402.         dj = CP::DJINN.djinn_base[djinn]
  403.         next unless cost.include?(dj.djinn_type) && cost[dj.djinn_type] > 0
  404.         payment[dj.djinn_type].push(djinn)
  405.         cost[dj.djinn_type] -= 1
  406.       end
  407.     end
  408.     if cost.values.any? {|n| n > 0}
  409.       return false
  410.     else
  411.       payment.values.each do |ary|
  412.         val = CP::DJINN::BASE_TURNS + 1
  413.         ary.each do |id|
  414.           djinn_masks[id][0] = :standby
  415.           djinn_masks[id][1] = val
  416.           val += CP::DJINN::ADDED_TURN
  417.         end
  418.       end
  419.       return true
  420.     end
  421.   end
  422.  
  423.   ## Standard gain item command modded to sort djinn after use.
  424.   alias cp_djinn_gain gain_item
  425.   def gain_item(item, amount, include_equip = false)
  426.     return unless item
  427.     cp_djinn_gain(item, amount, include_equip)
  428.     if CP::DJINN.djinn_base.include?(item) && item.djinn?
  429.       organize_djinn
  430.       update_djinn_masks
  431.     end
  432.   end
  433.  
  434.   ## Allows only one of each djinn to be gained.
  435.   alias cp_djinn_max_num max_item_number
  436.   def max_item_number(item)
  437.     return 1 if item.djinn?
  438.     return cp_djinn_max_num(item)
  439.   end
  440.  
  441.   ## Add or remove members and organize djinn.
  442.   alias cp_djinn_add_actor add_actor
  443.   def add_actor(id)
  444.     cp_djinn_add_actor(id)
  445.     organize_djinn
  446.   end
  447.  
  448.   alias cp_djinn_rem_actor remove_actor
  449.   def remove_actor(id)
  450.     $game_actors[id].empty_djinn
  451.     cp_djinn_rem_actor(id)
  452.     organize_djinn
  453.   end
  454.  
  455.   ## Super method for ensuring proper djinn management.
  456.   def update_djinn_masks(standby = false)
  457.     @djinn_masks = {} if @djinn_masks.nil?
  458.     @djinn_masks = @djinn_masks.select {|k, i| djinn.include?(k)}
  459.     return unless @djinn_masks.size != djinn.size || standby
  460.     temp = []
  461.     djinn.each do |id|
  462.       next if standby && @djinn_masks[id] && @djinn_masks[id][0] != :standby
  463.       ele = CP::DJINN.djinn_base[id].djinn_type
  464.       @djinn_masks[id] = [:removed, 0, ele] if @djinn_masks[id].nil?
  465.       next unless standby && @djinn_masks[id][0] == :standby
  466.       @djinn_masks[id][1] -= 1 if @djinn_masks[id][1] > 0
  467.       next unless @djinn_masks[id][1] <= 0
  468.       @djinn_masks[id][0] = :equipped
  469.       temp.push(id)
  470.     end
  471.     return temp
  472.   end
  473.  
  474.   ## Returns the djinn mask array for use.
  475.   def djinn_masks
  476.     update_djinn_masks if @djinn_masks.nil?
  477.     return @djinn_masks
  478.   end
  479. end
  480.  
  481. class Game_Actor < Game_Battler
  482.   attr_accessor :djinn
  483.  
  484.   ## Several methods for djinn checking and management.
  485.   def djinn
  486.     update_djinn
  487.     return @djinn
  488.   end
  489.  
  490.   def add_djinn(dj)
  491.     update_djinn
  492.     @djinn.push(dj)
  493.   end
  494.  
  495.   def pop_djinn
  496.     update_djinn
  497.     return @djinn.pop
  498.   end
  499.  
  500.   def has_djinn?(id)
  501.     return djinn.include?(id)
  502.   end
  503.  
  504.   def update_djinn
  505.     @djinn = [] if @djinn.nil?
  506.     @djinn = @djinn.select {|i| $game_party.djinn.include?(i)}
  507.   end
  508.  
  509.   def empty_djinn
  510.     @djinn = []
  511.   end
  512.  
  513.   ## Simplifies djinn and summon commands to prevent cost usage.
  514.   def use_djinn(item)
  515.     item.effects.each {|effect| item_global_effect_apply(effect) }
  516.   end
  517.  
  518.   ## Adds djinn to equipped items.
  519.   alias cp_djinn_fo feature_objects
  520.   def feature_objects
  521.     cp_djinn_fo + djinn_objects.compact
  522.   end
  523.  
  524.   alias cp_param_plus param_plus
  525.   def param_plus(param_id)
  526.     djinn_objects.compact.inject(cp_param_plus(param_id)) {|r, item| r += item.params[param_id]}
  527.   end
  528.  
  529.   ## Gets all the equipped djinn.
  530.   def djinn_objects
  531.     result = []
  532.     djinn.each do |id|
  533.       next unless id
  534.       object = CP::DJINN.djinn_base[id]
  535.       next unless object
  536.       next unless $game_party.djinn_masks[id][0] == :equipped
  537.       result.push(object)
  538.     end
  539.     return forced_djinn(result)
  540.   end
  541.  
  542.   ## Prepares and checks if a djinn is forcibly added for test checking.
  543.   def force_djinn(id_add = nil, id_rem = nil)
  544.     @fr_djinn = [] if @fr_djinn.nil?
  545.     @fa_djinn = [] if @fa_djinn.nil?
  546.     @fr_djinn.push(CP::DJINN.djinn_base[id_rem]) if id_rem && id_rem > 0
  547.     @fa_djinn.push(CP::DJINN.djinn_base[id_add]) if id_add && id_add > 0
  548.   end
  549.  
  550.   def forced_djinn(result)
  551.     result -= @fr_djinn if @fr_djinn
  552.     result += @fa_djinn if @fa_djinn
  553.     return result
  554.   end
  555. end
  556.  
  557. class Scene_Battle < Scene_Base
  558.   ## Aliased window methods to allow djinn window creation.
  559.   alias cp_djinn_windows create_all_windows
  560.   def create_all_windows
  561.     cp_djinn_windows
  562.     create_freefloating_window
  563.     create_djinn_window
  564.     create_dsummon_window
  565.   end
  566.  
  567.   alias cp_djinn_actor_cmd create_actor_command_window
  568.   def create_actor_command_window
  569.     cp_djinn_actor_cmd
  570.     @actor_command_window.set_handler(:djinn,        method(:command_djinn))
  571.     @actor_command_window.set_handler(:djinn_summon, method(:command_dsummon))
  572.   end
  573.  
  574.   def create_djinn_window
  575.     @djinn_window = Window_BattleDjinn.new(@help_window, @info_viewport, @freefloating_window)
  576.     @djinn_window.set_handler(:ok,     method(:on_djinn_ok))
  577.     @djinn_window.set_handler(:cancel, method(:on_djinn_cancel))
  578.     return unless $imported["CP_BATTLEVIEW_2"] && CP::BATTLERS.style5
  579.     @djinn_window.y = 0
  580.     @djinn_window.viewport = @skill_viewport
  581.   end
  582.  
  583.   def create_dsummon_window
  584.     @dsummon_window = Window_BattleDSummon.new(@help_window, @info_viewport, @freefloating_window)
  585.     @dsummon_window.set_handler(:ok,     method(:on_dsummon_ok))
  586.     @dsummon_window.set_handler(:cancel, method(:on_dsummon_cancel))
  587.     return unless $imported["CP_BATTLEVIEW_2"] && CP::BATTLERS.style5
  588.     @dsummon_window.y = 0
  589.     @dsummon_window.viewport = @skill_viewport
  590.   end
  591.  
  592.   def create_freefloating_window
  593.     @freefloating_window = Window_Freefloating.new(@info_viewport)
  594.     @freefloating_window.hide
  595.   end
  596.  
  597.   ## The commands for when djinn and summons are used.
  598.   def command_djinn
  599.     @djinn_window.actor = BattleManager.actor
  600.     @djinn_window.refresh
  601.     @djinn_window.show.activate
  602.     @freefloating_window.show
  603.   end
  604.  
  605.   def command_dsummon
  606.     @dsummon_window.actor = BattleManager.actor
  607.     @dsummon_window.refresh
  608.     @dsummon_window.show.activate
  609.     @freefloating_window.show
  610.   end
  611.  
  612.   def on_djinn_ok
  613.     @freefloating_window.hide
  614.     @skill = $data_skills[@djinn_window.item.djinn_id]
  615.     BattleManager.actor.input.set_djinn(@skill.id, @djinn_window.item.id)
  616.     if !@skill.need_selection? ||
  617.        $game_party.djinn_masks[@djinn_window.item.id][0] == :removed
  618.       @djinn_window.hide
  619.       next_command
  620.     elsif @skill.for_opponent?
  621.       select_enemy_selection
  622.     else
  623.       select_actor_selection
  624.     end
  625.   end
  626.  
  627.   def on_djinn_cancel
  628.     @djinn_window.hide
  629.     @freefloating_window.hide
  630.     @actor_command_window.activate
  631.   end
  632.  
  633.   def on_dsummon_ok
  634.     @freefloating_window.hide
  635.     @skill = @dsummon_window.item
  636.     BattleManager.actor.input.set_dsummon(@skill.id)
  637.     if !@skill.need_selection?
  638.       @dsummon_window.hide
  639.       next_command
  640.     elsif @skill.for_opponent?
  641.       select_enemy_selection
  642.     else
  643.       select_actor_selection
  644.     end
  645.   end
  646.  
  647.   def on_dsummon_cancel
  648.     @dsummon_window.hide
  649.     @freefloating_window.hide
  650.     @actor_command_window.activate
  651.   end
  652.  
  653.   alias cp_djinn_on_e_cancel on_enemy_cancel
  654.   def on_enemy_cancel
  655.     cp_djinn_on_e_cancel
  656.     on_cancel_a_window
  657.   end
  658.  
  659.   alias cp_djinn_on_a_cancel on_actor_cancel
  660.   def on_actor_cancel
  661.     cp_djinn_on_a_cancel
  662.     on_cancel_a_window
  663.   end
  664.  
  665.   def on_cancel_a_window
  666.     case @actor_command_window.current_symbol
  667.     when :djinn
  668.       @djinn_window.activate
  669.       @freefloating_window.show
  670.     when :djinn_summon
  671. #~       BattleManager.actor.input.set_attack
  672.       @dsummon_window.activate
  673.       @freefloating_window.show
  674.     end
  675.   end
  676.  
  677.   alias cp_djinn_on_e_ok on_enemy_ok
  678.   def on_enemy_ok
  679.     @djinn_window.hide
  680.     @dsummon_window.hide
  681.     cp_djinn_on_e_ok
  682.   end
  683.  
  684.   alias cp_djinn_on_a_ok on_actor_ok
  685.   def on_actor_ok
  686.     @djinn_window.hide
  687.     @dsummon_window.hide
  688.     cp_djinn_on_a_ok
  689.   end
  690.  
  691.   ## Super method that modifies actions when djinn or summons are used.
  692.   alias cp_djinn_old_item use_item
  693.   def use_item
  694.     item = @subject.current_action.item
  695.     if @subject.current_action.djinn?
  696.       djinn = @subject.current_action.djinn
  697.       if $game_party.djinn_masks[djinn.id][0] == :equipped
  698.         $game_party.djinn_masks[djinn.id][0] = :removed
  699.         @log_window.display_release_djinn(@subject, djinn)
  700.         @log_window.display_use_item(djinn, item)
  701.         @subject.use_djinn(item)
  702.         refresh_status
  703.         targets = @subject.current_action.make_targets.compact
  704.         show_animation(targets, item.animation_id)
  705.         targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  706.       else
  707.         do_set_djinn(@subject, djinn)
  708.       end
  709.     elsif @subject.current_action.dsummon?
  710.       if $game_party.pay_djinn_cost(@subject, item)
  711.         @log_window.display_use_item(@subject, item)
  712.         @subject.use_djinn(item)
  713.         refresh_status
  714.         targets = @subject.current_action.make_targets.compact
  715.         show_animation(targets, item.animation_id)
  716.         targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  717.       else
  718.         @log_window.display_use_item(@subject, item)
  719.         @log_window.display_dsummon_fail(@subject, item)
  720.         abs_wait_short
  721.       end
  722.     else
  723.       cp_djinn_old_item
  724.     end
  725.   end
  726.  
  727.   ## Sets a djinn to a character, both in and out of the party.
  728.   def do_set_djinn(subject, djinn)
  729.     $game_party.djinn_masks[djinn.id][0] = :equipped
  730.     if $game_party.battle_members.include?(subject)
  731.       subject.animation_id = CP::DJINN::EQUIP_ANIM
  732.       @log_window.display_equip_djinn(subject, djinn)
  733.       wait_for_animation
  734.     else
  735.       @log_window.display_equip_djinn(subject, djinn)
  736.       abs_wait_short
  737.     end
  738.   end
  739.  
  740.   alias cp_djinn_turn_end turn_end
  741.   def turn_end
  742.     returned = $game_party.update_djinn_masks(true)
  743.     unless returned.empty?
  744.       $game_party.all_members.each do |mem|
  745.         returned.each do |id|
  746.           next unless mem.has_djinn?(id)
  747.           do_set_djinn(mem, CP::DJINN.djinn_base[id])
  748.         end
  749.       end
  750.     end
  751.     cp_djinn_turn_end
  752.   end
  753. end
  754.  
  755. ## The freefloating djinn window, used to determine available djinn.
  756. class Window_Freefloating < Window_Base
  757.   def initialize(info_viewport)
  758.     @info_viewport = info_viewport
  759.     super(0, y_pos, window_width, fitting_height(4))
  760.     @offset = 0
  761.   end
  762.  
  763.   def y_pos
  764.     if $imported["CP_BATTLEVIEW_2"] && CP::BATTLERS.style5
  765.       @info_viewport.rect.y - fitting_height(4)
  766.     else
  767.       @info_viewport.rect.y
  768.     end
  769.   end
  770.  
  771.   def window_width
  772.     return 52 * col_max + standard_padding * 2
  773.   end
  774.  
  775.   def col_max
  776.     i = (CP::DJINN::ELEMENTS.size / 2)
  777.     return CP::DJINN::ELEMENTS.size % 2 > 0 ? i + 1 : i
  778.   end
  779.  
  780.   def refresh
  781.     contents.clear
  782.     draw_text(2, 0, contents.width - 4, line_height, CP::DJINN::DJINN_BOX, 1)
  783.     i = 0
  784.     CP::DJINN::ELEMENTS.each do |name, icon|
  785.       rect = Rect.new(52 * (i % col_max), line_height * (2 + i / col_max), 52, line_height)
  786.       text = $game_party.free_djinn_minus_used(name)
  787.       wide = contents.text_size(text).width + 26
  788.       rect.x += (52 - wide) / 2
  789.       draw_icon(icon, rect.x, rect.y)
  790.       rect.x += 24
  791.       draw_text(rect, text)
  792.       i += 1
  793.     end
  794.   end
  795.  
  796.   def shift?
  797.     return false if $imported["CP_BATTLEVIEW_2"] && CP::BATTLERS.style5
  798.     return true
  799.   end
  800.  
  801.   def show
  802.     refresh
  803.     if shift?
  804.       @offset = width
  805.       @info_viewport.ox += @offset
  806.       @info_viewport.rect.x = width
  807.     end
  808.     super
  809.   end
  810.  
  811.   def hide
  812.     if shift?
  813.       @info_viewport.ox -= @offset
  814.       @info_viewport.rect.x = 0
  815.       @offset = 0
  816.     end
  817.     super
  818.   end
  819. end
  820.  
  821. class Game_Action
  822.   ## Added special methods to allow djinn and summons to be detected.
  823.   def set_djinn(item_id, djinn_id)
  824.     set_skill(item_id)
  825.     @djinn_id = djinn_id
  826.     self
  827.   end
  828.  
  829.   def set_dsummon(item_id)
  830.     set_skill(item_id)
  831.     @dsummon = true
  832.     self
  833.   end
  834.  
  835.   alias cp_djinn_skill set_skill
  836.   def set_skill(item_id)
  837.     cp_djinn_skill(item_id)
  838.     @dsummon = false
  839.     @djinn_id = 0
  840.   end
  841.  
  842.   alias cp_djinn_item set_item
  843.   def set_item(item_id)
  844.     cp_djinn_item(item_id)
  845.     @dsummon = false
  846.     @djinn_id = 0
  847.   end
  848.  
  849.   def djinn?
  850.     return djinn ? djinn.id > 0 : false
  851.   end
  852.  
  853.   def djinn
  854.     @djinn_id = 0 if @djinn_id.nil?
  855.     return CP::DJINN.djinn_base[@djinn_id]
  856.   end
  857.  
  858.   def dsummon?
  859.     return @dsummon ? true : false
  860.   end
  861. end
  862.  
  863. ## Adds the new commands to the actor window.
  864. class Window_ActorCommand < Window_Command
  865.   alias cp_standard_cmd_list make_command_list
  866.   def make_command_list
  867.     return unless @actor
  868.     cp_standard_cmd_list
  869.     unless $imported["CP_BATTLEVIEW_2"] && $imported["CP_BATTLEVIEW_2"] >= 1.2
  870.       add_djinn_command
  871.       add_djinn_summon_command
  872.     end
  873.   end
  874.  
  875.   alias cp_djinn_addon_command addon_command if method_defined?(:addon_command)
  876.   def addon_command(comm)
  877.     if comm == :djinn
  878.       add_djinn_command
  879.     elsif comm == :djinn_summon
  880.       add_djinn_summon_command
  881.     else
  882.       cp_djinn_addon_command(comm)
  883.     end
  884.   end
  885.  
  886.   def add_djinn_command
  887.     add_command(CP::DJINN::DJINN_COMM, :djinn, !@actor.djinn.empty?)
  888.   end
  889.  
  890.   def add_djinn_summon_command
  891.     add_command(CP::DJINN::SUMMON_COMM, :djinn_summon, !CP::DJINN.summons.empty?)
  892.   end
  893.  
  894.   alias cp_djinn_addon_help_update addon_help_update if method_defined?(:addon_help_update)
  895.   def addon_help_update(sym)
  896.     cp_djinn_addon_help_update(sym)
  897.     case sym
  898.     when :djinn
  899.       @help_window.set_text(CP::DJINN::DJINN_HELP)
  900.     when :djinn_summon
  901.       @help_window.set_text(CP::DJINN::SUMMON_HELP)
  902.     end
  903.   end
  904. end
  905.  
  906. ## The window to display usable djinn in battle.
  907. class Window_BattleDjinn < Window_BattleSkill
  908.   def initialize(hw, iv, fw)
  909.     super(hw, iv)
  910.     @freefloating_window = fw
  911.   end
  912.  
  913.   def make_item_list
  914.     @data = []
  915.     if @actor
  916.       @actor.djinn.each do |dj|
  917.         temp = CP::DJINN.djinn_base[dj]
  918.         @data.push(temp)
  919.       end
  920.     end
  921.   end
  922.  
  923.   def enable?(item)
  924.     @actor && $game_party.djinn_masks[item.id][0] != :standby
  925.   end
  926.  
  927.   def draw_item(index)
  928.     skill = @data[index]
  929.     if skill
  930.       rect = item_rect(index)
  931.       rect.width -= 4
  932.       case $game_party.djinn_masks[skill.id][0]
  933.       when :removed
  934.         change_color(power_down_color)
  935.       when :standby
  936.         change_color(crisis_color)
  937.         cdtime = $game_party.djinn_masks[skill.id][1]
  938.       else
  939.         change_color(normal_color)
  940.       end
  941.       draw_icon(skill.icon_index, rect.x, rect.y)
  942.       rect.x += 24
  943.       rect.width -= 24
  944.       draw_text(rect, skill.name)
  945.       draw_skill_cooldown(rect, cdtime)
  946.     end
  947.   end
  948.  
  949.   def draw_skill_cooldown(rect, cdtime)
  950.     change_color(normal_color, false)
  951.     draw_text(rect, cdtime, 2)
  952.   end
  953. end
  954.  
  955. ## The djinn summon window for use in battle.
  956. class Window_BattleDSummon < Window_BattleSkill
  957.   def initialize(hw, iv, fw)
  958.     super(hw, iv)
  959.     @freefloating_window = fw
  960.   end
  961.  
  962.   def make_item_list
  963.     @data = CP::DJINN.summons
  964.   end
  965.  
  966.   def enable?(item)
  967.     return true
  968.   end
  969.  
  970.   def draw_item(index)
  971.     skill = @data[index]
  972.     if skill
  973.       rect = item_rect(index)
  974.       rect.width -= 4
  975.       change_color(normal_color)
  976.       draw_item_name(skill, rect.x, rect.y)
  977.       draw_skill_cost(rect, skill)
  978.     end
  979.   end
  980.  
  981.   def draw_skill_cost(rect, skill)
  982.     temp = []
  983.     CP::DJINN::ELEMENTS.each do |name, icon|
  984.       i = skill.djinn_cost[name.downcase]
  985.       next unless i || i == 0
  986.       color = $game_party.free_djinn_minus_used(name) >= i ? normal_color :
  987.                                                              power_down_color
  988.       temp.push([i, color, name, icon])
  989.     end
  990.     temp.reverse_each do |r|
  991.       change_color(r[1])
  992.       draw_text(rect, r[0], 2)
  993.       rect.width -= (contents.text_size(r[0]).width + 24)
  994.       draw_icon(r[3], rect.x + rect.width, rect.y)
  995.     end
  996.   end
  997. end
  998.  
  999. ## Log window texts for use in battle.
  1000. class Window_BattleLog < Window_Selectable
  1001.   def display_release_djinn(subject, djinn)
  1002.     text = CP::DJINN::RELEASE_DJINN.gsub(/<actor>/i, subject.name)
  1003.     text.gsub!(/<djinn>/i, djinn.name)
  1004.     add_text(text)
  1005.     wait
  1006.   end
  1007.  
  1008.   def display_equip_djinn(subject, djinn)
  1009.     text = CP::DJINN::EQUIP_DJINN.gsub(/<actor>/i, subject.name)
  1010.     text.gsub!(/<djinn>/i, djinn.name)
  1011.     replace_text(text)
  1012.   end
  1013.  
  1014.   def display_dsummon_fail(subject, djinn)
  1015.     text = CP::DJINN::SUMMON_FAIL.gsub(/<actor>/i, subject.name)
  1016.     text.gsub!(/<djinn>/i, djinn.name)
  1017.     wait
  1018.     add_text(text)
  1019.   end
  1020. end
  1021.  
  1022. ## Modify the main menu window to include the Djinn command.
  1023. class Window_MenuCommand < Window_Command
  1024.   alias cp_djinn_add_commands add_original_commands
  1025.   def add_original_commands
  1026.     cp_djinn_add_commands
  1027.     add_command(CP::DJINN::MENU_NAME, :djinn, djinn_command_usable?)
  1028.   end
  1029.  
  1030.   def djinn_command_usable?
  1031.     return !$game_party.djinn.empty? && main_commands_enabled
  1032.   end
  1033. end
  1034.  
  1035. class Scene_Menu < Scene_MenuBase
  1036.   alias cp_djinn_c_cmd_wind create_command_window
  1037.   def create_command_window
  1038.     cp_djinn_c_cmd_wind
  1039.     @command_window.set_handler(:djinn, method(:command_djinn_menu))
  1040.   end
  1041.  
  1042.   def command_djinn_menu
  1043.     SceneManager.call(Scene_Djinn)
  1044.   end
  1045. end
  1046.  
  1047. ## The Djinn scene.
  1048. ## Did this and then my laptop broke for a week, so not 100% sure I can do the
  1049. ## comments on it at the moment. (I'm lazy, sue me.)
  1050. class Scene_Djinn < Scene_MenuBase
  1051.   def start
  1052.     super
  1053.     create_status_windows
  1054.     create_help_window
  1055.     create_main_list
  1056.   end
  1057.  
  1058.   def create_status_windows
  1059.     @status1_window = Window_DjinnStatus.new(0)
  1060.     @status2_window = Window_DjinnStatus.new(Graphics.width / 2)
  1061.   end
  1062.  
  1063.   def create_help_window
  1064.     @help_window = Window_Help.new
  1065.     @help_window.y = Graphics.height - @help_window.height
  1066.   end
  1067.  
  1068.   def create_main_list
  1069.     @list_window = Window_DjinnPartyList.new(@help_window, @status1_window,
  1070.                                              @status2_window)
  1071.     @list_window.select(0)
  1072.     @list_window.activate
  1073.     @list_window.set_handler(:cancel, method(:unselect_djinn))
  1074.     @list_window.set_handler(:ok,     method(:select_djinn))
  1075.   end
  1076.  
  1077.   def select_djinn
  1078.     if @list_window.pending_index == @list_window.index
  1079.       set_djinn
  1080.       @list_window.redraw_item(@list_window.index)
  1081.       @list_window.pending_index = -1
  1082.     elsif @list_window.pending_index >= 0
  1083.       $game_party.swap_djinn(@list_window.index, @list_window.pending_index)
  1084.       @list_window.refresh
  1085.       @list_window.pending_index = -1
  1086.     else
  1087.       @list_window.pending_index = @list_window.index
  1088.     end
  1089.     @list_window.activate
  1090.     @list_window.call_update_help
  1091.   end
  1092.  
  1093.   def unselect_djinn
  1094.     if @list_window.pending_index >= 0
  1095.       @list_window.pending_index = -1
  1096.       @list_window.activate
  1097.     else
  1098.       return_scene
  1099.     end
  1100.   end
  1101.  
  1102.   def set_djinn
  1103.     i = @list_window.index
  1104.     actor = $game_party.members[i % $game_party.members.size]
  1105.     djinn = actor.djinn[i / $game_party.members.size]
  1106.     status = $game_party.djinn_masks[djinn][0]
  1107.     case status
  1108.     when :equipped
  1109.       $game_party.djinn_masks[djinn][0] = :removed
  1110.     when :removed
  1111.       $game_party.djinn_masks[djinn][0] = :equipped
  1112.     end
  1113.   end
  1114. end
  1115.  
  1116. class Window_DjinnPartyList < Window_Selectable
  1117.   attr_accessor :pending_index
  1118.  
  1119.   def initialize(help_window, status1, status2)
  1120.     @help_window = help_window
  1121.     @status1 = status1
  1122.     @status2 = status2
  1123.     @pending_index = -1
  1124.     height = Graphics.height - (@status1.height + @help_window.height)
  1125.     super(0, @status1.height, Graphics.width, height)
  1126.     refresh
  1127.   end
  1128.  
  1129.   def item_max
  1130.     return [$game_party.djinn.size, row_max * col_max].max
  1131.   end
  1132.  
  1133.   def col_max
  1134.     return $game_party.members.size
  1135.   end
  1136.  
  1137.   def row_max
  1138.     return $game_party.max_djinn
  1139.   end
  1140.  
  1141.   def item_width
  1142.     (width - standard_padding * 2 + spacing) / 4 - spacing
  1143.   end
  1144.  
  1145.   def item_height
  1146.     line_height
  1147.   end
  1148.  
  1149.   def contents_width
  1150.     [super - super % col_max, (item_width + spacing) * col_max - spacing].max
  1151.   end
  1152.  
  1153.   def ch
  1154.     return CP::DJINN::CHARA_HEIGHT + 2
  1155.   end
  1156.  
  1157.   def contents_height
  1158.     [super, row_max * item_height + ch].max
  1159.   end
  1160.  
  1161.   def spacing
  1162.     return 10
  1163.   end
  1164.  
  1165.   def item_rect(index)
  1166.     rect = super(index)
  1167.     rect.y += ch
  1168.     rect
  1169.   end
  1170.  
  1171.   def refresh
  1172.     super
  1173.     col_max.times {|i| draw_djinn_graphic(i)}
  1174.   end
  1175.  
  1176.   def draw_djinn_graphic(index)
  1177.     rect = item_rect(index)
  1178.     actor = $game_party.members[index]
  1179.     fx = rect.x + rect.width / 2
  1180.     draw_actor_graphic(actor, fx, ch - 1)
  1181.   end
  1182.  
  1183.   def draw_item(index)
  1184.     draw_item_background(index)
  1185.     rect = item_rect(index)
  1186.     actor = $game_party.members[index % col_max]
  1187.     id = actor.djinn[index / col_max]
  1188.     return unless id
  1189.     djinn = CP::DJINN.djinn_base[id]
  1190.     draw_djinn_item(actor, djinn, rect)
  1191.   end
  1192.  
  1193.   def draw_djinn_item(actor, djinn, rect)
  1194.     case $game_party.djinn_masks[djinn.id][0]
  1195.     when :removed
  1196.       change_color(power_down_color)
  1197.     when :standby
  1198.       change_color(crisis_color)
  1199.     else
  1200.       change_color(normal_color)
  1201.     end
  1202.     draw_icon(djinn.icon_index, rect.x, rect.y)
  1203.     draw_text(rect.x + 24, rect.y, rect.width - 26, line_height, djinn.name)
  1204.   end
  1205.  
  1206.   def draw_item_background(index)
  1207.     if index == @pending_index
  1208.       contents.fill_rect(item_rect(index), pending_color)
  1209.     end
  1210.   end
  1211.  
  1212.   def page_row_max
  1213.     (height - padding - padding_bottom - ch) / item_height
  1214.   end
  1215.  
  1216.   def top_col
  1217.     self.ox / (item_width + spacing)
  1218.   end
  1219.  
  1220.   def bottom_col
  1221.     top_col + 3
  1222.   end
  1223.  
  1224.   def ensure_cursor_visible
  1225.     super
  1226.     while index % col_max > bottom_col
  1227.       self.ox += item_width + spacing
  1228.     end
  1229.     while index % col_max < top_col
  1230.       self.ox -= item_width + spacing
  1231.     end
  1232.   end
  1233.  
  1234.   def pending_index=(index)
  1235.     last_pending_index = @pending_index
  1236.     @pending_index = index
  1237.     redraw_item(@pending_index)
  1238.     redraw_item(last_pending_index)
  1239.   end
  1240.  
  1241.   def call_update_help
  1242.     update_help if active
  1243.   end
  1244.  
  1245.   def update_help
  1246.     aid = @index % col_max
  1247.     actor = $game_party.members[aid]
  1248.     djinn = actor.djinn[@index / col_max]
  1249.    
  1250.     if @pending_index >= 0
  1251.       if actor != @status1.actor
  1252.         djin2 = @status1.actor.djinn[@pending_index / col_max]
  1253.         dlmask = d2mask = nil
  1254.         d1mask = $game_party.djinn_masks[djinn][0] unless djinn.nil?
  1255.         d2mask = $game_party.djinn_masks[djin2][0] unless djin2.nil?
  1256.         djinn = nil if d1mask != :equipped
  1257.         djin2 = nil if d2mask != :equipped
  1258.         @status1.make_actor_change(nil, djinn, djin2)
  1259.         @status2.make_actor_change(actor, djin2, djinn)
  1260.       elsif @index == @pending_index
  1261.         if djinn.nil?
  1262.           @status1.temp_actor = nil
  1263.         else
  1264.           case $game_party.djinn_masks[djinn][0]
  1265.           when :standby
  1266.             @status1.temp_actor = nil
  1267.           when :removed
  1268.             @status1.make_actor_change(nil, djinn)
  1269.           when :equipped
  1270.             @status1.make_actor_change(nil, nil, djinn)
  1271.           end
  1272.           @status2.actor = nil
  1273.           @status2.temp_actor = nil
  1274.         end
  1275.       else
  1276.         @status1.temp_actor = nil
  1277.         @status2.actor = nil
  1278.       end
  1279.     else
  1280.       @status1.actor = actor
  1281.       @status1.temp_actor = nil
  1282.       @status2.actor = nil
  1283.     end
  1284.     @status1.refresh
  1285.     @status2.refresh
  1286.     @actor = actor
  1287.    
  1288.     if @help_window
  1289.       super
  1290.       id = actor.djinn[@index / col_max]
  1291.       @help_window.set_item(CP::DJINN.djinn_base[id]) if id
  1292.     end
  1293.   end
  1294. end
  1295.  
  1296. class Window_DjinnStatus < Window_Base
  1297.   attr_accessor :actor
  1298.   attr_accessor :temp_actor
  1299.  
  1300.   def initialize(x)
  1301.     super(x, 0, Graphics.width / 2, fitting_height(5))
  1302.     @actor = nil
  1303.     @temp_actor = nil
  1304.   end
  1305.  
  1306.   def refresh
  1307.     contents.clear
  1308.     return unless @actor
  1309.     actor_basic_info
  1310.     actor_class_info
  1311.     actor_hp_info
  1312.     actor_param_info
  1313.   end
  1314.  
  1315.   def actor_basic_info
  1316.     draw_actor_name(@actor, 2, 0, contents.width / 2)
  1317.     draw_actor_face(@actor, 0, line_height)
  1318.   end
  1319.  
  1320.   def actor_class_info
  1321.     wd = contents.width / 2
  1322.     if @temp_actor.nil? || @actor.class == @temp_actor.class
  1323.       change_color(normal_color)
  1324.     else
  1325.       change_color(power_up_color)
  1326.     end
  1327.     actor = @temp_actor ? @temp_actor : @actor
  1328.     draw_actor_class(actor, wd + 2, 0, wd)
  1329.   end
  1330.  
  1331.   def actor_hp_info
  1332.     wd = (contents.width - 98) / 2
  1333.     change_color(system_color)
  1334.     actor = @temp_actor ? @temp_actor : @actor
  1335.     draw_text(96,      line_height, wd, line_height, Vocab::hp_a)
  1336.     draw_text(96 + wd, line_height, wd, line_height, Vocab::mp_a)
  1337.     if @temp_actor.nil? || @actor.mhp == @temp_actor.mhp
  1338.       change_color(normal_color)
  1339.     elsif @actor.mhp > @temp_actor.mhp
  1340.       change_color(power_down_color)
  1341.     elsif @actor.mhp < @temp_actor.mhp
  1342.       change_color(power_up_color)
  1343.     end
  1344.     draw_text(96,      line_height, wd, line_height, actor.mhp, 2)
  1345.     if @temp_actor.nil? || @actor.mmp == @temp_actor.mmp
  1346.       change_color(normal_color)
  1347.     elsif @actor.mmp > @temp_actor.mmp
  1348.       change_color(power_down_color)
  1349.     elsif @actor.mmp < @temp_actor.mmp
  1350.       change_color(power_up_color)
  1351.     end
  1352.     draw_text(96 + wd, line_height, wd, line_height, actor.mmp, 2)
  1353.   end
  1354.  
  1355.   def actor_param_info
  1356.     wd = (contents.width - 98) / 2
  1357.     actor = @temp_actor ? @temp_actor : @actor
  1358.     6.times do |i|
  1359.       i += 2
  1360.       n = i % 2; lh = (line_height * 1) + (i / 2) * line_height
  1361.       change_color(system_color)
  1362.       draw_text(96 + wd * n, lh, wd, line_height, Vocab::param(i))
  1363.       param_color(i)
  1364.       draw_text(96 + wd * n, lh, wd, line_height, actor.param(i), 2)
  1365.     end
  1366.   end
  1367.  
  1368.   def param_color(param_id)
  1369.     if @temp_actor.nil? || @actor.param(param_id) == @temp_actor.param(param_id)
  1370.       change_color(normal_color)
  1371.     elsif @actor.param(param_id) > @temp_actor.param(param_id)
  1372.       change_color(power_down_color)
  1373.     elsif @actor.param(param_id) < @temp_actor.param(param_id)
  1374.       change_color(power_up_color)
  1375.     end
  1376.   end
  1377.  
  1378.   def actor=(actor)
  1379.     return if actor == @actor
  1380.     @actor = actor
  1381.     @temp_actor = nil if @actor.nil?
  1382.   end
  1383.  
  1384.   def temp_actor=(actor)
  1385.     return if actor == @temp_actor
  1386.     @temp_actor = actor
  1387.   end
  1388.  
  1389.   def make_actor_change(actor = nil, id_a = nil, id_r = nil)
  1390.     @actor = actor unless actor.nil?
  1391.     return if @actor.nil?
  1392.     @temp_actor = Marshal.load(Marshal.dump(@actor))
  1393.     force_djinn(id_a, id_r)
  1394.   end
  1395.  
  1396.   def force_djinn(id_a = nil, id_r = nil)
  1397.     @temp_actor.force_djinn(id_a, id_r)
  1398.   end
  1399. end
  1400.  
  1401. ##-----------------------------------------------------------------------------
  1402. ## End of script.
  1403. ##-----------------------------------------------------------------------------
RAW Paste Data