Project1
标题: 请问有没有一次性商店的脚本 [打印本页]
作者: 雨落忧伤 时间: 2017-12-19 18:59
标题: 请问有没有一次性商店的脚本
具体是这样的,我希望能够在游戏里做一个成就,那就是把某一个商人的所有商品都买过一个遍。为了达到这样的效果,我希望有一个商店(应该在有些游戏里也能够见到,比如说《茶杯头大冒险》),就是一个商人会出售很多商品,但是每出售完一个,这个商品就会显示“卖完(Sold Out)”,这样的话等到所有的物品都显示“已售罄”以后,就可以获得这个成就。
当然,我知道这个效果可以通过纯事件来制作,只要用开关和条件分支就可以做这种类型的商店事件,不过我还是想通过商店界面来实现这种功能,而不是游戏体验比较差的纯事件方式。
所以,请问一下有没有这种一次性商店的脚本,最好是能够设置成二周目有办法重置商品的。
P.S.之前看过一个真实商店脚本,好像可以实现我所说的功能,但是那个脚本是RMXP的,并不是RMVA的。
作者: 魔法丶小肉包 时间: 2017-12-19 22:04
打开SHOP作为ID的开关,进入一次性商店,商品设置事件照常不变,当全部卖完后10号开关会自动打开(这个时候就是你设置获得成就的时候了)
.....(什么二周目重置之类的懒得写了....)
SHOP = 1
class Scene_Shop
alias obo on_buy_ok
def on_buy_ok
if $game_switches[SHOP]
@item = @buy_window.item
do_buy(1) if !$game_switches[@item.id+1000]
$game_variables[9999] += 1 if !$game_switches[@item.id+1000]
$game_switches[@item.id+1000] = true
@gold_window.refresh
@status_window.refresh
activate_buy_window
else
obo
end
end
end
class Window_ShopBuy
alias di draw_item
def draw_item(index)
if $game_switches[SHOP]
item = @data[index]
if $game_switches[item.id+1000]
rect = item_rect(index)
draw_text(rect, "-------已售完-------", 1)
if $game_variables[9999] == item_max
$game_switches[10] = true
end
else
di(index)
end
else
di(index)
end
end
end
SHOP = 1
class Scene_Shop
alias obo on_buy_ok
def on_buy_ok
if $game_switches[SHOP]
@item = @buy_window.item
do_buy(1) if !$game_switches[@item.id+1000]
$game_variables[9999] += 1 if !$game_switches[@item.id+1000]
$game_switches[@item.id+1000] = true
@gold_window.refresh
@status_window.refresh
activate_buy_window
else
obo
end
end
end
class Window_ShopBuy
alias di draw_item
def draw_item(index)
if $game_switches[SHOP]
item = @data[index]
if $game_switches[item.id+1000]
rect = item_rect(index)
draw_text(rect, "-------已售完-------", 1)
if $game_variables[9999] == item_max
$game_switches[10] = true
end
else
di(index)
end
else
di(index)
end
end
end
作者: 雨落忧伤 时间: 2017-12-20 09:44
非常感谢,可以达到我想要的效果!
不过,的确是没有办法重置商店……如果能把这个解决就更完美了。
作者: 魔法丶小肉包 时间: 2017-12-20 11:23
帮你把重置功能加上了,打开RE作为ID的开关,然后马上关掉这个开关(关闭之前不要让玩家有机会进入一次性商店买东西),重置完毕
SHOP = 1
RE = 2
class Scene_Map
alias up update
def update
up
$game_switches[10] = false if $game_switches[RE]
if $game_switches[RE]
i = 0
loop do
$game_switches[i+1000] = false
i += 1
break if i == 1000
end
$game_variables[9999] = 0
end
end
end
class Scene_Shop
alias obo on_buy_ok
def on_buy_ok
if $game_switches[SHOP]
@item = @buy_window.item
do_buy(1) if !$game_switches[@item.id+1000]
$game_variables[9999] += 1 if !$game_switches[@item.id+1000]
$game_switches[@item.id+1000] = true
@gold_window.refresh
@status_window.refresh
activate_buy_window
else
obo
end
end
end
class Window_ShopBuy
alias di draw_item
def draw_item(index)
if $game_switches[SHOP]
item = @data[index]
if $game_switches[item.id+1000]
rect = item_rect(index)
draw_text(rect, "-------已售完-------", 1)
if $game_variables[9999] == item_max
$game_switches[10] = true
end
else
di(index)
end
else
di(index)
end
end
end
SHOP = 1
RE = 2
class Scene_Map
alias up update
def update
up
$game_switches[10] = false if $game_switches[RE]
if $game_switches[RE]
i = 0
loop do
$game_switches[i+1000] = false
i += 1
break if i == 1000
end
$game_variables[9999] = 0
end
end
end
class Scene_Shop
alias obo on_buy_ok
def on_buy_ok
if $game_switches[SHOP]
@item = @buy_window.item
do_buy(1) if !$game_switches[@item.id+1000]
$game_variables[9999] += 1 if !$game_switches[@item.id+1000]
$game_switches[@item.id+1000] = true
@gold_window.refresh
@status_window.refresh
activate_buy_window
else
obo
end
end
end
class Window_ShopBuy
alias di draw_item
def draw_item(index)
if $game_switches[SHOP]
item = @data[index]
if $game_switches[item.id+1000]
rect = item_rect(index)
draw_text(rect, "-------已售完-------", 1)
if $game_variables[9999] == item_max
$game_switches[10] = true
end
else
di(index)
end
else
di(index)
end
end
end
作者: 雨落忧伤 时间: 2017-12-23 20:16
对了,今天重新测试的时候发现了一个问题。
因为考虑在游戏里加入商店进阶(也就是游戏流程越往后商品越多),然后如果是我先开了一个商店,然后再开一个商店,新开的商店增加新的商品的话,新的商品是“已售完”的状态……
不知道可不可以解决一下。
作者: 魔法丶小肉包 时间: 2017-12-24 00:55
需要设置的地方
1.准备设多少一次性商店就在MAXSHOP写多少
2.$mshop这里需要设置,格式 [商店所在的地图ID,商店的事件ID] => 商店编号,
看例子
$mshop = {
[1,5] => 1,
[1,2] => 2
}
[1,5] => 1 #1号地图ID为5的事件是1号商店
[1,2] => 2 #1号地图ID为2的事件是2号商店
3.商店事件前请加上事件脚本$eid = get_character(0).id
4.打开名为SHOP的开关
5.其他照常
这个版本开始,每个一次性商店商品都是独立的,当然一个商店同一个物品还是只能买一次,买完了可以换商店再买
6.好困,我去睡觉了...
SHOP = 1
RE = 2
MAXSHOP = 2
$mshop = {}
$mshop = {
[1,5] => 1,
[1,2] => 2
}
class Scene_Map
alias up update
def update
up
$game_switches[10] = false if $game_switches[RE]
if $game_switches[RE]
i = 0
loop do
$game_switches[i+1000] = false
i += 1
break if i == 1000
end
$game_variables[9999] = 0
end
end
end
class Scene_Shop
alias mst start
def start
mst
if $game_switches[SHOP]
$msaveshop ||= Array.new(MAXSHOP)
p $msaveshop
if $msaveshop.include?(nil)
a ||= 0
loop do
$msaveshop[a] = []
a += 1
break if a == MAXSHOP
end
end
re_shop
load_shop
end
end
def terminate
super
save_shop
end
def save_shop
i = 0
loop do
$msaveshop[$mshop[[$game_map.map_id,$eid]]-1][i] = $game_switches[i+1000]
i += 1
break if i == 1000
end
end
def re_shop
i = 0
loop do
$game_switches[i+1000] = false
i += 1
break if i == 1000
end
$game_variables[9999] = 0
end
def load_shop
i = 0
loop do
$game_switches[i+1000] = $msaveshop[$mshop[[$game_map.map_id,$eid]]-1][i] if $msaveshop[$mshop[[$game_map.map_id,$eid]]-1]
i += 1
break if i == 1000
end
end
alias obo on_buy_ok
def on_buy_ok
if $game_switches[SHOP]
@item = @buy_window.item
do_buy(1) if !$game_switches[@item.id+1000]
$game_variables[9999] += 1 if !$game_switches[@item.id+1000]
$game_switches[@item.id+1000] = true
@gold_window.refresh
@status_window.refresh
activate_buy_window
else
obo
end
end
end
class Window_ShopBuy
alias di draw_item
def draw_item(index)
if $game_switches[SHOP]
item = @data[index]
if $game_switches[item.id+1000]
rect = item_rect(index)
draw_text(rect, "-------已售完-------", 1)
if $game_variables[9999] == item_max
$game_switches[10] = true
end
else
di(index)
end
else
di(index)
end
end
end
SHOP = 1
RE = 2
MAXSHOP = 2
$mshop = {}
$mshop = {
[1,5] => 1,
[1,2] => 2
}
class Scene_Map
alias up update
def update
up
$game_switches[10] = false if $game_switches[RE]
if $game_switches[RE]
i = 0
loop do
$game_switches[i+1000] = false
i += 1
break if i == 1000
end
$game_variables[9999] = 0
end
end
end
class Scene_Shop
alias mst start
def start
mst
if $game_switches[SHOP]
$msaveshop ||= Array.new(MAXSHOP)
p $msaveshop
if $msaveshop.include?(nil)
a ||= 0
loop do
$msaveshop[a] = []
a += 1
break if a == MAXSHOP
end
end
re_shop
load_shop
end
end
def terminate
super
save_shop
end
def save_shop
i = 0
loop do
$msaveshop[$mshop[[$game_map.map_id,$eid]]-1][i] = $game_switches[i+1000]
i += 1
break if i == 1000
end
end
def re_shop
i = 0
loop do
$game_switches[i+1000] = false
i += 1
break if i == 1000
end
$game_variables[9999] = 0
end
def load_shop
i = 0
loop do
$game_switches[i+1000] = $msaveshop[$mshop[[$game_map.map_id,$eid]]-1][i] if $msaveshop[$mshop[[$game_map.map_id,$eid]]-1]
i += 1
break if i == 1000
end
end
alias obo on_buy_ok
def on_buy_ok
if $game_switches[SHOP]
@item = @buy_window.item
do_buy(1) if !$game_switches[@item.id+1000]
$game_variables[9999] += 1 if !$game_switches[@item.id+1000]
$game_switches[@item.id+1000] = true
@gold_window.refresh
@status_window.refresh
activate_buy_window
else
obo
end
end
end
class Window_ShopBuy
alias di draw_item
def draw_item(index)
if $game_switches[SHOP]
item = @data[index]
if $game_switches[item.id+1000]
rect = item_rect(index)
draw_text(rect, "-------已售完-------", 1)
if $game_variables[9999] == item_max
$game_switches[10] = true
end
else
di(index)
end
else
di(index)
end
end
end
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |