Krótki opis
Skrypt przenosi do ekranu wyboru lokacji - tzw. mapy świata. Podobną zastosowano m.in. w ffx. Dodatkowo:
* dowolne modyfikowanie obrazka kursora,
* dowolna modyfikacja listy miejsc na mapie,
* 'poznawanie' nowych miejsc w miarę rozwoju gry,
* migający kursor ,
* zapamiętanie ostatniego wyboru,
* okienko wyboru zmienia pozycje zależnie od położenia kursora (prawo/lewo),
* zapis i odczyt listy znanych miejsc przy zapisie/odczycie gry.
Autor skryptu
Sabikku/slabix, czyli ja.
Kompatybilność
Tylko XP; nie powinno kłócić się z innymi skryptami.
class Game_System
attr_accessor :known_places, :last_place
# Initialize. --------------------------------------------------
alias sab_initialize initialize
def initialize
sab_initialize
@known_places=KNOWN_PLACES
@last_place=FIRST_PLACE
end
end
class Window_Command
# Getting command content --------------------------------------
def get_command(index=@index)
if index==:all then
return @commands
else
return @commands[index]
end
end
end
class Interpreter
# Learning a place. --------------------------------------------
def learn(string)
if PLACES.include?(string)
$game_system.known_places[PLACES.index(string)]=true
end
end
# Setting a current place --------------------------------------
def set_place(string)
$game_system.last_place=string
end
end
class Scene_Save < Scene_File
alias sab_write_save_data write_save_data
def write_save_data(file)
sab_write_save_data(file)
file=File.open('mapinfo '+make_filename(@file_index).to_s, "w")
Marshal.dump($game_system.known_places, file)
Marshal.dump($game_system.last_place, file)
file.close
end
end
class Scene_Load < Scene_File
alias sab_read_save_data read_save_data
def read_save_data(file)
sab_read_save_data(file)
file=File.open('mapinfo '+make_filename(@file_index).to_s, "r")
$game_system.known_places = Marshal.load(file)
$game_system.last_place = Marshal.load(file)
file.close
end
end
# ================================================================
# ACTUAL SCRIPT
# ================================================================
class Scene_WorldMap
attr_reader :command_window
# Main. --------------------------------------------------------
def main
# Bgm/bgs fade out.
$game_system.bgm_fade(2)
$game_system.bgs_fade(2)
# Command window place settings.
places=[]
for i in 0...PLACES.size
if $game_system.known_places[i]
places << PLACES[i]
end
end
# Windows.
@command_window=Window_Command.new(192, places) # Command window.
@command_window.opacity=COMMAND_WINDOW_OPACITY
if COMMAND_WINDOW_BOTTOM_ALING
@command_window.y=480-@command_window.height
end
@command_window.index = $game_system.last_place=="" ? 0 : @command_window.get_command(:all).index($game_system.last_place)
@bg_window=Window_WorldMap.new # Background.
@bg_window.z-=10
check_command_window_position
# Settings.
Graphics.transition
# Main loop.
while $scene==self
Graphics.update
Input.update
update
end
# Disposing.
Graphics.freeze
@command_window.dispose
@bg_window.dispose
end
# Update. ------------------------------------------------------
def update
@command_window.update
@bg_window.refresh
# Moving command_window.
check_command_window_position
# Checking keyboard.
if Input.trigger?(Input::C)
if $game_map.map_id==TELEPORTS[PLACES.index(@command_window.get_command)][0]
return_to_map
else
$game_system.se_play($data_system.decision_se)
# Teleport - new place.
map, x, y, direction = TELEPORTS[PLACES.index(@command_window.get_command)]
$game_map.setup(map)
$game_player.moveto(x, y)
case direction
when 2: $game_player.turn_down
when 4: $game_player.turn_left
when 6: $game_player.turn_right
when 8: $game_player.turn_up
end
# Poprawka.
$game_player.direction=direction
$game_system.last_place=$scene.command_window.get_command
$scene=Scene_Map.new
# Playing map bgm/bgs.
$game_map.autoplay
end
elsif Input.trigger?(Input::B)
return_to_map
end
end
# Returning to the actual map ----------------------------------
def return_to_map
$game_system.se_play($data_system.cancel_se)
# Teleport - old place.
$scene=Scene_Map.new
# Playing map bgm/bgs.
$game_map.autoplay
end
# Checking command_window position. ----------------------------
def check_command_window_position
x, y = @bg_window.cursor_position
if x >= 320
@command_window.x=0
else
@command_window.x=640-@command_window.width
end
end
end
# Refresh. -----------------------------------------------------
def refresh
# Cursor fading.
if @cursor_fading
@cursor_opacity=[@cursor_opacity+6, 180].min
if @cursor_opacity==180
@cursor_fading=false
end
else
@cursor_opacity=[@cursor_opacity-6, 100].max
if @cursor_opacity==100
@cursor_fading=true
end
end
# Map drawing.
self.contents.clear
self.contents.blt(16, 16, RPG::Cache.picture(MAP_NAME), Rect.new(0, 0, 640, 480), 255)
# Actual index cursor drawing.
p=COORDINATES[PLACES.index($scene.command_window.get_command)]
x=p[0]; y=p[1]
self.contents.blt(x, y, RPG::Cache.picture(CURSOR_NAME), Rect.new(0, 0, 32, 32), @cursor_opacity)
# Actual player place cursor drawing.
p=COORDINATES[PLACES.index($game_system.last_place)]
x=p[0]; y=p[1]
self.contents.blt(x, y, RPG::Cache.picture(CURSOR_NAME), Rect.new(0, 0, 32, 32), 200)
end
# Getting cursor_x ---------------------------------------------
def cursor_position
p=COORDINATES[PLACES.index($game_system.last_place)]
return p[0], p[1]
end
end
Instrukcja
Wklej skrypt nad "Main" w Edytorze Skryptów.
Linijki z kolejnymi miejscami na początku skryptu można kasować/dodawać dowoli. Oto wyjaśnienie jednej linijki:
"Las" oznacza nazwę (i, zarówno, identyfikator) miejsca. 85 i 377 to współrzędne punktu na obrazku mapy. true/false wskazuje, czy dane miejsce ma być dostępne od początku gry: true - tak, false - nie. 4, 1 i 15 to kolejno id mapy docelowej danego miejsca, x i y. 6 to kierunek postaci gracza po teleporcie: 2 - dół, 4 - lewo, 6 - prawo, 8 - góra.
Dalej.
MAP_NAME to nazwa obrazka w folderze Pictures, oznaczającego mapę świata. Może być dowolnych rozmiarów, ale wyświetlony zostanie 640x480px. CURSOR_NAME to nazwa obrazka kursora wyboru na mapie, również w folderze Pictures. FIRSTW_PLACE to miejsce, w którym zaczynamy grę (w którym pojawi się kursorek przy pierwszym odpaleniu mapy). COMMAND_WINDOW_OPACITY to przezroczystość okienka wyboru, a COMMAND_WINDOW_BOTTOM_ALING - ustawienie okienka góra/dół (false - góra, true - dół).
Skrypt wywołujemy kodem:
Kod:
$scene=Scene_WorldMap.new
Troszkę zawiłe, ale jak ktoś będzie potrzebował to się zaznajomi :). W razie problemów pisać.
PS Mam nadzieję, że Ayene nie obrazi się o podkradnięcie szablonu wiadomości xd.
Ostatnio zmieniony przez Sabikku Pią 24 Gru, 2010 20:42, w całości zmieniany 2 razy
Poprawiłem błędy znalezione podczas normalnego użytkowania:
* błąd kierunku gracza po teleportacji,
* odpływanie bgm i bgs (o tym drugim wcześniej w ogóle zapomniałem) podczas przenoszenia na mapę świata,
* odtwarzanie bgm i bgs po teleportacji.
class Game_System
attr_accessor :known_places, :last_place
# Initialize. --------------------------------------------------
alias sab_initialize initialize
def initialize
sab_initialize
@known_places=KNOWN_PLACES
@last_place=FIRST_PLACE
end
end
class Window_Command
# Getting command content --------------------------------------
def get_command(index=@index)
if index==:all then
return @commands
else
return @commands[index]
end
end
end
class Interpreter
# Learning a place. --------------------------------------------
def learn(string)
if PLACES.include?(string)
$game_system.known_places[PLACES.index(string)]=true
end
end
# Setting a current place --------------------------------------
def set_place(string)
$game_system.last_place=string
end
end
class Scene_Save < Scene_File
alias sab_write_save_data write_save_data
def write_save_data(file)
sab_write_save_data(file)
file=File.open('mapinfo '+make_filename(@file_index).to_s, "w")
Marshal.dump($game_system.known_places, file)
Marshal.dump($game_system.last_place, file)
file.close
end
end
class Scene_Load < Scene_File
alias sab_read_save_data read_save_data
def read_save_data(file)
sab_read_save_data(file)
file=File.open('mapinfo '+make_filename(@file_index).to_s, "r")
$game_system.known_places = Marshal.load(file)
$game_system.last_place = Marshal.load(file)
file.close
end
end
# ================================================================
# ACTUAL SCRIPT
# ================================================================
class Scene_WorldMap
attr_reader :command_window
# Main. --------------------------------------------------------
def main
# Bgm/bgs fade out.
$game_system.bgm_fade(2)
$game_system.bgs_fade(2)
# Command window place settings.
places=[]
for i in 0...PLACES.size
if $game_system.known_places[i]
places << PLACES[i]
end
end
# Windows.
@command_window=Window_Command.new(192, places) # Command window.
@command_window.opacity=COMMAND_WINDOW_OPACITY
if COMMAND_WINDOW_BOTTOM_ALING
@command_window.y=480-@command_window.height
end
@command_window.index = $game_system.last_place=="" ? 0 : @command_window.get_command(:all).index($game_system.last_place)
@bg_window=Window_WorldMap.new # Background.
@bg_window.z-=10
check_command_window_position
# Settings.
Graphics.transition
# Main loop.
while $scene==self
Graphics.update
Input.update
update
end
# Disposing.
Graphics.freeze
@command_window.dispose
@bg_window.dispose
end
# Update. ------------------------------------------------------
def update
@command_window.update
@bg_window.refresh
# Moving command_window.
check_command_window_position
# Checking keyboard.
if Input.trigger?(Input::C)
if $game_map.map_id==TELEPORTS[PLACES.index(@command_window.get_command)][2]
return_to_map
else
$game_system.se_play($data_system.decision_se)
# Teleport - new place.
map, x, y, direction = TELEPORTS[PLACES.index(@command_window.get_command)]
$game_map.setup(map)
$game_player.moveto(x, y)
case direction
when 2: $game_player.turn_down
when 4: $game_player.turn_left
when 6: $game_player.turn_right
when 8: $game_player.turn_up
end
# Poprawka.
$game_player.direction=direction
$game_system.last_place=$scene.command_window.get_command
$scene=Scene_Map.new
# Playing map bgm/bgs.
$game_map.autoplay
end
elsif Input.trigger?(Input::B)
return_to_map
end
end
# Returning to the actual map ----------------------------------
def return_to_map
$game_system.se_play($data_system.cancel_se)
# Teleport - old place.
$scene=Scene_Map.new
# Playing map bgm/bgs.
$game_map.autoplay
end
# Checking command_window position. ----------------------------
def check_command_window_position
x, y = @bg_window.cursor_position
if x >= 320
@command_window.x=0
else
@command_window.x=640-@command_window.width
end
end
end
# Refresh. -----------------------------------------------------
def refresh
# Cursor fading.
if @cursor_fading
@cursor_opacity=[@cursor_opacity+6, 180].min
if @cursor_opacity==180
@cursor_fading=false
end
else
@cursor_opacity=[@cursor_opacity-6, 100].max
if @cursor_opacity==100
@cursor_fading=true
end
end
# Map drawing.
self.contents.clear
self.contents.blt(16, 16, RPG::Cache.picture(MAP_NAME), Rect.new(0, 0, 640, 480), 255)
# Actual index cursor drawing.
p=COORDINATES[PLACES.index($scene.command_window.get_command)]
x=p[0]; y=p[1]
self.contents.blt(x, y, RPG::Cache.picture(CURSOR_NAME), Rect.new(0, 0, 32, 32), @cursor_opacity)
# Actual player place cursor drawing.
p=COORDINATES[PLACES.index($game_system.last_place)]
x=p[0]; y=p[1]
self.contents.blt(x, y, RPG::Cache.picture(CURSOR_NAME), Rect.new(0, 0, 32, 32), 200)
end
# Getting cursor_x ---------------------------------------------
def cursor_position
p=COORDINATES[PLACES.index($game_system.last_place)]
return p[0], p[1]
end
end
Tak trudno zajrzeć, znaleźć listę poleceń zdarzenia, nauczyć się wklikiwać tam polecenie 'script', wkleić jednolinijkowy kod, wcisnąć enter... Jak nie umiesz czytać z tak prostych, idiotoodpornych tutoriali z linka, uch, nie moja wina xd. Sorka za agresję, brrr.
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum