03-07-2008, 05:51 AM
Cross Commands
by Blazingamer
by Blazingamer
Introduction:
I modeled a cross command system for battle since my brother likes them. So in my spare time I made it.
The Script:
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
Instructions:
To use it in battle, replace
Code:
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
Code:
@actor_command_window = CrossCommand.new
FAQ:
Q: Why can't I select commands other than attack?
A: You must hold down the directional key to select.
Q: Why when I press up it flashes between the two?
A: I have no freakin' idea, so don't ask.
Thank you, have a nice day!