Oh wow, I just completely forgot to test for nested choices. :kaoswt2:
Replaced the code and now it's working perfectly, thanks!
$dataMap and $gameMap, giving this kind of error.// Configure plugin section is removed; or// Q46). Just remember it's MIT license, so the copyright notice should be included in an edited version./*:
* @target MZ
* @plugindesc Play animations when enemies die
* @author Dark_Ansem
*
* @param defaultAnimation
* @text Default Animation
* @desc The ID of the animation to play when an enemy dies, if no notetag is specified.
* @type animation
* @default 1
*
* @help This plugin allows you to play animations when enemies die.
*
* To specify a custom animation for an enemy, use the following notetag in the enemy's note field:
*
* <deathAnimation:ID>
*
* Replace ID with the ID of the animation you want to play.
*
* If no notetag is specified, the default animation set in the plugin parameters will be played.
*
* To disable the animation for an enemy, use the following notetag in the enemy's note field:
*
* <noDeathAnimation>
*/
(() => {
const parameters = PluginManager.parameters('DeathAnimation');
const defaultAnimation = Number(parameters['defaultAnimation']);
const _Game_Enemy_performCollapse = Game_Enemy.prototype.performCollapse;
Game_Enemy.prototype.performCollapse = function() {
if (this.isEnemy()) {
console.log(`Enemy ${this.enemyId()} died`);
if (!this.enemy().meta.noDeathAnimation) {
const animationId = this.enemy().meta.deathAnimation || defaultAnimation;
console.log(`Playing animation ${animationId}`);
BattleManager._logWindow.push('showAnimation', this, [this], animationId);
}
}
_Game_Enemy_performCollapse.call(this);
};
})();(() => {
const pluginName = 'DeathAnimation';
const parameters = PluginManager.parameters(pluginName);
const defaultAnimation = Number(parameters['defaultAnimation'] || 1);
const useDefault = parameters['useDefault'].toLowerCase() === 'true';
// Override the die method of the Game_Enemy class
const _Game_Enemy_die = Game_Enemy.prototype.die;
Game_Enemy.prototype.die = function() {
_Game_Enemy_die.call(this);
// Store the death animation ID on the enemy object for later use
this._deathAnimationId = this.deathAnimationId();
};
// Determine the ID of the death animation
Game_Enemy.prototype.deathAnimationId = function() {
// Check if the enemy has a deathAnimation notetag
if (this.enemy().meta.deathAnimation) {
// If it does, use the ID specified in the notetag
return Number(this.enemy().meta.deathAnimation);
} else if (useDefault) {
// If it doesn't, but the useDefault parameter is true, use the default animation ID
return defaultAnimation;
} else {
// If it doesn't and the useDefault parameter is false, don't play an animation
return 0;
}
};
// Override the updateEffect method of the Sprite_Enemy class
const _Sprite_Enemy_updateEffect = Sprite_Enemy.prototype.updateEffect;
Sprite_Enemy.prototype.updateEffect = function() {
_Sprite_Enemy_updateEffect.call(this);
if (this._effectType === 'collapse' && this._effectDuration % 20 === 19) {
const animationId = this._battler._deathAnimationId;
if (animationId > 0) {
this.parent.parent.startAnimation($dataAnimations[animationId], false, 0);
}
}
};
})();if (user.isEnemy()) $gameTemp.requestAnimation([user], 123);procDeathAnim function: if (a)
$gameTemp.requestAnimation([target], a);else clause starting on the next line, e.g. else
$gameTemp.requestAnimation([target], 123); else if (target.isEnemy())
$gameTemp.requestAnimation([target], 123);if (user.isEnemy()) $gameTemp.requestAnimation([user], 123);procDeathAnim function: if (a)
$gameTemp.requestAnimation([target], a);else clause starting on the next line, e.g. else
$gameTemp.requestAnimation([target], 123); else if (target.isEnemy())
$gameTemp.requestAnimation([target], 123);$gameTemp.requestAnimation is a core script method, and procDeathAnim uses it as such. Otherwise I don't know what you mean by "self-contained".procDeathAnim, and thus the edit described in my spoiler, will process once per trait object: not a great idea. I recommend you go with Turan's suggestion~addCommand, not only splice. This is mainly to interface nicely with other patches, e.g. the new Q52.return in the name. If that's what you want.addCommand, not just splice.StorageManager.exists; I guess I forgot that that function...exists. Also this feature now disables itself if the editor's "Skip Title Screen" option is enabled.$gameSystem instead of $gameTemp, allowing it to persist through save/load.<transform: 123> notetag, then when it is applied to an actor, the actor will "transform" into actor ID 123. When the state is removed, they'll revert. It's not a "real" transformation: basically it just changes a few properties like name, class, images.\T[phrase] message text code. This draws phrase as usual, but if you hover it with the cursor then it'll show the tip corresponding to that phrase, as defined in the plugin parameters. Also allows a button to cycle through available tips via the keyboard, default shift.