Hey again all!
So I'm trying to create a chain lightning spell. Yanfly actually made a whole "Tips and Tricks" video about this using his Target Core and Damage Core plugins:
I wanted to change this a little bit. I didn't want the less-damage-each-hit part, but that was easy to fix. I just removed the damage formula at the beginning. The next part was that I wanted it to be able to repeat targets if there are less targets available than hits. I made the following brute force version (I also lowered the targets by one, but that's easy enough to change):
What happens with this one is that it works normally if there are enough targets. But if there aren't, it simply hits the last target for the remaining hits. Funny enough, if there's only one target it only hits once. So my bumbling about in the code almost worked.
So, to sum this all up: say I have only two targets. How do I get this to bounce back and forth between the two for all of the hits?
So I'm trying to create a chain lightning spell. Yanfly actually made a whole "Tips and Tricks" video about this using his Target Core and Damage Core plugins:
Code:
<Damage Formula>
// Set the chain multiplier to a value if it doesn't exist.
this._chainmultiplier = this._chainmultiplier || 1.0;
// This is the damage formula.
value = user.mat + 1000;
// Apply the chain multiplier to the damage formula.
value *= this._chainmultiplier;
// Reduce the chain multiplier per target.
this._chainmultiplier -= 0.2;
</Damage Formula>
<Custom Target Eval>
// Adds the selected target to the target list.
targets.push(target);
// Grab the group of alive foes as candidates.
var members = foes.aliveMembers();
// Remove the target from the group of candidates.
members.splice(members.indexOf(target), 1);
// This is the number of extra targets to select with Chain Lightning.
var extraTargets = 3;
// Loop the extra targets.
while (extraTargets--) {
// Grab a random foe from the alive foes.
var member = members[Math.floor(Math.random() * members.length)];
// Check to see if the member exists.
if (member) {
// Add the member to the group of targets.
targets.push(member);
// Remove the member as a viable candidate.
members.splice(members.indexOf(member), 1);
}
}
</Custom Target Eval>
I wanted to change this a little bit. I didn't want the less-damage-each-hit part, but that was easy to fix. I just removed the damage formula at the beginning. The next part was that I wanted it to be able to repeat targets if there are less targets available than hits. I made the following brute force version (I also lowered the targets by one, but that's easy enough to change):
Code:
<Custom Target Eval>
targets.push(target);
var members = foes.aliveMembers();
members.splice(members.indexOf(target), 1);
var extraTargets = 2;
while (extraTargets--) {
var member = members[Math.floor(Math.random() * members.length)];
if (member) {
targets.push(member);
}
}
</Custom Target Eval>
What happens with this one is that it works normally if there are enough targets. But if there aren't, it simply hits the last target for the remaining hits. Funny enough, if there's only one target it only hits once. So my bumbling about in the code almost worked.
So, to sum this all up: say I have only two targets. How do I get this to bounce back and forth between the two for all of the hits?