Tuesday, October 26, 2010

Tutorial RPG Maker 2

Ini adalah tutorial menambahkan script berenang (Hero dapat berenang) untuk RPG Maker XP, tutorial ini merupakan requesting dari seorang siswa di tempat magang kami (SMP N 1 Ciparay).
Untuk berenang kita harus menambahkan CMS (Custom Movement System) script pada database script RPGXP. Caranya sama dengan tutorial RPGXP sebelumnya. Buat script RPG baru dengan cara klik Tool di toolbar kemudian pilih Script Editor atau dengan menekan F11, kemudian buat sebuah script dengan cara klik kanan di box script klik "Insert" beri nama UMS kemudian pastekan script berikut ini.
#####################################################
#Swimming System 2.0 By Amaranth & MCgamer
#Last updated March 12, 2009
#####################################################

#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Game_Map
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Return terrain ID for a tile
#--------------------------------------------------------------------------
def terrain_tag(x, y)
if @map_id != 0
for i in [2, 1, 0]
tile_id = data[x, y, i]
if tile_id == nil
return 0
elsif tile_id > 0
return @terrain_tags[tile_id]
end
end
end
return 0
end

end


#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# establish possible swimmers
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
$swimmers = []
graphics = []
graphics = Dir.entries("Graphics/Characters")

for file in graphics
if file.include?('-SWIM')
#take out "swim" and file extension
file.gsub!(/-SWIM.*/){||''}
#add name to end of array
$swimmers << file
end
end

#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
class Game_Character
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------

#--------------------------------------------------------------------------
# * Determine if Moving
#--------------------------------------------------------------------------
def moving?

# SWIMMING: Should character swim?
check_terrain_type()

# If logical coordinates differ from real coordinates,
# movement is occurring.
return (@real_x != @x * 128 or @real_y != @y * 128)

end

#--------------------------------------------------------------------------
# * Check the terrain for the character
#--------------------------------------------------------------------------
def check_terrain_type()

#get the terrain tag # upon which character is standing
@terrain = $game_map.terrain_tag(@x, @y)

#get the name of the character's graphic
name = @character_name

#check if character's swimming graphic is currently being used (nil if no)
swim = name.match("-SWIM")

#enter or exit water (change "3" to the tag you want for water)
enter_water(swim) if @terrain == 3
exit_water(swim) if @terrain != 3

end

#--------------------------------------------------------------------------
# * Enter the water (events only)
#--------------------------------------------------------------------------
def enter_water(swim)

# Check if picture exists and not already swimming
if swim == nil and $swimmers.include?(@character_name)

# Switch to swimming graphic
@character_name += "-SWIM"

# Disable menu and save
$game_system.menu_disabled = true
$game_system.save_disabled = true

# Play splash sound
Audio.se_play("Audio/SE/127-Water02", 50, 100)

# Animate sprite
@step_anime = true

# Display swimming event
$game_map.refresh

return true

end
end

#--------------------------------------------------------------------------
# * Exit the water (events only)
#--------------------------------------------------------------------------
def exit_water(swim)

# Check if picture is not walking sprite
if swim != nil

# don't animate player while not in motion
@step_anime = false

# Display walking player
@character_name = @character_name.chomp("-SWIM")

# Display walking event
$game_map.refresh

#Enable menu and save
$game_system.menu_disabled = false
$game_system.save_disabled = false

end
end

end
Kemudian copy-kan gambar berikut ini ke Folder Graphics --> Characters.

2 comments:

  1. Makasih ya kak............
    Udah ngasih tau.............

    ReplyDelete
  2. kurang lengkap nih, event untuk membuatnya berenang belum ditulis.

    ReplyDelete