赞 | 274 |
VIP | 0 |
好人卡 | 0 |
积分 | 158 |
经验 | 515 |
最后登录 | 2024-11-8 |
在线时间 | 2106 小时 |
Lv4.逐梦者
- 梦石
- 1
- 星屑
- 14790
- 在线时间
- 2106 小时
- 注册时间
- 2017-9-28
- 帖子
- 662
|
- =begin
- #===============================================================================
- ** 装备事件
- Author: Hime
- Date: Feb 26, 2013
- --------------------------------------------------------------------------------
- ** Change log
- Feb 26, 2014
- - re-ordered event execution .dequip event is executed before equip event.
- Jun 7, 2013
- - updated common event queue for backwards compatibility. common event ID
- returns the first element in the queue list
- Jun 6, 2013
- - equip events do not automatically run in scenes now. You will need
- the Scene Interpreter script
- May 20, 2013
- - common events now queue up and will be run automatically
- Feb 15, 2013
- - added support for dequipping items
- Sep 21
- - fixed bug where equipping nothing threw NoMethod error
- Sep 6, 2012
- - initial release
- --------------------------------------------------------------------------------
- ** Description
-
- 在武器/护甲装备/解除时可以触发一个公共事件.
- --------------------------------------------------------------------------------
- ** Installation
-
- Place this below Materials and above Main.
-
- --------------------------------------------------------------------------------
- ** Usage
-
- 武器/护甲备注
-
- <装备公共事件: x>
- <解除公共事件: x>
-
- x为公共事件ID.
- #===============================================================================
- =end
- $imported = {} if $imported.nil?
- $imported["Tsuki_EquipEvents"] = true
- #===============================================================================
- # ** Configuration
- #===============================================================================
- module Tsuki
- module Equip_Events
-
- Equip_Regex = /<装备公共事件:\s*(\d+)>/i
- Dequip_Regex = /<解除公共事件:\s*(\d+)>/i
- end
- end
- #===============================================================================
- # ** Rest of script
- #===============================================================================
- module RPG
- class EquipItem
-
- def equip_event_id
- return @equip_event_id unless @equip_event_id.nil?
- res = Tsuki::Equip_Events::Equip_Regex.match(self.note)
- return @equip_event_id = res ? res[1].to_i : 0
- end
-
- def dequip_event_id
- return @dequip_event_id unless @dequip_event_id.nil?
- res = Tsuki::Equip_Events::Dequip_Regex.match(self.note)
- return @dequip_event_id = res ? res[1].to_i : 0
- end
- end
- end
- class Game_Actor
-
- alias :th_equip_events_change_equip :change_equip
- def change_equip(slot_id, item)
- old_item = @equips[slot_id].object
- th_equip_events_change_equip(slot_id, item)
- if @equips[slot_id].object == item
- $game_temp.reserve_common_event(old_item.dequip_event_id) if old_item
- $game_temp.reserve_common_event(item.equip_event_id) if item
- end
- end
- end
- unless $imported["TH_CommonEventQueue"]
- class Game_Temp
- attr_reader :reserved_common_events
- alias :th_common_event_queue_init :initialize
- def initialize
- th_common_event_queue_init
- @reserved_common_events = []
- end
- # re-write
- def reserve_common_event(common_event_id)
- @reserved_common_events.push(common_event_id) if common_event_id > 0
- end
-
- def common_event_id
- @reserved_common_events[0]
- end
- # Note that I don't actually need to clear it out. It's done
- # by the queue.
- # true if list is not empty
- def common_event_reserved?
- !@reserved_common_events.empty?
- end
- # Grab the first one, first-in-first-out order
- def reserved_common_event
- $data_common_events[@reserved_common_events.shift]
- end
- end
- end
复制代码 |
|