Project1
标题:
有没有装备武器或者防具时自动触发公共事件脚本?
[打印本页]
作者:
a965645462
时间:
2017-12-23 18:37
标题:
有没有装备武器或者防具时自动触发公共事件脚本?
本帖最后由 a965645462 于 2017-12-23 18:39 编辑
有没有装备武器或者防具时自动触发公共事件脚本?(我知道可以用事件可以做,但是可能做的比较多)
作者:
韩飞广
时间:
2018-1-12 18:17
提示:
作者被禁止或删除 内容自动屏蔽
作者:
Nil2018
时间:
2018-1-13 13:38
=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
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1