forked from Trivel/RMMV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMrTS_RestoreHpMpTp.js
122 lines (112 loc) · 4.28 KB
/
MrTS_RestoreHpMpTp.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
//=============================================================================
// MrTS_RestoreHpMpTp.js
//=============================================================================
/*:
* @plugindesc Allows to have equipment/states that restore HP/MP/TP after battles or level ups.
* @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
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Trait Objects Tags (Actor/Class/Weapon/Armor/State)
* --------------------------------------------------------------------------------
* HP:
* <RestoreAfterBattleHP: [AMOUNT]>
* <RestoreAfterBattleHPPercent: [PERCENT AMOUNT]>
*
* <RestoreAfterLevelUpHP: [AMOUNT]>
* <RestoreAfterLevelUpHPPercent: [PERCENT AMOUNT]>
*
* MP:
* <RestoreAfterBattleMP: [AMOUNT]>
* <RestoreAfterBattleMPPercent: [PERCENT AMOUNT]>
*
* <RestoreAfterLevelUpMP: [AMOUNT]>
* <RestoreAfterLevelUpMPPercent: [PERCENT AMOUNT]>
*
* TP:
* <RestoreAfterBattleTP: [AMOUNT]>
* <RestoreAfterBattleTPPercent: [PERCENT AMOUNT]>
*
* <RestoreAfterLevelUpTP: [AMOUNT]>
* <RestoreAfterLevelUpTPPercent: [PERCENT AMOUNT]>
*
* RestoreAfterBattle - restores HP/MP/TP after a won battle.
* RestoreAfterLevelUp - restores HP/MP/TP after a level up.
* [AMOUNT] - flat amount E.g. 10, 100, 1000, 50, 37
* [PERCENT AMOUNT] - uses floating point E.g. 0.53 being 53%, 1.0 being 100%
*
* Examples:
* <RestoreAfterBattleTP: 50>
* <RestoreAfterBattleHP: 15>
* <RestoreAfterBattleHPPercent: 0.05>
* <RestoreAfterBattleMPPercent: 0.10>
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.0 - Release
*/
(function() {
Game_Actor.prototype.restoreAfterType = function(type) {
var valueHp = 0;
var valueHpP = 0.0;
var valueMp = 0;
var valueMpP = 0.0;
var valueTp = 0;
var valueTpP = 0.0;
var traitObjects = this.traitObjects();
for (var i = 0; i < traitObjects.length; i++) {
switch(type)
{
case 'battle':
{
valueHp += Number(traitObjects[i].meta.RestoreAfterBattleHP) || 0;
valueHpP += Number(traitObjects[i].meta.RestoreAfterBattleHPPercent) || 0;
valueMp += Number(traitObjects[i].meta.RestoreAfterBattleMP) || 0;
valueMpP += Number(traitObjects[i].meta.RestoreAfterBattleMPPercent) || 0;
valueTp += Number(traitObjects[i].meta.RestoreAfterBattleTP) || 0;
valueTpP += Number(traitObjects[i].meta.RestoreAfterBattleTPPercent) || 0;
} break;
case 'levelup':
{
valueHp += Number(traitObjects[i].meta.RestoreAfterLevelUpHP) || 0;
valueHpP += Number(traitObjects[i].meta.RestoreAfterLevelUpHPPercent) || 0;
valueMp += Number(traitObjects[i].meta.RestoreAfterLevelUpMP) || 0;
valueMpP += Number(traitObjects[i].meta.RestoreAfterLevelUpMPPercent) || 0;
valueTp += Number(traitObjects[i].meta.RestoreAfterLevelUpTP) || 0;
valueTpP += Number(traitObjects[i].meta.RestoreAfterLevelUpTPPercent) || 0;
} break;
}
}
var totalHp = valueHp + Math.floor(this.mhp * valueHpP);
var totalMp = valueMp + Math.floor(this.mmp * valueMpP);
var totalTp = valueTp + Math.floor(100 * valueTpP);
console.log(valueHp, valueMp, valueTp);
this.gainHp(totalHp);
this.gainMp(totalMp);
this.gainTp(totalTp);
};
var _GameActor_levelUp = Game_Actor.prototype.levelUp;
Game_Actor.prototype.levelUp = function() {
_GameActor_levelUp.call(this);
this.restoreAfterType('levelup');
};
var _BattleManager_processVictory = BattleManager.processVictory;
BattleManager.processVictory = function() {
_BattleManager_processVictory.call(this);
for (var i = 0; i < $gameParty.battleMembers().length; i++) {
$gameParty.battleMembers()[i].restoreAfterType('battle');
}
};
})();