查看: 4838|回复: 10

[有事请教] 请问如何做到清空背包进入地图,搜刮地图,带回家里

[复制链接]
梦石
0
星屑
362
在线时间
102 小时
注册时间
2021-7-1
回帖
15
发表于 2021-7-5 18:48:51 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 DCASH45 于 2021-7-5 18:51 编辑

请问如何做出进一个关卡清空背包,然后退出关卡搜刮的物品都会带出来,放在进关卡前的背包,如果死亡则清空背包,返回出发前。
这种效果能做出来吗?
梦石
0
星屑
3136
在线时间
1444 小时
注册时间
2019-11-28
回帖
140
发表于 2021-7-5 21:40:32 | 显示全部楼层
变量A=物品A数量
变量B=物品B数量
……
……

物品A数量 减少 变量A
物品B数量 减少 变量B
……
……

出来之后
物品A数量 增加 变量A
物品B数量 增加 变量B
……
……


比较繁琐,应该能达到效果
回复 1 0

使用道具 举报

梦石
0
星屑
3036
在线时间
338 小时
注册时间
2020-6-14
回帖
77

极短22参与

发表于 2021-7-6 00:19:22 | 显示全部楼层
做应该能做,但是不是用事件。。至少也是把物品数据要用脚本保存一下吧
具体的我就不懂了,我对脚本一无所知等一个代码我也学习一下
回复

使用道具 举报

梦石
0
星屑
362
在线时间
102 小时
注册时间
2021-7-1
回帖
15
 楼主| 发表于 2021-7-6 00:43:02 | 显示全部楼层
Retsu 发表于 2021-7-5 21:40
变量A=物品A数量
变量B=物品B数量
……

刚刚去试了下,成功了,厉害,但是太多东西了,有没有可以实现这种功能的插件啊
回复

使用道具 举报

梦石
0
星屑
362
在线时间
102 小时
注册时间
2021-7-1
回帖
15
 楼主| 发表于 2021-7-6 00:43:47 | 显示全部楼层
鼠曲草 发表于 2021-7-6 00:19
做应该能做,但是不是用事件。。至少也是把物品数据要用脚本保存一下吧
具体的我就不懂了,我对脚本一无所 ...

2楼的大佬那个可以做,但是东西太多了,就没有那种插件吗
回复

使用道具 举报

梦石
0
星屑
387
在线时间
59 小时
注册时间
2021-6-30
回帖
19
发表于 2021-7-6 02:59:41 | 显示全部楼层
本帖最后由 QChan 于 2021-7-6 03:02 编辑

我试着做了个脚本,不太确定有没有什么BUG。
你丢到 js/plugins 里面,然后插件管理器启用这个插件。

然后就可以用插件指令了
1.png

插件指令有下面这些
qchan_saveitem save
保存当前背包, 并且清空背包
保存的物品信息会写到你的存档里。

qchan_saveitem clearsave
清除已经保存的物品

qchan_saveitem clearitems
清除当前背包物品

qchan_saveitem merge
qchan_saveitem merge2
把保存的物品合并到当前背包
merge 和 merge2 功能是一样的,merge 是独立的给予物品, merge2 是用系统自己的给予物品。
如果有装一些提醒获取物品的插件,用 merge2 可能会触发。


你可以进入关卡前用一下 qchan_saveitem save 保存背包,通关后出来后用一下 qchan_saveitem merge 合并背包。
如果是死亡的话可以用 qchan_saveitem clearitems 清空背包, 出来再用 qchan_saveitem merge 把旧背包恢复。


如果你有装 YEP_ItemCore 插件,那个插件的独立物品可能会无法保存,那边代码太多了,我暂时没弄懂,所以还没兼容。

QChan_SaveItem.rar

1.03 KB, 下载次数: 37

回复 2 0

使用道具 举报

梦石
0
星屑
362
在线时间
102 小时
注册时间
2021-7-1
回帖
15
 楼主| 发表于 2021-7-6 03:20:04 | 显示全部楼层
QChan 发表于 2021-7-6 02:59
我试着做了个脚本,不太确定有没有什么BUG。
你丢到 js/plugins 里面,然后插件管理器启用这个插件。

大佬大佬,可以加qq聊一聊吗!3156457306,谢谢你!!!
回复

使用道具 举报

梦石
0
星屑
7802
在线时间
683 小时
注册时间
2012-7-29
回帖
172
发表于 2021-7-6 03:33:09 | 显示全部楼层
本帖最后由 开关关 于 2021-7-6 06:01 编辑

哈哈,写完插件发现撞车了。_(:з」∠)_ 不过这个插件用起来和楼上的有点不同,还是发出来吧。
插件内容
  1. //=============================================================================
  2. // Kgg_AnotherItems.js
  3. //=============================================================================

  4. /*:
  5. * @plugindesc 另一个背包 AnotherItems
  6. * @author 开关关
  7. *
  8. * @help
  9. * Kgg:2021.7.6
  10. *
  11. * 该插件用于切换到另一个背包。
  12. * 另一个背包与原版背包功能完全相同,数据相互独立。切换后,另一个背包
  13. * 将代替原版背包。
  14. * 可以创建无数个相互独立的背包,只要名字不同即可互不干扰。
  15. *
  16. * 看到这篇帖子( [url]https://rpg.blue/thread-486245-1-1.html[/url] ),想到自己也
  17. * 可能需要,于是写了这个插件。
  18. * 其实估计已经有类似功能的插件了,不过我搜索能力比较差,没找到。
  19. *
  20. *
  21. * 用法:输入脚本
  22. *
  23. * 切换到(或新建)名字为name的背包
  24. * $gameParty.useAnotherItems(name);
  25. * name需要自行换成自己喜欢的名字。是字符串的话,记得要加引号。
  26. *
  27. * 切换到原版背包
  28. * $gameParty.useOriginalItems();
  29. *
  30. * 删除名字为name的背包
  31. * $gameParty.deleteAnotherItems(name);
  32. *
  33. * 合并当前背包与名字为name的背包
  34. * $gameParty.mixAnotherItems(name);
  35. *
  36. *
  37. * @param 另一个背包的金钱是否独立
  38. * @type boolean
  39. * @on 是
  40. * @off 否
  41. * @desc 若是,每个背包金钱数量独立记录。若否,所有背包共用金钱。
  42. * @default true

  43. */
  44. // 这部分是仿照Drill_up大佬的插件教程写的。
  45.         var Imported = Imported || {};                                        //导入识别类
  46.         Imported.Kgg_AnotherItems = true;                            //导入的插件标记
  47.         var Kgg = Kgg || {};                                                         //临时全局变量中转类
  48.     Kgg.parameters = PluginManager.parameters('Kgg_AnotherItems');
  49.     Kgg.AnotherItems_affectGold = Boolean(Kgg.parameters['另一个背包的金钱是否独立'] || "true") == "true";

  50. // 新增另一个背包
  51. Game_Party.prototype.addAnotherItems = function(name) {
  52.     if (!name) return;
  53.     this._anotherItems = this._anotherItems || {};
  54.     this._anotherItems[name] = {};
  55.     if (Kgg.AnotherItems_affectGold) this._anotherItems[name]['_gold'] = 0;
  56.     this._anotherItems[name]['_items'] = {};
  57.     this._anotherItems[name]['_weapons'] = {};
  58.     this._anotherItems[name]['_armors'] = {};
  59. };
  60. // 删除另一个背包
  61. Game_Party.prototype.deleteAnotherItems = function(name) {
  62.     this._anotherItems = this._anotherItems || {};
  63.     delete this._anotherItems[name];
  64. };
  65. // 切换到原版背包
  66. Game_Party.prototype.useOriginalItems = function() {
  67.     this._anotherItems = this._anotherItems || {};
  68.     // 存储另一个背包
  69.     if (this._nowItems) {
  70.         if (Kgg.AnotherItems_affectGold) this._anotherItems[this._nowItems]['_gold'] = this._gold;
  71.         this._anotherItems[this._nowItems]['_items'] = this._items;
  72.         this._anotherItems[this._nowItems]['_weapons'] = this._weapons;
  73.         this._anotherItems[this._nowItems]['_armors'] = this._armors;
  74.         // 修改标志
  75.         this._nowItems = '';
  76.         // 替换数据
  77.         if (Kgg.AnotherItems_affectGold) this._gold = this._itemsOriginal['_gold'];
  78.         this._items = this._itemsOriginal['_items'];
  79.         this._weapons = this._itemsOriginal['_weapons'];
  80.         this._armors = this._itemsOriginal['_armors'];
  81.     }
  82. };
  83. // 切换到另一个背包
  84. Game_Party.prototype.useAnotherItems = function(name) {
  85.     this._nowItems = this._nowItems || '';
  86.     this._anotherItems = this._anotherItems || {};
  87.     if (!name || this._nowItems == name) return;
  88.     if (!this._nowItems) { // 当前用的是原版背包
  89.         // 存储原版背包
  90.         this._itemsOriginal = {};
  91.         if (Kgg.AnotherItems_affectGold) this._itemsOriginal['_gold'] = this._gold;
  92.         this._itemsOriginal['_items'] = this._items;
  93.         this._itemsOriginal['_weapons'] = this._weapons;
  94.         this._itemsOriginal['_armors'] = this._armors;
  95.     } else { // 当前用的是另一个背包
  96.         this._anotherItems[this._nowItems] = {};
  97.         if (Kgg.AnotherItems_affectGold) this._anotherItems[this._nowItems]['_gold'] = this._gold;
  98.         this._anotherItems[this._nowItems]['_items'] = this._items;
  99.         this._anotherItems[this._nowItems]['_weapons'] = this._weapons;
  100.         this._anotherItems[this._nowItems]['_armors'] = this._armors;
  101.     }
  102.     // 修改标志
  103.     this._nowItems = name;
  104.     // 替换数据
  105.     if (name in this._anotherItems) { // 准备切换出来的背包有已经储存的数据
  106.         if (Kgg.AnotherItems_affectGold) this._gold = this._anotherItems[name]['_gold'];
  107.         this._items = this._anotherItems[name]['_items'];
  108.         this._weapons = this._anotherItems[name]['_weapons'];
  109.         this._armors = this._anotherItems[name]['_armors'];
  110.     } else { // 准备切换出来的背包名字不认识,是新来的背包
  111.         this.addAnotherItems(name);
  112.         if (Kgg.AnotherItems_affectGold) this._gold = 0;
  113.         this._items = {};
  114.         this._weapons = {};
  115.         this._armors = {};
  116.     }
  117. };
  118. // 合并当前背包与另一个背包
  119. Game_Party.prototype.mixAnotherItems = function(name) {
  120.     this._anotherItems = this._anotherItems || {};
  121.     if (!name || this._nowItems == name || !(name in this._anotherItems)) return;
  122.     // 金钱合并
  123.     if (Kgg.AnotherItems_affectGold) this._gold += this._anotherItems[name]['_gold'];
  124.     // 其他合并
  125.     let objectNeedMix = ['_items','_weapons','_armors'];
  126.     for (let i = 0; i < objectNeedMix.length; i++) {
  127.         // 该段代码来自[url]https://segmentfault.com/q/1010000021272211[/url]
  128.         let temp = {...this[objectNeedMix[i]], ...this._anotherItems[name][objectNeedMix[i]]};
  129.         Object.keys(temp).forEach(key => {
  130.             temp[key] = (this[objectNeedMix[i]][key] || 0) + (this._anotherItems[name][objectNeedMix[i]][key] || 0);
  131.         });
  132.         this[objectNeedMix[i]] = temp;
  133.     }
  134. };
  135. //=============================================================================
  136. // End
  137. //=============================================================================
复制代码




具体到楼主这个案例,用法就是:

进一个关卡时,需要切换到另一个背包,这里就暂且命名为a吧。
  1. $gameParty.useAnotherItems("a");
复制代码

顺利打通关卡,则切换回原版背包,然后将背包a合并到原版背包,最后清空背包a。
  1. $gameParty.useOriginalItems();
  2. $gameParty.mixAnotherItems("a");
  3. $gameParty.deleteAnotherItems("a");
复制代码

如果半路失败了,失败退出关卡,则切换回原版背包,不合并,直接清空背包a。
  1. $gameParty.useOriginalItems();
  2. $gameParty.deleteAnotherItems("a");
复制代码

评分

参与人数 1赞 +1 收起 理由
微笑的迪妮莎 + 1 精品文章

查看全部评分

回复 1 0

使用道具 举报

梦石
0
星屑
362
在线时间
102 小时
注册时间
2021-7-1
回帖
15
 楼主| 发表于 2021-7-6 04:28:59 | 显示全部楼层
开关关 发表于 2021-7-6 03:33
哈哈,写完插件发现撞车了。_(:з」∠)_ 不过这个插件用起来和楼上的有点不同,还是发出来吧。
[fold=插件 ...

谢谢大哥!!!

点评

不用谢!刚刚发现我把用法写错了,现在已经改正。  发表于 2021-7-6 05:48
回复

使用道具 举报

梦石
0
星屑
362
在线时间
102 小时
注册时间
2021-7-1
回帖
15
 楼主| 发表于 2022-7-23 16:51:37 | 显示全部楼层
QChan 发表于 2021-7-6 02:59
我试着做了个脚本,不太确定有没有什么BUG。
你丢到 js/plugins 里面,然后插件管理器启用这个插件。

大佬在吗,最近做游戏遇到很多困难,希望可以得到您的帮助!我发现找不到你的QQ了,可以发给我嘛谢谢麻烦了
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部