Advertisement
LiTTleDRAgo

[RGSS/2] Battle Self Switches

May 1st, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.93 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # Battle Self Switches
  3. # Version: 1.00
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #
  7. #  This script will make you able to use Self Switches in battles
  8. #
  9. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  10. module LiTTleDRAgo
  11.  
  12.   SwitchKey       = 'BattleSelfSwitch'
  13.   ClearwhenFinish = false      
  14.   # If true, the self switch will reset on battle starts
  15.  
  16. end
  17. #==============================================================================
  18. # ** Interpreter
  19. #------------------------------------------------------------------------------
  20. #  This interpreter runs event commands. This class is used within the
  21. #  Game_System class and the Game_Event class.
  22. #==============================================================================
  23. VX = defined?(Window_ActorCommand)
  24. eval "
  25. class #{VX ? 'Game_' : ''}Interpreter
  26.  #--------------------------------------------------------------------------
  27.  # * Constant Variables
  28.  #--------------------------------------------------------------------------
  29.  SwitchKey       = LiTTleDRAgo::SwitchKey
  30.  ClearwhenFinish = LiTTleDRAgo::ClearwhenFinish
  31.  #--------------------------------------------------------------------------
  32.  # * Alias Listing
  33.  #--------------------------------------------------------------------------
  34.  alias drg129_cmd111 command_111 unless method_defined?(:drg129_cmd111)
  35.  alias drg129_cmd123 command_123 unless method_defined?(:drg129_cmd123)
  36.  #--------------------------------------------------------------------------
  37.  # * Control Self Switch
  38.  #--------------------------------------------------------------------------
  39.  def command_123
  40.    inbattle = $BlizzABS ? @event_id == 0 : $game_temp.in_battle
  41.    if in_battle
  42.      @params = @parameters unless VX
  43.      key = [ SwitchKey ,$game_troop.troop_id, @params[0]]
  44.      $game_self_switches[key] = (@params[1] == 0)
  45.    end
  46.    drg129_cmd123
  47.  end
  48.  #--------------------------------------------------------------------------
  49.  # * Conditional Branch
  50.  #--------------------------------------------------------------------------
  51.  def command_111
  52.    result = false
  53.    unless VX
  54.      @params = @parameters
  55.      @indent = @list[@index].indent
  56.    end
  57.    inbattle = $BlizzABS ? @event_id == 0 : $game_temp.in_battle
  58.    if @params[0] == 2 && in_battle
  59.      key = [(SwitchKey),$game_troop.troop_id, @params[1]]
  60.      if @params[2] == 0
  61.        result = ($game_self_switches[key] == true)
  62.      else
  63.        result = ($game_self_switches[key] != true)
  64.      end
  65.      @branch[@indent] = result
  66.      if @branch[@indent] == true
  67.        @branch.delete(@indent)
  68.        return true
  69.      end
  70.      return command_skip
  71.    end
  72.    drg129_cmd111
  73.  end
  74. end#"
  75. #==============================================================================
  76. # ** Scene_Battle
  77. #------------------------------------------------------------------------------
  78. #  This class performs battle screen processing.
  79. #==============================================================================
  80. class Scene_Battle
  81.   #--------------------------------------------------------------------------
  82.   # * Alias Listing
  83.   #--------------------------------------------------------------------------
  84.   alias drg129_main main unless method_defined?(:drg129_main)
  85.   #--------------------------------------------------------------------------
  86.   # * Main Processing
  87.   #--------------------------------------------------------------------------
  88.   def main
  89.     drg129_main
  90.     val = ['A','B','C','D']
  91.     (0...val.size).each {|i|
  92.        key = [LiTTleDRAgo::SwitchKey,$game_troop.troop_id, val[i]]
  93.        $game_self_switches[key] = false } if LiTTleDRAgo::ClearwhenFinish
  94.   end
  95. end
  96. #==============================================================================
  97. # ** Game_Troop
  98. #------------------------------------------------------------------------------
  99. #  This class deals with troops. Refer to "$game_troop" for the instance of
  100. #  this class.
  101. #==============================================================================
  102. class Game_Troop
  103.   #--------------------------------------------------------------------------
  104.   # * Public Instance Variables
  105.   #--------------------------------------------------------------------------\
  106.   attr_reader :troop_id
  107.   #--------------------------------------------------------------------------
  108.   # * Alias Listing
  109.   #--------------------------------------------------------------------------
  110.   alias drg129_setup setup unless method_defined?(:drg129_setup)
  111.   #--------------------------------------------------------------------------
  112.   # * Setup
  113.   #     troop_id : troop ID
  114.   #--------------------------------------------------------------------------
  115.   def setup(troop_id)
  116.     @troop_id = troop_id
  117.     drg129_setup(troop_id)
  118.   end
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement