Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2011
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.40 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Enemy Autostates
  4. # Last Date Updated: 2010.05.06
  5. # Level: Normal
  6. #
  7. # To make enemies start out with an autostate that never leaves, use this. It
  8. # will make the state present for that enemy at the start of battle and cannot
  9. # be removed.
  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. # <autostate: x>
  17. # <autostates: x, x, x>
  18. # Place this tag into the enemy's notebox. It will have state x on all the time.
  19. #===============================================================================
  20.  
  21. $imported = {} if $imported == nil
  22. $imported["EnemyAutostates"] = true
  23.  
  24. #==============================================================================
  25. # RPG::Enemy
  26. #==============================================================================
  27.  
  28. class RPG::Enemy
  29.   #--------------------------------------------------------------------------
  30.   # autostates
  31.   #--------------------------------------------------------------------------
  32.   def autostates
  33.     return @autostates if @autostates != nil
  34.     @autostates = []
  35.     self.note.split(/[\r\n]+/).each { |line|
  36.       case line
  37.       when /<(?:AUTOSTATE|autostates):[ ](\d+(?:\s*,\s*\d+)*)>/i
  38.         $1.scan(/\d+/).each { |num|
  39.         @autostates.push($data_states[num.to_i]) if num.to_i > 0 }
  40.       end
  41.     }
  42.     return @autostates
  43.   end
  44. end
  45.  
  46. #==============================================================================
  47. # ** Game_Enemy
  48. #==============================================================================
  49.  
  50. class Game_Enemy < Game_Battler
  51.   #--------------------------------------------------------------------------
  52.   # * states
  53.   #--------------------------------------------------------------------------
  54.   def states
  55.     st = super
  56.     for state in enemy.autostates
  57.       st.push(state) unless state.nil?
  58.     end
  59.     return st.uniq
  60.   end
  61. end
  62.  
  63. #===============================================================================
  64. #
  65. # END OF FILE
  66. #
  67. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement