Advertisement
Zeriab

[RGSS3] Geomancy skill

Dec 22nd, 2016
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.23 KB | None | 0 0
  1. ##
  2. # Copyright (c) 2016 Zeriab
  3. #
  4. # This software is provided 'as-is', without any express or implied
  5. # warranty. In no event will the authors be held liable for any damages
  6. # arising from the use of this software.
  7. #
  8. # Permission is granted to anyone to use this software for any purpose,
  9. # including commercial applications, and to alter it and redistribute it
  10. # freely, subject to the following restrictions:
  11. #
  12. # 1. The origin of this software must not be misrepresented; you must not
  13. #    claim that you wrote the original software. If you use this software
  14. #    in a product, an acknowledgement in the product documentation would be
  15. #    appreciated but is not required.
  16. # 2. Altered source versions must be plainly marked as such, and must not be
  17. #    misrepresented as being the original software.
  18. # 3. This notice may not be removed or altered from any source distribution.
  19. #
  20. ##
  21. # Interpreter command
  22. #
  23. # Use in a script call to set current geomancy tag:
  24. #   set_geomancy_tag(1)
  25. #
  26. # To disable geomancy use
  27. #   set_geomancy_tag(0)
  28. #
  29. def set_geomancy_tag(tag)
  30.   $game_player.geomancy_tag = tag
  31. end
  32.  
  33. ##
  34. # Add geomancy tags to skills
  35. #
  36. class RPG::Skill < RPG::UsableItem
  37.   attr_writer :geomancy_tags
  38.   def geomancy_tags
  39.     @geomancy_tags ||= []
  40.     return @geomancy_tags
  41.   end
  42.  
  43.   def add_tag(tag)
  44.     self.geomancy_tags << tag
  45.   end
  46.  
  47.   def geomancy?
  48.     !geomancy_tags.empty?
  49.   end
  50. end
  51.  
  52. ##
  53. # Player has a specific geomancy tag
  54. #
  55. class Game_Player < Game_Character
  56.   attr_accessor :geomancy_tag
  57.   def geomancy?
  58.     return geomancy_tag != nil && geomancy_tag > 0
  59.   end
  60.  
  61.   ##
  62.   # Clear geomancy tag upon transfer
  63.   #
  64.   alias_method :geomancy_clear_transfer_info, :clear_transfer_info
  65.   def clear_transfer_info
  66.     geomancy_clear_transfer_info
  67.     self.geomancy_tag = 0
  68.   end
  69.  
  70. end
  71.  
  72. ##
  73. # Geomancy skill check
  74. #
  75. class Game_BattlerBase
  76.   alias_method :geomancy_skill_conditions_met?, :skill_conditions_met?
  77.   def skill_conditions_met?(skill)
  78.     enabled = geomancy_skill_conditions_met?(skill)
  79.     # Geomancy conditions check
  80.     if enabled && skill.geomancy? && $game_player.geomancy?
  81.       enabled = skill.geomancy_tags.include?($game_player.geomancy_tag)
  82.     end
  83.     return enabled
  84.   end
  85. end
  86.  
  87. ##
  88. # Setup skill geomancy as post-processing part of loading the database
  89. #
  90. module DataManager
  91.   class << self
  92.     alias_method :geomancy_load_database, :load_database
  93.     def load_database(*args)
  94.       geomancy_load_database(*args)
  95.       database_post_process
  96.     end
  97.    
  98.     def database_post_process
  99.       setup_geomancy
  100.     end
  101.    
  102.     ##
  103.     # User interface for adding geomancy tags
  104.     #
  105.     def add_geomancy_tag(hash)
  106.       skill_id = hash[:skill_id]
  107.       tag = hash[:tag]
  108.       skill = $data_skills[skill_id]
  109.       unless skill.nil? || tag.nil?
  110.         skill.add_tag(tag)
  111.       end
  112.     end
  113.   end
  114. end    
  115.  
  116. __END__
  117. # Configuration section - I recommend putting this code in a different section of the script editor
  118. module DataManager
  119.   module_function
  120.   def setup_geomancy
  121.     # Specify geomancy tags here
  122.     # Note: Tags using 0 will be ignored    
  123.     add_geomancy_tag(:skill_id => 80, :tag => 1)    
  124.     add_geomancy_tag(:skill_id => 81, :tag => 2)    
  125.   end
  126. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement