QuasiXi

Quasi Passive

Mar 24th, 2014
512
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #==============================================================================
  2. #** Quasi Passive Skills v 1.04
  3. #==============================================================================
  4. # Edited - Fixed a bug after battle turns
  5. # Edited - Added an option to hide passive skills during battle
  6. # Edited - Fixed bug with clear all
  7. # Edited - Forgot to change a value, which allowed non passive skills to gain a
  8. # passive~
  9. # Allows Skills to give you passive traits.
  10. #==============================================================================
  11. # Instructions:
  12. # Very simple to use, just needs 2 notes tags!~
  13. # The State(Passive) is added when the skill is learned,  it is also removed
  14. # when the skill is forgoten.
  15. #-----------------------------------------------------------------------------
  16. module Quasi
  17.   module Passive
  18.     #--------------------------------------------------------------------------
  19.     # Change this value to the Skill Type ID that you wish to hide
  20.     #  Skills with this skill type id, aren't shown in battle.
  21.     #--------------------------------------------------------------------------
  22.     TYPE = 3
  23.   end
  24. end
  25. #------------------------------------------------------------------------------
  26. # * Skill Note Tag
  27. #------------------------------------------------------------------------------
  28. # <passive: state_id>
  29. # Replace state_id with the state you wish to add
  30. #
  31. #------------------------------------------------------------------------------
  32. # * State Note Tag
  33. #------------------------------------------------------------------------------
  34. # <passive>
  35. # Just checks if the state is a passive state, if it is, it doesn't display on
  36. # State icons, and can not be removed.
  37. #
  38. # Alias :
  39. # Game_Actor
  40. #  learn_skill
  41. #  forget_skill
  42. #
  43. # Overwrites:
  44. # Game_Battler
  45. #  remove_states
  46. #
  47. # Game_BattlerBase
  48. #  state_icons
  49. #==============================================================================#
  50. # By Quasi (http://quasixi.wordpress.com/)
  51. #  - 3/23/14
  52. #==============================================================================#
  53. #   ** Stop! Do not edit anything below, unless you know what you      **
  54. #   ** are doing!                                                      **
  55. #==============================================================================#
  56. $imported = {} if $imported.nil?
  57. $imported["Quasi_Passive"] = 1.04
  58. #==============================================================================
  59. # ** Game_Actor
  60. #------------------------------------------------------------------------------
  61. #  This class handles actors. It is used within the Game_Actors class
  62. # ($game_actors) and is also referenced from the Game_Party class ($game_party).
  63. #==============================================================================
  64.  
  65. class Game_Actor < Game_Battler
  66.   alias qpassive_learn learn_skill
  67.   alias qpassive_forget forget_skill
  68.   #--------------------------------------------------------------------------
  69.   # * Learn Skill
  70.   #--------------------------------------------------------------------------
  71.   def learn_skill(skill_id)
  72.     learn_passive(skill_id)
  73.     qpassive_learn(skill_id)
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # * Forget Skill
  77.   #--------------------------------------------------------------------------
  78.   def forget_skill(skill_id)
  79.     forget_passive(skill_id)
  80.     qpassive_forget(skill_id)
  81.   end
  82.  
  83.   def learn_passive(skill_id)
  84.     unless skill_learn?($data_skills[skill_id])
  85.       passive = $data_skills[skill_id].passive
  86.       add_new_state(passive.to_i) if passive
  87.       reset_state_counts(passive.to_i) if passive
  88.     end
  89.   end
  90.  
  91.   def forget_passive(skill_id)
  92.     passive = $data_skills[skill_id].passive
  93.     remove_passive(passive.to_i) if passive
  94.   end
  95. end
  96.  
  97. #==============================================================================
  98. # ** Game_Battler
  99. #------------------------------------------------------------------------------
  100. #  A battler class with methods for sprites and actions added. This class
  101. # is used as a super class of the Game_Actor class and Game_Enemy class.
  102. #==============================================================================
  103.  
  104. class Game_Battler < Game_BattlerBase
  105.   #--------------------------------------------------------------------------
  106.   # * OVERWRITE Remove State
  107.   #--------------------------------------------------------------------------
  108.   def remove_state(state_id)
  109.     if state?(state_id) && !$data_states[state_id].passive?
  110.       revive if state_id == death_state_id
  111.       erase_state(state_id)
  112.       refresh
  113.       @result.removed_states.push(state_id).uniq!
  114.     end
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # * NEW Remove State
  118.   #--------------------------------------------------------------------------
  119.   def remove_passive(state_id)
  120.     if state?(state_id) && $data_states[state_id].passive?
  121.       revive if state_id == death_state_id
  122.       erase_state(state_id)
  123.       refresh
  124.       @result.removed_states.push(state_id).uniq!
  125.     end
  126.   end
  127. end
  128. #==============================================================================
  129. # ** Game_BattlerBase
  130. #------------------------------------------------------------------------------
  131. #  This base class handles battlers. It mainly contains methods for calculating
  132. # parameters. It is used as a super class of the Game_Battler class.
  133. #==============================================================================
  134.  
  135. class Game_BattlerBase
  136.   #--------------------------------------------------------------------------
  137.   # * OVERWRITE Get Current States as an Array of Icon Numbers
  138.   #--------------------------------------------------------------------------
  139.   def state_icons
  140.     icons = states.collect { |state| state.passive? ? nil : state.icon_index }
  141.     icons.delete(nil)
  142.     icons.delete(0)
  143.     icons
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # * OVERWRITE Clear State Information
  147.   #--------------------------------------------------------------------------
  148.   def clear_states
  149.     @states = [] if @states.nil?
  150.     @states.keep_if{|state| $data_states[state].passive?} if !@states.nil?
  151.     @state_turns = {} if @state_turns.nil?
  152.     @state_turns.delete_if{|state| !$data_states[state].passive?} if !@state_turns.nil?
  153.     @state_steps = {} if @state_steps.nil?
  154.     @state_steps.delete_if{|state| !$data_states[state].passive?} if !@state_steps.nil?
  155.   end
  156. end
  157. #==============================================================================
  158. # ** Window_ActorCommand
  159. #------------------------------------------------------------------------------
  160. #  This window is for selecting an actor's action on the battle screen.
  161. #==============================================================================
  162.  
  163. class Window_ActorCommand < Window_Command
  164.   #--------------------------------------------------------------------------
  165.   # * Add Skill Command to List
  166.   #--------------------------------------------------------------------------
  167.   def add_skill_commands
  168.     @actor.added_skill_types.sort.each do |stype_id|
  169.       next if stype_id == Quasi::Passive::TYPE
  170.       name = $data_system.skill_types[stype_id]
  171.       add_command(name, :skill, true, stype_id)
  172.     end
  173.   end
  174. end
  175. #==============================================================================
  176. # ** RPG::Skill
  177. #==============================================================================
  178. class RPG::Skill
  179.   def passive
  180.     if @passive.nil?
  181.       if @note =~ /<(?:passive):(.*)>/i
  182.         @passive = $1
  183.       else
  184.         @passive = false
  185.       end
  186.     end
  187.     @passive
  188.   end
  189. end
  190. #==============================================================================
  191. # ** RPG::State
  192. #==============================================================================
  193. class RPG::State
  194.   def passive?
  195.     if @passive.nil?
  196.       if @note =~ /<(?:passive)>/
  197.         @passive = true
  198.       else
  199.         @passive = false
  200.       end
  201.     end
  202.     @passive
  203.   end
  204. end
RAW Paste Data