- Joined
- Mar 14, 2014
- Messages
- 314
- Reaction score
- 171
- First Language
- English
- Primarily Uses
- N/A
In my game I have a skill that hits 3 random enemies. I noticed sometime after making it that if any enemy dies during the first or second hit of the skill, the now non existent enemy still has a chance of being targeted for the following hits. I'm surprised this happens as I think it defeats part of the purpose of a skill hitting multiple random enemies. The skill should capitalize on an enemy dying early in the skill at the trade-off of the player not knowing who it will hit. This is how I've seen random skills handled in RPGs at least.
What I would like is to make use of the <Custom Target Eval> to have skills that hit multiple random targets update the target array mid skill if an enemy dies. So on a 3 random target skill: if the first hit of the skill kills enemy A, then enemy A won't get targeted for the remainder of the hits. This also means that enemy A could be targeted 3 times if enemy A is alive for the entire skill.
The above code is from Yanfly's chain lightning trick. After an enemy gets hit by a skill with this code, other random enemies can be hit by the skill afterwards by the skill repeating itself on a number of random targets. In the code's case it's 3 other enemies. But the code makes it so that the same enemy can't be targeted twice by the randomness. It's not quite the effect I want, but it's sort of close.
Here's what I want it to do:
1. Create an array with 3 targets, chosen at random.
2. Hit the first target in the array then remove it if it has 0 HP.
3. Hit the next, then remove it if it has 0 HP.
4. Hit the last, remove it.
What I would like is to make use of the <Custom Target Eval> to have skills that hit multiple random targets update the target array mid skill if an enemy dies. So on a 3 random target skill: if the first hit of the skill kills enemy A, then enemy A won't get targeted for the remainder of the hits. This also means that enemy A could be targeted 3 times if enemy A is alive for the entire skill.
Code:
<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>
Here's what I want it to do:
1. Create an array with 3 targets, chosen at random.
2. Hit the first target in the array then remove it if it has 0 HP.
3. Hit the next, then remove it if it has 0 HP.
4. Hit the last, remove it.
Last edited:
