本帖最后由 soulsaga 于 2016-9-21 12:14 编辑
瞬移到敌人背后
有难度啊..
瞬移到敌人背后
Game_Character 3
#-------------------------------------------------------------------------- # ● 瞬移到事件身后 #-------------------------------------------------------------------------- def Teleport_event(Range) #Range为瞬移可能的距离 sx = [] sy = [] for i in $game_map.events sx.push(@x.abs - $game_map.events[i].x.abs) sy.push(@y.abs - $game_map.events[i].y.abs) end case @direction when 8 #面向上 if $game_player.y == sy.min and sy <= Range $game_player.y = sy.min - 1 @direction = 2 #修正朝向为面向敌人 end when 2 #面向下 if $game_player.y == sy.min and sy <= Range $game_player.y = sy.min - 1 @direction = 8 #修正朝向为面向敌人 end when 4 #面向左 if $game_player.x == sx.min and sx <= Range $game_player.x = sx.min - 1 @direction = 6 #修正朝向为面向敌人 end @direction = 6 #修正朝向为面向敌人 when 6 #面向右 if $game_player.x == sx.min and sx <= Range $game_player.x = sx.min - 1 @direction = 4 #修正朝向为面向敌人 end end end
#--------------------------------------------------------------------------
# ● 瞬移到事件身后
#--------------------------------------------------------------------------
def Teleport_event(Range) #Range为瞬移可能的距离
sx = []
sy = []
for i in $game_map.events
sx.push(@x.abs - $game_map.events[i].x.abs)
sy.push(@y.abs - $game_map.events[i].y.abs)
end
case @direction
when 8 #面向上
if $game_player.y == sy.min and sy <= Range
$game_player.y = sy.min - 1
@direction = 2 #修正朝向为面向敌人
end
when 2 #面向下
if $game_player.y == sy.min and sy <= Range
$game_player.y = sy.min - 1
@direction = 8 #修正朝向为面向敌人
end
when 4 #面向左
if $game_player.x == sx.min and sx <= Range
$game_player.x = sx.min - 1
@direction = 6 #修正朝向为面向敌人
end
@direction = 6 #修正朝向为面向敌人
when 6 #面向右
if $game_player.x == sx.min and sx <= Range
$game_player.x = sx.min - 1
@direction = 4 #修正朝向为面向敌人
end
end
end
未测试..不知行不行得通..
移动路线用脚本:Teleport_event(瞬移可能距离) |