I'm trying to make a Ghost state which will change the actor's SV_Actor sprite to the Ghost version upon reaching 0 HP if there is MP remaining, and then return the previous SV_Actor sprite upon revival or death. To accomplish this, I followed Yanfly's Actor Transformations guide, and then modded YEP_AutoPassiveStates with ATT_Turan's "Auto Passive States - Apply and Remove" Terrific Tweak to fix the Custom Apply and Custom Remove functions of Passive States.
Here's what I got:
State: Ghost
- State Resist: Dead
The application of the status works great, just as I'd like it to; the state activates, and the SV_Actor switches to the ghost one. The real trouble begins when the state should be removed, in which case it will freeze the game. I'm completely at a loss as to why this happens-- I think I've modded the plugin correctly. It seems to be something in the removal process which screws things up, both when reviving and dying for real. If anyone has any idea what might be causing this and/or how to fix it, I'd greatly appreciate hearing it.
Here's what I got:
State: Ghost
- State Resist: Dead
[
<Passive Condition: HP Below 1>
<Passive Condition: MP Above 0>
<Custom Turn End Effect>
// Lose 1 MP
target.gainMp(-1);
</Custom Turn End Effect>
<Custom React Effect>
// Convert would-be HP damage to MP damage
if (this.isHpEffect && value > 0) {
var offset = Math.floor((Math.min(value*1.0, target.mp)));
value -= offset;
target.gainMp(-offset);
}
</Custom React Effect>
<Custom Apply Effect>
// Check if user is an actor.
if (user.isActor()) {
// Archive the previous settings.
user._prevCharName = user._prevCharName || user._characterName;
user._prevCharIndex = user._prevCharIndex || user._characterIndex;
user._prevBattlerName = user._prevBattlerName || user._battlerName;
// Check if the actor ID is 1.
if (user.actorId() === 1) {
// The filename of the character graphic without the file extension.
var charName = 'Ripple';
// The index of the character graphic used.
var charIndex = 0;
// The filename of the battler graphic without the file extension.
var battlerName = 'ActorCow_2';
// If none of the above actor ID's match, use this setting.
} else {
// The filename of the character graphic without the file extension.
var charName = 'Ripple';
// The index of the character graphic used.
var charIndex = 0;
// The filename of the battler graphic without the file extension.
var battlerName = 'ActorCow_2';
}
// Changes the character image to the setting applied from above.
user.setCharacterImage(charName, charIndex);
// Changes the battler image from the setting applied from above.
user.setBattlerImage(battlerName);
// Refreshes the user's appearance.
user.refresh();
}
</Custom Apply Effect>
<Custom Remove Effect>
// Retrieve archived settings.
var charName = user._prevCharName;
var charIndex = user._prevCharIndex;
var battlerName = user._prevBattlerName;
// Changes the character image to the archived setting.
user.setCharacterImage(charName, charIndex);
// Changes the battler image from the archived setting.
user.setBattlerImage(battlerName);
// Clear archived data.
user._priorityCharacterName = undefined;
user._priorityCharacterIndex = undefined;
user._priorityBattlerName = undefined;
user._prevBattlerName = undefined;
// Refreshes the user's appearance.
user.refresh();
</Custom Remove Effect>
]
<Passive Condition: HP Below 1>
<Passive Condition: MP Above 0>
<Custom Turn End Effect>
// Lose 1 MP
target.gainMp(-1);
</Custom Turn End Effect>
<Custom React Effect>
// Convert would-be HP damage to MP damage
if (this.isHpEffect && value > 0) {
var offset = Math.floor((Math.min(value*1.0, target.mp)));
value -= offset;
target.gainMp(-offset);
}
</Custom React Effect>
<Custom Apply Effect>
// Check if user is an actor.
if (user.isActor()) {
// Archive the previous settings.
user._prevCharName = user._prevCharName || user._characterName;
user._prevCharIndex = user._prevCharIndex || user._characterIndex;
user._prevBattlerName = user._prevBattlerName || user._battlerName;
// Check if the actor ID is 1.
if (user.actorId() === 1) {
// The filename of the character graphic without the file extension.
var charName = 'Ripple';
// The index of the character graphic used.
var charIndex = 0;
// The filename of the battler graphic without the file extension.
var battlerName = 'ActorCow_2';
// If none of the above actor ID's match, use this setting.
} else {
// The filename of the character graphic without the file extension.
var charName = 'Ripple';
// The index of the character graphic used.
var charIndex = 0;
// The filename of the battler graphic without the file extension.
var battlerName = 'ActorCow_2';
}
// Changes the character image to the setting applied from above.
user.setCharacterImage(charName, charIndex);
// Changes the battler image from the setting applied from above.
user.setBattlerImage(battlerName);
// Refreshes the user's appearance.
user.refresh();
}
</Custom Apply Effect>
<Custom Remove Effect>
// Retrieve archived settings.
var charName = user._prevCharName;
var charIndex = user._prevCharIndex;
var battlerName = user._prevBattlerName;
// Changes the character image to the archived setting.
user.setCharacterImage(charName, charIndex);
// Changes the battler image from the archived setting.
user.setBattlerImage(battlerName);
// Clear archived data.
user._priorityCharacterName = undefined;
user._priorityCharacterIndex = undefined;
user._priorityBattlerName = undefined;
user._prevBattlerName = undefined;
// Refreshes the user's appearance.
user.refresh();
</Custom Remove Effect>
]