GubiD's Tactical Battle System
Autor
GubiD
Instruções
Cria um sistema de batalha tático com posições pré defidas para posicionamento, similar ao Final Fantasy Tactics. Possui efeitos de particulas e projéteis.
Srceens








Download para VX
LINK PROTEGIDO!
REGISTRE-SE ou faça o LOGIN para visualizar o link.
Download para XP
LINK PROTEGIDO!
REGISTRE-SE ou faça o LOGIN para visualizar o link.
ADD ON
Mouse suport:
Código:
if defined?(Sprite_Mouse)
#==============================================================================
# Sprite Mouse changes
#==============================================================================
class Sprite_Mouse
def dispose
@sprite.dispose
end
end
#==============================================================================
# ** Window
#------------------------------------------------------------------------------
# Adds all window instances to $windows array so that Input will only be
# registered if Mouse is over window or key was pressed.
#==============================================================================
$windows = []
class Window_Base < Window
alias init_win_mouse_gtbs initialize
def initialize(*args)
init_win_mouse_gtbs(*args)
$windows << self
end
alias dispose_win_mouse_gtbs dispose
def dispose(*args)
$windows.delete(self)
dispose_win_mouse_gtbs(*args)
end
end
#==============================================================================
# ** Input
#------------------------------------------------------------------------------
# Modifies mouse input so that it is only registered if over active window or
# key was logged.
#==============================================================================
class << Input
UMS_Present = defined?(NORMAL_MODE)
def Input.get_active_window
win = nil
for window in $windows
if !window.disposed? and window.active and window.visible and
!window.is_a?(Window_Actor_Display) and !window.is_a?(Window_Help)
if UMS_Present and !window.is_a?(Window_Dummy)
win = window
else
win = window
end
end
end
return win
end
alias upd_gtbs_input_mouse update
def Input.update
@new_cycle = true
upd_gtbs_input_mouse
end
#--------------------------------------------------------------------------
# * Update old input triggers
# num : A, B, C
#--------------------------------------------------------------------------
alias gtbs_mouse_old_trigger? trigger? unless $@
def Input.trigger?(num)
# Result old result(mousie method) if not gtbs battle
return gtbs_mouse_old_trigger?(num) if !$scene.is_a?(Scene_Battle_TBS)
result = old_trigger?(num)
return result if result == true #return keyboard result if it was found
# If Mouse is inside of the game window.
if Mouse.pos(false) != nil
active = Input.get_active_window
# If no active window
if active.nil?
if Mouse.click?(Mouse::Middle_Click) and !$scene.busy
$mouse.set_cursor
return false
elsif Mouse.click?(Mouse::Left_Click) and num == Input::C and !$scene.busy
cursor = $scene.cursor
if (cursor.x != $mouse.tile_x or cursor.y != $mouse.tile_y) and $scene.phase != 6
$mouse.set_cursor
@new_cycle = false
else
return (old_trigger?(num) or (Mouse.click?(Mouse::Left_Click) and num == Input::C and @new_cycle))
end
elsif Mouse.click?(Mouse::Right_Click) and num == Input::B
return Mouse.click?(Mouse::Right_Click)
else; return false
end
#If active window, then ensure that cursor is within dialog and proceed like normal
elsif active != nil and $mouse.x.between?(active.x, active.x+active.width) and
$mouse.y.between?(active.y, active.y+active.height)
case num
when Input::A
return (old_trigger?(num) or Mouse.click?(Mouse::Middle_Click))
when Input::B
if MOUSE_RIGHT_ACTION == 0
return (old_trigger?(num) or Mouse.click?(Mouse::Right_Click))
else
if !$scene.is_a?(Scene_Map)
return (old_trigger?(num) or Mouse.click?(Mouse::Right_Click))
else
return (old_trigger?(num))
end
end
when Input::C
if MOUSE_LEFT_ACTION == 0
return (old_trigger?(num) or Mouse.click?(Mouse::Left_Click))
else
if !$scene.is_a?(Scene_Map)
return (old_trigger?(num) or Mouse.click?(Mouse::Left_Click))
else
if $mouse.clicked == 2
return (old_trigger?(num) or Mouse.click?(Mouse::Left_Click))
else
return (old_trigger?(num))
end
end
end
end
end
end
return result
end
#--------------------------------------------------------------------------
# * Check to see if an old input call was repeated
# num : B
#--------------------------------------------------------------------------
alias old_repeat? repeat? unless $@
def repeat?(num)
return old_repeat?(num) if Mouse.pos(false) == nil
if num == Input::B
return (old_repeat?(num) or Mouse.repeat?(Mouse::Right_Click))
else
return old_repeat?(num)
end
end
end
#==============================================================================
# Game Battler - changes introduced by mouse
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# Turn Toward (object) - Turns the player towards the object based on x,y
#--------------------------------------------------------------------------
def turn_toward(object)
# Get difference in player coordinates
sx = self.x - object.x
sy = self.y - object.y
# If coordinates are equal
if sx == 0 and sy == 0
return
end
# If horizontal distance is longer
if sx.abs > sy.abs
# Turn to the right or left towards player
sx > 0 ? turn_left : turn_right
# If vertical distance is longer
else
# Turn up or down towards player
sy > 0 ? turn_up : turn_down
end
end
end
#==============================================================================
# Scene Battle TBS changes
#==============================================================================
class Scene_Battle_TBS
attr_reader :cursor
attr_reader :windows
#--------------------------------------------------------------------------
# Start - Replace Mouse with GTBS version
#--------------------------------------------------------------------------
alias start_gtbs_battle start
def start
start_gtbs_battle
$mouse.dispose
$mouse = Sprite_Mouse_GTBS.new
end
#--------------------------------------------------------------------------
# Busy - Prevents mouse click from interruppting a process
#--------------------------------------------------------------------------
def busy
return true if @tbs_phase > 6
end
#--------------------------------------------------------------------------
# Phase - Returns the current TBS phase
#--------------------------------------------------------------------------
def phase
return @tbs_phase
end
#--------------------------------------------------------------------------
# Terminate - Resets the mouse back to default
#--------------------------------------------------------------------------
alias terminate_gtbs_battle terminate
def terminate
$mouse.dispose
$mouse = Sprite_Mouse.new
terminate_gtbs_battle
end
#--------------------------------------------------------------------------
# tbs_phase_6 - wait phase updates for mouse
#--------------------------------------------------------------------------
alias wait_phase_mouse_update tbs_phase_6
def tbs_phase_6
unless @wait_pic
wait_phase_mouse_update
end
update_battler_to_mouse_direction(@active_battler)
wait_phase_mouse_update
end
#--------------------------------------------------------------------------
# Update Battler To Mouse Direction (pretty self explanitory)
#--------------------------------------------------------------------------
def update_battler_to_mouse_direction(battler)
if Mouse.pos(false) != nil
pos = POS.new($mouse.tile_x, $mouse.tile_y)
@active_battler.turn_toward(pos)
end
end
end
#==============================================================================
# Game Event Update
#==============================================================================
class Game_Event < Game_Character
def at_xy_coord(x,y)
return (x == self.x and y == self.y)
end
end
#==============================================================================
# Sprite Mouse
#==============================================================================
class Sprite_Mouse
#--------------------------------------------------------------------------
# Initialize - Changes to overall reduce lag of the Mousie System
#--------------------------------------------------------------------------
alias init_spr_mouse initialize
def initilaize
init_spr_mouse
@cur_tile_x = 0
@cur_tile_y = 0
end
#--------------------------------------------------------------------------
# Update - Same as above
#--------------------------------------------------------------------------
alias update_spr_mouse update
def update
update_spr_mouse
@new_cycle_x = true
@new_cycle_y = true
end
#--------------------------------------------------------------------------
# * Mouseover Icon - more changes to reduce lag
#--------------------------------------------------------------------------
alias gtbs_mouse_over_icon_fix mouse_over_icon
def mouse_over_icon
return if $game_map.scrolling? or $game_player.moving?
gtbs_mouse_over_icon_fix
end
#--------------------------------------------------------------------------
# * Get the current x-coordinate of the tile - iso based as well
#--------------------------------------------------------------------------
def tile_x
if !@new_cycle_x
return @cur_tile_x
else
if !$game_map.iso?
@cur_tile_x = ((($game_map.display_x.to_f/4.0).floor + @x.to_f)/32.0).floor
@new_cycle_x = false
return @cur_tile_x
else
x,y = $mouse.x, $mouse.y
x += $game_map.display_x/4
y += $game_map.display_y/4
for pos in $game_map.grid.keys
rect = $game_map.grid[pos]
if rect.in?(x,y)
@cur_tile_x = pos[0]
@new_cycle_x = false
return @cur_tile_x
end
end
end
return @cur_tile_x
end
end
#--------------------------------------------------------------------------
# * Get the current y-coordinate of the tile - iso based as well
#--------------------------------------------------------------------------
def tile_y
if !@new_cycle_y
return @cur_tile_y
else
if !$game_map.iso?
@cur_tile_y = ((($game_map.display_y.to_f/4.0).floor + @y.to_f)/32.0).floor
@new_cycle_y = false
return @cur_tile_y
else
x,y = $mouse.x, $mouse.y
x += $game_map.display_x/4
y += $game_map.display_y/4
for pos in $game_map.grid.keys
rect = $game_map.grid[pos]
if rect.in?(x,y)
@cur_tile_y = pos[1]
@new_cycle_y = false
return @cur_tile_y
end
end
end
return @cur_tile_y
end
end
end
#==============================================================================
# ** Sprite_Mouse_GTBS
#------------------------------------------------------------------------------
# This sprite is used to display the mouse. It observes the Mouse module and
# automatically changes mouse graphic conditions.
#==============================================================================
class Sprite_Mouse_GTBS
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :icon
attr_accessor :x
attr_accessor :y
attr_accessor :clicked
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@x = 0
@y = 0
@clicked = nil
@sprite = Sprite.new
@sprite.z = 10000
@draw = false
@events = {}
reset
end
def dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Reset
#--------------------------------------------------------------------------
def reset
@icon = RPG::Cache.icon(MOUSE_ICON[MOUSE_DEFAULT])
@icon_name = MOUSE_ICON[MOUSE_DEFAULT]
@sprite.bitmap.dispose if @sprite.bitmap != nil and @sprite.bitmap.disposed?
@sprite.bitmap = @icon
@draw = false
# Updates the co-ordinates of the icon
@x, @y = Mouse.pos
@sprite.x = @x
@sprite.y = @y
@sprite.z = 10000
@sprite.visible = true
@cur_tile_x = 0
@cur_tile_y = 0
end
#--------------------------------------------------------------------------
# * Set Cursor - Updates the location of the battle cursor
#--------------------------------------------------------------------------
def set_cursor
$game_troop.interpreter.set_tbs_cursor(tile_x, tile_y)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
Mouse.update
@sprite.update
# Updates the co-ordinates of the icon
@x, @y = Mouse.pos
return if @x == nil or @y == nil
#Get Client Size
width,height = Mouse.client_size
@sprite.x = @x
@sprite.y = @y
#Check if needs to restart
(@draw = (@x < 0 or @y < 0 or @x > width or @y > height)) if !@draw
#Reset if need to reset
reset if @draw and @x > 1 and @y > 1 and @x < width and @y < height
#Show mouse if need to
if (@x < 0 or @y < 0 or @x > width or @y > height) and @visible
Mouse.visible?
elsif (@x > 0 or @y > 0 or @x < width or @y < height) and !@visible
Mouse.visible?(false)
end
@new_cycle_x = true
@new_cycle_y = true
end
#--------------------------------------------------------------------------
# * Get the current x-coordinate of the tile - iso as well
#--------------------------------------------------------------------------
def tile_x
if !@new_cycle_x
return @cur_tile_x
else
if !$game_map.iso?
@cur_tile_x = ((($game_map.display_x.to_f/4.0).floor + @x.to_f)/32.0).floor
@new_cycle_x = false
return @cur_tile_x
else
x,y = $mouse.x, $mouse.y
x += $game_map.display_x/4
y += $game_map.display_y/4
for pos in $game_map.grid.keys
rect = $game_map.grid[pos]
if rect.in?(x,y)
@cur_tile_x = pos[0]
@new_cycle_x = false
return @cur_tile_x
end
end
end
return @cur_tile_x
end
end
#--------------------------------------------------------------------------
# * Get the current y-coordinate of the tile - iso as well
#--------------------------------------------------------------------------
def tile_y
if !@new_cycle_y
return @cur_tile_y
else
if !$game_map.iso?
@cur_tile_y = ((($game_map.display_y.to_f/4.0).floor + @y.to_f)/32.0).floor
@new_cycle_y = false
return @cur_tile_y
else
x,y = $mouse.x, $mouse.y
x += $game_map.display_x/4
y += $game_map.display_y/4
for pos in $game_map.grid.keys
rect = $game_map.grid[pos]
if rect.in?(x,y)
@cur_tile_y = pos[1]
@new_cycle_y = false
return @cur_tile_y
end
end
end
return @cur_tile_y
end
end
#--------------------------------------------------------------------------
# * Get Object - Returns GTBS battle objects only
#--------------------------------------------------------------------------
def get_object
for event in $game_map.tactical_events
return [true,event] if event.at_xy_coord(tile_x, tile_y)
end
return [false,nil]
end
#--------------------------------------------------------------------------
# * MOUSE Refresh(Event, List, Characterset Name - Here for compatibility
#--------------------------------------------------------------------------
def refresh(event, list)
end
end
#==============================================================================
# Rectangle Class Method Additions
#==============================================================================
class Rect
#--------------------------------------------------------------------------
# In? - Returns if the ploted x,y is contained with-IN the rect
#--------------------------------------------------------------------------
def in?(x,y)
if (self.x <= x and (self.x + self.width) >= x) and
(self.y <= y and (self.y + self.height) >= y)
return true
end
return false
end
end
#==============================================================================
# Game Map Changes - for iso mouse movement
#==============================================================================
class Game_Map
attr_reader :grid
#--------------------------------------------------------------------------
# Setup - Sets up the current map click grid if iso
#--------------------------------------------------------------------------
alias gtbs_gm_setup_mouse setup
def setup(map_id)
gtbs_gm_setup_mouse(map_id)
@grid = {}
generate_click_grid if iso?
end
#--------------------------------------------------------------------------
# Generate Click Grid - Creates click gride based on iso coords
# Due to size of the objects, there will be overlap in placed, but it shouldn't
# matter because it will always use the first match found. Also if you click
# in an area that is not within any click grid, then it will use $game_player, or
# battle_cursor current value for the missing coord to prevent errors.
#--------------------------------------------------------------------------
def generate_click_grid
for x in 0...width
for y in 0...height
sx = (x*32 - y*32) + (32*height)
sy = (x*32 + y*32)/2
rect = Rect.new(sx-13,sy+6,36,19)
@grid[[x,y]] = rect
end
end
end
end
end
Créditos Extras
Nick pelo TBS original
CronoCry por algumas traduções
MGCaladtogel e Seigfried pelo ISO script
CrushD pelos projéteis
Zeriab pelo comando de reset usando F12.
Near Fantasia pelo "path finding" scripts

Entrar
Cadastre-se
Ajuda


Citar