Advertisement
Kyriaki

Shanghai Simple Script - Teach Skill Items

Apr 27th, 2011
1,221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.22 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Teach Skill Items
  4. # Last Date Updated: 2010.05.03
  5. # Level: Normal
  6. #
  7. # This script allows the target character to learn a skill (outside of battle)
  8. # when an item containing those skill teaching properties is applied to that
  9. # character.
  10. #===============================================================================
  11. # Instructions
  12. # -----------------------------------------------------------------------------
  13. # To install this script, open up your script editor and copy/paste this script
  14. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  15. #
  16. # <teach skill: x>
  17. # <teach skill: x, x, x>
  18. # Place this in the item's notebox. Replace x with the ID of the skills you want
  19. # to teach the character. Use the comma version for multiple skills.
  20. #===============================================================================
  21.  
  22. $imported = {} if $imported == nil
  23. $imported["TeachSkillItems"] = true
  24.  
  25. #==============================================================================
  26. # RPG::BaseItem
  27. #==============================================================================
  28.  
  29. class RPG::BaseItem
  30.   #--------------------------------------------------------------------------
  31.   # teach_skills
  32.   #--------------------------------------------------------------------------
  33.   def teach_skills
  34.     return @teach_skills if @teach_skills != nil
  35.     @teach_skills = []
  36.     self.note.split(/[\r\n]+/).each { |line|
  37.       case line
  38.       when /<(?:TEACH SKILL|LEARN SKILL):[ ](\d+(?:\s*,\s*\d+)*)>/i
  39.         $1.scan(/\d+/).each { |num|
  40.         @teach_skills.push(num.to_i) if num.to_i > 0 }
  41.       end
  42.     }
  43.     return @teach_skills
  44.   end
  45. end
  46.  
  47. #==============================================================================
  48. # ** Game_Battler
  49. #==============================================================================
  50.  
  51. class Game_Battler
  52.   #--------------------------------------------------------------------------
  53.   # * Item Application Test
  54.   #--------------------------------------------------------------------------
  55.   alias item_test_sss_teachskillitems item_test unless $@
  56.   def item_test(user, item)
  57.     return true if item.teach_skills != []
  58.     return item_test_sss_teachskillitems(user, item)
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Apply Item Effects
  62.   #--------------------------------------------------------------------------
  63.   alias item_effect_sss_teachskillitems item_effect unless $@
  64.   def item_effect(user, item)
  65.     item_effect_sss_teachskillitems(user, item)
  66.     return if @skipped or @missed or @evaded
  67.     teach_item_skills(item) if actor?
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # * teach_item_skills
  71.   #--------------------------------------------------------------------------
  72.   def teach_item_skills(item)
  73.     for skill_id in item.teach_skills do learn_skill(skill_id) end
  74.   end
  75. end
  76.  
  77. #===============================================================================
  78. #
  79. # END OF FILE
  80. #
  81. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement