forked from Trivel/RMMV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMrTS_SimpleShopTax.js
102 lines (89 loc) · 3.07 KB
/
MrTS_SimpleShopTax.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//=============================================================================
// MrTS_SimpleShopTax.js
//=============================================================================
/*:
* @plugindesc Allows easy way to change prices for whole shop items at once.
* @author Mr. Trivel
*
* @help
* --------------------------------------------------------------------------------
* Terms of Use
* --------------------------------------------------------------------------------
* Don't remove the header or claim that you wrote this plugin.
* Credit Mr. Trivel if using this plugin in your project.
* Free for commercial and non-commercial projects.
* --------------------------------------------------------------------------------
* Version 1.1
* --------------------------------------------------------------------------------
**
* --------------------------------------------------------------------------------
* Plugin Commands
* --------------------------------------------------------------------------------
* SetTaxTo Buy [TAX]
* SetTaxTo Sell [TAX]
*
* Examples:
* SetTaxTo Buy 50
* SetTaxTo Buy -75
* SetTaxTo Sell 25
* SeTtAxTo Sell -50
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.1 - Added sell tax.
* 1.0 - Release
*/
(function() {
//--------------------------------------------------------------------------
// Game_Interpreter
//
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command.toLowerCase() === 'settaxto') {
switch(args[0].toUpperCase())
{
case 'BUY':
{
$gameSystem.setBuyTaxTo(Number(args[1]));
} break;
case 'SELL':
{
$gameSystem.setSellTaxTo(Number(args[1]));
}
}
}
};
//--------------------------------------------------------------------------
// Window_ShopBuy
//
var _WindowShopBuy_price = Window_ShopBuy.prototype.price;
Window_ShopBuy.prototype.price = function(item) {
var price = _WindowShopBuy_price.call(this, item);
price += Math.floor(price * $gameSystem.getBuyTax());
return price;
};
//--------------------------------------------------------------------------
// Scene_Shop
//
var _Scene_Shop_sellingPrice = Scene_Shop.prototype.sellingPrice;
Scene_Shop.prototype.sellingPrice = function() {
var sellingPrice = _Scene_Shop_sellingPrice.call(this);
return Math.max(0, sellingPrice - Math.floor(sellingPrice * $gameSystem.getSellTax()));
};
//--------------------------------------------------------------------------
// Game_System
//
Game_System.prototype.setBuyTaxTo = function(tax) {
this._shopBuyTax = tax;
};
Game_System.prototype.setSellTaxTo = function(tax) {
this._shopSellTax = tax;
};
Game_System.prototype.getBuyTax = function() {
return this._shopBuyTax/100 || 0;
};
Game_System.prototype.getSellTax = function() {
return this._shopSellTax/100 || 0;
};
})();