Advertisement
neutale

Preemptive Switch

Jun 13th, 2019
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.75 KB | None | 0 0
  1. #==============================================================================
  2. # ■ Preemptive Switch
  3. #   @version 0.1 12/01/22
  4. #   @author sabakan
  5. #   @license: MIT License
  6. #------------------------------------------------------------------------------
  7. #   Able to control Preemptive Strike with a switch
  8. #==============================================================================
  9. module Saba
  10.   module Preemptive
  11.     PREEMPTIVE_SWITCH = 79  # If this switch is ON, you'll go first in battle
  12.     SURPRISE_SWITCH = 80    # If this switch is ON, expect a surprise from enemy
  13.   end
  14. end
  15.  
  16. class << BattleManager
  17.   include Saba::Preemptive
  18.   #--------------------------------------------------------------------------
  19.   # ● Setup
  20.   #--------------------------------------------------------------------------
  21.   alias saba_preemptive_setup setup
  22.   def setup(troop_id, can_escape = true, can_lose = false)
  23.     saba_preemptive_setup(troop_id, can_escape, can_lose)
  24.     setup_preemptive_switch
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● Process on encounter
  28.   #--------------------------------------------------------------------------
  29.   alias saba_preemptive_on_encounter on_encounter
  30.   def on_encounter
  31.     saba_preemptive_on_encounter
  32.     setup_preemptive_switch
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ○ Setup for preemptive or surprise switch
  36.   #--------------------------------------------------------------------------
  37.   def setup_preemptive_switch
  38.     if $game_switches[PREEMPTIVE_SWITCH]
  39.       @preemptive = true
  40.       @surprise = false
  41.     elsif $game_switches[SURPRISE_SWITCH]
  42.       @preemptive = false
  43.       @surprise = true
  44.     end
  45.   end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement