Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if true # << Make true to use this script, false to disable.
- #===============================================================================
- #
- # ☆ $D13x - Equipment Durability
- # -- Author : Dekita
- # -- Version : 1.1
- # -- Level : Easy / Normal
- # -- Requires : $D13x - Unique Equipment
- # -- Engine : RPG Maker VX Ace.
- #
- #===============================================================================
- # ☆ Import
- #-------------------------------------------------------------------------------
- $D13x={}if$D13x==nil
- $D13x[:Equip_Durability] = true
- #===============================================================================
- # ☆ Updates
- #-------------------------------------------------------------------------------
- # D /M /Y
- # 18/o3/2o13 - Updated final version before release,
- # o9/o3/2o13 - Finished,
- # o6/o3/2o13 - Started,
- #
- #===============================================================================
- # ☆ Introduction
- #-------------------------------------------------------------------------------
- # This script allows for equipment to have a durability.
- # once the equipment durability reaches 0 it becomes unusable,
- # you can also make equips be removed from inventory when they break.
- #
- #===============================================================================
- # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
- #===============================================================================
- # 1. You MUST give credit to "Dekita" !!
- # 2. You are NOT allowed to repost this script.(or modified versions)
- # 3. You are NOT allowed to convert this script.
- # 4. You are NOT allowed to use this script for Commercial games.
- # 5. ENJOY!
- #
- # "FINE PRINT"
- # By using this script you hereby agree to the above terms and conditions,
- # if any violation of the above terms occurs "legal action" may be taken.
- # Not understanding the above terms and conditions does NOT mean that
- # they do not apply to you.
- # If you wish to discuss the terms and conditions in further detail you can
- # contact me at http://dekitarpg.wordpress.com/
- #
- #===============================================================================
- # ☆ Instructions
- #-------------------------------------------------------------------------------
- # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
- # Place Under My $D13x Equipment Individualize script.
- #
- #===============================================================================
- # ☆ Notetags ( default )
- # For use with Weapon / Armor noteboxes !
- #-------------------------------------------------------------------------------
- # <durab: F>
- # Replace F with a float value, ie 1.1 / 2.5 / 3.8 / 4.4 / 5.1 ect
- #
- #===============================================================================
- module Equip_Durability
- #===============================================================================
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ☆ Customisation Settings
- #--------------------------------------------------------------------------
- # If this is true, when an equip reaches 0 durability it will be removed from
- # the partys inventory, if false the equip will just be un-equipped.
- Remove_Equip_On_Break = true
- # All items will be given the default duability
- # Unless notetagged otherwise. (or given random endurance feature)
- Default_Durability = 20.00
- # This is the durability damage formula used when player
- # is attacking the enemy.
- def self.formula_when_attack(actor, enemy, equip, hp_dam, mp_dam)
- return 0.0 if equip.etype_id != 0 # 0 damage if is NOT weapon
- # Gets Durability Damage Calculation
- damage = ( (0.01 * ( (enemy.def + enemy.mdf ) / 100 + 1) ) / 100.0 * hp_dam )
- damage *= 2.0 if hp_dam.to_i > enemy.mhp # 2 * DMG if OneShot The Enemy.
- return damage # Returns Damage
- end
- # This is the default formula for when player is defending.
- def self.formula_when_defend(actor, enemy, equip, hp_dam, mp_dam)
- return 0.0 if equip.etype_id == 0 # 0 damage if is weapon
- # Gets Durability Damage Calculation
- damage = 0.01 * ( hp_dam.to_f / 10 )
- # Randomly Break Equip If Actor got OneShot [ default chance is 10% ]
- if hp_dam.to_i > actor.mhp
- do_break = rand(100) < 10 ? true : false
- equip.kill_self if do_break
- end
- return damage # Returns Damage
- end
- # Notetag used for durability
- Durability_Note = /<durab:(.*)>/i
- # This option requiresmy $D13x Equipment Shops Script
- Repair_Vocab = "Repair"
- # These options require my $D13x Equipment Screen Script
- Durability_V = "Durability"
- # This will show durability as a percentage if true, else 12.34/56.00 .
- Show_Percent = false
- #####################
- # CUSTOMISATION END #
- end #####################
- #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
- # #
- # http://dekitarpg.wordpress.com/ #
- # #
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
- #===============================================================================#
- # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
- # YES?\.\. #
- # OMG, REALLY? \| #
- # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
- # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
- #===============================================================================#
- class RPG::EquipItem < RPG::BaseItem
- #===============================================================================
- #---------------------------------------------------------------------------
- # Included modules
- #---------------------------------------------------------------------------
- include Equip_Durability
- #---------------------------------------------------------------------------
- # Alias List
- #---------------------------------------------------------------------------
- alias :deki_equip_Durab :load_unique_equip
- #---------------------------------------------------------------------------
- # Pi Variables
- #---------------------------------------------------------------------------
- attr_accessor :durability
- attr_accessor :max_durability
- attr_accessor :durab_rate
- #---------------------------------------------------------------------------
- # load unique shit
- #---------------------------------------------------------------------------
- def load_unique_equip
- deki_equip_Durab
- @durability = Default_Durability
- @durab_rate = 0
- @is_alive = true
- self.note.split(/[\r\n]+/).each do |line|
- case line
- when Durability_Note
- @durability = $1.to_f
- end
- end
- @max_durability = @durability
- end
- #--------------------------------------------------------------------------
- # Checks Need Repair
- #--------------------------------------------------------------------------
- def durability_full?
- return @durability == @max_durability
- end
- #--------------------------------------------------------------------------
- # Lose Durability
- #--------------------------------------------------------------------------
- def hurt_self(pain)
- @durability -= (pain * (1.0-(@durab_rate.to_f/100))).to_f
- kill_self if is_dead?
- end
- #--------------------------------------------------------------------------
- # Suicide / Death Trigger
- #--------------------------------------------------------------------------
- def kill_self
- @durability = 0.0
- @is_alive = false
- end
- #--------------------------------------------------------------------------
- # Complete Equip Removal
- #--------------------------------------------------------------------------
- def total_removal
- return unless Remove_Equip_On_Break
- type = self.is_a?(RPG::Weapon) ? :weapon : :armor
- Cloning_101.delete_clone(type,self.id,true)
- end
- #--------------------------------------------------------------------------
- # Check For Battle Log Display
- #--------------------------------------------------------------------------
- def is_alive?
- return @is_alive
- end
- #--------------------------------------------------------------------------
- # Check Durability Above 0
- #--------------------------------------------------------------------------
- def is_dead?
- return true if @durability <= 0.0
- return false
- end
- #--------------------------------------------------------------------------
- # Restore Durability
- #--------------------------------------------------------------------------
- def heal_self
- @durability = @max_durability
- end
- end # RPG::EquipItem
- #==============================================================================
- class Game_Battler < Game_BattlerBase
- #==============================================================================
- #---------------------------------------------------------------------------
- # Alias List
- #---------------------------------------------------------------------------
- alias :exe_dmg_durab :execute_damage
- #--------------------------------------------------------------------------
- # Execute Damage
- #--------------------------------------------------------------------------
- def execute_damage(user)
- if user.is_a?(Game_Actor)
- user.equips.each do |equip|
- next if equip == nil
- hm = @result.hp_damage
- mm = @result.mp_damage
- pain = Equip_Durability.formula_when_attack(user,self,equip,hm,mm)
- equip.hurt_self(pain)
- end
- end
- # if user.is_a?(Game_Enemy)
- # self.equips.each do |equip|
- # next if equip == nil
- # hm = @result.hp_damage
- # mm = @result.mp_damage
- # pain = Equip_Durability.formula_when_defend(self,user,equip,hm,mm)
- # equip.hurt_self(pain)
- # end
- # end
- exe_dmg_durab(user)
- end
- end # Game_Battler
- #==============================================================================
- class Window_EquipItem < Window_ItemList
- #==============================================================================
- #---------------------------------------------------------------------------
- # Alias List
- #---------------------------------------------------------------------------
- alias :enable_durab? :enable?
- #--------------------------------------------------------------------------
- # Display in Enabled State?
- #--------------------------------------------------------------------------
- def enable?(item)
- return false if item == nil
- return false if item.durability <= 0.0
- enable_durab?(item)
- end
- end
- #==============================================================================
- class Equip_ShopCommand < Window_Command
- #==============================================================================
- #--------------------------------------------------------------------------
- # Add Repair Command
- #--------------------------------------------------------------------------
- def add_repair_command
- add_command(Equip_Durability::Repair_Vocab, :repair, equipment_need_repair?)
- end
- #--------------------------------------------------------------------------
- # Equip Need Repaired ?
- #--------------------------------------------------------------------------
- def equipment_need_repair?
- $game_party.battle_members.each do |m|
- m.equips.each do |e|
- next if e == nil
- next if e.durability_full?
- return true
- end
- end
- return false
- end
- end
- #==============================================================================
- class Durab_Wind_EquipSlot < Window_EquipSlot
- #==============================================================================
- #--------------------------------------------------------------------------
- # Initialization
- #--------------------------------------------------------------------------
- def initialize(x, y, w, h)
- @__w = w-(standard_padding*2)
- @__h = h
- super(x, y, w)
- end
- #--------------------------------------------------------------------------
- # Window Height
- #--------------------------------------------------------------------------
- def window_height
- return @__h
- end
- #--------------------------------------------------------------------------
- # Draw All Items
- #--------------------------------------------------------------------------
- def draw_all_items
- item_max.times {|i| draw_item(i) }
- end
- #--------------------------------------------------------------------------
- # Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- return unless @actor
- rect = item_rect_for_text(index)
- change_color(system_color, enable?(index))
- draw_text(rect.x, rect.y, 92, line_height, slot_name(index))
- nw = (self.width - 118)
- draw_item_name(@actor.equips[index], rect.x + 74, rect.y, enable?(index),nw)
- end
- #--------------------------------------------------------------------------
- # Enable Repair ?
- #--------------------------------------------------------------------------
- def enable?(index)
- return false unless @actor
- @actor.equips[index] != nil
- end
- end
- #==============================================================================
- class Window_BattleLog < Window_Selectable
- #==============================================================================
- #--------------------------------------------------------------------------
- # Display EquipBreak
- #--------------------------------------------------------------------------
- def display_equipbreak(target)
- return unless target.is_a?(Game_Actor)
- target.equips.each do |e|
- next if e == nil
- next if e.is_alive?#durability <= 0.0
- text = "%s's %s Has Broken !!"
- add_text(sprintf(text,target.name, e.name))
- if Equip_Durability::Remove_Equip_On_Break
- e.total_removal
- else
- target.change_equip(e.etype_id, nil)
- end
- end
- end
- end
- #==============================================================================#
- class Scene_Battle < Scene_Base
- #==============================================================================#
- #--------------------------------------------------------------------------
- # Alias List
- #--------------------------------------------------------------------------
- alias :equip_durab_pae :process_action_end
- #--------------------------------------------------------------------------
- # Process Action End
- #--------------------------------------------------------------------------
- def process_action_end
- process_equip_break
- equip_durab_pae
- end
- #--------------------------------------------------------------------------
- # Process Equip Break
- #--------------------------------------------------------------------------
- def process_equip_break
- return if @subject.is_a?(Game_Enemy)
- @log_window.display_equipbreak(@subject)
- @log_window.wait
- @log_window.wait_and_clear
- end
- end
- #==============================================================================#
- # http://dekitarpg.wordpress.com/ #
- #==============================================================================#
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement