/*:
- @plugindesc Robot Parts Equipment System for RPG Maker MV
- @author YourName
- @param Torso Icon Index
- @desc Icon index for the torso parts category.
- Default: 1
- @default 1
- @param Left Arm Icon Index
- @desc Icon index for the left arm parts category.
- Default: 2
- @default 2
- @param Right Arm Icon Index
- @desc Icon index for the right arm parts category.
- Default: 3
- @default 3
- @param Legs Icon Index
- @desc Icon index for the legs parts category.
- Default: 4
- @default 4
- @help This plugin creates a robot parts equipment system for RPG Maker MV,
- with torso, left arm, right arm, and legs categories. These can be
- easily expanded to add new parts and different stats and attacks.
- The parameters are editable in the plugin manager.
*/
(function () {
var parameters = PluginManager.parameters('RobotParts');
var torsoIconIndex = Number(parameters['Torso Icon Index'] || 1);
var leftArmIconIndex = Number(parameters['Left Arm Icon Index'] || 2);
var rightArmIconIndex = Number(parameters['Right Arm Icon Index'] || 3);
var legsIconIndex = Number(parameters['Legs Icon Index'] || 4);
// Extend RPG Maker MV data structures
DataManager.isRobotPart = function (item) {
return (
(item && item.etypeId) ===
(torsoIconIndex || leftArmIconIndex || rightArmIconIndex || legsIconIndex)
);
};
DataManager.equipTypes = function () {
return ['torso', 'leftArm', 'rightArm', 'legs'];
};
Window_EquipSlot.prototype.slotName = function (index) {
switch (index) {
case 0:
return 'Torso';
case 1:
return 'Left Arm';
case 2:
return 'Right Arm';
case 3:
return 'Legs';
}
};
Window_Status.prototype.drawEquipments = function (x, y) {
var equips = [
// Using previously defined equipTypes
this._actor.robotEquip('torso'),
this._actor.robotEquip('leftArm'),
this._actor.robotEquip('rightArm'),
this._actor.robotEquip('legs'),
];
for (var i = 0; i < equips.length; i++) {
this.drawItemName(equips[i], x, y + this.lineHeight() * i);
}
};
// Add robot parts to enemies
Game_Enemy.prototype.robotParts = function () {
return this.enemy().robot_parts.slice();
};
Game_Enemy.prototype.initRobotParts = function () {
this._robot_parts = this.robotParts();
};
// Add functionality to enable/disable parts
Game_Enemy.prototype.leftArmEnabled = function () {
return this._robot_parts.leftArm.enabled;
};
Game_Enemy.prototype.rightArmEnabled = function () {
return this._robot_parts.rightArm.enabled;
};
// Display robot parts in battle (enemies)
Window_BattleEnemy.prototype.refresh = function () {
this.contents.clear();
for (var i = 0; i < this.maxItems(); i++) {
var name = this.enemyName(i);
var rect = this.itemRectForText(i);
this.drawText(name, rect.x, rect.y, rect.width);
var parts = this._enemies[i].robotParts();
for (var j = 0; j < parts.length; j++) {
this.drawText(
parts[j].name,
rect.x + rect.width * (j + 1),
rect.y,
rect.width
);
}
}
};
// Alias original methods
var _Enemy_initMembers = Game_Enemy.prototype.initMembers;
var _BattleEnemy_initialize = Window_BattleEnemy.prototype.initialize;
// Initialize robot parts for enemies on creation
Game_Enemy.prototype.initMembers = function () {
_Enemy_initMembers.call(this);
this.initRobotParts();
};
// Initialize battle enemy window with robot parts display
Window_BattleEnemy.prototype.initialize = function (x, y) {
_BattleEnemy_initialize.call(this, x, y);
this.refresh();
};
// Add robot parts to note tags of actors and enemies
DataManager.processRobotPartsNotetags = function (group) {
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
obj.robot_parts = [];
for (var i = 0; i < notedata.length; i++) {
var line = notedata[i];
if (line.match(/<(?:ROBOT_PARTS_DIR):[ ]*(.*)>/i)) {
var parts = String(RegExp.$1).split(',');
for (var j = 0; j < parts.length; j++) {
obj.robot_parts.push({
type: DataManager.equipTypes()[j],
id: Number(parts[j].trim()),
});
}
}
}
}
};
// Alias original methods to process additional note tags
var _DataManager_onLoadEnemy = DataManager.onLoad;
DataManager.onLoad = function (object) {
_DataManager_onLoadEnemy.call(this, object);
if (object === dataActors)DataMdataEnemies) {
DataManager.processRobotPartsNotetags(object);
}
};
})();