Advertisement
Dekita

Equipdruab

Mar 29th, 2014
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.86 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Equipment Durability
  5. # -- Author : Dekita
  6. # -- Version : 1.1
  7. # -- Level : Easy / Normal
  8. # -- Requires : $D13x - Unique Equipment
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Equip_Durability] = true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 18/o3/2o13 - Updated final version before release,
  21. # o9/o3/2o13 - Finished,
  22. # o6/o3/2o13 - Started,
  23. #
  24. #===============================================================================
  25. # ☆ Introduction
  26. #-------------------------------------------------------------------------------
  27. # This script allows for equipment to have a durability.
  28. # once the equipment durability reaches 0 it becomes unusable,
  29. # you can also make equips be removed from inventory when they break.
  30. #
  31. #===============================================================================
  32. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  33. #===============================================================================
  34. # 1. You MUST give credit to "Dekita" !!
  35. # 2. You are NOT allowed to repost this script.(or modified versions)
  36. # 3. You are NOT allowed to convert this script.
  37. # 4. You are NOT allowed to use this script for Commercial games.
  38. # 5. ENJOY!
  39. #
  40. # "FINE PRINT"
  41. # By using this script you hereby agree to the above terms and conditions,
  42. # if any violation of the above terms occurs "legal action" may be taken.
  43. # Not understanding the above terms and conditions does NOT mean that
  44. # they do not apply to you.
  45. # If you wish to discuss the terms and conditions in further detail you can
  46. # contact me at http://dekitarpg.wordpress.com/
  47. #
  48. #===============================================================================
  49. # ☆ Instructions
  50. #-------------------------------------------------------------------------------
  51. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  52. # Place Under My $D13x Equipment Individualize script.
  53. #
  54. #===============================================================================
  55. # ☆ Notetags ( default )
  56. # For use with Weapon / Armor noteboxes !
  57. #-------------------------------------------------------------------------------
  58. # <durab: F>
  59. # Replace F with a float value, ie 1.1 / 2.5 / 3.8 / 4.4 / 5.1 ect
  60. #
  61. #===============================================================================
  62. module Equip_Durability
  63. #===============================================================================
  64. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  65. # ☆ Customisation Settings
  66. #--------------------------------------------------------------------------
  67. # If this is true, when an equip reaches 0 durability it will be removed from
  68. # the partys inventory, if false the equip will just be un-equipped.
  69. Remove_Equip_On_Break = true
  70.  
  71. # All items will be given the default duability
  72. # Unless notetagged otherwise. (or given random endurance feature)
  73. Default_Durability = 20.00
  74.  
  75. # This is the durability damage formula used when player
  76. # is attacking the enemy.
  77. def self.formula_when_attack(actor, enemy, equip, hp_dam, mp_dam)
  78. return 0.0 if equip.etype_id != 0 # 0 damage if is NOT weapon
  79. # Gets Durability Damage Calculation
  80. damage = ( (0.01 * ( (enemy.def + enemy.mdf ) / 100 + 1) ) / 100.0 * hp_dam )
  81. damage *= 2.0 if hp_dam.to_i > enemy.mhp # 2 * DMG if OneShot The Enemy.
  82. return damage # Returns Damage
  83. end
  84.  
  85. # This is the default formula for when player is defending.
  86. def self.formula_when_defend(actor, enemy, equip, hp_dam, mp_dam)
  87. return 0.0 if equip.etype_id == 0 # 0 damage if is weapon
  88. # Gets Durability Damage Calculation
  89. damage = 0.01 * ( hp_dam.to_f / 10 )
  90. # Randomly Break Equip If Actor got OneShot [ default chance is 10% ]
  91. if hp_dam.to_i > actor.mhp
  92. do_break = rand(100) < 10 ? true : false
  93. equip.kill_self if do_break
  94. end
  95. return damage # Returns Damage
  96. end
  97.  
  98. # Notetag used for durability
  99. Durability_Note = /<durab:(.*)>/i
  100.  
  101. # This option requiresmy $D13x Equipment Shops Script
  102. Repair_Vocab = "Repair"
  103.  
  104. # These options require my $D13x Equipment Screen Script
  105. Durability_V = "Durability"
  106.  
  107. # This will show durability as a percentage if true, else 12.34/56.00 .
  108. Show_Percent = false
  109.  
  110. #####################
  111. # CUSTOMISATION END #
  112. end #####################
  113. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  114. # #
  115. # http://dekitarpg.wordpress.com/ #
  116. # #
  117. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  118. #===============================================================================#
  119. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  120. # YES?\.\. #
  121. # OMG, REALLY? \| #
  122. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  123. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  124. #===============================================================================#
  125. class RPG::EquipItem < RPG::BaseItem
  126. #===============================================================================
  127. #---------------------------------------------------------------------------
  128. # Included modules
  129. #---------------------------------------------------------------------------
  130. include Equip_Durability
  131. #---------------------------------------------------------------------------
  132. # Alias List
  133. #---------------------------------------------------------------------------
  134. alias :deki_equip_Durab :load_unique_equip
  135. #---------------------------------------------------------------------------
  136. # Pi Variables
  137. #---------------------------------------------------------------------------
  138. attr_accessor :durability
  139. attr_accessor :max_durability
  140. attr_accessor :durab_rate
  141. #---------------------------------------------------------------------------
  142. # load unique shit
  143. #---------------------------------------------------------------------------
  144. def load_unique_equip
  145. deki_equip_Durab
  146. @durability = Default_Durability
  147. @durab_rate = 0
  148. @is_alive = true
  149. self.note.split(/[\r\n]+/).each do |line|
  150. case line
  151. when Durability_Note
  152. @durability = $1.to_f
  153. end
  154. end
  155. @max_durability = @durability
  156. end
  157. #--------------------------------------------------------------------------
  158. # Checks Need Repair
  159. #--------------------------------------------------------------------------
  160. def durability_full?
  161. return @durability == @max_durability
  162. end
  163. #--------------------------------------------------------------------------
  164. # Lose Durability
  165. #--------------------------------------------------------------------------
  166. def hurt_self(pain)
  167. @durability -= (pain * (1.0-(@durab_rate.to_f/100))).to_f
  168. kill_self if is_dead?
  169. end
  170. #--------------------------------------------------------------------------
  171. # Suicide / Death Trigger
  172. #--------------------------------------------------------------------------
  173. def kill_self
  174. @durability = 0.0
  175. @is_alive = false
  176. end
  177. #--------------------------------------------------------------------------
  178. # Complete Equip Removal
  179. #--------------------------------------------------------------------------
  180. def total_removal
  181. return unless Remove_Equip_On_Break
  182. type = self.is_a?(RPG::Weapon) ? :weapon : :armor
  183. Cloning_101.delete_clone(type,self.id,true)
  184. end
  185. #--------------------------------------------------------------------------
  186. # Check For Battle Log Display
  187. #--------------------------------------------------------------------------
  188. def is_alive?
  189. return @is_alive
  190. end
  191. #--------------------------------------------------------------------------
  192. # Check Durability Above 0
  193. #--------------------------------------------------------------------------
  194. def is_dead?
  195. return true if @durability <= 0.0
  196. return false
  197. end
  198. #--------------------------------------------------------------------------
  199. # Restore Durability
  200. #--------------------------------------------------------------------------
  201. def heal_self
  202. @durability = @max_durability
  203. end
  204.  
  205. end # RPG::EquipItem
  206.  
  207. #==============================================================================
  208. class Game_Battler < Game_BattlerBase
  209. #==============================================================================
  210. #---------------------------------------------------------------------------
  211. # Alias List
  212. #---------------------------------------------------------------------------
  213. alias :exe_dmg_durab :execute_damage
  214. #--------------------------------------------------------------------------
  215. # Execute Damage
  216. #--------------------------------------------------------------------------
  217. def execute_damage(user)
  218. if user.is_a?(Game_Actor)
  219. user.equips.each do |equip|
  220. next if equip == nil
  221. hm = @result.hp_damage
  222. mm = @result.mp_damage
  223. pain = Equip_Durability.formula_when_attack(user,self,equip,hm,mm)
  224. equip.hurt_self(pain)
  225. end
  226. end
  227. # if user.is_a?(Game_Enemy)
  228. # self.equips.each do |equip|
  229. # next if equip == nil
  230. # hm = @result.hp_damage
  231. # mm = @result.mp_damage
  232. # pain = Equip_Durability.formula_when_defend(self,user,equip,hm,mm)
  233. # equip.hurt_self(pain)
  234. # end
  235. # end
  236. exe_dmg_durab(user)
  237. end
  238.  
  239. end # Game_Battler
  240.  
  241. #==============================================================================
  242. class Window_EquipItem < Window_ItemList
  243. #==============================================================================
  244. #---------------------------------------------------------------------------
  245. # Alias List
  246. #---------------------------------------------------------------------------
  247. alias :enable_durab? :enable?
  248. #--------------------------------------------------------------------------
  249. # Display in Enabled State?
  250. #--------------------------------------------------------------------------
  251. def enable?(item)
  252. return false if item == nil
  253. return false if item.durability <= 0.0
  254. enable_durab?(item)
  255. end
  256.  
  257. end
  258.  
  259. #==============================================================================
  260. class Equip_ShopCommand < Window_Command
  261. #==============================================================================
  262. #--------------------------------------------------------------------------
  263. # Add Repair Command
  264. #--------------------------------------------------------------------------
  265. def add_repair_command
  266. add_command(Equip_Durability::Repair_Vocab, :repair, equipment_need_repair?)
  267. end
  268. #--------------------------------------------------------------------------
  269. # Equip Need Repaired ?
  270. #--------------------------------------------------------------------------
  271. def equipment_need_repair?
  272. $game_party.battle_members.each do |m|
  273. m.equips.each do |e|
  274. next if e == nil
  275. next if e.durability_full?
  276. return true
  277. end
  278. end
  279. return false
  280. end
  281.  
  282. end
  283.  
  284. #==============================================================================
  285. class Durab_Wind_EquipSlot < Window_EquipSlot
  286. #==============================================================================
  287. #--------------------------------------------------------------------------
  288. # Initialization
  289. #--------------------------------------------------------------------------
  290. def initialize(x, y, w, h)
  291. @__w = w-(standard_padding*2)
  292. @__h = h
  293. super(x, y, w)
  294. end
  295. #--------------------------------------------------------------------------
  296. # Window Height
  297. #--------------------------------------------------------------------------
  298. def window_height
  299. return @__h
  300. end
  301. #--------------------------------------------------------------------------
  302. # Draw All Items
  303. #--------------------------------------------------------------------------
  304. def draw_all_items
  305. item_max.times {|i| draw_item(i) }
  306. end
  307. #--------------------------------------------------------------------------
  308. # Draw Item
  309. #--------------------------------------------------------------------------
  310. def draw_item(index)
  311. return unless @actor
  312. rect = item_rect_for_text(index)
  313. change_color(system_color, enable?(index))
  314. draw_text(rect.x, rect.y, 92, line_height, slot_name(index))
  315. nw = (self.width - 118)
  316. draw_item_name(@actor.equips[index], rect.x + 74, rect.y, enable?(index),nw)
  317. end
  318. #--------------------------------------------------------------------------
  319. # Enable Repair ?
  320. #--------------------------------------------------------------------------
  321. def enable?(index)
  322. return false unless @actor
  323. @actor.equips[index] != nil
  324. end
  325.  
  326. end
  327.  
  328. #==============================================================================
  329. class Window_BattleLog < Window_Selectable
  330. #==============================================================================
  331. #--------------------------------------------------------------------------
  332. # Display EquipBreak
  333. #--------------------------------------------------------------------------
  334. def display_equipbreak(target)
  335. return unless target.is_a?(Game_Actor)
  336. target.equips.each do |e|
  337. next if e == nil
  338. next if e.is_alive?#durability <= 0.0
  339. text = "%s's %s Has Broken !!"
  340. add_text(sprintf(text,target.name, e.name))
  341. if Equip_Durability::Remove_Equip_On_Break
  342. e.total_removal
  343. else
  344. target.change_equip(e.etype_id, nil)
  345. end
  346. end
  347. end
  348.  
  349. end
  350.  
  351. #==============================================================================#
  352. class Scene_Battle < Scene_Base
  353. #==============================================================================#
  354. #--------------------------------------------------------------------------
  355. # Alias List
  356. #--------------------------------------------------------------------------
  357. alias :equip_durab_pae :process_action_end
  358. #--------------------------------------------------------------------------
  359. # Process Action End
  360. #--------------------------------------------------------------------------
  361. def process_action_end
  362. process_equip_break
  363. equip_durab_pae
  364. end
  365. #--------------------------------------------------------------------------
  366. # Process Equip Break
  367. #--------------------------------------------------------------------------
  368. def process_equip_break
  369. return if @subject.is_a?(Game_Enemy)
  370. @log_window.display_equipbreak(@subject)
  371. @log_window.wait
  372. @log_window.wait_and_clear
  373. end
  374.  
  375. end
  376.  
  377. #==============================================================================#
  378. # http://dekitarpg.wordpress.com/ #
  379. #==============================================================================#
  380.  
  381. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement