AMS Ultimate 1.1
Description
Ce script regroupe tout un tas de fonction très intéressantes dont voici la liste:
- Ajout de 4 directions => il est possible de se déplacer en diagonale.
- Ajout de la possibilité d'utiliser des sprites de plus de 4 animations.
- Ajout du son des pas lorsque l'on marche (différent selon la surface sur laquelle on marche).
- Ajout d'un sprint (les sons des pas s'adaptant à la vitesse du joueur).
- Ajout d'un saut avec prise en compte des reliefs sur la carte.
- Ajout d'un mode de vue en perspective avec zoom et dézoom sur le héros en fonction de son éloignement. La vitesse de ce dernier est également adaptée.
- Ajout d'animation comme les traces de pas dans la neige ou l'éclaboussement lorsqu'on marche dans l'eau.
Auteur(s) : Zeus81
Note du script:




Image
Installation
Ce script est en fait composé de 3 sous-scripts que voici.
Créez un script nommé "AMS Ultimate" juste avant le "Main" et copiez-y ceci:
#========================#
# Advanced Move System #
# ULTIMATE 1.1 #
# Script créé par Zeus81 #
# © 2007-2008 #
#========================#
# Vous pouvez choisir les touches pour sprinter et sauter aux lignes 35 et 36
# Les touches possibles sont Input::A, B, C, X, Y, Z, L, R
# Pour choisir à quelle touche ça correspond sur le clavier lancez le jeu puis appuyez sur F1
# Si les touches qui vous sont proposées ne vous conviennent pas vous pouvez toujours télécharger
# le script : "Input Ultimate" qui vous permettra de choisir n'importe quelle touche du clavier
# Si vous voulez désactiver le sprint écrivez : Dash_Input = 0
# Si vous voulez désactiver les sauts écrivez : Jump_Input = 0
# Vous pouvez initialiser le héros lignes 40 à 55
# @position => façon dont est positionnée l'image par rapport à ses coordonnées (voir tutorial)
# @move_speed => vitesse de déplacement, comprise entre 0 et 7
# @move_animation_speed => vitesse de l'animation du personnage, >= 0
# si = 0, la vitesse de l'animation sera automatiquement égale à la vitesse de déplacement
# @jump_power => puissance des sauts, doit être supérieure à la hauteur des murs que l'on veut pouvoir sauter
# @zoom => zoom en pourcentage : 1 => 100%, 0.5 => 50%, 2 => 200%
# @step_anime => animée à l'arrêt ? true => oui : false => non
# @spec_anime => animation spéciale qui se déclenche de manière aléatoire quand on est à l'arrêt
# @walk_anime => animée pendant mouvement ? true => oui : false => non
# @jump_anime => animée pendant saut ? true => oui : false => non
# @fall_anime => animée pendant chute ? true => oui : false => non
# @down_anime => animation spéciale qui se déclenche quand on tombe de trop haut
# @shadow => ombre activée ? true => oui : false => non
# @walk_steps => nombre de pas dans une animation
# @walk_terrain => force un terrain spécifique quel que soit l'endroit où l'on marche
# si = 0, le terrain est celui sur lequel on marche
# @walk_audio => bruits de pas activés ? true => oui : false => non
# @walk_graphics => traces de pas activées ? true => oui : false => non
class Game_Player
Dash_Input = Input::C
Jump_Input = Input::A
Jump_Audio = RPG::AudioFile.new("Data System/JumpAudio")
def initialize
super
@position = 8
@move_speed = 4
@move_animation_speed = 0
@jump_power = 1.5
@zoom = 1
@step_anime = false
@spec_anime = true
@walk_anime = true
@jump_anime = true
@fall_anime = true
@down_anime = true
@shadow = true
@walk_steps = 2
@walk_terrain = 0
@walk_audio = true
@walk_graphics = true
end
end
# Vous pouvez choisir les valeurs par défaut pour la gravité ligne 84.
# Vous pouvez choisir les valeurs par défaut pour les terrains lignes 87 à 107 :
# Default_Terrain[0][ X] = ["nom du fichier audio A", "volume" , "tempo" ]
# Default_Terrain[0][-X] = ["nom du fichier audio B", "volume" , "tempo" ]
# Default_Terrain[1][ X] = ["nom du fichier image" , "durée 1", "durée 2"]
# X = numéro du terrain
# audio A = audio joué lors du premier pas sur ce terrain
# audio B = audio joué lors du second pas sur ce terrain (S'il y a deux pas)
# durée 1 = durée d'affichage quand marche en nombre de frames (40 frames = 1 sec)
# durée 2 = durée d'affichage quand court en nombre de frames (40 frames = 1 sec)
# Vous pouvez configurer des terrains spéciaux à partir de la ligne 109 de la même façon que pour les terrains :
# Special_Terrain[0][ X] = ["nom du fichier audio A", "volume" , "tempo" ]
# Special_Terrain[0][-X] = ["nom du fichier audio B", "volume" , "tempo" ]
# Special_Terrain[1][ X] = ["nom du fichier image" , "durée 1", "durée 2"]
# Rappel :
# Si la variable @walk_terrain d'un évènement ou du héros est égale à 0
# Le terrain sur lequel il marche sera conforme à ce qui a été réglé dans les chipsets
# Si la variable @walk_terrain est comprise entre 1 et 7
# Le terrain sera celui indiqué par la variable sans tenir compte des chipsets
# Par contre si la variable @walk_terrain > 7 le terrain utilisé sera un terrain spécial
# Si @walk_terrain = 8, ce sera le terrain spécial 1
# Si @walk_terrain = 9, ce sera le terrain spécial 2
# etc ...
# Moi j'en ai mis que 2 mais vous pouvez en mettre à volonté
# Vous pouvez initialiser les évènements des alliés lignes 120 à 138 de la même façon que pour le héros
class Game_Map
Default_Gravity = 10
Default_Depth = [100, 100, 0, 0, 0]
Default_Terrain = [{}, {}]
Default_Terrain[0][ 1] = ["Data System/StepAudio_Terre01_a" , 100, 100]
Default_Terrain[0][-1] = ["Data System/StepAudio_Terre01_b" , 100, 100]
Default_Terrain[1][ 1] = ["Data System/StepGraphic_Terre01" , 0, 40]
Default_Terrain[0][ 2] = ["Data System/StepAudio_Herbe01_a" , 100, 100]
Default_Terrain[0][-2] = ["Data System/StepAudio_Herbe01_b" , 100, 100]
Default_Terrain[1][ 2] = ["Data System/StepGraphic_Herbe01" , 40, 60]
Default_Terrain[0][ 3] = ["Data System/StepAudio_Bois01_a" , 100, 100]
Default_Terrain[0][-3] = ["Data System/StepAudio_Bois01_b" , 100, 100]
Default_Terrain[1][ 3] = ["" , 0, 0]
Default_Terrain[0][ 4] = ["Data System/StepAudio_Pierre01_a", 100, 100]
Default_Terrain[0][-4] = ["Data System/StepAudio_Pierre01_b", 100, 100]
Default_Terrain[1][ 4] = ["" , 0, 0]
Default_Terrain[0][ 5] = ["Data System/StepAudio_Métal01_a" , 100, 100]
Default_Terrain[0][-5] = ["Data System/StepAudio_Métal01_b" , 100, 100]
Default_Terrain[1][ 5] = ["" , 0, 0]
Default_Terrain[0][ 6] = ["Data System/StepAudio_Neige01_a" , 100, 100]
Default_Terrain[0][-6] = ["Data System/StepAudio_Neige01_b" , 100, 100]
Default_Terrain[1][ 6] = ["Data System/StepGraphic_Neige01" , 60, 80]
Default_Terrain[0][ 7] = ["Data System/StepAudio_Eau01_a" , 100, 100]
Default_Terrain[0][-7] = ["Data System/StepAudio_Eau01_b" , 100, 100]
Default_Terrain[1][ 7] = ["Data System/StepGraphic_Eau01" , 40, 60]
Special_Terrain = [{}, {}]
Special_Terrain[0][ 1] = ["Data System/StepAudioS1" , 100, 100]
Special_Terrain[0][-1] = ["Data System/StepAudioS1" , 100, 80]
Special_Terrain[1][ 1] = ["" , 0, 0]
Special_Terrain[0][ 2] = ["Data System/StepAudioS2" , 100, 100]
Special_Terrain[0][-2] = ["Data System/StepAudioS2" , 100, 80]
Special_Terrain[1][ 2] = ["" , 0, 0]
def setup_train_actors
map_event = RPG::Event.new(0, 0)
for i in 1001..1003
map_event.id = i
@events[i] = Game_Event.new(0, map_event)
@events[i].position = 8
@events[i].move_speed = 4
@events[i].move_frequency = 6
@events[i].move_animation_speed = 0
@events[i].jump_power = 1.5
@events[i].zoom = 1
@events[i].follow_event_id = 0
@events[i].follow_distance = 1.5
@events[i].step_anime = false
@events[i].spec_anime = false
@events[i].walk_anime = true
@events[i].jump_anime = false
@events[i].fall_anime = false
@events[i].down_anime = false
@events[i].shadow = true
@events[i].walk_steps = 2
@events[i].walk_terrain = 0
@events[i].walk_audio = true
@events[i].walk_graphics = true
end
$game_party.train_actors($game_party.train_actors_visible)
end
end
# Pour que les alliés soient visibles par défaut, remplacez la ligne 152 :
# @train_actors_visible = false par @train_actors_visible = true
class Game_Party
MAX_DISTANCE = 9999999 * 128
attr_reader :distance, :train_actors_visible
alias amsu_game_party_initialize initialize
def initialize
amsu_game_party_initialize
@distance = @real_distance = 0
@train_actors_visible = false
end
def train_actors(visible)
@train_actors_visible = visible
for i in 1001..1003
actor = $game_party.actors[i-1000]
if $game_party.train_actors_visible and actor
$game_map.events[i].move_type = 2
$game_map.events[i].character_name = actor.character_name
$game_map.events[i].character_hue = actor.character_hue
else; $game_map.events[i].move_type = 4
end
end
end
def increase_distance
@real_distance = Math.min(@real_distance+2**$game_player.real_move_speed, MAX_DISTANCE)
@distance = (@real_distance / 128.0).round
end
end
class Game_Map
attr_reader :tile_events, :amsu_height, :amsu_depth, :walk_audio, :walk_graphics,
:gravity, :zoom_max, :zoom_min, :zoom_factor, :zoom_origin, :zoom_default
alias amsu_game_map_setup setup
def setup(map_id)
setup_data_system(map_id)
amsu_game_map_setup(map_id)
setup_train_actors
end
def setup_data_system(map_id = @map_id)
@tile_events = []
filename = sprintf("Data System/Map%03dH.rxdata", map_id)
if FileTest.exist?(filename)
@gravity, @floors = load_data(filename)
@gravity, @amsu_height = @gravity * 0.1, true
else; @gravity, @amsu_height = Default_Gravity * 0.1, false
end
filename = sprintf("Data System/Map%03dD.rxdata", map_id)
if FileTest.exist?(filename)
depth = load_data(filename)
@zoom_max = depth[0] * 0.01
@zoom_min = depth[1] * 0.01
@zoom_factor = depth[2] * 0.001
@zoom_origin = depth[3] * 0.01
@zoom_default = depth[4] * 0.01
@amsu_depth = true
else; @amsu_depth = false
end
filename = sprintf("Data System/Map%03dT.rxdata", map_id)
terrain = (FileTest.exist?(filename) ? load_data(filename) : Default_Terrain)
for i in 1..Special_Terrain[1].size; j = i + 7
terrain[0][j] = Special_Terrain[0][i]
terrain[0][-j] = Special_Terrain[0][-i]
terrain[1][j] = Special_Terrain[1][i]
end
@walk_audio, @walk_graphics = {}, terrain[1]
terrain[0].each_key {|i| @walk_audio[i] = RPG::AudioFile.new(*terrain[0][i])}
end
def scroll_down(d) ; @display_y = Math.min(@display_y+d, (self.height-15)*128); end
def scroll_left(d) ; @display_x = Math.max(@display_x-d, 0); end
def scroll_right(d); @display_x = Math.min(@display_x+d, (self.width-20)*128); end
def scroll_up(d) ; @display_y = Math.max(@display_y-d, 0); end
def passable?(x, y, d, self_event = nil)
return false unless valid?(x, y)
bit = d / 2 - 1
for event in @tile_events
if !event.through and event != self_event and event.x == x and event.y == y
if @passages[event.tile_id][bit] == 1 or @passages[event.tile_id] & 0x0f == 0x0f
return false
elsif @priorities[event.tile_id] == 0
return true
end
end
end
for i in 0..2
tile_id = data[x, y, 2-i]
if !tile_id or @passages[tile_id][bit] == 1 or @passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
end
return true
end
def bush?(x, y)
if @map_id != 0
for event in @tile_events
if event.x == x and event.y == y
return true if @passages[event.tile_id][6] == 1
end
end
for i in 0..2
tile_id = data[x, y, 2-i]
if !tile_id
return false
elsif @passages[tile_id][6] == 1
return true
end
end
end
return false
end
def counter?(x, y)
if @map_id != 0
for event in @tile_events
if event.x == x and event.y == y
return true if @passages[event.tile_id][7] == 1
end
end
for i in 0..2
tile_id = data[x, y, 2-i]
if !tile_id
return false
elsif @passages[tile_id][7] == 1
return true
end
end
end
return false
end
def terrain_tag(x, y)
if @map_id != 0
for event in @tile_events
if event.x == x and event.y == y
return @terrain_tags[event.tile_id] if @terrain_tags[event.tile_id] > 0
end
end
for i in 0..2
tile_id = data[x, y, 2-i]
if !tile_id
return 0
elsif @terrain_tags[tile_id] > 0
return @terrain_tags[tile_id]
end
end
end
return 0
end
def floor(x, y, self_event = nil)
if @amsu_height
for event in @tile_events
if !event.through and event != self_event and event.x == x and event.y == y
return event.floor if event.floor != 0
end
end
return @floors[x, y] if @floors[x, y]
end
return 0
end
end
class Game_Character
@@names_cache ||= {}
attr_reader :x2, :y2, :z, :real_zoom, :real_move_speed
attr_accessor :character_hue, :pattern_max, :direction_max, :position, :through,
:move_frequency, :move_type, :move_animation_speed, :real_z, :floor, :jump_power,
:zoom, :follow_event_id, :follow_distance, :dash, :trails, :shadow,
:step_anime, :spec_anime, :walk_anime, :jump_anime, :fall_anime, :down_anime,
:special_trail_name, :special_trail_hue, :special_trail_blend_type,
:special_trail_opacity, :special_trail_duration, :special_trail_activate,
:walk_steps, :walk_terrain, :walk_audio, :walk_graphics
alias amsu_game_character_initialize initialize
def initialize
amsu_game_character_initialize
@x2 = @y2 = 0
@phase, @original_character_name = 0, ""
@move_animation_speed, @real_move_speed, @real_direction = 0, 4, 2
@position, @direction_max, @pattern_max = 8, 4, 4
@z, @real_z, @floor, @fall_count, @jump_power = 0, 0, 0, 0, 1.5
@zoom = @real_zoom = 1
@follow_event_id, @follow_distance = 0, 1.5
@dash = @spec_anime = @jump_anime = @fall_anime = @down_anime = false
@trails, @shadow = [], false
@special_trail_name, @special_trail_hue = "", 0
@special_trail_activate, @special_trail_blend_type = false, 0
@special_trail_opacity, @special_trail_duration = 255, 40
@walk_steps, @walk_terrain, @walk_audio, @walk_graphics = 0, 0, true, true
end
def character_name=(n); @original_character_name = @character_name = n; end
def moving?; @real_x != @x2 or @real_y != @y2; end
def new_jumping?; @z != 0 or @real_z != 0; end
def passable?(x, y, d)
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
return false unless $game_map.valid?(new_x, new_y)
return true if @through
y_plus = change_floor(@x, @y, new_x, new_y, @real_z/128.0, d)
if y_plus == 0
return false unless $game_map.passable?(x, y, d, self)
return false unless $game_map.passable?(new_x, new_y, 10 - d)
else
new_y += y_plus
return false unless $game_map.passable?(new_x, new_y, 0)
end
return event_passable?(new_x, new_y)
end
def event_passable?(new_x, new_y)
for event in $game_map.events.values
if event.x == new_x and event.y == new_y and !event.character_name.empty?
if @id < 1000 and event.id > 1000
event.move_away_from_event(@id, 7) unless event.moving?
else return false unless event.through
end
end
end
if $game_player.x == new_x and $game_player.y == new_y
return false if !$game_player.through and !@character_name.empty?
end
return true
end
def change_floor(last_x, last_y, new_x, new_y, z, d)
return 0 unless $game_map.amsu_height
last_floor = $game_map.floor(last_x, last_y, self)
new_floor = $game_map.floor(new_x, new_y, self)
if d != 0 and new_floor != last_floor
if new_floor < 0
if d == 2 or d == 8; sens = d == 2 ? 1 : -1
else; sens = (new_floor == -4 or new_floor == -d/2) ? -1 : 1
end
else
if d == 2 or d == 8; return 0
else; sens = new_floor < last_floor ? 1 : -1
end
end
y_plus = 0
loop do
y_plus += sens
new_floor = $game_map.floor(new_x, new_y+y_plus, self)
break if new_floor >= 0 and (sens == 1 ? (last_floor <= new_floor+y_plus) : (last_floor >= new_floor+y_plus))
end
return y_plus if $game_map.valid?(new_x, new_y+y_plus) and new_floor != last_floor and new_floor < last_floor+z
end
return 0
end
def need_new_jump?(d = @real_direction)
return false if !$game_map.amsu_height or d % 2 == 1
new_x = @x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = @y + (d == 2 ? 1 : d == 8 ? -1 : 0)
new_z = @z + @jump_power * (2-$game_map.gravity) * @zoom
y_plus = change_floor(@x, @y, new_x, new_y, new_z, d)
return (y_plus < 0 ? passable?(new_x, new_y + y_plus, 0) : false)
end
def lock
return if @locked
@prelock_direction, @locked = @direction, true
turn_toward_event(0)
end
def moveto(x, y)
@x, @y = x % $game_map.width, y % $game_map.height
@real_x = @x2 = @x * 128
@real_y = @y2 = @y * 128
@prelock_direction = 0
update_zoom
end
def screen_y
sy = (@real_y - $game_map.display_y + 3) / 4 + 32
if jumping?
n = @jump_count >= @jump_peak ? (@jump_count-@jump_peak) : (@jump_peak-@jump_count)
sy -= (@jump_peak * @jump_peak - n * n) / 2
elsif new_jumping?; sy -= @real_z / 4.0
end
return sy
end
def screen_z(height = 0)
return 999 if @always_on_top
z = (@real_y - $game_map.display_y + 3) / 4 + 32
return z+(@tile_id > 0 ? ($game_map.priorities[@tile_id]*32-32) : (height > 32 ? 31 : 0))
end
def bush_depth
return 0 if @tile_id > 0 or @always_on_top
return (!jumping? and !new_jumping? and $game_map.bush?(@x, @y)) ? 12 : 0
end
def update
if jumping? ; update_jump
elsif new_jumping?; update_new_jump
elsif moving? ; update_move
else ; update_stop
end
update_animation
update_zoom
update_character_name
update_walk
return if @phase == 6
(@wait_count -= 1; return) if @wait_count > 0
(move_type_custom; return) if @move_route_forcing
return if @starting or lock?
return if @id != 0 and (@move_type == 1 or @move_type == 2) and updating_new_jump?
if (@move_frequency == 6 and !moving?) or (@stop_count > (40-@move_frequency*2)*(6-@move_frequency))
case @move_type
when 1; move_type_random
when 2; move_type_toward_event
when 3; move_type_custom
when 4; move_type_fusion_with_event
end
end
end
def update_jump
@trails.push([3]) if special_trail_activate
@jump_count -= 1
@real_x = (@real_x * @jump_count + @x2) / (@jump_count + 1)
@real_y = (@real_y * @jump_count + @y2) / (@jump_count + 1)
@phase = (@jump_count > @jump_peak ? 4 : 5)
@anime_count += 1.5 if (@phase == 5 ? @fall_anime : @jump_anime)
if @jump_count == 0 and @walk_steps > 0
make_step(0, true)
make_step(1, true)
end
end
def update_new_jump
if @z * 128 > @real_z
distance = 48 * Math.max(1-@real_z/@z/128.0, 0.1) * $game_map.gravity * @real_zoom
@real_z = Math.min(@real_z + distance, @z * 128)
else
@fall_count += 2 * $game_map.gravity
distance = @fall_count * $game_map.gravity * @real_zoom
@real_z = Math.max(@real_z - distance, 0)
@z = @real_z/128.0
end
@phase = (@z * 128 > @real_z ? 4 : 5)
@anime_count += 1.5 if (@phase == 5 ? @fall_anime : @jump_anime)
if @real_z == 0
if @down_anime and @fall_count * $game_map.gravity > 48
@phase, @pattern, @anim_count = 6, 0, 0
end
@fall_count = 0
if @walk_steps > 0
make_step(0, true)
make_step(1, true)
end
end
update_move
end
def updating_new_jump?
if new_jumping?
last_direction, @direction = @direction, @real_direction
move_forward(3)
@direction = last_direction
elsif need_new_jump?; new_jump
else; return false
end ; return true
end
def update_move
@trails.push([3]) if special_trail_activate
distance = 2 ** @real_move_speed
@y2 = Math.max(@y2 - distance, @y * 128) if @y2 > @y * 128 and !passable?(@x, @y, 2)
@x2 = Math.min(@x2 + distance, @x * 128) if @x2 < @x * 128 and !passable?(@x, @y, 4)
@x2 = Math.max(@x2 - distance, @x * 128) if @x2 > @x * 128 and !passable?(@x, @y, 6)
@y2 = Math.min(@y2 + distance, @y * 128) if @y2 < @y * 128 and !passable?(@x, @y, 8)
@real_y = Math.min(@real_y + distance, @y2) if @y2 > @real_y
@real_x = Math.max(@real_x - distance, @x2) if @x2 < @real_x
@real_x = Math.min(@real_x + distance, @x2) if @x2 > @real_x
@real_y = Math.max(@real_y - distance, @y2) if @y2 < @real_y
unless new_jumping? or @phase == 6
@phase = @dash ? 3 : 2
@anime_count += (@walk_anime ? 1.5 : @step_anime ? 1 : 0)
end
end
def update_stop
if @phase == 1 or @phase == 6
@anime_count += 1.5
elsif @spec_anime and @stop_count > 100 and @stop_count % (rand(1000)+1) == 0
@phase, @pattern = 1, 0
else
@phase = 0
if @step_anime; @anime_count += 1
elsif @pattern != @original_pattern; @anime_count += 1.5
end
@stop_count += 1 unless @starting or lock?
end
end
def update_animation
mas = (@move_animation_speed == 0 ? @move_speed : @move_animation_speed) + (@dash ? 1 : 0)
if @anime_count * @pattern_max/4.0 > 18 - mas * 2
if @phase == 0 and !@step_anime
@pattern = @original_pattern
else
@pattern = (@pattern + 1) % @pattern_max
if @pattern == 0 and (@phase == 1 or @phase == 6)
@pattern, @phase = @original_pattern, 0
end
end
@anime_count = 0
end
end
def update_zoom
if $game_map.amsu_depth
if @last_real_y != @real_y or @last_map_id != $game_map.map_id
@last_real_y, @last_map_id = @real_y, $game_map.map_id
default, factor = $game_map.zoom_default+1, $game_map.zoom_factor
origin = (1-$game_map.zoom_origin)*($game_map.height-1)-@real_y/128.0
@depth_zoom = Math.middle($game_map.zoom_min, default-origin*factor, $game_map.zoom_max)
@depth_speed = @depth_zoom * (1.5 - @depth_zoom/2)
end
@real_zoom = @zoom * @depth_zoom
@real_move_speed = Math.middle(0, (@move_speed+(@dash ?1:0))*@depth_speed, 7)
else
@real_zoom = @zoom
@real_move_speed = Math.middle(0, @move_speed+(@dash ?1:0), 7)
end
end
def update_character_name
if @last_character_name != @original_character_name or @last_phase != @phase
@last_character_name, @last_phase = @original_character_name, @phase
name = case @phase
when 1; "#{@original_character_name}_spec"
when 2; "#{@original_character_name}_walk"
when 3; "#{@original_character_name}_dash"
when 4; "#{@original_character_name}_jump"
when 5; "#{@original_character_name}_fall"
when 6; "#{@original_character_name}_down"
else ; @original_character_name
end
unless @@names_cache[name]
@@names_cache[name] = name
RPG::Cache.character(name, 0) rescue @@names_cache[name] = @original_character_name
end
@character_name = @@names_cache[name]
end
end
def update_walk
if @pattern != @last_pattern
@last_pattern = @pattern
return if @walk_steps == 0 or @phase == 1 or @phase == 4 or @phase == 5 or @phase == 6
if screen_x.between?(0, 640) and screen_y.between?(0, 480)
n = Math.max(@pattern_max / @walk_steps, 1)
make_step(@pattern/n%2, @dash) if @pattern % n == 1 or n == 1
end
end
end
def make_step(step, dash)
terrain = @walk_terrain == 0 ? terrain_tag : @walk_terrain
return if terrain == 0
if @walk_audio
audio = $game_map.walk_audio[terrain * (step == 0 ? 1 : -1)]
last_volume = audio.volume
audio.volume *= 0.8 unless dash
$game_system.se_play(audio)
audio.volume = last_volume
end
if @walk_graphics
graphics = $game_map.walk_graphics[terrain]
picture = graphics[0]
duration = graphics[(dash ? 2 : 1)]
step += 2 if dash
@trails.push([2, picture, duration, step]) if !picture.empty? and duration > 0
end
end
def move_type_random
if @move_frequency == 6
speed = Math.max(@real_move_speed, 4)
case rand(10)
when 0; move_random(speed)
when 1..8
last_direction, @direction = @direction, @real_direction
move_forward(speed)
@direction = last_direction
when 9; @stop_count = 0
end
else
case rand(6)
when 0..3; move_random(7)
when 4
last_direction, @direction = @direction, @real_direction
move_forward(7)
@direction = last_direction
when 5; @stop_count = 0
end
end
end
def move_type_toward_event
event = (@follow_event_id == 0) ? $game_player : $game_map.events[@follow_event_id]
return unless event
sx, sy= (@x2 - event.x2).abs, (@y2 - event.y2).abs
distance = Math.hypot(sx, sy)
if distance > 15 * 128
@dash = false
@id > 1000 ? moveto($game_player.x, $game_player.y) : move_type_random
return
end
@dash = (distance > @follow_distance * 256)
speed = @move_frequency == 6 ? @real_move_speed : 7
if distance > @follow_distance * 128
move_toward_event(@follow_event_id, speed)
elsif distance < @follow_distance * 128 - 2**speed * 2
move_away_from_event(@follow_event_id, 7)
elsif !moving?
turn_toward_event(@follow_event_id)
end
end
def move_type_custom
return if jumping? or moving?
while @move_route_index < @move_route.list.size
command = @move_route.list[@move_route_index]
case command.code
when 0
if @move_route.repeat; @move_route_index = 0
else; @stop_count = 0
if @move_route_forcing
@move_route, @move_route_index = @original_move_route, @original_move_route_index
@move_route_forcing, @original_move_route = false
end
end ; return
when 1; move_down(true, 7)
when 2; move_left(true, 7)
when 3; move_right(true, 7)
when 4; move_up(true, 7)
when 5; move_lower_left(true, 7)
when 6; move_lower_right(true, 7)
when 7; move_upper_left(true, 7)
when 8; move_upper_right(true, 7)
when 9; move_random(7)
when 10; move_toward_event(0, 7)
when 11; move_away_from_event(0, 7)
when 12; move_forward(7)
when 13; move_backward(7)
when 14; jump(command.parameters[0], command.parameters[1])
when 15; @wait_count = command.parameters[0] * 2 - 1
when 16; turn_down
when 17; turn_left
when 18; turn_right
when 19; turn_up
when 20; turn_right_90
when 21; turn_left_90
when 22; turn_180
when 23; turn_right_or_left_90
when 24; turn_random
when 25; turn_toward_event(0)
when 26; turn_away_from_event(0)
when 27; $game_switches[command.parameters[0]], $game_map.need_refresh = true, true
when 28; $game_switches[command.parameters[0]], $game_map.need_refresh = false, true
when 29; @move_speed = command.parameters[0]
when 30; @move_frequency = command.parameters[0]
when 31; @walk_anime = true
when 32; @walk_anime = false
when 33; @step_anime = true
when 34; @step_anime = false
when 35; @direction_fix = true
when 36; @direction_fix = false
when 37; @through = true
when 38; @through = false
when 39; @always_on_top = true
when 40; @always_on_top = false
when 41
@tile_id = 0
self.character_name, @character_hue = command.parameters[0], command.parameters[1]
if @original_direction != command.parameters[2]
@original_direction = @direction = command.parameters[2]
@prelock_direction = 0
end
if @original_pattern != command.parameters[3]
@original_pattern = @pattern = command.parameters[3]
end
when 42; @opacity = command.parameters[0]
when 43; @blend_type = command.parameters[0]
when 44; $game_system.se_play(command.parameters[0])
when 45; eval(command.parameters[0])
end
return if command.code < 15 and !@move_route.skippable and !moving? and !jumping?
@move_route_index += 1
return if command.code < 27
end
end
def move_type_fusion_with_event
event = (@follow_event_id == 0) ? $game_player : $game_map.events[@follow_event_id]
return unless event
@x, @y, @x2, @y2 = event.x, event.y, event.x2, event.y2
if @character_name.empty?; @real_x, @real_y = @x2, @y2
else
sx, sy = (@real_x - event.real_x).abs, (@real_y - event.real_y).abs
speed = (@move_frequency == 6) ? @real_move_speed : 7
if Math.hypot(sx, sy) < 2**speed * 2; self.character_name = ""
else; turn_toward_event(@follow_event_id)
end
end
end
def move_down(turn_enabled = true, speed = @real_move_speed)
turn_down if turn_enabled
y_max = @y + 1
unless passable?(@x, @y, 2)
if @y2 == @y*128
check_event_trigger_touch(@x, @y+1)
return false
else
speed -= 1
y_max -= 1
end
end
turn_down
last_x, last_y = @x, @y
@y2 = Math.min(@y2+2**speed, y_max*128)
@y = (@y2/128.0).round
if $game_map.amsu_height
y_plus = change_floor(last_x, last_y, @x, @y, @z, 2)
@y += y_plus
@y2 += y_plus * 128
@real_y += y_plus * 128
@z += y_plus
@real_z += y_plus * 128
end
increase_steps
return true
end
def move_left(turn_enabled = true, speed = @real_move_speed)
turn_left if turn_enabled
x_max = @x - 1
unless passable?(@x, @y, 4)
if @x2 == @x*128
check_event_trigger_touch(@x-1, @y)
return false
else
speed -= 1
x_max += 1
end
end
turn_left
last_x, last_y = @x, @y
@x2 = Math.max(@x2-2**speed, x_max*128)
@x = (@x2/128.0).round
if $game_map.amsu_height
y_plus = change_floor(last_x, last_y, @x, @y, @z, 4)
@y += y_plus
@y2 += y_plus * 128
@real_y += y_plus * 128
@z += y_plus
@real_z += y_plus * 128
end
increase_steps
return true
end
def move_right(turn_enabled = true, speed = @real_move_speed)
turn_right if turn_enabled
x_max = @x + 1
if passable?(@x, @y, 6) == false
if @x2 == @x*128
check_event_trigger_touch(@x+1, @y)
return false
else
speed -= 1
x_max -= 1
end
end
turn_right
last_x, last_y = @x, @y
@x2 = Math.min(@x2+2**speed, x_max*128)
@x = (@x2/128.0).round
if $game_map.amsu_height
y_plus = change_floor(last_x, last_y, @x, @y, @z, 6)
@y += y_plus
@y2 += y_plus * 128
@real_y += y_plus * 128
@z += y_plus
@real_z += y_plus * 128
end
increase_steps
return true
end
def move_up(turn_enabled = true, speed = @real_move_speed)
turn_up if turn_enabled
y_min = @y - 1
if passable?(@x, @y, 8) == false
if @y2 == @y*128
check_event_trigger_touch(@x, @y-1)
return false
else
speed -= 1
y_min += 1
end
end
turn_up
last_x, last_y = @x, @y
@y2 = Math.max(@y2-2**speed, y_min*128)
@y = (@y2/128.0).round
if $game_map.amsu_height
y_plus = change_floor(last_x, last_y, @x, @y, @z, 8)
@y += y_plus
@y2 += y_plus * 128
@real_y += y_plus * 128
@z += y_plus
@real_z += y_plus * 128
end
increase_steps
return true
end
def move_lower_left(turn_enabled = true, speed = @real_move_speed)
turn_lower_left if turn_enabled
move1 = move_down(false, speed)
move2 = move_left(false, speed)
turn_lower_left if move1 and move2
end
def move_lower_right(turn_enabled = true, speed = @real_move_speed)
turn_lower_right if turn_enabled
move1 = move_down(false, speed)
move2 = move_right(false, speed)
turn_lower_right if move1 and move2
end
def move_upper_left(turn_enabled = true, speed = @real_move_speed)
turn_upper_left if turn_enabled
move1 = move_up(false, speed)
move2 = move_left(false, speed)
turn_upper_left if move1 and move2
end
def move_upper_right(turn_enabled = true, speed = @real_move_speed)
turn_upper_right if turn_enabled
move1 = move_up(false, speed)
move2 = move_right(false, speed)
turn_upper_right if move1 and move2
end
def move_middle
if @x2 > @x * 128
if @y2 > @y * 128; move_upper_left
elsif @y2 < @y * 128; move_lower_left
else; move_left
end
elsif @x2 < @x * 128
if @y2 > @y * 128; move_upper_right
elsif @y2 < @y * 128; move_lower_right
else; move_right
end
else
if @y2 > @y * 128; move_up
elsif @y2 < @y * 128; move_down
end
end
@x2, @y2 = @x * 128, @y * 128
end
def move_random(speed = @real_move_speed)
case rand(8)
when 0; move_lower_left(false, speed)
when 1; move_down(false, speed)
when 2; move_lower_right(false, speed)
when 3; move_left(false, speed)
when 4; move_upper_left(false, speed)
when 5; move_right(false, speed)
when 6; move_upper_right(false, speed)
when 7; move_up(false, speed)
end
end
def move_toward_event(event_id = 0, speed = @real_move_speed)
event = (event_id == 0) ? $game_player : $game_map.events[event_id]
return unless event
sx, sy = @x2 - event.x2, @y2 - event.y2
return if sx == 0 and sy == 0
abs_sx, abs_sy = sx.abs, sy.abs
if (abs_sx - abs_sy).abs <= 128
if sy > 0; sx > 0 ? move_upper_left(true, speed) : move_upper_right(true, speed)
else; sx > 0 ? move_lower_left(true, speed) : move_lower_right(true, speed)
end
end
if !moving? and !need_new_jump?
if abs_sx > abs_sy
sx > 0 ? move_left(true, speed) : move_right(true, speed)
if !moving? and !need_new_jump? and sy != 0
sy > 0 ? move_up(true, 7) : move_down(true, 7)
end
else
sy > 0 ? move_up(true, speed) : move_down(true, speed)
if !moving? and !need_new_jump? and sx != 0
sx > 0 ? move_left(true, 7) : move_right(true, 7)
end
end
move_random(7) if !moving? and !need_new_jump?
end
end
def move_away_from_event(event_id = 0, speed = @real_move_speed)
event = (event_id == 0) ? $game_player : $game_map.events[event_id]
return unless event
sx, sy = @x2 - event.x2, @y2 - event.y2
(move_random(7); return) if sx == 0 and sy == 0
abs_sx, abs_sy = sx.abs, sy.abs
if (abs_sx - abs_sy).abs <= 128
if sy > 0; sx > 0 ? move_lower_right(true, speed) : move_lower_left(true, speed)
else; sx > 0 ? move_upper_right(true, speed) : move_upper_left(true, speed)
end
end
if !moving? and !need_new_jump?
if abs_sx > abs_sy
sx > 0 ? move_right(true, speed) : move_left(true, speed)
if !moving? and !need_new_jump? and sy != 0
sy > 0 ? move_down(true, 7) : move_up(true, 7)
end
else
sy > 0 ? move_down(true, speed) : move_up(true, speed)
if !moving? and !need_new_jump? and sx != 0
sx > 0 ? move_right(true, 7) : move_left(true, 7)
end
end
move_random(7) if !moving? and !need_new_jump?
end
end
def move_forward(speed = @real_move_speed)
case @direction
when 1; move_lower_left(false, speed)
when 2; move_down(false, speed)
when 3; move_lower_right(false, speed)
when 4; move_left(false, speed)
when 5; move_upper_left(false, speed)
when 6; move_right(false, speed)
when 7; move_upper_right(false, speed)
when 8; move_up(false, speed)
end
end
def move_backward(speed = @real_move_speed)
last_direction_fix, @direction_fix = @direction_fix, true
case @direction
when 1; move_upper_right(false, speed)
when 2; move_up(false, speed)
when 3; move_upper_left(false, speed)
when 4; move_right(false, speed)
when 5; move_lower_right(false, speed)
when 6; move_left(false, speed)
when 7; move_lower_left(false, speed)
when 8; move_down(false, speed)
end
@direction_fix = last_direction_fix
end
def new_jump
@z += @jump_power * (2-$game_map.gravity) * @real_zoom
if @walk_steps > 0
make_step(0, true)
make_step(1, true)
end
@stop_count = 0
end
def jump(x_plus = 0, y_plus = 0)
if x_plus != 0 or y_plus != 0
if x_plus.abs > y_plus.abs; x_plus < 0 ? turn_left : turn_right
else; y_plus < 0 ? turn_up : turn_down
end
end
until($game_map.valid?(@x + x_plus, @y)); x_plus += (x_plus > 0 ? -1 : 1); end
until($game_map.valid?(@x, @y + y_plus)); y_plus += (y_plus > 0 ? -1 : 1); end
loop do
new_x, new_y = @x + x_plus, @y + y_plus
if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
if @walk_steps > 0
make_step(0, true)
make_step(1, true)
end
straighten
@x += x_plus
@x2 += x_plus * 128
@y += y_plus
@y2 += y_plus * 128
@jump_peak = 10 + Math.hypot(x_plus, y_plus).round - @move_speed
@jump_count = @jump_peak * 2
@stop_count = 0
return
end
x_plus -= 1 if x_plus > 0
x_plus += 1 if x_plus < 0
y_plus -= 1 if y_plus > 0
y_plus += 1 if y_plus < 0
end
end
def turn_down
@real_direction = 2
@direction, @stop_count = 2, 0 unless @direction_fix
end
def turn_left
@real_direction = 4
@direction, @stop_count = 4, 0 unless @direction_fix
end
def turn_right
@real_direction = 6
@direction, @stop_count = 6, 0 unless @direction_fix
end
def turn_up
@real_direction = 8
@direction, @stop_count = 8, 0 unless @direction_fix
end
def turn_lower_left
@real_direction = 1
unless @direction_fix
@direction = @direction_max==4 ? @direction==6 ? 4 : @direction==8 ? 2 : @direction : 1
@stop_count = 0
end
end
def turn_lower_right
@real_direction = 3
unless @direction_fix
@direction = @direction_max==4 ? @direction==4 ? 6 : @direction==8 ? 2 : @direction : 3
@stop_count = 0
end
end
def turn_upper_left
@real_direction = 5
unless @direction_fix
@direction = @direction_max==4 ? @direction==6 ? 4 : @direction==2 ? 8 : @direction : 5
@stop_count = 0
end
end
def turn_upper_right
@real_direction = 7
unless @direction_fix
@direction = @direction_max==4 ? @direction==4 ? 6 : @direction==2 ? 8 : @direction : 7
@stop_count = 0
end
end
def turn_right_90
case @direction
when 1; turn_upper_left
when 2; turn_left
when 3; turn_lower_left
when 4; turn_up
when 5; turn_upper_right
when 6; turn_down
when 7; turn_lower_right
when 8; turn_right
end
end
def turn_left_90
case @direction
when 1; turn_lower_right
when 2; turn_right
when 3; turn_upper_right
when 4; turn_down
when 5; turn_lower_left
when 6; turn_up
when 7; turn_upper_left
when 8; turn_left
end
end
def turn_180
case @direction
when 1; turn_upper_right
when 2; turn_up
when 3; turn_upper_left
when 4; turn_right
when 5; turn_lower_right
when 6; turn_left
when 7; turn_lower_left
when 8; turn_down
end
end
def turn_random
case rand(8)
when 0; turn_lower_left
when 1; turn_down
when 2; turn_lower_right
when 3; turn_left
when 4; turn_upper_left
when 5; turn_right
when 6; turn_upper_right
when 7; turn_up
end
end
def turn_toward_event(event_id = 0)
event = (event_id == 0) ? $game_player : $game_map.events[event_id]
return unless event
sx, sy = @x - event.x, @y - event.y
return if sx == 0 and sy == 0
if sx.abs == sy.abs
if sy > 0; sx > 0 ? turn_upper_left : turn_upper_right
else; sx > 0 ? turn_lower_left : turn_lower_right
end
else
if sx.abs > sy.abs; sx > 0 ? turn_left : turn_right
else; sy > 0 ? turn_up : turn_down
end
end
end
def turn_away_from_event(event_id = 0)
event = (event_id == 0) ? $game_player : $game_map.events[event_id]
return unless event
sx, sy = @x - event.x, @y - event.y
return if sx == 0 and sy == 0
if sx.abs == sy.abs
if sy > 0; sx > 0 ? turn_lower_right : turn_lower_left
else; sx > 0 ? turn_upper_right : turn_upper_left
end
else
if sx.abs > sy.abs; sx > 0 ? turn_right : turn_left
else; sy > 0 ? turn_down : turn_up
end
end
end
end
class Game_Event
alias amsu_game_event_initialize initialize
def initialize(map_id, event)
@name = event.name.downcase
amsu_game_event_initialize(map_id, event)
end
alias amsu_game_event_refresh refresh
def refresh
amsu_game_event_refresh
self.character_name = @character_name
@down_anime = true if @name[/\\ad/]
@fall_anime = true if @name[/\\af/]
@jump_anime = true if @name[/\\aj/]
@spec_anime = true if @name[/\\as/]
@floor = $1.to_i if @name[/\\f\[([0-9-]+)\]/]
@follow_distance = $1.to_f if @name[/\\fd\[([0-9.]+)\]/]
@follow_event_id = $1.to_i if @name[/\\fe\[([0-9-]+)\]/]
@jump_power = $1.to_f if @name[/\\jp\[([0-9.]+)\]/]
@move_animation_speed = $1.to_f if @name[/\\ma\[([0-9.]+)\]/]
@move_speed = Math.min($1.to_f, 7) if @name[/\\ms\[([0-9.]+)\]/]
@position = $1.to_i if @name[/\\p\[([1-9])\]/]
@shadow = true if @name[/\\s/]
@walk_audio = false if @name[/\\wa/]
@walk_graphics = false if @name[/\\wg/]
@walk_steps = $1.to_i if @name[/\\ws\[([0-9]+)\]/]
@walk_terrain = $1.to_i if @name[/\\wt\[([0-9-]+)\]/]
@zoom = $1.to_f if @name[/\\z\[([0-9.]+)\]/]
$game_map.tile_events.delete(self)
$game_map.tile_events.push(self) if @tile_id > 0
end
end
class Game_Player
alias amsu_game_player_moveto moveto
def moveto(x, y)
amsu_game_player_moveto(x, y)
for i in 1001..1003; $game_map.events[i].moveto(x, y); end
end
alias amsu_game_player_refresh refresh
def refresh
amsu_game_player_refresh
self.character_name = @character_name
$game_party.train_actors($game_party.train_actors_visible)
end
def update
last_x, last_y, last_real_x, last_real_y = @x, @y, @real_x, @real_y-@real_z
update_inputs if @phase != 6
super
if @real_y-@real_z > last_real_y and @real_y-@real_z-$game_map.display_y > CENTER_Y
$game_map.scroll_down(@real_y-@real_z-last_real_y)
elsif @real_y-@real_z < last_real_y and @real_y-@real_z-$game_map.display_y < CENTER_Y
$game_map.scroll_up(last_real_y-@real_y+@real_z)
end
if @real_x < last_real_x and @real_x-$game_map.display_x < CENTER_X
$game_map.scroll_left(last_real_x-@real_x)
elsif @real_x > last_real_x and @real_x-$game_map.display_x > CENTER_X
$game_map.scroll_right(@real_x-last_real_x)
end
unless moving?
if last_x != @x or last_y != @y
unless check_event_trigger_here([1,2])
unless $DEBUG and Input.press?(Input::CTRL)
@encounter_count -= 1 if @encounter_count > 0
end
end
end
if Input.trigger?(Input::C) and !new_jumping?
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
def update_inputs
unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing
case Input.dir8
when 1; move_lower_left
when 2; move_down
when 3; move_lower_right
when 4; move_left
when 6; move_right
when 7; move_upper_left
when 8; move_up
when 9; move_upper_right
end
unless new_jumping?
@dash = (Input.press?(Dash_Input) and Input.dir8 > 0)
new_jump if Input.trigger?(Jump_Input)
end
end
end
def make_step(step, dash); super; $game_party.increase_steps if @phase == 2 or @phase == 3; end
def increase_steps
super
d = $game_party.distance
$game_party.increase_distance
$game_party.check_map_slip_damage if d != $game_party.distance and $game_party.distance % 2 == 0
end
def jump(x_plus = 0, y_plus = 0); super; $game_system.se_play(Jump_Audio); end
def new_jump; super; $game_system.se_play(Jump_Audio); end
end
class Sprite_Character
alias amsu_sprite_character_initialize initialize
def initialize(viewport, character)
@trails = [Sprite_Trail.new(viewport, [1], character)]
amsu_sprite_character_initialize(viewport, character)
end
def update
super
update_bitmap
update_sprite
update_trails
update_animation0
end
def update_bitmap
if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_hue != @character.character_hue or @position != @character.position
@tile_id, @character_name, @character_hue, @position = @character.tile_id, @character.character_name, @character.character_hue, @character.position
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name, @tile_id, @character_hue)
@cw = @ch = 32
self.src_rect.set(0, 0, @cw, @ch)
self.ox, self.oy = @cw / 2, @ch
else
self.bitmap = RPG::Cache.character(@character_name, @character_hue)
@character.direction_max = (@character_name[/_dir\[([0-9]+)\]/] ? $1.to_i : 4)
@character.pattern_max = (@character_name[/_mvt\[([0-9]+)\]/] ? $1.to_i : 4)
@cw, @ch = bitmap.width/@character.pattern_max, bitmap.height/@character.direction_max
pos_x, pos_y = (@position - 1) % 3, (@position - 1) / 3
self.ox, self.oy = @cw*(pos_x/2.0)+16*(1-pos_x), @ch*(pos_y/2.0)+16*(2-pos_y)
end
@trails[0].update_shadow_size(@cw, @ch)
end
end
def update_sprite
self.visible = !@character.transparent
if @tile_id == 0
sx = @character.pattern * @cw
if @character.direction_max == 4; sy = (@character.direction - 2) / 2 * @ch
else; sy = (Math.min(@character.direction, @character.direction_max) - 1) * @ch
end
self.src_rect.set(sx, sy, @cw, @ch)
self.zoom_x = self.zoom_y = @character.real_zoom
end
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
end
def update_trails
@character.trails.each {|t| @trails.push(Sprite_Trail.new(viewport, t, @character))}
@character.trails.clear
@trails.each {|t| t.update; @trails[@trails.index(t)] = t.dispose if t.opacity == 0}
@trails.compact!
end
def update_animation0
if @character.animation_id != 0
animation($data_animations[@character.animation_id], true)
@character.animation_id = 0
end
end
end
class Sprite_Trail < Sprite
def initialize(viewport, trail, character)
super(viewport)
@character, @type = character, trail[0]
case @type
when 0; self.opacity = 0
when 1
self.bitmap = RPG::Cache.picture("Data System/Shadow")
self.ox, self.oy = bitmap.width / 2, bitmap.height - 6
when 2
self.bitmap = RPG::Cache.picture(trail[1])
@real_opacity = 255
@opacity_fade = @real_opacity.to_f / Math.max(trail[2] + 1, 1)
cw, ch = bitmap.width / 4, bitmap.height / 8
sx, sy = trail[3] * cw, (@character.direction - 1) * ch
self.src_rect.set(sx, sy, cw, ch)
self.ox, self.oy = cw / 2, ch
self.zoom_x = self.zoom_y = @character.real_zoom
@real_x, @real_y = @character.real_x, @character.real_y
@y_plus = 0
when 3
character_name = @character.special_trail_name
character_name = @character.character_name if character_name.empty?
self.bitmap = RPG::Cache.character(character_name, @character.special_trail_hue)
self.blend_type = @character.special_trail_blend_type
self.opacity = @real_opacity = @character.special_trail_opacity
@opacity_fade = @real_opacity.to_f / Math.max(@character.special_trail_duration + 1, 1)
direction_max = (character_name[/_dir\[([0-9]+)\]/] ? $1.to_i : 4)
pattern_max = (character_name[/_mvt\[([0-9]+)\]/] ? $1.to_i : 4)
cw, ch = bitmap.width / pattern_max, bitmap.height / direction_max
sx = @character.pattern % pattern_max * cw
if direction_max == 4; sy = (@character.direction - 2) / 2 * ch
else; sy = (Math.min(@character.direction, direction_max) - 1) * ch
end
self.src_rect.set(sx, sy, cw, ch)
self.ox, self.oy = cw / 2, ch
self.zoom_x = self.zoom_y = @character.real_zoom
@real_x, @real_y = @character.real_x, @character.real_y
@y_plus = @character.screen_y - (@real_y - $game_map.display_y + 3) / 4 - 32
end
end
def update_shadow_size(cw, ch); @cw, @ch = cw, ch; end
def update
case @type
when 1
self.visible = (!@character.transparent and @character.shadow and !@character.character_name.empty?)
self.x = @character.screen_x
self.y = (@character.real_y - $game_map.display_y + 3) / 4 + 32
self.zoom_x = @character.real_zoom * @cw / 40.0 / Math.max(@character.real_z / 256.0, 1)
self.zoom_y = self.zoom_x / 2.0
when 2, 3
self.visible = !@character.transparent
self.x = (@real_x - $game_map.display_x + 3)/4 + 16
self.y = (@real_y - $game_map.display_y + 3)/4 + 32 + @y_plus
@real_opacity -= @opacity_fade
self.opacity = @real_opacity.round
end
end
end
module Math
def self.min(x, value_max); x < value_max ? x : value_max; end
def self.max(x, value_min); x > value_min ? x : value_min; end
def self.middle(value_min, x, value_max); x > value_min ? x < value_max ? x : value_max : value_min; end
end
Créez un script nommé "AMS Ultimate Divers" juste au-dessus de "Main" et copiez-y ceci:
# Ce script modifie l'affichage des héros dans les menus afin qu'il soit correct
# même quand le nombre de directions ou de mouvements a été modifié.
# Si vos héros n'ont que 4 directions/mouvements ou que vous utilisez des
# systèmes de menus custom vous pouvez (probablement) supprimer ce script.
class Window_Base
def draw_actor_graphic(actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
character_name = actor.character_name
direction_max = (character_name[/_dir\[([0-9]+)\]/] ? $1.to_i : 4)
pattern_max = (character_name[/_mvt\[([0-9]+)\]/] ? $1.to_i : 4)
cw, ch = bitmap.width / pattern_max, bitmap.height / direction_max
cy = (direction_max == 8 ? ch : 0)
self.contents.blt(x - cw / 2, y - ch, bitmap, Rect.new(0, cy, cw, ch))
end
end
class Window_SaveFile
def refresh
self.contents.clear
self.contents.font.color = normal_color
name = "File #{@file_index + 1}"
self.contents.draw_text(4, 0, 600, 32, name)
@name_width = contents.text_size(name).width
if @file_exist
actor = Struct.new(:character_name, :character_hue)
for i in 0...@characters.size
draw_actor_graphic(actor.new(*@characters[i]), 300-@characters.size*32+i*64, 68)
end
hour, min, sec = @total_sec / 60 / 60, @total_sec / 60 % 60, @total_sec % 60
self.contents.draw_text(4, 8, 600, 32, sprintf("%02d:%02d:%02d", hour, min, sec), 2)
self.contents.draw_text(4, 40, 600, 32, @time_stamp.strftime("%Y/%m/%d %H:%M"), 2)
end
end
end
Et pour finir, créez un dernier script nommé "AMS Ultimate Configuration" toujours juste au-dessus de "Main" et copiez-y ce code:
# Ce script contient l'utilitaire de configuration des maps.
# Si vous ne vous en servez plus ou que vous partagez votre jeu vous pouvez le
# supprimer afin d'optimiser le temps de chargement du jeu.
if $DEBUG
class Sprite_Map < Sprite
@@cache ||= {}
AUTOTILES = [
26, 27, 32, 33, 4, 27, 32, 33, 26, 5, 32, 33, 4, 5, 32, 33,
26, 27, 32, 11, 4, 27, 32, 11, 26, 5, 32, 11, 4, 5, 32, 11,
26, 27, 10, 33, 4, 27, 10, 33, 26, 5, 10, 33, 4, 5, 10, 33,
26, 27, 10, 11, 4, 27, 10, 11, 26, 5, 10, 11, 4, 5, 10, 11,
24, 25, 30, 31, 24, 5, 30, 31, 24, 25, 30, 11, 24, 5, 30, 11,
14, 15, 20, 21, 14, 15, 20, 11, 14, 15, 10, 21, 14, 15, 10, 11,
28, 29, 34, 35, 28, 29, 10, 35, 4, 29, 34, 35, 4, 29, 10, 35,
38, 39, 44, 45, 4, 39, 44, 45, 38, 5, 44, 45, 4, 5, 44, 45,
24, 29, 30, 35, 14, 15, 44, 45, 12, 13, 18, 19, 12, 13, 18, 11,
16, 17, 22, 23, 16, 17, 10, 23, 40, 41, 46, 47, 4, 41, 46, 47,
36, 37, 42, 43, 36, 5, 42, 43, 12, 17, 18, 23, 12, 13, 42, 43,
36, 41, 42, 47, 16, 17, 46, 47, 12, 17, 42, 47, 0, 1, 6, 7]
attr_accessor :map_id
def initialize(viewport = nil)
super(viewport)
@map_id = 0
unless @@cache[0]
@@cache[0] = Bitmap.new(320, 240)
@@cache[0].font.color.set(0,0,0)
@@cache[0].font.name = "Comic Sans MS"
@@cache[0].font.size = 32
@@cache[0].fill_rect(@@cache[0].rect, Color.new(255,255,255))
@@cache[0].draw_text(@@cache[0].rect, "Veuillez sélectionner une map", 1)
end
refresh
end
def refresh; self.bitmap = load_map(@map_id); end
def load_map(map_id)
unless @@cache[map_id]
map = load_data("Data/Map%03d.rxdata" % map_id)
tileset = $data_tilesets[map.tileset_id]
bitmap = Bitmap.new(map.width*32, map.height*32)
bitmap.fill_rect(bitmap.rect, Color.new(0,0,0))
tiles = []
for x in 0...map.data.xsize
for y in 0...map.data.ysize
for z in 0...map.data.zsize
tile_id = map.data[x, y, z]
if tile_id != 0
priority = tileset.priorities[tile_id]
bmp = load_tile(tileset, tile_id)
rect = Rect.new(0, 0, 32, 32)
rect.x, rect.y = (tile_id-384)%8*32, (tile_id-384)/8*32 if tile_id >= 384
tiles.push([priority, bmp, rect])
end
end
tiles.sort! {|a, b| a[0] <=> b[0]}
tiles.each {|tile| bitmap.blt(x*32, y*32, tile[1], tile[2])}
tiles.clear
end
end
@@cache[map_id] = bitmap
end
return @@cache[map_id]
end
def load_tile(tileset, tile_id)
if tile_id < 384
autotile = RPG::Cache.autotile(tileset.autotile_names[tile_id/48-1])
key = [autotile, tile_id]
unless @@cache[key]
@@cache[key] = Bitmap.new(32, 32)
4.times do |i|; j = AUTOTILES[4 * (tile_id % 48) + i]
@@cache[key].blt(i%2*16, i/2*16, autotile, Rect.new(j%6*16, j/6*16, 16, 16))
end
end
@@cache[key]
else RPG::Cache.tileset(tileset.tileset_name)
end
end
end
class Window_Help
SPACE = " "
alias amsu_window_help_initialize initialize
def initialize
amsu_window_help_initialize
@wait_count = @text_width = 0
end
def set_text(text, align = 0)
if text != @text or align != @align
@text, @align, @wait_count, @actor = text, align, 50
w = self.contents.text_size(text).width
if w < width - 32; @text_width, w = 0, width - 32
else
@text_width = self.contents.text_size(SPACE).width + w
text += SPACE + text
w += @text_width
end
last_name, last_size = self.contents.font.name, self.contents.font.size
self.ox = 0
self.contents = Bitmap.new(w, height - 32)
self.contents.font.name = last_name
self.contents.font.size = last_size
self.contents.draw_text(0, 0, w, 32, text, align)
end
self.visible = true
@wait_count -= 1
if @text_width > 0 and @wait_count < 0
self.ox += 2
self.ox = 0 if self.ox >= @text_width
end
end
end
class Window_List < Window_Selectable
attr_accessor :path
def initialize
super(366, 82, 276, 352)
self.opacity, self.active, self.visible = 0, false, false
@path = ""
end
def refresh; @path.empty? ? refresh_map_list : refresh_file_list; end
def refresh_map_list
map_infos = load_data("Data/MapInfos.rxdata")
@maps_id, @item_max, @index = map_infos.keys.sort, map_infos.size, 0
self.contents = Bitmap.new(width - 32, @item_max*32)
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 20
self.contents.fill_rect(0, 0, 244, @item_max*32, Color.new(64,64,128,128))
for i in 0...@item_max
self.contents.fill_rect(4, i*32+6, 236, 20, Color.new(0,0,0))
map_name = " %03d - #{map_infos[@maps_id[i]].name}" % @maps_id[i]
self.contents.draw_text(4, i*32+6, 236, 20, map_name)
end
end
def map_id; @maps_id[@index]; end
def refresh_file_list
@filenames = Dir.entries(@path)
@filenames[0, 2] = "Aucun(e)"
@item_max, @index = @filenames.size, 0
self.contents = Bitmap.new(width - 32, @item_max*32)
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 20
self.contents.fill_rect(0, 0, 244, @item_max*32, Color.new(64,64,128,128))
for i in 0...@item_max
self.contents.fill_rect(4, i*32+6, 236, 20, Color.new(0,0,0))
self.contents.draw_text(4, i*32+6, 236, 20, " #{@filenames[i]}")
end
end
def filename; @index == 0 ? "" : "Data System/#{@filenames[@index]}"; end
def update_help
text = "Touche C : Valider - Touche B : Annuler"
text << " - Touche A : Aperçu" unless @path.empty?
@help_window.set_text(text, 1)
end
end
class Window_Map_Height < Window_Selectable
attr_accessor :map_id, :floors, :scale
def initialize
super(8, 64, 352, 352)
self.opacity = 0
self.active = false
@map_id, @scale = 0, 1.0
@map_sprite, @values_sprite, @help_sprite = Sprite_Map.new, Sprite.new, Sprite.new
@map_sprite.x, @map_sprite.y, @map_sprite.z = 24, 120, 100
@values_sprite.x, @values_sprite.y, @values_sprite.z = 24, 80, 100
@help_sprite.x, @help_sprite.y, @help_sprite.z = 240, 400, 100
@help_sprite.bitmap = Bitmap.new(128, 24)
@help_sprite.bitmap.font.color.set(0,0,0)
@help_sprite.bitmap.font.name = "Comic Sans MS"
@help_sprite.bitmap.font.size = 16
end
def dispose
@map_sprite.dispose
@values_sprite.bitmap.dispose if @values_sprite.bitmap
@values_sprite.dispose
@help_sprite.dispose
super
end
def draw_value(bitmap, x, y, value, color)
if value < 0
bitmap.fill_rect(x+15, y+1, 2, 1, color)
bitmap.fill_rect(x+14, y+2, 4, 1, color)
bitmap.fill_rect(x+13, y+3, 6, 1, color)
bitmap.fill_rect(x+12, y+4, 8, 1, color)
bitmap.fill_rect(x+11, y+5, 10, 1, color)
bitmap.fill_rect(x+10, y+6, 12, 1, color)
bitmap.fill_rect(x+13, y+7, 6, 24, color)
bitmap.fill_rect(x+1, y+13, 13, 6, color) if [-3, -4].include?(value)
bitmap.fill_rect(x+18, y+13, 13, 6, color) if [-2, -4].include?(value)
else
bitmap.font.color = color
bitmap.draw_text(x, y, 32, 32, value.to_s, 1)
end
end
def reset
for x in 0...@floors.xsize
for y in 0...@floors.ysize
if @floors[x, y] != 0
@floors[x, y] = 0
refresh_values(x, y)
end
end
end
end
def selected_value; @floors[@index % @column_max, @index / @column_max]; end
def selected_value=(value); @floors[@index % @column_max, @index / @column_max] = [[value, -4].max, 32767].min; end
def refresh_selected_value
x = @index % @column_max * 32 / @scale + 16 / @scale + @map_sprite.x - 40
y = @index / @column_max * 32 / @scale + 16 / @scale + @map_sprite.y - 96
x = [[x, self.ox].max, self.ox+288].min
y = [[y, self.oy].max, self.oy+288].min
self.contents.fill_rect(x, y, 32, 32, normal_color)
draw_value(self.contents, x, y, selected_value, Color.new(0,0,0))
end
def refresh_values(x = @index % @column_max, y = @index / @column_max)
@values_sprite.bitmap.fill_rect(x*32+1, y*32+1, 30, 30, Color.new(0,0,0,0))
black_color = Color.new(0,0,0)
draw_value(@values_sprite.bitmap, x*32-1, y*32, @floors[x, y], black_color)
draw_value(@values_sprite.bitmap, x*32+1, y*32, @floors[x, y], black_color)
draw_value(@values_sprite.bitmap, x*32, y*32-1, @floors[x, y], black_color)
draw_value(@values_sprite.bitmap, x*32, y*32+1, @floors[x, y], black_color)
draw_value(@values_sprite.bitmap, x*32, y*32, @floors[x, y], normal_color)
end
def refresh_map
Graphics.freeze
thread = Thread.new {loop {Graphics.update; sleep(5)}}
@map_sprite.map_id = @map_id
@map_sprite.refresh
width, height = @map_sprite.bitmap.width, @map_sprite.bitmap.height
@values_sprite.bitmap.dispose if @values_sprite.bitmap
@values_sprite.bitmap = Bitmap.new(width, height)
@values_sprite.bitmap.font.name = "Comic Sans MS"
@values_sprite.bitmap.font.size = 24
grid_color = Color.new(0,0,0)
(width/32).times {|i| @values_sprite.bitmap.fill_rect(i*32, 0, 1, height, grid_color)}
(height/32).times {|i| @values_sprite.bitmap.fill_rect(0, i*32, width, 1, grid_color)}
@item_max, @column_max = width * height / 1024, width / 32
filename = sprintf("Data System/Map%03dH.rxdata", @map_id)
if FileTest.exist?(filename)
@floors = load_data(filename)[1]
if @floors.xsize != width/32 or @floors.ysize != height/32
print(" La taille de la map a été modifié depuis la dernière sauvegarde.\n",
"Il est conseillé de re-sauvegardé même si aucune modification n'a été apporté.")
@floors.resize(width/32, height/32)
end
else; @floors = Table.new(width/32, height/32)
end
refresh_scale
refresh_help
@floors.xsize.times {|x| @floors.ysize.times {|y| refresh_values(x, y)}}
thread.kill
Graphics.transition
end
def refresh_scale
@index = self.ox = self.oy = 0
width, height = @map_sprite.bitmap.width, @map_sprite.bitmap.height
self.contents = Bitmap.new([width/@scale, 320].max, [height/@scale, 320].max)
self.contents.font.color.set(0,0,0)
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 24
@values_sprite.src_rect = @map_sprite.src_rect = Rect.new(0, 0, 320*@scale, 320*@scale)
@values_sprite.zoom_x = @values_sprite.zoom_y = @map_sprite.zoom_x = @map_sprite.zoom_y = 1 / @scale
@values_sprite.x = @map_sprite.x = 24 + [(320 - width/@scale) / 2, 0].max
@values_sprite.y = @map_sprite.y = 80 + [(320 - height/@scale) / 2, 0].max
update_cursor_rect
end
def refresh_help
@help_sprite.bitmap.fill_rect(0, 1, 40, 14, normal_color)
@help_sprite.bitmap.fill_rect(43, 1, 40, 14, normal_color)
@help_sprite.bitmap.fill_rect(86, 1, 40, 14, normal_color)
@help_sprite.bitmap.draw_text(0, 0, 42, 16, " x : "+(@index % @column_max).to_s)
@help_sprite.bitmap.draw_text(43, 0, 42, 16, " y : "+(@index / @column_max).to_s)
@help_sprite.bitmap.draw_text(86, 0, 42, 16, " z : "+selected_value.to_s)
end
def update_cursor_rect
x = @index % @column_max * 32 / @scale + @map_sprite.x - 24
y = @index / @column_max * 32 / @scale + @map_sprite.y - 80
self.ox += 32 / @scale if x > 320 + self.ox - 32 / @scale
self.ox -= 32 / @scale if x < self.ox
self.oy += 32 / @scale if y > 320 + self.oy - 32 / @scale
self.oy -= 32 / @scale if y < self.oy
self.cursor_rect.set(x - self.ox, y- self.oy, 32/@scale, 32/@scale)
@values_sprite.src_rect.y = @map_sprite.src_rect.y = self.oy * @scale
@values_sprite.src_rect.x = @map_sprite.src_rect.x = self.ox * @scale
end
def update_help
refresh_help
if self.active
text = "Touche C : Modifier valeur - Touche B : Retour - Touche A : Coller dernière valeur"
else
text = "Appuyez sur les touches Haut et Bas pour modifier la valeur."
end
@help_window.set_text(text, 1)
end
end
class Window_Height_Config < Window_Selectable
attr_accessor :map_id, :gravity, :scale
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Comic Sans MS"
@item_max, @index, @map_id, @scale = 7, 0, 0, 0
refresh
end
def refresh
self.contents.clear
self.contents.fill_rect(0, 48, 608, 1, normal_color)
self.contents.fill_rect(0, 400, 608, 1, normal_color)
self.contents.fill_rect(352, 48, 1, 352, normal_color)
self.contents.fill_rect(352, 272, 256, 1, normal_color)
self.contents.fill_rect(370, 88, 236, 20, normal_color)
self.contents.fill_rect(490, 122, 116, 20, normal_color)
self.contents.fill_rect(490, 146, 116, 20, normal_color)
self.contents.font.size = 28
self.contents.font.color = knockout_color
self.contents.draw_text(0, 0, 608, 32, "Utilitaire de configuration de la hauteur", 1)
self.contents.font.color = normal_color
self.contents.font.size = 20
self.contents.draw_text(368, 56, 240, 24, "Choix de la map :")
self.contents.draw_text(368, 120, 120, 24, "Gravité :")
self.contents.draw_text(368, 144, 120, 24, "Echelle :")
self.contents.draw_text(368, 168, 240, 24, "Modifier les valeurs", 1)
self.contents.draw_text(368, 192, 240, 24, "Remettre à zéro", 1)
self.contents.draw_text(368, 216, 240, 24, "Annuler les modifications", 1)
self.contents.draw_text(368, 240, 240, 24, "Enregistrer les modifications", 1)
self.contents.draw_text(368, 272, 240, 24, "Légende :")
self.contents.fill_rect(377, 304, 2, 10, normal_color)
self.contents.fill_rect(377, 328, 2, 10, normal_color)
self.contents.fill_rect(377, 352, 2, 10, normal_color)
self.contents.fill_rect(377, 376, 2, 10, normal_color)
self.contents.fill_rect(378, 332, 5, 2, normal_color)
self.contents.fill_rect(373, 356, 5, 2, normal_color)
self.contents.fill_rect(373, 380, 10, 2, normal_color)
self.contents.font.size = 18
self.contents.draw_text(400, 298, 208, 20, ": Mur sautable rien que par le bas")
self.contents.draw_text(400, 322, 208, 20, ": Mur sautable aussi par la droite")
self.contents.draw_text(400, 346, 208, 20, ": Mur sautable aussi par la gauche")
self.contents.draw_text(400, 370, 208, 20, ": Mur sautable de toute part")
self.contents.draw_text(0, 400, 64, 20, "Aide")
self.contents.font.color.set(0,0,0)
self.contents.font.size = 20
end
def refresh_map
map_name = load_data("Data/MapInfos.rxdata")[@map_id].name
self.contents.fill_rect(370, 88, 236, 20, normal_color)
self.contents.draw_text(370, 88, 236, 20, " %03d - #{map_name}" % @map_id)
filename = "Data System/Map%03dH.rxdata" % @map_id
@gravity = FileTest.exist?(filename) ? load_data(filename)[0] : Game_Map::Default_Gravity
refresh_values
end
def refresh_values
self.contents.fill_rect(490, 122, 116, 20, normal_color)
self.contents.fill_rect(490, 146, 116, 20, normal_color)
@gravity, @scale = [[@gravity, 1].max, 19].min, [[@scale, 0].max, 4].min
self.contents.draw_text(490, 122, 116, 20, (@gravity*0.1).to_s, 1)
self.contents.draw_text(490, 146, 116, 20, "1 / "+(2**@scale).to_s, 1)
end
def update_cursor_rect
x, y, w = 364, @index.abs * 24 + 56, 120
x += 124 if @index < 0
y += 40 if @index != 0
w += 124 if @index > 2
self.cursor_rect.set(x, y, w, 24)
end
def update_help
text = case @index
when 0; "Sélectionnez la map que vous désirez configurer."
when 1; "Plus la gravité est basse plus les bonds seront lents et hauts."
when 2; "Choisissez l'échelle de l'aperçu."
when 3; "Modifier les valeurs de cette map ?"
when 4; "Remettre les paramètres de cette map à zéro ?"
when 5; "Charger les paramètres précédents de cette map ?"
when 6; "Sauvegarder les nouveaux paramètres de cette map ?"
else ; "Appuyez sur les touches Haut et Bas pour modifier la valeur."
end
@help_window.set_text(text, 1)
end
end
class Window_Depth_Config < Window_Selectable
attr_accessor :map_id, :zoom_max, :zoom_min, :zoom_factor, :zoom_origin, :zoom_default
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Comic Sans MS"
@item_max, @index, @map_id = 9, 0, 0
@map_sprite, @cursors_sprite = Sprite_Map.new, Sprite.new
@map_sprite.x, @map_sprite.y, @map_sprite.z = 24, 120, 100
@cursors_sprite.x, @cursors_sprite.y, @cursors_sprite.z = 8, 64, 101
@cursors_sprite.bitmap = Bitmap.new(352, 352)
@cursors_sprite.bitmap.font.color.set(0,0,0)
@cursors_sprite.bitmap.font.name = "Comic Sans MS"
@cursors_sprite.bitmap.font.size = 20
refresh
end
def dispose
@map_sprite.dispose
@cursors_sprite.dispose
super
end
def refresh
self.contents.clear
self.contents.fill_rect(0, 48, 608, 1, normal_color)
self.contents.fill_rect(0, 400, 608, 1, normal_color)
self.contents.fill_rect(352, 272, 256, 1, normal_color)
self.contents.fill_rect(352, 48, 1, 352, normal_color)
self.contents.fill_rect(370, 88, 236, 20, normal_color)
self.contents.fill_rect(490, 122, 116, 20, normal_color)
self.contents.fill_rect(490, 146, 116, 20, normal_color)
self.contents.fill_rect(490, 170, 116, 20, normal_color)
self.contents.fill_rect(490, 194, 116, 20, normal_color)
self.contents.fill_rect(490, 218, 116, 20, normal_color)
self.contents.font.size = 28
self.contents.font.color = knockout_color
self.contents.draw_text(0, 0, 608, 32, "Utilitaire de configuration de la profondeur", 1)
self.contents.font.color = normal_color
self.contents.font.size = 20
self.contents.draw_text(368, 56, 240, 24, "Choix de la map :")
self.contents.draw_text(368, 120, 120, 24, "Zoom max :")
self.contents.draw_text(368, 144, 120, 24, "Zoom min :")
self.contents.draw_text(368, 168, 120, 24, "Zoom facteur :")
self.contents.draw_text(368, 192, 120, 24, "Zoom origine :")
self.contents.draw_text(368, 216, 120, 24, "Zoom défaut :")
self.contents.draw_text(368, 240, 80, 24, "R à Z", 1)
self.contents.draw_text(448, 240, 80, 24, "Annuler", 1)
self.contents.draw_text(528, 240, 80, 24, "Enregistrer", 1)
self.contents.draw_text(368, 272, 240, 24, "Légende :")
self.contents.fill_rect(368, 304, 20, 10, Color.new(255,0,0))
self.contents.fill_rect(368, 328, 20, 10, Color.new(0,0,255))
self.contents.fill_rect(368, 352, 20, 10, Color.new(255,255,0))
self.contents.fill_rect(368, 376, 20, 10, Color.new(255,255,255))
self.contents.font.size = 18
self.contents.draw_text(400, 298, 208, 20, ": Zone où le zoom est au maximum")
self.contents.draw_text(400, 322, 208, 20, ": Zone où le zoom est au minimum")
self.contents.draw_text(400, 346, 208, 20, ": Origine du zoom")
self.contents.draw_text(400, 370, 208, 20, ": Valeur du zoom à cet endroit")
self.contents.draw_text(0, 400, 64, 20, "Aide")
self.contents.font.color.set(0,0,0)
self.contents.draw_text(368, 371, 20, 20, "x%", 2)
self.contents.font.size = 20
end
def refresh_map
@map_sprite.map_id = @map_id
@map_sprite.refresh
@width, @height = @map_sprite.bitmap.width, @map_sprite.bitmap.height
@map_sprite.zoom_x = @map_sprite.zoom_y = 1
if @width > 320; i = 320.0 / @width
@map_sprite.zoom_x = @map_sprite.zoom_y *= i
@height *= i
@width *= i
end
if @height > 320; i = 320.0 / @height
@map_sprite.zoom_x = @map_sprite.zoom_y *= i
@height *= i
@width *= i
end
@map_sprite.x, @map_sprite.y = 184-@width/2.0, 240-@height/2.0
map_name = load_data("Data/MapInfos.rxdata")[@map_id].name
self.contents.fill_rect(370, 88, 236, 20, normal_color)
self.contents.draw_text(370, 88, 236, 20, " %03d - #{map_name}" % @map_id)
filename = "Data System/Map%03dD.rxdata" % @map_id
@zoom_max, @zoom_min, @zoom_factor, @zoom_origin, @zoom_default =
FileTest.exist?(filename) ? load_data(filename) : Game_Map::Default_Depth
refresh_values
end
def refresh_values
self.contents.fill_rect(490, 122, 116, 20, normal_color)
self.contents.fill_rect(490, 146, 116, 20, normal_color)
self.contents.fill_rect(490, 170, 116, 20, normal_color)
self.contents.fill_rect(490, 194, 116, 20, normal_color)
self.contents.fill_rect(490, 218, 116, 20, normal_color)
@zoom_max = [@zoom_max, @zoom_min].max if @index == -1
@zoom_min = [[@zoom_max, @zoom_min].min, 0].max if @index == -2
@zoom_factor = [[@zoom_factor, 1000].min, -1000].max if @index == -3
@zoom_default = [[@zoom_default, @zoom_min-100].max, @zoom_max-100].min
self.contents.draw_text(490, 122, 116, 20, "#@zoom_max % ", 2)
self.contents.draw_text(490, 146, 116, 20, "#@zoom_min % ", 2)
self.contents.draw_text(490, 170, 116, 20, "#{(@zoom_factor*0.1)} % ", 2)
self.contents.draw_text(490, 194, 116, 20, "#@zoom_origin % ", 2)
self.contents.draw_text(490, 218, 116, 20, "#@zoom_default % ", 2)
@cursors_sprite.bitmap.clear
depth, zoom_factor = @map_sprite.bitmap.height/32 - 1.0, 0.001 * @zoom_factor
zoom_max, zoom_min = 0.01 * @zoom_max, 0.01 * @zoom_min
zoom_origin, zoom_default = 0.01 * @zoom_origin * depth, 0.01 * @zoom_default
value_up = ([[1 - (depth - zoom_origin) * zoom_factor + zoom_default, zoom_max].min, zoom_min].max * 100).round
value_down = ([[1 - (0 - zoom_origin) * zoom_factor + zoom_default, zoom_max].min, zoom_min].max * 100).round
value_origin = [[100+@zoom_default, @zoom_max].min, @zoom_min].max
pos_origin = @map_sprite.y + @height - 64 - @zoom_origin * @height / 100.0
if @zoom_factor != 0
pos_min = ((@zoom_default+100.0-@zoom_min)*@height)/(0.1*@zoom_factor.abs*depth)
pos_max = ((@zoom_max-100.0-@zoom_default)*@height)/(0.1*@zoom_factor.abs*depth)
if @zoom_factor > 0
y_up, y_down = @map_sprite.y - 64, pos_origin + pos_max
y2_up, y2_down = pos_origin - pos_min - y_up + 1, @map_sprite.y + @height - 63 - y_down
else
y_up, y_down = pos_origin + pos_max, @map_sprite.y - 64
y2_up, y2_down = @map_sprite.y + @height - 63 - y_up, pos_origin - pos_min - y_down + 1
end
y_up, y_down = [y_up, @map_sprite.y - 64].max, [y_down, @map_sprite.y - 64].max
y2_up, y2_down = [y2_up, @height].min, [y2_down, @height].min
@cursors_sprite.bitmap.fill_rect(@map_sprite.x-8, y_up, @width, y2_up, Color.new(0,0,255,128))
@cursors_sprite.bitmap.fill_rect(@map_sprite.x-8, y_down, @width, y2_down, Color.new(255,0,0,128))
end
@cursors_sprite.bitmap.fill_rect(@map_sprite.x-8, pos_origin-4, @width, 8, Color.new(255,255,0,128))
@cursors_sprite.bitmap.fill_rect(144, pos_origin-10, 64, 20, normal_color)
@cursors_sprite.bitmap.draw_text(144, pos_origin-10, 64, 20, "#{value_origin} % ", 2)
x, y = [@map_sprite.x - 40, 0].max, @map_sprite.y - 64
@cursors_sprite.bitmap.fill_rect(x, y-10, 64, 20, normal_color)
@cursors_sprite.bitmap.draw_text(x, y-10, 64, 20, "#{value_up} % ", 2)
x = [@map_sprite.x - 40 + @width, 288].min
y += @height
@cursors_sprite.bitmap.fill_rect(x, y-10, 64, 20, normal_color)
@cursors_sprite.bitmap.draw_text(x, y-10, 64, 20, "#{value_down} % ", 2)
end
def update_cursor_rect
x, y, w = 364, [@index.abs, 6].min * 24 + 56, 120
x += 124 if @index < 0
x += (@index-6)*82 if @index > 5
y += 40 if @index != 0
w = 80 if @index > 5
self.cursor_rect.set(x, y, w, 24)
end
def update_help
text = case @index
when 0; "Sélectionnez la map que vous désirez configurer."
when 1; "Le zoom maximum sert à limiter l'augmentation des personnages."
when 2; "Le zoom minimum sert à limiter la diminution des personnages."
when 3; "Le facteur de zoom est la valeur dont le zoom d'un personnage sera modifié lorsqu'il se déplacera verticalement d'un carreau."
when 4; "L'origine du zoom est l'endroit où les personnages auront leur zoom initial."
when 5; "Le zoom par défaut est une valeur qui sera ajoutée au zoom des personnages quelle que soit leur position."
when 6; "Remettre les paramètres de cette map à zéro ?"
when 7; "Charger les paramètres précédents de cette map ?"
when 8; "Sauvegarder les nouveaux paramètres de cette map ?"
else ; "Appuyez sur les touches Haut et Bas pour modifier la valeur."
end
@help_window.set_text(text, 1)
end
end
class Window_Terrain_Config < Window_Selectable
attr_accessor :map_id, :selected_id, :phase, :walk_audio, :walk_graphics
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Comic Sans MS"
@index = @map_id = @phase = 0
refresh
end
def refresh
self.contents.clear
self.contents.fill_rect(0, 48, 608, 1, normal_color)
self.contents.fill_rect(0, 400, 608, 1, normal_color)
self.contents.fill_rect(352, 48, 1, 352, normal_color)
self.contents.fill_rect(352, 272, 256, 1, normal_color)
self.contents.font.size = 28
self.contents.font.color = knockout_color
self.contents.draw_text(0, 0, 608, 32, "Utilitaire de configuration des terrains", 1)
self.contents.font.size = 20
self.contents.font.color = normal_color
self.contents.draw_text(0, 56, 160, 24, "Audio", 1)
self.contents.draw_text(176, 56, 160, 24, "Graphics", 1)
self.contents.draw_text(0, 90, 24, 20, "1")
self.contents.draw_text(0, 134, 24, 20, "2")
self.contents.draw_text(0, 178, 24, 20, "3")
self.contents.draw_text(0, 222, 24, 20, "4")
self.contents.draw_text(0, 266, 24, 20, "5")
self.contents.draw_text(0, 310, 24, 20, "6")
self.contents.draw_text(0, 354, 24, 20, "7")
self.contents.draw_text(0, 80, 24, 20, "a", 2)
self.contents.draw_text(0, 100, 24, 20, "b", 2)
self.contents.draw_text(0, 124, 24, 20, "a", 2)
self.contents.draw_text(0, 144, 24, 20, "b", 2)
self.contents.draw_text(0, 168, 24, 20, "a", 2)
self.contents.draw_text(0, 188, 24, 20, "b", 2)
self.contents.draw_text(0, 212, 24, 20, "a", 2)
self.contents.draw_text(0, 232, 24, 20, "b", 2)
self.contents.draw_text(0, 256, 24, 20, "a", 2)
self.contents.draw_text(0, 276, 24, 20, "b", 2)
self.contents.draw_text(0, 300, 24, 20, "a", 2)
self.contents.draw_text(0, 320, 24, 20, "b", 2)
self.contents.draw_text(0, 344, 24, 20, "a", 2)
self.contents.draw_text(0, 364, 24, 20, "b", 2)
self.contents.draw_text(176, 90, 24, 20, "1", 1)
self.contents.draw_text(176, 134, 24, 20, "2", 1)
self.contents.draw_text(176, 178, 24, 20, "3", 1)
self.contents.draw_text(176, 222, 24, 20, "4", 1)
self.contents.draw_text(176, 266, 24, 20, "5", 1)
self.contents.draw_text(176, 310, 24, 20, "6", 1)
self.contents.draw_text(176, 354, 24, 20, "7", 1)
self.contents.draw_text(368, 272, 240, 24, "Légende :")
self.contents.font.size = 18
self.contents.draw_text(360, 298, 248, 20, "Audio : Fichiers joués lors des pas")
self.contents.draw_text(360, 322, 248, 20, "Graphics : Fichiers affichés lors des pas")
self.contents.draw_text(360, 346, 248, 20, "1-7 : Id du terrain dans les chipsets")
self.contents.draw_text(360, 370, 248, 20, "a-b : Premier et second pas")
self.contents.draw_text(0, 400, 64, 20, "Aide")
refresh_map
end
def refresh_map
filename = "Data System/Map%03dT.rxdata" % @map_id
if FileTest.exist?(filename)
@walk_audio, @walk_graphics = load_data(filename)
else reset
end
refresh_phase
end
def refresh_phase
self.contents.fill_rect(353, 49, 287, 223, Color.new(0,0,0,0))
case @phase
when 0, 1, 2
self.contents.font.size = 20
self.contents.font.color = normal_color
self.contents.draw_text(368, 56, 240, 24, "Choix de la map :")
self.contents.draw_text(368, 128, 240, 24, "Modifier les valeurs", 1)
self.contents.draw_text(368, 160, 240, 24, "Remettre à zéro", 1)
self.contents.draw_text(368, 192, 240, 24, "Annuler les modifications", 1)
self.contents.draw_text(368, 224, 240, 24, "Enregistrer les modifications", 1)
self.contents.font.color.set(0,0,0)
self.contents.fill_rect(370, 88, 236, 20, normal_color)
if @map_id != 0
map_name = load_data("Data/MapInfos.rxdata")[@map_id].name
self.contents.draw_text(370, 88, 236, 20, " %03d - #{map_name}" % @map_id)
end
when 3
self.contents.font.size = 20
self.contents.font.color = normal_color
self.contents.draw_text(368, 56, 240, 24, "Nom du fichier :")
self.contents.draw_text(368, 128, 120, 24, "Volume :")
self.contents.draw_text(368, 160, 120, 24, "Tempo :")
self.contents.draw_text(368, 192, 240, 24, "Aperçu", 1)
self.contents.draw_text(368, 224, 240, 24, "Valider", 1)
when 4
self.contents.font.size = 20
self.contents.font.color = normal_color
self.contents.draw_text(368, 56, 240, 24, "Nom du fichier :")
self.contents.draw_text(368, 128, 120, 24, "Durée 1 :")
self.contents.draw_text(368, 160, 120, 24, "Durée 2 :")
self.contents.draw_text(368, 192, 240, 24, "Aperçu", 1)
self.contents.draw_text(368, 224, 240, 24, "Valider", 1)
end
refresh_values
end
def refresh_values
case @phase
when 0, 1, 2
self.contents.fill_rect(32, 82, 128, 16, normal_color)
self.contents.fill_rect(32, 102, 128, 16, normal_color)
self.contents.fill_rect(32, 126, 128, 16, normal_color)
self.contents.fill_rect(32, 146, 128, 16, normal_color)
self.contents.fill_rect(32, 170, 128, 16, normal_color)
self.contents.fill_rect(32, 190, 128, 16, normal_color)
self.contents.fill_rect(32, 214, 128, 16, normal_color)
self.contents.fill_rect(32, 234, 128, 16, normal_color)
self.contents.fill_rect(32, 258, 128, 16, normal_color)
self.contents.fill_rect(32, 278, 128, 16, normal_color)
self.contents.fill_rect(32, 302, 128, 16, normal_color)
self.contents.fill_rect(32, 322, 128, 16, normal_color)
self.contents.fill_rect(32, 346, 128, 16, normal_color)
self.contents.fill_rect(32, 366, 128, 16, normal_color)
self.contents.fill_rect(208, 92, 128, 16, normal_color)
self.contents.fill_rect(208, 136, 128, 16, normal_color)
self.contents.fill_rect(208, 180, 128, 16, normal_color)
self.contents.fill_rect(208, 224, 128, 16, normal_color)
self.contents.fill_rect(208, 268, 128, 16, normal_color)
self.contents.fill_rect(208, 312, 128, 16, normal_color)
self.contents.fill_rect(208, 356, 128, 16, normal_color)
if @map_id != 0
self.contents.font.size = 18
self.contents.font.color.set(0,0,0)
self.contents.draw_text(32, 82, 128, 16, File.basename(@walk_audio[1][0], ".*"), 1)
self.contents.draw_text(32, 102, 128, 16, File.basename(@walk_audio[-1][0], ".*"), 1)
self.contents.draw_text(32, 126, 128, 16, File.basename(@walk_audio[2][0], ".*"), 1)
self.contents.draw_text(32, 146, 128, 16, File.basename(@walk_audio[-2][0], ".*"), 1)
self.contents.draw_text(32, 170, 128, 16, File.basename(@walk_audio[3][0], ".*"), 1)
self.contents.draw_text(32, 190, 128, 16, File.basename(@walk_audio[-3][0], ".*"), 1)
self.contents.draw_text(32, 214, 128, 16, File.basename(@walk_audio[4][0], ".*"), 1)
self.contents.draw_text(32, 234, 128, 16, File.basename(@walk_audio[-4][0], ".*"), 1)
self.contents.draw_text(32, 258, 128, 16, File.basename(@walk_audio[5][0], ".*"), 1)
self.contents.draw_text(32, 278, 128, 16, File.basename(@walk_audio[-5][0], ".*"), 1)
self.contents.draw_text(32, 302, 128, 16, File.basename(@walk_audio[6][0], ".*"), 1)
self.contents.draw_text(32, 322, 128, 16, File.basename(@walk_audio[-6][0], ".*"), 1)
self.contents.draw_text(32, 346, 128, 16, File.basename(@walk_audio[7][0], ".*"), 1)
self.contents.draw_text(32, 366, 128, 16, File.basename(@walk_audio[-7][0], ".*"), 1)
self.contents.draw_text(208, 92, 128, 16, File.basename(@walk_graphics[1][0], ".*"), 1)
self.contents.draw_text(208, 136, 128, 16, File.basename(@walk_graphics[2][0], ".*"), 1)
self.contents.draw_text(208, 180, 128, 16, File.basename(@walk_graphics[3][0], ".*"), 1)
self.contents.draw_text(208, 224, 128, 16, File.basename(@walk_graphics[4][0], ".*"), 1)
self.contents.draw_text(208, 268, 128, 16, File.basename(@walk_graphics[5][0], ".*"), 1)
self.contents.draw_text(208, 312, 128, 16, File.basename(@walk_graphics[6][0], ".*"), 1)
self.contents.draw_text(208, 356, 128, 16, File.basename(@walk_graphics[7][0], ".*"), 1)
end
when 3
@walk_audio[@selected_id][1] = [[@walk_audio[@selected_id][1], 0].max, 100].min
@walk_audio[@selected_id][2] = [[@walk_audio[@selected_id][2], 50].max, 150].min
self.contents.fill_rect(370, 88, 236, 20, normal_color)
self.contents.fill_rect(490, 130, 116, 20, normal_color)
self.contents.fill_rect(490, 162, 116, 20, normal_color)
self.contents.font.size = 20
self.contents.font.color.set(0,0,0)
self.contents.draw_text(370, 88, 236, 20, " "<<File.basename(@walk_audio[@selected_id][0], ".*"))
self.contents.draw_text(490, 130, 116, 20, "#{@walk_audio[@selected_id][1]} % ", 2)
self.contents.draw_text(490, 162, 116, 20, "#{@walk_audio[@selected_id][2]} % ", 2)
when 4
@walk_graphics[@selected_id][1] = [@walk_graphics[@selected_id][1], 0].max
@walk_graphics[@selected_id][2] = [@walk_graphics[@selected_id][2], 0].max
self.contents.fill_rect(370, 88, 236, 20, normal_color)
self.contents.fill_rect(490, 130, 116, 20, normal_color)
self.contents.fill_rect(490, 162, 116, 20, normal_color)
self.contents.font.size = 20
self.contents.font.color.set(0,0,0)
self.contents.draw_text(370, 88, 236, 20, " "<<File.basename(@walk_graphics[@selected_id][0], ".*"))
self.contents.draw_text(490, 130, 116, 20, "#{@walk_graphics[@selected_id][1]} frames ", 2)
self.contents.draw_text(490, 162, 116, 20, "#{@walk_graphics[@selected_id][2]} frames ", 2)
end
end
def reset
@walk_audio, @walk_graphics = {}, {}
terrain = Game_Map::Default_Terrain
for i in 1..7
@walk_audio[i] = terrain[0][i].clone
@walk_audio[-i] = terrain[0][-i].clone
@walk_graphics[i] = terrain[1][i].clone
end
end
def update_cursor_rect
case @phase
when 0, 3, 4
@item_max = 5
x, y, w, h = 364, @index.abs*32+56, 120, 24
x += 124 if @index < 0
y += 40 if @index != 0
w += 124 if @phase == 0 ? @index != 0 : @index > 2
when 1
@item_max, @selected_id = 14, @index / 2 + 1
@selected_id *= -1 if @index % 2 == 1
x, y, w, h = 29, @index*20+79+@index/2*4, 134, 22
when 2
@item_max, @selected_id = 7, @index + 1
x, y, w, h = 205, @index*44+89, 134, 22
end
self.cursor_rect.set(x, y, w, h)
end
def update_help
text = case @phase
when 0
case @index
when 0; "Sélectionnez la map que vous désirez configurer."
when 1; "Modifier les valeurs de cette map ?"
when 2; "Remettre les paramètres de cette map à zéro ?"
when 3; "Charger les paramètres précédents de cette map ?"
when 4; "Sauvegarder les nouveaux paramètres de cette map ?"
end
when 1,2; "Touche C : Modifier valeur - Touche B : Retour - Touche A : Aperçu"
when 3
case @index
when 0; "Sélectionnez le nouveau fichier audio."
when 1; "Choisissez le volume entre 0% et 100% (La valeur que vous indiquez est le volume quand on court, quand on marche le volume sera à 80% de cette valeur)."
when 2; "Choisissez le tempo entre 50% et 150%."
when 3; "Ecouter le son ?"
when 4; "Valider la modification ?"
end
when 4
case @index
when 0; "Sélectionnez le nouveau fichier graphique."
when 1; "Durée d'affichage pendant qu'on marche en nombre de frames (40 frames = 1 sec)."
when 2; "Durée d'affichage pendant qu'on court en nombre de frames (40 frames = 1 sec)."
when 3; "Voir l'image ?"
when 4; "Valider la modification ?"
end
end
text = "Appuyez sur les touches Haut et Bas pour modifier la valeur." unless text
@help_window.set_text(text, 1)
end
end
class Window_Map_Config < Window_Selectable
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Comic Sans MS"
@index, @item_max = 0, 3
refresh
end
def refresh
self.contents.clear
self.contents.fill_rect(0, 48, 608, 1, normal_color)
self.contents.fill_rect(0, 400, 608, 1, normal_color)
self.contents.font.size = 28
self.contents.font.color = knockout_color
self.contents.draw_text(0, 0, 608, 32, "Utilitaire de configuration des maps", 1)
self.contents.font.size = 20
self.contents.font.color = normal_color
self.contents.draw_text(0, 100, 608, 32, "Utilitaire de configuration des terrains", 1)
self.contents.draw_text(0, 200, 608, 32, "Utilitaire de configuration de la profondeur", 1)
self.contents.draw_text(0, 300, 608, 32, "Utilitaire de configuration de la hauteur", 1)
self.contents.font.size = 18
self.contents.draw_text(0, 380, 608, 20, "© Zeus81 2007-2008 ", 2)
self.contents.draw_text(0, 400, 64, 20, "Aide")
end
def update_cursor_rect; self.cursor_rect.set(104, (@index + 1) * 100, 400, 32); end
def update_help
text = case @index
when 0; "Configurez les audio et graphismes des pas pour les sept terrains."
when 1; "Configurez la profondeur des maps."
when 2; "Configurez la gravité et le relief des maps."
end
@help_window.set_text(text, 1)
end
end
class Scene_Height_Config
def main
@window_height_config = Window_Height_Config.new
@window_height_config.help_window = @window_help = Window_Help.new
@window_help.y, @window_help.windowskin = 416
@window_help.contents.font.name = "Comic Sans MS"
@window_help.contents.font.size = 20
@window_map_height = Window_Map_Height.new
@window_map_height.help_window = @window_help
@window_list = Window_List.new
@window_list.help_window = @window_help
@window_list.refresh
@last_value = 0
Graphics.transition
while($scene == self)
Graphics.update
Input.update
update
end
@window_height_config.dispose
@window_list.dispose
@window_map_height.dispose
@window_help.dispose
end
def update
if @window_map_height.active; update_map_height_window
elsif @window_list.active; update_map_list_window
elsif @window_height_config.active; update_height_config_window
else; update_values
end
end
def update_map_height_window
@window_map_height.update
if Input.trigger?(Input::A)
$game_system.se_play($data_system.decision_se)
@window_map_height.selected_value = @last_value
@window_map_height.refresh_values
elsif Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_height_config.active = true
@window_map_height.active = false
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@window_map_height.active = false
@window_map_height.update_help
@last_value = @window_map_height.selected_value
end
end
def update_map_list_window
@window_list.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_height_config.active = true
@window_list.active = @window_list.visible = false
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@window_height_config.active = true
@window_list.active = @window_list.visible = false
@window_height_config.map_id = @window_map_height.map_id = @window_list.map_id
@window_height_config.refresh_map
@window_map_height.refresh_map
end
end
def update_height_config_window
@window_height_config.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map_Config.new
elsif Input.trigger?(Input::C)
if @window_height_config.index == 0
$game_system.se_play($data_system.decision_se)
@window_height_config.active = false
@window_list.active = @window_list.visible = true
elsif @window_map_height.map_id == 0
$game_system.se_play($data_system.buzzer_se)
elsif @window_height_config.index == 3
$game_system.se_play($data_system.decision_se)
@window_height_config.cursor_rect.empty
@window_height_config.active = false
@window_map_height.active = true
elsif @window_height_config.index == 4
$game_system.se_play($data_system.escape_se)
@window_height_config.gravity = Game_Map::Default_Gravity
@window_height_config.refresh_values
@window_map_height.reset
elsif @window_height_config.index == 5
$game_system.se_play($data_system.load_se)
@window_height_config.refresh_map
@window_map_height.refresh_map
elsif @window_height_config.index == 6
$game_system.se_play($data_system.save_se)
filename = "Data System/Map%03dH.rxdata" % @window_height_config.map_id
height = [@window_height_config.gravity, @window_map_height.floors]
if height[0] == Game_Map::Default_Gravity
delete = true
for x in 0...height[1].xsize
for y in 0...height[1].ysize
break unless delete = (height[1][x, y] == 0)
end
break unless delete
end
if delete
File.delete(filename) if FileTest.exist?(filename)
return
end
end
save_data(height, filename)
else
$game_system.se_play($data_system.decision_se)
@window_height_config.index *= -1
@window_height_config.active = false
@last_value = @window_height_config.gravity if @window_height_config.index == -1
@last_value = @window_height_config.scale if @window_height_config.index == -2
end
end
end
def update_values
if @window_height_config.index == 3
update_map_height_window_values
else update_height_config_window_values
end
end
def update_height_config_window_values
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@window_height_config.gravity += 1 if @window_height_config.index == -1
@window_height_config.scale += 1 if @window_height_config.index == -2
elsif Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@window_height_config.gravity -= 1 if @window_height_config.index == -1
@window_height_config.scale -= 1 if @window_height_config.index == -2
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_height_config.gravity = @last_value if @window_height_config.index == -1
@window_height_config.scale = @last_value if @window_height_config.index == -2
@window_height_config.index *= -1
@window_height_config.active = true
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if @window_height_config.index == -2
@window_map_height.scale = (2**@window_height_config.scale).to_f
@window_map_height.refresh_scale
end
@window_height_config.index *= -1
@window_height_config.active = true
end
@window_height_config.update
@window_height_config.refresh_values
end
def update_map_height_window_values
@window_map_height.update
@window_map_height.refresh_selected_value
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@window_map_height.selected_value += 1
elsif Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@window_map_height.selected_value -= 1
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_map_height.selected_value = @last_value
@window_map_height.contents.clear
@window_map_height.active = true
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@window_map_height.refresh_values
@window_map_height.contents.clear
@window_map_height.active = true
@last_value = @window_map_height.selected_value
end
end
end
class Scene_Depth_Config
def main
@window_depth_config = Window_Depth_Config.new
@window_depth_config.help_window = @window_help = Window_Help.new
@window_help.y, @window_help.windowskin = 416
@window_help.contents.font.name = "Comic Sans MS"
@window_help.contents.font.size = 20
@window_list = Window_List.new
@window_list.help_window = @window_help
@window_list.refresh
Graphics.transition
while($scene == self)
Graphics.update
Input.update
update
end
@window_depth_config.dispose
@window_list.dispose
@window_help.dispose
end
def update
if @window_list.active; update_map_list_window
elsif @window_depth_config.active; update_depth_config_window
else; update_depth_config_window_values
end
end
def update_map_list_window
@window_list.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_depth_config.active = true
@window_list.active = @window_list.visible = false
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@window_depth_config.active = true
@window_list.active = @window_list.visible = false
@window_depth_config.map_id = @window_list.map_id
@window_depth_config.refresh_map
end
end
def update_depth_config_window
@window_depth_config.update
if @window_depth_config.index > 5
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
@window_depth_config.index += 1
@window_depth_config.index = 6 if @window_depth_config.index == 9
elsif Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@window_depth_config.index -= 1
@window_depth_config.index = 8 if @window_depth_config.index == 5
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map_Config.new
elsif Input.trigger?(Input::C)
if @window_depth_config.index == 0
$game_system.se_play($data_system.decision_se)
@window_depth_config.active = false
@window_list.active = @window_list.visible = true
elsif @window_depth_config.map_id == 0
$game_system.se_play($data_system.buzzer_se)
elsif @window_depth_config.index == 6
$game_system.se_play($data_system.escape_se)
@window_depth_config.zoom_max, @window_depth_config.zoom_min,
@window_depth_config.zoom_factor, @window_depth_config.zoom_origin,
@window_depth_config.zoom_default = Game_Map::Default_Depth
@window_depth_config.refresh_values
elsif @window_depth_config.index == 7
$game_system.se_play($data_system.load_se)
@window_depth_config.refresh_map
elsif @window_depth_config.index == 8
$game_system.se_play($data_system.save_se)
filename = "Data System/Map%03dD.rxdata" % @window_depth_config.map_id
depth = [@window_depth_config.zoom_max, @window_depth_config.zoom_min,
@window_depth_config.zoom_factor, @window_depth_config.zoom_origin,
@window_depth_config.zoom_default]
if depth == Game_Map::Default_Depth
File.delete(filename) if FileTest.exist?(filename)
return
end
save_data(depth, filename)
else
$game_system.se_play($data_system.decision_se)
@window_depth_config.index *= -1
@window_depth_config.active = false
@last_value = @window_depth_config.zoom_max if @window_depth_config.index == -1
@last_value = @window_depth_config.zoom_min if @window_depth_config.index == -2
@last_value = @window_depth_config.zoom_factor if @window_depth_config.index == -3
@last_value = @window_depth_config.zoom_origin if @window_depth_config.index == -4
@last_value = @window_depth_config.zoom_default if @window_depth_config.index == -5
@count = 1
end
end
end
def update_depth_config_window_values
if Input.press?(Input::UP) == Input.press?(Input::DOWN)
@count = 1
elsif Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@window_depth_config.zoom_max += @count.round if @window_depth_config.index == -1
@window_depth_config.zoom_min += @count.round if @window_depth_config.index == -2
@window_depth_config.zoom_factor += @count.round if @window_depth_config.index == -3
@window_depth_config.zoom_origin += @count.round if @window_depth_config.index == -4
@window_depth_config.zoom_default += @count.round if @window_depth_config.index == -5
elsif Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@window_depth_config.zoom_max -= @count.round if @window_depth_config.index == -1
@window_depth_config.zoom_min -= @count.round if @window_depth_config.index == -2
@window_depth_config.zoom_factor -= @count.round if @window_depth_config.index == -3
@window_depth_config.zoom_origin -= @count.round if @window_depth_config.index == -4
@window_depth_config.zoom_default -= @count.round if @window_depth_config.index == -5
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_depth_config.zoom_max = @last_value if @window_depth_config.index == -1
@window_depth_config.zoom_min = @last_value if @window_depth_config.index == -2
@window_depth_config.zoom_factor = @last_value if @window_depth_config.index == -3
@window_depth_config.zoom_origin = @last_value if @window_depth_config.index == -4
@window_depth_config.zoom_default = @last_value if @window_depth_config.index == -5
@window_depth_config.index *= -1
@window_depth_config.active = true
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@window_depth_config.index *= -1
@window_depth_config.active = true
end
@count *= 1.01
@window_depth_config.update
@window_depth_config.refresh_values
end
end
class Scene_Terrain_Config
def main
@window_terrain_config = Window_Terrain_Config.new
@window_terrain_config.help_window = @window_help = Window_Help.new
@window_help.y, @window_help.windowskin = 416
@window_help.contents.font.name = "Comic Sans MS"
@window_help.contents.font.size = 20
@window_list = Window_List.new
@window_list.help_window = @window_help
Graphics.transition
while($scene == self)
Graphics.update
Input.update
update
end
@window_terrain_config.dispose
@window_list.dispose
@window_help.dispose
end
def update
if @window_list.active
@window_list.path.empty? ? update_map_list_window : update_file_list_window
elsif @window_terrain_config.active
case @window_terrain_config.phase
when 0; update_terrain_config_window_phase_0
when 1, 2; update_terrain_config_window_phase_1_2
when 3, 4; update_terrain_config_window_phase_3_4
end
else update_values
end
end
def update_map_list_window
@window_list.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_terrain_config.active = true
@window_list.active = @window_list.visible = false
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@window_terrain_config.active = true
@window_list.active = @window_list.visible = false
@window_terrain_config.map_id = @window_list.map_id
@window_terrain_config.refresh_map
end
end
def update_file_list_window
@window_list.update
if Input.trigger?(Input::A)
test
elsif Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_terrain_config.active = true
@window_list.active = @window_list.visible = false
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@window_terrain_config.active = true
@window_list.active = @window_list.visible = false
id = @window_terrain_config.selected_id
if @window_terrain_config.phase == 3
@window_terrain_config.walk_audio[id][0] = @window_list.filename
else @window_terrain_config.walk_graphics[id][0] = @window_list.filename
end
@window_terrain_config.refresh_values
end
end
def update_terrain_config_window_phase_0
@window_terrain_config.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map_Config.new
elsif Input.trigger?(Input::C)
if @window_terrain_config.index == 0
$game_system.se_play($data_system.decision_se)
@window_terrain_config.active = false
@window_list.path = ""
@window_list.refresh
@window_list.active = @window_list.visible = true
elsif @window_terrain_config.map_id == 0
$game_system.se_play($data_system.buzzer_se)
elsif @window_terrain_config.index == 1
$game_system.se_play($data_system.decision_se)
@window_terrain_config.phase = 1
@window_terrain_config.index = 0
elsif @window_terrain_config.index == 2
$game_system.se_play($data_system.escape_se)
@window_terrain_config.reset
@window_terrain_config.refresh_values
elsif @window_terrain_config.index == 3
$game_system.se_play($data_system.load_se)
@window_terrain_config.refresh_map
elsif @window_terrain_config.index == 4
$game_system.se_play($data_system.save_se)
filename = sprintf("Data System/Map%03dT.rxdata", @window_terrain_config.map_id)
terrain = [@window_terrain_config.walk_audio, @window_terrain_config.walk_graphics]
delete = true
for i in 1..7
delete = false if terrain[0][i] != Game_Map::Default_Terrain[0][i]
delete = false if terrain[0][-i] != Game_Map::Default_Terrain[0][-i]
delete = false if terrain[1][i] != Game_Map::Default_Terrain[1][i]
break unless delete
end
if delete
File.delete(filename) if FileTest.exist?(filename)
return
end
save_data(terrain, filename)
end
end
end
def update_terrain_config_window_phase_1_2
@window_terrain_config.update
if Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
if @window_terrain_config.phase == 1
@window_terrain_config.phase = 2
@window_terrain_config.index /= 2
else
@window_terrain_config.phase = 1
@window_terrain_config.index *= 2
end
elsif Input.trigger?(Input::A)
test
elsif Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@window_terrain_config.phase = 0
@window_terrain_config.index = 1
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
id = @window_terrain_config.selected_id
if @window_terrain_config.phase == 1
@last_value = @window_terrain_config.walk_audio[id].clone
else @last_value = @window_terrain_config.walk_graphics[id].clone
end
@last_index = @window_terrain_config.index
@window_terrain_config.phase += 2
@window_terrain_config.index = 0
@window_terrain_config.refresh_phase
end
end
def update_terrain_config_window_phase_3_4
@window_terrain_config.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
id = @window_terrain_config.selected_id
if @window_terrain_config.phase == 3
@window_terrain_config.walk_audio[id] = @last_value.clone
else @window_terrain_config.walk_graphics[id] = @last_value.clone
end
@window_terrain_config.phase -= 2
@window_terrain_config.index = @last_index
@window_terrain_config.refresh_phase
elsif Input.trigger?(Input::C)
case @window_terrain_config.index
when 0
$game_system.se_play($data_system.decision_se)
@window_terrain_config.active = false
@window_list.active = true
@window_list.visible = true
@window_list.path = @window_terrain_config.phase == 3 ?
"Audio\\SE\\Data System" : "Graphics\\Pictures\\Data System"
@window_list.refresh
when 1, 2
$game_system.se_play($data_system.decision_se)
id, id2 = @window_terrain_config.selected_id, @window_terrain_config.index
if @window_terrain_config.phase == 3
@last_value2 = @window_terrain_config.walk_audio[id][id2]
else @last_value2 = @window_terrain_config.walk_graphics[id][id2]
end
@count = 1
@window_terrain_config.index *= -1
@window_terrain_config.active = false
when 3
test
when 4
$game_system.se_play($data_system.decision_se)
@window_terrain_config.phase -= 2
@window_terrain_config.index = @last_index
@window_terrain_config.refresh_phase
end
end
end
def update_values
if Input.press?(Input::UP) == Input.press?(Input::DOWN)
@count = 1
elsif Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
id, id2 = @window_terrain_config.selected_id, @window_terrain_config.index.abs
if @window_terrain_config.phase == 3
@window_terrain_config.walk_audio[id][id2] += @count.round
else @window_terrain_config.walk_graphics[id][id2] += @count.round
end
elsif Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
id, id2 = @window_terrain_config.selected_id, @window_terrain_config.index.abs
if @window_terrain_config.phase == 3
@window_terrain_config.walk_audio[id][id2] -= @count.round
else @window_terrain_config.walk_graphics[id][id2] -= @count.round
end
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
id, id2 = @window_terrain_config.selected_id, @window_terrain_config.index.abs
if @window_terrain_config.phase == 3
@window_terrain_config.walk_audio[id][id2] = @last_value2
else @window_terrain_config.walk_graphics[id][id2] = @last_value2
end
@window_terrain_config.index *= -1
@window_terrain_config.active = true
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@window_terrain_config.index *= -1
@window_terrain_config.active = true
end
@count *= 1.01
@window_terrain_config.update
@window_terrain_config.refresh_values
end
def test
id = @window_terrain_config.selected_id
case @window_terrain_config.phase
when 1, 3
audio = @window_list.active ? [@window_list.filename, 100, 100] : @window_terrain_config.walk_audio[id]
$game_system.se_play(RPG::AudioFile.new(*audio))
when 2, 4
$game_system.se_play($data_system.decision_se)
filename = @window_list.active ? @window_list.filename : @window_terrain_config.walk_graphics[id][0]
rect = RPG::Cache.picture(filename).rect
sprite = Sprite.new
sprite.x, sprite.y, sprite.z = 320-rect.width/2, 240-rect.height/2, 9999
sprite.bitmap = Bitmap.new(rect.width, rect.height)
sprite.bitmap.fill_rect(rect, Color.new(0,255,0))
sprite.bitmap.blt(0, 0, RPG::Cache.picture(filename), rect)
grid_color = Color.new(0,0,0)
for i in 1..7
sprite.bitmap.fill_rect(rect.width/4*i, 0, 1, rect.height, grid_color)
sprite.bitmap.fill_rect(0, rect.height/8*i, rect.width, 1, grid_color)
end
until(Input.press?(Input::B))
Input.update
Graphics.update
end
sprite.bitmap.dispose
sprite.dispose
$game_system.se_play($data_system.cancel_se)
end
end
end
class Scene_Map_Config
def main
@window_map_config = Window_Map_Config.new
@window_map_config.help_window = @window_help = Window_Help.new
@window_help.y, @window_help.windowskin = 416
@window_help.contents.font.name = "Comic Sans MS"
@window_help.contents.font.size = 20
Graphics.transition
while($scene == self)
Graphics.update
Input.update
update
end
@window_map_config.dispose
@window_help.dispose
end
def update
@window_map_config.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$game_map.setup_data_system
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$scene = case @window_map_config.index
when 0; Scene_Terrain_Config.new
when 1; Scene_Depth_Config.new
when 2; Scene_Height_Config.new
end
end
end
end
end
La dernière étape consiste à copier 3 dossiers "Data System".
Vous les trouverez dans la démo que vous pouvez télécharger juste en-dessous.
Il y en a un à la racine, un dans le dossier "Audio/SE" et un dernier dans "Graphics/Pictures". Collez-les donc au même endroit dans le dossier de votre jeu !
Je tiens à préciser que la démo n'est pas de moi et viens directement de l'auteur.
Elle contient donc des commentaires pour vous aider à inclure facilement ses scripts dans votre projet ainsi que des explications précises sur comment sans servir !
Télécharger la démo du script
(Téléchargée 1107 fois !)
le 01/05/2010 à 23:25:16
Vu 7754 fois Dernière modification par Martial
le 05/05/2011 à 22:51:18
(édité 8 fois !)
Page: 1
Rroo a écrit: bouuuuuhhhhh Message posté le 20/04/2012 à 20:14:17 IP: 86.201.1.133 |
Martial a écrit: Le fichier ZIP, comment ça ? Tu veux un fichier ZIP en plus du RAR ? Message posté le 26/07/2010 à 17:09:01 IP: 88.186.172.45 |
![]() F@N@T!K a écrit:
Très bon travail, mais tu pourrais mettre le fichier en ZIP et en RAR Message posté le 26/07/2010 à 15:45:43 IP: 83.113.0.222 |
Rroo a écrit:
Je plaisante, ce script est très complet et très utile.
Je félicite grandement Zeus ;)
Message posté le 20/04/2012 à 20:55:24 IP: 86.201.1.133