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

Project1

 找回密码
 注册会员
搜索
查看: 4042|回复: 9
打印 上一主题 下一主题

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
701
在线时间
511 小时
注册时间
2012-4-8
帖子
255
跳转到指定楼层
1
发表于 2015-2-9 07:10:06 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 黑白界 于 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:}

脚本特别乱,毕竟是凑得

RUBY 代码复制
  1. #=========================================================================
  2. #======随身背包============================================================
  3. #============================================================================
  4. $icon_wupin=    260  #物品图标的编号
  5. $icon_wuqi=     386  #武器图标的编号
  6. $icon_hujia=    308  #护甲图标的编号
  7. $icon_guizhong= 358  #贵重物品图标的编号
  8. #==============================================================================
  9. # ** Window_MapStatus
  10. #==============================================================================
  11. class Window_MapStatus < Window_Command
  12.   #----------------------------------------------------------------------------
  13.   # * 初始化
  14.   #----------------------------------------------------------------------------
  15.   def initialize
  16.     @command_icon_index = [$icon_wupin]
  17.     super(Graphics.width-48, Graphics.height-48)
  18.   end
  19.   #----------------------------------------------------------------------------
  20.   # * 获取窗口宽度
  21.   #----------------------------------------------------------------------------
  22.   def window_width
  23.   return 48
  24.   end
  25.   #----------------------------------------------------------------------------
  26.   # * 创建命令列表
  27.   #----------------------------------------------------------------------------
  28.   def make_command_list
  29.   add_command(Vocab::item,:item,  true)
  30.   end
  31.  
  32.   def draw_item(index)
  33.     rect = item_rect_for_text(index)
  34.     draw_icon(@command_icon_index[index], rect.x-5, rect.y)
  35.   end
  36. end
  37.  
  38. #==============================================================================
  39. # ** Scene_Map
  40. #==============================================================================
  41. class Scene_Map<Scene_Base
  42.   #----------------------------------------------------------------------------
  43.   # * 重命名方法
  44.   #----------------------------------------------------------------------------
  45.   alias o_start start
  46.   #----------------------------------------------------------------------------
  47.   # * 开始处理
  48.   #----------------------------------------------------------------------------
  49.   def start
  50.     o_start
  51.     create_menu_window
  52.   end
  53.  
  54.   def create_menu_window
  55.  
  56.     @menu_command = Window_MapStatus.new
  57.     @menu_command.set_handler(:item  ,    method(:item_ok))
  58.  
  59.   end
  60.   def item_ok
  61.     SceneManager.call(Scene_NewItem)
  62.   end
  63. end
  64. #------------------------------------------------------------------------------
  65. #  物品画面和商店画面中,显示装备、所持物品等项目列表的窗口。
  66. #==============================================================================
  67.  
  68. class Window_NewItemCategory < Window_HorzCommand
  69.   #--------------------------------------------------------------------------
  70.   # ● 定义实例变量
  71.   #--------------------------------------------------------------------------
  72.   attr_reader   :item_window
  73.   #--------------------------------------------------------------------------
  74.   # ● 初始化对象
  75.   #--------------------------------------------------------------------------
  76.   def initialize
  77.     @command_icon_index = [$icon_wupin,$icon_wuqi,$icon_hujia,$icon_guizhong]
  78.     super(Graphics.width-220, Graphics.height-368)
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 获取窗口的宽度
  82.   #--------------------------------------------------------------------------
  83.   def window_width
  84.     220
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 获取列数
  88.   #--------------------------------------------------------------------------
  89.   def col_max
  90.     return 4
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 更新画面
  94.   #--------------------------------------------------------------------------
  95.   def update
  96.     super
  97.     @item_window.category = current_symbol if @item_window
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 生成指令列表
  101.   #--------------------------------------------------------------------------
  102.   def make_command_list
  103.     add_command(Vocab::item,     :item)
  104.     add_command(Vocab::weapon,   :weapon)
  105.     add_command(Vocab::armor,    :armor)
  106.     add_command(Vocab::key_item, :key_item)
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● 设置物品窗口
  110.   #--------------------------------------------------------------------------
  111.   def item_window=(item_window)
  112.     @item_window = item_window
  113.     update
  114.   end
  115.     def draw_item(index)
  116.     rect = item_rect_for_text(index)
  117.     draw_icon(@command_icon_index[index], rect.x+5, rect.y)
  118.   end
  119. end
  120.  
  121. #encoding:utf-8
  122. #==============================================================================
  123. # ■ Window_NewItemList
  124. #------------------------------------------------------------------------------
  125. #  物品画面中,显示持有物品的窗口。
  126. #==============================================================================
  127.  
  128. class Window_NewItemList < Window_Selectable
  129.   #--------------------------------------------------------------------------
  130.   # ● 初始化对象
  131.   #--------------------------------------------------------------------------
  132.   def initialize(x, y, width, height)
  133.     super(Graphics.width-220,Graphics.height-326,220,278)
  134.     @category = :none
  135.     @data = []
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # ● 设置分类
  139.   #--------------------------------------------------------------------------
  140.   def category=(category)
  141.     return if @category == category
  142.     @category = category
  143.     refresh
  144.     self.oy = 0
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ● 获取列数
  148.   #--------------------------------------------------------------------------
  149.   def col_max
  150.     return 4
  151.   end
  152.  
  153.   #--------------------------------------------------------------------------
  154.   # ● 获取项目数
  155.   #--------------------------------------------------------------------------
  156.   def item_max
  157.     @data ? @data.size : 1
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● 获取物品
  161.   #--------------------------------------------------------------------------
  162.   def item
  163.     @data && index >= 0 ? @data[index] : nil
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 获取选择项目的有效状态
  167.   #--------------------------------------------------------------------------
  168.   def current_item_enabled?
  169.     enable?(@data[index])
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 查询列表中是否含有此物品
  173.   #--------------------------------------------------------------------------
  174.   def include?(item)
  175.     case @category
  176.     when :item
  177.       item.is_a?(RPG::Item) && !item.key_item?
  178.     when :weapon
  179.       item.is_a?(RPG::Weapon)
  180.     when :armor
  181.       item.is_a?(RPG::Armor)
  182.     when :key_item
  183.       item.is_a?(RPG::Item) && item.key_item?
  184.     else
  185.       false
  186.     end
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 查询此物品是否可用
  190.   #--------------------------------------------------------------------------
  191.   def enable?(item)
  192.     $game_party.usable?(item)
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ● 生成物品列表
  196.   #--------------------------------------------------------------------------
  197.   def make_item_list
  198.     @data = $game_party.all_items.select {|item| include?(item) }
  199.     @data.push(nil) if include?(nil)
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # ● 返回上一个选择的位置
  203.   #--------------------------------------------------------------------------
  204.   def select_last
  205.     select(@data.index($game_party.last_item.object) || 0)
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 绘制项目
  209.   #--------------------------------------------------------------------------
  210.   def draw_item(index)
  211.     item = @data[index]
  212.     if item
  213.       rect = item_rect(index)
  214.       rect.width -= 4
  215.        color = Color.new(40, 40, 40)
  216.       self.contents.fill_rect(rect.x, rect.y, 24, 1, color)
  217.       self.contents.fill_rect(rect.x, rect.y, 1, 24, color)
  218.       self.contents.fill_rect(rect.x, rect.y+23, 24, 1, color)
  219.       self.contents.fill_rect(rect.x+23, rect.y, 1, 24, color)
  220.       draw_icon(item.icon_index,rect.x,rect.y,enable?(item))
  221.       rect.width += 9
  222.       rect.height += 14
  223.       draw_item_number(rect, item)
  224.     end
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ● 绘制物品个数
  228.   #--------------------------------------------------------------------------
  229.   def draw_item_number(rect, item)
  230.     draw_text(rect, sprintf("%2d", $game_party.item_number(item)), 2)
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 刷新
  234.   #--------------------------------------------------------------------------
  235.   def refresh
  236.     make_item_list
  237.     create_contents
  238.     draw_all_items
  239.   end
  240. end
  241. #encoding:utf-8
  242. #==============================================================================
  243. # ■ Scene_Item
  244. #------------------------------------------------------------------------------
  245. #  物品画面
  246. #==============================================================================
  247.  
  248. class Scene_NewItem < Scene_ItemBase
  249.   #--------------------------------------------------------------------------
  250.   # ● 开始处理
  251.   #--------------------------------------------------------------------------
  252.   def start
  253.     super
  254.     create_menu_window2
  255.     create_category_window
  256.     create_item_window
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ● 生成分类窗口
  260.   #--------------------------------------------------------------------------
  261.   def create_category_window
  262.     @category_window = Window_NewItemCategory.new
  263.     @category_window.viewport = @viewport
  264.     @category_window.set_handler(:ok,     method(:on_category_ok))
  265.     @category_window.set_handler(:cancel, method(:return_scene))
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # ● 生成物品窗口
  269.   #--------------------------------------------------------------------------
  270.   def create_item_window
  271.     wy = @category_window.y + @category_window.height
  272.     wh = Graphics.height
  273.     @item_window = Window_NewItemList.new(0, wy, Graphics.width, wh)
  274.     @item_window.viewport = @viewport
  275.     @item_window.set_handler(:ok,     method(:on_item_ok))
  276.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  277.     @category_window.item_window = @item_window
  278.   end
  279.  
  280.   #--------------------------------------------------------------------------
  281.   # ● 分类“确定”
  282.   #--------------------------------------------------------------------------
  283.   def on_category_ok
  284.     @item_window.activate
  285.     @item_window.select_last
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ● 物品“确定”
  289.   #--------------------------------------------------------------------------
  290.   def on_item_ok
  291.     $game_party.last_item.object = item
  292.     determine_item
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # ● 物品“取消”
  296.   #--------------------------------------------------------------------------
  297.   def on_item_cancel
  298.     @item_window.unselect
  299.     @category_window.activate
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● 播放使用物品声效
  303.   #--------------------------------------------------------------------------
  304.   def play_se_for_item
  305.     Sound.play_use_item
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # ● 使用物品
  309.   #--------------------------------------------------------------------------
  310.   def use_item
  311.     super
  312.     @item_window.redraw_current_item
  313.   end
  314.   def create_menu_window2
  315.  
  316.     @menu_command = Window_MapStatus.new
  317.     @menu_command.set_handler(:ok , method(:return_scene ))
  318.  
  319.   end
  320. end


安装装备帮助增强后,用下面代码作兼容
RUBY 代码复制
  1. #装备栏
  2.  
  3. module VIPArcher::Equipplus
  4.  
  5.   TIME = 0
  6.  
  7. end
  8.  
  9. class Scene_NewItem < Scene_ItemBase
  10.  
  11.   #--------------------------------------------------------------------------
  12.  
  13.   # ● 开始处理
  14.  
  15.   #--------------------------------------------------------------------------
  16.  
  17.   alias help_ex_start start
  18.  
  19.   def start
  20.  
  21.     help_ex_start
  22.  
  23.     create_help_ex
  24.  
  25.   end
  26.  
  27. end

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

BEIBAO1.png (68.97 KB, 下载次数: 32)

BEIBAO1.png

BEIBAO2.png (90.82 KB, 下载次数: 30)

BEIBAO2.png

随身背包.zip

1.67 MB, 下载次数: 169

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

Lv3.寻梦者

火烧大神

梦石
0
星屑
1813
在线时间
941 小时
注册时间
2012-1-1
帖子
1777
2
发表于 2015-2-9 13:20:54 | 只看该作者
好厉害,以前有学过其他语言的基础吗?

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

使用道具 举报

Lv2.观梦者

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

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

使用道具 举报

Lv1.梦旅人

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

使用道具 举报

Lv2.观梦者

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

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

使用道具 举报

Lv1.梦旅人

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

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
102
在线时间
402 小时
注册时间
2013-11-2
帖子
104
7
发表于 2015-2-9 20:35:13 | 只看该作者

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

使用道具 举报

Lv2.观梦者

梦石
0
星屑
701
在线时间
511 小时
注册时间
2012-4-8
帖子
255
8
 楼主| 发表于 2015-2-9 23:10:03 | 只看该作者
库拉托斯 发表于 2015-2-9 20:35
楼主帮给看看呗脚本盲无力啊拜托

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

使用道具 举报

Lv1.梦旅人

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

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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
33 小时
注册时间
2015-5-15
帖子
18
10
发表于 2015-6-3 20:59:55 | 只看该作者
有没有RM XP的..........

点评

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-22 01:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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