Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Sign in to follow this  
NightmareFelix

Bypass Target Window

Recommended Posts

Alright. it's been far too long since I've scripted (scripting for me = read, change, test, if that gives you guys any idea of where I am) and I need assistance.

 

In my game, you have one party member and never fight multiple enemies, so I think I want to bypass the target window altogether. I just can't remember how that sort of thing works.

 

I created my own menu system a year ago but that part of my brain seems full of cobwebs now.

Share this post


Link to post
Share on other sites

Did you want to bypass just the enemy targeting or both the enemy and actor targeting?

 

Well Assuming you are using default battle system (or something similar enough anyways), these little snippets should do what you want:

 

Script Edit to skip enemy targeting:

 

# Skip Enemy Targeting
class Scene_Battle
 #--------------------------------------------------------------------------
 # * Frame Updat (actor command phase : enemy selection)
 #--------------------------------------------------------------------------
 def update_phase3_enemy_select
   @active_battler.current_action.target_index = 0
   @enemy_arrow = nil
   if @skill_window != nil
     end_skill_select
   end
   if @item_window != nil
     end_item_select
   end
   phase3_next_actor
 end
 #--------------------------------------------------------------------------
 # * Start Enemy Selection
 #--------------------------------------------------------------------------
 def start_enemy_select
   @enemy_arrow = true
 end
end

 

Script Edit to skip actor targeting:

 

# Skip Actor Targeting
class Scene_Battle
 #--------------------------------------------------------------------------
 # * Frame Update (actor command phase : actor selection)
 #--------------------------------------------------------------------------
 def update_phase3_actor_select
   @active_battler.current_action.target_index = @actor_index
   @actor_arrow = nil
   if @skill_window != nil
     end_skill_select
   end
   if @item_window != nil
     end_item_select
   end
   phase3_next_actor
 end
 #--------------------------------------------------------------------------
 # * Start Actor Selection
 #--------------------------------------------------------------------------
 def start_actor_select
   @actor_arrow = true
 end
end

 

Just put 'em above main (in whichever order, or whichever one or you could put them both in the same script) (just make sure they are below all Scene_BattleX)

Share this post


Link to post
Share on other sites

Bypass Item Targeting in Menu:

 

class Scene_Item
 unless method_defined?(:new_ksd_skip_target_upd)
   alias :new_ksd_skip_target_upd :update_item
 end

 def update_item
   if Input.trigger?(Input::C)
     @item = @item_window.item
     if @item.is_a?(RPG::Item) &&
       $game_party.item_can_use?(@item.id)

       if @item.scope >= 3
         target = $game_party.actors.first
         used = target.item_effect(@item)
         if used
           @status_window.refresh if @status_window
           $game_system.se_play(@item.menu_se)
           if @item.consumable
             $game_party.lose_item(@item.id, 1)
             @item_window.draw_item(@item_window.index)
           end
           if $game_party.all_dead?
             $scene = Scene_Gameover.new
           elsif @item.common_event_id > 0
             $game_temp.common_event_id = @item.common_event_id
             $scene = Scene_Map.new
           end
           return
         end
       else
         if @item.common_event_id > 0
           @status_window.refresh if @status_window
           $game_temp.common_event_id = @item.common_event_id
           $game_system.se_play(@item.menu_se)
           if @item.consumable
             $game_party.lose_item(@item.id, 1)
             @item_window.draw_item(@item_window.index)
           end
           $scene = Scene_Map.new
           return
         end
       end
     end
     $game_system.se_play($data_system.buzzer_se)
     return
   end
   new_ksd_skip_target_upd
 end
end

 

 

Bypass Skill Targeting in Menu:

 

class Scene_Skill
 unless method_defined?(:new_ksd_skip_target_upd)
   alias :new_ksd_skip_target_upd :update_skill
 end

 def update_skill
   if Input.trigger?(Input::C)
     @skill = @skill_window.skill
     if @actor.skill_can_use?(@skill.id)

       if @skill.scope >= 3
         target = $game_party.actors.first
         used = target.skill_effect(@actor, @skill)
         if used
           $game_system.se_play(@skill.menu_se)
           @actor.sp -= @skill.sp_cost
           @status_window.refresh
           @skill_window.refresh
           if $game_party.all_dead?
             $scene = Scene_Gameover.new
           elsif @skill.common_event_id > 0
             $game_temp.common_event_id = @skill.common_event_id
             $scene = Scene_Map.new
           end
           return
         end
       else
         if @skill.common_event_id > 0
           $game_temp.common_event_id = @skill.common_event_id
           $game_system.se_play(@skill.menu_se)
           @actor.sp -= @skill.sp_cost
           @status_window.refresh
           @skill_window.refresh
           $scene = Scene_Map.new
           return
         end
       end  
     end
     $game_system.se_play($data_system.buzzer_se)
     return
   end
   new_ksd_skip_target_upd
 end
end

 

 

Bypass Menu Targeting (i.e. Select character's skills to use):

 

class Scene_Menu
 unless method_defined?(:new_ksd_skip_target_upd)
   alias :new_ksd_skip_target_upd :update_command
 end

 def update_command
   if Input.trigger?(Input::C)
     if $game_party.actors.size > 0 && 
       (1..3).include?(@command_window.index)

       case @command_window.index
       when 1  # skill
         if $game_party.actors[@status_window.index].restriction >= 2
           $game_system.se_play($data_system.buzzer_se)
           return
         end
         $game_system.se_play($data_system.decision_se)
         $scene = Scene_Skill.new
       when 2  # equipment
         $game_system.se_play($data_system.decision_se)
         $scene = Scene_Equip.new
       when 3  # status
         $game_system.se_play($data_system.decision_se)
         $scene = Scene_Status.new
       end
       return
     end
   end
   new_ksd_skip_target_upd
 end
end

 

 

Add Character Status to Item menu (to see item usage changes):

 

class Window_Item < Window_Selectable
 def initialize
   super(0, 128, 640, 352)
   @column_max = 2
   refresh
   self.index = 0
   if $game_temp.in_battle
     self.y = 64
     self.height = 256
     self.back_opacity = 160
   end
 end
end

class Scene_Item

 def initialize(actor_index = 0)
   @actor = $game_party.actors[actor_index]
 end

 unless method_defined?(:new_ksd_skip_target_main)
   alias :new_ksd_skip_target_main :main
 end

 def main
   @status_window = Window_SkillStatus.new(@actor)
   new_ksd_skip_target_main
   @status_window.dispose
 end

 unless method_defined?(:new_ksd_skip_target_upd_2)
   alias :new_ksd_skip_target_upd_2 :update
 end

 def update
   @status_window.update
   new_ksd_skip_target_upd_2
 end

end

 

Share this post


Link to post
Share on other sites

Ooh... that add character status to item menu one is snazzy. Kell to the rescue, just as I remember you.

 

Although now that I think about it, I won't need it because I've incorporated the inventory into the primary menu screen, which has a status window a-la old-school resident evil.

 

But thanks for all the other bits, that should do wonders for me.

Edited by NightmareFelix

Share this post


Link to post
Share on other sites

I'm having trouble making the Item targeting one work since my Inventory all takes place on the main menu screen now instead of in Scene_Item. It may be something you'd have to look at to solve, or maybe you'll just pull it out of your butt like you always seem to.

Share this post


Link to post
Share on other sites

pull it out of your butt like you always seem to.

 

LOL this made my day.

 

EDIT: That might explain where my long-term memory is; Every time something leaves my short-term memory, it seems impossible to retrieve.

 

*ahem* unfortunately my scripting bowels are empty right now. I think I'd have to see how you've incorporated the inventory into the Main menu, if possible.

 

I'm sure it should be simple enough to integrate; but it would be a complete shot in the dark without having some structure to go on.

Share this post


Link to post
Share on other sites

 

306169_3946465670898_1557726606_3183857_646705246_n.jpg

 

 

That should be a picture of my menu, there. I may need to post the Scene_Menu code, right?

 

Basically when the player selects "inventory" the item menu becomes active.

 

I designed this over a year ago and God knows how.

 

EDIT: Here's my Scene_Menu:

 

 

#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
#  メニュー画面の処理を行うクラスです。
#==============================================================================
class Scene_Menu
 #--------------------------------------------------------------------------
 # ● オブジェクト初期化
 #	 menu_index : コマンドのカーソル初期位置
 #--------------------------------------------------------------------------
 def initialize(menu_index = 0)
@menu_index = menu_index
 end
 #--------------------------------------------------------------------------
 # ● メイン処理
 #--------------------------------------------------------------------------
 def main
# コマンドウィンドウを作成
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Status"
s5 = "Quit"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.index = @menu_index
# パーティ人数が 0 人の場合
if $game_party.actors.size == 0
  # アイテム、スキル、装備、ステータスを無効化
  @command_window.disable_item(0)
  @command_window.disable_item(1)
  @command_window.disable_item(2)
  @command_window.disable_item(3)
end
# セーブ禁止の場合
if $game_system.save_disabled
  # セーブを無効にする
  @command_window.disable_item(4)
end
# ステータスウィンドウを作成
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# Make item window
@item_window = Window_Item.new
@item_window.x = 0
@item_window.y = 192
# make help window
@help_window = Window_Help.new
@help_window.x = 0
@help_window.y = 416
# Make target window (set to invisible / inactive)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# Execute transition
Graphics.transition
# Main loop
loop do
  # Update game screen
  Graphics.update
  # Update input information
  Input.update
  # Frame update
  update
  # Abort loop if screen is changed
  if $scene != self
	break
  end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@status_window.dispose
@item_window.dispose
@help_window.dispose
 end

 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
# Update windows
@command_window.update
@status_window.update
@target_window.update
@item_window.update
@help_window.update
# If command window is active: call update_command
if @command_window.active
  @item_window.index = -1
  @item_window.active = false
  update_command
  return
end
# If status window is active: call update_status
if @status_window.active
  update_status
  return
end
# If item window is active: call update_item
if @item_window.active
  update_item
  return
end
#if target call update_target
if @target_window.active
  update_target
  return
end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when command window is active)
 #--------------------------------------------------------------------------
 def update_command
# If B button was pressed
if Input.trigger?(Input::B)
  # Play cancel SE
  $game_system.se_play($data_system.cancel_se)
  # Switch to map screen
  $scene = Scene_Map.new
  return
end
# If C button was pressed
if Input.trigger?(Input::C)
  # If command other than save or end game, and party members = 0
  if $game_party.actors.size == 0 and @command_window.index < 4
	# Play buzzer SE
	$game_system.se_play($data_system.buzzer_se)
	return
  end
  # Branch by command window cursor position
  case @command_window.index
  when 0  # item
	# Play decision SE
	$game_system.se_play($data_system.decision_se)
	# Make item window active
	@command_window.active = false
	@item_window.active = true
	@item_window.index = 0
	# Associate help window
	@item_window.help_window = @help_window
  when 1  # skill
	# Play decision SE
	$game_system.se_play($data_system.decision_se)
	# Make status window active
	$scene = Scene_Skill.new(@status_window.index)
  when 2  # equipment
	# Play decision SE
	$game_system.se_play($data_system.decision_se)
	# Switch to equipment screen
	$scene = Scene_Equip.new(@status_window.index)
  when 3  # status
	# Play decision SE
	$game_system.se_play($data_system.decision_se)
	# Switch to status screen
	$scene = Scene_Status.new(@status_window.index)
  when 4  # end game
	# Play decision SE
	$game_system.se_play($data_system.decision_se)
	# Switch to end game screen
	$scene = Scene_End.new
  end
  return
end
 end
 #--------------------------------
 #frame update - item
 #--------------------------------
 def update_item
# If B button was pressed
if Input.trigger?(Input::B)
  # Play cancel SE
  $game_system.se_play($data_system.cancel_se)
  # Make command window active
  @command_window.active = true
  @item_window.active = false
  @item_window.index = -1
  return
end
# If C button was pressed
if Input.trigger?(Input::C)
  # Get currently selected data on the item window
  @item = @item_window.item
  # If not a use item
  unless @item.is_a?(RPG::Item)
	# Play buzzer SE
	$game_system.se_play($data_system.buzzer_se)
	return
  end
  # If it can't be used
  unless $game_party.item_can_use?(@item.id)
	# Play buzzer SE
	$game_system.se_play($data_system.buzzer_se)
	return
  end
  # Play decision SE
  $game_system.se_play($data_system.decision_se)
  # If effect scope is an ally
  if @item.scope >= 3
	# Activate target window
	@item_window.active = false
	@target_window.x = (@item_window.index + 1) % 2 * 304
	@target_window.visible = true
	@target_window.active = true
	# Set cursor position to effect scope (single / all)
	if @item.scope == 4 || @item.scope == 6
	  @target_window.index = -1
	else
	  @target_window.index = 0
	end
  # If effect scope is other than an ally
  else
	# If command event ID is valid
	if @item.common_event_id > 0
	  # Command event call reservation
	  $game_temp.common_event_id = @item.common_event_id
	  # Play item use SE
	  $game_system.se_play(@item.menu_se)
	  # If consumable
	  if @item.consumable
		# Decrease used items by 1
		$game_party.lose_item(@item.id, 1)
		# Draw item window item
		@item_window.draw_item(@item_window.index)
	  end
	  # Switch to map screen
	  $scene = Scene_Map.new
	  return
	end
  end
  return
end
 end
#--------------------------------------------------------------------------
 # * Frame Update (when target window is active)
 #--------------------------------------------------------------------------
 def update_target
# If B button was pressed
if Input.trigger?(Input::B)
  # Play cancel SE
  $game_system.se_play($data_system.cancel_se)
  # If unable to use because items ran out
  unless $game_party.item_can_use?(@item.id)
	# Remake item window contents
	@item_window.refresh
  end
  # Erase target window
  @item_window.active = true
  @target_window.visible = false
  @target_window.active = false
  return
end
# If C button was pressed
if Input.trigger?(Input::C)
  # If items are used up
  if $game_party.item_number(@item.id) == 0
	# Play buzzer SE
	$game_system.se_play($data_system.buzzer_se)
	return
  end
  # If target is all
  if @target_window.index == -1
	# Apply item effects to entire party
	used = false
	for i in $game_party.actors
	  used |= i.item_effect(@item)
	end
  end
  # If single target
  if @target_window.index >= 0
	# Apply item use effects to target actor
	target = $game_party.actors[@target_window.index]
	used = target.item_effect(@item)
  end
  # If an item was used
  if used
	# Play item use SE
	$game_system.se_play(@item.menu_se)
	# If consumable
	if @item.consumable
	  # Decrease used items by 1
	  $game_party.lose_item(@item.id, 1)
	  # Redraw item window item
	  @item_window.draw_item(@item_window.index)
	end
	# Remake target window contents
	@target_window.refresh
	# If all party members are dead
	if $game_party.all_dead?
	  # Switch to game over screen
	  $scene = Scene_Gameover.new
	  return
	end
	# If common event ID is valid
	if @item.common_event_id > 0
	  # Common event call reservation
	  $game_temp.common_event_id = @item.common_event_id
	  # Switch to map screen
	  $scene = Scene_Map.new
	  return
	end
  end
  # If item wasn't used
  unless used
	# Play buzzer SE
	$game_system.se_play($data_system.buzzer_se)
  end
  return
end
 end
 #--------------------------------------------------------------------------
 # * Frame Update (when status window is active)
 #--------------------------------------------------------------------------
 def update_status
# If B button was pressed
if Input.trigger?(Input::B)
  # Play cancel SE
  $game_system.se_play($data_system.cancel_se)
  # Make command window active
  @command_window.active = true
  @status_window.active = false
  @status_window.index = -1
  return
end
# If C button was pressed
if Input.trigger?(Input::C)
  # Branch by command window cursor position
  case @command_window.index
  when 1  # skill
	# If this actor's action limit is 2 or more
	if $game_party.actors[@status_window.index].restriction >= 2
	  # Play buzzer SE
	  $game_system.se_play($data_system.buzzer_se)
	  return
	end
	# Play decision SE
	$game_system.se_play($data_system.decision_se)
	# Switch to skill screen
	$scene = Scene_Skill.new(@status_window.index)
  when 2  # equipment
	# Play decision SE
	$game_system.se_play($data_system.decision_se)
	# Switch to equipment screen
	$scene = Scene_Equip.new(@status_window.index)
  when 3  # status
	# Play decision SE
	$game_system.se_play($data_system.decision_se)
	# Switch to status screen
	$scene = Scene_Status.new(@status_window.index)
  end
  return
end
 end
end

 

Edited by NightmareFelix

Share this post


Link to post
Share on other sites

Ah perfect! I had a feeling it would be implemented that way.

 

I think, you should be able to just change the first part of my script from:

class Scene_Item

to

class Scene_Menu

and it should work correctly.

 

* Make sure though, that my script is BELOW your menu script *

 

Let me know if that works or not.

 

EDIT: Or, do you need it to target the character at all (like in the status window) as some kind of confirmation?

Share this post


Link to post
Share on other sites

You know what... that's exactly what I just did on my own while waiting for your response. The thing was, I thought I had tried that a minute ago and turned back some sort of problem, but I tried it again about 3 seconds ago and it fixed it. Thanks Kell. You've been instrumental. I'm ready for Beta now!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...