Pomógł: 13 razy Dołączył: 02 Lip 2010 Posty: 131 Skąd: z Polski
Wysłany: Sob 03 Lip, 2010 18:56
Window CMS
Zrobiłem tego CMS'a 4 miesiące temu ... Dam od razu poprawiona wersję 1.1. Okienka płynnie wchodzą.
Spoiler:
Kod:
# Autor - Gatoz (shiwt). Szczególne podziękowania dla Thieffer'a. Egrimowi i
# HellKillerowi też dzięki za pomoc przy malutkim błędzie ;)
# Jest mój pierwszy CMS więc proszę o wyrozumiałość :]
# Dodałem możliwość zmiany przezroczystości, czcionki i jej rozmiaru, kilka
# napisów znajdujących się w menu, tj. czas gry, kroki i inne. Szybkość
# wchodzenia okienek. Zmienna odpowiadającej za reputację i szybka możliwość
# zmiany poszczególnych nazw w reputacji.
def appear
@okno1.x -= Szybkość if @okno1.x > 480
@okno2.x -= Szybkość if @okno2.x > 480
@okno3.x -= Szybkość if @okno3.x > 480
@okno4.y += Szybkość if @okno4.y < 0
@status_window.y -= Szybkość if @status_window.y > 370
@okno6.x -= Szybkość if @okno6.x > 480
@command_window.x += Szybkość if @command_window.x < 0
@okno7.x += Szybkość if @okno7.x < 0
if @okno1.x == 480 and @okno2.x == 480 and @okno3.x == 480 and @okno4.y == 0 and @status_window.y == 370 and @okno6.x == 480 and @command_window.x == 0 and @okno7.x == 0
@appearing = false
end
end
def update
if @appearing
appear
end
@okno1.update
@okno2.update
@okno3.update
@okno4.update
@status_window.update
@okno6.update
@command_window.update
@spriteset.update
@okno7.update
#-------------------------------------------------------------------------------
# Reszta Scene_Menu ------------------------------------------------------------
#-------------------------------------------------------------------------------
if @command_window.active
update_command
return
end
if @status_window.active
update_status
return
end
end
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0 # item
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1 # skill
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
if $game_system.save_disabled
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Save.new
when 5 # load
$game_system.se_play($data_system.decision_se)
$scene = Scene_Loading.new
when 6 # end game
$game_system.se_play($data_system.decision_se)
$scene = Scene_End.new
end
return
end
end
def update_status
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 1 # skill
if $game_party.actors[@status_window.index].restriction >= 2
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
#-------------------------------------------------------------------------------
# Window_Selectable2 -----------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Selectable2 < Window_Base
attr_reader :index
attr_reader :help_window
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 4
@index = -1
end
def index=(index)
@index = index
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
def row_max
return (@item_max + @column_max - 1) / @column_max
end
def top_row
return self.ox / 32
end
def top_row=(row)
if row < 0
row = 0
end
if row > row_max - 1
row = row_max - 1
end
self.ox = row * 32
end
def page_row_max
return (self.height - 32) / 32
end
def page_item_max
return page_row_max * @column_max
end
def help_window=(help_window)
@help_window = help_window
if self.active and @help_window != nil
update_help
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
row = @index / @column_max
if row < self.top_row
self.top_row = row
end
if row > self.top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1)
end
cursor_width = self.width / @column_max - 32
y = @index % @column_max * (cursor_width + 32)
x = @index / @column_max * 32 - self.oy
self.cursor_rect.set(x, y, cursor_width, 32)
end
def update
super
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::DOWN)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
if Input.repeat?(Input::UP)
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
if Input.repeat?(Input::RIGHT)
if @column_max >= 2 and @index < @item_max - 1
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
if Input.repeat?(Input::LEFT)
if @column_max >= 2 and @index > 0
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
end
if Input.repeat?(Input::R)
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
$game_system.se_play($data_system.cursor_se)
@index = [@index + self.page_item_max, @item_max - 1].min
self.top_row += self.page_row_max
end
end
if Input.repeat?(Input::L)
if self.top_row > 0
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.top_row -= self.page_row_max
end
end
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
end
#-------------------------------------------------------------------------------
# Scene_Loading ----------------------------------------------------------------
#-------------------------------------------------------------------------------
class Scene_Loading < Scene_File
def initialize
$game_temp = Game_Temp.new
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("Czy chcesz wczytać grę?")
end
def on_decision(filename)
unless FileTest.exist?(filename)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open(filename, "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
def on_cancel
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(5)
end
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
end
#-------------------------------------------------------------------------------
# Scene_End --------------------------------------------------------------------
#-------------------------------------------------------------------------------
class Scene_End
alias oldupdate update
def update
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(6)
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0 # to title
command_to_title
when 1 # shutdown
command_shutdown
when 2 # quit
command_cancel
$scene = Scene_Menu.new(6)
end
return
oldupdate
end
end
end
#-------------------------------------------------------------------------------
# Window_Postać (Status Menu) --------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Postać < Window_Selectable2
def initialize
super(0, 480, 640, 110)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
refresh
self.active = false
self.index = -1
self.back_opacity = Przezroczystość
end
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = i * 160
y = 0
actor = $game_party.actors[i]
draw_actor_graphic(actor, x + 100, y + 65)
draw_actor_name(actor, x, y)
draw_actor_state(actor, x, y + 32)
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index * 160, 0, self.height + 18, 78)
end
end
end
#-------------------------------------------------------------------------------
# Napis "Menu" u góry ekranu ---------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Napis < Window_Base
def initialize
super(0, -50, 640, 50)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(100, -3, 400, 25, Napis_u_góry_ekranu, 1)
end
end
#-------------------------------------------------------------------------------
# Window_Lokacja ---------------------------------------------------------------
#-------------------------------------------------------------------------------
class Game_Map
def name
$map_infos[@map_id]
end
end
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
class Window_Lokacja < Window_Base
def initialize
super(640, 306, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
cx = contents.text_size($game_map.name).width
self.contents.draw_text(124-cx, 0, cx, 32, $game_map.name, 1)
end
end
#-------------------------------------------------------------------------------
# Window_Gold ------------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Gold2 < Window_Base
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end
#-------------------------------------------------------------------------------
# Window_Steps -----------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Steps2 < Window_Base
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, Liczba_kroków)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)
end
end
#-------------------------------------------------------------------------------
# Window_PlayTime --------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_PlayTime2 < Window_Base
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, Czas_gry)
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
end
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#-------------------------------------------------------------------------------
# Window_Reputacja -------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Reputacja < Window_Base
def initialize
super(640, 306, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
@reputacja = $game_variables[Zmienna]
if @reputacja == 0
self.contents.draw_text(0, 0, 124, 32, Poziom_1, 1)
end
if @reputacja == 10
self.contents.draw_text(0, 0, 124, 32, Poziom_2, 1)
end
if @reputacja == 30
self.contents.draw_text(0, 0, 124, 32, Poziom_3, 1)
end
if @reputacja == 50
self.contents.draw_text(0, 0, 124, 32, Poziom_4, 1)
end
if @reputacja == 85
self.contents.draw_text(0, 0, 124, 32, Poziom_5, 1)
end
if @reputacja == 100
self.contents.draw_text(0, 0, 124, 32, Poziom_6, 1)
end
end
end
Pomogła: 232 razy Dołączyła: 18 Wrz 2007 Posty: 2424
Wysłany: Czw 08 Lip, 2010 20:40
Wersja z animowanymi postaciami
Spoiler:
Kod:
# Autor - Gatoz (shiwt). Szczególne podziękowania dla Thieffer'a. Egrimowi i
# HellKillerowi też dzięki za pomoc przy malutkim błędzie ;)
# Jest mój pierwszy CMS więc proszę o wyrozumiałość :]
# Dodałem możliwość zmiany przezroczystości, czcionki i jej rozmiaru, kilka
# napisów znajdujących się w menu, tj. czas gry, kroki i inne. Szybkość
# wchodzenia okienek. Zmienna odpowiadającej za reputację i szybka możliwość
# zmiany poszczególnych nazw w reputacji.
Pomógł: 13 razy Dołączył: 02 Lip 2010 Posty: 131 Skąd: z Polski
Wysłany: Sro 14 Lip, 2010 21:09
Jest to reputacja. Na początku skryptu się wybiara6 możliwych do wybrania. Jeżeli jakas zmienna będzie wynosić ileś, to ta reputacja się zmieni. Gdzieś na końcu skryptu musisz sprawdzić ile ustawiłem. Oczywiście możesz to dowolnie z edytować.
Te rangi są oparte na zmiennej prawda ?
Wiec można to zrobić na zasadzie ustawienia warunku ze zmienna XXX(ta od rang) wynosi 2 lub wyżej, wtedy strażnik nas wpuszcza jeśli nie mówi nam że potrzebna nam ranga 2.
Pomógł: 13 razy Dołączył: 02 Lip 2010 Posty: 131 Skąd: z Polski
Wysłany: Pią 16 Lip, 2010 12:19
UWAGA !!!
W tej chwili wpadł mi pomysł do głowy co do systemu reputacji i jest troszeczkę łatwiejszy w obsłudze.
Mój zwykły poprawiony kod:
Spoiler:
Kod:
# Autor - Gatoz. Szczególne podziękowania dla Thieffer'a. Egrimowi i
# HellKillerowi też dzięki za pomoc przy malutkim błedzie ;)
# Jest mój pierwszy CMS więc proszę o wyrozumiałość :]
# Na końcu skryptu można z edytować pozycje w reputacji i inne rzeczy.
# Do dodawania reputacji są potrzebne 2 zmienne. Zmienna [0001] Odpowaiada za
# reputację, dlatego dodajemy tylko do zmiennej [0002] punkty. Ustawiamy typowe
# zdarzenie, że jak zmienna [0002] jest równa np. 30 to zmienna [0001] też jest
# równa 30. Wszystko jest ok. Jak ktoś nie rozumie to proszę ściągną demko ;]
# Data powstania skryptu: 1 marca 17:38
# Dodałem możliwość zmiany przezroczystości, czcionki i jej rozmiaru, kilka
# napisów znajdujących się w menu, tj. czas gry, kroki i inne. Szybkość
# wchodzenia okienek. Zmienna odpowiadającej za reputację i szybka możliwość
# zmiany poszczególnych nazw w reputacji.
def appear
@okno1.x -= Szybkość if @okno1.x > 480
@okno2.x -= Szybkość if @okno2.x > 480
@okno3.x -= Szybkość if @okno3.x > 480
@okno4.y += Szybkość if @okno4.y < 0
@status_window.y -= Szybkość if @status_window.y > 370
@okno6.x -= Szybkość if @okno6.x > 480
@command_window.x += Szybkość if @command_window.x < 0
@okno7.x += Szybkość if @okno7.x < 0
if @okno1.x == 480 and @okno2.x == 480 and @okno3.x == 480 and @okno4.y == 0 and @status_window.y == 370 and @okno6.x == 480 and @command_window.x == 0 and @okno7.x == 0
@appearing = false
end
end
def update
if @appearing
appear
end
@okno1.update
@okno2.update
@okno3.update
@okno4.update
@status_window.update
@okno6.update
@command_window.update
@spriteset.update
@okno7.update
#-------------------------------------------------------------------------------
# Reszta Scene_Menu ------------------------------------------------------------
#-------------------------------------------------------------------------------
if @command_window.active
update_command
return
end
if @status_window.active
update_status
return
end
end
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0 # item
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1 # skill
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
if $game_system.save_disabled
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Save.new
when 5 # load
$game_system.se_play($data_system.decision_se)
$scene = Scene_Loading.new
when 6 # end game
$game_system.se_play($data_system.decision_se)
$scene = Scene_End.new
end
return
end
end
def update_status
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 1 # skill
if $game_party.actors[@status_window.index].restriction >= 2
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
#-------------------------------------------------------------------------------
# Window_Selectable2 -----------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Selectable2 < Window_Base
attr_reader :index
attr_reader :help_window
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 4
@index = -1
end
def index=(index)
@index = index
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
def row_max
return (@item_max + @column_max - 1) / @column_max
end
def top_row
return self.ox / 32
end
def top_row=(row)
if row < 0
row = 0
end
if row > row_max - 1
row = row_max - 1
end
self.ox = row * 32
end
def page_row_max
return (self.height - 32) / 32
end
def page_item_max
return page_row_max * @column_max
end
def help_window=(help_window)
@help_window = help_window
if self.active and @help_window != nil
update_help
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
row = @index / @column_max
if row < self.top_row
self.top_row = row
end
if row > self.top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1)
end
cursor_width = self.width / @column_max - 32
y = @index % @column_max * (cursor_width + 32)
x = @index / @column_max * 32 - self.oy
self.cursor_rect.set(x, y, cursor_width, 32)
end
def update
super
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::DOWN)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
if Input.repeat?(Input::UP)
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
if Input.repeat?(Input::RIGHT)
if @column_max >= 2 and @index < @item_max - 1
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
if Input.repeat?(Input::LEFT)
if @column_max >= 2 and @index > 0
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
end
if Input.repeat?(Input::R)
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
$game_system.se_play($data_system.cursor_se)
@index = [@index + self.page_item_max, @item_max - 1].min
self.top_row += self.page_row_max
end
end
if Input.repeat?(Input::L)
if self.top_row > 0
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.top_row -= self.page_row_max
end
end
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
end
#-------------------------------------------------------------------------------
# Scene_Loading ----------------------------------------------------------------
#-------------------------------------------------------------------------------
class Scene_Loading < Scene_File
def initialize
$game_temp = Game_Temp.new
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("Czy chcesz wczytać grę?")
end
def on_decision(filename)
unless FileTest.exist?(filename)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open(filename, "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
def on_cancel
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(5)
end
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
end
#-------------------------------------------------------------------------------
# Scene_End --------------------------------------------------------------------
#-------------------------------------------------------------------------------
class Scene_End
alias oldupdate update
def update
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(6)
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0 # to title
command_to_title
when 1 # shutdown
command_shutdown
when 2 # quit
command_cancel
$scene = Scene_Menu.new(6)
end
return
oldupdate
end
end
end
#-------------------------------------------------------------------------------
# Window_Postać (Status Menu) --------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Postać < Window_Selectable2
def initialize
super(0, 480, 640, 110)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
refresh
self.active = false
self.index = -1
self.back_opacity = Przezroczystość
end
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = i * 160
y = 0
actor = $game_party.actors[i]
draw_actor_graphic(actor, x + 100, y + 65)
draw_actor_name(actor, x, y)
draw_actor_state(actor, x, y + 32)
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index * 160, 0, self.height + 18, 78)
end
end
end
#-------------------------------------------------------------------------------
# Napis "Menu" u góry ekranu ---------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Napis < Window_Base
def initialize
super(0, -50, 640, 50)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(100, -3, 400, 25, Napis_u_góry_ekranu, 1)
end
end
#-------------------------------------------------------------------------------
# Window_Lokacja ---------------------------------------------------------------
#-------------------------------------------------------------------------------
class Game_Map
def name
$map_infos[@map_id]
end
end
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
class Window_Lokacja < Window_Base
def initialize
super(640, 306, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
cx = contents.text_size($game_map.name).width
self.contents.draw_text(124-cx, 0, cx, 32, $game_map.name, 1)
end
end
#-------------------------------------------------------------------------------
# Window_Gold ------------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Gold2 < Window_Base
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end
#-------------------------------------------------------------------------------
# Window_Steps -----------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Steps2 < Window_Base
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, Liczba_kroków)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)
end
end
#-------------------------------------------------------------------------------
# Window_PlayTime --------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_PlayTime2 < Window_Base
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, Czas_gry)
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
end
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#-------------------------------------------------------------------------------
# Window_Reputacja -------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Reputacja < Window_Base
def initialize
super(640, 306, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
@reputacja = $game_variables[Zmienna]
if @reputacja >= 0
self.contents.draw_text(0, 0, 124, 32, Poziom_1, 1)
end
if @reputacja >= 10
self.contents.clear
self.contents.draw_text(0, 0, 124, 32, Poziom_2, 1)
end
if @reputacja >= 30
self.contents.clear
self.contents.draw_text(0, 0, 124, 32, Poziom_3, 1)
end
if @reputacja >= 50
self.contents.clear
self.contents.draw_text(0, 0, 124, 32, Poziom_4, 1)
end
if @reputacja >= 85
self.contents.clear
self.contents.draw_text(0, 0, 124, 32, Poziom_5, 1)
end
if @reputacja >= 100
self.contents.clear
self.contents.draw_text(0, 0, 124, 32, Poziom_6, 1)
end
end
end
Kod z poruszającymi postaciami, który zamieściła Ayene:
Spoiler:
Kod:
# Autor - Gatoz (shiwt). Szczególne podziękowania dla Thieffer'a. Egrimowi i
# HellKillerowi też dzięki za pomoc przy malutkim błędzie ;)
# Jest mój pierwszy CMS więc proszę o wyrozumiałość :]
# Dodałem możliwość zmiany przezroczystości, czcionki i jej rozmiaru, kilka
# napisów znajdujących się w menu, tj. czas gry, kroki i inne. Szybkość
# wchodzenia okienek. Zmienna odpowiadającej za reputację i szybka możliwość
# zmiany poszczególnych nazw w reputacji.
def appear
@okno1.x -= Szybkość if @okno1.x > 480
@okno2.x -= Szybkość if @okno2.x > 480
@okno3.x -= Szybkość if @okno3.x > 480
@okno4.y += Szybkość if @okno4.y < 0
@status_window.y -= Szybkość if @status_window.y > 370
@okno6.x -= Szybkość if @okno6.x > 480
@command_window.x += Szybkość if @command_window.x < 0
@okno7.x += Szybkość if @okno7.x < 0
if @okno1.x == 480 and @okno2.x == 480 and @okno3.x == 480 and @okno4.y == 0 and @status_window.y == 370 and @okno6.x == 480 and @command_window.x == 0 and @okno7.x == 0
@appearing = false
end
end
def update
if @appearing
appear
end
@okno1.update
@okno2.update
@okno3.update
@okno4.update
@status_window.update
@okno6.update
@command_window.update
@spriteset.update
@okno7.update
#-------------------------------------------------------------------------------
# Reszta Scene_Menu ------------------------------------------------------------
#-------------------------------------------------------------------------------
if @command_window.active
update_command
return
end
if @status_window.active
update_status
return
end
end
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
if $game_party.actors.size == 0 and @command_window.index < 4
$game_system.se_play($data_system.buzzer_se)
return
end
case @command_window.index
when 0 # item
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1 # skill
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
if $game_system.save_disabled
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Save.new
when 5 # load
$game_system.se_play($data_system.decision_se)
$scene = Scene_Loading.new
when 6 # end game
$game_system.se_play($data_system.decision_se)
$scene = Scene_End.new
end
return
end
end
def update_status
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 1 # skill
if $game_party.actors[@status_window.index].restriction >= 2
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
$game_system.se_play($data_system.decision_se)
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
#-------------------------------------------------------------------------------
# Window_Selectable2 -----------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Selectable2 < Window_Base
attr_reader :index
attr_reader :help_window
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 4
@index = -1
end
def index=(index)
@index = index
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
def row_max
return (@item_max + @column_max - 1) / @column_max
end
def top_row
return self.ox / 32
end
def top_row=(row)
if row < 0
row = 0
end
if row > row_max - 1
row = row_max - 1
end
self.ox = row * 32
end
def page_row_max
return (self.height - 32) / 32
end
def page_item_max
return page_row_max * @column_max
end
def help_window=(help_window)
@help_window = help_window
if self.active and @help_window != nil
update_help
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
row = @index / @column_max
if row < self.top_row
self.top_row = row
end
if row > self.top_row + (self.page_row_max - 1)
self.top_row = row - (self.page_row_max - 1)
end
cursor_width = self.width / @column_max - 32
y = @index % @column_max * (cursor_width + 32)
x = @index / @column_max * 32 - self.oy
self.cursor_rect.set(x, y, cursor_width, 32)
end
def update
super
if self.active and @item_max > 0 and @index >= 0
if Input.repeat?(Input::DOWN)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
if Input.repeat?(Input::UP)
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
if Input.repeat?(Input::RIGHT)
if @column_max >= 2 and @index < @item_max - 1
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
if Input.repeat?(Input::LEFT)
if @column_max >= 2 and @index > 0
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
end
if Input.repeat?(Input::R)
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
$game_system.se_play($data_system.cursor_se)
@index = [@index + self.page_item_max, @item_max - 1].min
self.top_row += self.page_row_max
end
end
if Input.repeat?(Input::L)
if self.top_row > 0
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.top_row -= self.page_row_max
end
end
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
end
#-------------------------------------------------------------------------------
# Scene_Loading ----------------------------------------------------------------
#-------------------------------------------------------------------------------
class Scene_Loading < Scene_File
def initialize
$game_temp = Game_Temp.new
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("Czy chcesz wczytać grę?")
end
def on_decision(filename)
unless FileTest.exist?(filename)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open(filename, "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
def on_cancel
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(5)
end
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
end
#-------------------------------------------------------------------------------
# Scene_End --------------------------------------------------------------------
#-------------------------------------------------------------------------------
class Scene_End
alias oldupdate update
def update
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(6)
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0 # to title
command_to_title
when 1 # shutdown
command_shutdown
when 2 # quit
command_cancel
$scene = Scene_Menu.new(6)
end
return
oldupdate
end
end
end
#-------------------------------------------------------------------------------
# Window_Postać (Status Menu) --------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Postać < Window_Selectable2
def initialize
super(0, 480, 640, 110)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
@frame = 0
refresh
self.active = false
self.index = -1
self.back_opacity = Przezroczystość
end
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = i * 160
y = 0
actor = $game_party.actors[i]
draw_actor_sprite(actor, x + 90, y + 10)
draw_actor_name(actor, x, y)
draw_actor_state(actor, x, y + 32)
end
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index * 160, 0, self.height + 18, 78)
end
end
def draw_actor_sprite (actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
src_rect = Rect.new(bitmap.width / 4 * @frame, 0, bitmap.width / 4, bitmap.height / 4)
cw = bitmap.width / 4
ch = bitmap.height / 4
self.contents.stretch_blt(Rect.new(x, y, cw, ch), bitmap, src_rect)
end
def update
super
if Graphics.frame_count % 10 == 0
@frame == 3 ? @frame = 0 : @frame += 1
refresh
end
end
end
#-------------------------------------------------------------------------------
# Napis "Menu" u góry ekranu ---------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Napis < Window_Base
def initialize
super(0, -50, 640, 50)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(100, -3, 400, 25, Napis_u_góry_ekranu, 1)
end
end
#-------------------------------------------------------------------------------
# Window_Lokacja ---------------------------------------------------------------
#-------------------------------------------------------------------------------
class Game_Map
def name
$map_infos[@map_id]
end
end
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
class Window_Lokacja < Window_Base
def initialize
super(640, 306, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
cx = contents.text_size($game_map.name).width
self.contents.draw_text(124-cx, 0, cx, 32, $game_map.name, 1)
end
end
#-------------------------------------------------------------------------------
# Window_Gold ------------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Gold2 < Window_Base
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end
#-------------------------------------------------------------------------------
# Window_Steps -----------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Steps2 < Window_Base
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, Liczba_kroków)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)
end
end
#-------------------------------------------------------------------------------
# Window_PlayTime --------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_PlayTime2 < Window_Base
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, Czas_gry)
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
end
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#-------------------------------------------------------------------------------
# Window_Reputacja -------------------------------------------------------------
#-------------------------------------------------------------------------------
class Window_Reputacja < Window_Base
def initialize
super(640, 306, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = Czcionka
self.contents.font.size = Rozmiar
self.back_opacity = Przezroczystość
refresh
end
def refresh
self.contents.clear
@reputacja = $game_variables[Zmienna]
if @reputacja == 0
self.contents.draw_text(0, 0, 124, 32, Poziom_1, 1)
end
self.contents.clear
if @reputacja == 10
self.contents.draw_text(0, 0, 124, 32, Poziom_2, 1)
end
self.contents.clear
if @reputacja == 30
self.contents.draw_text(0, 0, 124, 32, Poziom_3, 1)
end
self.contents.clear
if @reputacja == 50
self.contents.draw_text(0, 0, 124, 32, Poziom_4, 1)
end
self.contents.clear
if @reputacja == 85
self.contents.draw_text(0, 0, 124, 32, Poziom_5, 1)
end
self.contents.clear
if @reputacja == 100
self.contents.draw_text(0, 0, 124, 32, Poziom_6, 1)
end
end
end
Napiszę wam dokładną instrukcję bo mi się nie chce dema robić.
1. Na początku skryptu można wybrać zmienną odpowiadającą oraz 6 rang.
2. Na samym dole skryptu mamy napisane:
Spoiler:
Kod:
if @reputacja >= 0
self.contents.draw_text(0, 0, 124, 32, Poziom_1, 1)
end
if @reputacja >= 10
self.contents.draw_text(0, 0, 124, 32, Poziom_2, 1)
end
if @reputacja >= 30
self.contents.draw_text(0, 0, 124, 32, Poziom_3, 1)
end
if @reputacja >= 50
self.contents.draw_text(0, 0, 124, 32, Poziom_4, 1)
end
if @reputacja >= 85
self.contents.draw_text(0, 0, 124, 32, Poziom_5, 1)
end
if @reputacja >= 100
self.contents.draw_text(0, 0, 124, 32, Poziom_6, 1)
end
Kod:
if @reputacja >= 0
self.contents.draw_text(0, 0, 124, 32, Poziom_1, 1)
jeżeli zmienna X będzie wynosić 0, to będzie ranga ta co ustaliłeś na górze pod nazwą Poziom_1.
I tak dalej robicie.
Oczywiście jak jest np.
Kod:
if @reputacja == 100
- to to 100 można zmienić na inną liczbę która będzie wam odpowiadać.
3. Teraz po jakimś wykonanym zadaniu dajecie:
zmienna X + 1 czy ile chcecie
a przy tym strażniku dajecie:
czy zmienna X jest równa albo większa od np. 10 - to on was wpuszcza.
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