| 赞 | 664 |
| VIP | |
| 好人卡 | |
| 积分 | 345 |
| 经验 | |
| 最后登录 | 2024-7-10 |
| 在线时间 | 5096 小时 |
- 梦石
- 0
- 星屑
- 34464
- 在线时间
- 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
[pre lang="javascript"]//==================================================================================================================
;var XdRsData = XdRsData || {};
XdRsData.floatingPrices = {};
//==================================================================================================================
XdRsData.floatingPrices.DMonLoad = DataManager.onLoad;
DataManager.onLoad = function(object) {
XdRsData.floatingPrices.DMonLoad.call(this, object);
XdRsData.floatingPrices.setup(object);
};
XdRsData.floatingPrices.DMloadGame = DataManager.loadGame;
DataManager.loadGame = function(savefileId) {
var loaded = XdRsData.floatingPrices.DMloadGame.call(this, savefileId);
loaded && XdRsData.floatingPrices.setupPrice();
return loaded;
};
//==================================================================================================================
XdRsData.floatingPrices.isItemData = function(object) {
return object === $dataItems || object === $dataWeapons || object === $dataArmors;
};
XdRsData.floatingPrices.syms = function() {
return ['I','W','A'];
};
XdRsData.floatingPrices.setup = function(object) {
if (!this.isItemData(object)) return;
object.forEach(function(item){if (item) item.basePrice = item.price;});
};
XdRsData.floatingPrices.setupPrice = function() {
this.syms().forEach(function(sym){this.change(sym, $gameSystem.itemPriceData()[sym]);}, this);
};
XdRsData.floatingPrices.getObj = function(sym) {
switch (sym) {
case 'I' :return $dataItems;
case 'W' :return $dataWeapons;
case 'A' :return $dataArmors;
}
return [];
};
XdRsData.floatingPrices.change = function(sym, rate) {
this.getObj(sym).forEach(function(item){this.changeItemPrice(item, rate);}, this);
$gameSystem.saveItemPrices(sym, rate);
};
XdRsData.floatingPrices.changeItemPrice = function(item, rate) {
if (!item || !item.basePrice) return;
item.price = Math.max(Math.round(item.basePrice * rate / 100), 1);
};
XdRsData.floatingPrices.restore = function(sym) {
this.change(sym, 100);
};
XdRsData.floatingPrices.restoreAll = function() {
this.syms().forEach(function(sym){this.restore(sym);}, this);
};
//==================================================================================================================
XdRsData.floatingPrices.GSinitialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
XdRsData.floatingPrices.GSinitialize.call(this);
this.restoreItemPrices();
};
Game_System.prototype.itemPriceData = function() {
return this._itemPrices;
};
Game_System.prototype.saveItemPrices = function(sym, rate) {
this._itemPrices[sym] = rate;
};
Game_System.prototype.restoreItemPrices = function() {
this._itemPrices = {'I':100,'W':100,'A':100};
};
//==================================================================================================================
XdRsData.floatingPrices.GIpluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
XdRsData.floatingPrices.GIpluginCommand.call(this, command, args);
command === 'ChangeItemPrice' && XdRsData.floatingPrices.change(''+args[0], +args[1]);
command === 'RestoreItemPrice' && XdRsData.floatingPrices.restore(''+args[0]);
command === 'RestoreAllPrice' && XdRsData.floatingPrices.restoreAll();
};
//==================================================================================================================
// end
//==================================================================================================================[/pre] |
评分
-
查看全部评分
|