赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 10 |
经验 | 0 |
最后登录 | 2024-7-3 |
在线时间 | 84 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 995
- 在线时间
- 84 小时
- 注册时间
- 2023-12-26
- 帖子
- 122
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 djs789783 于 2024-2-15 21:53 编辑
请教ACE大佬帮我看下重装机兵里面的贩售机脚本哪里没好
附工程案例。
,帮我弄下,发给我哈,谢谢你,新年快乐。
重装机兵里面的贩售机就是,固定可以买几样东西,还带抽奖。。。请问有没有类似这样的就是固定买几个东西,还能带抽奖的脚本?然后脚本上可以随便自己添加物品。
大佬帮我工程弄下发给我吗谢谢,或者发其它类似这样的工程案例让我学习学习。
==========================
#设置[0,3,0,500][分类,id,价格,]
module SH
GBSE = "Cursor2" #光标转动时播放的SE
WINME = "Victory1" #中奖时播放的ME
GBZDSD = 10 #光标转动的速度/帧 2帧转动一次
ZSZDQS = 2 #抽奖至少转动几圈
WBHDD = 60 #抽奖完毕后,等待多少帧光标归零
end
#主调用方法
def 售货机(goods,prize=nil)
$prize = prize
#goods代表物品 prize代表奖品
SceneManager.call(Scene_Shop_A)
SceneManager.scene.prepare(goods, false)
end
#encoding:utf-8
#==============================================================================
# ■ Window_ShopNumber
#------------------------------------------------------------------------------
# 商店画面中,输入“物品买入/卖出数量”的窗口。
#==============================================================================
class Window_ShopNumber_S < Window_Selectable
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :number # 数量
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y, height)
super(x, y, window_width, height)
@item = nil
@Max = 1
@price = 0
@number = 1
@currency_unit = Vocab::currency_unit
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return 440
end
#--------------------------------------------------------------------------
# ● 设置物品、最大值、价格、货币单位
#--------------------------------------------------------------------------
def set(item, max, price, currency_unit = nil)
@item = item
@max = max
@price = price
@currency_unit = currency_unit if currency_unit
@number = 1
refresh
end
#--------------------------------------------------------------------------
# ● 设置货币单位
#--------------------------------------------------------------------------
def currency_unit=(currency_unit)
@currency_unit = currency_unit
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_item_name(@item, 0, item_y)
draw_number
draw_total_price
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
#--------------------------------------------------------------------------
# ● 绘制总价
#--------------------------------------------------------------------------
def draw_total_price
width = contents_width - 8
draw_currency_value(@price * @number, @currency_unit, 4, price_y, width)
end
#--------------------------------------------------------------------------
# ● 显示物品名称行的 Y 坐标
#--------------------------------------------------------------------------
def item_y
contents_height / 2 - line_height * 3 / 2
end
#--------------------------------------------------------------------------
# ● 显示价格行的 Y 坐标
#--------------------------------------------------------------------------
def price_y
contents_height / 2 + line_height / 2
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
#encoding:utf-8
#==============================================================================
# ■ Window_name
#------------------------------------------------------------------------------
# 物品名称的窗口
#==============================================================================
class Window_Name < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, window_height)
end
#--------------------------------------------------------------------------
# ● 设置内容
#--------------------------------------------------------------------------
def set_text(text)
if text != @text
@text = text
refresh
end
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return 440-200
end
#--------------------------------------------------------------------------
# ● 获取窗口的高度
#--------------------------------------------------------------------------
def window_height
return 248
end
#--------------------------------------------------------------------------
# ● 清除
#--------------------------------------------------------------------------
def clear
set_text("")
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 技能、物品等
#--------------------------------------------------------------------------
def set_item(item)
set_text(item ? item.name : "")
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_text_ex(4, 0, @text)
end
end
###############################################################################
###############################################################################
#encoding:utf-8
#==============================================================================
# ■ Window_ShopBuy_A
#------------------------------------------------------------------------------
# 商店画面中,买入时显示所有商品的窗口。
#==============================================================================
class Window_ShopBuy_A < Window_Selectable
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :status_window # 状态窗口
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y, height, shop_goods)
super(100, 0, window_width, height)
@shop_goods = shop_goods
@money = 0
refresh
select(0)
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return (Graphics.width-200)
end
#--------------------------------------------------------------------------
# ● 获取窗口的列数
#--------------------------------------------------------------------------
def col_max
return 4
end
#--------------------------------------------------------------------------
# ● 获取项目数
#--------------------------------------------------------------------------
def item_max
@data ? @data.size : 1
end
#--------------------------------------------------------------------------
# ● 获取商品
#--------------------------------------------------------------------------
def item
@data[index]
end
#--------------------------------------------------------------------------
# ● 设置持有金钱
#--------------------------------------------------------------------------
def money=(money)
@money = money
refresh
end
#--------------------------------------------------------------------------
# ● 获取选择项目的有效状态
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(@data[index])
end
#--------------------------------------------------------------------------
# ● 获取商品价格
#--------------------------------------------------------------------------
def price(item)
@price[item]
end
#--------------------------------------------------------------------------
# ● 查询商品是否可买
#--------------------------------------------------------------------------
def enable?(item)
item && price(item) <= @money && !$game_party.item_max?(item)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# ● 生成商品列表
#--------------------------------------------------------------------------
def make_item_list
@data = []
@price = {}
@shop_goods.each do |goods|
case goods[0]
when 0; item = $data_items[goods[1]]
when 1; item = $data_weapons[goods[1]]
when 2; item = $data_armors[goods[1]]
end
if item
@data.push(item)
@price[item] = goods[2] == 0 ? item.price : goods[3]
end
end
end
#--------------------------------------------------------------------------
# ● 绘制项目
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = item_rect(index)
draw_icon(item.icon_index, rect.x+35, rect.y-60, enable?(item))
rect.width -= 4
#rect.y += 130
draw_text(rect, price(item), 1)
end
#--------------------------------------------------------------------------
# ● 获取项目的绘制矩形
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new
rect.width = item_width
rect.height = item_height
rect.x = index % col_max * (item_width + spacing)
rect.y = index / col_max * item_height + 130
rect
end
#--------------------------------------------------------------------------
# ● 更新帮助内容
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(item) if @help_window
end
end
################################################################################
#encoding:utf-8
#==============================================================================
# ■ Scene_Shop_A
#------------------------------------------------------------------------------
# 商店画面
#==============================================================================
class Scene_Shop_A < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 准备
#--------------------------------------------------------------------------
def prepare(goods, purchase_only)
@goods = goods
@purchase_only = purchase_only
end
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_backgrond
create_dummy_window
create_number_window
create_name_window
create_buy_window
create_gold_window
command_buy
end
#--------------------------------------------------------------------------
# ● 生成背景图
#--------------------------------------------------------------------------
def create_backgrond
@backgrond = Sprite.new
@backgrond.bitmap = Bitmap.new("Graphics/Pictures/贩卖机")
@backgrond.x = 0
@gb = Sprite.new
@gb.bitmap = Bitmap.new("Graphics/Pictures/光标")
@gb.ox = @gb.width / 2
@gb.oy = +82
@gb.x = 317
@gb.y = [email protected]
end
#--------------------------------------------------------------------------
# ● 生成金钱窗口
#--------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_Gold.new
@gold_window.viewport = @viewport
@gold_window.x = @buy_window.x + @buy_window.width - @gold_window.width
@gold_window.y = @buy_window.y + @buy_window.height
@gold_window.opacity = 0
end
#--------------------------------------------------------------------------
# ● 生成名称窗口
#--------------------------------------------------------------------------
def create_name_window
@name_window = Window_Name.new
@name_window.x = 100
@name_window.y = 200
@name_window.opacity = 0
end
#--------------------------------------------------------------------------
# ● 生成填充窗口
#--------------------------------------------------------------------------
def create_dummy_window
wy = 120
wh = Graphics.height - wy
@dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
@dummy_window.viewport = @viewport
end
#--------------------------------------------------------------------------
# ● 生成数值输入窗口
#--------------------------------------------------------------------------
def create_number_window
wy = 0
wh = 200
@number_window = Window_ShopNumber_S.new(100, wy, wh)
@number_window.viewport = @viewport
@number_window.hide
@number_window.set_handler(:ok, method(:on_number_ok))
@number_window.set_handler(:cancel, method(:on_number_cancel))
end
#--------------------------------------------------------------------------
# ● 生成买入窗口
#--------------------------------------------------------------------------
def create_buy_window
wy = 0
wh = 200
@buy_window = Window_ShopBuy_A.new(0, wy, wh, @goods)
@buy_window.viewport = @viewport
@buy_window.help_window = @name_window
@buy_window.set_handler(:ok, method(:on_buy_ok))
@buy_window.set_handler(:cancel, method(:on_buy_cancel))
@buy_window.opacity = 0
end
#--------------------------------------------------------------------------
# ● 启用买入窗口
#--------------------------------------------------------------------------
def activate_buy_window
@buy_window.money = money
@buy_window.show.activate
end
#--------------------------------------------------------------------------
# ● 指令“买入”
#--------------------------------------------------------------------------
def command_buy
@dummy_window.hide
activate_buy_window
end
#--------------------------------------------------------------------------
# ● 买入“确定”
#--------------------------------------------------------------------------
def on_buy_ok
@item = @buy_window.item
@buy_window.hide
@number_window.set(@item, max_buy, buying_price, currency_unit)
@number_window.show.activate
end
#--------------------------------------------------------------------------
# ● 买入“取消”
#--------------------------------------------------------------------------
def on_buy_cancel
return_scene
#@backgrond.dispose
#@backgrond.bitmap.dispose
end
#--------------------------------------------------------------------------
# ● 数值输入“确定”
#--------------------------------------------------------------------------
def on_number_ok
Sound.play_shop
do_buy(@number_window.number)
end_number_input
@gold_window.refresh
end
#--------------------------------------------------------------------------
# ● 数值输入“取消”
#--------------------------------------------------------------------------
def on_number_cancel
Sound.play_cancel
end_number_input
end
#--------------------------------------------------------------------------
# ● 执行买入
#--------------------------------------------------------------------------
def do_buy(number)
$game_party.lose_gold(number * buying_price)
$game_party.gain_item(@item, number)
###抽奖系统放在这里
抽奖
##################
end
#--------------------------------------------------------------------------
# ● 买入后执行抽奖
#--------------------------------------------------------------------------
def 抽奖
a = SH::ZSZDQS * 8 + rand(17)
a.times do
Audio.se_play("Audio/SE/#{SH::GBSE}", 100, 100)
@gb.angle -= 45
Graphics.update
Graphics.wait(SH::GBZDSD)
end
if a % 8 == 0
Audio.me_play("Audio/ME/#{SH::WINME}", 100, 100)
Graphics.wait(120)
case $prize[0]
when 1
$game_party.gain_item($data_items[$prize[1]], $prize[2])
when 2
$game_party.gain_item($data_weapons[$prize[1]], $prize[2],true)
when 3
$game_party.gain_item($data_armors[$prize[1]], $prize[2],true)
end
else
end
Graphics.wait(SH::WBHDD)
@gb.angle = 0
end
#--------------------------------------------------------------------------
# ● 结束数值输入
#--------------------------------------------------------------------------
def end_number_input
@number_window.hide
activate_buy_window
end
#--------------------------------------------------------------------------
# ● 获取可以买入的最大值
#--------------------------------------------------------------------------
def max_buy
max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
buying_price == 0 ? max : [max, money / buying_price].min
end
#--------------------------------------------------------------------------
# ● 获取持有金钱
#--------------------------------------------------------------------------
def money
@gold_window.value
end
#--------------------------------------------------------------------------
# ● 获取货币单位
#--------------------------------------------------------------------------
def currency_unit
@gold_window.currency_unit
end
#--------------------------------------------------------------------------
# ● 获取买入价格
#--------------------------------------------------------------------------
def buying_price
return 150 unless RPGBOY.check_item(@item)
@buy_window.price(@item)
end
end
==============================================================================
==================================
|
|