Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Jens009's Battle Command Deacivation, Deactivate/Reactivate Battle commands. Even in-game!
jens009
post Aug 5 2008, 12:11 AM
Post #1


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




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


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies
cheahjc
post Aug 8 2008, 12:35 PM
Post #2


Got watermelons?
Group Icon

Group: Revolutionary
Posts: 186
Type: Event Designer
RM Skill: Skilled




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!


__________________________

[Show/Hide] This is my signature, BEWARE


[Show/Hide] Click here to see how awesome I am






[Show/Hide] Funny T-Shirts






[Show/Hide] Can you read this?

Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.

[Show/Hide] They Found Nemo!



WARNING, The Following picture may be frightening to Nemo fans and sushi haters


[Show/Hide] Continue




[Show/Hide] Awesome Quotes


"Yesterday was history, tomorrow is a mystery, and today is a gift. Thats why they call it the present." - Kong Fu Panda

"What are you? Dumb?"
"Well you should have knwon I was dumb, so your the dumb one!" Max from Wizards of Waverly Place

"If everyone is thinking alike then sombody isn't thinking." - George Patton.

"Always bear in mind that your own resolution to succeed is more important than any one thing" - Abraham Lincoln

"Ask not what your country can do for you--ask what you can do for your country" - John F. Kennedy

"Leadership is not position. Leadership is action" - UNKNOWN

"You can't a home run unless you step up to the plate."
"You can't catch a fish unless you put your line in the water."
"You can't reach you goals if you don't try." - Kathy Seligman

"Shoot for the moon. Even if you miss, you will land among the stars" - Les Brown


Thanks Leper!

Cheahjc is too cool for school.
GO ASIANS!
Go to the top of the page
 
+Quote Post
   



Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 06:17 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker