Skip to content

Instantly share code, notes, and snippets.

@Sivli-Embir
Created August 11, 2017 18:52
Show Gist options
  • Select an option

  • Save Sivli-Embir/a21e4ec0b1a200f16076d779d9f73b01 to your computer and use it in GitHub Desktop.

Select an option

Save Sivli-Embir/a21e4ec0b1a200f16076d779d9f73b01 to your computer and use it in GitHub Desktop.
diff --git a/YEP_EnhancedTP.js b/SIV_EnhancedTP.js
index 0c5a4bf..58ca159 100644
--- a/YEP_EnhancedTP.js
+++ b/SIV_EnhancedTP.js
@@ -2854,6 +2854,10 @@ Game_BattlerBase.prototype.initTpMode = function() {
this._tpMode = this.enemy().tpMode;
this._unlockedTpModes = this.enemy().unlockedTpModes.slice();
}
+ if (this.pendingInit.length) {
+ this._unlockedTpModes = this._unlockedTpModes.concat(this.pendingInit)
+ }
this._unlockedTpModes = this._unlockedTpModes.filter(Yanfly.Util.onlyUnique);
this._unlockedTpModes.sort(function(a, b) { return a - b; });
};
@@ -2889,11 +2893,14 @@ Game_BattlerBase.prototype.tpRate = function() {
};
Game_BattlerBase.prototype.unlockTpMode = function(tpModeId) {
- if (!this._unlockedTpModes) this.initTpMode();
- this._unlockedTpModes.push(tpModeId);
- this._unlockedTpModes = this._unlockedTpModes.filter(Yanfly.Util.onlyUnique);
- this._unlockedTpModes.sort(function(a, b) { return a - b; });
- this.refresh();
+ if (this._unlockedTpModes) {
+ this._unlockedTpModes.push(tpModeId);
+ this._unlockedTpModes = this._unlockedTpModes.filter(Yanfly.Util.onlyUnique);
+ this._unlockedTpModes.sort(function(a, b) { return a - b; });
+ this.refresh();
+ } else {
+ this.pendingInit.push(tpModeId)
+ }
};
Game_BattlerBase.prototype.removeTpMode = function(tpModeId) {
@@ -3123,6 +3130,7 @@ Game_Battler.prototype.chargeTpByDeath = function() {
Yanfly.ETP.Game_Actor_setup = Game_Actor.prototype.setup;
Game_Actor.prototype.setup = function(actorId) {
+ this.pendingInit = [];
Yanfly.ETP.Game_Actor_setup.call(this, actorId);
this.initTpMode();
};
@@ -3137,7 +3145,7 @@ Game_Actor.prototype.learnSkill = function(skillId) {
Game_Actor.prototype.learnSkillTpMode = function(skill) {
var length = skill.learnUnlockedTpModes.length;
for (var i = 0; i < length; ++i) {
- var tpMode = skill.learnUnlockedTpModes[tpMode]
+ var tpMode = skill.learnUnlockedTpModes[i];
if ($dataTpModes[tpMode]) this.unlockTpMode(tpMode);
}
};
@@ -3148,8 +3156,9 @@ Game_Actor.prototype.learnSkillTpMode = function(skill) {
Yanfly.ETP.Game_Enemy_setup = Game_Enemy.prototype.setup;
Game_Enemy.prototype.setup = function(enemyId, x, y) {
- Yanfly.ETP.Game_Enemy_setup.call(this, enemyId, x, y);
- this.initTpMode();
+ this.pendingInit = []
+ Yanfly.ETP.Game_Enemy_setup.call(this, enemyId, x, y);
+ this.initTpMode();
};
//=============================================================================
@Sivli-Embir

Copy link
Copy Markdown
Author

Line 47 has for loop var issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment