Advertisement
Craze

Untitled

May 11th, 2020
2,917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.17 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Craze's Script Asylum - Equipment Tags v1.00
  4. # -- Last Updated: 2020.5.11
  5. # -- Level: Advanced/Scripter Tool
  6. # -- Requires: n/a
  7. # -- Terms: Freely modify and use, just don't claim it as your own.
  8. #           Please notify Craze of use in commercial projects (@silver_bolts),
  9. #           and I'll allow it 99% of the time for free.
  10. #
  11. #==============================================================================
  12.  
  13. $imported = {} if $imported.nil?
  14. $imported["CRZ-EquipmentTags"] = true
  15.  
  16. #==============================================================================
  17. # ▼ Updates
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # 2016-sometime - Started Script.
  20. # 2018.11.05 - Polished up Script for public use.
  21. # 2018.11.17 - Got around to testing bonus Script features; released on RMN.
  22. # 2020.5.11 - I actually expanded this a while ago. Pulls more data now.
  23. #
  24. #==============================================================================
  25. # ▼ Introduction
  26. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  27. # This is a scripter tool to let you easily check weapons, armors, and enemies
  28. # for unique effects. What this means is you can take any battler, ask if it
  29. # has a specific tag, and use that for whatever you want.
  30. #
  31. # This script does nothing on its own, but I hope it gives you the power to
  32. # create more inventive and ambitious games. :)
  33. #
  34. #==============================================================================
  35. # ▼ Instructions
  36. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  37. # To install this script, open up your script editor and copy/paste this script
  38. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  39. #
  40. # -----------------------------------------------------------------------------
  41. # Weapon, Armor, and Enemy Notetags -
  42. # These notetags go in those noteboxes in the database.
  43. # -----------------------------------------------------------------------------
  44. # <tag: string>
  45. #
  46. # Use with any string you can imagine.
  47. # Then, simply call for battler.e_tag?("string")
  48. #
  49. # For example, if you use <tag: cursed> on enemies, your Silver Bolts ability
  50. # could deal additional damage to those enemies.
  51. #
  52. # Or, you could proc an effect on a weapon where it recharges a bit of MP
  53. # because of <tag: manacrit> whenever you get a critical hit --
  54. # then user.e_tag?("manacrit") would let you do that.
  55. #
  56. # You'll need some additional coding knowledge. I suggest learning how to
  57. # use Yanfly's Lunatic Object/Damage/State scripts!
  58. #
  59. # Special thanks to Yanfly for teaching me how to code and giving me permission
  60. # a thousand years ago to use his script header format. <3
  61. #
  62. #==============================================================================
  63. # ▼ Compatibility
  64. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  65. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  66. # it will run with RPG Maker VX without adjusting.
  67. #
  68. # All methods are newly defined or common aliases,
  69. # so there's no reason it won't work. (Famous last words...!)
  70. #==============================================================================
  71.  
  72. class Game_Battler < Game_BattlerBase
  73.  
  74.   def e_tag?(str)
  75.     if enemy? # enemies don't have equipment.
  76.       return true if enemy.equip_tag.include?(str)
  77.       return false
  78.     else
  79.       return true if actor.equip_tag.include?(str)
  80.       for equip in weapons
  81.         next if equip.nil?
  82.         return true if equip.equip_tag.include?(str)
  83.       end
  84.       for equip in armors
  85.         next if equip.nil?
  86.         return true if equip.equip_tag.include?(str)
  87.       end
  88.       return false
  89.     end
  90.   end
  91.  
  92. end # Game_Battler
  93.  
  94. module CRZ
  95.   module REGEXP
  96.   module BASEITEM
  97.    
  98.     EQUIP_TAG = /<(?:TAG|tag):[ ]*(.*)>/i
  99.    
  100.   end # BASEITEM
  101.   end # REGEXP
  102. end # CRZ
  103.  
  104. #==============================================================================
  105. # ■ DataManager
  106. #==============================================================================
  107.  
  108. module DataManager
  109.  
  110.   #--------------------------------------------------------------------------
  111.   # alias method: load_database
  112.   #--------------------------------------------------------------------------
  113.   class <<self; alias load_database_tagz load_database; end
  114.   def self.load_database
  115.     load_database_tagz
  116.     load_notetags_tagz
  117.   end
  118.  
  119.   #--------------------------------------------------------------------------
  120.   # new method: load_notetags_aee
  121.   #--------------------------------------------------------------------------
  122.   def self.load_notetags_tagz
  123.     groups = [$data_actors, $data_items, $data_armors, $data_weapons, $data_enemies, $data_skills]
  124.     for group in groups
  125.       for obj in group
  126.         next if obj.nil?
  127.         obj.load_notetags_tagz
  128.       end
  129.     end
  130.   end
  131.  
  132. end # DataManager
  133.  
  134.  
  135.  
  136. #==============================================================================
  137. # ■ RPG::BaseItem
  138. #==============================================================================
  139.  
  140. class RPG::BaseItem
  141.  
  142.   #--------------------------------------------------------------------------
  143.   # public instance variables
  144.   #--------------------------------------------------------------------------
  145.   attr_accessor :equip_tag
  146.  
  147.   #--------------------------------------------------------------------------
  148.   # common cache: load_notetags_tagz
  149.   #--------------------------------------------------------------------------
  150.   def load_notetags_tagz
  151.     @equip_tag = []
  152.     #---
  153.     self.note.split(/[\r\n]+/).each { |line|
  154.       case line
  155.       when CRZ::REGEXP::BASEITEM::EQUIP_TAG
  156.         @equip_tag.push($1.to_s)
  157.       #---
  158.       end
  159.     } # self.note.split
  160.     #---
  161.   end
  162.  
  163.   def e_tag?(str)
  164.     return true if @equip_tag.include?(str)
  165.     return false
  166.   end
  167.  
  168. end # RPG::BaseItem
  169.  
  170. #==============================================================================
  171. #
  172. # ▼ End of File
  173. #
  174. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement