Advertisement
Black_Mage

Katharsis Script & Bugfix

Sep 2nd, 2019
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.92 KB | None | 0 0
  1. #===============================================================================
  2. # 1st problem.
  3. #===============================================================================
  4. class Game_Interpreter
  5.   def space_on_grid?(type, id)
  6.     item = b_get_item(type, id); a = b_grid_available?(type, id)
  7.     $game_party.lune_grid_gain_item(item, 1, include_equip = false) if a
  8.   end
  9.   def b_get_item(type,id)
  10.     case type
  11.     when 1; return $data_items[id]
  12.     when 2; return $data_weapons[id]
  13.     when 3; return $data_armors[id]
  14.     end
  15.   end
  16.   def b_grid_available?(type, id)
  17.     case type
  18.     when 1; return $game_party.check_grid_available($data_items[id])
  19.     when 2; return $game_party.check_grid_available($data_weapons[id])
  20.     when 3; return $game_party.check_grid_available($data_armors[id])
  21.     end
  22.   end
  23. end
  24. #===============================================================================
  25.  
  26. #===============================================================================
  27. # 2nd problem.
  28. #===============================================================================
  29. module Lune_Item_Grid
  30.   STAT_WIN_POS = [0,0]
  31. end
  32. class Scene_ItemBase < Scene_MenuBase
  33.   def show_sub_window(window)
  34.     window.x = Lune_Item_Grid::STAT_WIN_POS[0]
  35.     window.y = Lune_Item_Grid::STAT_WIN_POS[1]
  36.     window.show.activate
  37.   end
  38. end
  39. #===============================================================================
  40.  
  41. #===============================================================================
  42. # 3rd problem. Partial 8th Problem Fix.
  43. #===============================================================================
  44. class Game_Party < Game_Unit
  45.   def falcaopearl_itempop_gain(item, amount, include_equip = false, add_grid = true)
  46.     while amount > 0
  47.       lune_grid_gain_item(item, 1, include_equip = false) if check_grid_available(item, add_grid)
  48.       amount -= 1
  49.     end
  50.     if amount < 0
  51.       lune_grid_gain_item(item, amount, include_equip = false)
  52.       amount.abs.times {remove_item(item)}
  53.     end
  54.   end
  55. end
  56. class Game_Party < Game_Unit
  57.   def gain_item(item, amount, include_equip = false, add_grid = true)
  58.     if !item_container(item.class).nil? && SceneManager.scene_is?(Scene_Map)
  59.       if amount > 0
  60.         $game_system.item_object = [item, amount]
  61.         RPG::SE.new(PearlItemPop::ItemSe, 80).play rescue nil
  62.       end
  63.     end
  64.     falcaopearl_itempop_gain(item, amount, include_equip, add_grid)
  65.   end
  66. end
  67. class Game_Actor < Game_Battler
  68.   def trade_item_with_party(new_item, old_item)
  69.    
  70.     # 8th Problem Fix
  71.     return true if $game_temp.eqip_chnge && SceneManager.scene_is?(Scene_RepairEquip)
  72.     return true if $game_temp.eqip_chnge && SceneManager.scene_is?(Scene_QuickTool)
  73.     return false if new_item && !$game_party.has_item?(new_item)
  74.     if !old_item || $game_party.check_grid_available(old_item, false)
  75.       $game_party.gain_item(old_item, 1, false, false)
  76.       $game_party.lose_item(new_item, 1)
  77.     else
  78.       return false
  79.     end
  80.     return true
  81.   end
  82. end
  83. #===============================================================================
  84.  
  85. #===============================================================================
  86. # 4th & 9th problem.
  87. #===============================================================================
  88. class Game_Temp; attr_accessor :b_w; end
  89. class RPG::Weapon
  90.   def break_by_durability(actor)
  91.     actor.equips.each_index do |i|
  92.       if actor.equips[i] == self
  93.         actor.change_equip(i, nil)
  94.         if TH_Instance::Weapon::Destroy_Broken_Weapon
  95.           $game_party.gain_item(self, -1)
  96.         else
  97.           if broken_weapon_change
  98.             $game_party.gain_item($data_weapons[self.template_id], -1)
  99.             $game_party.gain_item($data_weapons[broken_weapon_change], 1)
  100.           end
  101.         end
  102.         break
  103.       end
  104.     end
  105.   end
  106. end
  107. #===============================================================================
  108.  
  109. #===============================================================================
  110. # 5th problem.
  111. #===============================================================================
  112. class Scene_Item < Scene_ItemBase
  113.   def command_release
  114.     return unless @item_window.selected_item
  115.     old_index = @item_window.index
  116.     @item_old = @item_window.selected_item
  117.     if @item_old.note.include?("<key_item>")
  118.       Sound.play_buzzer
  119.       @use_item.close
  120.       @item_window.activate  
  121.       return
  122.     end
  123.     cur_eq = $game_player.actor.equips[0]
  124.     $game_player.actor.change_equip_by_id(0,0)
  125.     $game_party.item_grid_x = @item_window.current_col
  126.     $game_party.item_grid_y = @item_window.current_row
  127.     $game_party.gain_item(@item_old, -1, true)
  128.     $game_party.item_grid_x = $game_party.item_grid_y = -1
  129.     @item_window.dispose
  130.     create_item_window
  131.     @use_item.close
  132.     @item_window.activate  
  133.     @item_window.index = old_index
  134.     $game_player.actor.change_equip(0, cur_eq) if $game_party.weapons.include?(cur_eq)
  135.   end
  136. end
  137. #===============================================================================
  138.  
  139. #===============================================================================
  140. # 6th problem.
  141. #===============================================================================
  142. class Window_EquipRepair < Window_ItemList
  143.   def make_item_list
  144.     actor = $game_player.actor
  145.     @data = $game_party.all_items.select {|item| include?(item) }
  146.     @data.push(actor.equips[0]) if actor.equips[0] != nil
  147.     @data.push(nil) if include?(nil)
  148.   end
  149. end
  150. #===============================================================================
  151.  
  152. #===============================================================================
  153. # 7th problem. Skillbar is affected by Victor Lighting Engine.
  154. #===============================================================================
  155. #module VICTOR_LIGHTING
  156. #  SHADE_Z = 0
  157. #end
  158. #class Sprite_Light < Sprite_Base
  159. #  def initialize(shade, viewport)
  160. #    super(viewport); @shade = shade
  161. #    self.bitmap     = Bitmap.new(Graphics.width, Graphics.height)
  162. #    self.blend_type = @shade.blend; self.opacity    = @shade.opacity
  163. #    self.z = VICTOR_LIGHTING::SHADE_Z; @lights = {}
  164. #  end
  165. #end
  166. #===============================================================================
  167.  
  168. #===============================================================================
  169. # 8th problem. Can't swap equip when Inventory is full.
  170. #===============================================================================
  171. class Game_Temp
  172.   attr_accessor :eqip_chnge; alias b_init_1 initialize
  173.   def initialize; b_init_1; @eqip_chnge = false; end
  174. end
  175. class Game_Actor < Game_Battler
  176.   def th_instance_items_change_equip(slot_id, item)
  177.     $game_temp.eqip_chnge = true
  178.     if !trade_item_with_party(item, equips[slot_id])
  179.       $game_temp.eqip_chnge = false
  180.       return
  181.     end
  182.     $game_temp.eqip_chnge = false
  183.     return if item && equip_slots[slot_id] != item.etype_id
  184.     @equips[slot_id].object = item
  185.     refresh
  186.   end
  187. end
  188. #===============================================================================
  189.  
  190. #===============================================================================
  191. # Repair Broken Item.
  192. #===============================================================================
  193. # Tag the broken version of the weapon that you want to appear on the repair
  194. # scene with:
  195. #
  196. # <broken_item n>
  197. #
  198. # where n is the weapon ID of it's repaired version.
  199. #===============================================================================
  200. class RPG::Weapon
  201.   def broken?; self.note =~ /<broken_item (\d+)>/ ? [true, $1.to_i] : [false,-1]; end
  202.   alias b_c_rep? can_repair?
  203.   def can_repair?; broken?[0] ? true : b_c_rep?; end
  204.   alias b_rep_prc repair_price
  205.   def repair_price; broken?[0] ? 0 : b_rep_prc; end
  206.   def repair_broken_item
  207.     $game_party.gain_item($data_weapons[template_id], -1)
  208.     $game_party.gain_item($data_weapons[broken?[1]], 1)
  209.   end
  210. end
  211. class Window_EquipRepair < Window_ItemList
  212.   def include?(item)
  213.     !item.is_a?(RPG::Item) && !item.nil? && (item.use_durability || item.broken?[0])
  214.   end
  215. end
  216. class Scene_RepairEquip < Scene_ItemBase
  217.   # Overwrite on_item_ok method.
  218.   def on_item_ok
  219.     $game_party.lose_gold(item.repair_price)
  220.     item.broken?[0] ? item.repair_broken_item : item.repair
  221.     @gold_window.refresh; on_item_sound; activate_item_window
  222.   end
  223. end
  224. #===============================================================================
  225.  
  226. #===============================================================================
  227. # Unequip weapon by selecting the empty slot.
  228. #===============================================================================
  229. class Window_ActorQuickTool < Window_Selectable
  230.   def refresh(actor, kind)
  231.     self.contents.clear if self.contents != nil
  232.     @data = []
  233.     if kind == :weapon
  234.       operand = $game_party.weapons
  235.       operand.push(actor.equips[0]) if actor.equips[0] != nil
  236.     end
  237.     if kind == :armor
  238.       operand = $game_party.armors
  239.       operand.push(actor.equips[1]) if actor.equips[1] != nil
  240.     end
  241.     operand = $game_party.items if kind == :item
  242.     operand = actor.skills if kind == :skill
  243.     for item in operand
  244.       if kind == :weapon || kind == :armor
  245.         next unless actor.equippable?(item)
  246.         next if item.etype_id > 1
  247.       end
  248.       unless @data.include?(item)
  249.         next if item.tool_data("Exclude From Tool Menu = ", false) == "true"
  250.         @data.push(item)
  251.       end
  252.     end
  253.     @data.push(nil) if @data.size > 0
  254.     @item_max = @data.size
  255.     if @item_max > 0
  256.       self.contents = Bitmap.new(width - 32, row_max * 24)
  257.       for i in 0...@item_max
  258.         draw_item(i)
  259.       end
  260.     end
  261.   end
  262.   def draw_item(index)
  263.     item = @data[index]
  264.     return if !item
  265.     x, y = index % col_max * (190 + 32), index / col_max  * 24
  266.     self.contents.font.size = 20
  267.     draw_icon(item.icon_index, x, y)
  268.     contents.draw_text(x + 24, y, 212, 32, item.name)
  269.   end
  270. end
  271. class Scene_QuickTool < Scene_MenuBase
  272.   def perform_item_ok
  273.     if @items_w.item.nil?
  274.       actor.change_equip(0, @items_w.item)
  275.     else
  276.       case @type_select.current_symbol
  277.       when :weapon; (actor.change_equip_by_id(0, @items_w.item.id); equip_play)
  278.       when :armor; (actor.change_equip_by_id(1, @items_w.item.id); equip_play)
  279.       when :item; activate_slots
  280.       when :skill; activate_slots
  281.       end
  282.       DisplayTools.sprite.refresh_texts
  283.     end
  284.   end
  285. end
  286. #===============================================================================
  287.  
  288. #===============================================================================
  289. # Show durability on Skillbar.
  290. #===============================================================================
  291. class Sprite_PearlTool < Sprite
  292.   alias b_update update
  293.   def update; dur_update; b_update; end
  294.   def dur_update
  295.     self.bitmap.clear
  296.     return if !@actor.equips[0]
  297.     a = @actor.equips[0].durability.to_s + "/" + @actor.equips[0].max_durability.to_s
  298.     self.bitmap.draw_text(18, 36, 32,32, a, 1)
  299.   end
  300. end
  301. #===============================================================================
  302.  
  303. #===============================================================================
  304. # Reduce Duct Tape after repairing.
  305. #===============================================================================
  306. module TH_Instance
  307.   module Scene_Repair
  308.     ITEM_COST_ID = 5
  309.   end
  310. end
  311. class Scene_RepairEquip < Scene_ItemBase
  312.   alias b_o_i_o on_item_ok
  313.   def on_item_ok
  314.     cost_item = $data_items[TH_Instance::Scene_Repair::ITEM_COST_ID]
  315.     $game_party.gain_item(cost_item, -1); b_o_i_o
  316.   end
  317. end
  318. class Window_EquipRepair < Window_ItemList
  319.   def enable?(item)
  320.     return false if !has_item_cost?
  321.     return true if item.is_a?(RPG::EquipItem) && item.can_repair? && $game_party.gold >=  item.repair_price
  322.     return false
  323.   end
  324.   def has_item_cost?
  325.     cost_item = $data_items[TH_Instance::Scene_Repair::ITEM_COST_ID]
  326.     return true if TH_Instance::Scene_Repair::ITEM_COST_ID != 0 && $game_party.has_item?(cost_item)
  327.     return false
  328.   end
  329. end
  330. #===============================================================================
  331.  
  332. #===============================================================================
  333. # Make fast collapse effect on nil.
  334. #===============================================================================
  335. class Game_CharacterBase
  336.   alias b_u_b_c update_battler_collapse
  337.   def update_battler_collapse
  338.     if battler.collapse_type.nil? && @colapse_time > 0
  339.       @colapse_time = 1
  340.       $game_self_switches[[$game_map.map_id, @id, PearlKernel::DeadposeSelfW]] = false
  341.     end
  342.     b_u_b_c
  343.   end
  344. end
  345. #===============================================================================
  346.  
  347. #===============================================================================
  348. # After toss, highlight use.
  349. #===============================================================================
  350. class Scene_Item < Scene_ItemBase
  351.   alias b_c_r command_release
  352.   def command_release; b_c_r; @use_item.index = 0; end
  353.   def update
  354.     super
  355.     if Input.trigger?(:B) and !@use_item.close?
  356.       Sound.play_cancel; @use_item.close; @item_window.activate
  357.       @use_item.index = 0
  358.     end
  359.   end
  360. end
  361. #===============================================================================
  362.  
  363. #===============================================================================
  364. # The https://i.imgur.com/3VOsjLy.png Fix. Probably.
  365. #===============================================================================
  366. class Sprite_DamagePop < Sprite
  367.   alias b_c_t_f_d create_text_for_display
  368.   def create_text_for_display
  369.     return if @target.target.battler.nil?; b_c_t_f_d
  370.   end
  371. end
  372. #===============================================================================
  373.  
  374. #===============================================================================
  375. # The repair window have equip duplicate. Not sure why but somehow this fixes it.
  376. #===============================================================================
  377. class Window_EquipRepair < Window_ItemList
  378.   def make_item_list
  379.     @data = $game_party.all_items.select {|item| include?(item) }
  380.     @data.push(nil) if include?(nil); @data
  381.   end
  382. end
  383. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement