New account registration is temporarily disabled.

[SCRIPTING] BIDE COUNTER SKILL: IS THIS JS CODE CORRECT?

Posts

Pages: 1
KrimsonKatt
Gamedev by sunlight, magical girl by moonlight
3326
So I'm making a skill that's like bide from Pokemon. It's enemy only, and when the enemy uses the skill the gain the "omnidrive" status. While in Omnidrive they are unable to attack, but store up damage taken while in this state. After 3 turns this damage is unleashed with a powerful almighty attack that does damage equal to damage taken x4, then the state is removed. However, if no damage is dealt, a switch is activated that causes a skill to be used called "Realground Shattering" which does infinite (not really) almighty damage to the entire party. This skill/state is primarily based off this tips and tricks from Yanfly:

Link to the Webpage
Link to the Video


And here is the code for that particular version of the bide state.

<Custom Apply Effect>
// Upon applying Bide, set the Bide damage to 0.
user._bide = 0;
</Custom Apply Effect>

<Custom Respond Effect>
// Check if the target took any HP damage.
if (target.result().hpDamage > 0) {
// If the target did, raise the Bide damage by the HP damage taken.
target._bide += target.result().hpDamage;
}
</Custom Respond Effect>

<Custom Remove Effect>
// Check if the party is in battle.
if ($gameParty.inBattle()) {
// Play animation 97 on the user.
user.startAnimation(97);
// Calculate the damage. The damage dealt is equal to 2x Bide damage.
var damage = Math.ceil(user._bide * 2);
// Get the group of alive enemies.
var enemies = user.opponentsUnit().aliveMembers();
// Loop through each of the enemies.
for (var i = 0; i < enemies.length; ++i) {
// Get the enemy.
var enemy = enemies[i];
// Play animation 107 on the enemy.
enemy.startAnimation(107);
// Make the enemy take damage.
enemy.gainHp(-damage);
// Prompt the enemy's damage popup.
enemy.startDamagePopup();
// Clear the results of the enemy taking damage.
enemy.clearResult();
// Check if the enemy is dead.
if (enemy.isDead()) {
// If the enemy is dead, make it collapse.
enemy.performCollapse();
}
}
// Reset the Bide damage value.
user._bide = 0;

} // Check if the party is in battle.
</Custom Remove Effect>


And here is my version

<Custom Apply Effect>
user._bide = 0;
</Custom Apply Effect>

<Custom Respond Effect>
if (target.result().hpDamage > 0) {
target._bide += target.result().hpDamage;
}
</Custom Respond Effect>

<Custom Remove Effect>
if ($gameParty.inBattle()) && user._bide > 0 {
user.startAnimation(97);
var damage = Math.ceil(user._bide * 4);
var enemies = user.opponentsUnit().aliveMembers();
for (var i = 0; i < enemies.length; ++i) {
var enemy = enemies[i];
enemy.startAnimation(104);
enemy.gainHp(-damage);
enemy.startDamagePopup();
enemy.clearResult();
if (enemy.isDead()) {
enemy.performCollapse();
}
}
user._bide = 0;
}
else $gameSwitches.setValue(102, true)
</Custom Remove Effect>


Is this code correct? Are there any errors I should be made aware of? Because I'm not that experienced with Javascript yet so I don't know exactly how well this code would work. Thanks for the help.
Pages: 1