- Jul 19, 2021
- Reaction score
- First Language
- Primarily Uses
Can you use array.findIndex ?When you use "enemy index x", you need to replace the x with the actual numerical index of the enemy that you want. Unfortunately, there is not a way to use a variable for the index, so you don't really have a good way to calculate a reasonable value to use for the index in this type of situation. You'd have to use a ton of if statements, to test each possible index.
It'd probably be better to use the target action sequences, like ATT_Turan suggested. Unfortunately, I'm responding from mobile right now, so it'd be really hard for me to try to show you how to use it. I'd recommend checking the example in the wiki one more time, and then try to implement it. If it still doesn't work, then show us exactly how you tried to do it, and tell us what happened when you tried to use it.
const enemies = $gameTroop.members() const targetIndex = enemies.findIndex(enemy => enemy === $target) $gameVariables.setValue(n, targetIndex)