考虑到默认系统中玩家操控的角色按下方向键会直接移动,因此添加了领队原地选择方向的功能,默认键位下按住键盘上的A键,再按方向键可原地调整方向(做到随时面向队友)
如果玩家面向队友,默认键位下按回车或者空格键可触发 1号变量的值 的公共事件
比如:1号变量值为1,那么面向队友按下空格键,会触发1号公共事件的内容
此脚本针对的是楼主所说的只有1个队友的情况下写的,如果队友不止一个的话我是不管的
class Game_Player def do_new_direction if Input.press?(:X) if Input.trigger?(:UP) set_direction(8) elsif Input.trigger?(:DOWN) set_direction(2) elsif Input.trigger?(:LEFT) set_direction(4) elsif Input.trigger?(:RIGHT) set_direction(6) end end end alias mfxrbmbi190316 move_by_input def move_by_input return if Input.press?(:X) mfxrbmbi190316 end alias mfxrbupdate190627 update def update do_new_direction mfxrbupdate190627 update_play_command end def has_follower?(index,x,y) @followers[index].x == x && @followers[index].y == y end def follower_ahead? e_x = $game_player.x + 1 e_x2 = $game_player.x - 1 e_y = $game_player.y + 1 e_y2 = $game_player.y - 1 a = has_follower?(0,e_x,$game_player.y) b = has_follower?(0,e_x2,$game_player.y) c = has_follower?(0,$game_player.x,e_y) d = has_follower?(0,$game_player.x,e_y2) if (a && $game_player.direction == 6) or (b && $game_player.direction == 4) or(c && $game_player.direction == 2) or (d && $game_player.direction == 8) return true else return false end end def update_play_command return unless follower_ahead? if Input.trigger?(:C) && $game_variables[1].is_a?(Integer) $game_temp.reserve_common_event($game_variables[1]) end end end
class Game_Player
def do_new_direction
if Input.press?(:X)
if Input.trigger?(:UP)
set_direction(8)
elsif Input.trigger?(:DOWN)
set_direction(2)
elsif Input.trigger?(:LEFT)
set_direction(4)
elsif Input.trigger?(:RIGHT)
set_direction(6)
end
end
end
alias mfxrbmbi190316 move_by_input
def move_by_input
return if Input.press?(:X)
mfxrbmbi190316
end
alias mfxrbupdate190627 update
def update
do_new_direction
mfxrbupdate190627
update_play_command
end
def has_follower?(index,x,y)
@followers[index].x == x && @followers[index].y == y
end
def follower_ahead?
e_x = $game_player.x + 1
e_x2 = $game_player.x - 1
e_y = $game_player.y + 1
e_y2 = $game_player.y - 1
a = has_follower?(0,e_x,$game_player.y)
b = has_follower?(0,e_x2,$game_player.y)
c = has_follower?(0,$game_player.x,e_y)
d = has_follower?(0,$game_player.x,e_y2)
if (a && $game_player.direction == 6) or (b && $game_player.direction == 4) or(c && $game_player.direction == 2) or (d && $game_player.direction == 8)
return true
else
return false
end
end
def update_play_command
return unless follower_ahead?
if Input.trigger?(:C) && $game_variables[1].is_a?(Integer)
$game_temp.reserve_common_event($game_variables[1])
end
end
end
|