- 21/8/06
- 5,784
- 24,060
Hướng Dẫn làm 1 game HarvestMoon từ A > Z bẳng RPG maker VX
Nguồn - Gamevn
Bạn là 1 fan của game HM ? Vậy bạn có bao giờ nghĩ đến việc tự tạo cho mình 1 game y như phong cách của bạn chưa ? Tôi thì có , tôi mang ý định đó suốt 4 năm nhưng cuối cùng vẫn không thực hiện được ? Tôi tự hỏi tại sao Vâng, nếu tôi biết thì tôi đã ko tự hỏi ,nếu tôi tự hỏi thì có nghĩa là tôi ko biết, nhưng tôi mong khi tôi viết bài này , có một ai đó sẽ giúp tôi tìm ra câu trả lời ,và hoàn thành ý định đó hộ tôi
Các bạn có thể chẳng biết làm game thế nào cả ? các bạn chẳng biết gì về code hay graphic PTS gì cả, nhưng đừng lo, cái cần nhất mà game maker cần là ý tường , bản thân tôi lại thiếu cái đó .(có thể đây là 1 lý do mà tôi ko thể hoàn thành project này đc )
Thôi thì dài dòng văn tự quá rồi , chương trình tôi sử dụng để làm game là Rpg maker VX
Các bạn có thể down nó tại
http://www.mediafire.com/?mzjnla2mwwy
Ccòn nữa, trước khi bắt đầu xin các bạn vui long đọc hết những gì tôi đã viết trong topic này
http://forum.gamevn.com/showthread....g-dan-nhung-dieu-co-ban-nhat-cua-RPG-maker-VX
Tuy đó ko phải hướng dẫn làm 1 game thể loại HM nhưng lại chứa yếu tố rất cần thiết là cơ bản cho mọi thể loại ,và nếu các bạn ko đọc bài đó thì tôi nghĩ tôi sắp nói gì dưới đây chắc các bạn cũng ko hiểu !
-----------------------------------------------------
Tổng hợp những hệ thống của 1 game HM cần có
Chúng ta bắt đầu thống kê nhé :
1. Thời gian
2. TV
3. Tình cảm với các cô gái (chàng trai)
4. Chăn nuôi
5. Trồng trọt
6. Thời tiết
7. Nấu nướng
Còn gì nữa không nhỉ ? Tôi nghĩ cũng tạm đủ rồi, tôi sẽ hướng dẫn các cậu làm tất cả 7 chức năng này, 7 chức năng này là nền móng buộc phải có của 1 game HM nếu các bạn tạo đc 7 hệ thống này, việc tạo 1 game HM chỉ còn là vấn đề thời gian ……
---------- Post added at 15:41 ---------- Previous post was at 15:29 ----------
Thời gian
Cái bạn cần ở đây là script , script là 1 đoạn code 1 ,loại ngôn ngữ dành riêng cho RPG maker dùng để mở rộng hay tạo 1 số hệ thống cho game
Bây giờ tôi cần script thời gian ở đây tôi cùng đọan code này :
Copy đoạn code này
Mã:
#==============================================================================
# ● Script Function Calls
#------------------------------------------------------------------------------
# ● $kts.stop - Stops time (can be used for cutscenes)
# ● $kts.go - Resumes time (don't forget to use this!)
# ● $kts.sec(n) - progresses time forward (n) seconds
# ● $kts.min(n) - progresses time forward (n) minutes
# ● $kts.hours(n) - progresses time forward (n) hours
# ● $kts.days(n) - progresses time forward (n) days
# ● $kts.jump_to_hour(n) - progresses time forward TO the specified hour.
#==============================================================================
# ● Game Database Setup
#------------------------------------------------------------------------------
# This script, by defult, uses the following game variables and switches:
# Database Variables:
# [1] The Current Time [4] The Current Hour
# [2] The Current Second [5] The Current Day
# [3] The Current Minute [6] Name of the Current Day
# Database Switches
# [1] ON during night hours (2200-0400)(10pm-4am)
# [2] ON during dawn hours (0500-0800)( 5am-8am)
# [3] ON during daytime hours (0900-1800)( 9am-6pm)
# [4] ON during sunset hours (1900-2100)( 7pm-9pm)
#==============================================================================
#==============================================================================
# Stores variables and user defined settings for the time system.
#==============================================================================
module KTS
#-----------------------------------------------------------------------
# User Definable Clock Settings
#-----------------------------------------------------------------------
# Sets the speed multiplier of the clock. 1 is real time. A higher
# value will give you a faster clock. Default is 100.
SPEED = 60
#AMPM (True: 12-hour clock, False: 24-hour clock)
AMPM = true
# Sets the time at the start of your game.
START_HOUR = 9
START_DAY = 1
#-----------------------------------------------------------------------
# If you want custom day names, edit away!
#-----------------------------------------------------------------------
DAY_NAMES = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
#-----------------------------------------------------------------------
# Settings for Time Periods
#-----------------------------------------------------------------------
T1 = [ 0,5 ] # Night # Sets time periods for tinting effects
T2 = [ 6,8 ] # Dawn # [Start Hour, End Hour] for time period
T3 = [ 9,18] # Day # Use 24-hour values for time periods
T4 = [19,21] # Sunset
T5 = [22,24] # Night # <- Ex: Night is between 23:00 and 24:00
#-----------------------------------------------------------------------
# Settings for Output to Game Variables option.
#-----------------------------------------------------------------------
# Set this to true to output the current time to game variables.
DATABASE_OUTPUT = true
# Game Variable to be used for time output.
TIME = 101 #(Time in string format. Ex: "2:48 AM" or "02:48")
SECONDS = 102
MINUTES = 103
HOURS = 104
DAYS = 105
DAYNAME = 106
# Game Switches to be used for time output.
NIGHT = 17 # This switch is on during night hours (2200-0400)(10pm-4am)
DAWN = 18 # This switch is on during dawn hours (0500-0800)( 5am-8am)
DAY = 19 # This switch is on during daytime hours (0900-1800)( 9am-6pm)
SUNSET = 20 # This switch is on during sunset hours (1900-2100)( 7pm-9pm)
#-----------------------------------------------------------------------
# Settings for time controlled screen toning
#-----------------------------------------------------------------------
TONE_SWITCH_ID = 40
# True will enable screen toning to be used by the script.
USE_TONE = true
# Sets the duration of tone changes (in frames)
FADE_LENGTH = 120
# Defines tones to be used in the corresponding time periods defined above.
# RED, GREEN, BLUE, GREY
C1 = Tone.new(-187, -119, -17, 68)
C2 = Tone.new( 17, -51, -102, 0)
C3 = Tone.new( 0, 0, 0, 0)
C4 = Tone.new( -68, -136, -34, 0)
C5 = Tone.new(-187, -119, -17, 68)
# Defines anti-tones
A1 = Tone.new( 187, 119, 17, -68)
A2 = Tone.new( -17, 51, 102, 0)
A3 = Tone.new( 0, 0, 0, 0)
A4 = Tone.new( 68, 136, 34, 0)
A5 = Tone.new( 187, 119, 17, -68)
end
#==============================================================================
# Core Time System Engine
#==============================================================================
class Kylock_Time_System
# sets instance variables
def initialize
$kts_map_data = load_data("Data/MapInfos.rvdata")
@event_offset = (KTS::START_HOUR * 3600) + (KTS::START_DAY * 86400)
@kts_stop = false
$kts_event_tone = false
$kts_battle_tone = true
$kts_anti_tone = Tone.new(0,0,0,0)
end
# Computes current time and updates variables if used
def update
if !@kts_stop
@total_seconds = (Graphics.frame_count * KTS::SPEED / 60) + @event_offset
@seconds = (@total_seconds) % 60
@minutes = (@total_seconds / 60) % 60
@hours = (@total_seconds / 3600) % 24
@days = (@total_seconds / 86400)
update_tint
if KTS::DATABASE_OUTPUT
$game_variables[KTS::TIME] = getTime
end
end
end
def update_variables
$game_variables[KTS::SECONDS] = @seconds
$game_variables[KTS::MINUTES] = @minutes
$game_variables[KTS::HOURS] = @hours
$game_variables[KTS::DAYS] = @days
$game_variables[KTS::DAYNAME] = getDayName
end
def update_switches
if @period == 1 || @period == 5
$game_switches[KTS::NIGHT] = true
else
$game_switches[KTS::NIGHT] = false
end
if @period == 2
$game_switches[KTS::DAWN] = true
else
$game_switches[KTS::DAWN] = false
end
if @period == 3
$game_switches[KTS::DAY] = true
else
$game_switches[KTS::DAY] = false
end
if @period == 4
$game_switches[KTS::SUNSET] = true
else
$game_switches[KTS::SUNSET] = false
end
end
def getTime
if KTS::AMPM
# Formats a 12-Hour Clock
if @hours > 12
hours1 = @hours - 12
if hours1 > 9
time = sprintf("%02d:%02d" + " PM", hours1, @minutes, @seconds)
else
time = sprintf("%01d:%02d" + " PM", hours1, @minutes, @seconds)
end
else
if @hours > 9
time = sprintf("%02d:%02d" + " AM", @hours, @minutes, @seconds)
else
time = sprintf("%01d:%02d" + " AM", @hours, @minutes, @seconds)
end
end
#-------------------------------------------------------------------------------
# 12-Format Fix by the unsung bard
#-------------------------------------------------------------------------------
# if @hours == 12
# time = sprintf("%01d:%02d:%02d" + " PM", @hours, @minutes, @seconds)
# end
# if @hours == 0
# time = sprintf("%02d:%02d:%02d" + " AM", "12", @minutes, @seconds)
# end
#-------------------------------------------------------------------------------
return time
else
# Formats a 24-Hour Clock
time = sprintf("%02d:%02d:%02d", @hours, @minutes, @seconds)
return time
end
end
#-----------------------------------------------------------------------
# Script Command Functions
#-----------------------------------------------------------------------
def stop
@time_stopped = @total_seconds
@kts_stop = true
end
def go
total_seconds = (Graphics.frame_count * KTS::SPEED / 60) + @event_offset
@event_offset -= (total_seconds - @time_stopped)
@kts_stop = false
end
def sec(sec = 0)
@event_offset += sec
end
def min(min = 0)
@event_offset += min * 60
end
def hours(hours = 0)
@event_offset += hours * 3600
end
def days(days = 0)
@event_offset += days * 86400
end
def jump_to_hour(jhour = 0)
while @hours != jhour
@event_offset += 1
$kts.update
end
end
#-----------------------------------------------------------------------
# Script Support/Misc Functions
#-----------------------------------------------------------------------
def getDayName
weekday = (@days % KTS::DAY_NAMES.length)
return KTS::DAY_NAMES[weekday]
end
#-----------------------------------------------------------------------
# Screen Tone Functions
#-----------------------------------------------------------------------
def update_tint(duration = KTS::FADE_LENGTH)
return if $BTEST
unless $game_switches[KTS::TONE_SWITCH_ID]
if KTS::USE_TONE && !$kts_event_tone && $kts_map_data[$game_map.map_id].outside_tint?
if @hours >= KTS::T1[0] and @hours <= KTS::T1[1]
@period = 1
screen.start_tone_change(KTS::C1,duration)
$kts_anti_tone = KTS::A1
elsif @hours >= KTS::T2[0] and @hours <= KTS::T2[1]
@period = 2
screen.start_tone_change(KTS::C2,duration)
$kts_anti_tone = KTS::A2
elsif @hours >= KTS::T3[0] and @hours <= KTS::T3[1]
@period = 3
screen.start_tone_change(KTS::C3,duration)
$kts_anti_tone = KTS::A3
elsif @hours >= KTS::T4[0] and @hours <= KTS::T4[1]
@period = 4
screen.start_tone_change(KTS::C4,duration)
$kts_anti_tone = KTS::A4
elsif @hours >= KTS::T5[0] and @hours <= KTS::T5[1]
@period = 5
screen.start_tone_change(KTS::C5,duration)
$kts_anti_tone = KTS::A5
end
else
# no tone if indoors
if !$kts_map_data[$game_map.map_id].outside_tint?
screen.start_tone_change(Tone.new(0,0,0,0),duration)
end
end
end
end
def screen
if $game_temp.in_battle
return $game_troop.screen
else
return $game_map.screen
end
end
end
class Spriteset_Map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias kts_initialize initialize
def initialize
$kts.update_switches if !@kts_stop && KTS::DATABASE_OUTPUT
$kts.update_variables if !@kts_stop && KTS::DATABASE_OUTPUT
kts_initialize
end
end
#==============================================================================
# Instantly updates screen tone when a new map is loaded.
#==============================================================================
class Game_Map
alias kts_setup setup
def setup(map_id)
kts_setup(map_id)
$kts_event_tone = false
$kts.update
$kts.update_tint(0)
end
end
#==============================================================================
# Instantly updates screen tone when a battle starts.
#==============================================================================
class Spriteset_Battle
alias kts_create_battleback create_battleback
def create_battleback
$kts.update_tint(0)
kts_create_battleback
end
end
#==============================================================================
# Temporarily disables auto-toning if an event tints the screen.
#==============================================================================
class Game_Interpreter
alias kts_Interpreter_command_223 command_223
def command_223
$kts_event_tone = true
kts_Interpreter_command_223
end
end
#==============================================================================
# Integrates the Time System into the Game System.
#==============================================================================
class Game_System
# inits a KTS object
alias kts_initialize initialize
def initialize
$kts=Kylock_Time_System.new
kts_initialize
end
# Updates kts every game frame
alias kts_update update
def update
$kts.update
kts_update
end
end
#==============================================================================
# Scans Map Names for Toning
#==============================================================================
class RPG::MapInfo
def name # Definition prevents location scripts from reading anything within
eturn @name.gsub(/\[.*\]/) {""} # brackets, including the brackets
end
def original_name
return @name
end
def outside_tint?
return @name.scan(/\[KTS\]/).size > 0
# old regexp: return @name.scan(/[\KTS]/).size > 0
end
end
#==============================================================================
# Sets up the time window for the menu.
#==============================================================================
class Window_KTS < Window_Base
def initialize(x, y)
super(x, y, 210, WLH + 52)
refresh
end
def refresh
self.contents.clear
# Change "49" or "120" higher or lower to move the words horizontally
# Change "32" higher or lower to move the words vertically
self.contents.clear
self.contents.font.color = Color.new(173, 255, 47, 255)
self.contents.draw_text(4, 15, 75, 32, $kts.getDayName , 2)
self.contents.draw_text(4, 15, 165, 32, $kts.getTime, 2)
self.contents.draw_text(152, -8, 75, 32, $game_variables[10])
end
def update
super
$kts.update
self.contents.clear
self.contents.font.color = Color.new(173, 255, 47, 255)
self.contents.draw_text(4, 15, 75, 32,$kts.getDayName , 2)
self.contents.draw_text(4, 15, 165, 32, $kts.getTime, 2)
self.contents.draw_text(152, -8, 75, 32, $game_variables[10])
end
end
#==============================================================================
# Adds the time window to the menu.
#==============================================================================
class Scene_Map < Scene_Base
alias kts_start start
def start
kts_start
@kts_window = Window_KTS.new(329,339)
@kts_window.opacity = 0
end
alias kts_terminate terminate
def terminate
kts_terminate
@kts_window.dispose
end
alias kts_update update
def update
kts_update
if $game_map.map_id != 14 and $game_map.map_id != 5 #map id clear
@kts_window.update
else
@kts_window.contents.clear
end
end
end
#==============================================================================
# Saves and Loads game time to/from save game file.
#==============================================================================
class Scene_File
alias kts_write_save_data write_save_data
def write_save_data(file)
kts_write_save_data(file)
Marshal.dump($kts, file)
end
alias kts_read_save_data read_save_data
def read_save_data(file)
kts_read_save_data(file)
$kts = Marshal.load(file)
end
end
bây giờ các bạn mở RPG maker VX ra có phải giao diện là thế này không
Bạn ấn F11
Sau đó past đoạn script vừa copy vào trên script main sẳn có như thế này
ở script này các bạn chỉ cần để ý đến line 35, 39 ,40 , 44 cái này kiến thức AV cấp 1 cũng hiểu nên tớ ko cần giải thích
Và để ý line 59 > line 64 nữa , cái này tôi sẽ nói sau !
Việc chèn script tôi chỉ hướng dẫn 1 lần , các bạn nhớ kĩ đấy
Rồi đây giờ vào game test thử xem đã có thời gian chưa ?
Kết quả đây đúng ko ? ok rồi nhưng nhin dzầy nó xấu quá các cậu nhỉ thử dùng tấm graphic của tớ xem !
down tấm ảnh này về vất vào folder “pictures”
Bây giờ tạo 1 common event với nội dung như thế này
Common event này có tác dụng show cái bức ảnh clock các bạn vừa down về đó ra ngoài map khi switch 3 được bật
Việc rất đơn giản bây giờ chúng ta chỉ cần làm cho switch 3 được bật
làm thế nào à ? đây chỉnh autorun rồi xóa đi
Kết quả tuyệt ko ? thấy cái số 0 kết chữ spring ko ? đó là số ngày , cái đó tôi thêm vào script gốc để phù hợp với thể loại game HM (thật ra thì tôi cũng thêm và chỉnh khá nhiều thứ vào script gốc rồi !)
Các bạn muốn tăng số ngày chỉ cần thay đổi số “variable no.10” ok chứ ?
Chưa xog, các bạn tưởng hệ thống thời gian trong HM nó đơn giản là tạo 1 cái clock bên ngoài map sao ? Ko phải đâu , script này có 1 hệ thống mà riêng riêng game HM rất cần đó là “thời gian có thể kích hoạt event”
Nói đơn giản 1 cái shop chỉ được vào từ 9h sáng tới 2h trưa thôi , bây giờ phải làm thế nào?
Yên tâm đã có tôi rồi :
Ta tạo 1 common event với nội dung thế này
Common event này có tác dụng kích hoạt swicth no.10 khi variable 104 của chúng ta lớn hơn hoặc = 8 và nhỏ hơn 15 , (tôi có bảo các bạn để ý line 59 > 64 trong script thời gian nhỉ, và variable “giờ” của chúng ta là no.104 đấy )
Nhìn hơi khó hiểu nhỉ, tự nhiên event kích hoạt từ 9h > 14h mà trong event này lại có số 15 và số 8 để tôi giải thích 1 chút từ 9h > 14 h có nghĩa là dưới 9h cái cửa đó ko vào đc nên có dấu < =8 số 15 cũng tương tự
Các bạn hỏi sao ko để thẵng là 9 > 14 lun á , khổ lắm các bạn ạ , để như thế nó ko hoạt động mới chết ấy chứ, tôi cũng chả hỉu nổi cái scrit này nó lạ đời kinh khủng )
để common event này hoạt động ta phải kích hoạt switch 9 trước
Để hiểu rõ tác dụng của commont event này ta thử nhé
Tạo 1 ngôi nhà và tao 1 event cửa gồm 2 page với nội dung lần lượt là thế này
test đi các chàng trai
thế là xog phần thời gian demo ,tôi gửi file đính kèm bên dưới
6 phần còn lại mỗi ngày tôi sẽ viết 1 phần , hiện tôi đc nghỉ 1 tuần nên sẽ cố gắng hoàn thành việc này do ko thể thực hiện đc lời hứa làm project này đc
Attachments
Chỉnh sửa cuối: