Advertisement
TroyZ

TroyZ - Skill HP Cost

May 29th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.52 KB | None | 0 0
  1. # ==============================================================================
  2. # ▼▼▼▼▼▼                    TroyZ - Skill HP Cost                         ▼▼▼▼▼▼
  3. # ==============================================================================
  4. # Script by : Agung Prasetyo(TroyZ)
  5. # Contact me by : - Email agung.endisnear.xyz@gmail.com
  6. #                 - Forum RPGMakerID, username TroyZ
  7. #                 - Handphone 085756289121
  8. # Engine : VXAce
  9. # Level : Normal
  10. # Version : 1.0
  11. # ------------------------------------------------------------------------------
  12. # Change Logs :
  13. # 29 Mei 2013 - Rilis script versi 1.0
  14. # ------------------------------------------------------------------------------
  15. # How this work :
  16. # Dengan script ini kamu bisa memasang HP sebagai cost dari sebuah skill. Cocok
  17. # untuk petarung dengan HP yang tebal yang biasanya kurang mendapatkan MP.
  18. # ------------------------------------------------------------------------------
  19. # How to use :
  20. # Pasang dibawah material dan diatas main. Untuk menggunakan HP sebagai cost dari
  21. # sebuah skill, tuliskan seperti ini di notetag dari skill tersebut :
  22. # <hp cost: x>
  23. # Dimana x adalah cost dari HP itu sendiri. Contohnya :
  24. # <hp cost: 50>
  25. # Maka setiap kali menggunakan skill tersebut, 50 HP akan terkuras dari battler
  26. # tersebut. Jika battler memiliki HP tersisa sama dengan HP cost skill tersebut,
  27. # skill tersebut tidak bisa digunakan.
  28. # ------------------------------------------------------------------------------
  29. # Who to credit :
  30. # - Allah swt. : Untuk kesempatan ke rahmat yang sudah Dia berikan.
  31. # - Nabi Muhammad saw. : Yang sudah menjadi pemimpin umat yang menurut saya PERFECT.
  32. #                        Saya bangga jadi umatmu. :)
  33. # - Agung Prasetyo(TroyZ) : Ya saya, yang buat script kan saya. :P
  34. # - Tio Allin Subiantoro(Theo Allen) : Thankz buat petunjuk notetagnya. :v
  35. # ------------------------------------------------------------------------------
  36. # License :
  37. # - Free Game : Silahkan dengan syarat credit diatas dicantumkan.
  38. # - Commercial Game : Syarat yang sama dengan Free Game + game komersilnya yang
  39. #                     full versi diberikan secara gratis untuk saya. :P
  40. # ------------------------------------------------------------------------------
  41. $imported = {} if $imported.nil?
  42. $imported[:TroyZ_SkillHPCost] = true
  43.  
  44. module TROYZ
  45.   module HP_COST
  46.     HP_COST_DEFAULT = 0 # HP Cost skill yang tidak punya notetag <hp cost: x>
  47.   end
  48. # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  49. # BATAS KONFIGURASI. DILARANG MELEWATI GARIS INI
  50. # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  51.   module NOTETAGS_HP_COST
  52.     HP_COST = /<(?:HP COST|hp cost):[ ]*(\d+)>/i
  53.   end
  54. end
  55. module DataManager
  56.   class << self
  57.     alias x_load_hp_cost_dbase_x    load_database
  58.   end
  59.  
  60.   def self.load_database
  61.     x_load_hp_cost_dbase_x
  62.     x_pake_hp_cost_notetags_x
  63.   end
  64.  
  65.   def self.x_pake_hp_cost_notetags_x
  66.     [$data_skills].each do |skills|
  67.       skills.each do |obj|
  68.         next unless obj
  69.         obj.x_pake_hp_cost_notetags_x
  70.       end
  71.     end
  72.   end
  73. end
  74.  
  75. class RPG::Skill
  76.   attr_accessor :hp_cost
  77.   alias x_init_x    initialize
  78.   def initialize
  79.     x_init_x
  80.     @hp_cost = TROYZ::HP_COST::HP_COST_DEFAULT
  81.   end
  82.  
  83.   def x_pake_hp_cost_notetags_x
  84.     @hp_cost = TROYZ::HP_COST::HP_COST_DEFAULT
  85.     self.note.split(/[\r\n]+/).each { |baris|
  86.       case baris
  87.       when TROYZ::NOTETAGS_HP_COST::HP_COST
  88.         @hp_cost = $1.to_i
  89.       end
  90.     }
  91.   end  
  92. end
  93.  
  94. class Game_BattlerBase
  95.   def skill_hp_cost(skill)
  96.     skill.hp_cost
  97.   end
  98.  
  99.   def skill_cost_payable?(skill)
  100.     tp >= skill_tp_cost(skill) && mp >= skill_mp_cost(skill) && hp > skill_hp_cost(skill)
  101.   end
  102.  
  103.   alias x_bayar_skill_x   pay_skill_cost
  104.   def pay_skill_cost(skill)
  105.     x_bayar_skill_x(skill)
  106.     self.hp -= skill_hp_cost(skill)
  107.   end
  108. end
  109.  
  110. class Window_SkillList < Window_Selectable
  111.   def draw_skill_cost(rect, skill)
  112.     if @actor.skill_tp_cost(skill) > 0
  113.       change_color(tp_cost_color, enable?(skill))
  114.       draw_text(rect, @actor.skill_tp_cost(skill), 2)  
  115.     elsif @actor.skill_mp_cost(skill) > 0
  116.       change_color(mp_cost_color, enable?(skill))
  117.       draw_text(rect, @actor.skill_mp_cost(skill), 2)      
  118.     elsif @actor.skill_hp_cost(skill) > 0
  119.       change_color(hp_cost_color, enable?(skill))
  120.       draw_text(rect, @actor.skill_hp_cost(skill), 2)  
  121.     end    
  122.   end
  123. end
  124.  
  125. class Window_Base < Window
  126.   def hp_cost_color
  127.     text_color(2)
  128.   end  
  129. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement