Help - Search - Members - Calendar
Full Version: Jens009's Battle Command Deacivation
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS2
jens009
Battle Command Deactivation
Version 2.0
Author Jens009
Release DateAugust 6, 2008



Exclusive Script at RPG RPG Revolution


Introduction
I was looking through the rgss script request forum when I saw one of the threads that asked to remove the attack option.
After doing the request, I suddenly thought I can expand from this idea and create a more usable script.

And so I present to you this script.

This script, deactivates battle commands and reactivates them at your will.
For example, if you want your characters to only use Attack and Guard in one battle, you deactivate item and skill.
But say you want to have attack and skill on the next battle, you can do that as well.

Alright. Sounds good so far? Good. Because the best part is, it\'s easy to use and requires little to no scripting knowledge.

Features
-Deactive and Reactivate Battle Commands
-Deactivate and reactivate at any point in time (even during battles)
-Easy to use and requires no scripting knowledge.
Version 2.0 Includes
-Compatible with most systems.
-Shorter and clearner code


Script
[Show/Hide] DBC Add on: No Escape Option

CODE
]#============================================
# Deactivate Battle Commands, ADD ON: No run Option.
# Description: Disable run option during battle.
# By Jens009
# 09.24.08
# Author's Note:
# Aliased methods to increase compatibility.
# I directly edited the following method:
#    update_party_command_selection
#============================================
class Game_Troop < Game_Unit
  attr_accessor :no_run
  alias jens009_add_on_deactivate_battle_commands_initialize initialize
  def initialize
    @no_run = false
    jens009_add_on_deactivate_battle_commands_initialize    
  end
end
class Window_PartyCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias jens009_add_on_deactivate_battle_commands_party_init initialize
  alias jens009_add_on_deactivate_battle_commands_party_update update
  def initialize
    jens009_add_on_deactivate_battle_commands_party_init
    draw_item(1, false) if $game_troop.no_run # Deactivate run option
  end
  def update
    jens009_add_on_deactivate_battle_commands_party_update
    draw_item(1, false) if $game_troop.no_run # Deactivate run option
    draw_item(1, true) if !$game_troop.no_run # Deactivate run option
  end
end
class Scene_Battle
  alias jens009_add_on_dbc_update_check update
  alias jens009_add_on_dbc_battle_end battle_end
  def battle_end(result)
    jens009_add_on_dbc_battle_end(result)
    $game_troop.no_run = false
  end
  def update_party_command_selection
    if Input.trigger?(Input::C)
      case @party_command_window.index
      when 0  # Fight
        Sound.play_decision
        @status_window.index = @actor_index = -1
        next_actor
      when 1  # Escape
        if $game_troop.can_escape == false or $game_troop.no_run
          Sound.play_buzzer
          return
        end
        Sound.play_decision
        process_escape
      end
    end
  end
end


[Show/Hide] Deactivate Battle Commands version 2.0

CODE
#============================================
# Deactivate Battle Commands
# By Jens009
# Version: 2.0
# Release Date: August 5, 2008
# Description: Deactivate Battle Commands Using a Script Switch
# Log:
#   - Major Change in Coding
#     Instead of deleting the actual command, it just blackens it and plays
#     buzzer when selected
# How to use:
#   Use a call script.
#     Deactivating, attack, skill, guard or item:
#       $game_troop.no_attack = true/false
#       $game_troop.no_skill = true/false
#       $game_troop.no_guard = true/false
#       $game_troop.no_item = true/false
#       $game_troop.no_attack = true/false
#  Setting it to true disables the battle command
# Author\'s Notes:
#   2 methods aliased.
#     jens009_command_deactivate_initialize initialize
#     jens009_deactivate_commands_setup setup
#   1 method directly edited
#     update_actor_command_selection
#================================================

#===================================================
# Start Game_Troop Edit
# Add Global Instances
#==================================================
class Game_Troop < Game_Unit
  attr_accessor :no_attack
  attr_accessor :no_skill
  attr_accessor :no_guard
  attr_accessor :no_item

  alias jens009_command_deactivate_initialize initialize
  
  def initialize
    @no_attack = false
    @no_skill = false
    @no_guard = false
    @no_item = false
    jens009_command_deactivate_initialize
  end
end



#==============================================
# End Game_Troop Edit
# Start Window_Actor_Command Edit
#===============================================
class Window_ActorCommand < Window_Command
    alias jens009_deactivate_commands_setup setup
  # Modify Setup
    def setup(actor)
      jens009_deactivate_commands_setup(actor)
       draw_item(0, false) if $game_troop.no_attack # Deactive attack
       draw_item(1, false) if $game_troop.no_skill  # Deactive skill
       draw_item(2, false) if $game_troop.no_guard  # Deactive guard
       draw_item(3, false) if $game_troop.no_item   # Deactive item
    end # End method
  
end # END CLASS
#============================================
# End Window_ActorCommand Edit
#===========================================
#====================================
# Start Scene_Battle edit
#  Method Edited: update_actor_command_selection
#     Play buzzer when deactivated.
#====================================
class Scene_Battle
    def update_actor_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      prior_actor
    elsif Input.trigger?(Input::C)
      case @actor_command_window.index
      when 0  # Attack
        
        if $game_troop.no_attack
          Sound.play_buzzer  
        else          
          Sound.play_decision
          @active_battler.action.set_attack
          start_target_enemy_selection
        end
        
      when 1  # Skill
        
        if $game_troop.no_skill
          Sound.play_buzzer
        else
          Sound.play_decision
          start_skill_selection
        end
        
      when 2  # Guard
        if $game_troop.no_guard
          Sound.play_buzzer
        else
          Sound.play_decision
          @active_battler.action.set_guard
          next_actor
        end
          
      when 3  # Item
        
        if $game_troop.no_item
          Sound.play_buzzer
        else
          Sound.play_decision
          start_item_selection
        end
        
      end # END CASE

      end # END INPUT CHECK
    end # END METHOD EDIT
    
end # END CLASS



[Show/Hide] Deactivate Battle Commands v1.0

CODE
#=============================================================================
# Deactivate Battle Commands
# by: Jens009
# August 05, 2008
# Version 1.0
# Description:
# Modifies Window_ActorCommand and Scene_Battle
#          so that actors only have limited commands.
# Compatibilitiy:
#          May cause errors that modifies class Window_ActorCommand and
#          method update_actor_command_selection from Scene_Battle
# Config:
#   Use the call script command and select which commands are deactivated
#   by setting true to the instances
#     Deactivating the Attack Command:
#       $game_temp.attack_off = true
#     Deactivating the Skill Command:
#       $game_temp.guard_off = true
#     Deactivating the Guard Command:
#       $game_temp.skill_off = true
#     Deactivating the Item Command:
#       $game_temp.item_off = true
#   To reactivate, simply set it to false.
#============================================================================
#=============================================================================
# ** Window_ActorCommand
#-----------------------------------------------------------------------------
#  This window is used to select actor commands, such as \"Attack\" or \"Skill\".
#=============================================================================


# Set Instances
class Game_Temp  
  attr_accessor :attack_off
  attr_accessor :item_off
  attr_accessor :guard_off
  attr_accessor :skill_off

  alias jens009_temp_initialize initialize
def initialize
  @attack_off = false
  @item_off = false
  @guard_off = false
  @skill_off = false
  jens009_temp_initialize
end

end

#==========================================================================
# END MODIFICATION
#==========================================================================
class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Setup
  #     actor : actor
  #--------------------------------------------------------------------------  
  def setup(actor)
    s1 = Vocab::attack
    s2 = Vocab::skill
    s3 = Vocab::guard
    s4 = Vocab::item
    if actor.class.skill_name_valid     # Skill command name is valid?
      s2 = actor.class.skill_name       # Replace command name
    end
    decide_commands
    refresh
    self.index = 0
  end
  
  def decide_commands
    s1 = Vocab::attack
    s2 = Vocab::skill
    s3 = Vocab::guard
    s4 = Vocab::item
    # Start Command Decision
    # When All 4 commands are off
    if $game_temp.attack_off and $game_temp.skill_off and $game_temp.guard_off and $game_temp.item_off
      @commands = []
      @item_max = 0
    # When only 3 commands are off
    elsif $game_temp.attack_off and $game_temp.skill_off and $game_temp.guard_off
      @commands = [s4]
      @item_max = 1
    elsif $game_temp.attack_off and $game_temp.skill_off and $game_temp.item_off
      @commands = [s3]
      @item_max = 1
    elsif $game_temp.attack_off and  $game_temp.guard_off and $game_temp.item_off
      @commands = [s2]
      @item_max = 1
    elsif $game_temp.skill_off and $game_temp.guard_off and $game_temp.item_off
      @commands = [s1]
      @item_max = 1
    # When only 2 commands are Off
    elsif $game_temp.attack_off and $game_temp.guard_off  
      @commands = [s2,s4]
      @item_max = 2
    elsif $game_temp.attack_off and $game_temp.item_off
      @commands = [s2,s3]
      @item_max = 2    
    elsif $game_temp.attack_off and $game_temp.skill_off  
      @commands = [s3,s4]
      @item_max = 2    
    elsif $game_temp.skill_off and $game_temp.guard_off
      @commands = [s1,s4]
      @item_max = 2    
    elsif $game_temp.skill_off and $game_temp.item_off
      @commands = [s1,s3]
      @item_max = 2    
    elsif $game_temp.guard_off and $game_temp.item_off
      @commands = [s1,s2]
      @item_max = 2
    # When 1 command is off
    elsif $game_temp.attack_off
      @commands = [s2,s3,s4]
      @item_max = 3    
    elsif $game_temp.skill_off
      @commands = [s1,s3,s4]
      @item_max = 3    
    elsif $game_temp.guard_off  
      @commands = [s1,s2,s4]
      @item_max = 3
    elsif $game_temp.item_off
      @commands = [s1,s2,s3]
      @item_max = 3
    else
      @commands = [s1,s2,s3,s4]
      @item_max = 4
    end # END DECISION
    
  end # END METHOD
end
#===========================================================================
# Scene_Battle
# Description: Handles Battle Information
# Modification:
#   Added Control Flow to Implement Deactivate Battle Commands
#==========================================================================
class Scene_Battle
  
  def update_actor_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      prior_actor
    elsif Input.trigger?(Input::C)
      case @actor_command_window.index
      when 0  # Attack
        Sound.play_decision
        decide_case0
      when 1  # Skill
        Sound.play_decision
        decide_case1
      when 2  # Guard
        Sound.play_decision
        decide_case2
      when 3  # Item
        Sound.play_decision
        start_item_selection
        
      end #  END case
    end #END Input check
  end #END method

#============================================================================
# Decide Case 0
# Description: Decide what happens at case 0 under deactivation of commands
#============================================================================
  def decide_case0
    # Start Command Decision
    # When All 4 commands are off
    if $game_temp.attack_off and $game_temp.skill_off and $game_temp.guard_off and $game_temp.item_off      
    # Do Nothing
    # When only 3 commands are off
    elsif $game_temp.attack_off and $game_temp.skill_off and $game_temp.guard_off
      # Item
      start_item_selection
      
    elsif $game_temp.attack_off and $game_temp.skill_off and $game_temp.item_off
      # Guard
      @active_battler.action.set_guard
      next_actor
      
    elsif $game_temp.attack_off and  $game_temp.guard_off and $game_temp.item_off
      # Skill
      start_skill_selection
      
      
    # When only 2 commands are Off
    elsif $game_temp.attack_off and $game_temp.guard_off  
      # Skill
      start_skill_selection
  
    elsif $game_temp.attack_off and $game_temp.item_off
      # Skill
      start_skill_selection
      
    elsif $game_temp.attack_off and $game_temp.skill_off
      # Skill
      start_skill_selection
      
    # When 1 command is off
    elsif $game_temp.attack_off
      # Skill
      start_skill_selection

    else
      # Default Attack
      @active_battler.action.set_attack
      start_target_enemy_selection
      
    end # END DECISION
  end # END METHOD
#============================================================================
# Decide Case 1
# Description: Decide what happens at case 0 under deactivation of commands
#============================================================================  
  def decide_case1
    # Start Command Decision
    # When All 4 commands are off
    if $game_temp.attack_off and $game_temp.skill_off and $game_temp.guard_off and $game_temp.item_off
      # Do Nothing
    # When only 2 commands are Off
    elsif $game_temp.attack_off and $game_temp.guard_off  
           start_item_selection

    elsif $game_temp.attack_off and $game_temp.item_off
        @active_battler.action.set_guard
        next_actor
    
    elsif $game_temp.attack_off and $game_temp.skill_off  
           start_item_selection
          
    elsif $game_temp.skill_off and $game_temp.guard_off
           start_item_selection

    elsif $game_temp.skill_off and $game_temp.item_off
        @active_battler.action.set_guard
        next_actor
    # When 1 command is off
    elsif $game_temp.attack_off
        @active_battler.action.set_guard
        next_actor
    elsif $game_temp.skill_off
        @active_battler.action.set_guard
        next_actor
    else
        start_skill_selection
      end # END DECISION
  end # END METHOD
#============================================================================
# Decide Case 2
# Description: Decide what happens at case 2 under deactivation of commands
#============================================================================
  def decide_case2
    # Start Command Decision
    # When All 4 commands are off
    if $game_temp.attack_off and $game_temp.skill_off and $game_temp.guard_off and $game_temp.item_off
    # When 1 command is off
    elsif $game_temp.attack_off
           start_item_selection
  
    elsif $game_temp.skill_off
           start_item_selection

    elsif $game_temp.guard_off  
           start_item_selection

    else
        @active_battler.action.set_guard
        next_actor

    end # END DECISION
  end # END METHOD
  
end # Class
#====================================================
# Scene_File
# Description:
#   Handles saving and loading data
# Aliases used:
#  alias jens009_save_commands  write_save_data
#  alias jens009_load_commands  read_save_data
#====================================================
class Scene_File < Scene_Base
  alias jens009_save_commands  write_save_data
  alias jens009_load_commands  read_save_data
  
   def write_save_data(file)
     jens009_save_commands(file)
    Marshal.dump($game_temp.attack_off,        file)
    Marshal.dump($game_temp.skill_off,         file)
    Marshal.dump($game_temp.guard_off,         file)
    Marshal.dump($game_temp.item_off,          file)    
  end
    def read_save_data(file)
    jens009_load_commands(file)
    $game_temp.attack_off          = Marshal.load(file)
    $game_temp.skill_off           = Marshal.load(file)
    $game_temp.guard_off           = Marshal.load(file)
    $game_temp.item_off            = Marshal.load(file)
  end
end



Customization
No scripting customization provided.

Compatibility
Version 1.0:
Compatible with any system so long as it doesn\'t have to do with the command window or the default command functions.

Version 2.0
Shorter and cleaner code.
Compatible with any system. There might be errors for custom commands though , But I doubt.

Screenshot
Version 2.0




[Show/Hide] Version 1.0

No Guard and Item

No Item



DEMO
None.

Installation
Copy and Paste the script below Materials.
Instructions on how to use are inside the script.

FAQ
I want this compatible with...
Post it up and I\'ll try to make it compatible with that system.
I found a bug!
Again, post it up and let\'s fix it.

Terms and Conditions
RRR Exclusive.
Not for commercial use unless I\'m contacted.
Credit me.

Credits
Jens009
Loki333
Very nice script, do you know if it would be compatible with your cross commands script? I'm not at my home computer to try out myself at the moment.
jens009
QUOTE (Loki333 @ Aug 5 2008, 03:35 AM) *
Very nice script, do you know if it would be compatible with your cross commands script? I'm not at my home computer to try out myself at the moment.

Not yet. I'll work on it later. =]
jarhead31
I think it was I that requested this. Great job, it looks a lot better and useful than I was even hoping for!
jens009
QUOTE (jarhead31 @ Aug 5 2008, 02:48 PM) *
I think it was I that requested this. Great job, it looks a lot better and useful than I was even hoping for!

Lol. You're welcome.

I'm going to rewrite the script to increase compatibility with any battle system.
It seems I made it much more complicated that it had to be. Working on Version 2.0 Right now.
Version 1.0 is ugly and badly scripted. Please wait.
jens009
Version 2.0 Is released!

Shorter and Cleaner code. Compatibility with other system is higher too!
Screenie Sample:


@Loki: This is now compatible with the Cross Command. I'm also adding a feature to blur the commands when it's deactivated.

Enjoy.
Loki333
Ooooo blurring the commands I like that idea smile.gif I'm very fond of your scripts they are short and too the point but they add that special something I'm always looking for :cheers:
cheahjc
Heh, that was my thread. Anyway, Great script! Even though I got the just skill thing, I can use this is deactivate "Items" in boss battles. I haven't tested it out yet, but I'm sure it will work. All your scripts do!
jens009
Updated:
Disable Escape Command during a battle using a call script:
CODE
$game_troop.no_run = true

Don't worry. The Script switch automatically turns off when the battle ends.

Check the first post!
N2Y
Awesome! For battle tutorials (like FFX) this could be very useful!
acela
Any way to do this so that it simply says when you try to select an option (like magic for prime example)

that it makes the normal selection chime but instead of bringing up a blank menu brings up a message window saying X does not know any magic?

smile.gif (everyone only has attack defense magic and item with what I'm planning out anyway.)

Mad thanks (silly question I know tongue.gif)
klizfer
Hi can you please help me with this problem, when I keep only the attack option active and then use it to attack the enemy it shows error
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.