Basicly, I kinda want to make an enemy that as his last resort tries to shot a random party member, using a last desprete attack.
Though its hard to do it the normal way since forced actions been reworked with it, so now I am wondering how to handle it where the enemy uses the attack right as he is dying, and have it be at a random enemy
If it's always supposed to happen (Meaning you can't kill the enemy before it happens) you can just make the enemy immune to knockout (By giving it a state with knockout immunity at the start of battle), set its desperation move to priority 9 with a condition of hp 0%. That should automatically make it use it as soon as it would be normally dead.
If you then want to use action sequencing, you can simply make the skill your usual "1 Random enemy" scope and in the sequence itself, after the hit landed, simply remove the immunity state from it and it will die.
If you want it right at death, you can do that immortal stuff and do a troop event at 0% hp. Use action sequence plugin commands in the troop event. Set the correct enemy to do stuff (index starts at 0). You can do movements, motions, animations, emulate skill at random target etc
Here's an example I made that I think works. Make a troop event (span: Battle) that has condition for the enemy hp to be at 0%. Here it's enemy number 1, so that means enemy index 0 (they start at 0). If you want it to target one random dude, you can use scripts to get a random target and then put conditionals depending on the result (here I'm using variable 20 called 'TEST'). Like (for that script box dont copy those colons before the lines start):
◆Script:const numberAlive = $gameParty.aliveMembers().length;
: :const randomIndex = Math.randomInt(numberAlive);
: :$gameVariables.setValue(20, randomIndex);
◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Float
: :Targets = ["enemy index 0"]
: :Desired Height = 100
: :Duration = 60
: :Float Easing = Linear
: :Wait For Float? = true
◆If:TEST = 0
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Emulate Skill Effect
: :Skill ID = 10
: :User(s) = ["enemy index 0"]
: :Targets = ["actor index 0"]
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Show Animation
: :Targets = ["actor index 0"]
: :Animation ID = 2
: :Mirror Animation = false
: :Wait For Animation? = true
◆
:End
◆If:TEST = 1
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Emulate Skill Effect
: :Skill ID = 10
: :User(s) = ["enemy index 0"]
: :Targets = ["actor index 1"]
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Show Animation
: :Targets = ["actor index 1"]
: :Animation ID = 2
: :Mirror Animation = false
: :Wait For Animation? = true
◆
:End
◆If:TEST = 2
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Emulate Skill Effect
: :Skill ID = 10
: :User(s) = ["enemy index 0"]
: :Targets = ["actor index 2"]
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Show Animation
: :Targets = ["actor index 2"]
: :Animation ID = 2
: :Mirror Animation = false
: :Wait For Animation? = true
◆
:End
◆If:TEST = 3
◆Plugin Command:VisuMZ_1_BattleCore, MECH: Emulate Skill Effect
: :Skill ID = 10
: :User(s) = ["enemy index 0"]
: :Targets = ["actor index 3"]
◆Plugin Command:VisuMZ_1_BattleCore, ANIM: Show Animation
: :Targets = ["actor index 3"]
: :Animation ID = 2
: :Mirror Animation = false
: :Wait For Animation? = true
◆
:End
◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Float
: :Targets = ["enemy index 0"]
: :Desired Height = 0
: :Duration = 60
: :Float Easing = Linear
: :Wait For Float? = true
◆Change Enemy State:#1 Goblin, - Immortal