赞 | 38 |
VIP | 2420 |
好人卡 | 100 |
积分 | 33 |
经验 | 75384 |
最后登录 | 2024-7-7 |
在线时间 | 3619 小时 |
Lv3.寻梦者 (暗夜天使) 名侦探小柯
- 梦石
- 0
- 星屑
- 3299
- 在线时间
- 3619 小时
- 注册时间
- 2006-9-6
- 帖子
- 37400
|
- =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)
- return if @chaojie
- old_gain_item(item,n,include_equip)
- end
- end
复制代码
我想是这脚本的问题吧…… |
|