赞 | 0 |
VIP | 7 |
好人卡 | 0 |
积分 | 2 |
经验 | 18255 |
最后登录 | 2021-7-7 |
在线时间 | 224 小时 |
Lv1.梦旅人 剑仙·影羽
- 梦石
- 0
- 星屑
- 172
- 在线时间
- 224 小时
- 注册时间
- 2010-3-20
- 帖子
- 1580
|
本帖最后由 凌辰 于 2010-7-3 17:08 编辑
好吧,第4个问题:
- =begin
- ------------------------------
- 重力状态:(在每个地图都要设置一下,"并行处理")
- $ud_ok = false
- $airjump = 1
- ====================================================================
- 解除重力:(在游戏里用于爬楼梯)
- $ud_ok = true
- ====================================================================
- - -b如果你比较有才,可以做出“海洋”中的那种超浮力跳跃!
- ------------------------------
- =end
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息!
- #==============================================================================
- $ud_ok = true
- $airjump = 0
- # ————————————————————————————————————
- # 脚本 RMXP重力系统
- # 翻译负责人:ML4455739
- # 相关网址:http://www.55rpg.com/
- # http://members.jcom.home.ne.jp/cogwheel/
- # ————————————————————————————————————
- #==============================================================================
- # ■ Game_Player
- #--
- # 主角的变化。事件启动确定、并且移动地图,有这些功能
- # 这个类 $game_player 参考。
- #==============================================================================
- class Game_Player < Game_Character
- #------------------------------------
- # ● 定值
- #------------------------------------
- UP = 48 # 上方的坐标(0 < UP < 63)
- DOWN = 16 # 下方的坐标(0 < DOWN <63)
- SIDE = 32 # 左右方向的坐标(0 < SIDE <63)
- SLANT = true # 斜向移动、速度修正
- JUMPMAX = 100
- JUMPADD = 10
- #------------------------------------
- # ● 公共变量
- #------------------------------------
- attr_reader :event # 自由落体时速度
- attr_accessor :move_speed # 移动速度
- #------------------------------------
- # ● 帧率更新
- #------------------------------------
- alias :update_original :update
- def update
- # @walk:歩行速度 @dash:冲刺时的速度
- # @event:事件的移动速度(为0时,事件没有速度变化)
- @walk = 4
- @dash = 5.5
- @event = 0
- if $game_switches[8] = true
- @dot_m = true
- else
- @dot_m = false
- end
- #冲刺能力。同时可以改变移动速度。
- unless moving? or $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing
- if @walk != @dash
- if Kboard.keyb($R_Key_1) == 1
- if @move_speed != @dash
- @move_speed = @dash
- $game_variables[10] = 4
- end
- else
- if @move_speed != @walk
- @move_speed = @walk
- $game_variables[10] = 1
- end
- end
- end
- end
- if @revise_x == nil and @revise_y == nil
- @revise_x = 0
- @revise_y = 0
- end
- unless @dot_m
- update_original
- return
- end
- if @move_route_forcing
- # 移动中记录全局变量
- last_moving = moving?
- # 以本地变量记忆坐标
- last_real_x = @real_x
- last_real_y = @real_y
- # 除此以外的场合
- if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
- if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
- @revise_x = @real_x - @x * 128
- @revise_y = @real_y - @y * 128
- end
- # 移动距离1和移动目标距离2的设定
- distance1 = 2 ** @move_speed
- distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
- # 移动距离超过目标的场合
- if distance1 > distance2
- # 强制修正坐标为0
- @real_x = @real_x - @revise_x
- @real_y = @real_y - @revise_y
- @revise_x = 0
- @revise_y = 0
- anime_update
- # 移动距离达到移动目标
- else
- # 移动距离不到移动目标的场合
- @real_x -= (distance1 * @revise_x / distance2).round
- @real_y -= (distance1 * @revise_y / distance2).round
- @revise_x = @real_x - @x * 128
- @revise_y = @real_y - @y * 128
- anime_update
- end
- else
- super
- end
- else
- @move = false
- # 移动中、冲刺中、强制移动中、
- # 没有进程的场合
- unless moving? or $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing
- @event_run = false
- # 若按下方向键,主角向这个方向移动
- #---------------------------上下移动---
- case Input.dir8
- when 1
- $ud_ok ? move_lower_left_p : move_left_p
- when 2
- # $ud_ok ? move_down_p : move_down_aaaagq
- move_down_p if $ud_ok
- when 3
- $ud_ok ? move_lower_right_p : move_right_p
- when 4
- move_left_p
- when 6
- move_right_p
- when 7
- $ud_ok ? move_upper_left_p : move_left_p
- when 8
- # $ud_ok ? move_up_p : move_up_aaaagq
- move_up_p if $ud_ok
- when 9
- $ud_ok ? move_upper_right_p : move_right_p
- end
- end
- # 以一个本地变量记忆坐标
- last_real_x = @real_x
- last_real_y = @real_y
- # 移动处理
- @real_x = @x * 128 + @revise_x
- @real_y = @y * 128 + @revise_y
- # 全局变量
- last_moving = moving?
- # 位置记忆更新
- move_on
- # 目前坐标和以前的坐标不相同的场合
- if (last_real_x != @real_x or last_real_y != @real_y)
- @move_distance = 0 if @move_distance == nil
- @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
- (last_real_y - @real_y) ** 2)
- if @move_distance >= 128
- @move_distance %= 128
- increase_steps
- end
- # 更新
- anime_update
- else
- @pattern = 0
- end
- end
- # 向下移动,将画面移动到中心
- if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
- # 向下卷动画面
- $game_map.scroll_down(@real_y - last_real_y)
- end
- # 向左移动,将画面移动到中心
- if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
- # 向左卷动画面
- $game_map.scroll_left(last_real_x - @real_x)
- end
- # 向右移动,将画面移动到中心
- if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
- # 向右卷动画面
- $game_map.scroll_right(@real_x - last_real_x)
- end
- # 向上移动,将画面移动到中心
- if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
- # 向上卷动画面
- $game_map.scroll_up(last_real_y - @real_y)
- end
- # 主角停止移动
- if last_moving
- # 同位置事件启动
- result = check_event_trigger_here([1,2])
- if result == true
- if (last_real_x / 128.0).round != @x and
- (last_real_y / 128.0).round != @y
- if @direction == 2 or @direction == 8
- if (last_real_x / 128.0).round > @x
- turn_left
- else
- turn_right
- end
- else
- if (last_real_y / 128.0).round > @y
- turn_up
- else
- turn_down
- end
- end
- elsif (last_real_x / 128.0).round > @x
- turn_left
- elsif (last_real_x / 128.0).round < @x
- turn_right
- elsif (last_real_y / 128.0).round > @y
- turn_up
- elsif (last_real_y / 128.0).round < @y
- turn_down
- end
- end
- # 事件没有启动的场合
- if result == false
- # 检查调试模式,Ctrl键是否被按下
- unless $DEBUG and Input.press?(Input::CTRL)
- # 结束
- if @encounter_count > 0
- @encounter_count -= 1
- end
- end
- end
- end
- #-----------------------起跳---------
- # 2键按下的场合
- if Kboard.keyboard($R_Key_2) and not $ud_ok
- $game_variables[10] = 5
- @twojump = 1 if @twojump == 0 and down1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, 5, true)
- if (not @apassed) and @twojump <= $airjump
- @apassed = true
- @jumpnow = JUMPMAX
- @twojump += 1
- else
- @jumpnow += 3
- end
- else
- @apassed = false
- end
- #----------------------自由落体--------------------------------
- if not $ud_ok
- @jumpnow -= 10
- if @jumpnow < 0
- @jumpnow = [@jumpnow, -JUMPMAX].max
- if not down1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, -@jumpnow, true)
- @jumpnow = 0
- @twojump = 0
- end
- elsif @jumpnow > 0
- @jumpnow = [@jumpnow, JUMPMAX].min
- if not up1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, @jumpnow, true)
- @jumpnow = 0
- end
- end
- end
- if Input.trigger?(Input::C)
- # 同位置正面事件启动
- check_event_trigger_here([0])
- check_event_trigger_there([0,1,2])
- $game_variables[10] = 1
- end
- end
- #------------------------------------
- # ● 初始化对象
- #------------------------------------
- def initialize
- @jumpnow = 0
- @twojump = 0
- @apassed = false
- @revise_x = 0
- @revise_y = 0
- @move == false
- super
- end
- #------------------------------------
- # ● 移动判断
- #------------------------------------
- def moving?
- unless @dot_m
- result = super
- return result
- end
- # 强制移动的场合
- if @move_route_forcing
- if @move == false
- return false
- end
- super
- # 目前的真实坐标
- else
- return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
- end
- end
- #------------------------------------
- # ● 移动判断
- #------------------------------------
- def moving_a?
- if @move == false
- if (@move_route.list[@move_route_index].code <= 14 or
- @move_route.list[@move_route_index].code == 25)
- @move = true
- end
- return false
- end
- moving?
- end
- #------------------------------------
- # ● 帧率更新(跳跃)
- #------------------------------------
- def update_jump
- # -1
- @jump_count -= 1
- # 新的坐标更新
- @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
- @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
- if @jump_count == 0
- @revise_x = 0
- @revise_y = 0
- end
- end
- #------------------------------------
- # ● 移动类型:自定义移动
- #------------------------------------
- def move_type_custom
- unless @dot_m
- super
- return
- end
- # 停止中断
- if jumping? or moving_a?
- return
- end
- # 循环移动,直至移动操作的最后一次移动
- while @move_route_index < @move_route.list.size
- # 获取移动事件的指令
- command = @move_route.list[@move_route_index]
- # 代码0 (事件页的最后) 的场合
- if command.code == 0
- # 选项 [操作循环] 为 ON 的场合
- if @move_route.repeat
- # 返回初始
- @move_route_index = 0
- end
- # 选项 [操作循环] 为 OFF 的場合
- unless @move_route.repeat
- # 强制移动的场合
- if @move_route_forcing and not @move_route.repeat
- # 强制移动解除
- @move_route_forcing = false
- # 回到原来的路线
- @move_route = @original_move_route
- @move_route_index = @original_move_route_index
- @original_move_route = nil
- end
- # 停止记忆
- @stop_count = 0
- end
- return
- end
- # 移动指令(向下跳跃) 的場合
- if command.code <= 14
- # 命令分歧
- case command.code
- when 1 # 向下移动
- move_down
- when 2 # 向左移动
- move_left
- when 3 # 向右移动
- move_right
- when 4 # 向上移动
- move_up
- when 5 # 向左下移动
- move_lower_left
- when 6 # 向右下移动
- move_lower_right
- when 7 # 向左上移动
- move_upper_left
- when 8 # 向右上移动
- move_upper_right
- when 9 # 随机移动
- move_random
- when 10 # 接近主角
- move_toward_player
- when 11 # 远离主角
- move_away_from_player
- when 12 # 向前一步
- move_forward
- when 13 # 向后一步
- move_backward
- when 14 # 跳跃
- jump(command.parameters[0], command.parameters[1])
- end
- # 选项 [忽略不能移动的场合] 为 OFF 在失败的场合
- if not @move_route.skippable and not moving? and not jumping?
- return
- end
- @move_route_index += 1
- return
- end
- # 重力
- if command.code == 15
- # 设置
- @wait_count = command.parameters[0] * 2 - 1
- @move_route_index += 1
- return
- end
- # 改变方向的移动指令
- if command.code >= 16 and command.code <= 26
- # 指令分歧
- case command.code
- when 16 # 下方向
- turn_down
- when 17 # 左方向
- turn_left
- when 18 # 右方向
- turn_right
- when 19 # 上方向
- turn_up
- when 20 # 向右转90°
- turn_right_90
- when 21 # 向左转90°
- turn_left_90
- when 22 # 旋转180°
- turn_180
- when 23 # 向左或向右旋转90°
- turn_right_or_left_90
- when 24 # 随机转向
- turn_random
- when 25 # 主角正面
- turn_toward_player
- when 26 # 主角背面
- turn_away_from_player
- end
- @move_route_index += 1
- return
- end
- # 其它移动指令
- if command.code >= 27
- # 指令分歧
- case command.code
- when 27 # 开关为 ON 的场合
- $game_switches[command.parameters[0]] = true
- $game_map.need_refresh = true
- when 28 # 开关为 OFF 的场合
- $game_switches[command.parameters[0]] = false
- $game_map.need_refresh = true
- when 29 # 移动速度变更
- @move_speed = command.parameters[0]
- when 30 # 移动频率变更
- @move_frequency = command.parameters[0]
- when 31 # 播放移动动画为 ON
- @walk_anime = true
- when 32 # 播放移动动画为 OFF
- @walk_anime = false
- when 33 # 播放停止时动画 ON
- @step_anime = true
- when 34 # 播放停止时动画 OFF
- @step_anime = false
- when 35 # 面向固定 ON
- @direction_fix = true
- when 36 # 面向固定 OFF
- @direction_fix = false
- when 37 # 穿透 ON
- @through = true
- when 38 # 穿透 OFF
- @through = false
- when 39 # 在最前方显示 ON
- @always_on_top = true
- when 40 # 在最前方显示 OFF
- @always_on_top = false
- when 41 # 更改图形
- @tile_id = 0
- @character_name = command.parameters[0]
- @character_hue = command.parameters[1]
- if @original_direction != command.parameters[2]
- @direction = command.parameters[2]
- @original_direction = @direction
- @prelock_direction = 0
- end
- if @original_pattern != command.parameters[3]
- @pattern = command.parameters[3]
- @original_pattern = @pattern
- end
- when 42 # 不透明度变更
- @opacity = command.parameters[0]
- when 43 # 合成方法变更
- @blend_type = command.parameters[0]
- when 44 # SE 音效演奏
- $game_system.se_play(command.parameters[0])
- when 45 # 脚本
- result = eval(command.parameters[0])
- end
- @move_route_index += 1
- return
- end
- end
- end
- #------------------------------------
- # ● 向下移动
- #------------------------------------
- def move_down_p
- # 向下
- turn_down
- # 计算移动距离
- distance = 2 ** @move_speed
- down1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance, true)
- end
- def move_down_aaaagq
- distance = 2 ** @move_speed
- down1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance, true)
- end
- #------------------------------------
- # ● 向下移动判定 1
- #------------------------------------
- def down1(x, y, distance, down = false)
- result = down2(x, y, distance)
- if result == false
- @event_run = check_event_trigger_touch(x, y+1)
- return result
- end
- if @revise_x < -SIDE
- result = down2(x, y + 1, distance, 4)
- result &= down2(x - 1, y, distance)
- if result == false
- if down
- move_lower_right_p
- if @revise_x > SIDE
- @revise_x = SIDE
- end
- end
- return result
- end
- elsif @revise_x > SIDE
- result = down2(x, y + 1, distance, 6)
- result &= down2(x + 1, y, distance)
- if result == false
- if down
- move_lower_left_p
- if @revise_x < -SIDE
- @revise_x = -SIDE
- end
- end
- return result
- end
- end
- # 向下移动距离
- @revise_y += distance
- return result
- end
- #------------------------------------
- # ● 向下移动判定 2
- #------------------------------------
- def down2(x, y, distance, d = 2)
- if @revise_y + distance > DOWN
- unless passable?(x, y, d)
- if @revise_y < DOWN
- @revise_y = DOWN
- end
- return false
- end
- end
- return true
- end
- #------------------------------------
- # ● 向左移动
- #------------------------------------
- def move_left_p
- # 向左
- turn_left
- distance = 2 ** @move_speed
- left1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance, true)
- end
- #------------------------------------
- # ● 向左移动判定 1
- #------------------------------------
- def left1(x, y, distance, left = false)
- result = left2(x, y, distance)
- if result == false
- @event_run = check_event_trigger_touch(x-1, y)
- return result
- end
- if @revise_y < -UP and $ud_ok
- result = left2(x - 1, y, distance, 8)
- result &= left2(x, y - 1, distance)
- if result == false
- if left
- move_lower_left_p
- if @revise_y > DOWN
- @revise_y = DOWN
- end
- end
- return result
- end
- elsif @revise_y > DOWN and $ud_ok
- result = left2(x - 1, y, distance, 2)
- result &= left2(x, y + 1, distance)
- if result == false
- if left
- move_upper_left_p
- if @revise_y < -UP
- @revise_y = -UP
- end
- end
- return result
- end
- end
- @revise_x -= distance
- return result
- end
- #------------------------------------
- # ● 向左移动判定 2
- #------------------------------------
- def left2(x, y, distance, d = 4)
- if @revise_x - distance < -SIDE
- unless passable?(x, y, d)
- if @revise_x > -SIDE
- @revise_x = -SIDE
- end
- return false
- end
- end
- return true
- end
- #------------------------------------
- # ● 向右移动
- #------------------------------------
- def move_right_p
- # 向右
- turn_right
- distance = 2 ** @move_speed
- right1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance, true)
- end
- #------------------------------------
- # ● 向右移动判定 1
- #------------------------------------
- def right1(x, y, distance, right = false)
- result = right2(x, y, distance)
- if result == false
- @event_run = check_event_trigger_touch(x+1, y)
- return result
- end
- if @revise_y < -UP and $ud_ok
- result = right2(x + 1, y, distance, 8)
- result &= right2(x, y - 1, distance)
- if result == false
- if right
- move_lower_right_p
- if @revise_y > DOWN
- @revise_y = DOWN
- end
- end
- return result
- end
- elsif @revise_y > DOWN and $ud_ok
- result = right2(x + 1, y, distance, 2)
- result &= right2(x, y + 1, distance)
- if result == false
- if right
- move_upper_right_p
- if @revise_y < -UP
- @revise_y = -UP
- end
- end
- return result
- end
- end
- @revise_x += distance
- return result
- end
- #------------------------------------
- # ● 向右移动判定 2
- #------------------------------------
- def right2(x, y, distance, d = 6)
- if @revise_x + distance > SIDE
- unless passable?(x, y, d)
- if @revise_x < SIDE
- @revise_x = SIDE
- end
- return false
- end
- end
- return true
- end
- #------------------------------------
- # ● 向上移动
- #------------------------------------
- def move_up_p
- # 向上
- turn_up
- # 向下移动
- distance = 2 ** @move_speed
- up1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance, true)
- end
- def move_up_aaaagq
- distance = 2 ** @move_speed
- up1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance, true)
- end
- #------------------------------------
- # ● 向上移动判定 1
- #------------------------------------
- def up1(x, y, distance, up = false)
- result = up2(x, y, distance)
- if result == false
- @event_run = check_event_trigger_touch(x, y-1)
- return result
- end
- if @revise_x < -SIDE
- result = up2(x, y - 1, distance, 4)
- result &= up2(x - 1, y, distance)
- if result == false
- if up
- move_upper_right_p
- if @revise_x > SIDE
- @revise_x = SIDE
- end
- end
- return result
- end
- elsif @revise_x > SIDE
- result = up2(x, y - 1, distance, 6)
- result &= up2(x + 1, y, distance)
- if result == false
- if up
- move_upper_left_p
- if @revise_x < -SIDE
- @revise_x = -SIDE
- end
- end
- return result
- end
- end
- @revise_y -= distance
- return result
- end
- #------------------------------------
- # ● 向上移动判定 2
- #------------------------------------
- def up2(x, y, distance, d = 8)
- if @revise_y - distance < -UP
- unless passable?(x, y, d)
- if @revise_y > -UP
- @revise_y = -UP
- end
- return false
- end
- end
- return true
- end
- #------------------------------------
- # ● 向左下移动
- #------------------------------------
- def move_lower_left_p
- # 面向固定的场合
- unless @direction_fix
- # 固定左右,则向上向下
- @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
- end
- # 左下移动
- distance = (2 ** @move_speed) / Math.sqrt(2)
- if @direction == 2
- turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_down if @event_run
- unless @event_run
- if last_move?(@real_x, @real_y, 2, distance)
- result = check_event_trigger_here([1,2], false)
- if result == true
- return
- end
- end
- move_on
- if @revise_y > DOWN and -UP > @revise_y - distance
- @revise_y = DOWN
- end
- turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_left if @event_run
- end
- else
- turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_left if @event_run
- unless @event_run
- if last_move?(@real_x, @real_y, 4, distance)
- result = check_event_trigger_here([1,2], false)
- if result == true
- return
- end
- end
- move_on
- if @revise_x + distance> SIDE and -SIDE > @revise_x
- @revise_x = -SIDE
- end
- turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_down if @event_run
- end
- end
- end
- #------------------------------------
- # ● 向右下移動
- #------------------------------------
- def move_lower_right_p
- # 面向固定的场合
- unless @direction_fix
- # 固定左右,则向上向下
- @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
- end
- # 右下移动
- distance = (2 ** @move_speed) / Math.sqrt(2)
- if @direction == 2
- turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_down if @event_run
- unless @event_run
- if last_move?(@real_x, @real_y, 2, distance)
- result = check_event_trigger_here([1,2], false)
- if result == true
- return
- end
- end
- move_on
- if @revise_y > DOWN and -UP > @revise_y - distance
- @revise_y = DOWN
- end
- turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_right if @event_run
- end
- else
- turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_right if @event_run
- unless @event_run
- if last_move?(@real_x, @real_y, 6, distance)
- result = check_event_trigger_here([1,2], false)
- if result == true
- return
- end
- end
- move_on
- if @revise_x > SIDE and -SIDE > @revise_x - distance
- @revise_x = SIDE
- end
- turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_down if @event_run
- end
- end
- end
- #------------------------------------
- # ● 向左上移動
- #------------------------------------
- def move_upper_left_p
- # 面向固定的场合
- unless @direction_fix
- # 固定左右,则向上向下
- @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
- end
- # 左上移动
- distance = (2 ** @move_speed) / Math.sqrt(2)
- if @direction == 8
- turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_up if @event_run
- unless @event_run
- if last_move?(@real_x, @real_y, 8, distance)
- result = check_event_trigger_here([1,2], false)
- if result == true
- return
- end
- end
- move_on
- if @revise_y + distance > DOWN and -UP > @revise_y
- @revise_y = -UP
- end
- turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_left if @event_run
- end
- else
- turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_left if @event_run
- unless @event_run
- if last_move?(@real_x, @real_y, 4, distance)
- result = check_event_trigger_here([1,2], false)
- if result == true
- return
- end
- end
- move_on
- if @revise_x > SIDE and -SIDE > @revise_x - distance
- @revise_x = SIDE
- end
- turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_up if @event_run
- end
- end
- end
- #------------------------------------
- # ● 向右上移動
- #------------------------------------
- def move_upper_right_p
- # 面向固定的场合
- unless @direction_fix
- # 固定左右,则向上向
- @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
- end
- # 右上移动
- distance = (2 ** @move_speed) / Math.sqrt(2)
- if @direction == 8
- turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_up if @event_run
- unless @event_run
- if last_move?(@real_x, @real_y, 8, distance)
- result = check_event_trigger_here([1,2], false)
- if result == true
- return
- end
- end
- move_on
- if @revise_y + distance > DOWN and -UP > @revise_y
- @revise_y = -UP
- end
- turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_right if @event_run
- end
- else
- turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_right if @event_run
- unless @event_run
- if last_move?(@real_x, @real_y, 6, distance)
- result = check_event_trigger_here([1,2], false)
- if result == true
- return
- end
- end
- move_on
- if @revise_x > SIDE and -SIDE > @revise_x - distance
- @revise_x = SIDE
- end
- turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
- ((@y * 128 + @revise_y) / 128.0).round, distance)
- turn_up if @event_run
- end
- end
- end
- #------------------------------------
- # ● 确定事件的初始位置
- #------------------------------------
- def check_event_trigger_here(triggers, run = true)
- result = false
- # 正在执行时间的场合
- if $game_system.map_interpreter.running?
- return result
- end
- # 循环全部事件
- for event in $game_map.events.values
- # 与事件坐标一致的场合
- if event.x == ((@x * 128 + @revise_x) / 128.0).round and
- event.y == ((@y * 128 + @revise_y) / 128.0).round and
- triggers.include?(event.trigger)
- # 初始活动地点
- if not event.jumping? and event.over_trigger?
- if event.list.size > 1
- if run == true
- event.start
- end
- result = true
- end
- end
- end
- end
- return result
- end
- #------------------------------------
- # ● 坐标修正及更新
- #------------------------------------
- def move_on
- if @y < (@y + @revise_y / 128.0).round
- @y += 1
- @revise_y -= 128
- end
- if @x > (@x + @revise_x / 128.0).round
- @x -= 1
- @revise_x += 128
- end
- if @x < (@x + @revise_x / 128.0).round
- @x += 1
- @revise_x -= 128
- end
- if @y > (@y + @revise_y / 128.0).round
- @y -= 1
- @revise_y += 128
- end
- end
- #------------------------------------
- # ● 动画以及动作更新
- #------------------------------------
- def anime_update
- # 播放移动时动画为 ON 的场合
- if @walk_anime
- # 动画+1.5
- @anime_count += 1.5
- # 播放移动时动画为 OFF 或 播放停止时动画为 ON 的场合
- elsif @step_anime
- # 动画+1
- @anime_count += 1
- end
- # 动画最大值超过上限的场合
- # ※最大值、基本值 18 从移动速度 * 1 减去
- if @anime_count > 18 - @move_speed * 2
- # 播放停止时动画为 OFF 并且 停止的场合
- if not @step_anime and @stop_count > 0
- # 回到原来的模式
- @pattern = @original_pattern
- # 播放停止时动画为 ON 或 正在移动的场合
- else
- # 更替模式
- @pattern = (@pattern + 1) % 4
- end
- # 计数动画
- @anime_count = 0
- end
- end
- #------------------------------------
- # ● 移动到指定的位置
- #------------------------------------
- # 重命名事件
- alias :moveto_original :moveto
- def moveto(x, y)
- # 初始化修改坐标
- @revise_x = 0
- @revise_y = 0
- # 调用初始坐标
- moveto_original(x, y)
- end
- #------------------------------------
- # ● 是否移动的判定
- #------------------------------------
- def last_move?(x, y, direction, distance)
- if direction == 2 or direction == 6
- distance *= -1
- end
- if (direction == 2 or direction == 8) and
- (y / 128.0).round != ((y - distance) / 128.0).round
- return true
- end
- if (direction == 4 or direction == 6) and
- (x / 128.0).round != ((x - distance) / 128.0).round
- return true
- end
- return false
- end
- end
- #==============================================================================
- # ■ Game_Character (分割定义 1)
- #--
- # 代码处理的类。这个类在 Game_Player 和 Game_Event
- # 中使用的超类。
- #==============================================================================
- class Game_Character
- #------------------------------------
- # ● 帧率更新 (移动中)
- #------------------------------------
- def update_move
- # 地图坐标随移动距离转换
- distance = 2 ** @move_speed
- if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
- distance /= Math.sqrt(2)
- end
- # 若处于实际坐标下
- if @y * 128 > @real_y
- # 向下移动
- @real_y = [@real_y + distance, @y * 128].min
- end
- # 若处于实际坐标左
- if @x * 128 < @real_x
- # 向左移动
- @real_x = [@real_x - distance, @x * 128].max
- end
- # 若处于实际坐标右
- if @x * 128 > @real_x
- # 向右移动
- @real_x = [@real_x + distance, @x * 128].min
- end
- # 若处于实际坐标上
- if @y * 128 < @real_y
- # 向上移动
- @real_y = [@real_y - distance, @y * 128].max
- end
- # 播放移动时动画为 ON 的场合
- if @walk_anime
- # 动画+1.5
- @anime_count += 1.5
- # 播放移动时动画为 OFF 或 播放停止时动画为 ON 的场合
- elsif @step_anime
- # 动画+1
- @anime_count += 1
- end
- end
- end
- #==============================================================================
- # ■ Game_Event
- #--
- # 处理事件的类。满足执行条件、可以执行的时间、并行处理的事件
- # 已经执行的功能(例如事件),在Game_Map 内部中使用。
- #==============================================================================
- class Game_Event < Game_Character
- #------------------------------------
- # ● 执行开始
- #------------------------------------
- def start
- # 什么都没做的场合
- if @list.size > 1
- # $game_player.event 为0的场合
- if $game_player.event != 0
- # 移动速度 $game_player.event
- $game_player.move_speed = $game_player.event
- end
- @starting = true
- end
- end
- end
- #==============================================================================
- # 本脚本来自www.66RPG.com,由55RPG部分翻译,使用和转载请保留此信息!
- #==============================================================================
复制代码 其实问题1用我那个方法更好,可以不浪费变量^_^ |
|