Advertisement
MiKeMiTchi

MITCHI Auto Battle when Idle [VX]

Nov 2nd, 2011
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.95 KB | None | 0 0
  1. #============================================================================01=
  2. #  MITCHI Auto Battle when Idle
  3. #------------------------------------------------------------------------------
  4. #  Script version: 1.1
  5. #  By: //mitchi.exe                        
  6. #  On: Nov. 2, 2011
  7. #  Originally requested by: SortaCool
  8. #  (This is my first completed script!)
  9. #------------------------------------------------------------------------------
  10. #  Description:
  11. #  This script will make all actors in the party to auto attack when the player
  12. #  is not doing anything (idling) during a party or actor command selection
  13. #  after a specified amount of frames. This is very useful when you suddenly
  14. #  have to do something else IRL and you don't want to waste game play time!
  15. #  This is also beneficial when you're sleepy or lazy... or somethin'...
  16. #------------------------------------------------------------------------------
  17. #  Features:
  18. #  ~Party attacks automatically if player is idle
  19. #  ~Can set a specific amount of frames before the auto-battle starts
  20. #  ~Can be disabled by a switch
  21. #  ~Change an actor's auto-battle setting via event script command
  22. #------------------------------------------------------------------------------
  23. #  Instructions:
  24. #  Change the value of IDLE_FRAMES below to the amount you want:
  25. #  IDLE_FRAMES = n
  26. #  The party will automatically attack after 'n' frames.  
  27. IDLE_FRAMES = 300
  28.  
  29. #  Change the value of DISABLE_IDLE_SWITCH below to a switch you want:
  30. #  DISABLE_IDLE_SWITCH = n
  31. #  If the switch 'n' is turned ON, auto battle when idle WILL NOT WORK.
  32. DISABLE_IDLE_SWITCH = 85
  33.  
  34. #  You can alter an actor's auto-battle setting with an event script command:
  35. #  $game_actors[<id of actor>].idle_auto_battler(<true or false>)
  36. #  *Note that ^this will still work even if DISABLE_IDLE_SWITCH is on.  
  37. #------------------------------------------------------------------------------
  38. #  Compatibility:
  39. #  -Only supports UP, DOWN, OKAY(C), and CANCEL(B) keys for idling
  40. #  -This should work with battle systems that uses
  41. #   @actor_command_window and @party_command_window
  42. #===========================================================================42=
  43. #   Changelog:
  44. #   v1.1 - auto.battle -> make.action to prevent screwing up
  45. #          each actor's default auto-battle setting
  46. #==============================================================================
  47. ##### START OF CODE #####
  48.  
  49. class Game_Actor < Game_Battler
  50.  
  51.   def idle_auto_battler(boolean)
  52.     actor.auto_battle = (boolean)
  53.   end
  54.  
  55. end
  56.  
  57.  
  58. class Scene_Battle < Scene_Base
  59.  
  60.   alias idle_auto_start start
  61.   alias idle_auto_update update
  62.   alias idle_auto_turn_end turn_end
  63.  
  64.   def start
  65.     idle_auto_start
  66.     @idle_counter = 0
  67.   end
  68.    
  69.   def idle_auto_key_trigger?
  70.     if (Input.trigger?(Input::DOWN) or Input.trigger?(Input::UP))
  71.       return true
  72.     elsif (Input.trigger?(Input::C) or Input.trigger?(Input::B))
  73.       return true
  74.     end
  75.     return false
  76.   end
  77.  
  78.   def update
  79.     idle_auto_update
  80.     if !$game_switches[DISABLE_IDLE_SWITCH]
  81.       if @party_command_window.active or @actor_command_window.active
  82.         @idle_counter = 0 if idle_auto_key_trigger?
  83.         @idle_counter += 1
  84.         if @idle_counter == (IDLE_FRAMES)
  85.           for i in 0..$game_party.members.size
  86.             actor_set_auto = $game_party.members[i].id
  87.             $game_actors[actor_set_auto].make_action  
  88.           end
  89.           Sound.play_decision
  90.           start_main
  91.         end
  92.       end
  93.     end
  94.   end  
  95.  
  96.   def turn_end
  97.     @idle_counter = 0
  98.     idle_auto_turn_end
  99.   end
  100.  
  101. end
  102.  
  103. ##### END OF CODE #####
  104. #==============================================================================
  105. #  _   _   _   _____   ____   _   _   _
  106. # | \ / | | | |_   _| |  __| | |_| | | |
  107. # |  '  | | |   | |   | |__  |  _  | | |
  108. # |_|_|_| |_|   |_|   |____| |_| |_| |_|
  109. #  "Yay for my first completed script!"
  110. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement