设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3674|回复: 5
打印 上一主题 下一主题

[已经解决] 请问如何事件接触事件来触发动作

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
137 小时
注册时间
2012-8-27
帖子
109
跳转到指定楼层
1
发表于 2013-6-8 18:00:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 liminglun 于 2013-6-8 18:10 编辑

谢谢各位了,在做事健
补充:事件过多,所以用判断x,y会累死的
从某处扒来了个脚本思路
用矩形数组加循环加下标读取所有事件的横,纵坐标。然后编写函数运算x,y的距离值,返回真假
再用一个循环将所有数组带入函数运算一遍,返回真的话就倒出当前数组下标••••然后运行排列为倒出数的时间就行了= =


Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
21626
在线时间
9413 小时
注册时间
2012-6-19
帖子
7118

开拓者短篇九导演组冠军

2
发表于 2013-6-9 20:44:07 | 只看该作者
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
137 小时
注册时间
2012-8-27
帖子
109
3
 楼主| 发表于 2013-6-10 14:39:30 | 只看该作者
喵呜喵5 发表于 2013-6-9 20:44
http://himeworks.wordpress.com/2013/04/05/custom-event-triggers/

(需要翻墙)

能帮忙贴过来吗,实在是懒得弄apn了。。。谢谢大神


回复 支持 反对

使用道具 举报

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
21626
在线时间
9413 小时
注册时间
2012-6-19
帖子
7118

开拓者短篇九导演组冠军

4
发表于 2013-6-10 15:11:48 | 只看该作者
liminglun 发表于 2013-6-10 14:39
能帮忙贴过来吗,实在是懒得弄apn了。。。谢谢大神

用法说明:
RUBY 代码复制
  1. To specify a custom page trigger, create a comment of the form
  2.  
  3. <page trigger: trigger_name>
  4. Where `trigger_name` is one of the available custom event triggers. The reference section lists all of the available custom triggers.
  5.  
  6. Extended Trigger Data
  7.  
  8. This script adds “extended data” to the trigger.
  9. Certain triggers may use this data to determine how to run.
  10.  
  11. The general format for extended trigger data is
  12.  
  13. <page trigger: trigger_name ext_data>
  14. Where ext_data is any string. Check the reference to see what kinds of
  15. extended data may be required for each trigger.
  16.  
  17. Parallel Triggers
  18.  
  19. A custom trigger can be used as a condition for starting a parallel process. If the activation condition is met, then the event will begin running as a parallel process. This will not stop until the page changes.
  20.  
  21.  
  22.  
  23. Reference
  24.  
  25. Here is a list of available triggers and a description about them.
  26.  
  27. Player_Leave
  28.  
  29. Triggered when the player steps off an event. Note that this means the
  30. event must have below-character priority.
  31.  
  32.  
  33.  
  34. Timer Expire
  35.  
  36. Triggered when the game timer counts down to zero. The timer must be counting down in order for these events to trigger.
  37.  
  38. Event_On_Event
  39.  
  40. Triggered when an event comes into contact with another event (using the
  41. “event touch” rules).  Takes a list of event ID’s for extended data. Only the specified event ID’s can trigger this event. When no ext data is specified, then any event can trigger this event. Use -1 if you want the player to trigger it as well
  42.  
  43.  
  44.  
  45. Region_Enter
  46.  
  47. Triggered when the player enters a region. This is not checked if you are already in the region. It takes a list of region ID’s as extended data.
  48.  
  49.  
  50.  
  51. Region_Leave
  52.  
  53. Triggered when the player leaves a region. It takes a list of region ID’s as extended data.


脚本:
RUBY 代码复制
  1. =begin
  2. #===============================================================================
  3.  Title: Custom Event Triggers
  4.  Author: Tsukihime
  5.  Date: Apr 9, 2013
  6. --------------------------------------------------------------------------------
  7.  ** Change log
  8.  Apr 9
  9.    - implemented parallel processing for all custom triggers
  10.  Apr 8
  11.    - added "region enter" trigger
  12.    - added "region leave" trigger
  13.  Apr 5
  14.    - added "event_to_event" trigger
  15.  Apr 4, 2013
  16.    - added "timer_expire" trigger
  17.    - Initial release
  18. --------------------------------------------------------------------------------   
  19.  ** Terms of Use
  20.  * Free to use in commercial/non-commercial projects
  21.  * No real support. The script is provided as-is
  22.  * Will do bug fixes, but no compatibility patches
  23.  * Features may be requested but no guarantees, especially if it is non-trivial
  24.  * Credits to Tsukihime in your project
  25.  * Preserve this header
  26. --------------------------------------------------------------------------------
  27.  ** Description
  28.  
  29.  This script provides additional event triggers.
  30.  The built-in event triggers include
  31.  
  32.    Action Trigger
  33.    Player Touch
  34.    Event Touch
  35.    Autorun
  36.    Parallel Process
  37.    
  38.  This script provides additional triggers.
  39.    
  40. --------------------------------------------------------------------------------
  41.  ** Installation
  42.  
  43.  Place this below Materials and above Main
  44.  
  45. --------------------------------------------------------------------------------
  46.  ** Usage
  47.  
  48.  To specify a custom page trigger, create a comment of the form
  49.  
  50.    <page trigger: trigger_name>
  51.    
  52.  Where `trigger_name` is one of the available custom event triggers.
  53.  
  54.  -- Extended trigger data --
  55.  
  56.  This script adds "extended data" to the trigger.
  57.  Certain triggers may use this data to determine how to run.
  58.  
  59.  The general format for extended trigger data is
  60.  
  61.    <page trigger: trigger_name ext_data>
  62.    
  63.  Where ext_data is any string. Check the reference to see what kinds of
  64.  extended data may be required for each trigger.
  65.  
  66.  -- Parallel Triggers --
  67.  
  68.  All event pages using custom triggers can be set as parallel processes if
  69.  you set the trigger to Parallel Process. However, the difference is that
  70.  rather than running constantly, they will begin to run only when their
  71.  activation condition is met. However, after they begin running they will
  72.  continue to run until the page is changed.
  73.  
  74. --------------------------------------------------------------------------------
  75.  ** Reference
  76.  
  77.  Here is a list of available triggers and their trigger timing. The timing
  78.  indicates when the page will be checked.
  79.  
  80.  Name: Player_Leave
  81.  Time: Triggered when the player steps off an event. Note that this means the
  82.        event must have below-character priority.
  83.   Ext: None
  84.    
  85.  Name: Timer_Expire
  86.  Time: Triggered when the game timer expires (eg: it goes to zero)
  87.   Ext: None
  88.  
  89.  Name: Event_To_Event
  90.  Time: Triggered when an event comes into contact with another event (using the
  91.        "event touch" rules)
  92.   Ext: Takes a list of event ID's. Only the specified event ID's can trigger
  93.        this event. When no ext data is specified, then any event can
  94.        trigger this event. Use -1 if you want the player to trigger it as well
  95.     
  96.  Name: Region_Enter
  97.  Time: Triggered when a player enters a particular region. Does not check if
  98.        the player is already in the region
  99.   Ext: Takes a list of region ID's
  100.  
  101.  Name: Region_Leave
  102.  Time: Triggered when a player leaves a particular region
  103.   Ext: Takes a list of region ID's
  104.    
  105. #===============================================================================
  106. =end
  107. $imported = {} if $imported.nil?
  108. $imported["TH_CustomEventTriggers"] = true
  109. #===============================================================================
  110. # ** Configuration
  111. #===============================================================================
  112. module TH
  113.   module Custom_Event_Triggers
  114.  
  115. #===============================================================================
  116. # ** Rest of script
  117. #===============================================================================
  118.     Trigger_Table = {
  119.       # default triggers
  120.       :action_trigger    => 0,
  121.       :player_touch      => 1,
  122.       :event_touch       => 2,
  123.       :autorun           => 3,
  124.       :parallel_process  => 4,
  125.  
  126.       # custom triggers
  127.       :player_leave      => 5,
  128.       :timer_expire      => 6,
  129.       :event_to_event    => 7,
  130.       :region_enter      => 8,
  131.       :region_leave      => 9
  132.     }
  133.  
  134.     Regex = /<page trigger:\s*(\w+)\s*(.*)>/i
  135.   end
  136. end
  137.  
  138. #-------------------------------------------------------------------------------
  139. #
  140. #-------------------------------------------------------------------------------
  141. module RPG
  142.   class Event::Page
  143.  
  144.     def parallel_process?
  145.       return @old_trigger == 4
  146.     end
  147.  
  148.     #---------------------------------------------------------------------------
  149.     # Load any custom triggers, if necessary
  150.     #---------------------------------------------------------------------------
  151.     alias :th_custom_event_triggers_trigger :trigger
  152.     def trigger
  153.       parse_event_triggers unless @custom_event_triggers_checked
  154.       th_custom_event_triggers_trigger
  155.     end
  156.  
  157.     #---------------------------------------------------------------------------
  158.     # Extended trigger data. Use depends on the trigger type
  159.     #---------------------------------------------------------------------------
  160.     def trigger_ext
  161.       return @trigger_ext unless @trigger_ext.nil?
  162.       parse_event_triggers unless @custom_event_triggers_checked
  163.       return @trigger_ext
  164.     end
  165.  
  166.     #---------------------------------------------------------------------------
  167.     # Returns a symbol representing the trigger type. These are the keys in
  168.     # the trigger table above
  169.     #---------------------------------------------------------------------------
  170.     def trigger_type
  171.       return @trigger_type unless @trigger_type.nil?
  172.       parse_event_triggers unless @custom_event_triggers_checked
  173.       return @trigger_type
  174.     end
  175.  
  176.     #---------------------------------------------------------------------------
  177.     # Search for a page trigger comment
  178.     #---------------------------------------------------------------------------
  179.     def parse_event_triggers
  180.       @old_trigger = @trigger
  181.       @trigger_ext = ""
  182.       @list.each do |cmd|
  183.         if cmd.code == 108 && cmd.parameters[0] =~ TH::Custom_Event_Triggers::Regex
  184.           @trigger_type = $1.downcase.to_sym
  185.           @trigger = TH::Custom_Event_Triggers::Trigger_Table[@trigger_type]
  186.           @trigger_ext = parse_extended_trigger($2)
  187.         end
  188.       end
  189.       @custom_event_triggers_checked = true
  190.     end
  191.  
  192.     #---------------------------------------------------------------------------
  193.     # Parse the extended data according to the trigger type. Different triggers
  194.     # may expect different input
  195.     #---------------------------------------------------------------------------
  196.     def parse_extended_trigger(data)
  197.       case @trigger_type
  198.       when :event_to_event, :region_enter, :region_leave
  199.         @trigger_ext = data.split.map{|val| val.to_i}
  200.       else
  201.         @trigger_ext = data
  202.       end
  203.     end
  204.   end
  205. end
  206.  
  207. #-------------------------------------------------------------------------------
  208. #
  209. #-------------------------------------------------------------------------------
  210. class Game_Timer
  211.  
  212.   #-----------------------------------------------------------------------------
  213.   # Check map events for any events that trigger on time expiry
  214.   #-----------------------------------------------------------------------------
  215.   alias :th_custom_event_triggers_on_expire :on_expire
  216.   def on_expire
  217.     th_custom_event_triggers_on_expire
  218.     $game_map.events.each_value do |event|
  219.       event.check_event_trigger_on_timer_expire([6])
  220.     end
  221.   end
  222. end
  223.  
  224. #-------------------------------------------------------------------------------
  225. #
  226. #-------------------------------------------------------------------------------
  227. class Game_Player < Game_Character
  228.  
  229.   attr_reader :last_region_id
  230.   attr_reader :last_x
  231.   attr_reader :last_y
  232.  
  233.   alias :th_custom_event_triggers_update :update
  234.   def update
  235.     store_previous_position unless moving?
  236.     th_custom_event_triggers_update
  237.   end
  238.  
  239.   alias :th_custom_event_triggers_update_nonmoving :update_nonmoving
  240.   def update_nonmoving(last_moving)
  241.     th_custom_event_triggers_update_nonmoving(last_moving)
  242.     return if $game_map.interpreter.running?
  243.     if last_moving
  244.       check_player_leave_event
  245.       if @last_region_id != self.region_id
  246.         check_player_region_enter_events
  247.         check_player_region_leave_events
  248.       end
  249.     end
  250.   end
  251.  
  252.   #-----------------------------------------------------------------------------
  253.   # Check for events with event-to-event trigger as well, in case the player
  254.   # also triggers it
  255.   #-----------------------------------------------------------------------------
  256.   alias :th_custom_event_triggers_check_event_trigger_touch :check_event_trigger_touch
  257.   def check_event_trigger_touch(x, y)
  258.     th_custom_event_triggers_check_event_trigger_touch(x, y)
  259.     return if $game_map.interpreter.running?
  260.     start_map_event(x, y, [7], true)
  261.   end
  262.  
  263.   #-----------------------------------------------------------------------------
  264.   # New. Keep track of most recent position
  265.   #-----------------------------------------------------------------------------
  266.   def store_previous_position
  267.     @last_real_x = @real_x
  268.     @last_real_y = @real_y
  269.     @last_x = @x
  270.     @last_y = @y
  271.     @last_region_id = self.region_id
  272.   end
  273.  
  274.   #-----------------------------------------------------------------------------
  275.   # New. Determines if any events at the player's previous position should be
  276.   # triggered
  277.   #-----------------------------------------------------------------------------
  278.   def check_player_leave_event
  279.     check_event_trigger_before([5])
  280.   end
  281.  
  282.   #-----------------------------------------------------------------------------
  283.   # New. Check any events in the player's previous position
  284.   #-----------------------------------------------------------------------------
  285.   def check_event_trigger_before(triggers)
  286.     start_map_event(@last_x, @last_y, triggers, false)
  287.   end
  288.  
  289.   #-----------------------------------------------------------------------------
  290.   # New. Check any events in the player's previous position
  291.   #-----------------------------------------------------------------------------
  292.   def check_player_region_enter_events
  293.     $game_map.events.each_value do |event|
  294.       event.check_event_trigger_on_region_enter
  295.     end
  296.   end
  297.  
  298.   def check_player_region_leave_events
  299.     $game_map.events.each_value do |event|
  300.       event.check_event_trigger_on_region_leave
  301.     end
  302.   end
  303. end
  304.  
  305. class Game_Event < Game_Character
  306.  
  307.   alias :th_custom_event_triggers_start :start
  308.   def start
  309.     return if empty?
  310.     p 'here'
  311.     if @page.parallel_process?
  312.       @interpreter = Game_Interpreter.new
  313.     else
  314.       th_custom_event_triggers_start
  315.     end
  316.   end
  317.  
  318.   #-----------------------------------------------------------------------------
  319.   # New. Returns the extended trigger data
  320.   #-----------------------------------------------------------------------------
  321.   def trigger_ext
  322.     @page.nil? ? [] : @page.trigger_ext
  323.   end
  324.  
  325.   #-----------------------------------------------------------------------------
  326.   # Start an event if timer expires
  327.   #-----------------------------------------------------------------------------
  328.   def check_event_trigger_on_timer_expire(triggers)
  329.     start if trigger_in?(triggers)
  330.   end
  331.  
  332.   #-----------------------------------------------------------------------------
  333.   # First check event touch with player, then event touch with event
  334.   #-----------------------------------------------------------------------------
  335.   alias :th_custom_event_triggers_check_event_trigger_touch :check_event_trigger_touch
  336.   def check_event_trigger_touch(x, y)
  337.     th_custom_event_triggers_check_event_trigger_touch(x, y)
  338.     return if $game_map.interpreter.running?
  339.     check_event_to_event_touch(x, y, [7])
  340.   end
  341.  
  342.   #-----------------------------------------------------------------------------
  343.   # Check whether events coming into contact should trigger
  344.   #-----------------------------------------------------------------------------
  345.   def check_event_to_event_touch(x, y, triggers)
  346.     $game_map.events_xy(x, y).each do |event|
  347.       next unless event.trigger_in?(triggers)
  348.       event.start if event.trigger_ext.empty? || event.trigger_ext.include?(@id)
  349.     end
  350.   end
  351.  
  352.   #-----------------------------------------------------------------------------
  353.   # Check whether events should run due to player entering a region
  354.   #-----------------------------------------------------------------------------
  355.   def check_event_trigger_on_region_enter
  356.     start if @trigger == 8 && trigger_ext.include?($game_player.region_id)
  357.   end
  358.  
  359.   #-----------------------------------------------------------------------------
  360.   # Check whether events should run due to player leaving a region
  361.   #-----------------------------------------------------------------------------
  362.   def check_event_trigger_on_region_leave
  363.     start if @trigger == 9 && trigger_ext.include?($game_player.last_region_id)
  364.   end
  365. end

点评

谢谢。。不过英文说明研究了半天。。。。。。  发表于 2013-6-11 10:19
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
137 小时
注册时间
2012-8-27
帖子
109
5
 楼主| 发表于 2013-6-11 10:40:21 | 只看该作者
喵呜喵5 发表于 2013-6-10 15:11
用法说明:
To specify a custom page trigger, create a comment of the form

大神啊,某无赖想要一个范例=、=。。。研究很久不明白怎么用A!。。。


回复 支持 反对

使用道具 举报

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
21626
在线时间
9413 小时
注册时间
2012-6-19
帖子
7118

开拓者短篇九导演组冠军

6
发表于 2013-6-11 12:03:12 | 只看该作者
liminglun 发表于 2013-6-11 10:40
大神啊,某无赖想要一个范例=、=。。。研究很久不明白怎么用A!。。。

Data.zip (211.39 KB, 下载次数: 199)

新建一个工程,替换掉那个工程的data文件夹

点评

感谢您耐心的回答! 认可答案  发表于 2013-6-11 12:30

评分

参与人数 1梦石 +1 收起 理由
Sion + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-15 20:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表