Project1
标题:
RMVX 求脚本 仓库 和 携带物品上限限制
[打印本页]
作者:
PitcherF
时间:
2008-5-26 02:41
提示:
作者被禁止或删除 内容自动屏蔽
作者:
越前リョーマ
时间:
2008-5-26 02:55
仓库的话我想要,
至于第二个,我有个半成品……不过有个BUG……
=begin
使用方法:
1.搜索
@chaojie = true if $game_variables[6] <= @itemnumber
将那个“1”换成控制总数的变量号
注意:一共有三处……
2.将图片放到Graphics/Pictures/bag.png
规格180*360
3.搜索
self.contents.draw_text(4, 0, self.width - 40, WLH, "我可爱的背包")
把“我可爱的背包”换成你想要的文字
=end
class Window_ItemBag < Window_Base
def initialize
super(0,0,544-180,56)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.draw_text(4, 0, self.width - 40, WLH, "小背包")
end
end
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对象
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
# width : 窗口的宽
# height : 窗口的高
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@column_max = 2
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# ● 取得物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 列表中包含的物品
# item : 物品
#--------------------------------------------------------------------------
def include?(item)
return false if item == nil
if $game_temp.in_battle
return false unless item.is_a?(RPG::Item)
end
return true
end
#--------------------------------------------------------------------------
# ● 显示是否可以使用物品
# item : 物品
#--------------------------------------------------------------------------
def enable?(item)
return $game_party.item_can_use?(item)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@data = []
for item in $game_party.items
next unless include?(item)
@data.push(item)
if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
self.index = @data.size - 1
end
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
enabled = enable?(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled)
self.contents.font.size = 12
self.contents.draw_text(rect.x + 5 , rect.y - 23, WLH , 80, number.to_s, 2)
self.contents.font.size = 20
end
end
#--------------------------------------------------------------------------
# ● 更新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
def draw_item_name(item, x, y, enabled = true)
if item != nil
draw_icon(item.icon_index, x, y, enabled)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x + 48, y, 172, WLH, item.name)
end
end
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_menu_background
@viewport = Viewport.new(0, 0, 544, 416)
@help_window = Window_Help.new
@help_window.viewport = @viewport
@item_window = Window_Item.new(0, 56, 544-180, 416-56*2)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@help_window.y = 416-56
@item_window.active = false
@sprite = Sprite.new
@sprite.x = 544-180
@sprite.bitmap = Bitmap.new("Graphics/Pictures/bag")
@sprite.opacity = 160
@target_window = Window_MenuStatus.new(0, 0)
@bag_window = Window_ItemBag.new
hide_target_window
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@viewport.dispose
@sprite.dispose
@help_window.dispose
@item_window.dispose
@target_window.dispose
@bag_window.dispose
end
#--------------------------------------------------------------------------
# ● 返回至原来的画面
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Menu.new(0)
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@item_window.update
@target_window.update
if @item_window.active
update_item_selection
elsif @target_window.active
update_target_selection
end
end
#--------------------------------------------------------------------------
# ● 更新物品选择
#--------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
@item = @item_window.item
if @item != nil
$game_party.last_item_id = @item.id
end
if $game_party.item_can_use?(@item)
Sound.play_decision
determine_item
else
Sound.play_buzzer
end
end
end
#--------------------------------------------------------------------------
# ● 确定物品
#--------------------------------------------------------------------------
def determine_item
if @item.for_friend?
show_target_window(@item_window.index % 2 == 0)
if @item.for_all?
@target_window.index = 99
else
if $game_party.last_target_index < @target_window.item_max
@target_window.index = $game_party.last_target_index
else
@target_window.index = 0
end
end
else
use_item_nontarget
end
end
#--------------------------------------------------------------------------
# ● 更新选择目标
#--------------------------------------------------------------------------
def update_target_selection
if Input.trigger?(Input::B)
Sound.play_cancel
if $game_party.item_number(@item) == 0 # 物品使用完了的情况下
@item_window.refresh # 重新生成窗口内容
end
hide_target_window
elsif Input.trigger?(Input::C)
if not $game_party.item_can_use?(@item)
Sound.play_buzzer
else
determine_target
end
end
end
#--------------------------------------------------------------------------
# ● 确定目标
# 无效的情况下 (在不能战斗的情况下使用恢复剂) 播放 buzzer 的 SE。
#--------------------------------------------------------------------------
def determine_target
used = false
if @item.for_all?
for target in $game_party.members
target.item_effect(target, @item)
used = true unless target.skipped
end
else
$game_party.last_target_index = @target_window.index
target = $game_party.members[@target_window.index]
target.item_effect(target, @item)
used = true unless target.skipped
end
if used
use_item_nontarget
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# ● 显示目标窗口
# right : 靠右标志 (false 为靠左)
#--------------------------------------------------------------------------
def show_target_window(right)
@item_window.active = false
width_remain = 544 - @target_window.width
@target_window.x = right ? width_remain : 0
@target_window.visible = true
@target_window.active = true
if right
@viewport.rect.set(0, 0, width_remain, 416)
@viewport.ox = 0
else
@viewport.rect.set(@target_window.width, 0, width_remain, 416)
@viewport.ox = @target_window.width
end
end
#--------------------------------------------------------------------------
# ● 不显示目标窗口
#--------------------------------------------------------------------------
def hide_target_window
@item_window.active = true
@target_window.visible = false
@target_window.active = false
@viewport.rect.set(0, 0, 544, 416)
@viewport.ox = 0
end
#--------------------------------------------------------------------------
# ● 使用物品 (也适用于我方对象以外的效果)
#--------------------------------------------------------------------------
def use_item_nontarget
Sound.play_use_item
$game_party.consume_item(@item)
@item_window.draw_item(@item_window.index)
@target_window.refresh
if $game_party.all_dead?
$scene = Scene_Gameover.new
elsif @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$scene = Scene_Map.new
end
end
end
class Game_Party < Game_Unit
alias old_gain_item gain_item
def gain_item(item, n, include_equip = false)
@itemnumber = 0
@chaojie = false
for i in 0...$data_items.size
new_item = $data_items[i]
@itemnumber += 1 if has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
for i in 0...$data_weapons.size
new_item = $data_weapons[i]
@itemnumber += 1 if has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
for i in 0...$data_armors.size
new_item = $data_armors[i]
@itemnumber += 1 if has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
@chaojie = true if has_item?(item)
@chaojie = false if n < 0
return if @chaojie
old_gain_item(item,n,include_equip)
end
end
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
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)
@itemnumber = 0
@chaojie = false
for i in 0...$data_items.size
new_item = $data_items[i]
@itemnumber += 1 if $game_party.has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
for i in 0...$data_weapons.size
new_item = $data_weapons[i]
@itemnumber += 1 if $game_party.has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
for i in 0...$data_armors.size
new_item = $data_armors[i]
@itemnumber += 1 if $game_party.has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
if @item == nil or @item.price > $game_party.gold or number == 99 or @chaojie
Sound.play_buzzer
else
Sound.play_decision
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
#==============================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_ShopBuy < Window_Selectable
def draw_item(index)
item = @data[index]
number = $game_party.item_number(item)
enabled = (item.price <= $game_party.gold and number < 99)
@itemnumber = 0
@chaojie = false
for i in 0...$data_items.size
new_item = $data_items[i]
@itemnumber += 1 if $game_party.has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
for i in 0...$data_weapons.size
new_item = $data_weapons[i]
@itemnumber += 1 if $game_party.has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
for i in 0...$data_armors.size
new_item = $data_armors[i]
@itemnumber += 1 if $game_party.has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
if enabled == true and @chaojie == false
enabled = true
else
enabled = false
end
rect = item_rect(index)
self.contents.clear_rect(rect)
draw_item_name(item, rect.x, rect.y, enabled)
rect.width -= 4
self.contents.draw_text(rect, item.price, 2)
end
end
#==============================================================================
# ■ Scene_Equip
#------------------------------------------------------------------------------
# 处理装备画面
#==============================================================================
class Scene_Equip < Scene_Base
#--------------------------------------------------------------------------
# ● 更新选择物品
#--------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@equip_window.active = true
@item_window.active = false
@item_window.index = -1
elsif Input.trigger?(Input::C)
@itemnumber = 0
@chaojie = false
for i in 0...$data_items.size
new_item = $data_items[i]
@itemnumber += 1 if $game_party.has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
for i in 0...$data_weapons.size
new_item = $data_weapons[i]
@itemnumber += 1 if $game_party.has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
for i in 0...$data_armors.size
new_item = $data_armors[i]
@itemnumber += 1 if $game_party.has_item?(new_item)
@chaojie = true if $game_variables[6] <= @itemnumber
end
case @equip_window.index
when 0
temp = $game_actors[@actor_index+1].weapon_id
when 1
temp = $game_actors[@actor_index+1].armor1_id
when 2
temp = $game_actors[@actor_index+1].armor2_id
when 3
temp = $game_actors[@actor_index+1].armor3_id
when 4
temp = $game_actors[@actor_index+1].armor4_id
end
if @chaojie and temp != 0
Sound.play_buzzer
else
Sound.play_equip
@actor.change_equip(@equip_window.index, @item_window.item)
@equip_window.active = true
@item_window.active = false
@item_window.index = -1
@equip_window.refresh
for item_window in @item_windows
item_window.refresh
end
end
end
end
end
复制代码
[LINE]1,#dddddd[/LINE]
系统信息:本贴获得楼主认可,66RPG感谢您的热情解答~
作者:
shinliwei
时间:
2008-5-26 03:39
仓库确实需要。。我也想要一个啊
作者:
zreo
时间:
2008-5-27 05:03
提示:
作者被禁止或删除 内容自动屏蔽
作者:
PitcherF
时间:
2008-5-27 05:22
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1