Project1

标题: 请问一下,如何让玩家穿上某件装备的时候,切换某个行... [打印本页]

作者: hq1107    时间: 2023-9-20 13:40
标题: 请问一下,如何让玩家穿上某件装备的时候,切换某个行...
=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
本来我使用的是这个脚本来切换行走图。但是这个脚本与我使用的另一个脚本冲突。

作者: AshhsA    时间: 2023-9-20 16:22
请具体说明另一个脚本是什么……

作者: suixinsua    时间: 2023-9-29 19:49
用alias 取个别名试试!




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1