Advertisement
Guest User

Untitled

a guest
Jan 18th, 2011
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 30.75 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine RD - Custom Item Abilities
  4. # Last Date Updated: 2009.06.24
  5. # Level: Easy, Normal, Hard, Lunatic
  6. #
  7. # Usable items have generally been a very neglected part of many RPG Maker
  8. # games due to the complete and utter lack of flavour they deliver to the game.
  9. # This script allows you to give items a few more abilities than what they
  10. # originally had and restores a few of the lost RPG Maker 2000/2003 features.
  11. #
  12. # - Item charges. Use items a certain number of times before they're consumed.
  13. # - Variable and Switch adjustment. Rather than doing it with common events,
  14. #   do it straight from the menu without kicking the player out of the menu.
  15. # - Unique item effects. Different actors and different classes can produce
  16. #   different effects from the same item depending on who is using them.
  17. # - Some actors and classes are unable to use particular items. This is another
  18. #   feature reclaimed from older RPG Makers.
  19. # - Some items will not have any effects on certain actors, classes, or enemies.
  20. #
  21. # - Custom effects for lunatic scripters. These effects can happen before the
  22. #   item is used, consuming the item, or after the item is used.
  23. #
  24. #===============================================================================
  25. # Updates:
  26. # ----------------------------------------------------------------------------
  27. # o 2009.06.24 - Finished script.
  28. # o 2009.06.21 - Started script.
  29. #===============================================================================
  30. # Instructions
  31. #===============================================================================
  32. #
  33. # These tags go into item noteboxes within the database.
  34. #
  35. # <item charges x>
  36. # This will allow items to be used x times before they are consumed. This was
  37. # originally a feature that came from RPG Maker 2000 and RPG Maker 2003. The
  38. # default charge is 1. Use x to deliver charges higher than 1 to have an effect.
  39. #
  40. # ----------------------------------------------------------------------------
  41. #
  42. # <variable x +y> or <variable x -y>
  43. # This causes the item to change variable x by y amount when used. This can
  44. # will be activated both in battle and out of battle.
  45. #
  46. # <switch x on> or <switch x off> or <toggle switch x>
  47. # This will cause switch x to be turned on or off. If you use the toggle tag,
  48. # switch x will turn off if it was originally on and vice versa.
  49. #
  50. # ----------------------------------------------------------------------------
  51. #
  52. # The following will affect whether or not an item can be used by different
  53. # actors inside battle. This is a feature that was originally taken out of
  54. # RPG Maker 2000 and RPG Maker 2003.
  55. #
  56. # <pharmacology only>
  57. # Only actors with pharmacology will be able to use this item. If the actor
  58. # does not possess the pharmacology trait by either innate, class trait, or
  59. # from a status effect, the item cannot be used.
  60. #
  61. # <unusable actor x> or <unusable actor x,x>
  62. # <unusable class x> or <unusable class x,x>
  63. # This will cause the listed actors and classes to be unable to use the said
  64. # items. Items that cannot be used will not appear for them in battle when the
  65. # "item" command is selected.
  66. #
  67. # ----------------------------------------------------------------------------
  68. #
  69. # <null actor x> or <null actor x,x>
  70. # <null class x> or <null class x,x>
  71. # <null enemy x> or <null enemy x,x>
  72. # This will cause the item to have no effect on the specified actors, classes,
  73. # or enemies. The items will still be used, but nothing else will change on
  74. # that target and the game will go on as if nothing happened.
  75. #
  76. # ----------------------------------------------------------------------------
  77. #
  78. # The following will only occur in battle as it's calculated by individual use
  79. # rather than party-wide use. These effects will change the item's effects into
  80. # a skill's effects if conditions are met.
  81. #
  82. # <pharmacology effect x>
  83. # This will cause the item to cast a skill instead of using the typical item
  84. # effect. This will only trigger if the actor using the skill has the
  85. # pharmacology trait and this will override any of the below tags if they're
  86. # to be used together.
  87. #
  88. # <actor effect y> or <actor effect x:y>
  89. # This will cause the item to cast a skill instead of using the typical item
  90. # effect. The skill used will be y. If you use the second tag, it will cause
  91. # different actors to use different skills when using that particular item. x
  92. # will determine which actor will use skill y. If x is 0, that skill becomes
  93. # the universal skill for unlisted actors.
  94. #
  95. # <class effect y> or <class effect x:y>
  96. # This will cause the item to cast a skill instead of using the typical item
  97. # effect. The skill used will be y. If you use the second tag, it will cause
  98. # different classes to use different skills when using that particular item. x
  99. # will determine which class will use skill y. If x is 0, that skill becomes
  100. # the universal skill for unlisted classes.
  101. #
  102. #===============================================================================
  103. #
  104. # Compatibility
  105. # - Works With: Yanfly Custom Skill Effects, Scene Battle ReDux
  106. # - Works With: KGC's Usable Equipment
  107. # - Alias: Game_Battler: item_effective?
  108. # - Alias: Game_Party: consume_item
  109. # - Alias: Scene_Item: use_item_nontarget
  110. # - Alias: Window_Item: refresh
  111. # - Overwrites: Game_Party: item_can_use?
  112. # - Overwrites: Scene_Battle: execute_action_item
  113. # - Overwrites: Window_Item: draw_item
  114. #
  115. #===============================================================================
  116.  
  117. $imported = {} if $imported == nil
  118. $imported["CustomItemAbilities"] = true
  119.  
  120. module YE
  121.   module ITEM
  122.    
  123.     # This will change the way item text is displayed in battle.
  124.     USE_ITEM = "%s uses %s!"
  125.    
  126.     # This is how the amount of an item is drawn in menus.
  127.     DRAW_ITEM = "×%2d"
  128.    
  129.     # If this is set to true, it will name the item used along with the
  130.     # name of the skill produced by the item if the item has a skill effect.
  131.     SHOW_SKILL_EFFECT = true
  132.    
  133.     # This adjusts the size of the item charges displayed in the item window.
  134.     # Items will only display this if they have the <item charge x> tag.
  135.     CHARGE_SIZE = 14
  136.     CHARGE_BOLD = true
  137.    
  138.   end # ITEM
  139. end # YE
  140.  
  141. #===============================================================================
  142. # How to Use: Lunatic Mode
  143. #===============================================================================
  144. #
  145. # <usage effect x>
  146. # Usage effects will occur before the item is used. In a way, this is the
  147. # preparation step for items. Find "def effect_usage" to begin adding in your
  148. # own custom usage effects. "def common_usage" will have usage effects that
  149. # will occur for all items regardless of UIE tagging.
  150. #
  151. # <consume effect x>
  152. # Consume effects will only occur when the item is consumed. This means that if
  153. # an item has more than 1 charges left or the item isn't consumable, this will
  154. # not trigger. Find "def effect_consume" to begin adding in your own custom
  155. # consume effects. "def common_consume" will have consume effects that will
  156. # occur whenever an item is consumed regardless of CIE tagging.
  157. #
  158. # <finish effect x>
  159. # Finish effects will only occur when the item is finished being used. This will
  160. # pretty much at the end of the turn. Find "def effect_finish" to begin adding
  161. # in your own custom finish effects. "def common_finish" will have finish
  162. # effects that will occur whenever an item is finished being used regardless of
  163. # FIE tagging.
  164. #
  165. #===============================================================================
  166.  
  167. class Scene_Battle < Scene_Base
  168.  
  169.   def effect_usage(item, usageitem)
  170.     line_number = @message_window.line_number
  171.     case usageitem
  172.     #---------------------------------------------------------------------------
  173.     # //////////////////////////////////////////////////////////////////////////
  174.     # This is where you begin adding in your own item usage effects.
  175.     #---------------------------------------------------------------------------
  176.     when 1
  177.       # Active Battler will recover MP equal to Active Battler's Level
  178.       @active_battler.mp += @active_battler.level
  179.      
  180.     when 2
  181.       # Active Battler will recover HP equal to Active Battler's Level
  182.       @active_battler.hp += @active_battler.level
  183.      
  184.     when 3
  185.      
  186.     #---------------------------------------------------------------------------
  187.     # This is the part you guys shouldn't touch afterwards.
  188.     # //////////////////////////////////////////////////////////////////////////
  189.     #---------------------------------------------------------------------------
  190.     end
  191.   end
  192.  
  193.   #-----------------------------------------------------------------------------
  194.   #-----This is the common usage effect. It'll occur regardless of UIE tagging.
  195.   def common_usage(item)
  196.    
  197.   end
  198.   #-----------------------------------------------------------------------------
  199.  
  200.   def effect_consume(item, consumeitem)
  201.     line_number = @message_window.line_number
  202.     case consumeitem
  203.     #---------------------------------------------------------------------------
  204.     # //////////////////////////////////////////////////////////////////////////
  205.     # This is where you begin adding in your own item finish effects.
  206.     #---------------------------------------------------------------------------
  207.     when 1
  208.       # Party will recover to full health when the item is consumed
  209.       for member in $game_party.existing_members
  210.         member.hp = member.maxhp
  211.       end
  212.      
  213.     when 2
  214.      
  215.     #---------------------------------------------------------------------------
  216.     # This is the part you guys shouldn't touch afterwards.
  217.     # //////////////////////////////////////////////////////////////////////////
  218.     #---------------------------------------------------------------------------
  219.     end
  220.   end
  221.  
  222.   #-----------------------------------------------------------------------------
  223.   #-----This is the common consume effect. It'll occur regardless of CIE tagging.
  224.   def common_consume(item)
  225.    
  226.   end
  227.   #-----------------------------------------------------------------------------
  228.  
  229.   def effect_finish(item, finishitem)
  230.     line_number = @message_window.line_number
  231.     case finishitem
  232.     #---------------------------------------------------------------------------
  233.     # //////////////////////////////////////////////////////////////////////////
  234.     # This is where you begin adding in your own item finish effects.
  235.     #---------------------------------------------------------------------------
  236.     when 1
  237.       # Active Battler will recover HP equal to Active Battler's Level
  238.       @active_battler.hp += @active_battler.level
  239.      
  240.     when 2
  241.       # Active Battler will recover MP equal to Active Battler's Level
  242.       @active_battler.mp += @active_battler.level
  243.      
  244.     when 3
  245.      
  246.     #---------------------------------------------------------------------------
  247.     # This is the part you guys shouldn't touch afterwards.
  248.     # //////////////////////////////////////////////////////////////////////////
  249.     #---------------------------------------------------------------------------
  250.     end
  251.   end
  252.  
  253.   #-----------------------------------------------------------------------------
  254.   #-----This is the common finish effect. It'll occur regardless of FIE tagging.
  255.   def common_finish(item)
  256.    
  257.   end
  258.   #-----------------------------------------------------------------------------
  259.  
  260. end # Scene_Battle
  261.  
  262. #===============================================================================
  263. # Editting anything past this point may potentially result in causing computer
  264. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  265. # Therefore, edit at your own risk.
  266. #===============================================================================
  267.  
  268. module YE
  269. module REGEXP
  270. module BASEITEM
  271.  
  272.   # Item Charges
  273.   ITEM_CHARGES = /<(?:ITEM_CHARGES|item charges)[ ]*(\d+)>/i
  274.  
  275.   # Variable and Switch Changes
  276.   CHANGE_VARIABLE = /<(?:CHANGE_VARIABLE|variable)[ ]*(\d+)[ ]([\+\-]\d+)>/i
  277.   CHANGE_SWITCH = /<(?:CHANGE_SWITCH|switch)[ ]*(\d+)[ ](.*)>/i
  278.   TOGGLE_SWITCH = /<(?:TOGGLE_SWITCH|toggle switch)[ ]*(\d+)>/i
  279.  
  280.   # Skill Effects for Items
  281.   PHARMACOLOGY_EFFECT = /<(?:PHARMACOLOGY_EFFECT|pharmacology effect)[ ]*(\d+)>/i
  282.   ACTOR_EFFECT = /<(?:ACTOR_EFFECT|actor effect)[ ]*(\d+)>/i
  283.   ACTOR_EFFECT_MULTI = /<(?:ACTOR_EFFECT|actor effect)[ ]*(\d+):(\d+)>/i
  284.   CLASS_EFFECT = /<(?:CLASS_EFFECT|class effect)[ ]*(\d+)>/i
  285.   CLASS_EFFECT_MULTI = /<(?:CLASS_EFFECT|class effect)[ ]*(\d+):(\d+)>/i
  286.  
  287.   # Null Effects for Items
  288.   NULL_ACTOR = /<(?:NULL_ACTOR|null actor)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  289.   NULL_CLASS = /<(?:NULL_CLASS|null class)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  290.   NULL_ENEMY = /<(?:NULL_ENEMY|null enemy)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  291.  
  292.   # Unusable Actors and Classes
  293.   PHARMACOLOGY_ONLY = /<(?:PHARMACOLOGY_ONLY|pharmacology only)>/i
  294.   UNUSABLE_ACTOR = /<(?:UNUSABLE_ACTOR|unusable actor)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  295.   UNUSABLE_CLASS = /<(?:UNUSABLE_CLASS|unusable class)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  296.  
  297.   # Lunatic Effects
  298.   USAGE_EFFECT   = /<(?:USAGE_EFFECT|usage effect|effect usage)[ ]*(\d+)>/i
  299.   CONSUME_EFFECT = /<(?:CONSUME_EFFECT|consume effect|effect consume)[ ]*(\d+)>/i
  300.   FINISH_EFFECT  = /<(?:FINISH_EFFECT|finish effect|effect finish)[ ]*(\d+)>/i
  301.  
  302. end # BASEITEM
  303. end # REGEXP
  304. end # YE
  305. module Vocab
  306.   UseItem = YE::ITEM::USE_ITEM
  307. end # Vocab
  308.  
  309. #===============================================================================
  310. # RPG::BaseItem
  311. #===============================================================================
  312.  
  313. class RPG::BaseItem
  314.  
  315.   #--------------------------------------------------------------------------
  316.   # Yanfly_Cache_BaseItem_CIA
  317.   #--------------------------------------------------------------------------
  318.   def yanfly_cache_baseitem_cia
  319.     @uie = 0; @cie = 0; @fie = 0
  320.     @change_var_id = 0; @change_var_amt = 0; @toggle_switch = 0
  321.     @change_switch_id = 0; @change_switch_flag = false; @pharma_effect = 0
  322.     @item_skill_effect = false; @unusable_actor = []; @unusuable_class = []
  323.     @actor_effect = {}; @class_effect = {}; @pharma_only = false
  324.     @item_charges = 1; @null_actor = []; @null_class = []; @null_enemy = []
  325.    
  326.     self.note.split(/[\r\n]+/).each { |line|
  327.       case line
  328.       when YE::REGEXP::BASEITEM::USAGE_EFFECT
  329.         @uie = $1.to_i
  330.       when YE::REGEXP::BASEITEM::CONSUME_EFFECT
  331.         @cie = $1.to_i
  332.       when YE::REGEXP::BASEITEM::FINISH_EFFECT
  333.         @fie = $1.to_i
  334.      
  335.       when YE::REGEXP::BASEITEM::ITEM_CHARGES
  336.         @item_charges = $1.to_i
  337.        
  338.       when YE::REGEXP::BASEITEM::CHANGE_VARIABLE
  339.         @change_var_id = $1.to_i
  340.         @change_var_amt = $2.to_i
  341.       when YE::REGEXP::BASEITEM::CHANGE_SWITCH
  342.         @change_switch_id = $1.to_i
  343.         case $2.to_s
  344.         when "true", "TRUE", "True", "on", "ON", "On"
  345.           @change_switch_flag = true
  346.         else
  347.           @change_switch_flag = false
  348.         end
  349.       when YE::REGEXP::BASEITEM::TOGGLE_SWITCH
  350.         @toggle_switch = $1.to_i
  351.        
  352.       when YE::REGEXP::BASEITEM::NULL_ACTOR
  353.         $1.scan(/\d+/).each { |num|
  354.         if num.to_i > 0
  355.           @null_actor.push(num.to_i)
  356.         end }
  357.       when YE::REGEXP::BASEITEM::NULL_CLASS
  358.         $1.scan(/\d+/).each { |num|
  359.         if num.to_i > 0
  360.           @null_class.push(num.to_i)
  361.         end }
  362.       when YE::REGEXP::BASEITEM::NULL_ENEMY
  363.         $1.scan(/\d+/).each { |num|
  364.         if num.to_i > 0
  365.           @null_enemy.push(num.to_i)
  366.         end }
  367.       when YE::REGEXP::BASEITEM::PHARMACOLOGY_ONLY
  368.         @pharma_only = true
  369.       when YE::REGEXP::BASEITEM::UNUSABLE_ACTOR
  370.         $1.scan(/\d+/).each { |num|
  371.         if num.to_i > 0
  372.           @unusable_actor.push(num.to_i)
  373.         end }
  374.       when YE::REGEXP::BASEITEM::UNUSABLE_CLASS
  375.         $1.scan(/\d+/).each { |num|
  376.         if num.to_i > 0
  377.           @unusuable_class.push(num.to_i)
  378.         end }
  379.        
  380.       when YE::REGEXP::BASEITEM::PHARMACOLOGY_EFFECT
  381.         @pharma_effect = $1.to_i
  382.         @item_skill_effect = true
  383.       when YE::REGEXP::BASEITEM::ACTOR_EFFECT
  384.         @actor_effect[0] = $1.to_i
  385.         @item_skill_effect = true
  386.       when YE::REGEXP::BASEITEM::ACTOR_EFFECT_MULTI
  387.         @actor_effect[0] = $2.to_i if @actor_effect[0] == nil
  388.         @actor_effect[$1.to_i] = $2.to_i
  389.         @item_skill_effect = true
  390.       when YE::REGEXP::BASEITEM::CLASS_EFFECT
  391.         @class_effect[0] = $1.to_i
  392.         @item_skill_effect = true
  393.       when YE::REGEXP::BASEITEM::CLASS_EFFECT_MULTI
  394.         @class_effect[0] = $2.to_i if @class_effect[0] == nil
  395.         @class_effect[$1.to_i] = $2.to_i
  396.         @item_skill_effect = true
  397.      
  398.       end
  399.     }
  400.   end
  401.  
  402.   #--------------------------------------------------------------------------
  403.   # definitions - misc
  404.   #--------------------------------------------------------------------------
  405.   def uie
  406.     yanfly_cache_baseitem_cia if @uie == nil
  407.     return @uie
  408.   end
  409.   def cie
  410.     yanfly_cache_baseitem_cia if @cie == nil
  411.     return @cie
  412.   end
  413.   def fie
  414.     yanfly_cache_baseitem_cia if @fie == nil
  415.     return @fie
  416.   end
  417.   def item_charges
  418.     yanfly_cache_baseitem_cia if @item_charges == nil
  419.     return @item_charges
  420.   end
  421.  
  422.   #--------------------------------------------------------------------------
  423.   # definitions - variables and switches
  424.   #--------------------------------------------------------------------------
  425.   def change_var_id
  426.     yanfly_cache_baseitem_cia if @change_var_id == nil
  427.     return @change_var_id
  428.   end
  429.   def change_var_amt
  430.     yanfly_cache_baseitem_cia if @change_var_amt == nil
  431.     return @change_var_amt
  432.   end
  433.   def change_switch_id
  434.     yanfly_cache_baseitem_cia if @change_switch_id == nil
  435.     return @change_switch_id
  436.   end
  437.   def change_switch_flag
  438.     yanfly_cache_baseitem_cia if @change_switch_flag == nil
  439.     return @change_switch_flag
  440.   end
  441.   def toggle_switch
  442.     yanfly_cache_baseitem_cia if @toggle_switch == nil
  443.     return @toggle_switch
  444.   end
  445.  
  446.   #--------------------------------------------------------------------------
  447.   # definitions - null/unusuable
  448.   #--------------------------------------------------------------------------
  449.   def null_actor
  450.     yanfly_cache_baseitem_cia if @null_actor == nil
  451.     return @null_actor
  452.   end
  453.   def null_class
  454.     yanfly_cache_baseitem_cia if @null_class == nil
  455.     return @null_class
  456.   end
  457.   def null_enemy
  458.     yanfly_cache_baseitem_cia if @null_enemy == nil
  459.     return @null_enemy
  460.   end
  461.   def pharma_only
  462.     yanfly_cache_baseitem_cia if @pharma_only == nil
  463.     return @pharma_only
  464.   end
  465.   def unusuable_actor
  466.     yanfly_cache_baseitem_cia if @unusable_actor == nil
  467.     return @unusable_actor
  468.   end
  469.   def unusuable_class
  470.     yanfly_cache_baseitem_cia if @unusable_class == nil
  471.     return @unusable_class
  472.   end
  473.  
  474.   #--------------------------------------------------------------------------
  475.   # definitions - item/skill effects
  476.   #--------------------------------------------------------------------------
  477.   def item_skill_effect
  478.     yanfly_cache_baseitem_cia if @item_skill_effect == nil
  479.     return @item_skill_effect
  480.   end
  481.   def pharma_effect
  482.     yanfly_cache_baseitem_cia if @pharma_effect == nil
  483.     return @pharma_effect
  484.   end
  485.   def actor_effect
  486.     yanfly_cache_baseitem_cia if @actor_effect == nil
  487.     return @actor_effect
  488.   end
  489.   def class_effect
  490.     yanfly_cache_baseitem_cia if @class_effect == nil
  491.     return @class_effect
  492.   end
  493.  
  494. end # RPG::BaseItem
  495.  
  496. #==============================================================================
  497. # Game_Temp
  498. #==============================================================================
  499.  
  500. class Game_Temp
  501.  
  502.   #--------------------------------------------------------------------------
  503.   # Public Instance Variables
  504.   #--------------------------------------------------------------------------
  505.   attr_accessor :refreshing_cia
  506.  
  507. end # Game_Temp
  508.  
  509. #===============================================================================
  510. # Game_Battler
  511. #===============================================================================
  512.  
  513. class Game_Battler
  514.  
  515.   #--------------------------------------------------------------------------
  516.   # alias item_effective?
  517.   #--------------------------------------------------------------------------
  518.   alias item_effective_cia item_effective?
  519.   def item_effective?(user, item)
  520.     return false if null_effect?(item)
  521.     return item_effective_cia(user, item)
  522.   end
  523.  
  524.   #--------------------------------------------------------------------------
  525.   # null_effect?
  526.   #--------------------------------------------------------------------------
  527.   def null_effect?(item)
  528.     if self.actor?
  529.       return true if item.null_actor.include?(self.id)
  530.       return true if item.null_class.include?(self.class_id)
  531.     else
  532.       return true if item.null_enemy.include?(self.enemy_id)
  533.     end
  534.     return false
  535.   end
  536.  
  537. end # Game_Battler
  538.  
  539. #===============================================================================
  540. # Game_Party
  541. #===============================================================================
  542.  
  543. class Game_Party < Game_Unit
  544.  
  545.   #--------------------------------------------------------------------------
  546.   # overwrite item_can_use?
  547.   #--------------------------------------------------------------------------
  548.   def item_can_use?(item)
  549.     return false if !item.is_a?(RPG::Item) and !$imported["UsableEquipment"]
  550.     return false if item_number(item) == 0
  551.     return false unless actor_can_use(item)
  552.     return $game_temp.in_battle ? item.battle_ok? : item.menu_ok?
  553.   end
  554.  
  555.   #--------------------------------------------------------------------------
  556.   # actor_can_use
  557.   #--------------------------------------------------------------------------
  558.   def actor_can_use(item)
  559.     return true unless $game_temp.in_battle
  560.     return true if $game_temp.refreshing_cia
  561.     if item.pharma_only
  562.       return false unless $scene.active_battler.pharmacology
  563.     end
  564.     if item.unusuable_actor != []
  565.       actor_id = $scene.active_battler.id
  566.       return false if item.unusuable_actor.include?(actor_id)
  567.     end
  568.     if item.unusuable_class != []
  569.       class_id = $scene.active_battler.class_id
  570.       return false if item.unusuable_actor.include?(class_id)
  571.     end
  572.     return true
  573.   end
  574.  
  575.   #--------------------------------------------------------------------------
  576.   # alias consume_item
  577.   #--------------------------------------------------------------------------
  578.   alias consume_item_cia consume_item unless $@
  579.   def consume_item(item)
  580.     if item.is_a?(RPG::Item) and item.item_charges > 1 and item.consumable
  581.       if self.item_charges[item.id] == nil
  582.         self.item_charges[item.id] = item.item_charges
  583.       end
  584.       if self.item_charges[item.id] > 1
  585.         self.item_charges[item.id] -= 1
  586.       else
  587.         self.item_charges[item.id] = item.item_charges
  588.         consume_item_cia(item)
  589.       end
  590.     else
  591.       consume_item_cia(item)
  592.     end
  593.   end
  594.  
  595.   #--------------------------------------------------------------------------
  596.   # item_charges
  597.   #--------------------------------------------------------------------------
  598.   def item_charges
  599.     @item_charges = {} if @item_charges == nil
  600.     return @item_charges
  601.   end
  602.  
  603. end # Game_Party
  604.  
  605. #===============================================================================
  606. # Scene_Battle
  607. #===============================================================================
  608.  
  609. class Scene_Battle < Scene_Base
  610.  
  611.   #--------------------------------------------------------------------------
  612.   # overwrite execute_action_item
  613.   #--------------------------------------------------------------------------
  614.   def execute_action_item
  615.     item = @active_battler.action.item
  616.     item_variable_and_switch_changes(item)
  617.     if item.item_skill_effect == true
  618.       perform_item_skill_effect(item)
  619.     else
  620.       use_the_item(item)
  621.     end
  622.   end
  623.  
  624.   #--------------------------------------------------------------------------
  625.   # item_variable_and_switch_changes
  626.   #--------------------------------------------------------------------------
  627.   def item_variable_and_switch_changes(item)
  628.     if item.change_var_id > 0
  629.       $game_variables[item.change_var_id] += item.change_var_amt
  630.     end
  631.     if item.change_switch_id > 0
  632.       $game_switches[item.change_switch_id] = item.change_switch_flag
  633.     end
  634.     if item.toggle_switch > 0
  635.       if $game_switches[item.toggle_switch]
  636.         $game_switches[item.toggle_switch] = false
  637.       else
  638.         $game_switches[item.toggle_switch] = true
  639.       end
  640.     end
  641.   end
  642.  
  643.   #--------------------------------------------------------------------------
  644.   # consume_item
  645.   #--------------------------------------------------------------------------
  646.   def consume_item(item)
  647.     amount = $game_party.item_number(item)
  648.     $game_party.consume_item(item)
  649.     if $game_party.item_number(item) < amount
  650.       effect_consume(item, item.cie) if item.uie > 0
  651.       common_consume(item)
  652.     end
  653.   end
  654.  
  655.   #--------------------------------------------------------------------------
  656.   # perform_item_skill_effect
  657.   #--------------------------------------------------------------------------
  658.   def perform_item_skill_effect(item)
  659.     if item.pharma_effect > 0 and @active_battler.pharmacology
  660.       skill_id = item.pharma_effect
  661.     elsif item.actor_effect.include?(@active_battler.id)
  662.       skill_id = item.actor_effect[@active_battler.id]
  663.     elsif item.class_effect.include?(@active_battler.class_id)
  664.       skill_id = item.class_effect[@active_battler.class_id]
  665.     elsif item.actor_effect[0] != nil
  666.       skill_id = item.actor_effect[0]
  667.     elsif item.class_effect[0] != nil
  668.       skill_id = item.class_effect[0]
  669.     else
  670.       use_the_item(item)
  671.       return
  672.     end
  673.     if $imported["SceneBattleReDux"] and YE::REDUX::BATTLE::MSG_CURRENT_ACTION
  674.       text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
  675.       @message_window.add_instant_text(text) if YE::ITEM::SHOW_SKILL_EFFECT
  676.     end
  677.     effect_usage(item, item.uie) if item.uie > 0
  678.     common_usage(item)
  679.     consume_item(item)
  680.     @active_battler.action.set_skill(skill_id)
  681.     execute_action_skill
  682.     effect_finish(item, item.fie) if item.fie > 0
  683.     common_finish(item)
  684.     $game_temp.common_event_id = item.common_event_id
  685.   end
  686.  
  687.   #--------------------------------------------------------------------------
  688.   # use_the_item
  689.   #--------------------------------------------------------------------------
  690.   def use_the_item(item)
  691.     if $imported["SceneBattleReDux"] and YE::REDUX::BATTLE::MSG_CURRENT_ACTION
  692.       text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
  693.       @message_window.add_instant_text(text)
  694.     end
  695.     effect_usage(item, item.uie) if item.uie > 0
  696.     common_usage(item)
  697.     targets = @active_battler.action.make_targets
  698.     if $imported["CustomSkillEffects"] and item.csa > 0
  699.       custom_ani(targets, skill.csa)
  700.     else
  701.       display_animation(targets, item.animation_id)
  702.     end
  703.     consume_item(item)
  704.     for target in targets
  705.       target.item_effect(@active_battler, item)
  706.       display_action_effects(target, item)
  707.     end
  708.     effect_finish(item, item.fie) if item.fie > 0
  709.     common_finish(item)
  710.     $game_temp.common_event_id = item.common_event_id
  711.   end
  712.  
  713.   #--------------------------------------------------------------------------
  714.   # return active battler
  715.   #--------------------------------------------------------------------------
  716.   def active_battler
  717.     return @active_battler
  718.   end
  719.  
  720. end # Scene_Battle
  721.  
  722. #===============================================================================
  723. # Scene_Item
  724. #===============================================================================
  725.  
  726. class Scene_Item < Scene_Base
  727.  
  728.   #--------------------------------------------------------------------------
  729.   # alias use_item_nontarget
  730.   #--------------------------------------------------------------------------
  731.   alias use_item_nontarget_cia use_item_nontarget unless $@
  732.   def use_item_nontarget
  733.     if @item.change_var_id > 0
  734.       $game_variables[@item.change_var_id] += @item.change_var_amt
  735.     end
  736.     if @item.change_switch_id > 0
  737.       $game_switches[@item.change_switch_id] = @item.change_switch_flag
  738.     end
  739.     if @item.toggle_switch > 0
  740.       if $game_switches[@item.toggle_switch]
  741.         $game_switches[@item.toggle_switch] = false
  742.       else
  743.         $game_switches[@item.toggle_switch] = true
  744.       end
  745.     end
  746.     use_item_nontarget_cia
  747.   end
  748.  
  749. end # Scene_Item
  750.  
  751. #===============================================================================
  752. # Window_Item
  753. #===============================================================================
  754.  
  755. class Window_Item < Window_Selectable
  756.  
  757.   #--------------------------------------------------------------------------
  758.   # alias refresh
  759.   #--------------------------------------------------------------------------
  760.   alias refresh_window_item_cia refresh unless $@
  761.   def refresh
  762.     $game_temp.refreshing_cia = true
  763.     refresh_window_item_cia
  764.   end
  765.  
  766.   #--------------------------------------------------------------------------
  767.   # overwrite draw_item
  768.   #--------------------------------------------------------------------------
  769.   def draw_item(index)
  770.     $game_temp.refreshing_cia = false
  771.     rect = item_rect(index)
  772.     self.contents.clear_rect(rect)
  773.     item = @data[index]
  774.     if item != nil
  775.       number = $game_party.item_number(item)
  776.       enabled = enable?(item)
  777.       rect.width -= 4
  778.       draw_item_name(item, rect.x, rect.y, enabled)
  779.       draw_charges(item, rect, enabled)
  780.       self.contents.draw_text(rect, sprintf(YE::ITEM::DRAW_ITEM, number), 2)
  781.     end
  782.   end
  783.  
  784.   #--------------------------------------------------------------------------
  785.   # draw_charges
  786.   #--------------------------------------------------------------------------
  787.   def draw_charges(item, rect, enabled)
  788.     return unless item.item_charges > 1
  789.     return unless item.consumable
  790.     return if $game_party.item_number(item) <= 0
  791.     if $game_party.item_charges[item.id] == nil
  792.       $game_party.item_charges[item.id] = item.item_charges
  793.     end
  794.     charges = $game_party.item_charges[item.id]
  795.     dx = rect.x
  796.     dy = rect.y + WLH * 1 / 3
  797.     font_size = self.contents.font.size
  798.     font_bold = self.contents.font.bold
  799.     self.contents.font.size = YE::ITEM::CHARGE_SIZE
  800.     self.contents.font.bold = YE::ITEM::CHARGE_BOLD
  801.     self.contents.draw_text(dx, dy, 24, WLH * 2 / 3, charges, 2)
  802.     self.contents.font.size = font_size
  803.     self.contents.font.bold = font_bold
  804.   end
  805.  
  806. end # Window_Item
  807.  
  808. #===============================================================================
  809. #
  810. # END OF FILE
  811. #
  812. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement