//=============================================================================
// ST0RMTiger - ActorMPGaugeNames
// ST0RM_ActorMPGaugeNames.js
//=============================================================================
var Imported = Imported || {};
Imported.ST0RM_ActorMPGaugeNames = true;
var ST0RM = ST0RM || {};
ST0RM.ActorMPGaugeNames = ST0RM.ActorMPGaugeNames || {};
//=============================================================================
/*:
* @plugindesc v0.1.1
* Customize Names and Colors for MP and it's Gauge for each Actor
* (even in being in the same class!)
*
* @author ST0RMTiger
*
* @param Region 1
* @parent ---Regions 1 to 20---
* @type boolean
* @desc Set region to trigger RegionEvents only at Button OK.
* @default false
*
* @param ActorMPGaugeConfig
* @type struct<Actor>[]
*
* @help
* ============================================================================
* Introduction and Instructions
* ============================================================================
*
* This plugin lets you Choose Names for MP Gauge for each Actor.
*
* Define Names in the Plugin Parameters using the Actor IDs from the Database.
*
* ============================================================================
* Notetags
* ============================================================================
*
* For compatibility with YEP_SkillCore you have to put ST0RM_ActorGaugeNames
* ABOVE the YEP_SkillCore plugin!
* (Reason: The YEP-Plugin does some changes only on screen instead of
* "really" changing gauges if you swap gauges with that plugin.
* If you'd put the YEP plugin above this plugin and you are using the gauge
* swapping function, you'd change the "wrong" gauges. This is NOT an issue of
* THIS plugin.)
*
* ============================================================================
* Changelog
* ============================================================================
* v0.1.1
* - fixed the battle_log that was not showing the changed gauge names and
* still wrote always "MP" if MP damage was taken.
*
* v0.1.0
* - Plugin has been tested and functionality confirmed. Added note for order
* with YEP_SkillCore to precent compatibility issue.
*
* experimental Version 0.0.1
* - First version of the plugin. Establishing base functionality.
*
*
* ============================================================================
* Warranty
* ============================================================================
*
* No warranty at all! All use is in your own responsibility!
*
* ============================================================================
* License
* ============================================================================
*
* You may use this plugin in every rpg maker project, even adult and commercial.
*
* You have to credit ST0RMTiger.
*
* You are not allowed to commercialize the plugin, only your game itself that
* may use this plugin.
*
* All distributions, modifications etc. of this plugin has to keep the information
* written here and has to keep the license conditions and attribution of ST0RMTiger.
*
*/
/*~struct~Actor:
* @param Actor
* @type actor
* @min 1
* @max 1000
* @default 0
*
* @param MPGaugeName
* @type text
* @default Name
*
* @param MPGaugeNameColor
* @type number
* @min 0
* @max 31
* @default 0
*
* @param MPGaugeGradientColor1
* @type number
* @min 0
* @max 31
* @default 0
*
* @param MPGaugeGradientColor2
* @type number
* @min 0
* @max 31
* @default 0
*/
//=============================================================================
//=============================================================================
// Parameter Variables
//=============================================================================
parameters = PluginManager.parameters('ST0RM_ActorMPGaugeNames');
ST0RM.ActorMPGaugeNames.PARAMS = parameters || {};
ST0RM.ActorMPGaugeNames.regionsOK = {};
for (let i = 1; i <= 255; ++i) {
ST0RM.ActorMPGaugeNames.regionsOK[i] =
ST0RM.ActorMPGaugeNames.PARAMS[String('Region ' + String(i))] === 'true';
};
//=============================================================================
// Window_Base
//=============================================================================
/* original function in "rpg_windows.js"
Window_Base.prototype.drawActorMp = function(actor, x, y, width) {
width = width || 186;
var color1 = this.mpGaugeColor1();
var color2 = this.mpGaugeColor2();
this.drawGauge(x, y, width, actor.mpRate(), color1, color2);
this.changeTextColor(this.systemColor());
this.drawText(TextManager.mpA, x, y, 44);
this.drawCurrentAndMax(actor.mp, actor.mmp, x, y, width,
this.mpColor(actor), this.normalColor());
};
*/
const myMPGaugeName = 'Stamina';
const myMPGaugeNameColor = 20;
const myMPGaugeGradientColor1 = 19; //22
const myMPGaugeGradientColor2 = 18; //23
ST0RM.ActorMPGaugeNames.actorParams = function(actor_id) {
actors_params = JSON.parse(ST0RM.ActorMPGaugeNames.PARAMS.ActorMPGaugeConfig);
for (const key in actors_params) {
if (Object.hasOwnProperty.call(actors_params, key)) {
const element = actors_params[key];
actor_params = JSON.parse(element);
if(actor_params.Actor === String(actor_id)) {
return actor_params;
}
}
}
return null;
}
ST0RM.ActorMPGaugeNames.former_Window_Base_drawActorMp = Window_Base.prototype.drawActorMp;
Window_Base.prototype.drawActorMp = function(actor, x, y, width) {
// Note for further improvement:
// If this would be a performance issue, parse everything in a separete list with
// actor_ids as keys at game start and use this for return of actor_parameters
let actorParams = ST0RM.ActorMPGaugeNames.actorParams(actor._actorId);
if(actorParams) {
// call my function for the actors with special definitions
this.drawCustomizedActorMp(actor, x, y, width, actorParams);
} else {
// call standard function for the rest
ST0RM.ActorMPGaugeNames.former_Window_Base_drawActorMp.call(this, actor, x, y, width);
}
};
// Introducing a new function
Window_Base.prototype.drawCustomizedActorMp = function(actor, x, y, width, actorParams) {
width = width || 186;
var color1 = this.textColor(actorParams.MPGaugeGradientColor1);
var color2 = this.textColor(actorParams.MPGaugeGradientColor2);
this.drawGauge(x, y, width, actor.mpRate(), color1, color2);
this.changeTextColor(this.textColor(actorParams.MPGaugeNameColor));
this.drawText(actorParams.MPGaugeName, x, y, 44);
this.drawCurrentAndMax(actor.mp, actor.mmp, x, y, width,
this.mpColor(actor), this.normalColor());
}
//=============================================================================
// Window_BattleLog
//=============================================================================
/* original function in "rpg_windows.js"
Window_BattleLog.prototype.makeMpDamageText = function(target) {
var result = target.result();
var damage = result.mpDamage;
var isActor = target.isActor();
var fmt;
if (damage > 0 && result.drain) {
fmt = isActor ? TextManager.actorDrain : TextManager.enemyDrain;
return fmt.format(target.name(), TextManager.mp, damage);
} else if (damage > 0) {
fmt = isActor ? TextManager.actorLoss : TextManager.enemyLoss;
return fmt.format(target.name(), TextManager.mp, damage);
} else if (damage < 0) {
fmt = isActor ? TextManager.actorRecovery : TextManager.enemyRecovery;
return fmt.format(target.name(), TextManager.mp, -damage);
} else {
return '';
}
};
*/
ST0RM.ActorMPGaugeNames.former_Window_BattleLog_makeMpDamageText = Window_BattleLog.prototype.makeMpDamageText;
Window_BattleLog.prototype.makeMpDamageText = function(target) {
if(target.isActor()) {
let actorParams = ST0RM.ActorMPGaugeNames.actorParams(target._actorId) || null;
console.log(target);
console.log(actorParams);
if(actorParams) {
return this.makeCustomizedMpDamageText(target, actorParams);
}
}
// in all other cases use the standard function
return ST0RM.ActorMPGaugeNames.former_Window_BattleLog_makeMpDamageText.call(this, target);
}
// Introducing a new function
Window_BattleLog.prototype.makeCustomizedMpDamageText = function(target, actorParams) {
var result = target.result();
var damage = result.mpDamage;
var isActor = true;
var fmt;
if (damage > 0 && result.drain) {
fmt = isActor ? TextManager.actorDrain : TextManager.enemyDrain;
return fmt.format(target.name(), actorParams.MPGaugeName, damage);
} else if (damage > 0) {
fmt = isActor ? TextManager.actorLoss : TextManager.enemyLoss;
return fmt.format(target.name(), actorParams.MPGaugeName, damage);
} else if (damage < 0) {
fmt = isActor ? TextManager.actorRecovery : TextManager.enemyRecovery;
return fmt.format(target.name(), actorParams.MPGaugeName, -damage);
} else {
return '';
}
};
//=============================================================================
// End of File
//=============================================================================