In the game Marvel Rivals for PC, PS5 and the new Xbox system if those aren't familiar, The winter solider has an ultimate where he slams down on an enemy and if that attack kills the enemy he's able to use that attack again continuously until his attack doesn't kill an enemy. I'm trying to create something similar, it's a state my party member is going to get into, where if his attack kills an enemy, he repeats that attack on another random enemy that's alive. If the attack doesn't kill the enemy or their are no more living enemies left, then it breaks out this loop. This is what I was able to come up with, but nothing is happening when I kill the enemy, I'm sure I'm doing something wrong. I tried using Custom Confirm as well but no such luck.
<Custom Establish Effect>
var aliveMembers = foes.aliveMembers(); // Get initial alive enemies
while (aliveMembers.length > 0) {
if (value > 0 && target.isDead()) {
// Re-update alive members after the death of the target
aliveMembers = foes.aliveMembers();
if (aliveMembers.length > 0) {
// Select a random alive enemy
var randomIndex = Math.floor(Math.random() * aliveMembers.length);
var randomMember = aliveMembers[randomIndex];
// Force the action on the random enemy, assuming user is the attacker
user.forceAction(608, randomMember); // Replace 608 with the correct skill ID
BattleManager.forceAction(user);
}
} else {
break; // Exit the loop if no valid action happens
}
}
</Custom Establish Effect>
Update: I decided to try another method and simply edit the action sequence for anyone who is curious using Yanfly's Actions Sequence pack then simply put an If event to check and see if the enemy's HP was 0 and set a common event to repeat the attack on a random enemy. Works like a charm!
Skill Action Notetag
<setup action>
clear battle log
immortal: targets, true
</setup action>
<whole action>
perform start
motion standby: user
wait for movement
face user: targets
camera focus: user
zoom: 125%
wait for zoom
</whole action>
<target action>
jump user: 150, 20
move user: target, front base, 20
wait 35
motion attack: user
wait: 10
attack animation: target
wait: 10
action effect
shake screen: 12, 9, 9
wait: 10
if target.hp<=0
Immortal: targets, false
common event: 27
end
</target action>
<follow action>
Immortal: targets, false
move user: home, 20
wait for animation
reset camera
reset zoom
<follow action>
<Custom Establish Effect>
var aliveMembers = foes.aliveMembers(); // Get initial alive enemies
while (aliveMembers.length > 0) {
if (value > 0 && target.isDead()) {
// Re-update alive members after the death of the target
aliveMembers = foes.aliveMembers();
if (aliveMembers.length > 0) {
// Select a random alive enemy
var randomIndex = Math.floor(Math.random() * aliveMembers.length);
var randomMember = aliveMembers[randomIndex];
// Force the action on the random enemy, assuming user is the attacker
user.forceAction(608, randomMember); // Replace 608 with the correct skill ID
BattleManager.forceAction(user);
}
} else {
break; // Exit the loop if no valid action happens
}
}
</Custom Establish Effect>
Update: I decided to try another method and simply edit the action sequence for anyone who is curious using Yanfly's Actions Sequence pack then simply put an If event to check and see if the enemy's HP was 0 and set a common event to repeat the attack on a random enemy. Works like a charm!
Skill Action Notetag
<setup action>
clear battle log
immortal: targets, true
</setup action>
<whole action>
perform start
motion standby: user
wait for movement
face user: targets
camera focus: user
zoom: 125%
wait for zoom
</whole action>
<target action>
jump user: 150, 20
move user: target, front base, 20
wait 35
motion attack: user
wait: 10
attack animation: target
wait: 10
action effect
shake screen: 12, 9, 9
wait: 10
if target.hp<=0
Immortal: targets, false
common event: 27
end
</target action>
<follow action>
Immortal: targets, false
move user: home, 20
wait for animation
reset camera
reset zoom
<follow action>