Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Cross Commands

I modeled a cross command system for battle since my brother likes them.  So in my spare time I made it.

Code:
#==============================================================================
#  CrossCommand
#  
#   Blazingamer
#  -----------------------------------------
#   Makes a pretty command window in a shape of a cross like in Wild Arms
#==============================================================================

class CrossCommand < Window_Selectable

  def initialize
	super(320 - 128, 160 - 128, 256, 256)
	self.contents = Bitmap.new(width - 32, height - 32)
	self.opacity = 0
	@commands = ["attack", "magic","defend","items","run away"]
	@item_max = 5
	draw_item(0, 32,32,"Attack")
	draw_item(1, 32,0, "Magic")
	draw_item(2, 64,32,"Defend")
	draw_item(3, 0,32, "Items")
	draw_item(4, 32,64, "Run")
	self.active = false
	self.visible = false
	self.index = 0
  end

  def draw_item(index, x, y, icon)   
	bitmap = RPG::Cache.icon(icon)
	self.contents.blt(x, y, bitmap, Rect.new(0, 0, 32, 32))
  end

  def update_cursor_rect
	if index == 3
	  self.cursor_rect.set(0, 32, 32, 32)
	elsif index == 2
	  self.cursor_rect.set(64, 32, 32, 32)
	elsif index == 1
	   self.cursor_rect.set(32,0,32,32)
	elsif index == 4
	   self.cursor_rect.set(32,64,32,32)
	else
	   self.cursor_rect.set(32,32,32,32)
	end
	if Input.press?(Input::LEFT)
	  @index = 3
	elsif Input.press?(Input::RIGHT)
	  @index = 2
	elsif Input.press?(Input::UP)
	  @index = 1
	elsif Input.press?(Input::DOWN)
	  @index = 4
	else
	  @index = 0
	end
  end
end

class Scene_Battle
  
  def update_phase3_basic_command
	if Input.trigger?(Input::B)
	  $game_system.se_play($data_system.cancel_se)
	  phase3_prior_actor
	  return
	end
	if Input.trigger?(Input::C)
	  case @actor_command_window.index
	  when 0
		$game_system.se_play($data_system.decision_se)
		@active_battler.current_action.kind = 0
		@active_battler.current_action.basic = 0
		start_enemy_select
	  when 1
		$game_system.se_play($data_system.decision_se)
		@active_battler.current_action.kind = 1
		start_skill_select
	  when 2
		$game_system.se_play($data_system.decision_se)
		@active_battler.current_action.kind = 0
		@active_battler.current_action.basic = 1
		phase3_next_actor
	  when 3
		$game_system.se_play($data_system.decision_se)
		@active_battler.current_action.kind = 2
		start_item_select
	  when 4
		enemies_agi = 0
		enemies_number = 0
		for enemy in $game_troop.enemies
		  if enemy.exist?
			enemies_agi += enemy.agi
			enemies_number += 1
		  end
		end
		if enemies_number > 0
		  enemies_agi /= enemies_number
		end
		actors_agi = 0
		actors_number = 0
		for actor in $game_party.actors
		  if actor.exist?
			actors_agi += actor.agi
			actors_number += 1
		  end
		end
		if actors_number > 0
		  actors_agi /= actors_number
		end
		success = rand(100) < 50 * actors_agi / enemies_agi
		if success
		  $game_system.se_play($data_system.escape_se)
		  $game_system.bgm_play($game_temp.map_bgm)
		  battle_end(1)
		else
		  $game_party.clear_actions
		  start_phase4
		end
	  end
	  return
	end
  end
end

Instead of using pictures, it uses 32 x 32 pixels icons.  You can change the size of the icons to what ever size you want, but it will take a bit of adjustments in the script.

To use it in battle, replace

Code:
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])

with

Code:
@actor_command_window = CrossCommand.new

To use it, you can either make your own icons or if you want, use these provided for you

http://www.creationasylum.net/uploads/m ... 159701.png[/img]
http://www.creationasylum.net/uploads/m ... 159758.png[/img]
http://www.creationasylum.net/uploads/m ... 159745.png[/img]
http://www.creationasylum.net/uploads/m ... 159727.png[/img]
http://www.creationasylum.net/uploads/m ... 159715.png[/img]
 

creiz

Member

nice one, homie. But it does'nt work With TRTAB for me. Do you think you can fix it?

By the way, Simple, yet effective. VERY nice work. Kudos!
 
For some reason, when I hold "Up", the cursor will flash between up and center. But this doesn't happen for the other directions.

Or, better yet, it there anyway to make it so you don't have to hold the directional button? Like, if you press 'Up' and want to go back to 'attack', you just press 'down'?
 

Taylor

Sponsor

I can't seem to scroll through the options or see the text (I assume there should be captions for options?)
I think it's incompatible with SDK.
 

Taylor

Sponsor

Ah... you have to hold down the arrow key to get the corresponding item.
The icons should highlight when a button is held down, that would help work out how to choose items.
 
I don't know what's wrong with what you're doing JT, but there aren't supposed to be captions and the buttons do highlight, they have a square around the selected one.
 
kaze950":2it0awfc said:
For some reason, when I hold "Up", the cursor will flash between up and center. But this doesn't happen for the other directions.
Necro post sorry but can you fix the bug?
 
well i must say, the icons are cool, but the whole system is just messy,
there's just 3  problems i found with it so far...

1. if u hold up it flicks between middle and top icon,

2. it's annoying that the CRAP "fight - escape" options appear after every round,

and...

3. when you select magic, it only uses the skill in the first skill slot.

If you could sort those out I would definatly use this in my new game I'm making,
other than those 3 points though, it will be a great CBS if you deal with these issues.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top