Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- RGSS3 Item Destruction Rate Ver.1.11 2012/03/26 mo-to
- TKOOL COOL
- http://mototkool.blog.fc2.com/
- ★Usage★
- Paste this script above Main.
- In the item's Note box, put <probability destroy n%> n = 1 to 99.
- Ex.) If <probability destroy 30%> in the Note box for the item "potion"
- When used, there is a 30% chance of using up a "potion".
- ★Overview★
- You can create items that are used with probability.
- ★Update history★
- Ver.1.00 Initial released
- Ver.1.10 Added a message for broken
- Ver.1.11 Item name can also be displayed
- =end
- #↓Customization
- module MOTO
- #Disrupted message displayed on the menu screen (control characters available)
- MESSEGE = "\\C[2] is broken!"
- #Broken message displayed during battle
- BATTLE_MESSEGE = "%s is broken!"
- end
- #So far
- class RPG::Item < RPG::UsableItem
- #--------------------------------------------------------------------------
- # ☆ Acquisition of memo field
- #--------------------------------------------------------------------------
- def item_break_rate_set
- @item_break_rate = nil
- self.note.each_line { |line|
- case line
- when /<probability destroy \s*(\d+)([%%])?>/
- @item_break_rate = $1.to_i
- end
- }
- end
- #--------------------------------------------------------------------------
- # ☆ Acquisition of destruction probability
- #--------------------------------------------------------------------------
- def item_break_rate
- item_break_rate_set if @item_break_rate == nil
- return @item_break_rate
- end
- end
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ☆ Public instance variable
- #--------------------------------------------------------------------------
- attr_accessor :lose_item_window # Item disruption window display flag
- #--------------------------------------------------------------------------
- # ○ Object initialization
- #--------------------------------------------------------------------------
- alias ori_moto_initialize initialize
- def initialize
- ori_moto_initialize
- @lose_item_window = false
- end
- #--------------------------------------------------------------------------
- # ○ Item consumption
- # If the specified item is consumed, reduce the number of possession.
- #--------------------------------------------------------------------------
- alias ori_moto_consume_item consume_item
- def consume_item(item)
- break_rate = rand(100) + 1
- if item.item_break_rate != nil && item.item_break_rate < break_rate &&
- item.is_a?(RPG::Item) && item.consumable
- lose_item(item, 0)
- elsif item.item_break_rate != nil && item.item_break_rate > break_rate &&
- item.is_a?(RPG::Item) && item.consumable
- lose_item(item, 1)
- @lose_item_window= true
- else
- ori_moto_consume_item(item)
- end
- end
- end
- class Window_Mini_Messege < Window_Selectable
- #--------------------------------------------------------------------------
- # ☆ Object initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, window_width, window_height)
- @item = nil
- self.visible = false
- end
- #--------------------------------------------------------------------------
- # ☆ Item, setting of maximum number
- #--------------------------------------------------------------------------
- def set(item)
- @item = item
- refresh
- end
- #--------------------------------------------------------------------------
- # ☆ Get window width
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width / 2
- end
- #--------------------------------------------------------------------------
- # ☆ Get window height
- #--------------------------------------------------------------------------
- def window_height
- return 72
- end
- #--------------------------------------------------------------------------
- # ☆ Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.x = (Graphics.width - width) / 2
- self.y = (Graphics.height - height) / 2
- self.z = 255
- draw_item_name(@item, 0, 0)
- draw_text_ex(0, 26, MOTO::MESSEGE)
- end
- end
- class Window_BattleLog < Window_Selectable
- #--------------------------------------------------------------------------
- # ● Display action results
- #--------------------------------------------------------------------------
- def display_action_results(target, item)
- if target.result.used
- last_line_number = line_number
- display_critical(target, item)
- display_damage(target, item)
- display_affected_status(target, item)
- display_failure(target, item)
- display_lose_item(item)
- wait if line_number > last_line_number
- back_to(last_line_number)
- end
- end
- #--------------------------------------------------------------------------
- # ☆ Display when item is broken
- #--------------------------------------------------------------------------
- def display_lose_item(item)
- if $game_party.lose_item_window
- add_text(sprintf(MOTO::BATTLE_MESSEGE, item.name))
- $game_party.lose_item_window = false
- wait
- end
- end
- end
- class Scene_ItemBase < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ○ Start process
- #--------------------------------------------------------------------------
- alias ori_moto_start start
- def start
- ori_moto_start
- create_mini_messege_window
- end
- #--------------------------------------------------------------------------
- # ☆ Create mini window
- #--------------------------------------------------------------------------
- def create_mini_messege_window
- @mini_messege_window = Window_Mini_Messege.new
- @mini_messege_window.set_handler(:ok, method(:on_winclose_ok))
- @mini_messege_window.set_handler(:cancel, method(:on_winclose_cancel))
- end
- #--------------------------------------------------------------------------
- # ☆ Mini window close [Ok]
- #--------------------------------------------------------------------------
- def on_winclose_ok
- @mini_messege_window.hide
- @actor_window.activate
- @actor_window.refresh
- end
- #--------------------------------------------------------------------------
- # ☆ Mini window close [cancel]
- #--------------------------------------------------------------------------
- def on_winclose_cancel
- @mini_messege_window.hide
- @actor_window.activate
- @actor_window.refresh
- end
- #--------------------------------------------------------------------------
- # ○ Use item
- #--------------------------------------------------------------------------
- alias ori_moto_use_item use_item
- def use_item
- ori_moto_use_item
- if $game_party.lose_item_window
- @actor_window.deactivate
- @mini_messege_window.set(item)
- @mini_messege_window.show
- @mini_messege_window.activate
- $game_party.lose_item_window = false
- Input.update
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement