| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 9 |
| 经验 | |
| 最后登录 | 2024-6-27 |
| 在线时间 | 86 小时 |
- 梦石
- 0
- 星屑
- 917
- 在线时间
- 86 小时
- 注册时间
- 2022-9-13
- 回帖
- 13
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
如题,在下找遍了所有会用的物品得失提示脚本,都不能提示通过gain_item得到的物品
通过搜索找到了一个已解决的帖子,说是通过仿写command_126就可以解决这个问题,原贴脚本如下
[pre lang="ruby"]#--------------------------------------------------------------------------
# ● 得失物品提示
#--------------------------------------------------------------------------
module Taroxd end
module Taroxd::GainMessage
# --- 设置 ---
# 信息格式
# 转义符:
# \name 代表物品名称 / 金钱单位
# \value 代表获得 / 失去的物品 / 金钱数量
# \icon 绘制物品 / 金钱的图标
# \action 代表“获得”或者“失去”。可在下面修改。
# 支持“显示文字”中的所有转义符。
ITEM_FORMAT = '\action了 \name * \value'
GOLD_FORMAT = '\action了 \value \name'
ACTION_GAIN = '获得'
ACTION_LOSE = '失去'
GOLD_ICON_INDEX = 361 # 金钱图标的索引
BACKGROUND = 1 # 窗口背景(0/1/2)
POSITION = 1 # 显示位置(0/1/2)
# 音效(不需要的话可以直接删去对应的行)
GAIN_GOLD_SE = 'Shop' # 获得金钱
LOSE_GOLD_SE = 'Blow2' # 失去金钱
GAIN_ITEM_SE = 'Item1' # 获得物品
LOSE_ITEM_SE = LOSE_GOLD_SE # 失去物品
# 设置功能是否启用。
# true:启用。
# false:不启用。
# $game_switches[开关ID]: 对应开关打开时。
def self.enabled?
true
end
# --- 设置结束 ---
# 显示提示信息。获得金钱时将 item 设为 nil。
def self.show(value, item)
@item = item
@value = value
$game_message.background = BACKGROUND
$game_message.position = POSITION
$game_message.add(message)
play_se
end
private
# 获取提示的消息
def self.message
if @item
format = ITEM_FORMAT
icon_index = @item.icon_index
name = @item.name
else
format = GOLD_FORMAT
icon_index = GOLD_ICON_INDEX
name = Vocab.currency_unit
end
# gsub: 以替换前的字符串为键,替换后内容为值的 hash。可以自由设置。
gsub = {
'\action' => @value > 0 ? ACTION_GAIN : ACTION_LOSE,
'\value' => @value.abs,
'\icon' => "\\I[#{icon_index}]",
'\name' => name
}
format.gsub(Regexp.union(gsub.keys), gsub)
end
def self.play_se
const = :"#{@value > 0 ? 'GAIN' : 'LOSE'}_#{@item ? 'ITEM' : 'GOLD'}_SE"
se = const_defined?(const) && const_get(const)
Audio.se_play('Audio/SE/' + se) if se
end
end
class Game_Party < Game_Unit
# 获取道具总数(包括装备)
def item_number_with_equip(item)
members.inject(item_number(item)) { |a, e| a + e.equips.count(item) }
end
end
class Game_Interpreter
GainMessage = Taroxd::GainMessage
# 别名:不显示提示窗口的事件指令
alias_method :gain_gold_without_message, :command_125
alias_method :gain_item_without_message, :command_126
alias_method :gain_weapon_without_message, :command_127
alias_method :gain_armor_without_message, :command_128
# 显示提示窗口
def show_gain_message(value, item = nil)
return if value.zero?
GainMessage.show(value, item)
wait_for_message
end
# 增减持有金钱
def command_125
return gain_gold_without_message unless GainMessage.enabled?
last_gold = $game_party.gold
gain_gold_without_message
show_gain_message($game_party.gold - last_gold)
end
# 增减物品
def command_126
return gain_item_without_message unless GainMessage.enabled?
item = $data_items[@params[0]]
last_num = $game_party.item_number(item)
gain_item_without_message
show_gain_message($game_party.item_number(item) - last_num, item)
end
# 增减武器
def command_127
return gain_weapon_without_message unless GainMessage.enabled?
item = $data_weapons[@params[0]]
last_num = $game_party.item_number_with_equip(item)
gain_weapon_without_message
value = $game_party.item_number_with_equip(item) - last_num
show_gain_message(value, item)
end
# 增减护甲
def command_128
return gain_armor_without_message unless GainMessage.enabled?
item = $data_armors[@params[0]]
last_num = $game_party.item_number_with_equip(item)
gain_armor_without_message
value = $game_party.item_number_with_equip(item) - last_num
show_gain_message(value, item)
end
end[/pre]
但在下是个刚接触RM的小白,脚本啥的完全不会写
原贴又是15年的,那么久的贴实在不好意思挖坟……
所以就自己发了个帖子请教各方的大佬们。
萌新也没啥拿得出手的东西,还请大佬们不吝赐教
这边再贴另外一个物品得失的脚本,感觉视觉效果上会比上面的这个好一些(?)
不过这个脚本据说会有大量获得只显示最后一个的问题,在下还没有这样使用所以不太清楚。
[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Event Window v1.01
# -- Last Updated: 2011.12.27
# -- Level: Easy, Normal
# -- Requires: n/a
#
#==============================================================================
$imported = {} if $imported.nil?
$imported["YEA-EventWindow"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.27 - Bug Fixed: Used the wrong script to hide event window.
# 2011.12.26 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# The Event Window is a new feature added through this script that appears in
# the lower left corner of the screen. Whenever the player gains or loses gold
# and items, the Event Window is updated to show the changes. In addition to
# showing item gains and losses, you may even add in your own text to update
# through a Script Call.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Script Calls - These commands are used with script calls.
# -----------------------------------------------------------------------------
# event_window_add_text(string)
# This inserts "string" text into the Event Window. Use \n to designate
# linebreaks in the string. If you wish to use text codes, write them in the
# strings as \\n[2] or \\c[3] to make them work properly.
#
# event_window_clear_text
# This causes the Event Window to clear all of the stored text. You can choose
# whether or not to clear the stored Event Window text every time the player
# enters a new map.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
module YEA
module EVENT_WINDOW
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Event Window Switch -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# This is the switch used for hiding the event window. When this switch is
# ON, the event window will be hidden from view. If it is OFF, the event
# window will maintain normal visibility.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HIDE_SWITCH = 24 # 如果开关打开,不会出现事件窗口。
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - General Event Window Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# This section adjusts the event window. These settings adjust the overall
# appearance of the event window from the width to the number of lines
# shown and the window fade rate.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
NEW_MAP_CLEAR = true # Clear text when entering a new map?
WINDOW_WIDTH = 480 # 事件窗口的宽度.
VISIBLE_TIME = 180 # 帧窗口是褪色之前可见。
MAX_LINES = 8 # 最大行数显示。
WINDOW_FADE = 8 # 褪色率的事件窗口。
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Event Window Text Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# This section adjusts the text that appears in the event window. The text
# that appears when an item is found and the text that appears when an item
# is lost will always appear before the item found. If there is more than
# one item found, the amount text will be added on after followed by the
# closing text. When gold is found, no icons will be used.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HEADER_TEXT = "" # Text that's always used at the head.
FOUND_TEXT = "\ec[6]获得\ec[0] " # Text used when an item is found.
LOST_TEXT = "\ec[4]失去\ec[0] " # Text used when an item is lost.
AMOUNT_TEXT = "×%s" # Text used to display an amount.
CLOSER_TEXT = "" # Text that's always used at the end.
end # EVENT_WINDOW
end # YEA
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
#==============================================================================
# ■ Switch
#==============================================================================
module Switch
#--------------------------------------------------------------------------
# self.hide_event_window
#--------------------------------------------------------------------------
def self.hide_event_window
return false if YEA::EVENT_WINDOW::HIDE_SWITCH <= 0
return $game_switches[YEA::EVENT_WINDOW::HIDE_SWITCH]
end
end # Switch
#==============================================================================
# ■ Numeric
#==============================================================================
class Numeric
#--------------------------------------------------------------------------
# new method: group_digits
#--------------------------------------------------------------------------
unless $imported["YEA-CoreEngine"]
def group; return self.to_s; end
end # $imported["YEA-CoreEngine"]
end # Numeric
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :event_window_data
#--------------------------------------------------------------------------
# new method: add_event_window_data
#--------------------------------------------------------------------------
def add_event_window_data(text)
@event_window_data = [] if @event_window_data.nil?
return if text == ""
@event_window_data.push(text)
end
#--------------------------------------------------------------------------
# new method: clear_event_window_data
#--------------------------------------------------------------------------
def clear_event_window_data
@event_window_data = []
end
end # Game_Temp
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# alias method: command_125
#--------------------------------------------------------------------------
alias game_interpreter_command_125_ew command_125
def command_125
game_interpreter_command_125_ew
value = operate_value(@params[0], @params[1], @params[2])
$game_temp.clear_event_window_data
event_window_make_gold_text(value)
end
#--------------------------------------------------------------------------
# alias method: command_126
#--------------------------------------------------------------------------
alias game_interpreter_command_126_ew command_126
def command_126
game_interpreter_command_126_ew
value = operate_value(@params[1], @params[2], @params[3])
$game_temp.clear_event_window_data
event_window_make_item_text($data_items[@params[0]], value)
end
#--------------------------------------------------------------------------
# alias method: command_127
#--------------------------------------------------------------------------
alias game_interpreter_command_127_ew command_127
def command_127
game_interpreter_command_127_ew
value = operate_value(@params[1], @params[2], @params[3])
$game_temp.clear_event_window_data
event_window_make_item_text($data_weapons[@params[0]], value)
end
#--------------------------------------------------------------------------
# alias method: command_128
#--------------------------------------------------------------------------
alias game_interpreter_command_128_ew command_128
def command_128
game_interpreter_command_128_ew
value = operate_value(@params[1], @params[2], @params[3])
event_window_make_item_text($data_armors[@params[0]], value)
end
#--------------------------------------------------------------------------
# new method: event_window_make_gold_text
#--------------------------------------------------------------------------
def event_window_make_gold_text(value)
return unless SceneManager.scene_is?(Scene_Map)
return if Switch.hide_event_window
if value > 0
text = YEA::EVENT_WINDOW::FOUND_TEXT
elsif value < 0
text = YEA::EVENT_WINDOW::LOST_TEXT
else; return
end
text += sprintf("%s%s", value.abs.group, Vocab::currency_unit)
event_window_add_text(text)
end
#--------------------------------------------------------------------------
# new method: event_window_make_item_text
#--------------------------------------------------------------------------
def event_window_make_item_text(item, value)
return unless SceneManager.scene_is?(Scene_Map)
return if Switch.hide_event_window
if value > 0
text = YEA::EVENT_WINDOW::FOUND_TEXT
elsif value < 0
text = YEA::EVENT_WINDOW::LOST_TEXT
else; return
end
text += sprintf("\ei[%d]%s", item.icon_index, item.name)
if value.abs > 1
fmt = YEA::EVENT_WINDOW::AMOUNT_TEXT
text += sprintf(fmt, value.abs.group)
end
event_window_add_text(text)
end
#--------------------------------------------------------------------------
# new method: event_window_add_text
#--------------------------------------------------------------------------
def event_window_add_text(text)
return unless SceneManager.scene_is?(Scene_Map)
return if Switch.hide_event_window
text = YEA::EVENT_WINDOW::HEADER_TEXT + text
text += YEA::EVENT_WINDOW::CLOSER_TEXT
SceneManager.scene.event_window_add_text(text)
end
#--------------------------------------------------------------------------
# new method: event_window_clear_text
#--------------------------------------------------------------------------
def event_window_clear_text
$game_temp.clear_event_window_data
end
end # Game_Interpreter
#==============================================================================
# ■ Window_EventWindow
#==============================================================================
class Window_EventWindow < Window_Selectable
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
dw = YEA::EVENT_WINDOW::WINDOW_WIDTH
super(0, 0, dw, fitting_height(YEA::EVENT_WINDOW::MAX_LINES))
self.x -= 12
self.opacity = 0
self.contents_opacity = 0
@visible_counter = 0
modify_skin
deactivate
end
#--------------------------------------------------------------------------
# modify_skin
#--------------------------------------------------------------------------
def modify_skin
dup_skin = self.windowskin.dup
dup_skin.clear_rect(64, 0, 64, 64)
dup_skin.clear_rect(64, 64, 32, 32)
self.windowskin = dup_skin
end
#--------------------------------------------------------------------------
# item_max
#--------------------------------------------------------------------------
def item_max
return $game_temp.event_window_data ? $game_temp.event_window_data.size : 1
end
#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
self.visible = show_window?
update_visible_counter
update_contents_opacity
end
#--------------------------------------------------------------------------
# show_window?
#--------------------------------------------------------------------------
def show_window?
return false if $game_message.visible
return true
end
#--------------------------------------------------------------------------
# update_visible_counter
#--------------------------------------------------------------------------
def update_visible_counter
return if @visible_counter <= 0
@visible_counter -= 1
end
#--------------------------------------------------------------------------
# update_contents_opacity
#--------------------------------------------------------------------------
def update_contents_opacity
return if @visible_counter > 0
return if self.contents_opacity <= 0
self.contents_opacity -= YEA::EVENT_WINDOW::WINDOW_FADE
end
#--------------------------------------------------------------------------
# instant_hide
#--------------------------------------------------------------------------
def instant_hide
@visible_counter = 0
self.contents_opacity = 0
end
#--------------------------------------------------------------------------
# add_text
#--------------------------------------------------------------------------
def add_text(text)
$game_temp.add_event_window_data(text)
refresh
self.contents_opacity = 255
@visible_counter = YEA::EVENT_WINDOW::VISIBLE_TIME
change_y_position
select(item_max - 1)
end
#--------------------------------------------------------------------------
# change_y_position 这里的数字可以改变显示条的位置,数字越小越低。
#--------------------------------------------------------------------------
def change_y_position
maximum = [item_max, YEA::EVENT_WINDOW::MAX_LINES].min
self.y = Graphics.height - fitting_height(maximum) - 180
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
$game_temp.clear_event_window_data if $game_temp.event_window_data.nil?
item = $game_temp.event_window_data[index]
return if item.nil?
rect = item_rect(index)
draw_background(rect)
rect.x += 4
rect.width -= 8
draw_text_ex(rect.x, rect.y, item)
end
#--------------------------------------------------------------------------
# draw_background
#--------------------------------------------------------------------------
def draw_background(rect)
back_colour1 = Color.new(72, 209,204, 62)
back_colour2 = Color.new(0, 0, 0, 0)
contents.gradient_fill_rect(rect, back_colour1, back_colour2)
end
end # Window_EventWindow
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# alias method: create_all_windows
#--------------------------------------------------------------------------
alias scene_map_create_all_windows_event_window create_all_windows
def create_all_windows
scene_map_create_all_windows_event_window
create_event_window
end
#--------------------------------------------------------------------------
# new method: create_event_window
#--------------------------------------------------------------------------
def create_event_window
@event_window = Window_EventWindow.new
end
#--------------------------------------------------------------------------
# new method: event_window_add_text
#--------------------------------------------------------------------------
def event_window_add_text(text)
Sound.play_shop
@event_window.add_text(text)
end
#--------------------------------------------------------------------------
# alias method: post_transfer
#--------------------------------------------------------------------------
alias scene_map_post_transfer_ew post_transfer
def post_transfer
$game_temp.clear_event_window_data if YEA::EVENT_WINDOW::NEW_MAP_CLEAR
@event_window.instant_hide
scene_map_post_transfer_ew
end
end # Scene_Map
#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]
(碎碎念)
后面这个脚本因为有贴出处,所以在下还去发布组网页找了半天,结果发布组现在好像只有MV和MZ的插件了,va的插件完全找不到……
如果有大佬直接拉到最下面看的话还请返回上面_(:₃」∠)_,因为这边只是在下的废话而已。
话说va是不是时代的眼泪了啊 一搜帖子全都是十年甚至九年以前的东西了 |
|