~Base De Datos de Script de EMD~

Estado
Cerrado para nuevas respuestas
Mensajes
315
Reacciones
0
Puntos
0
No es necesario un script, puedes hacerlo con una buena combinacion acciones dentro de un evento.

Por ejemplo si usas el VX (cosa que deberías haber aclarado)

Podría hacerlo como yo lo estoy haciendo en una parte de mi juego. utilizando las condiciones y efectos y las animaciones, yo lo hice así:

(entre parentesis () pondré la acción que se ejecuta, y al lado las indicaciones)

Hoja 1:

Gráfico(el que uses, puede ser una piedra o roca).

Prioridad igual al personaje, para que o lo puedas pasar.

Contenido del evento

(Condiciones y efectos) Puedes poner que tengas un objeto, o que un personaje este equipado con un arma, o usa tu imaginación.

Condiciones y efectos (Si)

(Mostrar animación) Elige una a tu gusto.
(Control de interruptor) ponle un nombre que recuerdes, y pone activado.


Condiciones y efectos (No)



Hoja 2

Condiciones de aparición: pone si el interruptor que usaste esta activado.

Grafico: Ninguno

Prioridad: Bajo el personaje

Contenido del evento: Ninguno.
 
Mensajes
315
Reacciones
0
Puntos
0
Hola La Verdad Es Que Yo Soy Nuevo En Esto Del Rpg Maker Xp Pero Tengo Una Duda Yo Creo Los Sprites Para Mis Chars Pero Me Cuando Los Pruevo En El Juego Me Aparece El Color Del Fondo Del Esprite Y No Se Como Se Quita Eso

Primero debes postear en el tema de dudas.

Pero se resuelve poniendo el color de fondo el mismo que es el color de fondo de tu imagen.
 
Mensajes
7
Reacciones
0
Puntos
0
Ubicación
En mi casa ... XD
Nombre : mode7

version de scripts : ???

rpg maker ç. xp

introduccion: crea un nuevo modo de vista es epecial para hacer esenas de presentacion


7836453244.png



Code :

#============================================================================
# This script adds a kind of depth for the maps.
# Written by MGCaladtogel
# English version (24/04/08)
#----------------------------------------------------------------------------
# Instructions :
# You must add to the map's name :
#- [M7] : to activate Mode7
#- [#XX] : XX is the slant angle (in degree). Default value is 0 (normal maps)
#- [Y] : Y-map looping
#- [X] : X-map looping. This option needs resources (lower fps).
#- [A] : animated autotiles (with 4 patterns). This option increases
# significantly the loading time, so it may crash for large maps
# (SystemStackError)
#- [C] : to center the map on the hero (even for small maps)
#- [P] : to have a fixed panorama
#- [H] : to have a white horizon
#- [OV] : Overworld Sprite Resize (a Mewsterus's script feature)
#
# OR :
# see the "$mode7_maps_settings" below (l.48) to prapare your settings
#----------------------------------------------------------------------------
# Other commands (for events) :
#- $scene.spriteset.tilemap.mode7_set(new_angle)
# To redraw the map with the new_angle
#- $scene.spriteset.tilemap.mode7_set_p(new_angle)
# To redraw progressively the map from the current angle to the new
#- $scene.spriteset.tilemap.mode7_redraw
# To redraw the map (useful with the following commands)
#- $game_system.map_opacity = value
# To define the opacity for Mode7 maps (it needs to redraw)
#- $game_system.map_gradual_opacity = value
# To define a gradual opacity for Mode7 maps (it needs to redraw)
# (it bugs with horizontal looping)
#- $game_system.map_tone = Color.new(Red, Green, Blue)
# To define the tone for Mode7 maps (it needs to redraw)
#- $game_system.map_gradual_tone = Tone.new(Red, Green, Blue, Gray)
# To define a gradual tone for Mode7 maps (it needs to redraw)
#- $game_system.horizon = value
# To define the view's distance (default : 960) (it needs to redraw)
#- $game_system.reset
# To initialize the previous options
#
#- To obtain flat events :
# just add a comment in the event's commands list with : "Flat"
#
#- To handle the height of a vertical event :
# add a comment in the event's commands list with : "Heigth X", where X is the
# height value ("Heigth 2" will draw the event 64 pixels above its original
# position - you can use floats)
#============================================================================
# The map is drawn from all the tiles of the three layers that do not have a
# terrain_tag's value of 1 or 2.
# The other tiles (terrain_tag = 1 or 2) form elements that are drawn vertically,
# like the 3rd-layer elements in the old version.
# The 2 terrains ID used to form vertical elements
$terrain_tags_vertical_tiles = [1,2] # You can modify these values
# To access maps names
$data_maps = load_data("Data/MapInfos.rxdata")
$mode7_maps_settings = {}
# Prepare your own settings for mode7 maps
# Just put the first parameter in a map's name
# For example :
$mode7_maps_settings["Worldmap"] = ["#60", "X", "Y", "A", "H", "OV"]
# -> will be called when "Worldmap" is included in the name
$mode7_maps_settings["Smallslant"] = ["#20", "A", "S"]
# Add any number of settings you want

# enable/disable mode7 for mode7 maps (not on the fly, just when the map is loaded), enabled by default
$enable_mode7_number = 5 # switch number : change this value !

#============================================================================
# ■ Game_System
#----------------------------------------------------------------------------
# Add attributes to this class
#============================================================================

class Game_System
attr_accessor :mode7 # false : normal map / true : mode 7
attr_accessor :loop_x # true : horizontal-looping map
attr_accessor :loop_y # true : vertical-looping map
attr_accessor :always_scroll # true : to center the camera around the hero
attr_accessor :map_tone # mode7 map's tone (Color)
attr_accessor :map_opacity # mode7 map's opacity (0..255)
attr_accessor :animated # true : animated autotiles for mode7 maps
attr_accessor :white_horizon # true : white line horizon for mode7 maps
attr_accessor :angle # mode7 map's slant angle (in degree)
attr_accessor :horizon # horizon's distance
attr_accessor :fixed_panorama # true : to fix the panorama (no scrolling any more)
attr_accessor :eek:v # true : Overworld Sprite Resize (smaller hero's sprite)
attr_accessor :eek:v_zoom # resize's value with ov
attr_accessor :map_gradual_opacity # mode7 map's gradual opacity (0..255)
attr_accessor :map_gradual_tone # mode7 map's gradual tone (Color)
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias initialize_mode7_game_system initialize
def initialize
initialize_mode7_game_system
self.mode7 = false
self.loop_x = false
self.loop_y = false
self.always_scroll = false
self.animated = false
self.white_horizon = false
self.angle = 0
self.fixed_panorama = false
self.ov = false
self.ov_zoom = 0.6
reset
end
#--------------------------------------------------------------------------
# * Reset the values for opacity, tone and horizon's distance
#--------------------------------------------------------------------------
def reset
self.map_opacity = 255
self.map_tone = Color.new(0,0,0,0)
self.horizon = 960 # default value, equivalent to 30 tiles
self.map_gradual_opacity = 0
self.map_gradual_tone = Tone.new(0,0,0,0)
end
end

#============================================================================
# ■ Tilemap_mode7
#----------------------------------------------------------------------------
# This new Tilemap class handles the drawing of a mode7 map
#============================================================================

class Tilemap_mode7
attr_accessor :maps_list # contains map's graphics
attr_accessor :map_ground # original map's graphic to handle flat events
attr_accessor :tone_values # tone values for each line (Hash)
attr_accessor :eek:pacity_values # opacity values for each line (Hash)
attr_reader :spriteset
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
#--------------------------------------------------------------------------
def initialize(viewport, spriteset)
@spriteset = spriteset
@id = $game_map.map_id # map's ID : to load or save the map in Cache
@maps_list = [] # contains map's drawings (Bitmap)
@disp_y = $game_map.display_y # @disp_y : tilemap's display_y
@disp_x = $game_map.display_x # @disp_x : tilemap's display_x
@height = 32 * $game_map.height # @height : map's height (in pixel)
@width = 32 * $game_map.width # @width : map's width (in pixel)
$game_temp.height = @height
# map's drawings are loaded if already in Cache
if RPG::Cache_Carte.in_cache(@id)
@map = RPG::Cache_Carte.load(@id)
@maps_list.push(@map)
@map_ground = RPG::Cache_Carte.load(@id, 4) # to handle flat events
if $game_system.animated
@map_2 = RPG::Cache_Carte.load(@id, 1)
@map_3 = RPG::Cache_Carte.load(@id, 2)
@map_4 = RPG::Cache_Carte.load(@id, 3)
@maps_list.push(@map_2)
@maps_list.push(@map_3)
@maps_list.push(@map_4)
end
else # draw the map and save it in the Cache
draw_map
end
# create vertical elements from tiles
data_V = Data_Vertical_Sprites.new(viewport)
# @sprites_V : list of vertical sprites (Sprite_V)
@sprites_V = data_V.list_sprites_V
# @sprites_V_animated : list of animated vertical sprites (Sprite_V)
@sprites_V_animated = data_V.list_sprites_V_animated
@angle = $game_system.angle # map's slant angle (in degree)
@distance_h = 480 # distance between the map's center and the vanishing point
@pivot = 256 # screenline's number of the slant's pivot
@index_animated = 0 # 0..3 : index of animated tiles pattern
@viewport = viewport
@tone_values = {} # list of the tone values for each line
@opacity_values = {} # list of the opacity values for each line
init_sprites(@angle) # initialize screenlines sprites
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# dispose of @sprites (scanlines), @sprites_V (vertical_sprites), and
# @sprites_loop_x (additional scanlines for horizontal looping)
for sprite in @sprites + @sprites_V + @sprites_loop_x
sprite.dispose
end
@sprites.clear
@sprites_loop_x.clear
@sprites_V.clear
@sprites_V_animated.clear
@maps_list.clear
$game_system.angle = @angle
end
#--------------------------------------------------------------------------
# * Increase slant's angle
#--------------------------------------------------------------------------
def increase_angle
return if @angle == 88
@angle = [@angle + 2, 88].min # angle's value between 0 and 88 degrees
@sprites.clear
@sprites_loop_x.clear
init_sprites(@angle) # reinitialize screenlines sprites
end
#--------------------------------------------------------------------------
# * Decrease slant's angle
#--------------------------------------------------------------------------
def decrease_angle
return if @angle == 0
@angle = [@angle - 2, 0].max # angle's value between 0 and 88 degrees
@sprites.clear
@sprites_loop_x.clear
init_sprites(@angle) # reinitialize screenlines sprites
end
#--------------------------------------------------------------------------
# * Slide from the current angle into the target value
# value : target angle's value (in degree)
#--------------------------------------------------------------------------
def mode7_set_p(value)
while value > @angle
increase_angle
spriteset.update
Graphics.update
end
while value < @angle
decrease_angle
spriteset.update
Graphics.update
end
end
#--------------------------------------------------------------------------
# * Redraw the map instantaneously with the new slant angle's value
# value : target angle's value (in degree)
#--------------------------------------------------------------------------
def mode7_set(value)
@angle = [[value, 0].max, 89].min
@sprites.clear
@sprites_loop_x.clear
init_sprites(@angle) # reinitialize screenlines sprites
update
Graphics.update
end
#--------------------------------------------------------------------------
# * Reinitialize screenlines sprites
#--------------------------------------------------------------------------
def mode7_redraw
@sprites.clear
@sprites_loop_x.clear
init_sprites(@angle) # reinitialize scanlines
update
Graphics.update
end
#--------------------------------------------------------------------------
# * Create sprites equivalent to scanlines
# value : target angle's value (in degree)
#--------------------------------------------------------------------------
def init_sprites(angle)
@horizon = $game_system.horizon
angle_rad = (Math::pI * angle) / 180 # angle in radian
@sprites = [] # list of the scanlines sprites (Sprite)
@sprites_loop_x = [] # list of the additionnal sprites (for X-looping)
cos_angle = Math.cos(angle_rad)
sin_angle = Math.sin(angle_rad)
# save values in $game_temp
$game_temp.distance_h = @distance_h
$game_temp.pivot = @pivot
$game_temp.cos_angle = cos_angle
$game_temp.sin_angle = sin_angle
# h0, z0 : intermediate values
h0 = (- @distance_h * @pivot * cos_angle).to_f /
(@distance_h + @pivot * sin_angle) + @pivot
z0 = @distance_h.to_f / (@distance_h + @pivot * sin_angle)
$game_temp.slope_value = (1.0 - z0) / (@pivot - h0)
$game_temp.corrective_value = 1.0 - @pivot * $game_temp.slope_value
last_line = - @pivot - @horizon # last_line : the highest line that is drawn
height_limit = (@distance_h * last_line * cos_angle).to_f /
(@distance_h - last_line * sin_angle) + @pivot # the line corresponding to
# the last_line in the warped reference = horizon's line
$game_temp.height_limit = height_limit
# constant to handle gradual opacity
k2lim = ((@distance_h * last_line).to_f /
(@distance_h * cos_angle + last_line * sin_angle)).to_i
# one sprite is created for each screenline
for j in 0..479
next if j < height_limit # if the line is further than the horizon's line,
# no sprite is created
i = j - @pivot # y-reference is the pivot's line
sprite = Sprite.new(@viewport)
sprite.x = 320 # x-reference is the vertical line in the middle of the screen
sprite.y = j
sprite.z = - 99999 # map must not mask vertical elements
sprite.y_origin_bitmap = (@distance_h * i).to_f /
(@distance_h * cos_angle + i * sin_angle) + @pivot
sprite.y_origin_bitmap_i = (sprite.y_origin_bitmap + 0.5).to_i
sprite.y_origin_bitmap_i %= @height if $game_system.loop_y
sprite.zoom_x = $game_temp.slope_value * j + $game_temp.corrective_value
sprite.length = 2 + (640.to_f / sprite.zoom_x).to_i
sprite.x_origin_bitmap_i = ((642 - sprite.length) / 2)
sprite.x_origin_bitmap_i %= @width if $game_system.loop_x
sprite.x_origin_bitmap = (sprite.x_origin_bitmap_i).to_f
sprite.ox = sprite.length / 2
sprite.bitmap = @map
# horizontal translation to center around the hero
if @disp_x != 0
sprite.x_origin_bitmap += @disp_x / 4
sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
sprite.x_origin_bitmap_i %= @width if $game_system.loop_x
end
# vertical translation to center around the hero
if @disp_y != 0
sprite.y_origin_bitmap += @disp_y / 4
sprite.y_origin_bitmap_i = (sprite.y_origin_bitmap + 0.5).to_i
sprite.y_origin_bitmap_i %= @height if $game_system.loop_y
end
# handle opacity and tone
k2 = ((@distance_h * i).to_f /
(@distance_h * cos_angle + i * sin_angle)).to_i
k2 = 0 if k2 > 0
k_red = (- k2.to_f/k2lim * $game_system.map_gradual_tone.red).to_i
k_green = (- k2.to_f/k2lim * $game_system.map_gradual_tone.green).to_i
k_blue = (- k2.to_f/k2lim * $game_system.map_gradual_tone.blue).to_i
k_gray = (- k2.to_f/k2lim * $game_system.map_gradual_tone.gray).to_i
k2 = (- k2.to_f/k2lim * $game_system.map_gradual_opacity).to_i
sprite.tone = Tone.new(k_red, k_green, k_blue, k_gray)
sprite.opacity = 255 - k2
sprite.opacity *= ($game_system.map_opacity).to_f / 255
sprite.color = $game_system.map_tone
# white horizon's line
k = j - height_limit
k = 500 / k
if $game_system.white_horizon
tone_red = sprite.tone.red + k
tone_green = sprite.tone.green + k
tone_blue = sprite.tone.blue + k
tone_gray = sprite.tone.gray + k
sprite.tone = Tone.new(tone_red, tone_green, tone_blue, tone_gray)
end
@tone_values[j] = sprite.tone
@opacity_values[j] = sprite.opacity
# set sprite's graphics
sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
sprite.length, 1)
@sprites.push(sprite)
if $game_system.loop_x and j < @pivot
# additional sprite to handle horizontal looping
sprite2 = Sprite.new(@viewport)
sprite2.x = 320
sprite2.y = j
sprite2.z = - 99999
sprite2.y_origin_bitmap = sprite.y_origin_bitmap
sprite2.y_origin_bitmap_i = sprite.y_origin_bitmap_i
sprite2.zoom_x = sprite.zoom_x
sprite2.length = sprite.length
sprite2.x_origin_bitmap_i = sprite.x_origin_bitmap_i - @width
sprite2.x_origin_bitmap = sprite.x_origin_bitmap_i - @width
sprite2.ox = sprite.ox
sprite2.bitmap = @map
sprite2.opacity = sprite.opacity
sprite2.color = sprite.color
sprite2.tone = sprite.tone
sprite2.src_rect.set(sprite2.x_origin_bitmap_i, sprite2.y_origin_bitmap_i,
sprite2.length, 1)
@sprites_loop_x.push(sprite2)
end
end
end
#--------------------------------------------------------------------------
# * Update the screenlines sprites and the vertical sprites
# compare tilemap's display with map's display
#--------------------------------------------------------------------------
def update
# update screenlines sprites
if @disp_y < $game_map.display_y
difference = $game_map.display_y - @disp_y
@disp_y += difference
for sprite in @sprites + @sprites_loop_x
sprite.y_origin_bitmap += difference.to_f / 4
sprite.y_origin_bitmap_i = (sprite.y_origin_bitmap+0.5).to_i
sprite.y_origin_bitmap_i %= @height if $game_system.loop_y
sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
sprite.length, 1)
end
end
if @disp_y > $game_map.display_y
difference = @disp_y - $game_map.display_y
@disp_y -= difference
for sprite in @sprites + @sprites_loop_x
sprite.y_origin_bitmap -= difference.to_f / 4
sprite.y_origin_bitmap_i = (sprite.y_origin_bitmap+0.5).to_i
sprite.y_origin_bitmap_i %= @height if $game_system.loop_y
sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
sprite.length, 1)
end
end
if @disp_x < $game_map.display_x
difference = $game_map.display_x - @disp_x
@disp_x += difference
for sprite in @sprites
sprite.x_origin_bitmap += difference.to_f / 4
sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
sprite.x_origin_bitmap_i %= @width if $game_system.loop_x
sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
sprite.length, 1)
end
for sprite in @sprites_loop_x
sprite.x_origin_bitmap += difference.to_f / 4
sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
sprite.x_origin_bitmap_i %= @width
sprite.x_origin_bitmap_i -= @width
sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
sprite.length, 1)
end
end
if @disp_x > $game_map.display_x
difference = @disp_x - $game_map.display_x
@disp_x -= difference
for sprite in @sprites
sprite.x_origin_bitmap -= difference.to_f / 4
sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
sprite.x_origin_bitmap_i %= @width if $game_system.loop_x
sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
sprite.length, 1)
end
for sprite in @sprites_loop_x
sprite.x_origin_bitmap -= difference.to_f / 4
sprite.x_origin_bitmap_i = (sprite.x_origin_bitmap).to_i
sprite.x_origin_bitmap_i %= @width
sprite.x_origin_bitmap_i -= @width
sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
sprite.length, 1)
end
end
# update vertical sprites
for sprite in @sprites_V
sprite.update
end
end
#--------------------------------------------------------------------------
# * Update animation for animated tiles
#--------------------------------------------------------------------------
def update_animated
@index_animated += 1
@index_animated %= 4
map = @maps_list[@index_animated]
# update screenlines sprites
for sprite in @sprites + @sprites_loop_x
sprite.bitmap = map
sprite.src_rect.set(sprite.x_origin_bitmap_i, sprite.y_origin_bitmap_i,
sprite.length, 1)
end
# update vertical sprites
for sprite in @sprites_V_animated
sprite.update_animated(@index_animated)
end
end
#--------------------------------------------------------------------------
# * Create bitmaps representing the map
#--------------------------------------------------------------------------
def draw_map
data = $game_map.data
# Table where animated tiles are flagged
data_animated = Table.new($game_map.width, $game_map.height)
# bigger maps to handle horizontal looping
offset = ($game_system.loop_x ? 640 : 0)
@map = Bitmap.new(@width + offset, @height)
@maps_list.push(@map)
rect = Rect.new(0, 0, 32, 32)
# create autotiles graphics
RPG::Cache.clear
@autotiles = []
for i in 0..6
autotile_name = $game_map.autotile_names
fichier = RPG::Cache.autotile(autotile_name)
for l in 0..3
data_autotile = Data_Autotiles.new(fichier,l)
data_autotile.number = 4*i + l
RPG::Cache.save_autotile(data_autotile, data_autotile.number)
@autotiles.push(data_autotile)
end
end
# scan map's data to draw it
for i in 0...$game_map.height
for j in 0...$game_map.width
data_animated[j, i] = 0
# tile's ID for the first layer
value1 = data[j, i, 0].to_i
# prevent from drawing a vertical tile
value1 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value1]) ?
0 : value1)
# value1 != 0
if value1 != 0
# tile's ID for the second layer
value2 = data[j, i, 1].to_i
# prevent from drawing a vertical tile
value2 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value2]) ?
0 : value2)
# tile's ID for the third layer
value3 = data[j, i, 2].to_i
# prevent from drawing a vertical tile
value3 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value3]) ?
0 : value3)
# value1 != 0, value2 = 0
if value2 == 0
# value1 != 0, value2 = 0, value3 = 0
if value3 == 0
# value1 associated with a normal autotile
if value1 > 383
bitmap = RPG::Cache.tile($game_map.tileset_name, value1, 0)
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
# value1 associated with an autotile
else
num = 4*((value1 / 48) - 1)
bitmap = RPG::Cache.autotile_base(num, value1)
if @autotiles[num].animated
data_animated[j, i] = 1
end
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
end
# value1 != 0, value2 = 0, value3 != 0
else
bitmap = RPG::Cache_Tile.load(value1, value3)
# value1 associated with an autotile
if value1 < 384
num = 4*((value1 / 48) - 1)
data_animated[j, i] = 1 if @autotiles[num].animated
end
# value3 associated with an autotile
if value3 < 384
num = 4*((value3 / 48) - 1)
data_animated[j, i] = 1 if @autotiles[num].animated
end
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
end
# value1 != 0, value2 != 0
else
# value1 != 0, value2 != 0, value3 = 0
if value3 == 0
bitmap = RPG::Cache_Tile.load(value1, value2)
# value1 associated with an autotile
if value1 < 384
num = 4*((value1 / 48) - 1)
data_animated[j, i] = 1 if @autotiles[num].animated
end
# value2 associated with an autotile
if value2 < 384
num = 4*((value2 / 48) - 1)
data_animated[j, i] = 1 if @autotiles[num].animated
end
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
# value1 != 0, value2 != 0, value3 != 0
else
bitmap = RPG::Cache_Tile.load2(value1, value2, value3)
# value1 associated with an autotile
if value1 < 384
num = 4*((value1 / 48) - 1)
data_animated[j, i] = 1 if @autotiles[num].animated
end
# value2 associated with an autotile
if value2 < 384
num = 4*((value2 / 48) - 1)
data_animated[j, i] = 1 if @autotiles[num].animated
end
# value3 associated with an autotile
if value3 < 384
num = 4*((value3 / 48) - 1)
data_animated[j, i] = 1 if @autotiles[num].animated
end
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
end
end
# value1 = 0
else
value2 = data[j, i, 1].to_i
value2 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value2]) ?
0 : value2)
value3 = data[j, i, 2].to_i
value3 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value3]) ?
0 : value3)
# value1 = 0, value2 = 0
if value2 == 0
# value1 = 0, value2 = 0, value3 != 0
if value3 != 0
# value3 associated with a normal tile
if value3 > 383
bitmap = RPG::Cache.tile($game_map.tileset_name, value3, 0)
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
# value3 associated with an autotile
else
num = 4*((value3 / 48) - 1)
bitmap = RPG::Cache.autotile_base(num, value3)
if @autotiles[num].animated
data_animated[j, i] = 1
end
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
end
end
# value1 = 0, value2 != 0
else
# value1 = 0, value2 != 0, value3 = 0
if value3 == 0
# value2 associated with a normal tile
if value2 > 383
bitmap = RPG::Cache.tile($game_map.tileset_name, value2, 0)
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
# value2 associated with an autotile
else
num = 4*((value2 / 48) - 1)
bitmap = RPG::Cache.autotile_base(num, value2)
if @autotiles[num].animated
data_animated[j, i] = 1
end
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
end
# value1 = 0, value2 != 0, value3 != 0
else
bitmap = RPG::Cache_Tile.load(value2, value3)
# value2 associated with an autotile
if value2 < 384
num = 4*((value2 / 48) - 1)
data_animated[j, i] = 1 if @autotiles[num].animated
end
# value3 associated with an autotile
if value3 < 384
num = 4*((value3 / 48) - 1)
data_animated[j, i] = 1 if @autotiles[num].animated
end
@map.blt(32*j, 32*i, bitmap, rect)
if $game_system.loop_x and j.between?(0, 19)
@map.blt(32*(j+$game_map.width), 32*i, bitmap, rect)
end
end







end
end
end
end
# save the map's drawing in the Cache
RPG::Cache_Carte.save(@id, @map)
@map_ground = @map.clone
# save a copy of the map to handle flat events
RPG::Cache_Carte.save(@id, @map_ground, 4)
return if !$game_system.animated
# create 3 other maps in case of animated tiles
@map_2 = @map.clone
@map_3 = @map.clone
@map_4 = @map.clone
@maps_list.push(@map_2)
@maps_list.push(@map_3)
@maps_list.push(@map_4)
for i in 0...$game_map.height
for j in 0...$game_map.width
next if data_animated[j, i].to_i == 0
# modify the tile if it is flagged as animated
value1 = data[j, i, 0].to_i
value2 = data[j, i, 1].to_i
value3 = data[j, i, 2].to_i
# prevent from drawing a vertical tile
value1 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value1]) ?
0 : value1)
value2 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value2]) ?
0 : value2)
value3 = ($terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value3]) ?
0 : value3)
if value1 != 0
if value2 == 0
if value3 == 0
num = 4*((value1 / 48) - 1)
bitmap_2 = RPG::Cache.autotile_base(num+1, value1)
bitmap_3 = RPG::Cache.autotile_base(num+2, value1)
bitmap_4 = RPG::Cache.autotile_base(num+3, value1)
@map_2.blt(32*j, 32*i, bitmap_2, rect)
@map_3.blt(32*j, 32*i, bitmap_3, rect)
@map_4.blt(32*j, 32*i, bitmap_4, rect)
if $game_system.loop_x and j.between?(0, 19)
@map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
@map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
@map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
end
else
bitmap_2 = RPG::Cache_Tile.load(value1, value3, 1)
bitmap_3 = RPG::Cache_Tile.load(value1, value3, 2)
bitmap_4 = RPG::Cache_Tile.load(value1, value3, 3)
@map_2.blt(32*j, 32*i, bitmap_2, rect)
@map_3.blt(32*j, 32*i, bitmap_3, rect)
@map_4.blt(32*j, 32*i, bitmap_4, rect)
if $game_system.loop_x and j.between?(0, 19)
@map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
@map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
@map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
end
end
else
if value3 == 0
bitmap_2 = RPG::Cache_Tile.load(value1, value2, 1)
bitmap_3 = RPG::Cache_Tile.load(value1, value2, 2)
bitmap_4 = RPG::Cache_Tile.load(value1, value2, 3)
@map_2.blt(32*j, 32*i, bitmap_2, rect)
@map_3.blt(32*j, 32*i, bitmap_3, rect)
@map_4.blt(32*j, 32*i, bitmap_4, rect)
if $game_system.loop_x and j.between?(0, 19)
@map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
@map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
@map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
end
else
bitmap_2 = RPG::Cache_Tile.load2(value1, value2, value3, 1)
bitmap_3 = RPG::Cache_Tile.load2(value1, value2, value3, 2)
bitmap_4 = RPG::Cache_Tile.load2(value1, value2, value3, 3)
@map_2.blt(32*j, 32*i, bitmap_2, rect)
@map_3.blt(32*j, 32*i, bitmap_3, rect)
@map_4.blt(32*j, 32*i, bitmap_4, rect)
if $game_system.loop_x and j.between?(0, 19)
@map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
@map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
@map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
end
end
end
else
if value2 != 0
if value3 == 0
num = 4*((value2 / 48) - 1)
bitmap_2 = RPG::Cache.autotile_base(num+1, value2)
bitmap_3 = RPG::Cache.autotile_base(num+2, value2)
bitmap_4 = RPG::Cache.autotile_base(num+3, value2)
@map_2.blt(32*j, 32*i, bitmap_2, rect)
@map_3.blt(32*j, 32*i, bitmap_3, rect)
@map_4.blt(32*j, 32*i, bitmap_4, rect)
if $game_system.loop_x and j.between?(0, 19)
@map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
@map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
@map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
end
else
bitmap_2 = RPG::Cache_Tile.load(value2, value3, 1)
bitmap_3 = RPG::Cache_Tile.load(value2, value3, 2)
bitmap_4 = RPG::Cache_Tile.load(value2, value3, 3)
@map_2.blt(32*j, 32*i, bitmap_2, rect)
@map_3.blt(32*j, 32*i, bitmap_3, rect)
@map_4.blt(32*j, 32*i, bitmap_4, rect)
if $game_system.loop_x and j.between?(0, 19)
@map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
@map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
@map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
end
end
else
if value3 != 0
num = 4*((value3 / 48) - 1)
bitmap_2 = RPG::Cache.autotile_base(num+1, value3)
bitmap_3 = RPG::Cache.autotile_base(num+2, value3)
bitmap_4 = RPG::Cache.autotile_base(num+3, value3)
@map_2.blt(32*j, 32*i, bitmap_2, rect)
@map_3.blt(32*j, 32*i, bitmap_3, rect)
@map_4.blt(32*j, 32*i, bitmap_4, rect)
if $game_system.loop_x and j.between?(0, 19)
@map_2.blt(32*(j+$game_map.width), 32*i, bitmap_2, rect)
@map_3.blt(32*(j+$game_map.width), 32*i, bitmap_3, rect)
@map_4.blt(32*(j+$game_map.width), 32*i, bitmap_4, rect)
end
end
end
end
end
end
# save the three additional maps in the Cache
RPG::Cache_Carte.save(@id, @map_2, 1)
RPG::Cache_Carte.save(@id, @map_3, 2)
RPG::Cache_Carte.save(@id, @map_4, 3)
end
#--------------------------------------------------------------------------
# * no tileset for mode7 maps
#--------------------------------------------------------------------------
def tileset
return nil
end
end
#============================================================================
# This script adds a kind of depth for the maps.
# Written by MGCaladtogel
# English version (24/04/08)
#============================================================================
# ■ Game_Map
#----------------------------------------------------------------------------
# Methods modifications to handle map looping
#============================================================================

class Game_Map
#--------------------------------------------------------------------------
# * Scroll Down
# distance : scroll distance
#--------------------------------------------------------------------------
alias scroll_down_mode7_game_map scroll_down
def scroll_down(distance)
if !$game_system.mode7
scroll_down_mode7_game_map(distance)
return
end
if $game_system.loop_y or $game_system.always_scroll
@display_y = @display_y + distance # always scroll
else
@display_y = [@display_y + distance, (self.height - 15) * 128].min
end
end
#--------------------------------------------------------------------------
# * Scroll Left
# distance : scroll distance
#--------------------------------------------------------------------------
alias scroll_left_mode7_game_map scroll_left
def scroll_left(distance)
if !$game_system.mode7
scroll_left_mode7_game_map(distance)
return
end
if $game_system.loop_x or $game_system.always_scroll
@display_x = @display_x - distance # always scroll
else
@display_x = [@display_x - distance, 0].max
end
end
#--------------------------------------------------------------------------
# * Scroll Right
# distance : scroll distance
#--------------------------------------------------------------------------
alias scroll_right_mode7_game_map scroll_right
def scroll_right(distance)
if !$game_system.mode7
scroll_right_mode7_game_map(distance)
return
end
if $game_system.loop_x or $game_system.always_scroll
@display_x = @display_x + distance # always scroll
else
@display_x = [@display_x + distance, (self.width - 20) * 128].min
end
end
#--------------------------------------------------------------------------
# * Scroll Up
# distance : scroll distance
#--------------------------------------------------------------------------
alias scroll_up_mode7_game_map scroll_up
def scroll_up(distance)
if !$game_system.mode7
scroll_up_mode7_game_map(distance)
return
end
if $game_system.loop_y or $game_system.always_scroll
@display_y = @display_y - distance # always scroll
else
@display_y = [@display_y - distance, 0].max
end
end
#--------------------------------------------------------------------------
# * Determine Valid Coordinates
# x : x-coordinate
# y : y-coordinate
# Allow the hero to go out of the map when map looping
#--------------------------------------------------------------------------
alias valid_mode7_game_map? valid?
def valid?(x, y)
if !$game_system.mode7
return (valid_mode7_game_map?(x, y))
end
if $game_system.loop_x
if $game_system.loop_y
return true
else
return (y >= 0 and y < height)
end
elsif $game_system.loop_y
return (x >= 0 and x < width)
end
return (x >= 0 and x < width and y >= 0 and y < height)
end
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8,10)
# * 0,10 = determine if all directions are impassable
# self_event : Self (If event is determined passable)
#--------------------------------------------------------------------------
alias passable_mode7_game_map? passable?
def passable?(x, y, d, self_event = nil)
if !$game_system.mode7
passable_mode7_game_map?(x, y, d, self_event)
return(passable_mode7_game_map?(x, y, d, self_event))
end
unless valid?(x, y)
return false
end
bit = (1 << (d / 2 - 1)) & 0x0f
for event in events.values
if event.tile_id >= 0 and event != self_event and
event.x == x and event.y == y and not event.through
if @passages[event.tile_id] & bit != 0
return false
elsif @passages[event.tile_id] & 0x0f == 0x0f
return false
elsif @priorities[event.tile_id] == 0
return true
end
end
end
for i in [2, 1, 0]
tile_id = data[x % width, y % height, i] # handle map looping
if tile_id == nil
return false
elsif @passages[tile_id] & bit != 0
return false
elsif @passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
end
return true
end
#--------------------------------------------------------------------------
# * Setup
# map_id : map ID
#--------------------------------------------------------------------------
alias old_setup_mode7 setup
def setup(map_id)
old_setup_mode7(map_id)
if !$game_switches[$enable_mode7_number]
$game_system.mode7 = false
$game_system.mode7 = false
$game_system.loop_x = false
$game_system.loop_y = false
$game_system.always_scroll = false
$game_system.animated = false
$game_system.white_horizon = false
$game_system.angle = 0
$game_system.fixed_panorama = false
$game_system.ov = false
$game_system.ov_zoom = 0.6
$game_system.reset
return
end
map_data = $data_maps[$game_map.map_id]
for keyword in $mode7_maps_settings.keys
if map_data.name2.include?(keyword)
command_list = $mode7_maps_settings[keyword]
$game_system.mode7 = true
$game_system.loop_x = command_list.include?("X")
$game_system.loop_y = command_list.include?("Y")
$game_system.always_scroll = command_list.include?("C")
$game_system.animated = command_list.include?("A")
$game_system.white_horizon = command_list.include?("H")
$game_system.fixed_panorama = command_list.include?("P")
$game_system.ov = command_list.include?("OV")
for command in command_list
if command.include?("#")
$game_system.angle = (command.slice(1, 2)).to_i
$game_system.angle = [[$game_system.angle, 0].max, 89].min
break
end
end
return
end
end
$game_system.mode7 = map_data.name2.include?("[M7]")
$game_system.loop_x = map_data.name2.include?("[X]")
$game_system.loop_y = map_data.name2.include?("[Y]")
$game_system.always_scroll = map_data.name2.include?("[C]")
$game_system.animated = map_data.name2.include?("[A]")
$game_system.white_horizon = map_data.name2.include?("[H]")
$game_system.fixed_panorama = map_data.name2.include?("[P]")
$game_system.ov = map_data.name2.include?("[OV]")
if $game_system.mode7
map_data.name2 =~ /\[#[ ]*([00-99]+)\]/i
$game_system.angle = $1.to_i
$game_system.angle = [[$game_system.angle, 0].max, 89].min
end
end
end

#============================================================================
# ■ Game_Character
#----------------------------------------------------------------------------
# "update" method modifications to handle map looping
#============================================================================

class Game_Character
attr_accessor :x
attr_accessor :y
attr_accessor :real_x
attr_accessor :real_y
attr_reader :flat
attr_reader :height
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias initialize_mode7_game_character initialize
def initialize
initialize_mode7_game_character
@flat = false
@height = 0.0
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
alias update_mode7_game_character update
def update
if !$game_system.mode7
update_mode7_game_character
return
end
# if x-coordinate is out of the map
if !(x.between?(0, $game_map.width - 1))
difference = 128 * x - real_x
if self.is_a?(Game_Player)
# increase or decrease map's number
self.map_number_x += difference / (difference.abs)
end
# x-coordinate is equal to its equivalent in the map
self.x %= $game_map.width
self.real_x = 128 * x - difference
end
# if y-coordinate is out of the map
if !(y.between?(0, $game_map.height - 1))
difference = 128 * y - real_y
if self.is_a?(Game_Player)
# increase or decrease map's number
self.map_number_y += difference / (difference.abs)
end
# y-coordinate is equal to its equivalent in the map
self.y %= $game_map.height
self.real_y = 128 * y - difference
end
update_mode7_game_character
end
end

#==============================================================================
# ■ Game_Event
#----------------------------------------------------------------------------
# Add methods to handle flat events and altitude for vertical event
#============================================================================

class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * scan the event's commands list
# page : the scanned page (RPG::Event::page)
#--------------------------------------------------------------------------
def check_commands(page)
@height = 0.0
command_list = page.list
for k in 0..command_list.length - 2
command = command_list[k]
if (command.parameters[0].to_s).include?("Height")
@height = (command.parameters[0][7,command.parameters[0].length-1]).to_f
end
@flat = (command.parameters[0].to_s).include?("Flat")
end
end
#--------------------------------------------------------------------------
# * scan the event's commands list of the current page when refreshed
#--------------------------------------------------------------------------
alias refresh_mode7_game_character refresh
def refresh
refresh_mode7_game_character
check_commands(@page) if @page != nil
end
end

#============================================================================
# ■ Game_Player
#----------------------------------------------------------------------------
# Add attributes to have a well-working panorama's scrolling
#============================================================================

class Game_Player < Game_Character
attr_accessor :map_number_x # map's number with X-looping
attr_accessor :map_number_y # map's number with Y-looping
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias initialize_mode7_game_player initialize
def initialize
initialize_mode7_game_player
self.map_number_x = 0
self.map_number_y = 0
end
#--------------------------------------------------------------------------
# * Handle the option : center around the hero
#--------------------------------------------------------------------------
alias center_mode7_game_player center
def center(x, y)
if !$game_system.loop_y and !$game_system.always_scroll#!$game_system.mode7
center_mode7_game_player(x, y)
return
end
$game_map.display_x = x * 128 - CENTER_X
$game_map.display_y = y * 128 - CENTER_Y
end
end

#============================================================================
# ■ Sprite
#----------------------------------------------------------------------------
# Add attributes to work efficiently with scanlines sprites
#============================================================================

class Sprite
attr_accessor :y_origin_bitmap # bitmap's y-coordinate for the "src_rect.set"
#method (float)
attr_accessor :x_origin_bitmap # bitmap's x-coordinate for the "src_rect.set"
#method (float)
attr_accessor :y_origin_bitmap_i # bitmap's y-coordinate for the
#"src_rect.set" method (integer)
attr_accessor :x_origin_bitmap_i # bitmap's x-coordinate for the
#"src_rect.set" method (integer)
attr_accessor :length # sprite's width
end

#============================================================================
# ■ Sprite_Character
#----------------------------------------------------------------------------
# Calculate x-coordinate and y-coordinate for a mode7 map
#============================================================================

class Sprite_Character < RPG::Sprite
attr_reader :flat_indicator # true if the event is flat-drawn
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias initialize_mode7_sprite_character initialize
def initialize(viewport, character = nil)
@flat_indicator = false
initialize_mode7_sprite_character(viewport, character)
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
alias update_mode7_sprite_character update
def update
if !$game_system.mode7
update_mode7_sprite_character
return

end
if @flat_indicator
if ([email protected] or @character.moving? or

@tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue)
@flat_indicator = @character.flat
# redraw the original ground
maps_list = $scene.spriteset.tilemap.maps_list
map_ground = $scene.spriteset.tilemap.map_ground
rect = Rect.new(@flat_x_map, @flat_y_map, @flat_width, @flat_height)
for map in maps_list
map.blt(@flat_x_map, @flat_y_map, map_ground, rect)
if $game_system.loop_x and @flat_x_map.between?(0, 19 * 32)
map.blt(@flat_x_map + 32 * $game_map.width, @flat_y_map, map_ground,
rect)
end
end
else
return
end
end
super
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
# pivot correction (intersection between the map and this sprite)
self.oy -= 4
end
end
self.visible = (not @character.transparent)
if @tile_id == 0
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
if @character.flat # event must be flat drawn
return if $scene.spriteset == nil
if @tile_id == 0
@flat_x_map = @character.real_x / 4 - (@cw - 32) / 2
@flat_y_map = @character.real_y / 4 - @ch + 32
@flat_x0 = sx
@flat_y0 = sy
@flat_width = @cw
@flat_height = @ch
else
@flat_x_map = @character.real_x / 4
@flat_y_map = @character.real_y / 4
@flat_x0 = 0
@flat_y0 = 0
@flat_width = 32
@flat_height = 32
end
# modify the maps graphics
maps_list = $scene.spriteset.tilemap.maps_list
rect = Rect.new(@flat_x0, @flat_y0, @flat_width, @flat_height)
for map in maps_list
map.blt(@flat_x_map, @flat_y_map, bitmap, rect, @character.opacity)
if $game_system.loop_x and @flat_x_map.between?(0, 19 * 32)
map.blt(@flat_x_map + 32 * $game_map.width, @flat_y_map, bitmap, rect,
@character.opacity)
end
end
@flat_indicator = true
self.opacity = 0
return
end
x_intermediate = @character.screen_x
y_intermediate = @character.screen_y
y_intermediate -= $game_temp.pivot + 4 if $game_system.mode7
# if vertical looping
if $game_system.loop_y
h = 32 * $game_map.height
y_intermediate = (y_intermediate + h / 2) % h - h / 2
end
# coordinates in a mode7 map
self.y = (($game_temp.distance_h * y_intermediate *
$game_temp.cos_angle).to_f / ($game_temp.distance_h - y_intermediate *
$game_temp.sin_angle) + $game_temp.pivot)
self.zoom_x = $game_temp.slope_value * y + $game_temp.corrective_value
self.zoom_y = zoom_x
self.x = 320 + zoom_x * (x_intermediate - 320)
# if horizontal looping
if $game_system.loop_x
offset = ($game_map.width >= 24 ? 64 * zoom_x : 0)
l = 32 * $game_map.width * zoom_x
self.x = (x + offset) % l - offset
end
if @character.is_a?(Game_Player)
# Overworld Sprite Resize
if $game_system.ov
self.zoom_x *= $game_system.ov_zoom
self.zoom_y *= $game_system.ov_zoom
end
end
self.z = @character.screen_z(@ch)
# hide the sprite if it is beyond the horizon's line
self.opacity = (y < $game_temp.height_limit ? 0 : @character.opacity)
self.y -= 32 * @character.height * zoom_y # height correction
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
end
end

#============================================================================
# ■ Sprite_V (Vertical Sprites)
#----------------------------------------------------------------------------
# Sprites corresponding to the vertical elements formed by tiles
#============================================================================

class Sprite_V < Sprite
attr_accessor :x_map # sprite's x_coordinates (in squares) (Float)
attr_accessor :y_map # sprite's y_coordinates (in squares) (Float)
attr_accessor :square_y # sprite's y_coordinates (in squares) (Integer)
attr_accessor :priority # sprite's priority
attr_accessor :animated # True if animated
attr_accessor :list_bitmap # list of sprite's bitmaps (Bitmap)
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
square_y_corrected = square_y
y_intermediate = 32 * y_map - $game_temp.pivot - $game_map.display_y / 4
y_intermediate_reference = y_intermediate
# if vertical looping
if $game_system.loop_y
y_intermediate = (y_intermediate + $game_temp.height / 2) %
$game_temp.height - $game_temp.height / 2
if y_intermediate_reference < y_intermediate
square_y_corrected = square_y + $game_map.height
elsif y_intermediate_reference > y_intermediate
square_y_corrected = square_y - $game_map.height
end
end
self.y = ($game_temp.distance_h * y_intermediate *
$game_temp.cos_angle).to_f / ($game_temp.distance_h - y_intermediate *
$game_temp.sin_angle) + $game_temp.pivot
if y < $game_temp.height_limit
# hide the sprite if it is beyond the horizon's line
self.opacity = 0
return
end
self.opacity = 255
if $scene.spriteset != nil and $scene.spriteset.tilemap.is_a?(Tilemap_mode7)
opacity_values = $scene.spriteset.tilemap.opacity_values
tone_values = $scene.spriteset.tilemap.tone_values
if opacity_values.has_key?(y)
self.opacity = opacity_values[y]
self.tone = tone_values[y]
end
end
self.zoom_x = $game_temp.slope_value * y + $game_temp.corrective_value
self.zoom_y = zoom_x
x_intermediate = 32 * x_map - $game_map.display_x / 4
self.x = 320 + (zoom_x * (x_intermediate - 320))
# if horizontal looping
if $game_system.loop_x
offset = ($game_map.width >= 24 ? 64 * zoom_x : 0)
l = 32 * $game_map.width * self.zoom_x
self.x = (self.x + offset) % l - offset
end
self.z = (128 * square_y_corrected - $game_map.display_y + 3) / 4 +
32 + 32 * priority
return
end
#--------------------------------------------------------------------------
# * Update bitmap for animation
# index : 0..3 : animation's index
#--------------------------------------------------------------------------
def update_animated(index)
self.bitmap = @list_bitmap[index]
end
end

#============================================================================
# ■ Spriteset_Map
#----------------------------------------------------------------------------
# Modifications to call a mode7 map
#============================================================================

class Spriteset_Map
attr_accessor :tilemap # just to be able to access the tilemap
#--------------------------------------------------------------------------
# * Initialize Object
# Rewritten to call a map with mode7
#--------------------------------------------------------------------------
alias initialize_mode7_spriteset_map initialize
def initialize
if !$game_system.mode7
initialize_mode7_spriteset_map
return
end
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 200
@viewport3.z = 5000
# mode7 map
@tilemap = Tilemap_mode7.new(@viewport1, self)
@panorama = Plane.new(@viewport1)
# sprites drawn at the horizon's level have a negative z, and with a z value
# of -100000 the panorama is still below
@panorama.z = ($game_system.mode7 ? -100000 : -1000)
@fog = Plane.new(@viewport1)
@fog.z = 3000
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
@weather = RPG::Weather.new(@viewport1)
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures))
end
@timer_sprite = Sprite_Timer.new
update
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
if @tilemap.tileset != nil
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles.dispose
end
end
@tilemap.dispose
@panorama.dispose
@fog.dispose
for sprite in @character_sprites
sprite.dispose
end
@weather.dispose
for sprite in @picture_sprites
sprite.dispose
end
@timer_sprite.dispose
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
alias update_mode7_spriteset_map update
def update
if !$game_system.mode7
update_mode7_spriteset_map
return
end
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @panorama.bitmap != nil
@panorama.bitmap.dispose
@panorama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
end
Graphics.frame_reset
end
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
# update animated tiles each 20 frames
if Graphics.frame_count % 20 == 0 and $game_system.animated
@tilemap.update_animated
end
@tilemap.update
# if the panorama is fixed
if $game_system.fixed_panorama
@panorama.ox = 0
@panorama.oy = 0
# if it is a mode7 map
else
# to have a fluent panorama scrolling
@panorama.ox = (128 * $game_map.width * $game_player.map_number_x +
$game_player.real_x) / 8
@panorama.oy = - (128 * $game_map.height * $game_player.map_number_y +
$game_player.real_y) / 32
end
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
@fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
@fog.tone = $game_map.fog_tone
for sprite in @character_sprites
sprite.update
end
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.ox = $game_map.display_x / 4
@weather.oy = $game_map.display_y / 4
@weather.update
for sprite in @picture_sprites
sprite.update
end
@timer_sprite.update
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
@viewport3.color = $game_screen.flash_color
@viewport1.update
@viewport3.update
end
end
#============================================================================
# This script adds a kind of depth for the maps.
# Written by MGCaladtogel
# English version (24/04/08)
#==============================================================================
# ■ Game_Switches
#==============================================================================
class Game_Switches
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias initialize_mode7_game_player initialize
def initialize
initialize_mode7_game_player
self[$enable_mode7_number] = true
end
end

#============================================================================
# ■ Scene_Map
#============================================================================
class Scene_Map
attr_accessor :spriteset # just need to access the spriteset
end

#============================================================================
# ■ Data_Autotiles
#----------------------------------------------------------------------------
# Creates the set of tiles from an autotile's file
#============================================================================

class Data_Autotiles < Bitmap
# data list to form tiles from an atotiles file
Data_creation = [[27,28,33,34],[5,28,33,34],[27,6,33,34],[5,6,33,34],
[27,28,33,12],[5,28,33,12],[27,6,33,12],[5,6,33,12],[27,28,11,34],
[5,28,11,34],[27,6,11,34],[5,6,11,34],[27,28,11,12],[5,28,11,12],
[27,6,11,12],[5,6,11,12],[25,26,31,32],[25,6,31,32],[25,26,31,12],
[25,6,31,12],[15,16,21,22],[15,16,21,12],[15,16,11,22],[15,16,11,12],
[29,30,35,36],[29,30,11,36],[5,30,35,36],[5,30,11,36],[39,40,45,46],
[5,40,45,46],[39,6,45,46],[5,6,45,46],[25,30,31,36],[15,16,45,46],
[13,14,19,20],[13,14,19,12],[17,18,23,24],[17,18,11,24],[41,42,47,48],
[5,42,47,48],[37,38,43,44],[37,6,43,44],[13,18,19,24],[13,14,43,44],
[37,42,43,48],[17,18,47,48],[13,18,43,48],[13,18,43,48]]
attr_accessor :number # autotile's number to identify it
attr_accessor :animated # TRUE if the autotile is animated
#--------------------------------------------------------------------------
# * Initialize Object
# file : autotiles file's bitmap (Bitmap)
# l : 0..3 : pattern's number for animated autotiles
#--------------------------------------------------------------------------
def initialize(file, l)
super(8*32, 6*32)
create(file, l)
end
#--------------------------------------------------------------------------
# * Create the tiles set
# file : autotiles file's bitmap (Bitmap)
# l : 0..3 : pattern's number for animated autotiles
#--------------------------------------------------------------------------
def create(file, l)
l = (file.width > 96 ? l : 0)
self.animated = (file.width > 96)
for i in 0..5
for j in 0..7
data = Data_creation[8 * i + j]
for number in data
number -= 1
m = 16 * (number % 6)
n = 16 * (number / 6)
blt(32 * j + m % 32, 32 * i + n % 32, file,
Rect.new(m + 96 * l, n, 16, 16))
end
end
end
end
end

#============================================================================
# ■ Data_Vertical_Sprites
#----------------------------------------------------------------------------
# Create a list of vertical sprites for the three layers of a map
# "V" for "Vertical" in the script
# "num" for "number"
#============================================================================

class Data_Vertical_Sprites
attr_accessor :list_sprites_V # list of vertical sprites
attr_accessor :list_sprites_V_animated # list of animated vertical sprites
#--------------------------------------------------------------------------
# * A little method to compare terrain_tags
# value : tile's ID
# num : reference terrain_tag's value
#--------------------------------------------------------------------------
def suitable?(value, num)
return ($game_map.terrain_tags[value] == num)
end
#--------------------------------------------------------------------------
# * This algorithm scans each layer and create a sprites formed by tiles
# in contact
# viewport : Viewport
#--------------------------------------------------------------------------
def initialize(viewport)
@viewport = viewport
# lists initialization
self.list_sprites_V = []
self.list_sprites_V_animated = []
# @num_tiles : list of tiles coordinates that form a vertical sprite
@num_tiles = []
# create copy of map's data
@dataV = ($game_map.data).clone
# scan each layer
for h in 0..2
# scan each row
for i in 0..$game_map.height
# scan each column
for j in 0..$game_map.width
value = @dataV[j, i, h].to_i
# if tile's terrain tag is declared to give vertical sprites
if $terrain_tags_vertical_tiles.include?($game_map.terrain_tags[value])
@reference_terrain_tag = $game_map.terrain_tags[value]
@num_tiles.push([j, i])
# the following algorithm is so complex that I really don't know how
# it works exactly
list_end = 0
length = 0
while j + length + 1 < $game_map.width and
suitable?(@dataV[j +length+ 1, i, h].to_i, @reference_terrain_tag)
@num_tiles.push([j + length+ 1,i])
length += 1
end
list_start = j
list_end = length + j
indicator = true
row = 0
j2 = j
while indicator
row += 1
break if (i + row) == $game_map.height
list_start2 = j2
length2 = 0
indicator = false
if length >= 2
for k in (j2 + 1)..(j2 + length -1)
if suitable?(@dataV[k, i + row, h].to_i,
@reference_terrain_tag)
if !indicator
list_start2 = k
else
length2 = k - list_start2
end
indicator = true
@num_tiles.push([k, i + row])
elsif !indicator
length2 -= 1
end
end
end
if suitable?(@dataV[j2 + length, i + row, h].to_i,
@reference_terrain_tag)
length2 = j2 + length - list_start2
indicator = true
@num_tiles.push([j2 + length, i + row])
length3 = 1
while j2 + length + length3 < $game_map.width and
suitable?(@dataV[j2 + length + length3, i + row, h].to_i,
@reference_terrain_tag)
@num_tiles.push([j2 + length + length3, i + row])
length3 += 1
length2 += 1
if j2 + length + length3 > list_end
list_end = j2 + length + length3
end
end
end
if suitable?(@dataV[j2, i + row, h].to_i, @reference_terrain_tag)
list_start3 = list_start2 - j2
length2 = length2 + list_start3
list_start2 = j2
indicator = true
@num_tiles.push([j2, i + row])
length3 = 1
while j2 - length3 >= 0 and
suitable?(@dataV[j2 - length3, i + row, h].to_i,
@reference_terrain_tag)
@num_tiles.push([j2 - length3, i + row])
length3 += 1
length2 += 1
list_start2 -= 1
if list_start2 < list_start
list_start = list_start2
end
end
end
length = length2
j2 = list_start2
end
row -= 1

# create a bitmap and a sprite from the tiles listed in @num_tiles
create_bitmap(i, list_start, row, list_end - list_start, h)
# clear the used tiles
clear_data(h)
# reinitialize the list of tiles
@num_tiles = []
end
end
end
end
end
#--------------------------------------------------------------------------
# * Clear the used data to prevent from reusing them
# layer : current scanned layer
#--------------------------------------------------------------------------
def clear_data(layer)
for num in @num_tiles
@dataV[num[0], num[1], layer] = 0
end
end
#--------------------------------------------------------------------------
# * Create a Bitmap from the listed tiles in @num_tiles and its associated
# sprite (Sprite_V)
# row : start row's value
# column : start column's value
# height : sprite's height (in tiles)
# width : sprite's width (in tiles)
# layer : current scanned layer
#--------------------------------------------------------------------------
def create_bitmap(row, column, height, width, layer)
bmp = Bitmap.new(32*(1+width), 32*(1+height))
rect = Rect.new(0, 0, 32, 32)
@num_tiles.sort! {|a, b| -(a[1] - b[1])}
sprite = Sprite_V.new(@viewport)
# initialize sprite's attributes
sprite.animated = false
sprite.list_bitmap = []
# draw the bitmap
for tile_coordinates in @num_tiles
value = @dataV[tile_coordinates[0], tile_coordinates[1], layer].to_i
# if tile is a normal tile
if value > 383
bitmap = RPG::Cache.tile($game_map.tileset_name, value, 0)
else # tile is an autotile
file = (value / 48) - 1
num_file = 4 * file
if !sprite.animated
autotile_name = $game_map.autotile_names[file]
fichier = RPG::Cache.autotile(autotile_name)
sprite.animated = (fichier.width > 96 ? true : false)
end
bitmap = RPG::Cache.autotile_base(num_file, value)
end
bmp.blt(32 * (tile_coordinates[0] - column),
32 * (tile_coordinates[1] - row), bitmap, rect)
end
sprite.list_bitmap.push(bmp)
# create 3 additionnal bitmaps for animated sprites
if sprite.animated
for j in 1..3
bmp = Bitmap.new(32 * (1 + width), 32 * (1 + height))
for tile_coordinates in @num_tiles
value = @dataV[tile_coordinates[0], tile_coordinates[1], layer].to_i
if value > 383
bitmap = RPG::Cache.tile($game_map.tileset_name, value, 0)
else
num_file = 4 * ((value / 48) - 1)
bitmap = RPG::Cache.autotile_base(num_file + j, value)
end
bmp.blt(32 * (tile_coordinates[0] - column),
32 * (tile_coordinates[1] - row), bitmap, rect)
end
sprite.list_bitmap.push(bmp)
end
end
value = @dataV[@num_tiles[0][0], @num_tiles[0][1], layer].to_i
# set sprite's priority
sprite.priority = $game_map.priorities[value]
# set sprite's coordinates (in squares (32 * 32 pixels))
sprite.x_map = (column.to_f) + bmp.width / 64
sprite.x_map += 0.5 if width % 2 == 0
sprite.y_map = (row + height).to_f + 0.5
sprite.square_y = sprite.y_map.to_i # Integer
# set the y_pivot (intersection between the map and the sprite)
sprite.oy = bmp.height - 16
sprite.ox = bmp.width / 2
sprite.bitmap = sprite.list_bitmap[0]
self.list_sprites_V.push(sprite)
self.list_sprites_V_animated.push(sprite) if sprite.animated
end
end

#============================================================================
# ■ RPG::Cache_Tile
#----------------------------------------------------------------------------
# The tiles resulting in a superimposing of several tiles are kept in memory
# for a faster call
# valueX : tile's ID
#============================================================================

module RPG
module Cache_Tile
@cache = {}
#------------------------------------------------------------------------
# * Superimposing of two tiles, offset = pattern's number for animated
# autotiles
#------------------------------------------------------------------------
def self.load(value1, value2, offset=0)
if not @cache.include?([value1, value2, offset])
bitmap = Bitmap.new(32, 32)
rect = Rect.new(0, 0, 32, 32)
if value1 > 383 # normal tile
bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value1, 0),
rect)
else # autotile
num = 4*((value1 / 48) - 1) + offset
bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value1), rect)
end
if value2 > 383 # normal tile
bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value2, 0),
rect)
else # autotile
num = 4*((value2 / 48) - 1) + offset
bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value2), rect)
end
@cache[[value1, value2, offset]] = bitmap
end
@cache[[value1, value2, offset]]
end
#------------------------------------------------------------------------
# * Superimposing of three tiles
#------------------------------------------------------------------------
def self.load2(value1, value2, value3, offset = 0)
if not @cache.include?([value1, value2, value3, offset])
bitmap = Bitmap.new(32, 32)
rect = Rect.new(0, 0, 32, 32)
if value1 > 383 # normal tile
bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value1, 0),
rect)
else # autotile
num = 4*((value1 / 48) - 1) + offset
bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value1), rect)
end
if value2 > 383 # normal tile
bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value2, 0),
rect)
else # autotile
num = 4*((value2 / 48) - 1) + offset
bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value2), rect)
end
if value3 > 383 # normal tile
bitmap.blt(0, 0, RPG::Cache.tile($game_map.tileset_name, value3, 0),
rect)
else # autotile
num = 4*((value3 / 48) - 1) + offset
bitmap.blt(0, 0, RPG::Cache.autotile_base(num, value3), rect)
end
@cache[[value1, value2, value3, offset]] = bitmap
end
@cache[[value1, value2, value3, offset]]
end
#------------------------------------------------------------------------
# * Clear the Cache
#------------------------------------------------------------------------
def self.clear
@cache = {}
GC.start
end
end
end

#============================================================================
# ■ RPG::Cache_Carte
#----------------------------------------------------------------------------
# Maps drawn with mode7 are kept in memory to have a faster call the next
# times they need to be drawn
#============================================================================

module RPG
module Cache_Carte
@cache = {}
#------------------------------------------------------------------------
# * Check if the map is in the Cache
# map_id : map's ID
#------------------------------------------------------------------------
def self.in_cache(map_id)
return @cache.include?(map_id)
end
#------------------------------------------------------------------------
# * Return the map's drawing (Bitmap)
# map_id : map's ID
# num : pattern's number for animated autotiles
#------------------------------------------------------------------------
def self.load(map_id, num = 0)
return @cache[map_id][num]
end
#------------------------------------------------------------------------
# * Save the map's drawing in the Cache
# map_id : map's ID
# bitmap : map's drawing (Bitmap)
# num : pattern's number for animated autotiles
#------------------------------------------------------------------------
def self.save(map_id, bitmap, num = 0)
@cache[map_id] = [] if !self.in_cache(map_id)
@cache[map_id][num] = bitmap
end
#------------------------------------------------------------------------
# * Clear the Cache
#------------------------------------------------------------------------
def self.clear
@cache = {}
GC.start
end
end
end

#============================================================================
# ■ RPG::Cache
#----------------------------------------------------------------------------
# The tiles from autotiles files are kept in memory for a faster call
#============================================================================

module RPG
module Cache
#------------------------------------------------------------------------
# * Check if the map is in the Cache
# num : autotiles file's ID
# value : tile's ID
#------------------------------------------------------------------------
def self.autotile_base(num, value)
key = [num, value]
if not @cache.include?(key) or @cache[key].disposed?
@cache[key] = Bitmap.new(32, 32)
num_tile = value % 48
sx = 32 * (num_tile % 8)
sy = 32 * (num_tile / 8)
rect = Rect.new(sx, sy, 32, 32)
@cache[key].blt(0, 0, self.load_autotile(num), rect)
end
@cache[key]
end
#------------------------------------------------------------------------
# * Save the tile's drawing in the Cache
# bitmap : tile's drawing (Bitmap)
# key : tile's ID
#------------------------------------------------------------------------
def self.save_autotile(bitmap, key)
@cache[key] = bitmap
end
#------------------------------------------------------------------------
# * Return the tile's drawing (Bitmap)
# key : tile's ID
#------------------------------------------------------------------------
def self.load_autotile(key)
@cache[key]
end
end
end

#============================================================================
# ■ RPG::MapInfo
#============================================================================

class RPG::MapInfo
# defines the map's name as the name without anything within brackets,
# including brackets
def name
return @name.gsub(/\[.*\]/) {""}
end
#--------------------------------------------------------------------------
# the original name with the codes
def name2
return @name
end
end

#============================================================================
# ■ Game_Temp
#----------------------------------------------------------------------------
# Add attributes to this class / Avoid using too many global variables
#============================================================================

class Game_Temp
attr_accessor :pivot # screenline's number of the slant's pivot
attr_accessor :cos_angle # cosinus of the slant's angle
attr_accessor :sin_angle # sinus of the slant's angle
attr_accessor :height_limit # horizon's line
attr_accessor :distance_h # distance between the map's center and the vanishing point
attr_accessor :slope_value # intermediate value
attr_accessor :corrective_value # intermediate value
attr_accessor :height # map's height (in pixel)
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias initialize_mode7_game_temp initialize
def initialize
initialize_mode7_game_temp
self.pivot = 0
self.cos_angle = 0.0
self.sin_angle = 0.0
self.height_limit = 0
self.distance_h = 0
self.slope_value = 0.0
self.corrective_value = 0.0
self.height = 0
end
end
 
Mensajes
249
Reacciones
0
Puntos
0
Ubicación
me muevo
Script de batalla estilo Final Fantasy Tactics para VX

Autor: GubiD
Función: permite hacer un sistema de combate táctica
Imagen:
gtbs.png

Recursos: ninguno
Demo: Demo (0.98 Mb; Archivo comprimido)
Observación: sometido a un test y funcional. Demo y explicaciones en inglés.
Número de scripts: 38
Instalación: Copiar los scripts del demo así como los elementos gráficos en tu proyecto.
Utilización: las explicaciones estan en el script nombrado "GTBS_General Help". Explicación en inglés
 

haroldx

Iconic User
Mensajes
181
Reacciones
0
Puntos
555
Ubicación
Estoy en tu mente...
Un script me gusto, es pra el rpg maker vx..


Tu Equipo Te Sigue

Código:
class Game_Player
   
   #--------------------------------------------------------------------------
   
   # * Move Down
   
   # turn_enabled : a flag permits direction change on that spot
   
   #--------------------------------------------------------------------------
   
   def move_down(turn_enabled = true)
     
     super(turn_enabled)
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Left
   
   # turn_enabled : a flag permits direction change on that spot
   
   #--------------------------------------------------------------------------
   
   def move_left(turn_enabled = true)
     
     super(turn_enabled)
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Right
   
   # turn_enabled : a flag permits direction change on that spot
   
   #--------------------------------------------------------------------------
   
   def move_right(turn_enabled = true)
     
     super(turn_enabled)
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move up
   
   # turn_enabled : a flag permits direction change on that spot
   
   #--------------------------------------------------------------------------
   
   def move_up(turn_enabled = true)
     
     super(turn_enabled)
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Lower Left
   
   #--------------------------------------------------------------------------
   
   def move_lower_left
     
     super
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Lower Right
   
   #--------------------------------------------------------------------------
   
   def move_lower_right
     
     super
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Upper Left
   
   #--------------------------------------------------------------------------
   
   def move_upper_left
     
     super
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Upper Right
   
   #--------------------------------------------------------------------------
   
   def move_upper_right
     
     super
     
   end
   
end



class Game_Follower < Game_Character
   
   #--------------------------------------------------------------------------
   
   # * Public Instance Variables
   
   #--------------------------------------------------------------------------
   
   attr_reader :actor
   
   attr_accessor :move_speed
   
   #--------------------------------------------------------------------------
   
   # * Object Initialization
   
   #--------------------------------------------------------------------------
   
   def initialize(actor)
     
     super()
     
     @through = true
     
     @actor = actor
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Set Actor
   
   #--------------------------------------------------------------------------
   
   def actor=(actor)
     
     @actor = actor
     
     setup
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Setup
   
   #--------------------------------------------------------------------------
   
   def setup
     
     if @actor != nil
       
       @character_name = $game_actors[@actor].character_name
       
       @character_index = $game_actors[@actor].character_index
       
     else
       
       @character_name = ""
       
       @character_index = 0
       
     end
     
     @opacity = 255
     
     @blend_type = 0
     
     @priority_type = 0
     
   end
   
   
   
   #--------------------------------------------------------------------------
   
   # * Screen Z
   
   #--------------------------------------------------------------------------
   
   def screen_z
     
     if $game_player.x == @x and $game_player.y == @y
       
       return $game_player.screen_z - 1
       
     end
     
     super
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Same Position Starting Determinant (Disabled)
   
   #--------------------------------------------------------------------------
   
   def check_event_trigger_here(triggers)
     
     result = false
     
     return result
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Front Envent Starting Determinant (Disabled)
   
   #--------------------------------------------------------------------------
   
   def check_event_trigger_there(triggers)
     
     result = false
     
     return result
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Touch Event Starting Determinant (Disabled)
   
   #--------------------------------------------------------------------------
   
   def check_event_trigger_touch(x, y)
     
     result = false
     
     return result
     
   end
   
end



class Spriteset_Map
   
   alias_method :spriteset_map_create_characters, :create_characters
   
   def create_characters
     
     spriteset_map_create_characters
     
     $game_party.followers.each do |char|
     
     @character_sprites << Sprite_Character.new(@viewport1, char)
     
   end
   
end

end



class Game_Party
   
   #--------------------------------------------------------------------------
   
   # * Constants
   
   #--------------------------------------------------------------------------
   
   MAX_SIZE = 8
   
   CATERPILLAR = 2
   
   #--------------------------------------------------------------------------
   
   # * Public Instance Variables
   
   #--------------------------------------------------------------------------
   
   attr_reader :followers
   
   #--------------------------------------------------------------------------
   
   # * Object Initialization
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_party_initialize, :initialize
   
   def initialize
     
     trick_caterpillar_party_initialize
     
     @followers = Array.new(MAX_SIZE - 1) {Game_Follower.new(nil)}
     
     @move_list = []
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Update Followers
   
   #--------------------------------------------------------------------------
   
   def update_followers
     
     flag = $game_player.transparent || $game_switches[CATERPILLAR]
     
     @followers.each_with_index do |char, i|
     
     char.actor = @actors[i + 1]
     
     char.move_speed = $game_player.move_speed
     
     if $game_player.dash?
       
       char.move_speed += 1
       
     end
     
     char.update
     
     char.transparent = flag
     
   end
   
end

#--------------------------------------------------------------------------

# * Move To Party

#--------------------------------------------------------------------------

def moveto_party(x, y)
   
   @followers.each {|char| char.moveto(x, y)}
   
   @move_list.clear
   
end

#--------------------------------------------------------------------------

# * Move Party

#--------------------------------------------------------------------------

def move_party
   
   @move_list.each_index do |i|
   
   if @followers[i] == nil
     
     @move_list[i...@move_list.size] = nil
     
     next
     
   end
   
   case @move_list[i].type
     
   when 2
     
     @followers[i].move_down(*@move_list[i].args)
     
   when 4
     
     @followers[i].move_left(*@move_list[i].args)
     
   when 6
     
     @followers[i].move_right(*@move_list[i].args)
     
   when 8
     
     @followers[i].move_up(*@move_list[i].args)
     
   when j
     
     @followers[i].move_lower_left
     
   when 3
     
     @followers[i].move_lower_right
     
   when 7
     
     @followers[i].move_upper_left
     
   when 9
     
     @followers[i].move_upper_right
     
   when 5
     
     @followers[i].jump(*@move_list[i].args)
     
   end
   
end

end

#--------------------------------------------------------------------------

# * Add Move List

#--------------------------------------------------------------------------

def update_move(type, *args)
   
   move_party
   
   @move_list.unshift(Game_MoveListElement.new(type, args))
   
end

end



class Game_MoveListElement
   
   #--------------------------------------------------------------------------
   
   # * Object Initialization
   
   #--------------------------------------------------------------------------
   
   def initialize(type, args)
     
     @type = type
     
     @args = args
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Type
   
   #--------------------------------------------------------------------------
   
   def type
     
     return @type
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Args
   
   #--------------------------------------------------------------------------
   
   def args
     
     return @args
     
   end
   
end



class Game_Player
   
   #--------------------------------------------------------------------------
   
   # * Public Instance Variables
   
   #--------------------------------------------------------------------------
   
   attr_reader :move_speed
   
   
   
   #--------------------------------------------------------------------------
   
   # * Update
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_update, :update
   
   def update
     
     $game_party.update_followers
     
     trick_caterpillar_player_update
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Moveto
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_moveto, :moveto
   
   def moveto(x, y)
     
     $game_party.moveto_party(x, y)
     
     trick_caterpillar_player_moveto(x, y)
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Down
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_move_down, :move_down
   
   def move_down(turn_enabled = true)
     
     if passable?(@x, @y+1)
       
       $game_party.update_move(2, turn_enabled)
       
     end
     
     trick_caterpillar_player_move_down(turn_enabled)
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Left
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_move_left, :move_left
   
   def move_left(turn_enabled = true)
     
     if passable?(@x-1, @y)
       
       $game_party.update_move(4, turn_enabled)
       
     end
     
     trick_caterpillar_player_move_left(turn_enabled)
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Right
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_move_right, :move_right
   
   def move_right(turn_enabled = true)
     
     if passable?(@x+1, @y)
       
       $game_party.update_move(6, turn_enabled)
       
     end
     
     trick_caterpillar_player_move_right(turn_enabled)
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Up
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_move_up, :move_up
   
   def move_up(turn_enabled = true)
     
     if passable?(@x, @y-1)
       
       $game_party.update_move(8, turn_enabled)
       
     end
     
     trick_caterpillar_player_move_up(turn_enabled)
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Lower Left
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_move_lower_left, :move_lower_left
   
   def move_lower_left
     
     if passable?(@x - 1, @y) and passable?(@x, @y + 1)
       
       $game_party.update_move(1)
       
     end
     
     trick_caterpillar_player_move_lower_left
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Lower Right
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_move_lower_right, :move_lower_right
   
   def move_lower_right
     
     if passable?(@x + 1, @y) and passable?(@x, @y + 1)
       
       $game_party.update_move(3)
       
     end
     
     trick_caterpillar_player_move_lower_right
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Upper Left
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_move_upper_left, :move_upper_left
   
   def move_upper_left
     
     if passable?(@x - 1, @y) and passable?(@x, @y - 1)
       
       $game_party.update_move(7)
       
     end
     
     trick_caterpillar_player_move_upper_left
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Move Upper Right
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_move_upper_right, :move_upper_right
   
   def move_upper_right
     
     if passable?(@x + 1, @y) and passable?(@x, @y - 1)
       
       $game_party.update_move(9)
       
     end
     
     trick_caterpillar_player_move_upper_right
     
   end
   
   #--------------------------------------------------------------------------
   
   # * Jump
   
   #--------------------------------------------------------------------------
   
   alias_method :trick_caterpillar_player_jump, :jump
   
   def jump(x_plus, y_plus)
     
     new_x = @x + x_plus
     
     new_y = @y + y_plus
     
     if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y)
       
       $game_party.update_move(5, x_plus, y_plus)
       
     end
     
     trick_caterpillar_player_jump(x_plus, y_plus)
     
   end
   
end
 
Última edición:
Mensajes
249
Reacciones
0
Puntos
0
Ubicación
me muevo
Oigan, el post de Fernando Escurra el script no está en spoiler, y de la mitad del script hacia abajo se ve toda la pantalla en blanco, porfavor que Fernando o algún mod lo edite o en su defecto lo borre.

De antemano gracias.
 
Mensajes
181
Reacciones
0
Puntos
0
Ubicación
en mi casa xD
BATALLA LATERAL(FUNCIONA!)
VERSION:
XP

DESCRIPCION:
no necesita una

DEMO:
no es una demo

CREDITOS:
no se quien lo creo

IMAGENES:
INSTRUCCIONES:
crea una nueva clase de script llamada Side View Battle y pone este codigo:
Código:
class Bitmap
if not method_defined?('original_draw_text')
alias original_draw_text draw_text
def draw_text(*arg)

   original_color = self.font.color.dup
   self.font.color = Color.new(0, 0, 0, 128)

   if arg[0].is_a?(Rect)
     arg[0].x += 2
     arg[0].y += 2
     self.original_draw_text(*arg)
     arg[0].x -= 2
     arg[0].y -= 2
   else
     arg[0] += 2
     arg[1] += 2
     self.original_draw_text(*arg)
     arg[0] -= 2
     arg[1] -= 2
   end

   self.font.color = original_color
   self.original_draw_text(*arg)

end
end
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
   for i in x...x + width
     red   = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
     green = color1.green +
             (color2.green - color1.green) * (i - x) / (width - 1)
     blue  = color1.blue +
             (color2.blue - color1.blue) * (i - x) / (width - 1)
     alpha = color1.alpha +
             (color2.alpha - color1.alpha) * (i - x) / (width - 1)
     color = Color.new(red, green, blue, alpha)
     fill_rect(i, y, 1, height, color)
   end
elsif align == 1
   for i in y...y + height
     red   = color1.red +
             (color2.red - color1.red) * (i - y) / (height - 1)
     green = color1.green +
             (color2.green - color1.green) * (i - y) / (height - 1)
     blue  = color1.blue +
             (color2.blue - color1.blue) * (i - y) / (height - 1)
     alpha = color1.alpha +
             (color2.alpha - color1.alpha) * (i - y) / (height - 1)
     color = Color.new(red, green, blue, alpha)
     fill_rect(x, i, width, 1, color)
   end
elsif align == 2
   for i in x...x + width
     for j in y...y + height
       red   = color1.red + (color2.red - color1.red) *
               ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       green = color1.green + (color2.green - color1.green) *
               ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       blue  = color1.blue + (color2.blue - color1.blue) *
               ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       alpha = color1.alpha + (color2.alpha - color1.alpha) *
               ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       color = Color.new(red, green, blue, alpha)
       set_pixel(i, j, color)
     end
   end
elsif align == 3
   for i in x...x + width
     for j in y...y + height
       red   = color1.red + (color2.red - color1.red) *
             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       green = color1.green + (color2.green - color1.green) *
             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       blue  = color1.blue + (color2.blue - color1.blue) *
             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       alpha = color1.alpha + (color2.alpha - color1.alpha) *
             ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
       color = Color.new(red, green, blue, alpha)
       set_pixel(i, j, color)
     end
   end
end
end
end

module RPG
class Sprite < ::Sprite
def damage(value, critical)
   dispose_damage
   if value.is_a?(Numeric)
     damage_string = value.abs.to_s
   else
     damage_string = value.to_s
   end
   bitmap = Bitmap.new(160, 48)
   bitmap.font.name = "Arial Black"
   bitmap.font.size = 32
   bitmap.font.color.set(0, 0, 0)
   bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
   bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
   bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
   bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
   if value.is_a?(Numeric) and value < 0
     bitmap.font.color.set(176, 255, 144)
   else
     bitmap.font.color.set(255, 255, 255)
   end
   bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
   if critical
     bitmap.font.size = 20
     bitmap.font.color.set(0, 0, 0)
     bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
     bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
     bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
     bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
     bitmap.font.color.set(255, 255, 255)
     bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
   end
   @_damage_sprite = ::Sprite.new
   @_damage_sprite.bitmap = bitmap
   @_damage_sprite.ox = 80 + self.viewport.ox
   @_damage_sprite.oy = 20 + self.viewport.oy
   @_damage_sprite.x = self.x + self.viewport.rect.x
   @_damage_sprite.y = self.y - self.oy / 2 + self.viewport.rect.y
   @_damage_sprite.z = 3000
   @_damage_duration = 40
end
def animation(animation, hit)
   dispose_animation
   @_animation = animation
   return if @_animation == nil
   @_animation_hit = hit
   @_animation_duration = @_animation.frame_max
   animation_name = @_animation.animation_name
   animation_hue = @_animation.animation_hue
   bitmap = RPG::Cache.animation(animation_name, animation_hue)
   if @@_reference_count.include?(bitmap)
     @@_reference_count[bitmap] += 1
   else
     @@_reference_count[bitmap] = 1
   end
   @_animation_sprites = []
   if @_animation.position != 3 or not @@_animations.include?(animation)
     for i in 0..15
       sprite = ::Sprite.new
       sprite.bitmap = bitmap
       sprite.visible = false
       @_animation_sprites.push(sprite)
     end
     unless @@_animations.include?(animation)
       @@_animations.push(animation)
     end
   end
   update_animation
end
def loop_animation(animation)
   return if animation == @_loop_animation
   dispose_loop_animation
   @_loop_animation = animation
   return if @_loop_animation == nil
   @_loop_animation_index = 0
   animation_name = @_loop_animation.animation_name
   animation_hue = @_loop_animation.animation_hue
   bitmap = RPG::Cache.animation(animation_name, animation_hue)
   if @@_reference_count.include?(bitmap)
     @@_reference_count[bitmap] += 1
   else
     @@_reference_count[bitmap] = 1
   end
   @_loop_animation_sprites = []
   for i in 0..15
     sprite = ::Sprite.new
     sprite.bitmap = bitmap
     sprite.visible = false
     @_loop_animation_sprites.push(sprite)
   end
   update_loop_animation
end
def animation_set_sprites(sprites, cell_data, position)
   for i in 0..15
     sprite = sprites[i]
     pattern = cell_data[i, 0]
     if sprite == nil or pattern == nil or pattern == -1
       sprite.visible = false if sprite != nil
       next
     end
     sprite.visible = true
     sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
     if position == 3
       if self.viewport != nil
         sprite.x = self.viewport.rect.width / 2
         sprite.y = self.viewport.rect.height - 160
       else
         sprite.x = 320
         sprite.y = 240
       end
     else
       sprite.x = self.x + self.viewport.rect.x -
                   self.ox + self.src_rect.width / 2
       sprite.y = self.y + self.viewport.rect.y -
                   self.oy + self.src_rect.height / 2
       sprite.y -= self.src_rect.height / 4 if position == 0
       sprite.y += self.src_rect.height / 4 if position == 2
     end
     sprite.x += cell_data[i, 1]
     sprite.y += cell_data[i, 2]
     sprite.z = 2000
     sprite.ox = 96
     sprite.oy = 96
     sprite.zoom_x = cell_data[i, 3] / 100.0
     sprite.zoom_y = cell_data[i, 3] / 100.0
     sprite.angle = cell_data[i, 4]
     sprite.mirror = (cell_data[i, 5] == 1)
     sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
     sprite.blend_type = cell_data[i, 7]
   end
end
end
end

class Game_Actor < Game_Battler
def screen_x
   if self.index != nil
   n_split = [($game_party.actors.length * 0.5).ceil, 4].min
   case n_split
   when 1
     n_index = self.index * 2
   when 2
     if self.index < ($game_party.actors.length - 2)
       n_index = 0.5 + (2 * self.index)
     else
       if $game_party.actors.length == 3 then
         n_index = (self.index * 2) + 2
       elsif $game_party.actors.length == 4 then
         n_index = self.index * 2
       end
     end
   when 3
       n_index = self.index + (0.25 * (self.index + 1))
     if $game_party.actors.length == 5
     if self.index < 2
       n_index = self.index + (0.25 * (self.index + 1))
     else
       n_index = self.index + (0.25 * (self.index + 2)) + 1
     end
     end
   when 4
     n_index = self.index
     if $game_party.actors.length == 7
     if self.index < 3
       n_index = self.index
     else
       n_index = self.index + 1
     end
     end
   end
     return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) / 5) + 480 + ((n_index / 4).floor * 60)
   else
     return 0
   end
end
#--------------------------------------------------------------------------
# ? ????? Y ?????
#--------------------------------------------------------------------------
def screen_y
   n_split = [($game_party.actors.length * 0.5).ceil, 4].min
   case n_split
   when 1
     n_index = self.index * 2
   when 2
     if self.index < ($game_party.actors.length - 2)
       n_index = 0.5 + (2 * self.index)
     else
       if $game_party.actors.length == 3 then
         n_index = (self.index * 2) + 2
       elsif $game_party.actors.length == 4 then
         n_index = self.index * 2
       end
     end
   when 3
       n_index = self.index + (0.25 * (self.index + 1))
     if $game_party.actors.length == 5
     if self.index < 2
       n_index = self.index + (0.25 * (self.index + 1))
     else
       n_index = self.index + (0.25 * (self.index + 2)) + 1
     end
     end
   when 4
     n_index = self.index
     if $game_party.actors.length == 7
     if self.index < 3
       n_index = self.index
     else
       n_index = self.index + 1
     end
     end
   end
   return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) * 1.6) + 270 - ((n_index / 4).floor * (110 - (4 * 20)))
end
#--------------------------------------------------------------------------
# ? ????? Z ?????
#--------------------------------------------------------------------------
def screen_z
   # ??????????? Z ?????????
   if self.index != nil
     return self.index
   else
     return 0
   end
end
end

class Game_Enemy < Game_Battler
def screen_x
   n_split = [($game_troop.enemies.length * 0.5).ceil, 4].min
   case n_split
   when 1
     n_index = self.index * 2
   when 2
     if self.index < ($game_troop.enemies.length - 2)
       n_index = 0.5 + (2 * self.index)
     else
       if $game_troop.enemies.length == 3 then
         n_index = (self.index * 2) + 2
       elsif $game_troop.enemies.length == 4 then
         n_index = self.index * 2
       end
     end
   when 3
       n_index = self.index + (0.25 * (self.index + 1))
     if $game_troop.enemies.length == 5
     if self.index < 2
       n_index = self.index + (0.25 * (self.index + 1))
     else
       n_index = self.index + (0.25 * (self.index + 2)) + 2
     end
     end
   when 4
     n_index = self.index
     if $game_troop.enemies.length == 7
     if self.index < 3
       n_index = self.index
     else
       n_index = self.index + 1
     end
     end
   end
   return (n_index - ((n_index / 4).floor) * 4) * ((-160 / (4)) / 5) + 160 - ((n_index / 4).floor * 60)
end
#--------------------------------------------------------------------------
# ? ????? Y ?????
#--------------------------------------------------------------------------
def screen_y
   n_split = [($game_troop.enemies.length * 0.5).ceil, 4].min
   case n_split
   when 1
     n_index = self.index * 2
   when 2
     if self.index < ($game_troop.enemies.length - 2)
       n_index = 0.5 + (2 * self.index)
     else
       if $game_troop.enemies.length == 3 then
         n_index = (self.index * 2) + 2
       elsif $game_troop.enemies.length == 4 then
         n_index = self.index * 2
       end
     end
   when 3
       n_index = self.index + (0.25 * (self.index + 1))
     if $game_troop.enemies.length == 5
     if self.index < 2
       n_index = self.index + (0.25 * (self.index + 1))
     else
       n_index = self.index + (0.25 * (self.index + 2)) + 1
     end
     end
   when 4
     n_index = self.index
     if $game_troop.enemies.length == 7
     if self.index < 3
       n_index = self.index
     else
       n_index = self.index + 1
     end
     end
   end
   return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) * 1.6) + 270 - ((n_index / 4).floor * (110 - (4 * 20)))
end
#--------------------------------------------------------------------------
# ? ????? Z ?????
#--------------------------------------------------------------------------
def screen_z
   return @member_index + 1
end
end

#==============================================================================
# ¦ Sprite_Battler
#------------------------------------------------------------------------------
#  ????????????????Game_Battler ???????????????
# ????????????????????
#==============================================================================

class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ? ??????????
#--------------------------------------------------------------------------
attr_accessor :battler                  # ????
attr_accessor :moving        # Is the sprite moving?
attr_reader   :index
attr_accessor :target_index
attr_accessor :direction
attr_accessor :pattern
#--------------------------------------------------------------------------
# ? ?????????
#     viewport : ??????
#     battler  : ???? (Game_Battler)
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
   super(viewport)
   change
   @old = Graphics.frame_count  # For the delay method
   @goingup = true    # Increasing animation? (if @rm2k_mode is true)
   @once = false      # Is the animation only played once?
   @animated = true   # Used to stop animation when @once is true
   self.opacity = 0
   @index = 0
   @pattern_b = 0
   @counter_b = 0
   @trans_sprite = Sprite.new
   @trans_sprite.opacity = 0
   @bar_hp_sprite = Sprite.new
   @bar_hp_sprite.bitmap = Bitmap.new(64, 10)
   @bar_sp_sprite = Sprite.new
   @bar_sp_sprite.bitmap = Bitmap.new(64, 10)
   @color1 = Color.new(0, 0, 0, 192)
   @color2 = Color.new(255, 255, 192, 192)
   @color3 = Color.new(0, 0, 0, 192)
   @color4 = Color.new(64, 0, 0, 192)
   @old_hp = -1
   @old_sp = -1
   @battler = battler
   @battler_visible = false
   @first = true
   @pattern = 0
   if $target_index == nil
     $target_index = 0
   end
   @battler.is_a?(Game_Enemy) ? enemy_pose(0, 1) : pose(0, 1)
end
#--------------------------------------------------------------------------
# ? ??
#--------------------------------------------------------------------------
def dispose
   if self.bitmap != nil
     self.bitmap.dispose
   end
   if @trans_sprite.bitmap != nil
     @trans_sprite.bitmap.dispose
   end
   @trans_sprite.dispose
   @bar_hp_sprite.bitmap.dispose
   @bar_hp_sprite.dispose
   @bar_sp_sprite.bitmap.dispose
   @bar_sp_sprite.dispose
   super
end

def change(frames = 0, delay = 0, offx = 0, offy = 0, startf = 0, once = false)
   @frames = frames
   @delay = delay
   @offset_x, @offset_y = offx, offy
   @current_frame = startf
   @once = once
   @goingup = true
   @animated = true
end
#--------------------------------------------------------------------------
# ? ??????
#--------------------------------------------------------------------------
def update
   bar_check = true if @_damage_duration == 1
   super
   @trans_sprite.blend_type = self.blend_type
   @trans_sprite.color = self.color
   if @_collapse_duration > 0
     @trans_sprite.opacity = self.opacity
   else
     @trans_sprite.opacity = [self.opacity, 160].min
   end
   if (@_damage_duration == 0 and bar_check == true) or @first == true
     @first = false if @first == true
     bar_check = false
     @bar_must_change = true
   end
   @bar_hp_sprite.opacity = self.opacity
   @bar_sp_sprite.opacity = self.opacity
   # ????? nil ???
   if @battler == nil
     self.bitmap = nil
     @trans_sprite.bitmap = nil
     loop_animation(nil)
     return
   end
   # ????????????????????
   if @battler.battler_name != @battler_name or
      @battler.battler_hue != @battler_hue
     # ????????????
     @battler_name = @battler.battler_name
     @battler_hue = @battler.battler_hue
     if @battler.is_a?(Game_Actor)
       @battler_name = @battler.character_name
       @battler_hue = @battler.character_hue
       @direction = 4
     else
       @direction = 6
     end
       self.bitmap = RPG::Cache.character(@battler_name, @battler_hue)
       @width = bitmap.width / 4
       @height = bitmap.height / 4
       @frame_width = @width
       @frame_height = @height
       self.ox = @width / 2
       self.oy = @height
       @pattern = @current_frame
       @direction = @offset_y
       sx = @pattern * @width
       sy = (@direction - 2) / 2 * @height
       self.src_rect.set(sx, sy, @width, @height)
       @current_frame = (@current_frame + 1) unless @frames == 0
       @animated = false if @current_frame == @frames and @once
       @current_frame %= @frames
       @trans_sprite.bitmap = self.bitmap
       @trans_sprite.ox = self.ox
       @trans_sprite.oy = self.oy
       @trans_sprite.src_rect.set(sx, sy, @width, @height)
     # ?????????????????? 0 ???
     if @battler.dead? or @battler.hidden
       self.opacity = 0
       @trans_sprite.opacity = 0
       @bar_hp_sprite.opacity = 0
       @bar_sp_sprite.opacity = 0
     end
   self.x = @battler.screen_x
   self.y = @battler.screen_y
   self.z = @battler.screen_z
end
change_sp_bar if @old_sp != @battler.sp
if delay(@delay) and @animated
     @pattern = @current_frame
     @direction = @offset_y
     sx = @pattern * @width
     sy = (@direction - 2) / 2 * @height
     self.src_rect.set(sx, sy, @width, @height)
     @current_frame = (@current_frame + 1) unless @frames == 0
     @animated = false if @current_frame == @frames and @once
     @current_frame %= @frames
     @trans_sprite.ox = self.ox
     @trans_sprite.oy = self.oy
     @trans_sprite.src_rect.set(sx, sy, @width, @height)
   end
   # ??????? ID ????????????
   if @battler.damage == nil and
      @battler.state_animation_id != @state_animation_id
     @state_animation_id = @battler.state_animation_id
     loop_animation($data_animations[@state_animation_id])
   end
   # ??????????????
   #if @battler.is_a?(Game_Actor) and @battler_visible
     # ???????????????????????
     #if $game_temp.battle_main_phase
       #self.opacity += 3 if self.opacity < 255
     #else
       #self.opacity -= 3 if self.opacity > 207
     #end
   #end
   # ??
   if @battler.blink
     blink_on
   else
     blink_off
   end
   # ??????
   unless @battler_visible
     # ??
     if not @battler.hidden and not @battler.dead? and
        (@battler.damage == nil or @battler.damage_pop)
       appear
       @battler_visible = true
     end
   end
   # ?????
   if @battler_visible
     # ??
     if @battler.hidden
       $game_system.se_play($data_system.escape_se)
       escape
       @trans_sprite.opacity = 0
       @battler_visible = false
     end
     # ??????
     if @battler.white_flash
       whiten
       @battler.white_flash = false
     end
     # ???????
     if @battler.animation_id != 0
       animation = $data_animations[@battler.animation_id]
       animation(animation, @battler.animation_hit)
       @battler.animation_id = 0
     end
     # ????
     if @battler.damage_pop
       damage(@battler.damage, @battler.critical)
       @battler.damage = nil
       @battler.critical = false
       @battler.damage_pop = false
     end
     if @bar_must_change == true
       @bar_must_change = false
       if @old_hp != @battler.hp
         change_hp_bar
       end
       if @battler.damage == nil and @battler.dead?
         if @battler.is_a?(Game_Enemy)
           $game_system.se_play($data_system.enemy_collapse_se)
         else
           $game_system.se_play($data_system.actor_collapse_se)
         end
         collapse
         @battler_visible = false
       end
     end
   end
   # ???????????
   @trans_sprite.x = self.x
   @trans_sprite.y = self.y
   @trans_sprite.z = self.z
   @bar_hp_sprite.x = @battler.screen_x - 32
   @bar_hp_sprite.y = @battler.screen_y - (@height +18) if @height != nil
   @bar_hp_sprite.z = 100
   @bar_sp_sprite.x = @battler.screen_x - 32
   @bar_sp_sprite.y = @battler.screen_y - (@height + 8) if @height != nil
   @bar_sp_sprite.z = 100
end

#--------------------------------------------------------------------------
# - Move the sprite
#   x : X coordinate of the destination point
#   y : Y coordinate of the destination point
#   speed : Speed of movement (0 = delayed, 1+ = faster)
#   delay : Movement delay if speed is at 0
#--------------------------------------------------------------------------
def move(x, y, speed = 1, delay = 0)
   @destx = x
   @desty = y
   @move_speed = speed
   @move_delay = delay
   @move_old = Graphics.frame_count
   @moving = true
end

#--------------------------------------------------------------------------
# - Move sprite to destx and desty
#--------------------------------------------------------------------------
def update_move
   return unless @moving
   movinc = @move_speed == 0 ? 1 : @move_speed
   if Graphics.frame_count - @move_old > @move_delay or @move_speed != 0
     self.x += movinc if self.x < @destx
     self.x -= movinc if self.x > @destx
     self.y += movinc if self.y < @desty
     self.y -= movinc if self.y > @desty
     @move_old = Graphics.frame_count
   end
   if @move_speed > 1  # Check if sprite can't reach that point
     self.x = @destx if (@destx - self.x).abs % @move_speed != 0 and
                        (@destx - self.x).abs <= @move_speed
     self.y = @desty if (@desty - self.y).abs % @move_speed != 0 and
                        (@desty - self.y).abs <= @move_speed
   end
   if self.x == @destx and self.y == @desty
     @moving = false
   end
end

#--------------------------------------------------------------------------
# - Pause animation, but still updates movement
#   frames : Number of frames
#--------------------------------------------------------------------------
def delay(frames)
   update_move
   if (Graphics.frame_count - @old >= frames)
     @old = Graphics.frame_count
     return true
   end
   return false
end

def change_hp_bar
   j = false
  @old_hp = @battler.hp if @old_hp == -1
   i = @old_hp
   loop do
     i -= 10
     if i < @battler.hp
       i = @battler.hp
       j = true
     end
     rate = i.to_f / @battler.maxhp
     @color5 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
     @color6 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
     @bar_hp_sprite.bitmap.clear
     @bar_hp_sprite.bitmap.fill_rect(0, 0, 64, 10, @color1)
     @bar_hp_sprite.bitmap.fill_rect(1, 1, 62, 8, @color2)
     @bar_hp_sprite.bitmap.gradation_rect(2, 2, 60, 6, @color3, @color4, 1)
     #@bar_hp_sprite.bitmap.fill_rect(2, 2, 60, 6, @color3)
     @bar_hp_sprite.bitmap.gradation_rect(2, 2, 64 * rate - 4, 6, @color5, @color6, 2)
     #@bar_hp_sprite.bitmap.fill_rect(2, 2, 64 * rate - 4, 6, @color5)
     @bar_hp_sprite.opacity = self.opacity
     Graphics.update
     if j == true
       j = false
       break
     end
   end
   @old_hp = @battler.hp
end

def change_sp_bar
   j = false
  @old_sp = @battler.sp if @old_sp == -1
   i = @old_sp
   loop do
     i -= 10
     if i < @battler.sp
       i = @battler.sp
       j = true
     end
     rate = i.to_f / @battler.maxsp
     @color7 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
     @color8 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
     @bar_sp_sprite.bitmap.clear
     @bar_sp_sprite.bitmap.fill_rect(0, 0, 64, 10, @color1)
     @bar_sp_sprite.bitmap.fill_rect(1, 1, 62, 8, @color2)
     @bar_sp_sprite.bitmap.gradation_rect(2, 2, 60, 6, @color3, @color4, 1)
     #@bar_hp_sprite.bitmap.fill_rect(2, 2, 60, 6, @color3)
     @bar_sp_sprite.bitmap.gradation_rect(2, 2, 64 * rate - 4, 6, @color7, @color8, 0)
     #@bar_hp_sprite.bitmap.fill_rect(2, 2, 64 * rate - 4, 6, @color5)
     @bar_sp_sprite.opacity = self.opacity
     Graphics.update
     if j == true
       j = false
       break
     end
   end
   @old_sp = @battler.sp
end

def enemy                                             #
   $target_index += $game_troop.enemies.size
   $target_index %= $game_troop.enemies.size
   return $game_troop.enemies[$target_index]           #
end                                                   #

def actor                                             #
   $target_index += $game_party.actors.size
   $target_index %= $game_party.actors.size
   return $game_party.actors[$target_index]            #
end

def index=(index)
   @index = index
   update
end

   def pose(number, frames = 4)
   case number
   when 0
     change(frames, 4, 0, 4, 0)
   when 1
     change(frames, 4, 0, 4)
   when 2
     change(frames, 4, 0, 6)
   else
     change(frames, 4, 0, 0, 0)
   end
end

   def enemy_pose(number ,enemy_frames = 4)
   case number
   when 0
     change(enemy_frames, 4, 0, 6, 0)
   when 1
     change(enemy_frames, 4, 0, 4)
   when 2
     change(enemy_frames, 4, 0, 6)
   else
     change(enemy_frames, 4, 0, 0, 0)
   end
end

def default_pose
   pose(0, 1)
end
end

#==============================================================================
# ¦ Spriteset_Battle
#------------------------------------------------------------------------------
#  ???????????????????????????? Scene_Battle ??
# ????????????
#==============================================================================

class Spriteset_Battle
#--------------------------------------------------------------------------
# ? ??????????
#--------------------------------------------------------------------------
attr_reader   :viewport1                # ????????????
attr_reader   :viewport2                # ????????????
attr_accessor :actor_sprites
attr_accessor :enemy_sprites
#--------------------------------------------------------------------------
# ? ?????????
#--------------------------------------------------------------------------
def initialize
   # ?????????
   @viewport1 = Viewport.new(0, 0, 640, 480)
   @viewport2 = Viewport.new(0, 0, 640, 480)
   @viewport3 = Viewport.new(0, 0, 640, 480)
   @viewport4 = Viewport.new(0, 0, 640, 480)
   @viewport2.z = 101
   @viewport3.z = 200
   @viewport4.z = 5000
   if $game_temp.battleback_name == ""
   @battleback_sprite = nil
   @tilemap = Tilemap.new(@viewport1)
   @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
   for i in 0..6
     autotile_name = $game_map.autotile_names[i]
     @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
   end
   @tilemap.map_data = $game_map.data
   @tilemap.priorities = $game_map.priorities
   else
   # ??????????????
   @tilemap = nil
   @battleback_sprite = Sprite.new(@viewport1)
   end
   # ????????????
   @enemy_sprites = []
   for enemy in $game_troop.enemies#.reverse
     @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
   end
   # ????????????
   @actor_sprites = []
   for j in 0..7
       # ƒAƒNƒ^[ƒXƒvƒ‰ƒCƒg‚ð’ljÁ
       @actor_sprites.push(Sprite_Battler.new(@viewport1, $game_party.actors[j]))
   end
   # ?????
   @weather = RPG::Weather.new(@viewport1)
   # ????????????
   @picture_sprites = []
   for i in 51..100
     @picture_sprites.push(Sprite_Picture.new(@viewport3,
       $game_screen.pictures[i]))
   end
   # ????????????
   @timer_sprite = Sprite_Timer.new
   # ??????
   update
end
#--------------------------------------------------------------------------
# ? ??
#--------------------------------------------------------------------------
def dispose
   if @tilemap != nil
   # ?????????
   @tilemap.tileset.dispose
   for i in 0..6
     @tilemap.autotiles[i].dispose
   end
   @tilemap.dispose
   end
   # ??????????????
   if @battleback_sprite != nil
   # ??????????????????????
   if @battleback_sprite.bitmap != nil
     @battleback_sprite.bitmap.dispose
   end
   @battleback_sprite.dispose
   end
   # ??????????????????????
   for sprite in @enemy_sprites + @actor_sprites
     sprite.dispose
   end
   # ?????
   @weather.dispose
   # ????????????
   for sprite in @picture_sprites
     sprite.dispose
   end
   # ????????????
   @timer_sprite.dispose
   # ?????????
   @viewport1.dispose
   @viewport2.dispose
   @viewport3.dispose
   @viewport4.dispose
end
#--------------------------------------------------------------------------
# ? ??????????
#--------------------------------------------------------------------------
def effect?
   # ??????????????? true ???
   for sprite in @enemy_sprites + @actor_sprites
     return true if sprite.effect?
   end
   return false
end
#--------------------------------------------------------------------------
# ? ??????
#--------------------------------------------------------------------------
def update
   # ???????????????????????
   if @battleback_sprite != nil
   if @battleback_name != $game_temp.battleback_name
     @battleback_name = $game_temp.battleback_name
     if @battleback_sprite.bitmap != nil
       @battleback_sprite.bitmap.dispose
     end
     bg_bitmap = RPG::Cache.battleback(@battleback_name)
     bg_bitmap_stretch = Bitmap.new(640, 480)
     bg_bitmap_stretch.stretch_blt(Rect.new(0, 0, 640, 480), bg_bitmap, bg_bitmap.rect)
     @battleback_sprite.bitmap = bg_bitmap_stretch
   end
   end
   if @tilemap != nil
   @tilemap.ox = $game_map.display_x / 4
   @tilemap.oy = $game_map.display_y / 4
   @tilemap.update
   end
   # ????????????
   for sprite in @enemy_sprites + @actor_sprites
     sprite.update
   end
   # ???????????
   @weather.type = $game_screen.weather_type
   @weather.max = $game_screen.weather_max
   @weather.update
   # ????????????
   for sprite in @picture_sprites
     sprite.update
   end
   # ????????????
   @timer_sprite.update
   # ???????????????
   @viewport1.tone = $game_screen.tone
   @viewport1.ox = $game_screen.shake
   # ????????????
   @viewport4.color = $game_screen.flash_color
   # ?????????
   @viewport1.update
   @viewport2.update
   @viewport4.update
end
end

#==============================================================================
# ¦ Window_Command
#------------------------------------------------------------------------------
#  ?????????????????????
#==============================================================================

class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# ? ?????????
#     width    : ???????
#     commands : ??????????
#--------------------------------------------------------------------------
def initialize(width, commands, column_max = 1, style = 0, inf_scroll = 1)
   # ????????????????????
   super(0, 0, width, (commands.size * 1.0 / column_max).ceil * 32 + 32)
   @inf_scroll = inf_scroll
   @item_max = commands.size
   @commands = commands
   @column_max = column_max
   @style = style
   self.contents = Bitmap.new(width - 32, (@item_max * 1.0 / @column_max).ceil * 32)
   self.contents.font.name = "Tahoma"
   self.contents.font.size = 22
   refresh
   self.index = 0
end
#--------------------------------------------------------------------------
# ? ??????
#--------------------------------------------------------------------------
def refresh
   self.contents.clear
   for i in 0...@item_max
     draw_item(i, normal_color)
   end
end
#--------------------------------------------------------------------------
# ? ?????
#     index : ????
#     color : ???
#--------------------------------------------------------------------------
def draw_item(index, color)
   self.contents.font.color = color
   rect = Rect.new(index%@column_max * (self.width / @column_max) + 4, 32 * (index/@column_max), self.width / @column_max - 40, 32)
   self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
   self.contents.draw_text(rect, @commands[index], @style)
end
#--------------------------------------------------------------------------
# ? ??????
#     index : ????
#--------------------------------------------------------------------------
def disable_item(index)
   draw_item(index, disabled_color)
end

def update_help
   @help_window.set_actor($game_party.actors[$scene.actor_index])
end
end

#==============================================================================
# ¦ Arrow_Enemy
#------------------------------------------------------------------------------
#  ????????????????????????????? Arrow_Base ??
# ????????
#==============================================================================

class Arrow_Enemy < Arrow_Base
#--------------------------------------------------------------------------
# ? ?????????????????
#--------------------------------------------------------------------------
def enemy
   return $game_troop.enemies[@index]
end
#--------------------------------------------------------------------------
# ? ??????
#--------------------------------------------------------------------------
def update
   super
   # ???????????????????
   $game_troop.enemies.size.times do
     break if self.enemy.exist?
     @index += 1
     @index %= $game_troop.enemies.size
   end
   # ?????
   if Input.repeat?(Input::DOWN)
     $game_system.se_play($data_system.cursor_se)
     $game_troop.enemies.size.times do
       @index += 1
       @index %= $game_troop.enemies.size
       break if self.enemy.exist?
     end
   end
   # ?????
   if Input.repeat?(Input::UP)
     $game_system.se_play($data_system.cursor_se)
     $game_troop.enemies.size.times do
       @index += $game_troop.enemies.size - 1
       @index %= $game_troop.enemies.size
       break if self.enemy.exist?
     end
   end
   if Input.repeat?(Input::RIGHT)
     $game_system.se_play($data_system.cursor_se)
     $game_troop.enemies.size.times do
       @index += ((($game_troop.enemies.length) * 0.5).ceil)
       @index %= $game_troop.enemies.size
       break if self.enemy.exist?
     end
   end
   if Input.repeat?(Input::LEFT)
     $game_system.se_play($data_system.cursor_se)
     $game_troop.enemies.size.times do
       @index += $game_troop.enemies.size - ((($game_troop.enemies.length) * 0.5).ceil)
       @index %= $game_troop.enemies.size
       break if self.enemy.exist?
     end
   end
   # ???????????
   if self.enemy != nil
     self.x = self.enemy.screen_x + 4
     self.y = self.enemy.screen_y + 36
     self.z = self.enemy.screen_z + 1
   end
end
#--------------------------------------------------------------------------
# ? ?????????
#--------------------------------------------------------------------------
def update_help
   # ????????????????????????
   @help_window.set_enemy(self.enemy)
end
end

#==============================================================================
# ¦ Arrow_Actor
#------------------------------------------------------------------------------
#  ????????????????????????????? Arrow_Base ??
# ????????
#==============================================================================

class Arrow_Actor < Arrow_Base
#--------------------------------------------------------------------------
# ? ?????????????????
#--------------------------------------------------------------------------
def actor
   return $game_party.actors[@index]
end
#--------------------------------------------------------------------------
# ? ??????
#--------------------------------------------------------------------------
def update
   super
   # ?????
   if Input.repeat?(Input::DOWN)
     $game_system.se_play($data_system.cursor_se)
     @index += 1
     @index %= $game_party.actors.size
   end
   # ?????
   if Input.repeat?(Input::UP)
     $game_system.se_play($data_system.cursor_se)
     @index += $game_party.actors.size - 1
     @index %= $game_party.actors.size
   end
   if Input.repeat?(Input::RIGHT)
     $game_system.se_play($data_system.cursor_se)
     @index += ($game_party.actors.length * 0.5).ceil
     @index %= $game_party.actors.size
   end
   # ?????
   if Input.repeat?(Input::LEFT)
     $game_system.se_play($data_system.cursor_se)
     @index += $game_party.actors.size - (($game_party.actors.length * 0.5).ceil)
     @index %= $game_party.actors.size
   end
   # ???????????
   if self.actor != nil
     self.x = self.actor.screen_x
     self.y = self.actor.screen_y + 36
     self.z = self.actor.screen_z + 1
   end
end
#--------------------------------------------------------------------------
# ? ?????????
#--------------------------------------------------------------------------
def update_help
   # ??????????????????????
   @help_window.set_actor(self.actor)
end
end

class Scene_Battle
attr_accessor :actor_index
def main
   # ???????????????
   $game_temp.in_battle = true
   $game_temp.battle_turn = 0
   $game_temp.battle_event_flags.clear
   $game_temp.battle_abort = false
   $game_temp.battle_main_phase = false
   $game_temp.battleback_name = $game_map.battleback_name
   $game_temp.forcing_battler = nil
   # ??????????????????
   $game_system.battle_interpreter.setup(nil, 0)
   # ???????
   @troop_id = $game_temp.battle_troop_id
   $game_troop.setup(@troop_id)
   # ????????????????
   s1 = $data_system.words.attack
   s1 = $data_system.words.attack
   s2 = $data_system.words.skill
   s3 = $data_system.words.guard
   s4 = $data_system.words.item
   @actor_command_window = Window_Command.new(640, [s1, s2, s3, s4], 4)
   @actor_command_window.y = 64
   @actor_command_window.back_opacity = 160
   @actor_command_window.active = false
   @actor_command_window.visible = false
   # ????????????
   @party_command_window = Window_PartyCommand.new
   @help_window = Window_Help.new
   @help_window.back_opacity = 160
   @help_window.visible = false
   #@status_window = Window_BattleStatus.new
   @message_window = Window_Message.new
   # ???????????
   @spriteset = Spriteset_Battle.new
   # ????????????
   @wait_count = 0
   # ?????????
   if $data_system.battle_transition == ""
     Graphics.transition(20)
   else
     Graphics.transition(40, "Graphics/Transitions/" +
       $data_system.battle_transition)
   end
   # ???????????
   start_phase1
   # ??????
   loop do
     # ????????
     Graphics.update
     # ???????
     Input.update
     # ??????
     update
     # ????????????????
     if $scene != self
       break
     end
   end
   # ??????????
$game_map.refresh
   # ?????????
   Graphics.freeze
   # ????????
   @actor_command_window.dispose
   @party_command_window.dispose
   @help_window.dispose
   #@status_window.dispose
   @message_window.dispose
   if @skill_window != nil
     @skill_window.dispose
   end
   if @item_window != nil
     @item_window.dispose
   end
   if @result_window != nil
     @result_window.dispose
   end
   # ???????????
   @spriteset.dispose
   # ???????????????
   if $scene.is_a?(Scene_Title)
     # ??????????
     Graphics.transition
     Graphics.freeze
   end
   # ???????????????????????????
   if $BTEST and not $scene.is_a?(Scene_Gameover)
     $scene = nil
   end
end

def update
   # ?????????????
   if $game_system.battle_interpreter.running?
     # ?????????
     $game_system.battle_interpreter.update
     # ?????????????????????????
     if $game_temp.forcing_battler == nil
       # ?????????????????
       unless $game_system.battle_interpreter.running?
         # ??????????????????????????
         unless judge
           setup_battle_event
         end
       end
       # ????????????????
       if @phase != 5
         # ?????????????????
         #@status_window.refresh
       end
     end
   end
   # ???? (????)??????
   $game_system.update
   $game_screen.update
   # ????? 0 ??????
   if $game_system.timer_working and $game_system.timer == 0
     # ?????
     $game_temp.battle_abort = true
   end
   # ????????
   @help_window.update
   @party_command_window.update
   @actor_command_window.update
   #@status_window.update
   @message_window.update
   # ???????????
   @spriteset.update
   # ?????????????
   if $game_temp.transition_processing
     # ?????????????????
     $game_temp.transition_processing = false
     # ?????????
     if $game_temp.transition_name == ""
       Graphics.transition(20)
     else
       Graphics.transition(40, "Graphics/Transitions/" +
         $game_temp.transition_name)
     end
   end
   # ????????????????
   if $game_temp.message_window_showing
     return
   end
   # ???????????
   if @spriteset.effect?
     return
   end
   # ??????????
   if $game_temp.gameover
     # ??????????????
     $scene = Scene_Gameover.new
     return
   end
   # ???????????
   if $game_temp.to_title
     # ???????????
     $scene = Scene_Title.new
     return
   end
   # ????????
   if $game_temp.battle_abort
     # ??????? BGM ???
     $game_system.bgm_play($game_temp.map_bgm)
     # ?????
     battle_end(1)
     return
   end
   # ????????
   if @wait_count > 0
     # ????????????
     @wait_count -= 1
     return
   end
   
   # this one holds the battle while the player moves
   for actor in @spriteset.actor_sprites
     if actor.moving
       return
     end
   end
   # and this one is for the enemy... 
   for enemy in @spriteset.enemy_sprites
     if enemy.moving# and $game_system.animated_enemy
       return
     end
   end
   # ???????????????????????
   # ????????????????
   if $game_temp.forcing_battler == nil and
      $game_system.battle_interpreter.running?
     return
   end
   # ??????????
   case @phase
   when 1  # ?????????
     update_phase1
   when 2  # ????????????
     update_phase2
   when 3  # ????????????
     update_phase3
   when 4  # ???????
     update_phase4
   when 5  # ???????????
     update_phase5
   end
end

def start_phase2
   # ???? 2 ???
   @phase = 2
   # ?????????????
   @actor_index = -1
   @active_battler = nil
   # ?????????????????
   @party_command_window.active = true
   @party_command_window.visible = true
   # ?????????????????
   @actor_command_window.active = false
   @actor_command_window.visible = false
   @help_window.visible = false
   # ??????????????
   $game_temp.battle_main_phase = false
   # ????????????????
   $game_party.clear_actions
   # ????????????
   unless $game_party.inputable?
     # ?????????
     start_phase4
   end
end

def update_phase2_escape
   # ??????????????
   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
     # ?? SE ???
     $game_system.se_play($data_system.escape_se)
       for actor in $game_party.actors
         @spriteset.actor_sprites[actor.index].pose(2)
         @spriteset.actor_sprites[actor.index].move(660, actor.screen_y, 10)
       end
       check = escape_move
     until check == false
       @spriteset.update
       Graphics.update
       check = escape_move
     end
     # ??????? BGM ???
     $game_system.bgm_play($game_temp.map_bgm)
     # ?????
     battle_end(1)
   # ???????
   else
     # ????????????????
     $game_party.clear_actions
     # ?????????
     start_phase4
   end
end

def escape_move
   for actor in @spriteset.actor_sprites
     if actor.moving
       return true
     end
   end
   return false
end

def start_phase5
   # ???? 5 ???
   @phase = 5
   # ????? ME ???
   $game_system.me_play($game_system.battle_end_me)
   # ??????? BGM ???
   $game_system.bgm_play($game_temp.map_bgm)
   # EXP???????????????
   exp = 0
   gold = 0
   treasures = []
   # ???
   for enemy in $game_troop.enemies
     # ??????????????
     unless enemy.hidden
       # ?? EXP????????
       exp += enemy.exp
       gold += enemy.gold
       # ?????????
       if rand(100) < enemy.treasure_prob
         if enemy.item_id > 0
           treasures.push($data_items[enemy.item_id])
         end
         if enemy.weapon_id > 0
           treasures.push($data_weapons[enemy.weapon_id])
         end
         if enemy.armor_id > 0
           treasures.push($data_armors[enemy.armor_id])
         end
       end
     end
   end
   # ???????? 6 ??????
   treasures = treasures[0..5]
   # EXP ??
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     if actor.cant_get_exp? == false
       last_level = actor.level
       actor.exp += exp
       if actor.level > last_level
         #@status_window.level_up(i)
       end
     end
   end
   # ??????
   $game_party.gain_gold(gold)
   # ???????
   for item in treasures
     case item
     when RPG::Item
       $game_party.gain_item(item.id, 1)
     when RPG::Weapon
       $game_party.gain_weapon(item.id, 1)
     when RPG::Armor
       $game_party.gain_armor(item.id, 1)
     end
   end
   # ???????????????
   @result_window = Window_BattleResult.new(exp, gold, treasures)
   # ???????????
   @phase5_wait_count = 100
end

#--------------------------------------------------------------------------
# ? ?????? (???????????)
#--------------------------------------------------------------------------
def update_phase5
   # ????????? 0 ???????
   if @phase5_wait_count > 0
     # ????????????
     @phase5_wait_count -= 1
     # ????????? 0 ??????
     if @phase5_wait_count == 0
       # ????????????
       @result_window.visible = true
       # ??????????????
       $game_temp.battle_main_phase = false
       # ?????????????????
       #@status_window.refresh
     end
     return
   end
   # C ??????????
   if Input.trigger?(Input::C)
     # ?????
     battle_end(0)
   end
end

def phase3_setup_command_window
   # ?????????????????
   @party_command_window.active = false
   @party_command_window.visible = false
   # ?????????????????
   @actor_command_window.active = true
   @actor_command_window.visible = true
   @help_window.visible = true
   # ???????????????????
   if @actor_command_window.help_window == nil
     @actor_command_window.help_window = @help_window
   end
   @actor_command_window.update_help    
   #@actor_command_window.x = @actor_index * 160
   # ??????? 0 ???
   @actor_command_window.index = 0
end
def start_enemy_select
   # ??????????
   @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2)
   # ?????????????
   @enemy_arrow.help_window = @help_window
   # ?????????????????
   @actor_command_window.active = false
   @actor_command_window.visible = false
end

def update_phase4
   case @phase4_step
   when 1
     update_phase4_step1
   when 2
     update_phase4_step2
   when 3
     update_phase4_step3
   when 4
     update_phase4_step4
   when 5
     update_phase4_step5
   when 6
     update_phase4_step6
   when 7
     update_phase4_step7
   end    
end

def update_phase4_step1

   # Change actor poses to default
   #if @active_battler.is_a?(Game_Actor)
   #  @spriteset.actor_sprites[@active_battler.index].default_pose
   #end
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     @spriteset.actor_sprites[i].default_pose
   end

   @help_window.visible = false
   if judge
     return
   end
   if $game_temp.forcing_battler == nil
     setup_battle_event
     if $game_system.battle_interpreter.running?
       return
     end
   end
   if $game_temp.forcing_battler != nil
     @action_battlers.delete($game_temp.forcing_battler)
     @action_battlers.unshift($game_temp.forcing_battler)
   end
   if @action_battlers.size == 0
     start_phase2
     return
   end
   @animation1_id = 0
   @animation2_id = 0
   @common_event_id = 0
   @active_battler = @action_battlers.shift
   if @active_battler.index == nil
     return
   end
   if @active_battler.hp > 0 and @active_battler.slip_damage?
     @active_battler.slip_damage_effect
     @active_battler.damage_pop = true
   end
   @active_battler.remove_states_auto
   #@status_window.refresh
   @phase4_step = 2
end

def make_basic_action_result
   
   if @active_battler.is_a?(Game_Actor)
     $actor_on_top = true
   elsif @active_battler.is_a?(Game_Enemy)
     $actor_on_top = false
   end
   if @active_battler.current_action.basic == 0
     @animation1_id = @active_battler.animation1_id
     @animation2_id = @active_battler.animation2_id
     if @active_battler.is_a?(Game_Enemy)
       if @active_battler.restriction == 3
         target = $game_troop.random_target_enemy
       elsif @active_battler.restriction == 2
         target = $game_party.random_target_actor
       else
         index = @active_battler.current_action.target_index
         target = $game_party.smooth_target_actor(index)
       end
#======== here is the setting for the movement & animation...
         x = target.screen_x - 32
         @spriteset.enemy_sprites[@active_battler.index].enemy_pose(2)
         @spriteset.enemy_sprites[@active_battler.index].move(x, target.screen_y, 10)
#========= here if you look at the RPG's movement settings you'll see
#========= that he takes the number 40 for the speed of the animation... 
#========= i thing thats too fast so i settet it down to 10 so looks smoother...
     end
     if @active_battler.is_a?(Game_Actor)
       weapon = $data_weapons[@active_battler.weapon_id]
       range = false
       if weapon != nil
         for id in weapon.element_set
           if $data_system.elements[23] == "Range"
             range = true
             break
           end
         end
       end
       if @active_battler.restriction == 3
         target = $game_party.random_target_actor
       elsif @active_battler.restriction == 2
         target = $game_troop.random_target_enemy
       else
         index = @active_battler.current_action.target_index
         target = $game_troop.smooth_target_enemy(index)
       end
#======= the same thing for the player... ^-^
       x = target.screen_x + 32
       @spriteset.actor_sprites[@active_battler.index].pose(1)
       @spriteset.actor_sprites[@active_battler.index].move(x * (range ? 2 : 1), target.screen_y, 10)
       range = false
     end
     @target_battlers = [target]
     for target in @target_battlers
       target.attack_effect(@active_battler)
     end
     return
   end
   if @active_battler.current_action.basic == 1
     if @active_battler.is_a?(Game_Actor)
       @spriteset.actor_sprites[@active_battler.index].pose(0, 1) #defence
     else
       @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1) #defence
     end
     @help_window.set_text($data_system.words.guard, 1)
     return
   end
   if @active_battler.is_a?(Game_Enemy) and
      @active_battler.current_action.basic == 2
     @help_window.set_text("Escape", 1)
     @active_battler.escape
     return
   end
   if @active_battler.current_action.basic == 3
     $game_temp.forcing_battler = nil
     @phase4_step = 1
     return
   end
   
   if @active_battler.current_action.basic == 4
     if $game_temp.battle_can_escape == false
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     $game_system.se_play($data_system.decision_se)
     update_phase2_escape
     return
   end
end

def make_skill_action_result
   
   @skill = $data_skills[@active_battler.current_action.skill_id]
   unless @active_battler.current_action.forcing
     unless @active_battler.skill_can_use?(@skill.id)
       $game_temp.forcing_battler = nil
       @phase4_step = 1
       return
     end
   end
   @active_battler.sp -= @skill.sp_cost
   #@status_window.refresh
   @help_window.set_text(@skill.name, 1)
   @animation1_id = @skill.animation1_id
   @animation2_id = @skill.animation2_id
     if @active_battler.is_a?(Game_Enemy)
         #@spriteset.enemy_sprites[@active_battler.index].change_sp_bar
          x = @active_battler.screen_x + 48
         @spriteset.enemy_sprites[@active_battler.index].enemy_pose(2)
         @spriteset.enemy_sprites[@active_battler.index].move(x, @active_battler.screen_y, 5)
         @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
     end
     if @active_battler.is_a?(Game_Actor)
       #@spriteset.actor_sprites[@active_battler.index].change_sp_bar
       x = @active_battler.screen_x - 48
       @spriteset.actor_sprites[@active_battler.index].pose(1)
       @spriteset.actor_sprites[@active_battler.index].move(x, @active_battler.screen_y, 5)
       @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
     end
   @common_event_id = @skill.common_event_id
   set_target_battlers(@skill.scope)
   for target in @target_battlers
     target.skill_effect(@active_battler, @skill)
   end
end

   def make_item_action_result
  
   # sorry i didnt work on this...
   # couse i dont have a sprite that uses items....
   # so i just added the standby sprite here...
   # when i get more time for this i'll try what i can do for this one... ^-^
   # its the same as the ones above...
   if @active_battler.is_a?(Game_Actor)
     @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
   else
     @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
   end
   
   @item = $data_items[@active_battler.current_action.item_id]
   unless $game_party.item_can_use?(@item.id)
     @phase4_step = 1
     return
   end
   if @item.consumable
     $game_party.lose_item(@item.id, 1)
   end
   @help_window.set_text(@item.name, 1)
   @animation1_id = @item.animation1_id
   @animation2_id = @item.animation2_id
   @common_event_id = @item.common_event_id
   index = @active_battler.current_action.target_index
   target = $game_party.smooth_target_actor(index)
   set_target_battlers(@item.scope)
   for target in @target_battlers
     target.item_effect(@item)
   end
end

def update_phase4_step3
   if @active_battler.current_action.kind == 0 and
      @active_battler.current_action.basic == 0
      # in this one... we have our weapon animations... for player and monster
     if @active_battler.is_a?(Game_Actor)
       @spriteset.actor_sprites[@active_battler.index].pose(0,1)
     elsif @active_battler.is_a?(Game_Enemy)
       @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0,1)
     end
   end
   if @animation1_id == 1
     @active_battler.white_flash = true
   else
     @active_battler.animation_id = @animation1_id
     @active_battler.animation_hit = true
   end
   @phase4_step = 4
end

def update_phase4_step4
   # this here is for the hit animation...
   for target in @target_battlers
     target.animation_id = @animation2_id
     target.animation_hit = (target.damage != "Miss")
   end
   @wait_count = 8
   @phase4_step = 5
end

def update_phase4_step5
   if @active_battler.hp > 0 and @active_battler.slip_damage?
     @active_battler.slip_damage_effect
     @active_battler.damage_pop = true
   end
   # ???????????
   @help_window.visible = false
   # ?????????????????
   #@status_window.refresh
   # ??????

   if @active_battler.is_a?(Game_Actor)
     @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
   else
     @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
   end
   for target in @target_battlers
     if target.damage != nil
       target.damage_pop = true
       if @active_battler.is_a?(Game_Actor)
         @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
       else
         @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
       end
     end
   end
   # ???? 6 ???
   @phase4_step = 6
end

def update_phase4_step6
   
   # here we are asking if the player is dead and is a player or an enemy...
   # these lines are for the running back and standby animation....
   if @active_battler.is_a?(Game_Actor)
     if @active_battler.current_action.basic == 1
       @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
     else
       @spriteset.actor_sprites[@active_battler.index].move(@active_battler.screen_x, @active_battler.screen_y, 20)
       @spriteset.actor_sprites[@active_battler.index].pose(2)
     end
   else
     if @active_battler.current_action.basic == 1
       @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
     else
       @spriteset.enemy_sprites[@active_battler.index].move(@active_battler.screen_x, @active_battler.screen_y, 20)
       @spriteset.enemy_sprites[@active_battler.index].enemy_pose(1)
     end
   end
   for target in @target_battlers
     if target.is_a?(Game_Actor)
         @spriteset.actor_sprites[target.index].pose(0, 1)
       else
         @spriteset.enemy_sprites[target.index].enemy_pose(0, 1)
     end
   end
   $game_temp.forcing_battler = nil
   if @common_event_id > 0
     common_event = $data_common_events[@common_event_id]
     $game_system.battle_interpreter.setup(common_event.list, 0)
   end
   @phase4_step = 7
end

def update_phase4_step7
   
   # here we are asking if the player is dead and is a player or an enemy...
   # these lines are for the running back and standby animation....
   if @active_battler.is_a?(Game_Actor)
     @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
   else
     @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
   end

   $game_temp.forcing_battler = nil
   if @common_event_id > 0
     common_event = $data_common_events[@common_event_id]
     $game_system.battle_interpreter.setup(common_event.list, 0)
   end
   @phase4_step = 1
end
end

y listo.
 
Última edición:
Estado
Cerrado para nuevas respuestas
Arriba Pie