Project1
标题:
【3VIP】如何实现让买掉的东西消失
[打印本页]
作者:
lxdsh2009
时间:
2011-8-31 11:42
标题:
【3VIP】如何实现让买掉的东西消失
本帖最后由 lxdsh2009 于 2011-8-31 11:42 编辑
比如商店中出售A、B、C三件物品,买了A后,再进入商店,就没有A这样商品了。
求脚本解法,事件用条件分歧写了一大串,无效。
人形1.jpg
(58.38 KB, 下载次数: 5)
下载附件
保存到相册
2011-8-31 11:41 上传
人形2.jpg
(37.26 KB, 下载次数: 6)
下载附件
保存到相册
2011-8-31 11:41 上传
dsu_plus_rewardpost_czw
作者:
fux2
时间:
2011-8-31 12:58
本帖最后由 fux2 于 2011-9-1 15:20 编辑
修正问题:
1.判断忽略空值问题
2.优化判断方法,提高效率
3.可以在存档中保存和读取.(之前的档案会失效)
[line]5[/line]
class Scene_Shop < Scene_Base
def update_buy_selection
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
number = $game_party.item_number(@item)
if @item == nil or @item.price > $game_party.gold or number == 99
Sound.play_buzzer
else
Sound.play_decision
if $buy_rec[$game_map.map_id]
if $buy_rec[$game_map.map_id][$curevent]
$buy_rec[$game_map.map_id][$curevent] << [@item.type,@item.id]
else
$buy_rec[$game_map.map_id][$curevent] = [[@item.type,@item.id]]
end
else
$buy_rec[$game_map.map_id] = {$curevent=>[[@item.type,@item.id]]}
end
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
end
class Game_Player < Game_Character
def check_event_trigger_there(triggers)
return false if $game_map.interpreter.running?
result = false
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
for event in $game_map.events_xy(front_x, front_y)
if triggers.include?(event.trigger) and event.priority_type == 1
event.start
$curevent = event.event.id
result = true
end
end
if result == false and $game_map.counter?(front_x, front_y)
front_x = $game_map.x_with_direction(front_x, @direction)
front_y = $game_map.y_with_direction(front_y, @direction)
for event in $game_map.events_xy(front_x, front_y)
if triggers.include?(event.trigger) and event.priority_type == 1
event.start
result = true
end
end
end
return result
end
end
class Window_ShopBuy < Window_Selectable
def refresh
@data = []
@shop_goods.each{|goods_item|
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
next if $buy_rec[$game_map.map_id] && $buy_rec[$game_map.map_id][$curevent] && $buy_rec[$game_map.map_id][$curevent].include?([item.type,item.id])
if item != nil
@data.push(item)
end
}
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
end
class Scene_Title < Scene_Base
alias:cng:command_new_game
define_method(:command_new_game){$buy_rec = {};cng}
end
class Scene_File < Scene_Base
alias:wsd:write_save_data
def write_save_data(file)
wsd(file)
Marshal.dump($buy_rec,file)
end
alias:rsd:read_save_data
def read_save_data(file)
rsd(file)
$buy_rec = Marshal.load(file)
end
end
复制代码
[acfun]http://ftp.66rpg.com/user/fux2/myzone.html[/acfun]
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1