设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: 魔力的觉醒
打印 上一主题 下一主题

[已经过期] 有事请教,关于脚本问题,物品信息添加颜色。

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
199
在线时间
248 小时
注册时间
2012-4-29
帖子
386
11
 楼主| 发表于 2013-5-31 17:47:46 | 只看该作者
=begin
================================================
道具提示系统 版本 1.01 By 804173948 QQ:同上
================================================

修正BUG:

1.读取游戏后获取道具错误

更新:
1.添加音效(本人觉得很难听)

使用方法:
在事件-脚本里输入

1、获得/失去物品

获得:

get_item($data_items[物品id],数量)

失去:

lost_item($data_items[物品id],数量)

例如:

get_item($data_items[10],4) 获得10号物品 4个

lost_item($data_items[1],3) 丢失1号物品 3个

2、获得/失去武器

获得:

get_item($data_weapons[物品id],数量)

失去:

lost_item($data_weapons[物品id],数量,是否包括装备)

是否包括装备:是则 True 否则 false 或不写 下同

3、获得/失去防具

获得:

get_item($data_armors[物品id],数量)

失去:

lost_item($data_armors[物品id],数量,是否包括装备)

注意:最后要加一句 show_window 否则不显示提示窗口


详情看范例……
有疑问或BUG之类的 欢迎提出
=end
class Game_Interpreter
  alias old_initialize initialize
  def initialize(depth = 0)
    old_initialize
    @get_item_var =[]
    @get_amount =[]
  end
  def show_window
    Audio.se_play("Audio/SE/Shop",80,100)
    SceneManager.call(Scene_Get_Item)
    SceneManager.scene.show_window(@get_item_var,@get_amount)
    @get_item_var =[]
    @get_amount =[]
  end
  def get_item(item,amount)
    amount = 99 if amount > 99
    @get_item_var = [] if @get_item_var == nil
    @get_amount = [] if @get_amount == nil
    @get_item_var.push(item)
    @get_amount.push(amount)
    $game_party.gain_item(item,amount)
  end
  def lost_item(item,amount,include_equip = false)
    amount = 99 if amount > 99
    @get_item_var = [] if @get_item_var == nil
    @get_amount = [] if @get_amount == nil
    @get_item_var.push(item)
    @get_amount.push(-amount)
    $game_party.gain_item(item,-amount,include_equip)
  end
end
class Scene_Get_Item < Scene_MenuBase
  def start
    super
    @get_item_var = []
    @get_amount = []
  end
  def show_window(get_item_var,get_amount)
    @get_item_var = get_item_var
    @get_amount = get_amount
    create_show_get_window
    create_category_window
  end
  def create_show_get_window
    @show_get_window = Window_Show_GetItem.new(120,88,300,200,@get_item_var,@get_amount) #窗口位置
    @show_get_window.set_handler(:ok,     method(:return_scene))
    @show_get_window.set_handler(:cancel, method(:on_item_cancel))
  end
  def create_category_window
    @show_getItem_category = Window_GetItem_Category.new(120,40,300,48)
    @show_getItem_category.item_window = @show_get_window
    @show_getItem_category.set_handler(:ok,     method(:on_category_ok))
    @show_getItem_category.set_handler(:cancel, method(:return_scene))
  end
  def on_category_ok
    @show_get_window.activate
  end
  def on_item_cancel
    @show_getItem_category.activate
  end
end
class Window_GetItem_Category < Window_HorzCommand
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :item_window
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(x,y,width,height)
    super(x, y)
    self.width = width
    self.height = height
  end
  #--------------------------------------------------------------------------
  # ● 窗口宽度
  #--------------------------------------------------------------------------
  def window_width
    return 300
  end
  #--------------------------------------------------------------------------
  # ● 获取列数
  #--------------------------------------------------------------------------
  def col_max
    return 2
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    @item_window.category = current_symbol if @item_window
  end
  #--------------------------------------------------------------------------
  # ● 生成指令列表
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(" 获得物品",   :get)
    add_command(" 失去物品",   :lost)
  end
  #--------------------------------------------------------------------------
  # ● 设置物品窗口
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
end

class Window_Show_GetItem < Window_ItemList
  def initialize(x, y, width, height,data,amount)
    super(x, y, width, height)
    @category = :get
    @data_save = data
    @amount_save = amount
    refresh
  end
  def col_max
    return 1
  end
  def spacing
    return 32
  end
  def include?(index)
    if index
      case @category
      when :get
        if index >= 0
          true
        else
          false
        end
      when :lost
        if index < 0
          true
        else
          false
        end
      else
        false
      end
    end
  end
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y)
      draw_item_number(rect, index)
    end
  end
  def draw_item_number(rect, item)
    if @amount[item] < 0
      s1 = -@amount[item]
    else
      s1 = @amount[item]
    end
    draw_text(rect, sprintf(":%2d", s1), 2)
  end
  #--------------------------------------------------------------------------
  # ● 查询此物品是否可用
  #--------------------------------------------------------------------------
  def enable?(item)
    return true
  end
  #--------------------------------------------------------------------------
  # ● 生成物品列表
  #--------------------------------------------------------------------------
  def make_item_list
    @data = Array.new(@data_save)
    @amount = Array.new(@amount_save)
    for i in 0 ... @data.size
    @data[i] = nil if include?(@amount_save[i]) == false
    @amount[i] = nil if include?(@amount_save[i]) == false
    end
    @data.delete(nil)
    @amount.delete(nil)
  end
end

最后一个^^^^^^^^^^^^^^^   
你的意思就是要打架咯?
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

梦石
0
星屑
266
在线时间
2355 小时
注册时间
2009-3-13
帖子
2309

贵宾

12
发表于 2013-5-31 18:20:38 | 只看该作者
本帖最后由 Sion 于 2013-5-31 18:25 编辑

要提问的话请重新开贴,把脚本整理好再传上来。脚本太多,建议传工程。

此贴太乱,影响阅读。因此作关闭下沉处理
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-10 08:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表