需要设置的地方
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
|