查看: 4886|回复: 9

[已经过期] 仿网游的随身背包(全脚本无需素材)

[复制链接]
梦石
0
星屑
701
在线时间
511 小时
注册时间
2012-4-8
回帖
193
发表于 2015-2-9 07:10:06 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 黑白界 于 2015-2-9 23:12 编辑

https://rpg.blue/thread-376385-1-1.html新版
——————————————————————————————————————————————
首先拜谢@945127391。昨天早上我还是一个清澈的脚本盲,跟他的4篇脚本教程学了1整天后(抱歉第4篇实在学不下来太长了),感觉可以出师了!
但毕竟新手,代码许多是教程里抓下来的,知其然不知其所以然,望有大神改进,我会更新。
好了,回到正题。

这个随身背包系统有两个前置脚本:
一个是sion神的鼠标https://rpg.blue/forum.php?mod=v ... D368%26typeid%3D368
还有装备帮助增强(抱歉原帖找不到了)

特点:
随时打开背包(游戏不得不暂停),再次点击背包或者点击右键都能关闭。
完全不影响原来的系统。

收一点经验用于计数,可以喵{:2_257:}

脚本特别乱,毕竟是凑得

[pre lang="ruby" line="1"]#=========================================================================
#======随身背包============================================================
#============================================================================
$icon_wupin=    260  #物品图标的编号
$icon_wuqi=     386  #武器图标的编号
$icon_hujia=    308  #护甲图标的编号
$icon_guizhong= 358  #贵重物品图标的编号
#==============================================================================
# ** Window_MapStatus
#==============================================================================
class Window_MapStatus < Window_Command
  #----------------------------------------------------------------------------
  # * 初始化
  #----------------------------------------------------------------------------
  def initialize
    @command_icon_index = [$icon_wupin]
    super(Graphics.width-48, Graphics.height-48)
  end
  #----------------------------------------------------------------------------
  # * 获取窗口宽度
  #----------------------------------------------------------------------------
  def window_width
  return 48
  end
  #----------------------------------------------------------------------------
  # * 创建命令列表
  #----------------------------------------------------------------------------
  def make_command_list
  add_command(Vocab::item,:item,  true)
  end

  def draw_item(index)
    rect = item_rect_for_text(index)
    draw_icon(@command_icon_index[index], rect.x-5, rect.y)
  end
end

#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map<Scene_Base
  #----------------------------------------------------------------------------
  # * 重命名方法
  #----------------------------------------------------------------------------
  alias o_start start
  #----------------------------------------------------------------------------
  # * 开始处理
  #----------------------------------------------------------------------------
  def start
    o_start
    create_menu_window
  end

  def create_menu_window

    @menu_command = Window_MapStatus.new
    @menu_command.set_handler(:item  ,    method(:item_ok))

  end
  def item_ok
    SceneManager.call(Scene_NewItem)
  end
end
#------------------------------------------------------------------------------
#  物品画面和商店画面中,显示装备、所持物品等项目列表的窗口。
#==============================================================================

class Window_NewItemCategory < Window_HorzCommand
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :item_window
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize
    @command_icon_index = [$icon_wupin,$icon_wuqi,$icon_hujia,$icon_guizhong]
    super(Graphics.width-220, Graphics.height-368)
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    220
  end
  #--------------------------------------------------------------------------
  # ● 获取列数
  #--------------------------------------------------------------------------
  def col_max
    return 4
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    @item_window.category = current_symbol if @item_window
  end
  #--------------------------------------------------------------------------
  # ● 生成指令列表
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::item,     :item)
    add_command(Vocab::weapon,   :weapon)
    add_command(Vocab::armor,    :armor)
    add_command(Vocab::key_item, :key_item)
  end
  #--------------------------------------------------------------------------
  # ● 设置物品窗口
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
    def draw_item(index)
    rect = item_rect_for_text(index)
    draw_icon(@command_icon_index[index], rect.x+5, rect.y)
  end
end

#encoding:utf-8
#==============================================================================
# ■ Window_NewItemList
#------------------------------------------------------------------------------
#  物品画面中,显示持有物品的窗口。
#==============================================================================

class Window_NewItemList < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(Graphics.width-220,Graphics.height-326,220,278)
    @category = :none
    @data = []
  end
  #--------------------------------------------------------------------------
  # ● 设置分类
  #--------------------------------------------------------------------------
  def category=(category)
    return if @category == category
    @category = category
    refresh
    self.oy = 0
  end
  #--------------------------------------------------------------------------
  # ● 获取列数
  #--------------------------------------------------------------------------
  def col_max
    return 4
  end

  #--------------------------------------------------------------------------
  # ● 获取项目数
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # ● 获取物品
  #--------------------------------------------------------------------------
  def item
    @data && index >= 0 ? @data[index] : nil
  end
  #--------------------------------------------------------------------------
  # ● 获取选择项目的有效状态
  #--------------------------------------------------------------------------
  def current_item_enabled?
    enable?(@data[index])
  end
  #--------------------------------------------------------------------------
  # ● 查询列表中是否含有此物品
  #--------------------------------------------------------------------------
  def include?(item)
    case @category
    when :item
      item.is_a?(RPG::Item) && !item.key_item?
    when :weapon
      item.is_a?(RPG::Weapon)
    when :armor
      item.is_a?(RPG::Armor)
    when :key_item
      item.is_a?(RPG::Item) && item.key_item?
    else
      false
    end
  end
  #--------------------------------------------------------------------------
  # ● 查询此物品是否可用
  #--------------------------------------------------------------------------
  def enable?(item)
    $game_party.usable?(item)
  end
  #--------------------------------------------------------------------------
  # ● 生成物品列表
  #--------------------------------------------------------------------------
  def make_item_list
    @data = $game_party.all_items.select {|item| include?(item) }
    @data.push(nil) if include?(nil)
  end
  #--------------------------------------------------------------------------
  # ● 返回上一个选择的位置
  #--------------------------------------------------------------------------
  def select_last
    select(@data.index($game_party.last_item.object) || 0)
  end
  #--------------------------------------------------------------------------
  # ● 绘制项目
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
       color = Color.new(40, 40, 40)
      self.contents.fill_rect(rect.x, rect.y, 24, 1, color)
      self.contents.fill_rect(rect.x, rect.y, 1, 24, color)
      self.contents.fill_rect(rect.x, rect.y+23, 24, 1, color)
      self.contents.fill_rect(rect.x+23, rect.y, 1, 24, color)
      draw_icon(item.icon_index,rect.x,rect.y,enable?(item))
      rect.width += 9
      rect.height += 14
      draw_item_number(rect, item)
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制物品个数
  #--------------------------------------------------------------------------
  def draw_item_number(rect, item)
    draw_text(rect, sprintf("%2d", $game_party.item_number(item)), 2)
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
end
#encoding:utf-8
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
#  物品画面
#==============================================================================

class Scene_NewItem < Scene_ItemBase
  #--------------------------------------------------------------------------
  # ● 开始处理
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_window2
    create_category_window
    create_item_window
  end
  #--------------------------------------------------------------------------
  # ● 生成分类窗口
  #--------------------------------------------------------------------------
  def create_category_window
    @category_window = Window_NewItemCategory.new
    @category_window.viewport = @viewport
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # ● 生成物品窗口
  #--------------------------------------------------------------------------
  def create_item_window
    wy = @category_window.y + @category_window.height
    wh = Graphics.height
    @item_window = Window_NewItemList.new(0, wy, Graphics.width, wh)
    @item_window.viewport = @viewport
    @item_window.set_handler(:ok,     method(:on_item_ok))
    @item_window.set_handler(:cancel, method(:on_item_cancel))
    @category_window.item_window = @item_window
  end

  #--------------------------------------------------------------------------
  # ● 分类“确定”
  #--------------------------------------------------------------------------
  def on_category_ok
    @item_window.activate
    @item_window.select_last
  end
  #--------------------------------------------------------------------------
  # ● 物品“确定”
  #--------------------------------------------------------------------------
  def on_item_ok
    $game_party.last_item.object = item
    determine_item
  end
  #--------------------------------------------------------------------------
  # ● 物品“取消”
  #--------------------------------------------------------------------------
  def on_item_cancel
    @item_window.unselect
    @category_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 播放使用物品声效
  #--------------------------------------------------------------------------
  def play_se_for_item
    Sound.play_use_item
  end
  #--------------------------------------------------------------------------
  # ● 使用物品
  #--------------------------------------------------------------------------
  def use_item
    super
    @item_window.redraw_current_item
  end
  def create_menu_window2

    @menu_command = Window_MapStatus.new
    @menu_command.set_handler(:ok , method(:return_scene ))

  end
end

[/pre]

安装装备帮助增强后,用下面代码作兼容
[pre lang="ruby" line="1"]#装备栏

module VIPArcher::Equipplus

  TIME = 0
  
end

class Scene_NewItem < Scene_ItemBase

  #--------------------------------------------------------------------------

  # ● 开始处理

  #--------------------------------------------------------------------------

  alias help_ex_start start

  def start

    help_ex_start

    create_help_ex

  end

end[/pre]
最后哪个大神知道怎么取消相邻物品的间隔啊,找了好久不知道怎么做
还有怎么让脚标显示的小一点
BEIBAO1.png
BEIBAO2.png

随身背包.zip

1.67 MB, 下载次数: 169

武侠|养成|战棋游戏《以武证道》头秃开发中...
开发日记在此

火烧大神

梦石
0
星屑
1916
在线时间
954 小时
注册时间
2012-1-1
回帖
1767
发表于 2015-2-9 13:20:54 | 显示全部楼层
好厉害,以前有学过其他语言的基础吗?

火兔游戏官网上线啦!!
戳 >>> www.huotuyouxi.com <<<戳
回复

使用道具 举报

梦石
0
星屑
701
在线时间
511 小时
注册时间
2012-4-8
回帖
193
 楼主| 发表于 2015-2-9 15:58:42 | 显示全部楼层
火烧兔子 发表于 2015-2-9 13:20
好厉害,以前有学过其他语言的基础吗?

基本没有,不过代码不是手写的,只是复制教程里给的模版然后改了些参数。。( ゚ω゚)
武侠|养成|战棋游戏《以武证道》头秃开发中...
开发日记在此
回复

使用道具 举报

梦石
0
星屑
102
在线时间
402 小时
注册时间
2013-11-2
回帖
80
发表于 2015-2-9 19:52:55 | 显示全部楼层
膜拜楼主了,不过sion大神的鼠标脚本使用“打开菜单时将鼠标移动到光标处”这个功能时如何能不让光标锁定在随身物品小栏上?
回复

使用道具 举报

梦石
0
星屑
701
在线时间
511 小时
注册时间
2012-4-8
回帖
193
 楼主| 发表于 2015-2-9 19:59:09 | 显示全部楼层
库拉托斯 发表于 2015-2-9 19:52
膜拜楼主了,不过sion大神的鼠标脚本使用“打开菜单时将鼠标移动到光标处”这个功能时如何能不让光标锁定在 ...

注释掉一些脚本,我在范例做过的。。不过忘了在哪了
武侠|养成|战棋游戏《以武证道》头秃开发中...
开发日记在此
回复

使用道具 举报

梦石
0
星屑
102
在线时间
402 小时
注册时间
2013-11-2
回帖
80
发表于 2015-2-9 20:04:29 | 显示全部楼层
库拉托斯 发表于 2015-2-9 19:52
膜拜楼主了,不过sion大神的鼠标脚本使用“打开菜单时将鼠标移动到光标处”这个功能时如何能不让光标锁定在 ...

楼主帮给看看呗脚本盲无力啊拜托{:2_249:}
回复

使用道具 举报

梦石
0
星屑
102
在线时间
402 小时
注册时间
2013-11-2
回帖
80
发表于 2015-2-9 20:35:13 | 显示全部楼层

楼主帮给看看呗脚本盲无力啊拜托
回复

使用道具 举报

梦石
0
星屑
701
在线时间
511 小时
注册时间
2012-4-8
回帖
193
 楼主| 发表于 2015-2-9 23:10:03 | 显示全部楼层
库拉托斯 发表于 2015-2-9 20:35
楼主帮给看看呗脚本盲无力啊拜托

搜索“方向键移动光标时将鼠标移动到对应的光标位置”,把那个def注释掉
武侠|养成|战棋游戏《以武证道》头秃开发中...
开发日记在此
回复

使用道具 举报

梦石
0
星屑
102
在线时间
402 小时
注册时间
2013-11-2
回帖
80
发表于 2015-2-10 21:46:32 | 显示全部楼层
黑白界 发表于 2015-2-9 23:10
搜索“方向键移动光标时将鼠标移动到对应的光标位置”,把那个def注释掉 ...

搜索出了很多行,应该注掉哪些?还有注释掉以后是不是连其他的光标到达菜单的功能也没有了啊?因为楼主的范例里调整那个功能的true或false已经不管用了
回复

使用道具 举报

梦石
0
星屑
50
在线时间
33 小时
注册时间
2015-5-15
回帖
10
发表于 2015-6-3 20:59:55 | 显示全部楼层
有没有RM XP的..........

点评

并没有。。  发表于 2015-6-3 23:40
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部