forked from Trivel/RMMV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMrTS_MaxLevelRestriction.js
165 lines (146 loc) · 5.23 KB
/
MrTS_MaxLevelRestriction.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//=============================================================================
// MrTS_MaxLevelRestriction.js
//=============================================================================
/*:
* @plugindesc Allows restricting and lifting actor, class and global max level.
* @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.0
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Plugin Commands
* --------------------------------------------------------------------------------
* MaxLevel GlobalSet [LEVEL] - sets global max level restriction to [LEVEL]
* MaxLevel GlobalLift - removes global max level restriction
*
* MaxLevel ActorSet [LEVEL] [ID] - sets max level restriction to [ID] of actor
* MaxLevel ActorLift [ID] - removes actor max level restriction
*
* MaxLevel ClassSet [LEVEL] [ID] - sets max level restriction to [ID] of class
* MaxLevel ClassLift [ID] - removes class max level restriction
*
* [LEVEL] - what is the new max level
* [ID] - actor or class ID
*
* Examples:
* MaxLevel GlobalSet 10
* MaxLevel GlobalLift
*
* Maxlevel ActorSet 20 5
* Maxlevel ActorLift
*
* MaxLevel ClassSet 30 7
* Maxlevel ClassLift
*
* Priority:
* In case of multiple restrictions (default, global, actor, class) the lowest
* value one will be used.
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 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() === "maxlevel") {
switch (args[0].toUpperCase())
{
case 'GLOBALSET':
{
$gameSystem.setGlobalMaxLevelRestriction(Number(args[1]));
} break;
case 'GLOBALLIFT':
{
$gameSystem.liftGlobalMaxLevelRestriction();
} break;
case 'ACTORSET':
{
$gameSystem.setActorMaxLevelRestriction(Number(args[1]), Number(args[2]));
} break;
case 'ACTORLIFT':
{
$gameSystem.liftActorMaxLevelRestriction(Number(args[1]));
} break;
case 'CLASSSET':
{
$gameSystem.setClassMaxLevelRestriction(Number(args[1]), Number(args[2]));
} break;
case 'CLASSLIFT':
{
$gameSystem.liftClassMaxLevelRestriction(Number(args[1]));
} break;
}
}
};
//--------------------------------------------------------------------------
// Game_System
//
var _Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
_Game_System_initialize.call(this);
this._maxLevelRestrictGlobal = -1;
this._maxLevelRestrictActor = {};
this._maxLevelRestrictClass = {};
};
Game_System.prototype.setGlobalMaxLevelRestriction = function(value) {
this._maxLevelRestrictGlobal = value;
};
Game_System.prototype.liftGlobalMaxLevelRestriction = function() {
this._maxLevelRestrictGlobal = -1;
};
Game_System.prototype.setActorMaxLevelRestriction = function(value, id) {
this._maxLevelRestrictActor[id] = value;
};
Game_System.prototype.liftActorMaxLevelRestriction = function(id) {
delete this._maxLevelRestrictActor[id];
};
Game_System.prototype.setClassMaxLevelRestriction = function(value, id) {
this._maxLevelRestrictClass[id] = value;
};
Game_System.prototype.liftClassMaxLevelRestriction = function(id) {
delete this._maxLevelRestrictClass[id];
};
Game_System.prototype.getGlobalMaxLevelRestriction = function() {
return this._maxLevelRestrictGlobal;
};
Game_System.prototype.getActorMaxLevelRestriction = function(id) {
return this._maxLevelRestrictActor[id];
};
Game_System.prototype.getClassMaxLevelRestriction = function(id) {
return this._maxLevelRestrictClass[id];
};
//--------------------------------------------------------------------------
// Game_Actor
//
var _Game_Actor_maxlevel = Game_Actor.prototype.maxLevel;
Game_Actor.prototype.maxLevel = function() {
var aId = this.actorId();
var cId = this._classId;
var levelArray = [];
var defaultLimit = _Game_Actor_maxlevel.call(this);
var globalLimit = $gameSystem.getGlobalMaxLevelRestriction();
var actorLimit = $gameSystem.getActorMaxLevelRestriction(aId);
var classLimit = $gameSystem.getClassMaxLevelRestriction(cId);
levelArray.push(defaultLimit);
if (globalLimit > -1) levelArray.push(globalLimit);
if (actorLimit) levelArray.push(actorLimit);
if (classLimit) levelArray.push(classLimit);
return Math.min.apply(null, levelArray);
};
})();