-
Notifications
You must be signed in to change notification settings - Fork 5
/
Kru_SkillCore.js
73 lines (65 loc) · 2.19 KB
/
Kru_SkillCore.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
//=============================================================================
// Krusynth Skill Core
// Version: 1.0.0
//=============================================================================
/*:
* @plugindesc Shared base for Krusynth skill-related plugins
*
* @author Krusynth
*
* @param ---General---
* @default
*
* @help
* ============================================================================
* Information
* ============================================================================
*
* This is the base include for many Krusynth RPG Maker MV skill plugins. It
* extends the core engine for better skill cost calculations. Skills can now
* have an HP cost as well.
*/
var Imported = Imported || {};
Imported.Kru_SkillCore = "1.0.0";
var Kru = Kru || {};
Kru.SC = {};
// Cost adjustment
Kru.SC.Game_BattlerBase___paySkillCost = Game_BattlerBase.prototype.paySkillCost;
Game_BattlerBase.prototype.paySkillCost = function(skill) {
this._hp -= this.skillHpCost(skill);
this._mp -= this.skillMpCost(skill);
this._tp -= this.skillTpCost(skill);
// TODO: allow any arbitrary cost in skill meta.
};
Game_BattlerBase.prototype.canPaySkillCost = function(skill) {
return this._tp >= this.skillTpCost(skill) &&
this._mp >= this.skillMpCost(skill) &&
this._hp >= this.skillHpCost(skill);
};
Kru.SC.Game_BattlerBase___skillMpCost = Game_BattlerBase.prototype.skillMpCost;
Game_BattlerBase.prototype.skillMpCost = function(item) {
let cost = Kru.SC.Game_BattlerBase___skillMpCost.call(this, item);
let skill = this._stskills[item.id];
if(item.meta.cost && item.meta.cost.mp) {
let a = this;
eval(item.meta.cost.mp);
}
return cost;
};
Kru.SC.Game_BattlerBase___skillTpCost = Game_BattlerBase.prototype.skillTpCost;
Game_BattlerBase.prototype.skillTpCost = function(item) {
let cost = Kru.SC.Game_BattlerBase___skillTpCost.call(this, item);
let a = this;
if(item.meta.cost && item.meta.cost.tp) {
eval(item.meta.cost.tp);
}
return cost;
};
// This doesn't exist in the core engine.
Game_BattlerBase.prototype.skillHpCost = function(item) {
let cost = item.hpCost || 0;
if(item.meta.cost && item.meta.cost.hp) {
eval(item.meta.cost.hp);
}
return cost;
};