Project1
标题:
八方像素横向行走(类似地下城)
[打印本页]
作者:
咚小黑
时间:
2011-11-20 19:07
标题:
八方像素横向行走(类似地下城)
至于出处,我不知道在哪了,以前海外看到的。
按照提示修改了一下,回了这个脚本给大家。(我很喜欢这种行走)
注意:NPC的随机移动是跟主角一样的。
=begin
================================================================================
Amethyst Custom Movement - v1.2 RMVX - 25/03/2010
================================================================================
--------------------------------------------------------------------------------
Credits\Terms of Use
--------------------------------------------------------------------------------
Created by Khas (
[email protected]
)
All Amethyst Scripts are licensed under a Creative Commons license
All Amethyst Scripts are for non-commercial projects, if you need
them for a commercial game, please send a email to
[email protected]
--------------------------------------------------------------------------------
Features
--------------------------------------------------------------------------------
This script creates an advanced movement, including "half-tile" step,
diagonal movement and an advanced touch trigger feature.
ACM is also compatible with RMVX vehicles
--------------------------------------------------------------------------------
Configuration
--------------------------------------------------------------------------------
=end
module Amcm_Config
# Enable Diagonal movement for Player?
Enable_Player_Diagonal = true
# Enable Diagonal movement for events?
Enable_Event_Diagonal = true
# Enable "half-tile" step for events?
Enable_Event_Movement = true
# Enable Advanced Trigger Touch feature?
Enable_Advanced_Touch = true
end
#-------------------------------------------------------------------------------
$Amethyst_Scripts = {} if $Amethyst_Scripts.nil?
$Amethyst_Scripts["Am Custom Movement"] = ["1.2","25/03/2010"]
class Game_Character
def amcm_integer?(value)
i = value.to_i; return value == i
end
def pos?(x, y)
if amcm_integer?(@x)
if amcm_integer?(@y)
return (@x == x and @y == y)
else
return (@x == x and (@y.to_i == y or @y.to_i+1 == y))
end
elsif amcm_integer?(@y)
return ((@x.to_i == x or @x.to_i+1 == x) and @y == y)
else
return ((@x.to_i == x or @x.to_i+1 == x)and(@y.to_i == y or @y.to_i+1 == y))
end
end
if Amcm_Config::Enable_Event_Diagonal
def move_random
case rand(8)
when 0; move_down(false)
when 1; move_left(false)
when 2; move_right(false)
when 3; move_up(false)
when 4; move_lower_left
when 5; move_lower_right
when 6; move_upper_left
when 7; move_upper_right
end
end
end
if Amcm_Config::Enable_Event_Movement
def move_down(turn_ok = true)
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x, @y+1)
@y = $game_map.round_y(@y+0.5)
@real_y = (@y-0.5)*256
increase_steps
@move_failed = false
else
check_event_trigger_touch(@x, @y+1)
@move_failed = true
end
else
@y = $game_map.round_y(@y+0.5)
@real_y = (@y-0.5)*256
increase_steps
@move_failed = false
end
elsif amcm_integer?(@y)
if passable?(@x.to_i, @y+1) and passable?(@x.to_i+1, @y+1)
@y = $game_map.round_y(@y+0.5)
@real_y = (@y-0.5)*256
increase_steps
@move_failed = false
else
check_event_trigger_touch(@x.to_i+1, @y+1)
check_event_trigger_touch(@x.to_i, @y+1)
@move_failed = true
end
else
@y = $game_map.round_y(@y+0.5)
@real_y = (@y-0.5)*256
increase_steps
@move_failed = false
end
end
def move_up(turn_ok = true)
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x, @y-1)
@y = $game_map.round_y(@y-0.5)
@real_y = (@y+0.5)*256
increase_steps
@move_failed = false
else
check_event_trigger_touch(@x, @y-1)
@move_failed = true
end
else
@y = $game_map.round_y(@y-0.5)
@real_y = (@y+0.5)*256
increase_steps
@move_failed = false
end
elsif amcm_integer?(@y)
if passable?(@x.to_i, @y-1) and passable?(@x.to_i+1, @y-1)
@y = $game_map.round_y(@y-0.5)
@real_y = (@y+0.5)*256
increase_steps
@move_failed = false
else
check_event_trigger_touch(@x.to_i, @y-1)
check_event_trigger_touch(@x.to_i+1, @y-1)
@move_failed = true
end
else
@y = $game_map.round_y(@y-0.5)
@real_y = (@y+0.5)*256
increase_steps
@move_failed = false
end
end
def move_left(turn_ok = true)
if amcm_integer?(@y)
if amcm_integer?(@x)
if passable?(@x-1, @y)
turn_left
@x = $game_map.round_x(@x-0.5)
@real_x = (@x+0.5)*256
increase_steps
@move_failed = false
else
turn_left if turn_ok
check_event_trigger_touch(@x-1, @y)
@move_failed = true
end
else
turn_left
@x = $game_map.round_x(@x-0.5)
@real_x = (@x+0.5)*256
increase_steps
@move_failed = false
end
elsif amcm_integer?(@x)
if passable?(@x-1,@y.to_i) and passable?(@x-1,@y.to_i+1)
turn_left
@x = $game_map.round_x(@x-0.5)
@real_x = (@x+0.5)*256
increase_steps
@move_failed = false
else
turn_left if turn_ok
check_event_trigger_touch(@x-1, @y.to_i)
check_event_trigger_touch(@x-1, @y.to_i+1)
@move_failed = true
end
else
turn_left
@x = $game_map.round_x(@x-0.5)
@real_x = (@x+0.5)*256
increase_steps
@move_failed = false
end
end
def move_right(turn_ok = true)
if amcm_integer?(@y)
if amcm_integer?(@x)
if passable?(@x+1, @y)
turn_right
@x = $game_map.round_x(@x+0.5)
@real_x = (@x-0.5)*256
increase_steps
@move_failed = false
else
turn_right if turn_ok
check_event_trigger_touch(@x+1, @y)
@move_failed = true
end
else
turn_right
@x = $game_map.round_x(@x+0.5)
@real_x = (@x-0.5)*256
increase_steps
@move_failed = false
end
elsif amcm_integer?(@x)
if passable?(@x+1,@y.to_i) and passable?(@x+1,@y.to_i+1)
turn_right
@x = $game_map.round_x(@x+0.5)
@real_x = (@x-0.5)*256
increase_steps
@move_failed = false
else
turn_right if turn_ok
check_event_trigger_touch(@x+1, @y.to_i)
check_event_trigger_touch(@x+1, @y.to_i+1)
@move_failed = true
end
else
turn_right
@x = $game_map.round_x(@x+0.5)
@real_x = (@x-0.5)*256
increase_steps
@move_failed = false
end
end
def move_lower_left
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x-1,@y) and passable?(@x-1,@y+1) and passable?(@x,@y+1)
@x -= 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
if passable?(@x-1,@y.to_i+1)
@x -= 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
end
elsif amcm_integer?(@y)
if passable?(@x.to_i,@y+1)
@x -= 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
@x -= 0.5
@y += 0.5
increase_steps
@move_failed = false
end
end
def move_lower_right
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x+1,@y) and passable?(@x+1,@y+1) and passable?(@x,@y+1)
@x += 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
if passable?(@x+1,@y.to_i+1)
@x += 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
end
elsif amcm_integer?(@y)
if passable?(@x.to_i+1,@y+1)
@x += 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
@x += 0.5
@y += 0.5
increase_steps
@move_failed = false
end
end
def move_upper_left
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x-1,@y) and passable?(@x-1,@y-1) and passable?(@x,@y-1)
@x -= 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
if passable?(@x-1,@y.to_i)
@x -= 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
end
elsif amcm_integer?(@y)
if passable?(@x.to_i,@y-1)
@x -= 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
@x -= 0.5
@y -= 0.5
increase_steps
@move_failed = false
end
end
def move_upper_right
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x+1,@y) and passable?(@x+1,@y-1) and passable?(@x,@y-1)
@x += 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
if passable?(@x+1,@y.to_i)
@x += 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
end
elsif amcm_integer?(@y)
if passable?(@x.to_i+1,@y-1)
@x += 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
@x += 0.5
@y -= 0.5
increase_steps
@move_failed = false
end
end
end
end
class Game_Player < Game_Character
if Amcm_Config::Enable_Player_Diagonal
def move_by_input
@run_event = false
return unless movable?
return if $game_map.interpreter.running?
case Input.dir8
when 1; move_lower_left
when 2; move_down
when 3; move_lower_right
when 4; move_left
when 6; move_right
when 7; move_upper_left
when 8; move_up
when 9; move_upper_right
end
end
end
def get_amx(plus=false)
if plus
case @direction
when 2; amcm_integer?(@x) ? i = @x : i = false
when 4; amcm_integer?(@x) ? i = @x-1 : i = false
when 6; amcm_integer?(@x) ? i = @x+1 : i = false
when 8; amcm_integer?(@x) ? i = @x : i = false
end
return i
else
amcm_integer?(@x) ? i = @x : i = [@x.to_i,@x.to_i+1]; return i
end
end
def get_amy(plus=false)
if plus
case @direction
when 2; amcm_integer?(@y) ? i = @y+1 : i = false
when 4; amcm_integer?(@y) ? i = @y : i = false
when 6; amcm_integer?(@y) ? i = @y : i = false
when 8; amcm_integer?(@y) ? i = @y-1 : i = false
end
return i
else
amcm_integer?(@y) ? i = @y : i = [@y.to_i,@y.to_i+1]; return i
end
end
if Amcm_Config::Enable_Advanced_Touch
def check_event_trigger_here(triggers)
return false if $game_map.interpreter.running?
result = false
ax = get_amx
ay = get_amy
if ax.is_a?(Array)
if ay.is_a?(Array)
for event in $game_map.events_xy(ax[0],ay[0])
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
return true if event.starting
end
end
for event in $game_map.events_xy(ax[0],ay[1])
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
return true if event.starting
end
end
for event in $game_map.events_xy(ax[1],ay[0])
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
return true if event.starting
end
end
for event in $game_map.events_xy(ax[1],ay[1])
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
return true if event.starting
end
end
else
for event in $game_map.events_xy(ax[0],ay)
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
return true if event.starting
end
end
for event in $game_map.events_xy(ax[1],ay)
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
return true if event.starting
end
end
end
elsif ay.is_a?(Array)
for event in $game_map.events_xy(ax,ay[0])
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
return true if event.starting
end
end
for event in $game_map.events_xy(ax,ay[1])
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
return true if event.starting
end
end
else
for event in $game_map.events_xy(ax,ay)
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
return true if event.starting
end
end
end
return result
end
else
def check_event_trigger_here(triggers)
return false if $game_map.interpreter.running?
result = false
for event in $game_map.events_xy(@x, @y)
if triggers.include?(event.trigger) and event.priority_type != 1
event.start
result = true if event.starting
end
end
return result
end
end
def check_event_trigger_there(triggers)
return false if $game_map.interpreter.running?
result = false
front_x = get_amx(true)
front_y = get_amy(true)
return if !front_x or !front_y
for event in $game_map.events_xy(front_x, front_y)
if triggers.include?(event.trigger) and event.priority_type == 1
event.start
result = true
end
end
if result == false and $game_map.counter?(front_x, front_y)
front_x = $game_map.x_with_direction(front_x, @direction)
front_y = $game_map.y_with_direction(front_y, @direction)
for event in $game_map.events_xy(front_x, front_y)
if triggers.include?(event.trigger) and event.priority_type == 1
event.start
result = true
end
end
end
return result
end
def get_on_vehicle
front_x = get_amx(true)
front_y = get_amy(true)
if $game_map.airship.pos?(@x, @y)
get_on_airship
return true
elsif $game_map.ship.pos?(front_x, front_y)
get_on_ship
return true
elsif $game_map.boat.pos?(front_x, front_y)
get_on_boat
return true
end
return false
end
def force_vland
if amcm_integer?(@x)
if amcm_integer?(@y)
return
else
case @direction
when 2; move_forward
when 8; move_forward
else
case rand(2)
when 0; move_up
when 1; move_down
end
end
end
elsif amcm_integer?(@y)
case @direction
when 4; move_forward
when 6; move_forward
else
case rand(2)
when 0; move_left
when 1; move_right
end
end
else
case @direction
when 2;
case rand(2)
when 0; move_lower_right
when 1; move_lower_left
end
when 4;
case rand(2)
when 0; move_lower_left
when 1; move_upper_left
end
when 6;
case rand(2)
when 0; move_lower_right
when 1; move_upper_right
end
when 8;
case rand(2)
when 0; move_upper_right
when 1; move_upper_left
end
end
end
return (amcm_integer?(@x) and amcm_integer?(@y))
end
def force_move_forward
@through = true
move_forward
move_forward if in_vehicle?
@through = false
end
def get_off_vehicle
if in_airship?
return if force_vland
return unless airship_land_ok?(@x, @y)
else
return if force_vland
front_x = get_amx(true)
front_y = get_amy(true)
return unless can_walk?(front_x, front_y)
end
$game_map.vehicles[@vehicle_type].get_off
if in_airship?
@direction = 2
else
force_move_forward
@transparent = false
end
@vehicle_getting_off = true
@move_speed = 4
@through = false
@walking_bgm.play
make_encounter_count
end
if not Amcm_Config::Enable_Event_Movement
def move_down(turn_ok = true)
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x, @y+1)
@y = $game_map.round_y(@y+0.5)
@real_y = (@y-0.5)*256
increase_steps
@move_failed = false
else
check_event_trigger_touch(@x, @y+1)
@move_failed = true
end
else
turn_down
@y = $game_map.round_y(@y+0.5)
@real_y = (@y-0.5)*256
increase_steps
@move_failed = false
end
elsif amcm_integer?(@y)
if passable?(@x.to_i, @y+1) and passable?(@x.to_i+1, @y+1)
@y = $game_map.round_y(@y+0.5)
@real_y = (@y-0.5)*256
increase_steps
@move_failed = false
else
check_event_trigger_touch(@x.to_i+1, @y+1)
check_event_trigger_touch(@x.to_i, @y+1)
@move_failed = true
end
else
turn_down
@y = $game_map.round_y(@y+0.5)
@real_y = (@y-0.5)*256
increase_steps
@move_failed = false
end
end
def move_up(turn_ok = true)
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x, @y-1)
@y = $game_map.round_y(@y-0.5)
@real_y = (@y+0.5)*256
increase_steps
@move_failed = false
else
check_event_trigger_touch(@x, @y-1)
@move_failed = true
end
else
turn_up
@y = $game_map.round_y(@y-0.5)
@real_y = (@y+0.5)*256
increase_steps
@move_failed = false
end
elsif amcm_integer?(@y)
if passable?(@x.to_i, @y-1) and passable?(@x.to_i+1, @y-1)
@y = $game_map.round_y(@y-0.5)
@real_y = (@y+0.5)*256
increase_steps
@move_failed = false
else
check_event_trigger_touch(@x.to_i, @y-1)
check_event_trigger_touch(@x.to_i+1, @y-1)
@move_failed = true
end
else
turn_up
@y = $game_map.round_y(@y-0.5)
@real_y = (@y+0.5)*256
increase_steps
@move_failed = false
end
end
def move_left(turn_ok = true)
if amcm_integer?(@y)
if amcm_integer?(@x)
if passable?(@x-1, @y)
turn_left
@x = $game_map.round_x(@x-0.5)
@real_x = (@x+0.5)*256
increase_steps
@move_failed = false
else
turn_left if turn_ok
check_event_trigger_touch(@x-1, @y)
@move_failed = true
end
else
turn_left
@x = $game_map.round_x(@x-0.5)
@real_x = (@x+0.5)*256
increase_steps
@move_failed = false
end
elsif amcm_integer?(@x)
if passable?(@x-1,@y.to_i) and passable?(@x-1,@y.to_i+1)
turn_left
@x = $game_map.round_x(@x-0.5)
@real_x = (@x+0.5)*256
increase_steps
@move_failed = false
else
turn_left if turn_ok
check_event_trigger_touch(@x-1, @y.to_i)
check_event_trigger_touch(@x-1, @y.to_i+1)
@move_failed = true
end
else
turn_left
@x = $game_map.round_x(@x-0.5)
@real_x = (@x+0.5)*256
increase_steps
@move_failed = false
end
end
def move_right(turn_ok = true)
if amcm_integer?(@y)
if amcm_integer?(@x)
if passable?(@x+1, @y)
turn_right
@x = $game_map.round_x(@x+0.5)
@real_x = (@x-0.5)*256
increase_steps
@move_failed = false
else
turn_right if turn_ok
check_event_trigger_touch(@x+1, @y)
@move_failed = true
end
else
turn_right
@x = $game_map.round_x(@x+0.5)
@real_x = (@x-0.5)*256
increase_steps
@move_failed = false
end
elsif amcm_integer?(@x)
if passable?(@x+1,@y.to_i) and passable?(@x+1,@y.to_i+1)
turn_right
@x = $game_map.round_x(@x+0.5)
@real_x = (@x-0.5)*256
increase_steps
@move_failed = false
else
turn_right if turn_ok
check_event_trigger_touch(@x+1, @y.to_i)
check_event_trigger_touch(@x+1, @y.to_i+1)
@move_failed = true
end
else
turn_right
@x = $game_map.round_x(@x+0.5)
@real_x = (@x-0.5)*256
increase_steps
@move_failed = false
end
end
def move_lower_left
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x-1,@y) and passable?(@x-1,@y+1) and passable?(@x,@y+1)
@x -= 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
if passable?(@x-1,@y.to_i+1)
@x -= 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
end
elsif amcm_integer?(@y)
if passable?(@x.to_i,@y+1)
@x -= 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
@x -= 0.5
@y += 0.5
increase_steps
@move_failed = false
end
end
def move_lower_right
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x+1,@y) and passable?(@x+1,@y+1) and passable?(@x,@y+1)
@x += 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
if passable?(@x+1,@y.to_i+1)
@x += 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
end
elsif amcm_integer?(@y)
if passable?(@x.to_i+1,@y+1)
@x += 0.5
@y += 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
@x += 0.5
@y += 0.5
increase_steps
@move_failed = false
end
end
def move_upper_left
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x-1,@y) and passable?(@x-1,@y-1) and passable?(@x,@y-1)
@x -= 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
if passable?(@x-1,@y.to_i)
@x -= 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
end
elsif amcm_integer?(@y)
if passable?(@x.to_i,@y-1)
@x -= 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
@x -= 0.5
@y -= 0.5
increase_steps
@move_failed = false
end
end
def move_upper_right
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
if amcm_integer?(@x)
if amcm_integer?(@y)
if passable?(@x+1,@y) and passable?(@x+1,@y-1) and passable?(@x,@y-1)
@x += 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
if passable?(@x+1,@y.to_i)
@x += 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
end
elsif amcm_integer?(@y)
if passable?(@x.to_i+1,@y-1)
@x += 0.5
@y -= 0.5
increase_steps
@move_failed = false
else
@move_failed = true
end
else
@x += 0.5
@y -= 0.5
increase_steps
@move_failed = false
end
end
end
end
复制代码
作者:
梦回碧落
时间:
2011-11-20 19:18
不兼容人物跟随……废了
作者:
皮卡星
时间:
2011-11-20 19:36
麻烦发到地球村
谢谢
作者:
各种压力的猫君
时间:
2011-11-20 23:02
2)本版所有发表的作品默认为发帖者在该作品内具体实质性的原创成分,转载、汉化请到地球村;
纯引版规
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1