Advertisement
roninator2

Lecode Item effects outside battle - mod

Dec 13th, 2024
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.41 KB | None | 0 0
  1. #==============================================================================
  2. # Different effects outside the battle
  3. # By Lecode
  4. #----------------------
  5. # Use <when_outside: x> on skills and items notetags.
  6. # When the party is outside, the effects of the skill/item with
  7. # the ID x w'll be used instead of the selected skill/item's effects
  8. # Added <when_inside: x> - Roninator2
  9. #==============================================================================
  10. module Lecode_ItemOutside
  11.   def self.get_outside_item(item)
  12.     return item if $game_party.in_battle
  13.     other_id = item.outside_item_id
  14.     if other_id > 0
  15.       if item.is_a?(RPG::Skill)
  16.         return $data_skills[other_id]
  17.       elsif item.is_a?(RPG::Item)
  18.         return $data_items[other_id]
  19.       end
  20.     end
  21.     return item
  22.   end
  23.   def self.get_inside_item(item)
  24.     return item if !$game_party.in_battle
  25.     other_id = item.inside_item_id
  26.     if other_id > 0
  27.       if item.is_a?(RPG::Skill)
  28.         return $data_skills[other_id]
  29.       elsif item.is_a?(RPG::Item)
  30.         return $data_items[other_id]
  31.       end
  32.     end
  33.     return item
  34.   end
  35. end
  36.  
  37. class Scene_ItemBase
  38.   def use_item_to_actors
  39.     true_item = Lecode_ItemOutside.get_outside_item(item)
  40.     item_target_actors.each do |target|
  41.       true_item.repeats.times { target.item_apply(user, true_item) }
  42.     end
  43.   end
  44. end
  45.  
  46. class Game_Battler
  47.   def use_item(item)
  48.     pay_skill_cost(item) if item.is_a?(RPG::Skill)
  49.     consume_item(item) if item.is_a?(RPG::Item)
  50.     true_item = Lecode_ItemOutside.get_outside_item(item)
  51.     if true_item.nil?
  52.       item.effects.each {|effect| item_global_effect_apply(effect) }
  53.     else
  54.       true_item.effects.each {|effect| item_global_effect_apply(effect) }
  55.     end
  56.   end
  57. end
  58.  
  59. class RPG::UsableItem
  60.   def outside_item_id
  61.     self.note =~ /<when_outside:[ ]?(.+)>/ ? $1.to_i : 0
  62.   end
  63.   def inside_item_id
  64.     self.note =~ /<when_inside:[ ]?(.+)>/ ? $1.to_i : 0
  65.   end
  66. end
  67.  
  68. class Scene_Battle < Scene_Base
  69.   def use_item
  70.     item = @subject.current_action.item
  71.     true_item = Lecode_ItemOutside.get_inside_item(item)
  72.     @log_window.display_use_item(@subject, true_item)
  73.     @subject.use_item(true_item)
  74.     refresh_status
  75.     targets = @subject.current_action.make_targets.compact
  76.     show_animation(targets, true_item.animation_id)
  77.     targets.each {|target| true_item.repeats.times { invoke_item(target, true_item) } }
  78.   end
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement