#=============================================================================
#★RMVX重力系统★
#-----------------------------------------------------------------------------
#★作者: Zhong_zw
#★游戏中引用本脚本,请保留以上信息,并作相关说明.
#☆如若转载本脚本请联系本人☆
#==============================================================================
#==============================================================================
# ★ Game_Character
#------------------------------------------------------------------------------
# 涉及角色的类。本类作为 Game_Player 类与 Game_Event 的超级类
# 使用。
#==============================================================================
#==============================================================================
#★参数设置
#==============================================================================
#跳跃初速度
JUMP_SPEED = 150
#重力加速度
GRAVITATIONAL = 9
#连跳次数
JUME_SERIES = 2
#连跳速度衰减
JUMP_SERIES_WEAKEN = 30
#跳跃键
JUMP_KEY = Input::C #默认为键盘A键
#弹跳时的行走图 (格式为:[名称,index])
JUMP_CHARACTER = nil
#弹跳时的声音 (注:声音文件放在SE文件夹下)
JUMP_SE = "Jump1.ogg"
#掉出屏幕时打开的开关(用于调用相关公共事件)
DEAD_SWITCHES_ID = 50
#各地图交通工具的摆放位置
MAP_VEHICLE = {1=>[[2,1],[3,1],[4,1],[5,1],[8,2],[6,2],[7,2,1]]}
#各地图可以飞的事件
MAP_FLY_EVENT = {1=>[10]}
#默认地图模式 0为正常模式 1为重力模式
DEFAULT_MAP_MODE = 0
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :id # ID
#===============================================================
attr_accessor :x # 地图 X 坐标 (理论坐标)
attr_accessor :y # 地图 Y 坐标 (理论坐标)
attr_accessor :real_x # 地图 X 坐标 (实际坐标 * 256)
attr_accessor :real_y # 地图 Y 坐标 (实际坐标 * 256)
attr_accessor :move_speed #角色移动速度
attr_accessor :jump_series #连跳次数
attr_accessor :gravitational #重力加速度
attr_accessor :vertical_speed #垂直速度
attr_accessor :can_fly #飞行开关
attr_accessor :jump_speed #跳跃初速度
attr_accessor :on_ladder #是否在梯子上
attr_accessor :map_vehicle #地图交通工具 0 无 1 为梯子 2 为踏板
attr_accessor :pedal_type #踏板类型
attr_accessor :on_pedal #是否在踏板
attr_accessor :jump_character #弹跳时的行走图
#=====================================================
#==========================================================================
# ★ 初始化对象
#==========================================================================
def initialize
@id = 0
@x = 0
@y = 0
@real_x = 0
@real_y = 0
@tile_id = 0
@character_name = ""
@character_index = 0
@opacity = 255
@blend_type = 0
@direction = 2
@pattern = 1
@move_route_forcing = false
@priority_type = 1
@through = false
@bush_depth = 0
@animation_id = 0
@balloon_id = 0
@transparent = false
@original_direction = 2 # 原朝向
@original_pattern = 1 # 原图案
@move_type = 0 # 移动类型
@move_speed = 4 # 移动速度
@move_frequency = 6 # 移动频度
@move_route = nil # 移动路径
@move_route_index = 0 # 移动路径执行位置
@original_move_route = nil # 原移动路径
@original_move_route_index = 0 # 原移动路径执行位置
@walk_anime = true # 步行动画
@step_anime = false # 踏步动画
@direction_fix = false # 朝向固定
@anime_count = 0 # 动画计数
@stop_count = 0 # 停止计数
@jump_count = 0 # 跳跃计数
@jump_peak = 0 # 跳跃顶点计数
@wait_count = 0 # 等待计数
@locked = false # 锁定标志
@prelock_direction = 0 # 锁定前的朝向
@move_failed = false # 移动失败标志
#===========================================================
@jump_speed = JUMP_SPEED #跳跃速度
#@jump_height = JUMP_HEIGHT
@jump_series = 0 #连跳次数累计
@jump_max_series = JUME_SERIES #最大连跳次数
@can_fly = false
#计算重力加速度
[url=home.php?mod=space&uid=282336]@gravitational[/url] = GRAVITATIONAL
#垂直速度为0
@vertical_speed = 0
#初始速度
@init_Vspeed = 0
#着陆
@is_land = true
#不需要继续下落的开关
@no_need_fall = false
#是否可以坠入悬崖
@can_falldown_screen = true
#交通工具性质
@map_vehicle = 0 #地图交通工具 0 无 1为梯子 2 为踏板
#是否在梯子上
@on_ladder = false
#踏板类型
@pedal_type = 0 # 0 为推进型踏板 1 为即落型踏板
#是否在踏板
@on_pedal = false
#弹跳时的行走图
@jump_character = nil
#跳前行走图
@last_character = nil
#乘客(踏板的情况下)
@passengers = nil
#===========================================================
end
#==========================================================================
#★ 设置跳跃初速度
#==========================================================================
def set_jump_speed(speed)
@jump_speed = speed
end #def
#==========================================================================
#--------------------------------------------------------------------------
# ★ 判断是否在跳跃
#--------------------------------------------------------------------------
def jumping?
if $game_map.scene_mode == 0
return @jump_count > 0
else
return false #废弃跳跃判定.主判定已放进update_falling里
end #if
end
#==========================================================================
# ★ 判断角色冲突
# x : X 坐标
# y : Y 坐标
# 包含玩家和交通工具、检测普通角色的冲突。
#==========================================================================
def collide_with_characters?(x, y)
for event in $game_map.events_xy(x, y) # 与事件坐标一致
if($game_map.scene_mode == 1 && event.map_vehicle == 1)
return false
end
unless event.through # 穿越 OFF?
return true if self.is_a?(Game_Event) # 自己是事件
return true if event.priority_type == 1 # 对方是普通角色
end
end
if @priority_type == 1 # 自己是普通角色
return true if $game_player.pos_nt?(x, y) # 与玩家的坐标一致
return true if $game_map.boat.pos_nt?(x, y) # 与小型船坐标一致
return true if $game_map.ship.pos_nt?(x, y) # 与大型船坐标一致
end
return false
end
#==========================================================================
# ★ 获取画面 Y 坐标
#==========================================================================
def screen_y
y = ($game_map.adjust_y(@real_y) + 8007) / 8 - 1000 + 32
#================================================
y -= 4 unless object? || $game_map.scene_mode == 1
#================================================
if $game_map.scene_mode == 0
if @jump_count >= @jump_peak
n = @jump_count - @jump_peak
else
n = @jump_peak - @jump_count
end
return y - (@jump_peak * @jump_peak - n * n) / 2
else
return y
end #if
end
#==========================================================================
# ★ 刷新画面
#==========================================================================
def update
if $game_map.scene_mode == 1
if falling?
update_falling
else
#如果本身是踏板的话检查上面有没乘客
check_passenger
if @real_y < @y*256 && !@on_ladder && !@can_fly && !on_pedal
free_fall
#update_horizontal_fly
else
if !@on_ladder && !@can_fly && !@on_pedal #不在梯子上
@real_y = @y*256 #修正
end
@vertical_speed = 0
@init_Vspeed = 0
@jump_count = 0
if moving?
update_move
else # 正在停止
update_stop
end
if @wait_count > 0 # 正在等待
@wait_count -= 1
elsif @move_route_forcing # 强制移动路径
move_type_custom
elsif not @locked # 被锁定以外
update_self_movement
end
update_animation
end
end
else
if jumping? # 正在跳跃
update_jump
elsif moving? # 正在移动
update_move
else # 正在停止
update_stop
end
if @wait_count > 0 # 正在等待
@wait_count -= 1
elsif @move_route_forcing # 强制移动路径
move_type_custom
elsif not @locked # 被锁定以外
update_self_movement
end
update_animation
end #if
end
#==========================================================================
#★判断是否会下落
#==========================================================================
def falling?
if @jump_series > 0 && !@on_ladder && @jump_character != nil
if @last_character == nil || @character_name != @jump_character[0]
@last_character = [@character_name,@character_index]
end
set_graphic(@jump_character[0],@jump_character[1])
elsif @last_character != nil && @last_character[0] != @character_name
set_graphic(@last_character[0],@last_character[1])
end
if @can_fly || @no_need_fall || @map_vehicle >= 1
return false
end
have_ladder = false
for event in $game_map.events_xy(@x, @y) # 与事件坐标一致
if event.map_vehicle == 1
have_ladder = true
@on_ladder = true
@is_land = true
end
end
if !have_ladder
@on_ladder = false if @on_ladder
else
return false
end
dir = @vertical_speed >= 0 ? 1 : -1
if @jump_count < 0 && @init_Vspeed < 0
dir = -1
end
x = @x
if @x*256-@real_x > 0 #向右
x = (@real_x*1.0/256).floor
elsif @x*256-@real_x < 0
x = (@real_x*1.0/256).ceil
end
result = passable?(x, @y+dir) && passable?(@x, @y+dir)
if ((@y+dir) >= $game_map.height || @real_y/256 > $game_map.height) && @can_falldown_screen
@y = ($game_map.height+1)
@no_need_fall = true
if self.is_a?(Game_Player)
$game_switches[DEAD_SWITCHES_ID] = true
end #
elsif (@y+dir) <= 0
result = true
end
if @on_pedal&&result
@on_pedal = false
end
last_state = @is_land
@is_land = !result && dir == 1
#判断上顶或着陆事件
if !result && (self.is_a?(Game_Player) || self.is_a?(Game_Event))
dir = -1 if @vertical_speed < 0
check_event_trigger_touch(@x,@y+dir)
end
return result
end
#==========================================================================
#★ 下落的更新
#==========================================================================
def update_falling
last_y = @real_y
y = (last_y/256).ceil
free_fall
dir = @vertical_speed >= 0 ? 1 : -1
d = (dir*@vertical_speed*1.00/256).ceil.abs
lst_i = 0
for i in 0..d
if !passable?(@x, y+i*dir)
break
end #if
lst_i = i
end #for
if i > 0
@y = y+lst_i*dir
if !passable?(@x, @y+dir) && @y +dir > 0
@real_y = @y*256
#@vertical_speed = 0
@init_Vspeed = 0
@jump_count = 0
end
end
update_horizontal_fly
end
#==========================================================================
#★自由落体运动
#==========================================================================
def free_fall
@jump_count += 1
@vertical_speed = @init_Vspeed + @gravitational*@jump_count
@real_y = @real_y + @vertical_speed
end
#=========================================================================
#★空中横向移动
#=========================================================================
def update_horizontal_fly
distance = 2 ** @move_speed*2 # 变换移动速度与移动距离
distance += 5 if dash? # 跑步状态时移动速度加倍
@real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
@real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
end
#=========================================================================
#★ 检查乘客(踏板专用)
#=========================================================================
def check_passenger
return if @map_vehicle != 2 || $game_map.scene_mode != 1
if @passengers == nil
@passengers = []
end
if @passengers.size > 0
@passengers.clear
end
for event in $game_map.events_xy(@x, @y-1)
if @pedal_type == 1 #即落型
@map_vehicle = 0 #设为普通角色(重力下自动掉落)
return
else
@passengers.push(event)
end
end
if $game_player.x == @x && $game_player.y == @y-1
if @pedal_type == 1 #即落型
@map_vehicle = 0 #设为普通角色(重力下自动掉落)
return
else
@passengers.push($game_player)
end
end
end
#==========================================================================
#--------------------------------------------------------------------------
# ★ 跳跃时的更新
#--------------------------------------------------------------------------
def update_jump
if $game_map.scene_mode == 0
@jump_count -= 1
@real_x = (@real_x * @jump_count + @x * 256) / (@jump_count + 1)
@real_y = (@real_y * @jump_count + @y * 256) / (@jump_count + 1)
update_bush_depth
end #if
end
#--------------------------------------------------------------------------
# ★ 向下移动
# turn_ok : 此地可以更改朝向
#--------------------------------------------------------------------------
def move_down(turn_ok = true)
if $game_map.scene_mode == 1
@on_ladder =true
end
if passable?(@x, @y+1) # 可以通过
if $game_map.scene_mode == 0 #正常模式下
turn_down
elsif $game_map.scene_mode == 1 #重力模式
turn_up if !@can_fly #设置爬梯时的朝向
#是否踏板,是否有乘客
if @map_vehicle == 2 && @passengers != nil && @passengers.size > 0
for event in @passengers
event.y = @y
event.on_pedal = true
end
end
end
@y = $game_map.round_y(@y+1)
@real_y = (@y-1)*256
increase_steps
@move_failed = false
else # 不可以通过
turn_down if turn_ok
check_event_trigger_touch(@x, @y+1) # 判断接触的事件启动
@move_failed = true
end
#end #if
end
#--------------------------------------------------------------------------
# ★ 向左移动
# turn_ok : 此地可以更改朝向
#--------------------------------------------------------------------------
def move_left(turn_ok = true)
if passable?(@x-1, @y) # 可以通过
turn_left
if $game_map.scene_mode == 1
if @map_vehicle == 2 && @passengers != nil && @passengers.size > 0
for event in @passengers
event.x = $game_map.round_x(@x-1)
event.on_pedal = true
end
end
end
@x = $game_map.round_x(@x-1)
@real_x = (@x+1)*256
increase_steps
@move_failed = false
else # 不可以通过
turn_left if turn_ok
check_event_trigger_touch(@x-1, @y) # 判断接触的事件启动
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ★ 向右移动
# turn_ok : 此地可以更改朝向
#--------------------------------------------------------------------------
def move_right(turn_ok = true)
if passable?(@x+1, @y) # 可以通过
turn_right
if $game_map.scene_mode == 1
if @map_vehicle == 2 && @passengers != nil && @passengers.size > 0
for event in @passengers
event.x = $game_map.round_x(@x+1)
event.on_pedal = true
end #for
end
end
@x = $game_map.round_x(@x+1)
@real_x = (@x-1)*256
increase_steps
@move_failed = false
else # 不可以通过
turn_right if turn_ok
check_event_trigger_touch(@x+1, @y) # 判断接触的事件启动
@move_failed = true
end
end
#--------------------------------------------------------------------------
# ★ 向上移动
# turn_ok : 此地可以更改朝向
#--------------------------------------------------------------------------
def move_up(turn_ok = true)
if $game_map.scene_mode == 0 || ($game_map.scene_mode == 1 && (@on_ladder || @can_fly || @map_vehicle == 2))
pedal_passable = false
if @map_vehicle == 2 && $game_map.scene_mode == 1 && @passengers != nil && @passengers.size > 0
for event in @passengers
if (event.passable?(@x,@y-2))
pedal_passable = true
event.y = $game_map.round_y(@y-2)
event.on_pedal = true
end #if
end#for
end
if passable?(@x, @y-1) || pedal_passable # 可以通过
turn_up
@y = $game_map.round_y(@y-1)
@real_y = (@y+1)*256
increase_steps
@move_failed = false
else # 不可以通过
turn_up if turn_ok
check_event_trigger_touch(@x, @y-1) # 判断接触的事件启动
@move_failed = true
end
end #if
end
#--------------------------------------------------------------------------
# ★ 向左下移动(为了不引起不必要的bug,把重力模式暂时没用到的屏蔽了)
#--------------------------------------------------------------------------
def move_lower_left
if $game_map.scene_mode == 0
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
end
if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y+1))
@x -= 1
@y += 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end
end
#--------------------------------------------------------------------------
# ★ 向右下移动
#--------------------------------------------------------------------------
def move_lower_right
if $game_map.scene_mode == 0
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
end
if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y+1))
@x += 1
@y += 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end #if
end
#--------------------------------------------------------------------------
# ★ 向左上移动
#--------------------------------------------------------------------------
def move_upper_left
if $game_map.scene_mode == 0
unless @direction_fix
@direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
end
if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
(passable?(@x-1, @y) and passable?(@x-1, @y-1))
@x -= 1
@y -= 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end #if
end
#--------------------------------------------------------------------------
# ★ 向右上移动
#--------------------------------------------------------------------------
def move_upper_right
if $game_map.scene_mode == 0
unless @direction_fix
@direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
end
if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
(passable?(@x+1, @y) and passable?(@x+1, @y-1))
@x += 1
@y -= 1
increase_steps
@move_failed = false
else
@move_failed = true
end
end #if
end
#==========================================================================
#★以下这几个是默认的,但是留着方便以后进一步扩展
#==========================================================================
#--------------------------------------------------------------------------
# ★ 随机移动
#--------------------------------------------------------------------------
def move_random
case rand(4)
when 0; move_down(false)
when 1; move_left(false)
when 2; move_right(false)
when 3; move_up(false)
end
end
#--------------------------------------------------------------------------
# ★ 接近玩家
#--------------------------------------------------------------------------
def move_toward_player
sx = distance_x_from_player
sy = distance_y_from_player
if sx != 0 or sy != 0
if sx.abs > sy.abs # 如果横向距离长
sx > 0 ? move_left : move_right # 左右方向优先
if @move_failed and sy != 0
sy > 0 ? move_up : move_down
end
else # 如果纵向距离等长
sy > 0 ? move_up : move_down # 上下方向优先
if @move_failed and sx != 0
sx > 0 ? move_left : move_right
end
end
end
end
#--------------------------------------------------------------------------
# ★ 远离玩家
#--------------------------------------------------------------------------
def move_away_from_player
sx = distance_x_from_player
sy = distance_y_from_player
if sx != 0 or sy != 0
if sx.abs > sy.abs # 如果横向距离长
sx > 0 ? move_right : move_left # 左右方向优先
if @move_failed and sy != 0
sy > 0 ? move_down : move_up
end #if
else # 如果纵向距离等长
sy > 0 ? move_down : move_up # 上下方向优先
if @move_failed and sx != 0
sx > 0 ? move_right : move_left
end #if
end #if
end #if
end
#--------------------------------------------------------------------------
# ★ 前进一步
#--------------------------------------------------------------------------
def move_forward
case @direction
when 2; move_down(false)
when 4; move_left(false)
when 6; move_right(false)
when 8; move_up(false)
end
end
#--------------------------------------------------------------------------
# ★ 后退一步
#--------------------------------------------------------------------------
def move_backward
last_direction_fix = @direction_fix
@direction_fix = true
case @direction
when 2; move_up(false)
when 4; move_right(false)
when 6; move_left(false)
when 8; move_down(false)
end
@direction_fix = last_direction_fix
end
#==========================================================================
#★以上这几个是默认的,但是留着方便以后进一步扩展
#==========================================================================
#--------------------------------------------------------------------------
# ★ 跳跃(重力模式该函数被屏蔽)
# x_plus : X 坐标增加值
# y_plus : Y 坐标增加值
#--------------------------------------------------------------------------
def jump(x_plus, y_plus)
if $game_map.scene_mode == 0
if x_plus.abs > y_plus.abs # 横向距离长
x_plus < 0 ? turn_left : turn_right
elsif x_plus.abs > y_plus.abs # 纵向距离长
y_plus < 0 ? turn_up : turn_down
end
@x += x_plus
@y += y_plus
distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round
@jump_peak = 10 + distance - @move_speed
@jump_count = @jump_peak * 2
@stop_count = 0
straighten
end #if
end
end # class
#==============================================================================
# ★ Game_Map
#------------------------------------------------------------------------------
# 处理地图的类。包含卷动以及可以通行的判断功能。
# 本类的实例请参考 $game_map 。
#==============================================================================
class Game_Map
attr_accessor :scene_mode #地图模式
attr_accessor :events # 事件
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
@screen = Game_Screen.new
@interpreter = Game_Interpreter.new(0, true)
@map_id = 0
@display_x = 0
@display_y = 0
@scene_mode = DEFAULT_MAP_MODE #0为正常模式 1为重力模式
create_vehicles
end
#--------------------------------------------------------------------------
# ● 设置事件
#--------------------------------------------------------------------------
def setup_events
@events = {} # 地图事件
for i in @map.events.keys
@events[i] = Game_Event.new(@map_id, @map.events[i])
end
@common_events = {} # 公共事件
for i in 1...$data_common_events.size
@common_events[i] = Game_CommonEvent.new(i)
end
if @scene_mode == 1
if MAP_VEHICLE != nil && MAP_VEHICLE.include?(@map_id)
for v in MAP_VEHICLE[@map_id]
@events[v[0]].map_vehicle = v[1]
if v[1] == 2
#如果是踏板且有设定其类型的情况下 设置其踏板类型
@events[v[0]].pedal_type = v[2] if v.size > 2
#设置踏板移动速度与角色速度相同,解决踏板与角色脱节的bug.但仍有缺陷,鉴于RM本身地图设计的局限性,忍了!
@events[v[0]].move_speed = $game_player.move_speed
end#if
end #for
end
if MAP_FLY_EVENT != nil && MAP_FLY_EVENT.include?(@map_id)
for v in MAP_FLY_EVENT[@map_id]
@events[v].can_fly = true
end #for
end
end #if
end
#=========================================================================
# ★ 判断是否可以通行
# x : X 坐标
# y : Y 坐标
# flag : 不能通行的点 (一般情况下为 0x01、可以在交通工具的情况下被更改)
#=========================================================================
def passable?(x, y, flag = 0x01)
for event in events_xy(x, y) # 调用坐标一致的事件
next if event.tile_id == 0 # 没有元件图片
next if event.priority_type > 0 # 不是"在普通角色下"
next if event.through # 直接通过状态
pass = @passages[event.tile_id] # 获取通行属性
next if pass & 0x10 == 0x10 # [☆] : 不受通行影响
return true if pass & flag == 0x00 # [○] : 可以通行
#=========================================================================
if($game_map.scene_mode == 1 && $game_player.on_ladder && event.map_vehicle == 1)
return true
end
#=========================================================================
return false if pass & flag == flag # [×] : 不可以通行
end
for i in [2, 1, 0] # 调用图层顺序
tile_id = @map.data[x, y, i] # 获取元件 ID
return false if tile_id == nil # 获取元件 ID 失败 : 不可以通行
pass = @passages[tile_id] # 获取通行属性
next if pass & 0x10 == 0x10 # [☆] : 不受通行影响
return true if pass & flag == 0x00 # [○] : 可以通行
return false if pass & flag == flag # [×] : 不可以通行
end
return false # 不可以通行
end
end #class
#==============================================================================
# ★ Game_Player
#------------------------------------------------------------------------------
# 处理主角的类。事件启动的判定、以及地图的滚动等功能。
# 本类的实例请参考 $game_player。
#==============================================================================
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# ★ 初始化对象
#--------------------------------------------------------------------------
def initialize
super
@vehicle_type = -1
@vehicle_getting_on = false # 乘座动作中标志
@vehicle_getting_off = false # 降下动作中标志
@transferring = false # 场所移动标志
@new_map_id = 0 # 移动目标地图 ID
@new_x = 0 # 移动目标 X 坐标
@new_y = 0 # 移动目标 Y 坐标
@new_direction = 0 # 移动后朝向
@walking_bgm = nil # 记忆步行时的 BGM 用
#=====================================================
@keypress_period = 0
@jump_character = JUMP_CHARACTER
#=====================================================
end
#==========================================================================
#★ 刷新输入
#==========================================================================
def update_input
return if $game_map.interpreter.running?
if @is_land
@jump_series = 0
end
#按下跳跃键时
if Input.press?(JUMP_KEY)
if @jump_series < @jump_max_series && @keypress_period == 0 && (@is_land || @jump_series > 0) && @y <= $game_map.height
@init_Vspeed = - @jump_speed + JUMP_SERIES_WEAKEN*@jump_series
@jump_count = -1
@jump_series += 1
if JUMP_SE != nil && JUMP_SE != ""
Audio.se_play("Audio/SE/"+JUMP_SE,100,100)
end
end
@keypress_period += 1
else
if @keypress_period > 0
@keypress_period = 0
@init_Vspeed = 0
@jump_count = -1
end
end
case Input.dir4
#向下
when 2;
move_down if movable?
#向左
when 4;
move_left if movable? || (!@is_land && flyable?)
#向右
when 6;
move_right if movable? || (!@is_land && flyable?)
#向上
when 8;
move_up if movable?
end #case
end
#==========================================================================
#★ 判断是否可以滑翔
#==========================================================================
def flyable?
return !(@real_x != @x * 256)
end
#==========================================================================
#★ 角色调入悬崖后重生(重新初始化相关重力数据)
#==========================================================================
def reborn
@no_need_fall = false
end
#==========================================================================
#--------------------------------------------------------------------------
# ★ 刷新画面
#--------------------------------------------------------------------------
def update
last_real_x = @real_x
last_real_y = @real_y
last_moving = moving?
if $game_map.scene_mode == 1 #重力模式
update_input
else
move_by_input
end
super
update_scroll(last_real_x, last_real_y)
update_vehicle
update_nonmoving(last_moving)
end
#==========================================================================
#★以下这几个是默认的,但是留着方便以后进一步扩展
#==========================================================================
#--------------------------------------------------------------------------
# ● 乘降交通工具
#--------------------------------------------------------------------------
def get_on_off_vehicle
return false unless movable?
if in_vehicle?
return get_off_vehicle
else
return get_on_vehicle
end
end
#--------------------------------------------------------------------------
# ● 乘座交通工具
# 前提是当前没有乘座交通工具。
#--------------------------------------------------------------------------
def get_on_vehicle
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
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 get_on_boat
@vehicle_getting_on = true # 乘座中标志
@vehicle_type = 0 # 设置交通工具类型
force_move_forward # 前进一步
@walking_bgm = RPG::BGM::last # 记忆步行时 BGM 用
$game_map.boat.get_on # 乘座处理
end
#--------------------------------------------------------------------------
# ● 乘座大型船
#--------------------------------------------------------------------------
def get_on_ship
@vehicle_getting_on = true # 乘座
@vehicle_type = 1 # 设置交通工具类型
force_move_forward # 前进一步
@walking_bgm = RPG::BGM::last # 记忆步行时 BGM 用
$game_map.ship.get_on # 乘座处理
end
#--------------------------------------------------------------------------
# ● 乘座飞行船
#--------------------------------------------------------------------------
def get_on_airship
@vehicle_getting_on = true # 开始乘座动作
@vehicle_type = 2 # 设置交通工具类型
@through = true # 穿越 ON
@walking_bgm = RPG::BGM::last # 记忆步行时 BGM 用
$game_map.airship.get_on # 乘座处理
end
#--------------------------------------------------------------------------
# ● 降下交通工具
# 前提是现在乘座了交通工具。
#--------------------------------------------------------------------------
def get_off_vehicle
if in_airship? # 飞行船
return unless airship_land_ok?(@x, @y) # 无法着陆?
else # 小型船·大型船
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
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 # 穿越 OFF
@walking_bgm.play # 还原步行时的 BGM
make_encounter_count # 初始化遇敌率
end
#==========================================================================
#★以上这几个是默认的,但是留着方便以后进一步扩展
#==========================================================================
end #class
就是这个脚本了{:2_279:} 本人脚本盲,求助