I am attempting to design an enemy that has to be frozen and then physically attacked to kill it, similar to Metroids in Metroid for Nintendo. I realize this will take an auto-passive state (124) specific to the enemy and that once placed in FROZEN state (125), any physical attack (elements 1, 10, 11, 16, 17, 18), ideally, will kill it. I also know that my current script does not achieve the desired effect, but I lack the JavaScripting scripting knowledge to reach the final result.
Desired outcome breakdown is below:
1. Enemy is always in auto-passive state 124 (I currently have no script written for this state). It is invincible unless the player uses ICE element 3 on it.
2. Player uses ICE element (3) on the enemy.
3. ICE element causes the enemy to be placed in a FROZEN state 125, reducing the enemy's HP to 0. I used the Yanfly Greater Undead JavaScript (at the bottom of the post).
4. If the player physically attacks (elements 1, 10, 11, 16, 17, 18) the enemy while it is FROZEN, it dies.
4.a. If a player uses element 3 on the enemy while it is in FROZEN state 125, it resets the state 125 timer.
4.b. If the player uses any other element on the enemy other than 1, 3, 10, 11, 16, 17, or 18, the enemy's HP returns to what it was before state 125 was applied, which should be max-HP.
Community assistance is greatly appreciated. Thanks!
FROZEN state 125 JavaScript:
Desired outcome breakdown is below:
1. Enemy is always in auto-passive state 124 (I currently have no script written for this state). It is invincible unless the player uses ICE element 3 on it.
2. Player uses ICE element (3) on the enemy.
3. ICE element causes the enemy to be placed in a FROZEN state 125, reducing the enemy's HP to 0. I used the Yanfly Greater Undead JavaScript (at the bottom of the post).
4. If the player physically attacks (elements 1, 10, 11, 16, 17, 18) the enemy while it is FROZEN, it dies.
4.a. If a player uses element 3 on the enemy while it is in FROZEN state 125, it resets the state 125 timer.
4.b. If the player uses any other element on the enemy other than 1, 3, 10, 11, 16, 17, or 18, the enemy's HP returns to what it was before state 125 was applied, which should be max-HP.
Community assistance is greatly appreciated. Thanks!
FROZEN state 125 JavaScript:
JavaScript:
<Custom Passive Condition>
// Check if the undead death flag has not been triggered
condition = !user._undeadDeath;
</Custom Passive Condition>
<Custom React Effect>
// Check if this action recovers HP
if (this.isHpRecover()) {
// Make it deal damage instead
value = Math.abs(value);
}
</Custom React Effect>
<Custom Respond Effect>
// Check if the target's HP is 0 or less
if (target.hp <= 0) {
// Get this action's elements
var elements = this.getItemElements();
// Create a list of the elements that can kill this undead
var killingElements = [1, 10, 11, 16, 17, 18];
// Set the initial kill flag to false
var killed = false;
// Loop through the killing elements
while (killingElements.length > 0) {
// Get the currently looped killing element
var elementId = killingElements.shift();
// Check if the action's elements have a killing element
if (elements.contains(elementId)) {
// If it does, set the kill flag to true
killed = true;
}
}
// Check if the kill flag has activated
if (killed) {
// Set the undead death flag to true
target._undeadDeath = true;
// Refresh the target
target.refresh();
} else {
// Otherwise, set the target's HP to 1
target.setHp(1);
}
}
</Custom Respond Effect>