| 赞 | 3 |
| VIP | |
| 好人卡 | |
| 积分 | 23 |
| 经验 | |
| 最后登录 | 2021-10-3 |
| 在线时间 | 125 小时 |
- 梦石
- 0
- 星屑
- 2270
- 在线时间
- 125 小时
- 注册时间
- 2015-8-14
- 回帖
- 17
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 Hello``Bubble 于 2015-8-18 08:55 编辑
说明事件指令“禁止斜触发”,用来制作传送,门,宝箱等事件。
使用时,在当前执行的事件页中的“任意”位置加入注释“禁止斜触发”即可。
PS 将移动处理、事件刷新、player刷新等方法,使用alias以提高兼容性。
其实就是让角色一次走半格,支持八方向。
rgss1默认走(默认关闭)- $game_temp.rgss_move = true# 默认走
- $game_temp.dir_4 = true# 四方向走
复制代码 半格走(默认开启)- $game_temp.rgss_move = false# 半格走
- $game_temp.dir_4 = false# 八方向走
复制代码半格移动截图(4图)
触发截图(11图)柜台
一般
脚本- class Game_Temp
- attr_accessor :rgss_move, :dir_4
- #alias rgss_initialize_xxxxxxxxx initialize 默认值???
- #def initialize
- # rgss_initialize_xxxxxxxxx
- # @rgss_move = false
- # @dir_4 = false
- #end
- end
- class Game_Event < Game_Character
- attr_reader :touch_4
- alias rgss_refresh refresh
- def refresh
- rgss_refresh
- @touch_4 = nil
- for list in @page.list
- if list.code == 108 or list.code == 408
- if list.parameters[0] =~ /禁止斜触发/
- @touch_4 = true
- break
- end
- end
- end
- end
- end
- class Game_Player < Game_Character
- def x(f=nil)
- return !f ? @x.to_i : @x
- end
- def y(f=nil)
- return !f ? @y.to_i : @y
- end
- def to_i
- @x = @x.to_i if @x.is_a?(Float)
- @y = @y.to_i if @y.is_a?(Float)
- end
- def player_passable?(dir = @direction, px = @x, py = @y)
- case dir
- when 8
- (py - 0.5).to_i == py.to_i or (passable?(px.to_i, py.to_i, 8) and
- passable?((px + 0.5).to_i, py.to_i, 8))
- when 2
- passable?(px.to_i, py.to_i, 2) and
- passable?((px + 0.5).to_i, py.to_i, 2)
- when 4
- (px - 0.5).to_i == px.to_i or (passable?(px.to_i, py.to_i, 4) and
- passable?(px.to_i, (py + 0.5).to_i, 4))
- when 6
- passable?(px.to_i, py.to_i, 6) and
- passable?(px.to_i, (py + 0.5).to_i, 6)
- when 1
- (player_passable?(4) and player_passable?(2, @x - 0.5)) or
- (player_passable?(2) and player_passable?(4, @x, @y + 0.5))
- when 3
- (player_passable?(6) and player_passable?(2, @x + 0.5)) or
- (player_passable?(2) and player_passable?(6, @x, @y + 0.5))
- when 7
- (player_passable?(4) and player_passable?(8, @x - 0.5)) or
- (player_passable?(8) and player_passable?(4, @x, @y - 0.5))
- when 9
- (player_passable?(6) and player_passable?(8, @x + 0.5)) or
- (player_passable?(8) and player_passable?(6, @x, @y - 0.5))
- end
- end
- #--------------------------------------------------------------------------
- # ● 接触事件启动判定
- #--------------------------------------------------------------------------
- def check_event_trigger_touch(x, y)
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 全事件的循环
- for event in $game_map.events.values
- if event.touch_4
- if (x - 0.5).to_i == x.to_i or
- (y - 0.5).to_i == y.to_i
- next
- end
- end
- # 事件坐标与目标一致的情况下
- if event.x == x.to_i and event.y == y.to_i and [1,2].include?(event.trigger)
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger?
- event.start
- result = true
- end
- end
- end
- return result
- end
- def player_check_event_trigger_touch(dir)
- case dir
- when 8
- check_event_trigger_touch(@x, @y - 1)
- if (@x + 0.5).to_i != @x.to_i
- check_event_trigger_touch(@x + 1, @y - 1)
- end
- when 2
- check_event_trigger_touch(@x, @y + 1)
- if (@x + 0.5).to_i != @x.to_i
- check_event_trigger_touch(@x + 1, @y + 1)
- end
- when 4
- check_event_trigger_touch(@x - 1, @y)
- if (@y + 0.5).to_i != @y.to_i
- check_event_trigger_touch(@x - 1, @y + 1)
- end
- when 6
- check_event_trigger_touch(@x + 1, @y)
- if (@y + 0.5).to_i != @y.to_i
- check_event_trigger_touch(@x + 1, @y + 1)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 同位置的事件启动判定
- #--------------------------------------------------------------------------
- def check_event_trigger_here(triggers)
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 全部事件的循环
- for event in $game_map.events.values
- # 事件坐标与目标一致的情况下
- if triggers.include?(event.trigger) and
- ((event.x == @x.to_i and event.y == @y.to_i) or
- (!event.touch_4 and event.x == (@x + 0.5).to_i and event.y == @y.to_i) or
- (!event.touch_4 and event.x == @x.to_i and event.y == (@y + 0.5).to_i))
- # 跳跃中以外的情况下、启动判定是同位置的事件
- if not event.jumping? and event.over_trigger?
- event.start
- result = true
- end
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 正面事件的启动判定
- #--------------------------------------------------------------------------
- def check_event_trigger_there(triggers)
- result = false
- # 事件执行中的情况下
- if $game_system.map_interpreter.running?
- return result
- end
- # 计算正面坐标
- new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- # 全部事件的循环
- for event in $game_map.events.values
- if event.touch_4
- if (new_x - 0.5).to_i == new_x.to_i or
- (new_y - 0.5).to_i == new_y.to_i
- next
- end
- end
- # 事件坐标与目标一致的情况下
- if !player_passable? and triggers.include?(event.trigger) and
- ((event.x == new_x.to_i and event.y == new_y.to_i) or
- (!event.touch_4 and event.x == (new_x + 0.5).to_i and event.y == new_y.to_i) or
- (!event.touch_4 and event.x == new_x.to_i and event.y == (new_y + 0.5).to_i))
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger?
- event.start
- result = true
- end
- end
- end
- # 找不到符合条件的事件的情况下
- if result == false
- # 正面的元件是柜台的情况下
- if $game_map.counter?(new_x, new_y)
- # 计算 1 元件里侧的坐标
- new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
- new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
- # 全事件的循环
- for event in $game_map.events.values
- if event.touch_4
- if (new_x - 0.5).to_i == new_x.to_i or
- (new_y - 0.5).to_i == new_y.to_i
- next
- end
- end
- # 事件坐标与目标一致的情况下
- if triggers.include?(event.trigger) and
- ((event.x == new_x.to_i and event.y == new_y.to_i) or
- (!event.touch_4 and event.x == (new_x + 0.5).to_i and event.y == new_y.to_i) or
- (!event.touch_4 and event.x == new_x.to_i and event.y == (new_y + 0.5).to_i))
- # 跳跃中以外的情况下、启动判定是正面的事件
- if not event.jumping? and not event.over_trigger?
- event.start
- result = true
- end
- end
- end
- end
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 向上移动
- # turn_enabled : 本场地位置更改许可标志
- #--------------------------------------------------------------------------
- def move_up(turn_enabled = true)
- if $game_temp.rgss_move then
- to_i ; super ; return
- end
- # 面向上
- if turn_enabled
- turn_up
- end
- # 可以通行的情况下
- if player_passable?(8)
- # 面向上
- turn_up
- # 更新坐标
- @y -= 0.5
- # 歩数増加
- increase_steps
- # 不能通行的情况下
- else
- # 接触事件的启动判定
- player_check_event_trigger_touch(8)
- end
- end
- #--------------------------------------------------------------------------
- # ● 向下移动
- # turn_enabled : 本场地位置更改许可标志
- #--------------------------------------------------------------------------
- def move_down(turn_enabled = true)
- if $game_temp.rgss_move then
- to_i ; super ; return
- end
- # 面向下
- if turn_enabled
- turn_down
- end
- # 可以通行的场合
- if player_passable?(2)
- # 面向下
- turn_down
- # 更新坐标
- @y += 0.5
- # 增加步数
- increase_steps
- # 不能通行的情况下
- else
- # 接触事件的启动判定
- player_check_event_trigger_touch(2)
- end
- end
- #--------------------------------------------------------------------------
- # ● 向左移动
- # turn_enabled : 本场地位置更改许可标志
- #--------------------------------------------------------------------------
- def move_left(turn_enabled = true)
- if $game_temp.rgss_move then
- to_i ; super ; return
- end
- # 面向左
- if turn_enabled
- turn_left
- end
- # 可以通行的情况下
- if player_passable?(4)
- # 面向左
- turn_left
- # 更新坐标
- @x -= 0.5
- # 增加步数
- increase_steps
- # 不能通行的情况下
- else
- # 接触事件的启动判定
- player_check_event_trigger_touch(4)
- end
- end
- #--------------------------------------------------------------------------
- # ● 向右移动
- # turn_enabled : 本场地位置更改许可标志
- #--------------------------------------------------------------------------
- def move_right(turn_enabled = true)
- if $game_temp.rgss_move then
- to_i ; super ; return
- end
- # 面向右
- if turn_enabled
- turn_right
- end
- # 可以通行的场合
- if player_passable?(6)
- # 面向右
- turn_right
- # 更新坐标
- @x += 0.5
- # 增加步数
- increase_steps
- # 不能通行的情况下
- else
- # 接触事件的启动判定
- player_check_event_trigger_touch(6)
- end
- end
- #--------------------------------------------------------------------------
- # ● 向左下移动
- #--------------------------------------------------------------------------
- def move_lower_left
- if $game_temp.rgss_move then
- to_i ; super ; return
- end
- # 没有固定面向的场合
- unless @direction_fix
- # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
- @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
- end
- # 下→左、左→下 的通道可以通行的情况下
- if player_passable?(1)
- # 更新坐标
- @x -= 0.5
- @y += 0.5
- # 增加步数
- increase_steps
- end
- end
- #--------------------------------------------------------------------------
- # ● 向右下移动
- #--------------------------------------------------------------------------
- def move_lower_right
- if $game_temp.rgss_move then
- to_i ; super ; return
- end
- # 没有固定面向的场合
- unless @direction_fix
- # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
- @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
- end
- # 下→右、右→下 的通道可以通行的情况下
- if player_passable?(3)
- # 更新坐标
- @x += 0.5
- @y += 0.5
- # 增加步数
- increase_steps
- end
- end
- #--------------------------------------------------------------------------
- # ● 向左上移动
- #--------------------------------------------------------------------------
- def move_upper_left
- if $game_temp.rgss_move then
- to_i ; super ; return
- end
- # 没有固定面向的场合
- unless @direction_fix
- # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
- @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
- end
- # 上→左、左→上 的通道可以通行的情况下
- if player_passable?(7)
- # 更新坐标
- @x -= 0.5
- @y -= 0.5
- # 增加步数
- increase_steps
- end
- end
- #--------------------------------------------------------------------------
- # ● 向右上移动
- #--------------------------------------------------------------------------
- def move_upper_right
- if $game_temp.rgss_move then
- to_i ; super ; return
- end
- # 没有固定面向的场合
- unless @direction_fix
- # 朝向是右的情况下适合的面是左面、朝向是上的情况下适合的面是下面
- @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
- end
- # 上→右、右→上 的通道可以通行的情况下
- if player_passable?(9)
- # 更新坐标
- @x += 0.5
- @y -= 0.5
- # 增加步数
- increase_steps
- end
- end
- #--------------------------------------------------------------------------
- # ● 画面更新
- #--------------------------------------------------------------------------
- alias rgss_update update
- def update
- if $game_temp.dir_4
- rgss_update
- return
- end
- # 本地变量记录移动信息
- last_moving = moving?
- # 移动中、事件执行中、强制移动路线中、
- # 信息窗口一个也不显示的时候
- unless moving? or $game_system.map_interpreter.running? or
- @move_route_forcing or $game_temp.message_window_showing
- # 如果方向键被按下、主角就朝那个方向移动
- 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
- # 本地变量记忆坐标
- last_real_x = @real_x
- last_real_y = @real_y
- super
- # 角色向下移动、画面上的位置在中央下方的情况下
- 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
- # 不在移动中的情况下
- unless moving?
- # 上次主角移动中的情况
- if last_moving
- # 与同位置的事件接触就判定为事件启动
- result = check_event_trigger_here([1,2])
- # 没有可以启动的事件的情况下
- if result == false
- # 调试模式为 ON 并且按下 CTRL 键的情况下除外
- unless $DEBUG and Input.press?(Input::CTRL)
- # 遇敌计数下降
- if @encounter_count > 0
- @encounter_count -= 1
- end
- end
- end
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 判定为同位置以及正面的事件启动
- check_event_trigger_here([0])
- check_event_trigger_there([0,1,2])
- end
- end
- end
- end
复制代码
附件完整基础版
像素移动 基础版.zip
(231.03 KB, 下载次数: 188)
更完整的斜向触发判断
像素移动 更完整斜触发.zip
(231.21 KB, 下载次数: 274)
|
评分
-
查看全部评分
|