Project1
标题:
如何在商店添加要出售全部的物品、武器、防具?
[打印本页]
作者:
jiangjie81
时间:
2013-3-3 15:34
标题:
如何在商店添加要出售全部的物品、武器、防具?
本帖最后由 jiangjie81 于 2013-3-10 18:44 编辑
求教各位大大,如何使用脚本代码,在商店里 直接添加要出售全部的物品、武器、防具?
一个一个的设定,实在是悲催!
=========
参见4楼的办法。有效。
作者:
yangjunyin2002
时间:
2013-3-3 15:43
目前,我只有获得全部物品的代码
for i in 0...$data_items.size
$game_party.gain_item($data_items[i],50)
end
for i in 0...$data_weapons.size
$game_party.gain_item($data_weapons[i],50)
end
for i in 0...$data_armors.size
$game_party.gain_item($data_armors[i],50)
end
复制代码
那个50可以改。就是所有物品、武器、防具给你的数量。
作者:
vince3725
时间:
2013-3-3 20:47
# ————————————————————————————————————
# 本脚本来自www.66rpg.com,转载请保留此信息
# ————————————————————————————————————
#==============================================================================
# ■ Scene_Warehouse
#------------------------------------------------------------------------------
# 商店画面 : 窗口管理
#==============================================================================
class Scene_Warehouse < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 开始处理 :生成窗口
#--------------------------------------------------------------------------
def start
super
create_help_window
create_command_window
create_item_window
create_number_window
end
#--------------------------------------------------------------------------
# ● 生成指令窗口
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_WarehouseCommand.new(Graphics.width, @purchase_only)
@command_window.viewport = @viewport
@command_window.y = @help_window.height
@command_window.set_handler(:save, method(:command_save))
@command_window.set_handler(:get, method(:command_get))
@command_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ● 生成物品窗口
#--------------------------------------------------------------------------
def create_item_window
y = @command_window.y + @command_window.height
height = Graphics.height - @command_window.y - @command_window.height
width = @help_window.width
@item_window = Window_WarehouseItem.new(0, y, width, height)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_action(0)
@item_window.set_handler(:ok, method(:on_ok))
@item_window.set_handler(:cancel, method(:on_cancel))
end
#--------------------------------------------------------------------------
# ● 生成输入窗口
#--------------------------------------------------------------------------
def create_number_window
@number_window = Window_WarehouseNumber.new((Graphics.width - 304)/2,(Graphics.height - 72)/2,72)
@number_window.viewport = @viewport
@number_window.hide
@number_window.set_handler(:ok, method(:on_num_ok))
@number_window.set_handler(:cancel, method(:on_num_cancel))
end
#==============================================================================
# ■仓库画面 : 主指令管理
#==============================================================================
#--------------------------------------------------------------------------
# ● 主界面 :存入
#--------------------------------------------------------------------------
def command_save
@item_window.set_action(1)
@command_window.deactivate # 冻结指令窗口
@item_window.activate # 激活物品窗口
@item_window.index = 0
@item_window.refresh
@item_window.update_help
end
#--------------------------------------------------------------------------
# ● 主界面 :取出
#--------------------------------------------------------------------------
def command_get
@item_window.set_action(2)
@command_window.deactivate # 冻结指令窗口
@item_window.activate # 激活物品窗口
@item_window.index = 0
@item_window.refresh
@item_window.update_help
end
#==============================================================================
# ■仓库画面 : 指令管理
#==============================================================================
#--------------------------------------------------------------------------
# ● 命令 :确定
#--------------------------------------------------------------------------
def on_ok
item = @item_window.get_item_now
if @item_window.enable?(item) || @item_window.action == 1
case @item_window.action
when 1
@number_window.save_item
@number_window.set(item,$game_party.item_number(item))
when 2
@number_window.save_item(false)
i = $game_party.max_item_number(item) - $game_party.item_number(item)
if i < $game_party.ware_num(item)
@number_window.set(item, i)
else
@number_window.set(item,$game_party.ware_num(item))
end
end
@item_window.deactivate
@number_window.show
@number_window.activate
else
Sound.play_buzzer
@help_window.set_text("背包内装不下了~")
@item_window.activate
end
end
#--------------------------------------------------------------------------
# ● 命令 :取消
#--------------------------------------------------------------------------
def on_cancel
@item_window.deactivate
@item_window.set_action(0)
@item_window.index = -1
@item_window.contents.clear
@command_window.activate
@help_window.clear
end
#==============================================================================
# ■仓库画面 : 数值输入指令管理
#==============================================================================
#--------------------------------------------------------------------------
# ● 命令 :存入确定
#--------------------------------------------------------------------------
def on_num_ok
@number_window.hide
@number_window.deactivate
case @number_window.action
when true
$game_party.ware_add(@number_window.get_item, @number_window.get_num)
$game_party.lose_item(@number_window.get_item, @number_window.get_num)
when false
$game_party.ware_del(@number_window.get_item, @number_window.get_num)
$game_party.gain_item(@number_window.get_item, @number_window.get_num)
end
# 更新画面
@item_window.refresh
if @number_window.get_num == @number_window.get_max && @item_window.index != 0
@item_window.index -= 1
end
if @item_window.get_data == []
@command_window.activate
@item_window.deactivate
@item_window.index = -1
@help_window.clear
else
@item_window.activate
end
@command_window.refresh
@number_window.refresh
end
#--------------------------------------------------------------------------
# ● 命令 :存入取消
#--------------------------------------------------------------------------
def on_num_cancel
@number_window.refresh
@number_window.hide
@number_window.deactivate
@item_window.activate
end
# 定义结束
end
复制代码
#encoding:utf-8
# ————————————————————————————————————
# 本脚本来自www.66rpg.com,转载请保留此信息
# ————————————————————————————————————
#==============================================================================
# ■ Window_WarehouseNumber
#------------------------------------------------------------------------------
# 商店画面中,输入“物品买入/卖出数量”的窗口。
#==============================================================================
class Window_WarehouseNumber < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y, height)
super(x, y, window_width, height)
@item = nil
[url=home.php?mod=space&uid=25307]@Max[/url] = 1
[url=home.php?mod=space&uid=27178]@Number[/url] = 1
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return 304
end
#--------------------------------------------------------------------------
# ● 设置物品、最大值
#--------------------------------------------------------------------------
def set(item, max)
@item = item
@max = max
@number = 1
refresh
end
#--------------------------------------------------------------------------
# ● 设置状态
#--------------------------------------------------------------------------
def save_item(action = true)
@action = action
end
#--------------------------------------------------------------------------
# ● 取得状态
#--------------------------------------------------------------------------
def action
return @action
end
#--------------------------------------------------------------------------
# ● 获得数值
#--------------------------------------------------------------------------
def get_num
return @number
end
#--------------------------------------------------------------------------
# ● 获得物品
#--------------------------------------------------------------------------
def get_item
return @item
end
#--------------------------------------------------------------------------
# ● 获得最大值
#--------------------------------------------------------------------------
def get_max
return @max
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_item_name(@item, 0, item_y)
draw_number
end
#--------------------------------------------------------------------------
# ● 绘制数量
#--------------------------------------------------------------------------
def draw_number
change_color(normal_color)
draw_text(cursor_x - 28, item_y, 22, line_height, "×")
draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
end
#--------------------------------------------------------------------------
# ● 显示物品名称行的 Y 坐标
#--------------------------------------------------------------------------
def item_y
return 8
end
#--------------------------------------------------------------------------
# ● 获取光标的宽度
#--------------------------------------------------------------------------
def cursor_width
figures * 10 + 12
end
#--------------------------------------------------------------------------
# ● 获取光标的 X 坐标
#--------------------------------------------------------------------------
def cursor_x
contents_width - cursor_width - 4
end
#--------------------------------------------------------------------------
# ● 获取数量显示的最大列数
#--------------------------------------------------------------------------
def figures
return 2
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
if active
last_number = @number
update_number
if @number != last_number
Sound.play_cursor
refresh
end
end
end
#--------------------------------------------------------------------------
# ● 更新数量
#--------------------------------------------------------------------------
def update_number
change_number(1) if Input.repeat?(:RIGHT)
change_number(-1) if Input.repeat?(:LEFT)
change_number(10) if Input.repeat?(:UP)
change_number(-10) if Input.repeat?(:DOWN)
end
#--------------------------------------------------------------------------
# ● 更改数量
#--------------------------------------------------------------------------
def change_number(amount)
@number = [[@number + amount, @max].min, 1].max
end
#--------------------------------------------------------------------------
# ● 更新光标
#--------------------------------------------------------------------------
def update_cursor
cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
end
end
复制代码
作者:
Sion
时间:
2013-3-4 19:55
本帖最后由 Sion 于 2013-3-4 20:03 编辑
goods = []
$data_items.compact.each {|item| goods.push([0, item.id, 0])}
$data_weapons.compact.each {|weapon| goods.push([1, weapon.id, 0])}
$data_armors.compact.each {|armor| goods.push([2, armor.id, 0])}
SceneManager.call(Scene_Shop)
SceneManager.scene.prepare(goods, false)#设为true禁止出售
复制代码
这个代码可以插入到事件的脚本中使用,插入默认的脚本框中因为代码太长会自动换行,导致运行的时候报错。你可能需要改一改脚本输入框;或者把它写成一个方法来调用。
作者:
jiangjie81
时间:
2013-3-6 11:46
用VA新工程测试了一下,真的没有药品出售。
作者:
紫苍焰
时间:
2013-3-6 16:43
本帖最后由 紫苍焰 于 2013-3-6 16:46 编辑
……
嗯,确认无解。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1