查看: 4649|回复: 2

[有事请教] 有插件能实现动态的物品价格吗?

[复制链接]
梦石
0
星屑
127
在线时间
8 小时
注册时间
2018-11-21
回帖
3
发表于 2019-1-7 12:59:12 | 显示全部楼层 |阅读模式

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

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

×
RT,有插件能实现动态的物品价格吗?
梦石
0
星屑
22799
在线时间
2623 小时
注册时间
2015-7-4
回帖
918
发表于 2019-1-7 13:52:10 | 显示全部楼层
商店的东西跟价格不是随时可以自定义的吗?还用得着插件?
捕获.JPG
回复

使用道具 举报

梦石
0
星屑
34511
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2019-1-8 09:34:00 | 显示全部楼层
本帖最后由 芯☆淡茹水 于 2019-1-8 09:47 编辑

一个个的指定,再条件分歧确实比较费工夫。
要随时改动价格也是比较简单,但还需要注意存取档的保存问题。

下面这个是不负责任的未测试。
插件命令:
物品打折 =>   ChangeItemPrice sym rate
sym :物品类型的标识(I:道具;W:武器;A:防具)
rate : 打折率,原价是 100, 超过100为加价。
比如: 所有武器打 85 折 => ChangeItemPrice W 85

价格还原 => RestoreItemPrice sym
sym :物品类型的标识(同上)

所有价格还原 => RestoreAllPrice


  1. //==================================================================================================================
  2. ;var XdRsData = XdRsData || {};
  3. XdRsData.floatingPrices = {};
  4. //==================================================================================================================
  5. XdRsData.floatingPrices.DMonLoad = DataManager.onLoad;
  6. DataManager.onLoad = function(object) {
  7.     XdRsData.floatingPrices.DMonLoad.call(this, object);
  8.     XdRsData.floatingPrices.setup(object);
  9. };
  10. XdRsData.floatingPrices.DMloadGame = DataManager.loadGame;
  11. DataManager.loadGame = function(savefileId) {
  12.     var loaded = XdRsData.floatingPrices.DMloadGame.call(this, savefileId);
  13.     loaded && XdRsData.floatingPrices.setupPrice();
  14.     return loaded;
  15. };
  16. //==================================================================================================================
  17. XdRsData.floatingPrices.isItemData = function(object) {
  18.     return object === $dataItems || object === $dataWeapons || object === $dataArmors;
  19. };
  20. XdRsData.floatingPrices.syms = function() {
  21.     return ['I','W','A'];
  22. };
  23. XdRsData.floatingPrices.setup = function(object) {
  24.     if (!this.isItemData(object)) return;
  25.     object.forEach(function(item){if (item) item.basePrice = item.price;});
  26. };
  27. XdRsData.floatingPrices.setupPrice = function() {
  28.     this.syms().forEach(function(sym){this.change(sym, $gameSystem.itemPriceData()[sym]);}, this);
  29. };
  30. XdRsData.floatingPrices.getObj = function(sym) {
  31.     switch (sym) {
  32.         case 'I' :return $dataItems;
  33.         case 'W' :return $dataWeapons;
  34.         case 'A' :return $dataArmors;
  35.     }
  36.     return [];
  37. };
  38. XdRsData.floatingPrices.change = function(sym, rate) {
  39.     this.getObj(sym).forEach(function(item){this.changeItemPrice(item, rate);}, this);
  40.     $gameSystem.saveItemPrices(sym, rate);
  41. };
  42. XdRsData.floatingPrices.changeItemPrice = function(item, rate) {
  43.     if (!item || !item.basePrice) return;
  44.     item.price = Math.max(Math.round(item.basePrice * rate / 100), 1);
  45. };
  46. XdRsData.floatingPrices.restore = function(sym) {
  47.     this.change(sym, 100);
  48. };
  49. XdRsData.floatingPrices.restoreAll = function() {
  50.     this.syms().forEach(function(sym){this.restore(sym);}, this);
  51. };
  52. //==================================================================================================================
  53. XdRsData.floatingPrices.GSinitialize = Game_System.prototype.initialize;
  54. Game_System.prototype.initialize = function() {
  55.     XdRsData.floatingPrices.GSinitialize.call(this);
  56.     this.restoreItemPrices();
  57. };
  58. Game_System.prototype.itemPriceData = function() {
  59.     return this._itemPrices;
  60. };
  61. Game_System.prototype.saveItemPrices = function(sym, rate) {
  62.     this._itemPrices[sym] = rate;
  63. };
  64. Game_System.prototype.restoreItemPrices = function() {
  65.     this._itemPrices = {'I':100,'W':100,'A':100};
  66. };
  67. //==================================================================================================================
  68. XdRsData.floatingPrices.GIpluginCommand = Game_Interpreter.prototype.pluginCommand;
  69. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  70.     XdRsData.floatingPrices.GIpluginCommand.call(this, command, args);
  71.     command === 'ChangeItemPrice'  && XdRsData.floatingPrices.change(''+args[0], +args[1]);
  72.     command === 'RestoreItemPrice' && XdRsData.floatingPrices.restore(''+args[0]);
  73.     command === 'RestoreAllPrice'  && XdRsData.floatingPrices.restoreAll();
  74. };
  75. //==================================================================================================================
  76. // end
  77. //==================================================================================================================
复制代码

评分

参与人数 1赞 +1 收起 理由
白嫩白嫩的 + 1 精品文章

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部