TheoAllen

Theo - Extended Skill Weapon Req

Jun 22nd, 2013
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.51 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Extended Skill Weapon Requirement
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_SkillWeaponReqEX] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.06.21 - Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   Perkenalan :
  16.   Script ini berfungsi untuk menambahkan weapon requirement skill lebih dari
  17.   dua.
  18.  
  19.   Cara penggunaan :
  20.   Pasang dibawah material namun diatas main.
  21.  
  22.   Gunakan tag ini pada database skill:  
  23.   <require wtype: n>
  24.   <require wtype: n,n>
  25.  
  26.   Dimana n adalah nomor id type senjatanya
  27.  
  28.   Terms of use :
  29.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  30.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  31.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  32.  
  33. =end
  34. # =============================================================================
  35. # Tidak ada konfigurasi
  36. # =============================================================================
  37. module THEO
  38.   module SKILL
  39.   module REGEXP
  40.    
  41.   EXT_WTYPE = /<(?:REQUIRE_WTYPE|require wtype): [ ]*[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  42.    
  43.   end
  44.   end
  45. end
  46.  
  47. class << DataManager
  48.  
  49.   alias pre_skillreqext_load_db load_database
  50.   def load_database
  51.     pre_skillreqext_load_db
  52.     load_ext_skill_wtypes
  53.   end
  54.  
  55.   def load_ext_skill_wtypes
  56.     $data_skills.compact.each do |skill|
  57.       skill.load_ext_wtypes
  58.     end
  59.   end
  60.  
  61. end
  62.  
  63. class RPG::Skill < RPG::UsableItem
  64.   attr_accessor :wtype_array
  65.  
  66.   include THEO::SKILL
  67.  
  68.   def load_ext_wtypes
  69.     @wtype_array = []
  70.     self.note.split(/[\r\n]+/).each do |line|
  71.       case line
  72.       when REGEXP::EXT_WTYPE
  73.         $1.scan(/\d+/).each do |num|
  74.           @wtype_array.push(num.to_i)
  75.         end
  76.       end
  77.     end
  78.   end
  79.  
  80. end
  81.  
  82. class Game_Actor < Game_Battler
  83.  
  84.   alias ori_wtype_ok? skill_wtype_ok?
  85.   def skill_wtype_ok?(skill)
  86.     ori_wtype_ok?(skill) || ext_wtype_ok?(skill)
  87.   end
  88.  
  89.   def ext_wtype_ok?(skill)
  90.     skill.wtype_array.any? do |wtype_id|
  91.       wtype_equipped?(wtype_id)
  92.     end
  93.   end
  94.  
  95. end
Advertisement
Add Comment
Please, Sign In to add comment