查看: 4162|回复: 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
星屑
1215
在线时间
375 小时
注册时间
2015-2-2
回帖
136

超评测优秀

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

使用道具 举报

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

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

使用道具 举报

老鹰

梦石
40
星屑
38049
在线时间
7128 小时
注册时间
2012-5-26
回帖
3306

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

发表于 2016-1-20 09:42:13 | 显示全部楼层
YEA-事件追逐玩家
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Event Chase Player v1.00
  4. # -- Last Updated: 2012.01.05
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================

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

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.01.05 - Started Script and Finished.
  15. #
  16. #==============================================================================
  17. # ▼ Introduction
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # This script allows you to make events that will chase the player or flee from
  20. # the player when the player enters within range of the event or when the event
  21. # sees the player.
  22. #
  23. #==============================================================================
  24. # ▼ Instructions
  25. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  26. # To install this script, open up your script editor and copy/paste this script
  27. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  28. #
  29. # -----------------------------------------------------------------------------
  30. # Move Script Call - Open up the script call in the event move menu and use:
  31. # -----------------------------------------------------------------------------
  32. # Add these variable changes to an event's move route to use them.
  33. #
  34. # @chase_range = x
  35. # Event will chase the player after reaching x range.
  36. #
  37. # @flee_range = x
  38. # Event will flee from player after reaching x range.
  39. #
  40. # @chase_speed = x
  41. # Event will move at x speed when chasing.
  42. #
  43. # @flee_speed = x
  44. # Event will move at x speed when fleeing.
  45. #
  46. # @sight_lock = x
  47. # Event will chase/flee from player for x frames.
  48. #
  49. # @alert_balloon = x
  50. # Event will show ballon ID x when chasing or fleeing.
  51. #
  52. # @alert_sound = x
  53. # Event will play this sound upon sighting the player
  54. #
  55. # @see_player = true
  56. # For events that require them to see the player first, use this script call
  57. # inside the movement boxes. This does not follow line of sight rules, which
  58. # means if there's a rock blocking you and the event, it will still see you.
  59. #
  60. #==============================================================================
  61. # ▼ Compatibility
  62. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  63. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  64. # it will run with RPG Maker VX without adjusting.
  65. #
  66. #==============================================================================

  67. module YEA
  68.   module EVENT_CHASE
  69.    
  70.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  71.     # - General Settings -
  72.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  73.     # These settings adjust some general settings regarding chasing and fleeing
  74.     # events. Adjust them as you see fit.
  75.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  76.     # The number of frames before a balloon can show up again on the same
  77.     # event. This is to prevent a massive balloon spamming. 60 frames = 1 sec.
  78.     # By default, 120 frames is 2 seconds.
  79.     ALERT_TIMER = 120
  80.    
  81.     # This is the default number of frames for how long the event will chase or
  82.     # flee from the player if used with @see_player = true. To change the amount
  83.     # individually for each event, use @sight_lock = x where x is a number.
  84.     # By default, 300 frames is 5 seconds.
  85.     SIGHT_LOCK = 300
  86.    
  87.   end # EVENT_CHASE
  88. end # YEA

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

  94. #==============================================================================
  95. # ■ Game_Event
  96. #==============================================================================

  97. class Game_Event < Game_Character
  98.   
  99.   #--------------------------------------------------------------------------
  100.   # alias method: update_self_movement
  101.   #--------------------------------------------------------------------------
  102.   alias game_event_update_self_movement_ecp update_self_movement
  103.   def update_self_movement
  104.     return if $imported["YEA-StopAllMovement"] && Switch.stop_npc_movement
  105.     update_chase_distance
  106.     update_flee_distance
  107.     if @stop_count > 0 && @chase_player
  108.       move_type_toward_player
  109.     elsif @stop_count > 0 && @flee_player
  110.       move_type_away_player
  111.     else
  112.       game_event_update_self_movement_ecp
  113.     end
  114.     update_alert_balloon       
  115.   end
  116.   
  117.   #--------------------------------------------------------------------------
  118.   # new method: update_chase_distance
  119.   #--------------------------------------------------------------------------
  120.   def update_chase_distance
  121.     return if @erased
  122.     return if @chase_range.nil?
  123.     dis = distance_x_from($game_player.x).abs
  124.     dis += distance_y_from($game_player.y).abs
  125.     if chase_conditions
  126.       @chase_player = true
  127.       @move_speed = @chase_speed unless @chase_speed.nil?
  128.     else
  129.       @chase_player = false
  130.       @move_speed = @page.move_speed
  131.       @alert_player = false if @alert_timer <= 0
  132.     end
  133.   end
  134.   
  135.   #--------------------------------------------------------------------------
  136.   # new method: chase_conditions
  137.   #--------------------------------------------------------------------------
  138.   def chase_conditions
  139.     dis = distance_x_from($game_player.x).abs
  140.     dis += distance_y_from($game_player.y).abs
  141.     return true if @alert_lock > 0
  142.     return true if dis <= @chase_range and see_player?
  143.     if dis <= @chase_range && @see_player != true
  144.       @alert_lock = @sight_lock if @sight_lock != nil && @sight_lock > 0
  145.       return true
  146.     end
  147.     return false
  148.   end
  149.   
  150.   #--------------------------------------------------------------------------
  151.   # new method: update_flee_distance
  152.   #--------------------------------------------------------------------------
  153.   def update_flee_distance
  154.     return if @erased
  155.     return if @flee_range.nil?
  156.     dis = distance_x_from($game_player.x).abs
  157.     dis += distance_y_from($game_player.y).abs
  158.     if flee_conditions
  159.       @flee_player = true
  160.       @move_speed = @flee_speed unless @flee_speed.nil?
  161.     else
  162.       @flee_player = false
  163.       @move_speed = @page.move_speed
  164.       @alert_player = false if @alert_timer <= 0
  165.     end
  166.   end
  167.   
  168.   #--------------------------------------------------------------------------
  169.   # new method: flee_conditions
  170.   #--------------------------------------------------------------------------
  171.   def flee_conditions
  172.     dis = distance_x_from($game_player.x).abs
  173.     dis += distance_y_from($game_player.y).abs
  174.     return true if @alert_lock > 0
  175.     return true if dis <= @flee_range and see_player?
  176.     if dis <= @flee_range && @see_player != true
  177.       @alert_lock = @sight_lock if @sight_lock != nil && @sight_lock > 0
  178.       return true
  179.     end
  180.     return false
  181.   end
  182.   
  183.   #--------------------------------------------------------------------------
  184.   # new method: update_alert_balloon
  185.   #--------------------------------------------------------------------------
  186.   def update_alert_balloon
  187.     return if @erased
  188.     @alert_timer = 0 if @alert_timer.nil?
  189.     @alert_lock = 0 if @alert_lock.nil?
  190.     @alert_lock -= 1 if @alert_lock >= 0
  191.     return if @alert_balloon == nil || @alert_balloon == 0
  192.     if (@chase_player || @flee_player) && !@alert_player
  193.       @balloon_id = @alert_balloon
  194.       @alert_player = true
  195.       @alert_timer = YEA::EVENT_CHASE::ALERT_TIMER
  196.           RPG::SE.new(@alert_sound, 100, 100).play unless @alert_sound.nil?
  197.     end
  198.     @alert_timer -= 1 if @alert_player
  199.   end
  200.   
  201.   #--------------------------------------------------------------------------
  202.   # new method: see_player?
  203.   #--------------------------------------------------------------------------
  204.   def see_player?
  205.     return false if @see_player != true
  206.     sx = distance_x_from($game_player.x)
  207.     sy = distance_y_from($game_player.y)
  208.     if sx.abs > sy.abs
  209.       direction = sx > 0 ? 4 : 6
  210.     else
  211.       direction = sy > 0 ? 8 : 2
  212.     end
  213.     if direction == @direction
  214.       if @sight_lock == nil || @sight_lock <= 0
  215.         @sight_lock = YEA::EVENT_CHASE::SIGHT_LOCK
  216.       end
  217.       @alert_lock = @sight_lock
  218.       return true
  219.     end
  220.     return false
  221.   end
  222.   
  223.   #--------------------------------------------------------------------------
  224.   # new method: move_type_away_player
  225.   #--------------------------------------------------------------------------
  226.   def move_type_away_player
  227.     sx = @x - $game_player.x
  228.     sy = @y - $game_player.y
  229.     if sx.abs + sy.abs >= 20
  230.       move_random
  231.     else
  232.       case rand(6)
  233.       when 0..3;  move_away_from_player
  234.       when 4;     move_random
  235.       when 5;     move_forward
  236.       end
  237.     end
  238.   end
  239.   
  240. end # Game_Event

  241. #==============================================================================
  242. #
  243. # ▼ End of File
  244. #
  245. #==============================================================================
复制代码


# @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.

在本版发帖返回顶部