I have being trying to sdk the Pixel Movement by F0TZ, and i must say that i failed miserably... Whenever I run my game the map and the characters don't appear... I don't know why, and I would like that someone could tell me where the problem is.
BTW I TOOK ALL THE FEATURES OF F0TZ Script except for the pixelmovement..
AND I TAKE NO CREDIT FOR THIS SCRIPT since this is just copy paste from f0tz script, changing somethings to make it sdk compatible( I might have made some mistakes thoug)...
BTW I TOOK ALL THE FEATURES OF F0TZ Script except for the pixelmovement..
AND I TAKE NO CREDIT FOR THIS SCRIPT since this is just copy paste from f0tz script, changing somethings to make it sdk compatible( I might have made some mistakes thoug)...
Code:
#==============================================================================
# ** Pixel Movement
#------------------------------------------------------------------------------
# Author: F0TZ
# Version:1.0
# Date : 29-7-06
#==============================================================================
#Big Thanx to Fotz, This is just what I need to make my platforme script, you don't need to credit me
#But YOU MUST CREDIT F0TZ!!
SDK.log('Pixel Movement', 'F0TZ', 1, '2006-07-29')
if SDK.state("Pixel Movement") == true
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
INDEX =
[
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
]
X = [0, 1, 0, 1]
Y = [0, 0, 1, 1]
attr_accessor :pass_pic #Bitmap, in der die Passability-Karte temporär gespeichert wird
attr_accessor :tileset_name
attr_accessor :autotile_names
#--------------------------------------------------------------------------
# * ALIAS
#--------------------------------------------------------------------------
alias chaosg1_pixel_movement_setup setup
alias chaosg1_pixel_movement_update update
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@map_id = map_id
# Load map from file and set @map
$collision_folder = "Graphics/ZPassability/"
@map_id = 0
@display_x = 0
@display_y = 0
end
#--------------------------------------------------------------------------
# * Setup
# map_id : map ID
#--------------------------------------------------------------------------
def setup(map_id)
chaosg1_pixel_movement_setup(map_id)
self.pass_init
end
#--------------------------------------------------------------------------
# * Pass init check the pass type, This was made by fotz
#--------------------------------------------------------------------------
def pass_init
@pass_pic= nil
@pass_pic = load_bitmap($collision_folder + map_id.to_s)
@pass_type = "Map"
if @pass_pic == nil
@pass_pic = []
@pass_pic[0] = load_bitmap($collision_folder + @tileset_name)
@pass_type = "Tileset"
if @pass_pic[0] == nil
@pass_pic == nil
@pass_type = nil
else
@autotile_names.each do |name|
bitmap = load_bitmap($collision_folder + name)
if bitmap != nil
gen_autotiles(@pass_pic.length, bitmap)
else
@pass_pic[@pass_pic.length] = Bitmap.new(32*8, 32*6)
end
end
end
end
end
#--------------------------------------------------------------------------
# * New Method, To load bitmaps
#--------------------------------------------------------------------------
def load_bitmap(file)
return Bitmap.new(file)
rescue
return nil
end
#generiert die Autotiles.. (ein Auszug aus:
#Class Tilemap.
# By: Fanha Giang
# ver 1.0def )
def gen_autotiles(id,bitmap)
scroll = []
frame = []
autotile = bitmap
scroll[id] = 0
frame[id] = autotile.width / 96
width = 8 * 32 * frame[id]
height = 6 * 32
@pass_pic[id] = Bitmap.new(width, height)
for f in 0...frame[id]
for pos in 0...48
for corner in [0,1,2,3]
h = 4 * pos + corner
yy = INDEX[h] / 6
xx = INDEX[h] % 6 + f * 6
y = pos / 8
x = pos % 8 + f * 8
src_rect = Rect.new(xx * 16 , yy * 16 , 16, 16 )
@pass_pic[id].blt(x * 32 + X[corner] * 16, y * 32 + Y[corner] * 16 , autotile, src_rect)
end # end for corner
end
end
end
#--------------------------------------------------------------------------
# * Get Width
#--------------------------------------------------------------------------
def width
return @map.width*16
end
#--------------------------------------------------------------------------
# * Get Height
#--------------------------------------------------------------------------
def height
return @map.height*16
end
#--------------------------------------------------------------------------
# * Get Valid coordinates
#--------------------------------------------------------------------------
def valid?(x, y)
return ((x >= 0 and x < width-12 and y >= 0 and y < height-14))
end
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8,10)
# * 0,10 = determine if all directions are impassable
# self_event : Self (If event is determined passable)
#--------------------------------------------------------------------------
def passable?(x, y, d, self_event = nil)
# If coordinates given are outside of the map
unless valid?(x, y)
# impassable
return false
end
# Loop in all events
for event in events.values
# If tiles other than self are consistent with coordinates
if not event.through and not event.character_name == "" or event.tile_id != 0
return false
end
end
#prüft, ob begehbar (+ initialisiert Pixel, die zu prüfen sind)
if @pass_type == "Map" or @pass_type == "Tileset"
return pixel_wahl(x,y,d,self_event,@pass_type)
else
return true
end
end
#--------------------------------------------------------------------------
# * Pixel Wall
#--------------------------------------------------------------------------
def pixel_wahl(x,y,d,event,type)
x_size = 1
y_size = 1
x = (x+8)*2
y = (y-2)*2+32
rand_links = 0
rand_rechts = 0
rand_oben = 0
rand_unten = 0
mal = 0
#IF direction = 2 down
if d==2
for i in (x-x_size)..(x+x_size-1)
if i % 2 == 0 and
((type == "Map" and self.pass_map(i,y)) or ( type == "Tileset" and self.pass_tileset(i,y)))
mal += 1
end
end
if mal > ((x+x_size-1)-(x-x_size))/2
return true
end
end
#IF direction = 4 right
if d==4
for i in (y-y_size/2)..(y)
if i % 2 == 0 and
((type == "Map" and self.pass_map(x-x_size,i)) or ( type == "Tileset" and self.pass_tileset(x-x_size,i)))
mal += 1
end
end
if mal > ((y)-(y-y_size/2))/2
return true
end
end
#IF direction = 6 left
if d==6
for i in (y-y_size/2)..(y)
if i % 2 == 0 and
((type == "Map" and self.pass_map(x+x_size-1,i)) or ( type == "Tileset" and self.pass_tileset(x+x_size-1,i)))
mal += 1
end
end
if mal > ((y)-(y-y_size/2))/2
return true
end
end
#IF direction = 8 up
if d==8
for i in (x-x_size)..(x+x_size-1)
if i % 2 == 0 and
((type == "Map" and self.pass_map(i,y-y_size/2)) or ( type == "Tileset" and self.pass_tileset(i,y-y_size/2)))
mal += 1
end
end
if mal > ((x+x_size-1)-(x-x_size))/2
return true
end
end
end
#--------------------------------------------------------------------------
# * Tile set passability, this is what checks the tile set passability
#--------------------------------------------------------------------------
def pass_tileset(x,y)
layer=0
passed = []
empty = 0
type=0
x_s = x
y_s = y
while layer <= 2
pruefe = true
x=x_s
y=y_s
pos = self.data[x/32,y/32,layer]
if pos == nil
pos = 0
end
if pos >= 384
pos -= 384
sy = (pos / 8)*32
sx = (pos % 8)*32
x = sx + x%32
y = sy + y%32
type=0
elsif pos >= 48
type = pos / 48
pos = pos % 48
sy = (pos / 8)*32
sx = (pos % 8)*32
x = sx + x%32
y = sy + y%32
else
passed[layer] = 1
empty += 1
pruefe = false
end
if pruefe
pixel = @pass_pic[type].get_pixel(x, y)
if pixel != Color.new(0, 0, 0)
passed[layer] = 1
else
passed[layer] = 0
end
end
layer+=1
end
if (passed[0] == 1 and passed[1] == 1 and passed[2] == 1) or (passed[0] == 0 and passed[1] == 1 and passed[2] == 1 and ((data[x_s/32, y_s/32, 1] != 0 and @priorities[data[x_s/32, y_s/32, 1]] == 0) or (data[x_s/32, y_s/32, 2] != 0 and @priorities[data[x_s/32, y_s/32, 2]] == 0)) and empty < 2)
return true
else
return false
end
end
#--------------------------------------------------------------------------
# * MAP passability, this is what checks the Map passability
#--------------------------------------------------------------------------
def pass_map(x,y)
pixel = @pass_pic.get_pixel(x, y)
if pixel == Color.new(0, 0, 0)
return false
else
return true
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if @pass_pic == nil
self.pass_init
end
chaosg1_pixel_movement_update
end
end#class end
#==============================================================================
# ** Game_Character (part 1)
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * ALias
#--------------------------------------------------------------------------
alias chaosg1_pixel_movement_game_char_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
chaosg1_pixel_movement_game_char_initialize
#Neues:
@schritte_gemacht = 0
@schritte_zaehl=0
@old_speed = @move_speed
@walk = false
@go_path = 0
@trigger_on = 0
@sprint = false
@sprint_time = 0
@no_slide = 0
end
#--------------------------------------------------------------------------
# * Determine if Moving
#--------------------------------------------------------------------------
def moving?
return (@real_x != @x*8 or @real_y != @y*8)
end
#--------------------------------------------------------------------------
# * Determine if Passable
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8)
# * 0 = Determines if all directions are impassable (for jumping)
#--------------------------------------------------------------------------
def passable?(x, y, d,steps=32)
# Get new coordinates
steps_x = steps/2
steps_y = steps/2
new_x = x + (d == 1 ? -steps_x : d == 3 ? steps_x : d == 7 ? -steps_x : d == 9 ? steps_x : d == 6 ? steps_x : d == 4 ? -steps_x : 0)
new_y = y + (d == 1 ? steps_y : d == 3 ? steps_y : d == 7 ? -steps_y : d == 9 ? -steps_y : d == 2 ? steps_y : d == 8 ? -steps_y : 0)
# If coordinates are outside of map
unless $game_map.valid?(new_x, new_y)
# impassable
return false
end
# If through is ON
if @through
# passable
return true
end
help_x = new_x
help_y = new_y
zahl = 0
if d== 1
y+=1
x-=1
while (help_y >= y) and (help_x <= x) and ($game_map.passable?(help_x,help_y,2,self)) and ($game_map.passable?(help_x,help_y,4,self))
zahl += 8
help_y -= 8
help_x += 8
end
if zahl < new_y-y+1 and zahl < x-new_x+1
return false
end
elsif d==2
y+=1
while (help_y >= y) and ($game_map.passable?(help_x,help_y,d,self))
zahl += 8
help_y -= 8
end
if zahl < new_y-y+1
return false
end
elsif d== 3
y+=1
x+=1
while (help_y >= y) and (help_x >= x) and ($game_map.passable?(help_x,help_y,2,self)) and ($game_map.passable?(help_x,help_y,6,self))
zahl += 8
help_y -= 8
help_x -= 8
end
if zahl < new_y-y+1 and zahl < new_x-x+1
return false
end
elsif d==4
x-=1
while (help_x <= x) and ($game_map.passable?(help_x,help_y,d,self))
zahl += 8
help_x += 8
end
if zahl < x-new_x+1
return false
end
elsif d==6
x+=1
while (help_x >= x) and ($game_map.passable?(help_x,help_y,d,self))
zahl += 8
help_x -= 8
end
if zahl < new_x-x+1
return false
end
elsif d== 7
y-=1
x-=1
while (help_y <= y) and (help_x <= x) and ($game_map.passable?(help_x,help_y,8,self)) and ($game_map.passable?(help_x,help_y,4,self))
zahl += 8
help_y += 8
help_x += 8
end
if zahl < y-new_y+1 and zahl < x-new_x+1
return false
end
elsif d==8
y-=1
while (help_y <= y) and ($game_map.passable?(help_x,help_y,d,self))
zahl += 8
help_y += 8
end
if zahl < y-new_y+1
return false
end
elsif d== 9
y-=1
x+=1
while (help_y <= y) and (help_x >= x) and ($game_map.passable?(help_x,help_y,8,self)) and ($game_map.passable?(help_x,help_y,6,self))
zahl += 8
help_y += 8
help_x -= 8
end
if zahl < y-new_y+1 and zahl < new_x-x+1
return false
end
end
# Loop all events
for event in $game_map.events.values
# If event coordinates are consistent with move destination
if event != self and event.character_name != ""
# If through is OFF
unless event.through
# If self is event
if self != $game_player
# impassable
return false
end
# With self as the player and partner graphic as character
if event.character_name != ""
# impassable
return false
end
end
end
end
# If player coordinates are consistent with move destination
if self != $game_player and not self.is_a?(Game_Party_Actor)
$game_player.x >= new_x and
$game_player.x <= new_x and
$game_player.y >= new_y and
$game_player.y <= new_y and
# If through is OFF
unless $game_player.through
# If your own graphic is the character
if @character_name != ""
# impassable
return false
end
end
end
# passable
return true
end
#--------------------------------------------------------------------------
# * Move to Designated Position
# x : x-coordinate
# y : y-coordinate
#--------------------------------------------------------------------------
def moveto(x, y, px=false)
if not px
@x = x % $game_map.width * 16
@y = y % $game_map.height * 16
else
@x = x/2 % $game_map.width
@y = y/2 % $game_map.height
end
@real_x = @x * 8
@real_y = @y * 8
@prelock_direction = 0
end
end
#==============================================================================
# ** Game_Character (part 2)
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# â— alias
#--------------------------------------------------------------------------
alias chaosg1_pixel_movement_game_char_update update
alias chaosg1_pixel_movement_game_cha_move_type_custom move_type_custom
def update
if @x < 0
@x = 0
end
if @y < 0
@y = 0
end
chaosg1_pixel_movement_game_char_update
end
#--------------------------------------------------------------------------
# * Update frame (move)
#--------------------------------------------------------------------------
def update_move
# Convert map coordinates from map move speed into move distance
distance = 2 ** @move_speed
# If logical coordinates are further up than real coordinates
if @y * 8 < @real_y
# Move up
@real_y = [@real_y - distance, @y * 8].max
# If logical coordinates are further down than real coordinates
elsif @y * 8 > @real_y
# Move down
@real_y = [@real_y + distance, @y * 8].min
end
# If logical coordinates are more to the left than real coordinates
if @x * 8 < @real_x
# Move left
@real_x = [@real_x - distance, @x * 8].max
# If logical coordinates are more to the right than real coordinates
elsif @x * 8 > @real_x
# Move right
@real_x = [@real_x + distance, @x * 8].min
end
# If move animation is ON
if @walk_anime
# Increase animation count by 1.5
@anime_count += 1.5
# If move animation is OFF, and stop animation is ON
elsif @step_anime
# Increase animation count by 1
@anime_count += 1
end
end
#--------------------------------------------------------------------------
# * Move Type : Random
#--------------------------------------------------------------------------
def move_type_random
case rand(12)
when 0..7 # Random
(rand(8)+9).times do
move_random(2)
end
when 8..9 # 1 step forward
(rand(8)+9).times do
move_forward(2)
end
end
end
#--------------------------------------------------------------------------
# * Move Type : Approach
#--------------------------------------------------------------------------
def move_type_toward_player
# Get difference in player coordinates
sx = @x - $game_player.x
sy = @y - $game_player.y
# Get absolute value of difference
abs_sx = sx > 0 ? sx : -sx
abs_sy = sy > 0 ? sy : -sy
# If separated by 20 or more tiles matching up horizontally and vertically
# Branch by random numbers 0-5
if sx.abs + sy.abs >= 16*20
8.times do
move_random(4)
end
elsif sx.abs > 0 or sy.abs > 0
8.times do
move_toward_player(4)
end
end
end
#--------------------------------------------------------------------------
# * Move Type : Custom
#--------------------------------------------------------------------------
def move_type_custom
# Interrupt if not stopping
if jumping? or moving?
return
end
# Loop until finally arriving at move command list
while @move_route_index < @move_route.list.size
# Acquiring move command
command = @move_route.list[@move_route_index]
# If command code is 0 (last part of list)
if command.code == 0
# If [repeat action] option is ON
if @move_route.repeat
# First return to the move route index
@move_route_index = 0
end
# If [repeat action] option is OFF
unless @move_route.repeat
# If move route is forcing
if @move_route_forcing and not @move_route.repeat
# Release forced move route
@move_route_forcing = false
# Restore original move route
@move_route = @original_move_route
@move_route_index = @original_move_route_index
@original_move_route = nil
end
# Clear stop count
@stop_count = 0
end
return
end
# During move command (from move down to jump)
if command.code <= 14
# Branch by command code
case command.code
when 1 # Move down
16.times do
move_down(2,true,false)
end
when 2 # Move left
16.times do
move_left(2,true,false)
end
when 3 # Move right
16.times do
move_right(2,true,false)
end
when 4 # Move up
16.times do
move_up(2,true,false)
end
when 5 # Move lower left
16.times do
move_lower_left(2,true,false)
end
when 6 # Move lower right
16.times do
move_lower_right(2,true,false)
end
when 7 # Move upper left
16.times do
move_upper_left(2,true,false)
end
when 8 # Move upper right
16.times do
move_upper_right(2,true,false)
end
when 9 # Move at random
16.times do
move_random(2,true,false)
end
when 10 # Move toward player
16.times do
move_toward_player(2)
end
when 11 # Move away from player
16.times do
move_away_from_player(2)
end
when 12 # 1 step forward
16.times do
move_forward(2)
end
when 13 # 1 step backward
16.times do
move_backward(2)
end
when 14 # Jump
jump(command.parameters[0], command.parameters[1])
end
# If movement failure occurs when [Ignore if can't move] option is OFF
if not @move_route.skippable and not moving? and not jumping?
return
end
@move_route_index += 1
return
end
# If waiting
if command.code == 15
# Set wait count
@wait_count = command.parameters[0] * 2 - 1
@move_route_index += 1
return
end
chaosg1_pixel_movement_game_cha_move_type_custom
end
end
end
#Auszug aus: Caesar's Graphics Toolkit
class Bitmap
def fill_circle(cx, cy, radius, color)
x = 0
y = radius
d = radius-1
while y >= x
fill_rect(cx-x, cy-y, 2*x, 1, color)
fill_rect(cx-y, cy-x, 2*y, 1, color)
fill_rect(cx-x, cy+y, 2*x, 1, color)
fill_rect(cx-y, cy+x, 2*y, 1, color)
return if y == x
if d < 0
d += 2*x + 3
else
y -= 1
d += 2*x - 2*y + 5
end
x += 1
end
end
#--------------------------------------------------------------------------
# * Jump
# x_plus : x-coordinate plus value
# y_plus : y-coordinate plus value
#--------------------------------------------------------------------------
def jump(x_plus, y_plus, high=5)
x_plus*=16
y_plus*=16
# If plus value is not (0,0)
if x_plus != 0 or y_plus != 0
# If horizontal distnace is longer
if x_plus.abs > y_plus.abs
# Change direction to left or right
x_plus < 0 ? turn_left : turn_right
# If vertical distance is longer, or equal
else
# Change direction to up or down
y_plus < 0 ? turn_up : turn_down
end
end
# Calculate new coordinates
new_x = @x + x_plus
new_y = @y + y_plus
# If plus value is (0,0) or jump destination is passable
if (x_plus == 0 and y_plus == 0) or $game_map.passable?(new_x, new_y, @direction,self)
# Straighten position
straighten
# Update coordinates
@x = new_x
@y = new_y
# Calculate distance
high_2 = 40/high
distance = Math.sqrt(x_plus/high_2 * x_plus/high_2 + y_plus/high_2 * y_plus/high_2).round
# Set jump count
@jump_peak = 10 + distance - @move_speed
@jump_count = @jump_peak * 2
# Clear stop count
@stop_count = 0
end
end
end
#==============================================================================
# ** Game_Character (part 3)
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Move Down
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_down(steps = 32, turn_enabled = true, again=true)
if @no_slide != 2
@no_slide = 0
end
# Turn down
if turn_enabled
turn_down
end
# If passable
if passable?(@x, @y, 2, steps)
# Update coordinates
@y += steps/2
# Increase steps
increase_steps
# If impassable
else
if again and @no_slide != 2
if check_slide(2) == 4
move_left(steps,false,false)
elsif check_slide(2) == 6
move_right(steps,false,false)
else
move_lower_left(steps,false , false)
move_lower_right(steps,false , false)
end
end
end
end
#--------------------------------------------------------------------------
# * Move Left
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_left(steps=32, turn_enabled = true, again=true)
if @no_slide != 4
@no_slide = 0
end
# Turn left
if turn_enabled
turn_left
end
# If passable
if passable?(@x, @y, 4, steps)
# Update coordinates
@x -= steps/2
# Increase steps
increase_steps
# If impassable
else
if again and @no_slide != 4
if check_slide(4) == 8
move_up(steps,false,false)
elsif check_slide(4) == 2
move_down(steps,false,false)
else
move_upper_left(steps,false , false)
move_lower_left(steps,false, false)
end
end
end
end
#--------------------------------------------------------------------------
# * Move Right
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_right(steps=32, turn_enabled = true, again=true)
if @no_slide != 6
@no_slide = 0
end
# Turn right
if turn_enabled
turn_right
end
# If passable
if passable?(@x, @y, 6, steps)
# Update coordinates
@x += steps/2
# Increase steps
increase_steps
# If impassable
else
if again and @no_slide != 6
if check_slide(6) == 8
move_up(steps,false,false)
elsif check_slide(6) ==2
move_down(steps,false,false)
else
move_upper_right(steps,false , false)
move_lower_right(steps,false , false)
end
end
end
end
#--------------------------------------------------------------------------
# * Move up
# turn_enabled : a flag permits direction change on that spot
#--------------------------------------------------------------------------
def move_up(steps=32, turn_enabled = true, again=true)
if @no_slide != 8
@no_slide = 0
end
# Turn up
if turn_enabled
turn_up
end
# If passable
if passable?(@x, @y, 8, steps)
# Update coordinates
@y -= steps/2
# Increase steps
increase_steps
# If impassable
else
if again and @no_slide != 8
if check_slide(8) == 4
move_left(steps,false,false)
elsif check_slide(8) == 6
move_right(steps,false,false)
else
move_upper_left(steps,false , false)
move_upper_right(steps,false , false)
end
end
end
end
#--------------------------------------------------------------------------
# * Move Lower Left
#--------------------------------------------------------------------------
def move_lower_left (steps=32, turn_enabled = true, again=true)
if again
@no_slide = 0
end
# Turn lower_left
if turn_enabled
turn_lower_left
end
# When a down to left or a left to down course is passable
if passable?(@x, @y, 1, steps)
# Update coordinates
@x -= steps/2
@y += steps/2
# Increase steps
increase_steps
else
if again
move_down(steps,false,false)
move_left(steps,false,false)
end
end
end
#--------------------------------------------------------------------------
# * Move Lower Right
#--------------------------------------------------------------------------
def move_lower_right(steps=32, turn_enabled = true, again=true)
if again
@no_slide = 0
end
# Turn lower_right
if turn_enabled
turn_lower_right
end
# When a down to right or a right to down course is passable
if passable?(@x, @y, 3, steps)
# Update coordinates
@x += steps/2
@y += steps/2
# Increase steps
increase_steps
else
if again
move_down(steps,false,false)
move_right(steps,false,false)
end
end
end
#--------------------------------------------------------------------------
# * Move Upper Left
#--------------------------------------------------------------------------
def move_upper_left(steps=32, turn_enabled = true, again=true)
if again
@no_slide = 0
end
# Turn upper_left
if turn_enabled
turn_upper_left
end
# When an up to left or a left to up course is passable
if passable?(@x, @y, 7, steps)
# Update coordinates
@x -= steps/2
@y -= steps/2
# Increase steps
increase_steps
else
if again
move_up(steps,false,false)
move_left(steps,false,false)
end
end
end
#--------------------------------------------------------------------------
# * Move Upper Right
#--------------------------------------------------------------------------
def move_upper_right(steps=32, turn_enabled = true, again=true)
if again
@no_slide = 0
end
# Turn upper_right
if turn_enabled
turn_upper_right
end
# When an up to right or a right to up course is passable
if passable?(@x, @y, 9, steps)
# Update coordinates
@x += steps/2
@y -= steps/2
# Increase steps
increase_steps
else
if again
move_up(steps,false,false)
move_right(steps,false,false)
end
end
end
#--------------------------------------------------------------------------
# * Neue Turn-Befehle
#--------------------------------------------------------------------------
def turn_lower_left
unless @direction_fix
@direction = 1
@stop_count = 0
end
end
def turn_lower_right
unless @direction_fix
@direction = 3
@stop_count = 0
end
end
def turn_upper_left
unless @direction_fix
@direction = 7
@stop_count = 0
end
end
def turn_upper_right
unless @direction_fix
@direction = 9
@stop_count = 0
end
end
#--------------------------------------------------------------------------
# * Move at Random
#--------------------------------------------------------------------------
def move_random(steps=32, turn_enabled = true, again=true)
case rand(12)
when 0..1 # Move down
move_down(steps,turn_enabled,again)
when 2..3 # Move left
move_left(steps,turn_enabled,again)
when 4..5 # Move right
move_right(steps,turn_enabled,again)
when 6..7 # Move up
move_up(steps,turn_enabled,again)
when 8
move_lower_left(steps,turn_enabled,again)
when 9
move_lower_right(steps,turn_enabled,again)
when 10
move_upper_left(steps,turn_enabled,again)
when 11
move_upper_right(steps,turn_enabled,again)
end
end
#--------------------------------------------------------------------------
# * Move toward Player
#--------------------------------------------------------------------------
def move_toward_player(steps=32)
self.turn_toward_player
self.move_forward(steps)
end
#--------------------------------------------------------------------------
# * Move away from Player
#--------------------------------------------------------------------------
def move_away_from_player(steps=32)
self.turn_away_from_player
self.move_forward(steps)
end
#--------------------------------------------------------------------------
# * 1 Step Forward
#--------------------------------------------------------------------------
def move_forward(steps=32)
case @direction
when 1
move_lower_left(steps,false,false)
when 2
move_down(steps,false,false)
when 3
move_lower_right(steps,false,false)
when 4
move_left(steps,false,false)
when 6
move_right(steps,false,false)
when 7
move_upper_left(steps,false,false)
when 8
move_up(steps,false,false)
when 9
move_upper_right(steps,false,false)
end
end
#--------------------------------------------------------------------------
# * 1 Step Backward
#--------------------------------------------------------------------------
def move_backward(steps=32)
# Remember direction fix situation
last_direction_fix = @direction_fix
# Force directino fix
@direction_fix = true
# Branch by direction
case @direction
when 1
move_upper_right(steps,false,false)
when 2
move_up(steps,false,false)
when 3
move_upper_left(steps,false,false)
when 4
move_right(steps,false,false)
when 6
move_left(steps,false,false)
when 7
move_lower_right(steps,false,false)
when 8
move_down(steps,false,false)
when 9
move_lower_left(steps,false,false)
end
# Return direction fix situation back to normal
@direction_fix = last_direction_fix
end
def looks_at?(id)
sx = @x - $game_map.events[id].x
sy = @y - $game_map.events[id].y
# 座標ãŒç‰ã—ã„å ´åˆ
if sx == 0 and sy == 0
return true
end
# 横ã®è·é›¢ã®ã»ã†ãŒé•·ã„å ´åˆ
if sx.abs > sy.abs
# å·¦å³æ–¹å‘ã§ãƒ—レイヤーã®ã„ã‚‹ã»ã†ã‚’å‘ã
if sx > 0 and (@direction == 4 or @direction == 1 or @direction == 7)
return true
elsif sx < 0 and (@direction == 6 or @direction == 3 or @direction == 9)
return true
end
# 縦ã®è·é›¢ã®ã»ã†ãŒé•·ã„å ´åˆ
else
# 上下方å‘ã§ãƒ—レイヤーã®ã„ã‚‹ã»ã†ã‚’å‘ã
if sy > 0 and (@direction == 8 or @direction == 7 or @direction == 9)
return true
elsif sy < 0 and (@direction == 2 or @direction == 1 or @direction == 3)
return true
end
end
return false
end
#--------------------------------------------------------------------------
# * Jump
# x_plus : x-coordinate plus value
# y_plus : y-coordinate plus value
#--------------------------------------------------------------------------
def jump(x_plus, y_plus, high=5)
x_plus*=16
y_plus*=16
# If plus value is not (0,0)
if x_plus != 0 or y_plus != 0
# If horizontal distnace is longer
if x_plus.abs > y_plus.abs
# Change direction to left or right
x_plus < 0 ? turn_left : turn_right
# If vertical distance is longer, or equal
else
# Change direction to up or down
y_plus < 0 ? turn_up : turn_down
end
end
# Calculate new coordinates
new_x = @x + x_plus
new_y = @y + y_plus
# If plus value is (0,0) or jump destination is passable
if (x_plus == 0 and y_plus == 0) or $game_map.passable?(new_x, new_y, @direction,self)
# Straighten position
straighten
# Update coordinates
@x = new_x
@y = new_y
# Calculate distance
high_2 = 40/high
distance = Math.sqrt(x_plus/high_2 * x_plus/high_2 + y_plus/high_2 * y_plus/high_2).round
# Set jump count
@jump_peak = 10 + distance - @move_speed
@jump_count = @jump_peak * 2
# Clear stop count
@stop_count = 0
end
end
#checkt, ob geslided werden soll
def check_slide(dir)
# All event loops
for event in $game_map.events.values
# If event coordinates and triggers are consistent
if event.trigger == 0 and self.looks_at?(event.id)
@no_slide = dir
return
end
end
if dir == 2
l = 0
r = 0
c = (-2)
for i in c..0
if passable?(@x+i, @y, 2, 2)
l += 1
else
break
end
end
c = (2)
for i in 0..c
if passable?(@x+(c-i), @y, 2, 2)
r += 1
if r > l
break
end
else
break
end
end
if r > l and passable?(@x+2, @y, 2, 2)
return 6
elsif l > 0 and passable?(@x-2, @y, 2, 2)
return 4
else
@no_slide = dir
end
elsif dir == 4
u = 0
d = 0
c = (-2)
for i in c..0
if passable?(@x, @y+i, 4, 2)
u += 1
else
break
end
end
c = (2)
for i in 0..c
if passable?(@x, @y+(c-i), 4, 2)
d += 1
if d > u
break
end
else
break
end
end
if u > d and passable?(@x, @y-2, 4, 2)
return 8
elsif d > 0 and passable?(@x, @y+2, 4, 2)
return 2
else
@no_slide = dir
end
elsif dir == 6
u = 0
d = 0
c = (-2)
for i in c..0
if passable?(@x, @y+i, 6, 2)
u += 1
else
break
end
end
c = (+2)
for i in 0..c
if passable?(@x, @y+(c-i), 6, 2)
d += 1
if d > u
break
end
else
break
end
end
if u > d and passable?(@x, @y-2, 6, 2)
return 8
elsif d > 0 and passable?(@x, @y+2, 6, 2)
return 2
else
@no_slide = dir
end
elsif dir == 8
l = 0
r = 0
c = (-2)
for i in c..0
if passable?(@x+i, @y, 8, 2)
l += 1
else
break
end
end
c = (+2)
for i in 0..c
if passable?(@x+(c-i), @y, 8, 2)
r += 1
if r > l
break
end
else
break
end
end
if r > l and passable?(@x+2, @y, 8, 2)
return 6
elsif l > 0 and passable?(@x-2, @y, 8, 2)
return 4
else
@no_slide = dir
end
end
return
end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# This class handles the player. Its functions include event starting
# determinants and map scrolling. Refer to "$game_player" for the one
# instance of this class.
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# * Alias
#--------------------------------------------------------------------------
alias chaosg1_pixel_movement_game_player_passable passable?
alias chaosg1_pixel_movement_game_player_is increase_steps
alias chaosg1_pixel_movement_game_player_update update
#--------------------------------------------------------------------------
# * Passable Determinants
# x : x-coordinate
# y : y-coordinate
# d : direction (0,2,4,6,8)
# * 0 = Determines if all directions are impassable (for jumping)
#--------------------------------------------------------------------------
def passable?(x, y, d, steps=32)
# Get new coordinates
steps_x = steps/2
steps_y = steps/2
chaosg1_pixel_movement_game_player_passable(x, y, d)
end
#--------------------------------------------------------------------------
# * Move to
#--------------------------------------------------------------------------
def moveto(x, y, px=false)
super(x,y,px)
if $scene.is_a?(Scene_Map) and $scene.spriteset != nil and $scene.spriteset.game_party_actors != nil
$scene.spriteset.game_party_actors.each do |actor|
actor.moveto(x,y,px)
end
end
if px
center(x/2, y/2)
else
center(x*16, y*16)
end
make_encounter_count
end
#--------------------------------------------------------------------------
# * Increase Steps
#--------------------------------------------------------------------------
def increase_steps
if @schritte_zaehl >= 10
chaosg1_pixel_movement_game_player_is
@schritte_zaehl = 0
else
@schritte_zaehl +=1
end
end
def player_movement
if @schritte_gemacht >= 2 and @move_speed>=4
steps=2**(@move_speed-2)
else
steps=2
end
case Input.dir8
when 1
(steps/2).times do
move_lower_left(2)
end
when 2
(steps/2).times do
move_down(2)
end
when 3
(steps/2).times do
move_lower_right(2)
end
when 4
(steps/2).times do
move_left(2)
end
when 6
(steps/2).times do
move_right(2)
end
when 7
(steps/2).times do
move_upper_left(2)
end
when 8
(steps/2).times do
move_up(2)
end
when 9
(steps/2).times do
move_upper_right(2)
end
end
# Remember coordinates in local variables
last_real_x = @real_x
last_real_y = @real_y
if last_real_x != @real_x or last_real_y != @real_y
@schritte_gemacht+=1
if @encounter_count > 0
if @schritte_gemacht >= 2 and @move_speed>=4
@encounter_count -= (2**(@move_speed-2))/2
else
@encounter_count -= 1
end
end
else
@schritte_gemacht=0
end
end
end #class end
class Scene_Save
def write_data(file)
# Write each type of game object
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
$game_map.pass_pic = nil
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end
#==============================================================================
# ¦ Scene_Map
#------------------------------------------------------------------------------
# ?????????????????
#==============================================================================
class Scene_Map
def transfer_player
# ãƒ—ãƒ¬ã‚¤ãƒ¤ãƒ¼å ´æ‰€ç§»å‹•ãƒ•ãƒ©ã‚°ã‚’ã‚¯ãƒªã‚¢
$game_temp.player_transferring = false
# 移動先ãŒç¾åœ¨ã®ãƒžãƒƒãƒ—ã¨ç•°ãªã‚‹å ´åˆ
if $game_map.map_id != $game_temp.player_new_map_id
id = true
# æ–°ã—ã„マップをセットアップ
$game_map.setup($game_temp.player_new_map_id)
end
# プレイヤーã®ä½ç½®ã‚’è¨å®š
$game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
# プレイヤーã®å‘ãã‚’è¨å®š
case $game_temp.player_new_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
# プレイヤーã®å§¿å‹¢ã‚’矯æ£
$game_player.straighten
# マップを更新 (並列イベント実行)
$game_map.update
# スプライトセットをå†ä½œæˆ
if id
@spriteset.dispose
@spriteset = Spriteset_Map.new
else
@spriteset.dispose(false)
@spriteset = Spriteset_Map.new(@spriteset.minimap)
end
# トランジション処ç†ä¸ã®å ´åˆ
if $game_temp.transition_processing
# トランジション処ç†ä¸ãƒ•ãƒ©ã‚°ã‚’クリア
$game_temp.transition_processing = false
# トランジション実行
Graphics.transition(20)
end
# マップã«è¨å®šã•ã‚Œã¦ã„ã‚‹ BGM 㨠BGS ã®è‡ªå‹•åˆ‡ã‚Šæ›¿ãˆã‚’実行
$game_map.autoplay
# フレームリセット
Graphics.frame_reset
# å…¥åŠ›æƒ…å ±ã‚’æ›´æ–°
Input.update
end
end
#######################
class Interpreter
def command_122
# 値をåˆæœŸåŒ–
value = 0
# オペランドã§åˆ†å²
case @parameters[3]
when 0 # 定数
value = @parameters[4]
when 1 # 変数
value = $game_variables[@parameters[4]]
when 2 # 乱数
value = @parameters[4] + rand(@parameters[5] - @parameters[4] + 1)
when 3 # アイテãƒ
value = $game_party.item_number(@parameters[4])
when 4 # アクター
actor = $game_actors[@parameters[4]]
if actor != nil
case @parameters[5]
when 0 # レベル
value = actor.level
when 1 # EXP
value = actor.exp
when 2 # HP
value = actor.hp
when 3 # SP
value = actor.sp
when 4 # MaxHP
value = actor.maxhp
when 5 # MaxSP
value = actor.maxsp
when 6 # 腕力
value = actor.str
when 7 # 器用ã•
value = actor.dex
when 8 # ç´ æ—©ã•
value = actor.agi
when 9 # é”力
value = actor.int
when 10 # 攻撃力
value = actor.atk
when 11 # 物ç†é˜²å¾¡
value = actor.pdef
when 12 # é”法防御
value = actor.mdef
when 13 # 回é¿ä¿®æ£
value = actor.eva
end
end
when 5 # エãƒãƒŸãƒ¼
enemy = $game_troop.enemies[@parameters[4]]
if enemy != nil
case @parameters[5]
when 0 # HP
value = enemy.hp
when 1 # SP
value = enemy.sp
when 2 # MaxHP
value = enemy.maxhp
when 3 # MaxSP
value = enemy.maxsp
when 4 # 腕力
value = enemy.str
when 5 # 器用ã•
value = enemy.dex
when 6 # ç´ æ—©ã•
value = enemy.agi
when 7 # é”力
value = enemy.int
when 8 # 攻撃力
value = enemy.atk
when 9 # 物ç†é˜²å¾¡
value = enemy.pdef
when 10 # é”法防御
value = enemy.mdef
when 11 # 回é¿ä¿®æ£
value = enemy.eva
end
end
when 6 # ã‚ャラクター
character = get_character(@parameters[4])
if character != nil
case @parameters[5]
when 0 # X 座標
value = character.x/16
when 1 # Y 座標
value = character.y/16
when 2 # å‘ã
value = character.direction
when 3 # ç”»é¢ X 座標
value = character.screen_x
when 4 # ç”»é¢ Y 座標
value = character.screen_y
when 5 # 地形タグ
value = character.terrain_tag
end
end
when 7 # ãã®ä»–
case @parameters[4]
when 0 # マップ ID
value = $game_map.map_id
when 1 # パーティ人数
value = $game_party.actors.size
when 2 # ゴールド
value = $game_party.gold
when 3 # æ©æ•°
value = $game_party.steps
when 4 # プレイ時間
value = Graphics.frame_count / Graphics.frame_rate
when 5 # タイマー
value = $game_system.timer / Graphics.frame_rate
when 6 # セーブ回数
value = $game_system.save_count
end
end
# 一括æ“作ã®ãŸã‚ã«ãƒ«ãƒ¼ãƒ—
for i in @parameters[0] .. @parameters[1]
# æ“作ã§åˆ†å²
case @parameters[2]
when 0 # 代入
$game_variables[i] = value
when 1 # åŠ ç®—
$game_variables[i] += value
when 2 # 減算
$game_variables[i] -= value
when 3 # ä¹—ç®—
$game_variables[i] *= value
when 4 # 除算
if value != 0
$game_variables[i] /= value
end
when 5 # 剰余
if value != 0
$game_variables[i] %= value
end
end
# 上é™ãƒã‚§ãƒƒã‚¯
if $game_variables[i] > 99999999
$game_variables[i] = 99999999
end
# 下é™ãƒã‚§ãƒƒã‚¯
if $game_variables[i] < -99999999
$game_variables[i] = -99999999
end
end
# マップをリフレッシュ
$game_map.need_refresh = true
# 継続
return true
end
def command_202
#
if $game_temp.in_battle
#
return true
end
#
character = get_character(@parameters[0])
#
if character == nil
#
return true
end
#
if @parameters[1] == 0
# character.moveto(@parameters[2], @parameters[3])
#
elsif @parameters[1] == 1
#
character.moveto($game_variables[@parameters[2]],
$game_variables[@parameters[3]])
#
else
old_x = character.x/16
old_y = character.y/16
character2 = get_character(@parameters[2])
if character2 != nil
character.moveto(character2.x/16, character2.y/16)
character2.moveto(old_x, old_y)
end
end
#
case @parameters[4]
when 8 #
character.turn_up
when 6 #
character.turn_right
when 2 #
character.turn_down
when 4 #
character.turn_left
end
#
return true
end
end
end