neonblack

Passive Skills script v1.1

Sep 5th, 2012
5,243
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##-----------------------------------------------------------------------------
  2. #  CP Passive Skills v1.1
  3. #  Created by Neon Black
  4. #  v1.1 - 12.9.2014 - Slight optimization
  5. #  v1.0b - 9.5.2012 - Slight bug fix
  6. #  v1.0 - 9.5.2012 - Wrote and debugged main script
  7. #  For both commercial and non-commercial use as long as credit is given to
  8. #  Neon Black and any additional authors.  Licensed under Creative Commons
  9. #  CC BY 4.0 - http://creativecommons.org/licenses/by/4.0/
  10. ##-----------------------------------------------------------------------------
  11.  
  12. ##-----------------------------------------------------------------------------
  13. #      Instructions:
  14. #  Place this script in the "Materials" section of the scripts above main.
  15. #  This script has no customization options and is plug and play.  To use this
  16. #  script just follow two fairly simple steps.
  17. #   1. Create a state with the passive buffs you would like a skill to add.
  18. #   2. Add the line "passive[x]" without the quotes to a skill's notebox where
  19. #      "x" is the ID of the state to be applied while the skill is learned.
  20. #      Note that passives do not apply to enemies.
  21. ##-----------------------------------------------------------------------------
  22.  
  23.  
  24. ##-----------------------------------------------------------------------------
  25. #  The following lines are the actual core code of the script.  While you are
  26. #  certainly invited to look, modifying it may result in undesirable results.
  27. #  Modify at your own risk!
  28. ##-----------------------------------------------------------------------------
  29.  
  30.  
  31. $imported ||= {}
  32. $imported["CP_PASSIVES"] = 1.1
  33.  
  34. class Game_BattlerBase  ## Alias the feature objects to get states and passives.
  35.   alias cp_passive_f_objects feature_objects
  36.   def feature_objects
  37.     return cp_passive_f_objects if @passover
  38.     return cp_passive_f_objects + passives
  39.   end
  40.  
  41.   def passives  ## Returns an empty passive array for all battlers.
  42.     return []
  43.   end
  44. end
  45.  
  46. class Game_Actor < Game_Battler  ## Gets passive states on a character.
  47.   def passives
  48.     res = []
  49.     @passover = true
  50.     skills.each do |skill|
  51.       next if skill.passives.empty?
  52.       res += skill.passives
  53.     end
  54.     @passover = false
  55.     return res.collect {|ps| $data_states[ps]}
  56.   end
  57. end
  58.  
  59. class RPG::Skill < RPG::UsableItem
  60.   def passives
  61.     return @passives if @passives
  62.     @passives = []
  63.     self.note.split(/[\r\n]+/).each do |line|
  64.       case line
  65.       when /passive\[(\d+)\]/i
  66.         @passives.push($1.to_i)
  67.       end
  68.     end
  69.     @passives
  70.   end
  71. end
  72.  
  73.  
  74. ##-----------------------------------------------------------------------------
  75. #  End of script.
  76. ##-----------------------------------------------------------------------------
RAW Paste Data