查看: 4013|回复: 15

[已经解决] 请问怎么判断事件是不是面朝主角

[复制链接]
梦石
0
星屑
50
在线时间
163 小时
注册时间
2015-11-12
回帖
32
发表于 2016-1-18 23:59:09 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
我想做类似于宠物小精灵里的效果。就是路上的人面朝你的时候,会主动过来和你决斗。不是面朝你的时候就不会触发。
请问在条件分歧里的脚本该怎么写?
嗯,谢谢各位大神了!
david_ng223 该用户已被删除
发表于 2016-1-19 07:25:25 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

店长

梦石
13
星屑
1282
在线时间
1810 小时
注册时间
2010-10-6
回帖
760

蛤蛤蛤蛤开拓者

发表于 2016-1-19 10:03:00 | 显示全部楼层
QQ图片20160119100139.png
QQ图片20160119100152.png
用坐标代入变量来判断.
Project4.zip (1.43 MB, 下载次数: 53)

评分

参与人数 1梦石 +1 收起 理由
丿梁丶小柒 + 1 认可答案

查看全部评分

努力填新坑中!
回复

使用道具 举报

梦石
0
星屑
50
在线时间
163 小时
注册时间
2015-11-12
回帖
32
 楼主| 发表于 2016-1-19 17:55:15 | 显示全部楼层
猪衰衰 发表于 2016-1-19 10:03
用坐标代入变量来判断.

额,十分感谢!不过似乎是我的描述有问题,我的朝向不仅仅是坐标相同那意思,就是事件里面有一个移动指令是面朝主角,那时候主角的坐标在一定范围内事件都只是朝一个方向。
再次感谢你的帮助!
回复

使用道具 举报

漾夕☽星化残月☾

梦石
0
星屑
8611
在线时间
3858 小时
注册时间
2015-5-12
回帖
2022

剧作品鉴家

发表于 2016-1-19 22:19:01 | 显示全部楼层
并行处理

如玩家面朝向为?(面对)则战斗处理
回复

使用道具 举报

梦石
0
星屑
50
在线时间
163 小时
注册时间
2015-11-12
回帖
32
 楼主| 发表于 2016-1-19 23:33:16 | 显示全部楼层
御曹司 发表于 2016-1-19 22:19
并行处理

如玩家面朝向为?(面对)则战斗处理

可能是我表达不清,十分抱歉!
我的意思是,角色在事件的朝向方向的时候会触发事件,事件不是朝向角色的时候不会触发,而且宠物小精灵里的事件都是会动的,会转向的。
额,还是十分感谢你啦。
回复

使用道具 举报

梦石
2
星屑
1073
在线时间
370 小时
注册时间
2015-2-2
回帖
127

超评测优秀

发表于 2016-1-20 00:07:41 | 显示全部楼层
你在人物前面平铺一排事件,就是角色碰到后,人物就开始行走(靠近主角),用开关控制。此时再让角色禁止移动,人物那是并行处理。也不知道行不行,你试一下
为什么要想那么多呢?夜空之下,冷风之中,其实也是一种美呢。一定会开启,梦之旅的!
回复

使用道具 举报

梦石
0
星屑
7736
在线时间
1227 小时
注册时间
2008-12-14
回帖
504
发表于 2016-1-20 00:49:30 | 显示全部楼层
你需要的是前方直线sensor一类的脚本。翻墙搜索下。sensor range是感应的,但你只要前方的。
需要购买本人MV插件必须先加wx好友。加不上wx就是本人忙,没时间卖。原则上太久以前的插件也不想卖,因为我也忘了,维护上会不给力。wx名:alskyif    本人插件地址:
   LCK_SRPG梦幻模拟战、火焰纹章类系统
   究极立绘ADV系统

   究极换装统合系统
   究极! 回想与CG系统
   消息文字的距离调整  
   自动返回上一张地图
回复

使用道具 举报

老鹰

梦石
40
星屑
37812
在线时间
7091 小时
注册时间
2012-5-26
回帖
3297

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2016-1-20 09:42:13 | 显示全部楼层
YEA-事件追逐玩家[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Event Chase Player v1.00
# -- Last Updated: 2012.01.05
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-EventChasePlayer"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.05 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script allows you to make events that will chase the player or flee from
# the player when the player enters within range of the event or when the event
# sees the player.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Move Script Call - Open up the script call in the event move menu and use:
# -----------------------------------------------------------------------------
# Add these variable changes to an event's move route to use them.
#
# @chase_range = x
# Event will chase the player after reaching x range.
#
# @flee_range = x
# Event will flee from player after reaching x range.
#
# @chase_speed = x
# Event will move at x speed when chasing.
#
# @flee_speed = x
# Event will move at x speed when fleeing.
#
# @sight_lock = x
# Event will chase/flee from player for x frames.
#
# @alert_balloon = x
# Event will show ballon ID x when chasing or fleeing.
#
# @alert_sound = x
# Event will play this sound upon sighting the player
#
# @see_player = true
# For events that require them to see the player first, use this script call
# inside the movement boxes. This does not follow line of sight rules, which
# means if there's a rock blocking you and the event, it will still see you.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YEA
  module EVENT_CHASE
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - General Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # These settings adjust some general settings regarding chasing and fleeing
    # events. Adjust them as you see fit.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # The number of frames before a balloon can show up again on the same
    # event. This is to prevent a massive balloon spamming. 60 frames = 1 sec.
    # By default, 120 frames is 2 seconds.
    ALERT_TIMER = 120
   
    # This is the default number of frames for how long the event will chase or
    # flee from the player if used with @see_player = true. To change the amount
    # individually for each event, use @sight_lock = x where x is a number.
    # By default, 300 frames is 5 seconds.
    SIGHT_LOCK = 300
   
  end # EVENT_CHASE
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

#==============================================================================
# ■ Game_Event
#==============================================================================

class Game_Event < Game_Character
  
  #--------------------------------------------------------------------------
  # alias method: update_self_movement
  #--------------------------------------------------------------------------
  alias game_event_update_self_movement_ecp update_self_movement
  def update_self_movement
    return if $imported["YEA-StopAllMovement"] && Switch.stop_npc_movement
    update_chase_distance
    update_flee_distance
    if @stop_count > 0 && @chase_player
      move_type_toward_player
    elsif @stop_count > 0 && @flee_player
      move_type_away_player
    else
      game_event_update_self_movement_ecp
    end
    update_alert_balloon       
  end
  
  #--------------------------------------------------------------------------
  # new method: update_chase_distance
  #--------------------------------------------------------------------------
  def update_chase_distance
    return if @erased
    return if @chase_range.nil?
    dis = distance_x_from($game_player.x).abs
    dis += distance_y_from($game_player.y).abs
    if chase_conditions
      @chase_player = true
      @move_speed = @chase_speed unless @chase_speed.nil?
    else
      @chase_player = false
      @move_speed = @page.move_speed
      @alert_player = false if @alert_timer <= 0
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: chase_conditions
  #--------------------------------------------------------------------------
  def chase_conditions
    dis = distance_x_from($game_player.x).abs
    dis += distance_y_from($game_player.y).abs
    return true if @alert_lock > 0
    return true if dis <= @chase_range and see_player?
    if dis <= @chase_range && @see_player != true
      @alert_lock = @sight_lock if @sight_lock != nil && @sight_lock > 0
      return true
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # new method: update_flee_distance
  #--------------------------------------------------------------------------
  def update_flee_distance
    return if @erased
    return if @flee_range.nil?
    dis = distance_x_from($game_player.x).abs
    dis += distance_y_from($game_player.y).abs
    if flee_conditions
      @flee_player = true
      @move_speed = @flee_speed unless @flee_speed.nil?
    else
      @flee_player = false
      @move_speed = @page.move_speed
      @alert_player = false if @alert_timer <= 0
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: flee_conditions
  #--------------------------------------------------------------------------
  def flee_conditions
    dis = distance_x_from($game_player.x).abs
    dis += distance_y_from($game_player.y).abs
    return true if @alert_lock > 0
    return true if dis <= @flee_range and see_player?
    if dis <= @flee_range && @see_player != true
      @alert_lock = @sight_lock if @sight_lock != nil && @sight_lock > 0
      return true
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # new method: update_alert_balloon
  #--------------------------------------------------------------------------
  def update_alert_balloon
    return if @erased
    @alert_timer = 0 if @alert_timer.nil?
    @alert_lock = 0 if @alert_lock.nil?
    @alert_lock -= 1 if @alert_lock >= 0
    return if @alert_balloon == nil || @alert_balloon == 0
    if (@chase_player || @flee_player) && !@alert_player
      @balloon_id = @alert_balloon
      @alert_player = true
      @alert_timer = YEA::EVENT_CHASE::ALERT_TIMER
          RPG::SE.new(@alert_sound, 100, 100).play unless @alert_sound.nil?
    end
    @alert_timer -= 1 if @alert_player
  end
  
  #--------------------------------------------------------------------------
  # new method: see_player?
  #--------------------------------------------------------------------------
  def see_player?
    return false if @see_player != true
    sx = distance_x_from($game_player.x)
    sy = distance_y_from($game_player.y)
    if sx.abs > sy.abs
      direction = sx > 0 ? 4 : 6
    else
      direction = sy > 0 ? 8 : 2
    end
    if direction == @direction
      if @sight_lock == nil || @sight_lock <= 0
        @sight_lock = YEA::EVENT_CHASE::SIGHT_LOCK
      end
      @alert_lock = @sight_lock
      return true
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # new method: move_type_away_player
  #--------------------------------------------------------------------------
  def move_type_away_player
    sx = @x - $game_player.x
    sy = @y - $game_player.y
    if sx.abs + sy.abs >= 20
      move_random
    else
      case rand(6)
      when 0..3;  move_away_from_player
      when 4;     move_random
      when 5;     move_forward
      end
    end
  end
  
end # Game_Event

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]


# @see_player = true
# For events that require them to see the player first, use this script call
# inside the movement boxes. This does not follow line of sight rules, which
# means if there's a rock blocking you and the event, it will still see you.

在移动路径里加上这个 @see_player = true 的话,事件会先判定是否“看见”玩家(事件朝向和玩家朝向相向,x或y相同时)
回复

使用道具 举报

梦石
0
星屑
50
在线时间
163 小时
注册时间
2015-11-12
回帖
32
 楼主| 发表于 2016-1-20 18:13:59 | 显示全部楼层
百里_飞柳 发表于 2016-1-20 09:42
[fold=YEA-事件追逐玩家]#============================================================================ ...

老鹰,我还是不太会用,能上传个范例么,麻烦你啦。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部