I have some problems with a amended script.
*Red line : Isometric move.
*Green line : Diagonal move.
As you can see, the script handles very well in isometric.
But now, diagonal move is sacrificed for iso movements.
I wan't to know if someone can help me with this.
Exemple... if switch [0001] is on, diagonal movements is enable. (Green line)
If switch [0001] if off, we let isometric movements. (Red line)
#---------------------------------------------------------------------------------
# SUPER WALK 1.2b + Déplacements isométriques
#---------------------------------------------------------------------------------
# Script créé par Zeus81
# Modifiée par Kreiss
#---------------------------------------------------------------------------------
class Game_Player
SUPER_WALK_SWITCH = 130 # id de l'interrupteur pour activer/désactiver le script
end
class Game_Character
alias super_walk_game_character_initialize initialize
def initialize
@x2 = @y2 = 0
super_walk_game_character_initialize
end
def super_walk_distance
@move_speed > 4 ? @move_speed > 5 ? 0.5 : 0.25 : 0.125
end
def moving?
@real_x != @x2*128 or @real_y != @y2*128
end
def passable?(x, y, d)
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
return false unless $game_map.valid?(new_x, new_y)
return true if @through
return false unless $game_map.passable?(x, y, d, self)
return false unless $game_map.passable?(new_x, new_y, 10-d)
$game_map.events.each_value do |event|
return false if event.x == new_x and event.y == new_y and !event.through and
(self != $game_player or !event.character_name.empty?)
end
return false if $game_player.x == new_x and $game_player.y == new_y and
!$game_player.through and !@character_name.empty?
return true
end
def moveto(x, y)
@x = @x2 = x % $game_map.width
@y = @y2 = y % $game_map.height
@real_x = @x * 128
@real_y = @y * 128
@prelock_direction = 0
end
def update_jump
@jump_count -= 1
@real_x = (@real_x * @jump_count + @x2 * 128) / (@jump_count + 1)
@real_y = (@real_y * @jump_count + @y2 * 128) / (@jump_count + 1)
end
def update_move
x128, y128, distance = @x2*128, @y2*128, 2**@move_speed
if x128 < @real_x; @real_x = [@real_x-distance*2, x128].max
elsif x128 > @real_x; @real_x = [@real_x+distance*2, x128].min
end
if y128 < @real_y; @real_y = [@real_y-distance, y128].max
elsif y128 > @real_y; @real_y = [@real_y+distance, y128].min
end
if @walk_anime; @anime_count += 1.5
elsif @step_anime; @anime_count += 1
end
end
def move_down(turn_enabled=true, super_walk=false)
turn_down if turn_enabled
if passable?(@x, @y, 2)
turn_down
if super_walk
@x2 -= 0.125 if @x2 > @x and !passable?(@x+1, @y, 2)
@x2 += 0.125 if @x2 < @x and !passable?(@x-1, @y, 2)
@y2 += super_walk_distance
@y = @y2.round
else @y2 = @y += 1
end
increase_steps
elsif @y2 < @y
@y2 += 0.125
else
check_event_trigger_touch(@x, @y+1)
return false
end
return true
end
def move_left(turn_enabled=true, super_walk=false)
turn_left if turn_enabled
if passable?(@x, @y, 4)
turn_left
if super_walk
@y2 -= 0.125 if @y2 > @y and !passable?(@x, @y+1, 4)
@y2 += 0.125 if @y2 < @y and !passable?(@x, @y-1, 4)
@x2 -= super_walk_distance
@x = @x2.round
else @x2 = @x -= 1
end
increase_steps
elsif @x2 > @x
@x2 -= 0.125
else
check_event_trigger_touch(@x-1, @y)
return false
end
return true
end
def move_right(turn_enabled=true, super_walk=false)
turn_right if turn_enabled
if passable?(@x, @y, 6)
turn_right
if super_walk
@y2 -= 0.125 if @y2 > @y and !passable?(@x, @y+1, 6)
@y2 += 0.125 if @y2 < @y and !passable?(@x, @y-1, 6)
@x2 += super_walk_distance
@x = @x2.round
else @x2 = @x += 1
end
increase_steps
elsif @x2 < @x
@x2 += 0.125
else
check_event_trigger_touch(@x+1, @y)
return false
end
return true
end
def move_up(turn_enabled=true, super_walk=false)
turn_up if turn_enabled
if passable?(@x, @y,
turn_up
if super_walk
@x2 -= 0.125 if @x2 > @x and !passable?(@x+1, @y,
@x2 += 0.125 if @x2 < @x and !passable?(@x-1, @y,
@y2 -= super_walk_distance
@y = @y2.round
else @y2 = @y -= 1
end
increase_steps
elsif @y2 > @y
@y2 -= 0.125
else
check_event_trigger_touch(@x, @y-1)
return false
end
return true
end
#--------------------------------------------------------------------------
# Move Lower Left
#--------------------------------------------------------------------------
def move_lower_left(turn_enabled=true, super_walk=false)
last_dir = @direction
move1 = move_down(false, super_walk)
move2 = move_left(false, super_walk)
move_left(false, super_walk)
if !@direction_fix and turn_enabled ? move1 == move2 : move1 && move2
@direction = last_dir == 6 ? 4 : last_dir == 8 ? 2 : last_dir
@stop_count = 0
end
return move1 || move2
end
#--------------------------------------------------------------------------
# Move Lower Right
#--------------------------------------------------------------------------
def move_lower_right(turn_enabled=true, super_walk=false)
last_dir = @direction
move1 = move_down( false, super_walk)
move2 = move_right(false, super_walk)
move_right(false, super_walk)
if !@direction_fix and turn_enabled ? move1 == move2 : move1 && move2
@direction = last_dir == 4 ? 6 : last_dir == 8 ? 2 : last_dir
@stop_count = 0
end
return move1 || move2
end
#--------------------------------------------------------------------------
# Move Upper Left
#--------------------------------------------------------------------------
def move_upper_left(turn_enabled=true, super_walk=false)
last_dir = @direction
move1 = move_up( false, super_walk)
move2 = move_left(false, super_walk)
move_left(false, super_walk)
if !@direction_fix and turn_enabled ? move1 == move2 : move1 && move2
@direction = last_dir == 6 ? 4 : last_dir == 2 ? 8 : last_dir
@stop_count = 0
end
return move1 || move2
end
#--------------------------------------------------------------------------
# Move Upper Right
#--------------------------------------------------------------------------
def move_upper_right(turn_enabled=true, super_walk=false)
last_dir = @direction
move1 = move_up( false, super_walk)
move2 = move_right(false, super_walk)
move_right(false, super_walk)
if !@direction_fix and turn_enabled ? move1 == move2 : move1 && move2
@direction = last_dir == 4 ? 6 : last_dir == 2 ? 8 : last_dir
@stop_count = 0
end
return move1 || move2
end
#--------------------------------------------------------------------------
def move_random
case rand(8)
when 0; move_lower_left
when 1; move_down
when 2; move_lower_right
when 3; move_left
when 4; move_upper_left
when 5; move_right
when 6; move_upper_right
when 7; move_up
end
end
def jump(x_plus, y_plus)
loop do
if (x_plus == 0 and y_plus == 0) or passable?(@x+x_plus, @y+y_plus, 0)
if x_plus.abs > y_plus.abs
x_plus < 0 ? turn_left : turn_right
else y_plus < 0 ? turn_up : turn_down
end unless x_plus == 0 and y_plus == 0
straighten
@x += x_plus
@x2 += x_plus
@y += y_plus
@y2 += y_plus
@jump_peak = 10 - @move_speed + Math.hypot(x_plus, y_plus).round
@jump_count = @jump_peak * 2
@stop_count = 0
return
end
x_plus -= 1 if x_plus > 0
x_plus += 1 if x_plus < 0
y_plus -= 1 if y_plus > 0
y_plus += 1 if y_plus < 0
end
end
end
class Game_Player
def update
last_x, last_y, last_rx, last_ry = @x, @y, @real_x, @real_y
super_walk = $game_switches[SUPER_WALK_SWITCH]
unless last_moving = moving? or @move_route_forcing or
$game_temp.message_window_showing or
$game_system.map_interpreter.running?
case Input.dir8
when 1; move_lower_left( true, super_walk)
when 2; move_down( true, super_walk)
when 3; move_lower_right(true, super_walk)
when 4; move_left( true, super_walk)
when 6; move_right( true, super_walk)
when 7; move_upper_left( true, super_walk)
when 8; move_up( true, super_walk)
when 9; move_upper_right(true, super_walk)
end
end
last_moving = last_x != @x || last_y != @y if super_walk
super
$game_map.scroll_left(last_rx-@real_x) if @real_x < last_rx and @real_x-$game_map.display_x < CENTER_X
$game_map.scroll_right(@real_x-last_rx) if @real_x > last_rx and @real_x-$game_map.display_x > CENTER_X
$game_map.scroll_up(last_ry-@real_y) if @real_y < last_ry and @real_y-$game_map.display_y < CENTER_Y
$game_map.scroll_down(@real_y-last_ry) if @real_y > last_ry and @real_y-$game_map.display_y > CENTER_Y
unless moving?
if last_moving and !check_event_trigger_here([1,2])
if @encounter_count > 0 and !($DEBUG and Input.press?(Input::CTRL))
@encounter_count -= 1
end
end
if Input.trigger?(Input::C)
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end
It would help the project to have more fluid movements.