Advertisement
neonblack

Starting States v1.0

Jun 15th, 2013
946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.98 KB | None | 0 0
  1. ##-----------------------------------------------------------------------------
  2. ## Starting States v1.0
  3. ## Created by Neon Black
  4. ##
  5. ## For both commercial and non-commercial use as long as credit is given to
  6. ## Neon Black and any additional authors.  Licensed under Creative Commons
  7. ## CC BY 3.0 - http://creativecommons.org/licenses/by/3.0/.
  8. ##----------------------------------------------------------------------------##
  9.                                                                               ##
  10. ##----------------------------------------------------------------------------##
  11. ##    Revision Info:
  12. ## v1.0 - 3.15.2013
  13. ##  Wrote and debugged main script
  14. ##----------------------------------------------------------------------------##
  15.                                                                               ##
  16. $imported ||= {}                                                              ##
  17. $imported["Starting_States"] = 1.0                                            ##
  18.                                                                               ##
  19. ##----------------------------------------------------------------------------##
  20. ##    Instructions:
  21. ## Place this script in the script editor below "Materials" and above "Main".
  22. ## This script allows you to create states that are applied to a battler at the
  23. ## start of a battle.  This can be done using anything in the database that can
  24. ## have features such as actors, enemies, weapons, or states.  To add these
  25. ## starting states, use the following tag:
  26. ##
  27. ## starting state[5]  -or-  starting states[1, 2, 5]
  28. ##  - Start the battle with the state IDs between the brackets applied.  Any
  29. ##    number of states may be applied either by using one tag or multiple tags.
  30. ##
  31. ## When using CP Stacking States, you can add this tag several times to apply
  32. ## a state to the stack several times.  When using CP State Graphics, you can
  33. ## use battler graphics and names to disguise one monster as another.  If a
  34. ## monster is disguised in this way, the letter at the end of the name is
  35. ## applied to monsters using the NEW name.
  36. ##----------------------------------------------------------------------------##
  37.                                                                               ##
  38. ##----------------------------------------------------------------------------##
  39. ## The following lines are the actual core code of the script.  While you are
  40. ## certainly invited to look, modifying it may result in undesirable results.
  41. ## Modify at your own risk!
  42. ###----------------------------------------------------------------------------
  43.  
  44.  
  45. module BattleManager  ## Added a few lines to allow actor states to apply.
  46.   class << self
  47.     alias :cp_starting_states_setup :setup
  48.   end
  49.  
  50.   def self.setup(*args)
  51.     $game_party.members.each do |mem|
  52.       mem.setup_start_states
  53.     end
  54.     cp_starting_states_setup(*args)
  55.   end
  56. end
  57.  
  58. class Game_Battler < Game_BattlerBase
  59.   def setup_start_states ## The common method used by both actors and enemies.
  60.     features(:starting_state_list).each do |fet|
  61.       add_state(fet.value)
  62.     end
  63.   end
  64. end
  65.  
  66. class Game_Enemy < Game_Battler
  67.   alias :cp_starting_states_init :initialize
  68.   def initialize(*args)  ## Starts a monster off and refreshes HP/MP.
  69.     cp_starting_states_init(*args)
  70.     setup_start_states
  71.     @hp = mhp
  72.     @mp = mmp
  73.   end
  74. end
  75.  
  76.  
  77. class RPG::BaseItem
  78.   def features
  79.     add_start_states
  80.     return @features
  81.   end
  82.  
  83.   def add_start_states
  84.     return if @start_states_made; @start_states_made = true
  85.     note.split(/[\r\n]+/).each do |line|
  86.       case line
  87.       when /starting states?\[([\d, ]+)\]/i
  88.         $1.to_s.split(/,/).each do |d|
  89.           f = RPG::BaseItem::Feature.new(:starting_state_list, 0, d.to_i)
  90.           @features.push(f)
  91.         end
  92.       end
  93.     end
  94.   end
  95. end
  96.  
  97.  
  98. ##-----------------------------------------------------------------------------
  99. ## End of script.
  100. ##-----------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement