Hello, all! I'm working on a skill that deals damage to random targets based on a state. The idea is you use a Lightning spell, and it will apply the Shock state to your target. Continuously using Lightning based skills reapplies the Shock state and increases its stacks, up to a max of 7. When a Lightning based skill hits a target with the max stacks of Shock, it causes a Chain Lightning effect that deals Lightning damage to random targets in the enemy troop, bouncing between targets 7 times. Repeat hits are possible, and targets that have Shock applied take extra damage, but do not gain more stacks of Shock nor set off further Chain Lightning reactions.
As it stands, I have the skill and state working functionally, but I am having a slight issue with how the animation actually plays out. I want a slight pause between lightning strikes to give it a "rhythm." Like a straight "1-2-3-4-5-6-7," if that makes any sense? But currently, whenever I test it, all of the hits come at once after the initial attack lands. I'm using the script call for Wait, but it doesn't seem to be doing anything. I've checked in the console, but there isn't anything undefined popping up, so my use of the call is correct, but its not functioning how I want it to. Or I may be making the call with the wrong interpreter?
Here's the relevant note tag and code:
As it stands, I have the skill and state working functionally, but I am having a slight issue with how the animation actually plays out. I want a slight pause between lightning strikes to give it a "rhythm." Like a straight "1-2-3-4-5-6-7," if that makes any sense? But currently, whenever I test it, all of the hits come at once after the initial attack lands. I'm using the script call for Wait, but it doesn't seem to be doing anything. I've checked in the console, but there isn't anything undefined popping up, so my use of the call is correct, but its not functioning how I want it to. Or I may be making the call with the wrong interpreter?
Here's the relevant note tag and code:
Code:
<Post-Damage Eval>
//Get target's Shock stack count
var shockStack = target.getStateCounter(29);
//Variable used in damage calculation
var spellPower = 10;
if (shockStack >= 7) {
//Get alive members of enemy troop
let troop = $gameTroop.aliveMembers();
//Loop until 7 random hits have occurred
for (let i = 0; i < shockStack; i++) {
//Target a random, living enemy
let enemy = troop[Math.randomInt(troop.length)];
//Calculate base damage dealt by Chain Lightning
var baseDmg = (user.mat * spellPower) - (target.mdf * (spellPower / 4));
//Initialize damage multiplier and final damage variables
var multiplier = 1;
var finalDmg = 0;
//Enemies afflicted with shock take extra damage
if (enemy.isStateAffected(29)) {
multiplier = enemy.getStateCounter(29) / 4;
}
//Final damage is base damage multiplied by the multiplier
finalDmg = Math.ceil(baseDmg * multiplier);
//Play animation on target, take damage, and damage popup
enemy.startAnimation(76);
enemy.gainHp(-(finalDmg));
enemy.startDamagePopup();
enemy.clearResult();
//If target dies, perform collapse and update list of living troop members
if (enemy.isDead()) {
enemy.performCollapse();
troop = $gameTroop.aliveMembers();
}
//Wait 30 frames to give a pause between strikes
$gameTroop._interpreter.wait(30);
}
//Remove Shock from initial target
target.removeState(29);
}
//If Shock is not at max stacks, reapply Shock
else { target.addState(29); }
</Post-Damage Eval>