Can you use array.findIndex ?
JavaScript:
const enemies = $gameTroop.members()
const targetIndex = enemies.findIndex(enemy => enemy === $target)
$gameVariables.setValue(n, targetIndex)
Can you use array.findIndex ?
const enemies = $gameTroop.members()
const targetIndex = enemies.findIndex(enemy => enemy === $target)
$gameVariables.setValue(n, targetIndex)
◆Plugin Command:VisuMZ_1_BattleCore, ACSET: Setup Action Set
: :Display Action = true
: :Immortal: On = false
: :Battle Step = true
: :Wait For Movement = true
: :Cast Animation = true
: :Wait For Animation = true
◆If:Guy2XAttack is ON
◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Perform Action
: :Targets = ["user"]
◆Wait:13 frames
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Attack Animation
: :Targets = ["current target"]
: :Mirror Animation = false
: :Wait For Animation? = true
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
: :Targets = ["current target"]
◆If:Script:$target.isDead()
◆Text:None, None, Window, Bottom
: :huh?
◆Plugin Command:VisuMZ_1_BattleCore, TARGET: Random Target
: :Force Random? = true
: :Jump To Label = Untitled
◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
: :Targets (Moving) = ["user"]
: :Targets (Destination) = ["current target"]
: :Target Location = front base
: :Melee Distance = 24
: :Offset Adjustment = horz
: :Offset: X = 0
: :Offset: Y = 0
: :Duration = 12
: :Face Destination? = true
: :Movement Easing = Linear
: :Movement Motion = walk
: :Wait For Movement? = true
◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Perform Action
: :Targets = ["user"]
◆Wait:13 frames
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Attack Animation
: :Targets = ["current target"]
: :Mirror Animation = false
: :Wait For Animation? = true
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
: :Targets = ["current target"]
◆
:Else
◆Text:None, None, Window, Bottom
: :whaaaa???
◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Perform Action
: :Targets = ["user"]
◆Wait:13 frames
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Attack Animation
: :Targets = ["current target"]
: :Mirror Animation = false
: :Wait For Animation? = true
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
: :Targets = ["current target"]
◆
:End
◆
:Else
◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Perform Action
: :Targets = ["user"]
◆Wait:30 frames
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Attack Animation
: :Targets = ["current target"]
: :Mirror Animation = false
: :Wait For Animation? = true
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
: :Targets = ["current target"]
◆
:End
◆Plugin Command:VisuMZ_1_BattleCore, ACSET: Finish Action
: :Immortal: Off = true
: :Wait For New Line = true
: :Wait For Effects = true
: :Clear Battle Log = true
: :Home Reset = true
: :Wait For Movement = true
You wouldn't need to do that, battlers have an index method you can use (e.g.
$target.index() ) - however, Arthran said you can't use a variable in that plugin command, you have to actually type a number. Edit: Sorry, you replied just as I was clicking to post.I don't know what you're talking about. What words did I use that would indicate I'm upset? O__o
Unfortunately, I don't have any other suggestions. From reading it, it looks like it ought to work to me (except the Jump to Label part, of course). The possible exception would be if there isn't another enemy in the troop to target, but I'm presuming you're always testing with multiple enemies in the troop.
console.log("Target is " + $target.name()); and see what pops up in the play test console. That can help you see if there's some error with getting the new target.Targets field:enemy index var x
◆Plugin Command:VisuMZ_1_BattleCore, ACSET: Setup Action Set
: :Display Action = true
: :Immortal: On = false
: :Battle Step = true
: :Wait For Movement = true
: :Cast Animation = true
: :Wait For Animation = true
◆Control Variables:#0010 Target = $target.index()
◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
: :Targets (Moving) = ["user"]
: :Targets (Destination) = ["enemy index var 10"]
: :Target Location = front base
: :Melee Distance = 24
: :Offset Adjustment = horz
: :Offset: X = 0
: :Offset: Y = 0
: :Duration = 12
: :Face Destination? = true
: :Movement Easing = Linear
: :Movement Motion = walk
: :Wait For Movement? = true
◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Perform Action
: :Targets = ["user"]
◆Wait:13 frames
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Attack Animation
: :Targets = ["enemy index var 10"]
: :Mirror Animation = false
: :Wait For Animation? = true
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
: :Targets = ["enemy index var 10"]
◆If:Script:!$target.isDead()
◆Script:console.log('Initial target still alive');
◆Jump to Label:Attack Again
◆
:End
◆Script:const aliveEnemies = $gameTroop.aliveMembers();
: :if (aliveEnemies.length > 0) {
: : const nextTarget = aliveEnemies[Math.randomInt(aliveEnemies.length)];
: : $gameVariables.setValue(10, nextTarget.index());
: :} else {
: : console.log('No other targets to attack.');
: : // Jump to Label: End
: : this.command119(['End']);
: :}
◆Script:console.log('Moving to new target.');
◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
: :Targets (Moving) = ["user"]
: :Targets (Destination) = ["enemy index var 10"]
: :Target Location = front base
: :Melee Distance = 24
: :Offset Adjustment = horz
: :Offset: X = 0
: :Offset: Y = 0
: :Duration = 12
: :Face Destination? = true
: :Movement Easing = Linear
: :Movement Motion = walk
: :Wait For Movement? = true
◆Label:Attack Again
◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Perform Action
: :Targets = ["user"]
◆Wait:13 frames
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Attack Animation
: :Targets = ["enemy index var 10"]
: :Mirror Animation = false
: :Wait For Animation? = true
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
: :Targets = ["enemy index var 10"]
◆Label:End
◆Plugin Command:VisuMZ_1_BattleCore, ACSET: Finish Action
: :Immortal: Off = true
: :Wait For New Line = true
: :Wait For Effects = true
: :Clear Battle Log = true
: :Home Reset = true
: :Wait For Movement = true
Perhaps they are intended to function with skills that have a multi-target scope? If you do, like, All Enemies, will those commands allow you to move around within the group?
Yeah, it could be that a multi-target scope is required, but then I'm not even sure what the initial "current target" index would be in that case. It would definitely help if they would document the action sequence stuff better, or at least include a few more examples in the demo project.
No problem. Let me know whether or not you manage to get my solution working.
I believe that's exactly right, caethyril. At this point the targets have already been selected from the available candidates, so those commands just loop through whatever targets it's been determined to have hit.
◆Plugin Command:VisuMZ_1_BattleCore, ACSET: Setup Action Set
: :Display Action = true
: :Immortal: On = false
: :Battle Step = true
: :Wait For Movement = true
: :Cast Animation = true
: :Wait For Animation = true
◆Control Variables:#0044 Target = $target.index()
◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
: :Targets (Moving) = ["user"]
: :Targets (Destination) = ["enemy index var 44"]
: :Target Location = front base
: :Melee Distance = 24
: :Offset Adjustment = horz
: :Offset: X = 0
: :Offset: Y = 0
: :Duration = 30
: :Face Destination? = true
: :Movement Easing = Linear
: :Movement Motion = walk
: :Wait For Movement? = true
◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Perform Action
: :Targets = ["user"]
◆Wait:13 frames
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Attack Animation
: :Targets = ["enemy index var 44"]
: :Mirror Animation = false
: :Wait For Animation? = true
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
: :Targets = ["enemy index var 44"]
◆If:Script:!$target.isDead()
◆Script:console.log('Initial target still alive');
◆Jump to Label:Attack Again
◆
:End
◆Script:const aliveEnemies = $gameTroop.aliveMembers();
: :: :if (aliveEnemies.length > 0) {
: :: : const nextTarget = aliveEnemies[Math.randomInt(aliveEnemies.length)];
: :: : $gameVariables.setValue(44, nextTarget.index());
: :: :} else {
: :: : console.log('No other targets to attack.');
: :: : // Jump to Label: End
: :: : this.command119(['End']);
: :: :}
◆Script:console.log('Moving to new target.');
◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
: :Targets (Moving) = ["user"]
: :Targets (Destination) = ["enemy index var 44"]
: :Target Location = front base
: :Melee Distance = 24
: :Offset Adjustment = horz
: :Offset: X = 0
: :Offset: Y = 0
: :Duration = 30
: :Face Destination? = true
: :Movement Easing = Linear
: :Movement Motion = walk
: :Wait For Movement? = true
◆Label:Attack Again
◆Plugin Command:VisuMZ_1_BattleCore, MOTION: Perform Action
: :Targets = ["user"]
◆Wait:13 frames
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Attack Animation
: :Targets = ["enemy index var 44"]
: :Mirror Animation = false
: :Wait For Animation? = true
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
: :Targets = ["enemy index var 44"]
◆Label:End
◆Plugin Command:VisuMZ_1_BattleCore, ACSET: Finish Action
: :Immortal: Off = true
: :Wait For New Line = true
: :Wait For Effects = true
: :Clear Battle Log = true
: :Home Reset = true
: :Wait For Movement = true
I don't see any problems, but my brain has already clocked out for the night, so I could definitely be overlooking something. Can you please describe exactly what's happening?
Weird. It's working fine for me, as far as I can tell. This is basically what you're trying to achieve, right?
Just Battle Core and Core Engine are required. I don't know what the issue is. If you wanna zip up your project, upload it somewhere, and send me the link, I can try to figure out the problem. If you'd rather not send your actual project, you can send me a new project that replicates the issue. Otherwise, maybe something will dawn on me after I get a good night's sleep.
If you zip it up, you can upload it to a file upload service, like Mega, workupload, MediaFire, etc. I think you can use the latter two without having to sign up for an account. Then you'll get a link to share it, and you can just PM the link to me.
Original thread: https://forums.rpgmakerweb.com/threads/check-if-enemy-is-dead-visustella-action-sequences.151443/