赞 | 3 |
VIP | 0 |
好人卡 | 0 |
积分 | 2 |
经验 | 45777 |
最后登录 | 2018-5-25 |
在线时间 | 248 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 199
- 在线时间
- 248 小时
- 注册时间
- 2012-4-29
- 帖子
- 386
|
=begin
================================================
道具提示系统 版本 1.01 By 804173948 QQ:同上
================================================
修正BUG:
1.读取游戏后获取道具错误
更新:
1.添加音效(本人觉得很难听)
使用方法:
在事件-脚本里输入
1、获得/失去物品
获得:
get_item($data_items[物品id],数量)
失去:
lost_item($data_items[物品id],数量)
例如:
get_item($data_items[10],4) 获得10号物品 4个
lost_item($data_items[1],3) 丢失1号物品 3个
2、获得/失去武器
获得:
get_item($data_weapons[物品id],数量)
失去:
lost_item($data_weapons[物品id],数量,是否包括装备)
是否包括装备:是则 True 否则 false 或不写 下同
3、获得/失去防具
获得:
get_item($data_armors[物品id],数量)
失去:
lost_item($data_armors[物品id],数量,是否包括装备)
注意:最后要加一句 show_window 否则不显示提示窗口
详情看范例……
有疑问或BUG之类的 欢迎提出
=end
class Game_Interpreter
alias old_initialize initialize
def initialize(depth = 0)
old_initialize
@get_item_var =[]
@get_amount =[]
end
def show_window
Audio.se_play("Audio/SE/Shop",80,100)
SceneManager.call(Scene_Get_Item)
SceneManager.scene.show_window(@get_item_var,@get_amount)
@get_item_var =[]
@get_amount =[]
end
def get_item(item,amount)
amount = 99 if amount > 99
@get_item_var = [] if @get_item_var == nil
@get_amount = [] if @get_amount == nil
@get_item_var.push(item)
@get_amount.push(amount)
$game_party.gain_item(item,amount)
end
def lost_item(item,amount,include_equip = false)
amount = 99 if amount > 99
@get_item_var = [] if @get_item_var == nil
@get_amount = [] if @get_amount == nil
@get_item_var.push(item)
@get_amount.push(-amount)
$game_party.gain_item(item,-amount,include_equip)
end
end
class Scene_Get_Item < Scene_MenuBase
def start
super
@get_item_var = []
@get_amount = []
end
def show_window(get_item_var,get_amount)
@get_item_var = get_item_var
@get_amount = get_amount
create_show_get_window
create_category_window
end
def create_show_get_window
@show_get_window = Window_Show_GetItem.new(120,88,300,200,@get_item_var,@get_amount) #窗口位置
@show_get_window.set_handler(:ok, method(:return_scene))
@show_get_window.set_handler(:cancel, method(:on_item_cancel))
end
def create_category_window
@show_getItem_category = Window_GetItem_Category.new(120,40,300,48)
@show_getItem_category.item_window = @show_get_window
@show_getItem_category.set_handler(:ok, method(:on_category_ok))
@show_getItem_category.set_handler(:cancel, method(:return_scene))
end
def on_category_ok
@show_get_window.activate
end
def on_item_cancel
@show_getItem_category.activate
end
end
class Window_GetItem_Category < Window_HorzCommand
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :item_window
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x,y,width,height)
super(x, y)
self.width = width
self.height = height
end
#--------------------------------------------------------------------------
# ● 窗口宽度
#--------------------------------------------------------------------------
def window_width
return 300
end
#--------------------------------------------------------------------------
# ● 获取列数
#--------------------------------------------------------------------------
def col_max
return 2
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
@item_window.category = current_symbol if @item_window
end
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
add_command(" 获得物品", :get)
add_command(" 失去物品", :lost)
end
#--------------------------------------------------------------------------
# ● 设置物品窗口
#--------------------------------------------------------------------------
def item_window=(item_window)
@item_window = item_window
update
end
end
class Window_Show_GetItem < Window_ItemList
def initialize(x, y, width, height,data,amount)
super(x, y, width, height)
@category = :get
@data_save = data
@amount_save = amount
refresh
end
def col_max
return 1
end
def spacing
return 32
end
def include?(index)
if index
case @category
when :get
if index >= 0
true
else
false
end
when :lost
if index < 0
true
else
false
end
else
false
end
end
end
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y)
draw_item_number(rect, index)
end
end
def draw_item_number(rect, item)
if @amount[item] < 0
s1 = -@amount[item]
else
s1 = @amount[item]
end
draw_text(rect, sprintf(":%2d", s1), 2)
end
#--------------------------------------------------------------------------
# ● 查询此物品是否可用
#--------------------------------------------------------------------------
def enable?(item)
return true
end
#--------------------------------------------------------------------------
# ● 生成物品列表
#--------------------------------------------------------------------------
def make_item_list
@data = Array.new(@data_save)
@amount = Array.new(@amount_save)
for i in 0 ... @data.size
@data[i] = nil if include?(@amount_save[i]) == false
@amount[i] = nil if include?(@amount_save[i]) == false
end
@data.delete(nil)
@amount.delete(nil)
end
end
最后一个^^^^^^^^^^^^^^^ |
|