The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Albysan on February 09, 2011, 03:47:28 PM

Title: [Request] Items for thief/ninja that can be used pre-battle
Post by: Albysan on February 09, 2011, 03:47:28 PM
Hello everyone, and Hi

I am pretty new here and hope someone can give me a helping script/hand.

I am planning to do the following:
I have my Char X. This X is using the thief or ninja class. The class is capability of using certain item BEFORE each battle.
here an example:
Smoke Bomb - blinds every enemy in the next battle
Poison Mist - has a chance of 40 % to poison each enemy in the next battle
etc. the items can be created in the database and should be only useable by the thief or ninja class when they have reached a certain level (and are capable of using that skill)

I don't know if such a script already exists but if someone has a moment, I would really appreciate help.

Regards,
Alby

Title: Re: [Request] Items for thief/ninja that can be used pre-battle
Post by: hiromu656 on February 10, 2011, 05:44:44 AM
I'm sure there isn't currently a script like that. But I don't understand why the item needs to be used before the battle, wouldn't it be much easier to make an item that blinds or poison an enemy and you use it during battle? It doesn't make much sense for it to happen before the battle.
Title: Re: [Request] Items for thief/ninja that can be used pre-battle
Post by: Albysan on February 10, 2011, 12:43:38 PM
Consider it as: Setting up a trap or backstab an enemy from behind (ambushing). This is my main idea.
Title: Re: [Request] Items for thief/ninja that can be used pre-battle
Post by: pacdiggity on February 11, 2011, 06:16:10 AM
I'm quite sure TDS made a script that allowed common events to happen before every battle. If you use that (I could find it if you wanted me to), you could make a choice event run that allows the player to choose if he does on of these. Conditional branches considering random variables decide how your battle goes.

Oh, look what I did!
Spoiler for TDS is a bloody genius:
This should let you run a common event before and after battle.

Code: [Select]
#==============================================================================
# ** TDS Battle Common Events
#    ver : 1.0
#------------------------------------------------------------------------------
#  Description :
#    This script is used to run common events before and after battle.
#==============================================================================

  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  # Common Event ID to run before a battle starts
  BEFORE_BATTLE_C_EVENT_ID = 1
  # Common Event ID to run after a battle ends (Win, Escape, Lose) 0 for nothing
  AFTER_BATTLE_C_EVENTS_ID = [2, 0, 2]
 
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listing
  #-------------------------------------------------------------------------- 
  alias tds_battle_common_events_scene_map_call_battle     call_battle 
  #--------------------------------------------------------------------------
  # * Switch to Battle Screen
  #--------------------------------------------------------------------------
  def call_battle     
    # Run Original Method
    tds_battle_common_events_scene_map_call_battle
    # Call a battle common event
    $game_map.interpreter.battle_common_event(BEFORE_BATTLE_C_EVENT_ID)   
    # Update Game Map Interpreter
    $game_map.interpreter.update   
  end
end


#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listing
  #-------------------------------------------------------------------------- 
  alias tds_battle_common_events_scene_battle_battle_end     battle_end 
  #--------------------------------------------------------------------------
  # * End Battle
  #     result : Results (0: win, 1: escape, 2:lose)
  #--------------------------------------------------------------------------
  def battle_end(result)
    # Run Original Method
    tds_battle_common_events_scene_battle_battle_end(result)
    # If After Battle Common Event ID is not 0
    if AFTER_BATTLE_C_EVENTS_ID[result] != 0
      # Call a battle common event
      $game_map.interpreter.battle_common_event(AFTER_BATTLE_C_EVENTS_ID[result])
      # Update Game Map Interpreter
      $game_map.interpreter.update   
    end   
  end 
end


#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Call Battle Common Event
  #--------------------------------------------------------------------------
  def battle_common_event(id)
    common_event = $data_common_events[id]
    if common_event != nil
      @child_interpreter = Game_Interpreter.new(@depth + 1)
      @child_interpreter.setup(common_event.list, @event_id)
    end
    return true
  end
end

To use simply edit these constants in the script.

Code: [Select]
  BEFORE_BATTLE_C_EVENT_ID = #

# Is the ID of the common event you want to run before battles.

Code: [Select]
  AFTER_BATTLE_C_EVENTS_ID = [#1, #2, #3]

After battle you can set 3 different common events to run depending on what happened in battle.

#1 ID of common event to run if you win
#2 ID of common event to run if you escape
#3 ID of common event to run if you lose

If you set the ID of any to 0 it won't run any common events in that instance.

Let me know if this works out for you and if you need anything fixed/added.

Have a nice day.
Is this what you needed?
Title: Re: [Request] Items for thief/ninja that can be used pre-battle
Post by: Albysan on February 11, 2011, 03:06:59 PM
Thanks a bunch, I will test it and tell you the results.
If I need any further help, I will come back ;)