MZ - Check if enemy is dead - VisuStella Action Sequences

● ARCHIVED · READ-ONLY
Started by mobiusclimber 41 posts Page 1 of 3 View original ↗
  1. Is there no way to check if an enemy is dead? I only saw a script call for the battler (ie party member).
  2. mobiusclimber said:
    Is there no way to check if an enemy is dead? I only saw a script call for the battler (ie party member).
    That's not correct - battlers are all entities in the battle. The player party members are actors and the game-controlled troop are enemies, but both actors and enemies are derived from Game_Battler (and Game_BattlerBase).

    The isDead() method should return expected results on enemies.
  3. I've been trying to get

    Code:
    $game.Party.members()[0].isDead()

    to work but I must be doing something wrong. You use "0" for the target?
  4. mobiusclimber said:
    I've been trying to get

    Code:
    $game.Party.members()[0].isDead()

    to work but I must be doing something wrong. You use "0" for the target?
    You have an extra period in there. It should be:
    JavaScript:
    $gameParty.members()[0].isDead()
  5. Thank you! This was my second time trying this and I guess I was a bit sloppy. XD But it still doesn't work. I mean, this time it will skip to the else branch instead of ignoring the whole thing entirely, but it doesn't register that the targeted enemy is dead.
  6. $gameParty is the player-controlled unit. For enemies, use $gameTroop instead:

    $gameTroop.members()[0].isDead()
    I.e. "is enemy #1 dead?".

    Alternatively, if this is in an event, you could consider Conditional Branch -> Enemy -> State: Dead.

    You might find the Script Call List (linked in this thread's first post) more helpful? It's less comprehensive, but has more examples/explanation.
  7. mobiusclimber said:
    Thank you! This was my second time trying this and I guess I was a bit sloppy. XD But it still doesn't work. I mean, this time it will skip to the else branch instead of ignoring the whole thing entirely, but it doesn't register that the targeted enemy is dead.
    Oops, I didn't realize you were wanting to check enemies. Guess I shoulda scrolled up and read the whole conversation.
  8. @caethyril - thanks, but I still can't get it to work. I tried the troop one but it still skips over it and goes to the else branch. I can't use enemy --> state --> dead bc I don't know which enemy the player has selected. Unless I'm being dense again, lol, and there's a way around that or something.
  9. You should check out the $gameTemp._lastActionData. It is composed of an array that contains the following:
    0 - last skill id used
    1 - last item id used
    2 - last actor id who was subject (the user of the skill)
    3 - last enemy index who was subject ^
    4 - last target actor id (who was attacked)
    5 - last target enemy index ^

    I don't know if you are trying to get all the last target enemy indexes, but 5 would at least get you the very last one that was targeted.
  10. I saw that but had no idea how to use it for what I was doing. Sorry I'm a complete n00b when it comes to script calls. I'm trying to do a conditional branch where if the last target is dead it does one thing and if not it does something else. How do I use that script call to get the info for the other script call?
  11. You can use Control Variables -> Game Data -> Last -> Last Target Enemy Index. Or, as indicated, $gameTemp.lastActionData(5). So you could try:

    $gameTroop.members()[$gameTemp.lastActionData(5)].isDead()
    I.e. "is the member of the enemy troop with index equal to the last target enemy index currently dead?" (leader is index 0).

    This is assuming you're running this in an event somewhere, e.g. via a Common Event effect on a skill. Last Target data gets updated immediately after an action is applied to a target, so this script call may give incorrect results if it is run before then. For example, if you're trying to use this in a notetag from some plugin, please give details of that.
  12. I'm using this on a common event for Visustella Battle Core's action sequences. I think there's something funny with that plugin bc this still isn't working even tho I think you nailed it and it really should work.
  13. lastActionData doesn't always work right in action sequences, because of the time that the action sequence gets executed, and the fact that the action sequence overwrites the normal flow of things.

    In an action sequence, you can use this:
    JavaScript:
    BattleManager._targets[0].isDead()

    Or if you happen to have VisuStella Core Engine installed, you can use:
    JavaScript:
    $target.isDead()
  14. Thanks @Arthran that is working, but it's still not doing what I'd like it to do. At least now it knows that the enemy is dead, but I can't get it to move on to the next enemy. Any idea? I've tried "alive enemies" but then it targets all of them. Also, no idea what the difference is between "enemy" and "opponent."

    Code:
      ◆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, MOVE: Move To Target(s)
          :              :Targets (Moving) = ["user"]
          :              :Targets (Destination) = ["enemy index x"]
          :              :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 x"]
          :              :Mirror Animation = false
          :              :Wait For Animation? = true
          ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
          :              :Targets = ["enemy index x"]
          ◆
        :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
  15. mobiusclimber said:
    Also, no idea what the difference is between "enemy" and "opponent."
    What do you mean? Who used the word "opponent"? I don't see it from Arthran, anyone else in this post, or the Battle Core documentation, so...what are you talking about?

    mobiusclimber said:
    Code:
          :              :Targets (Destination) = ["enemy index x"]
    Where did you get this command syntax from? It doesn't make any sense - what would "index x" be? The index of an array (such as the $gameTroop of enemies) has to be a number. I don't have the actual plugin to look in it, but I don't see anything that looks like this in the Battle Core documentation.

    A quick poke at said documentation shows the Target: Next Target, Target: Previous Target and Target: Random Target (Force Random) commands. These should all do what you're going for, but I think the last one would be the most reliable.
  16. All that stuff is in action sequences. Opponents and enemies, index x, that's all in action sequences. I tried the target: next target, and target: random target and neither one worked.

    actionseq.png
  17. 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.
  18. Wow! I didn't know you could just write over the "x" in there! Seriously, I wish this part of the plugin was better explained. I read the whole thing and I don't think they ever go over how to use this part. Here's what I do when I use "next target":

    Code:
          ◆Plugin Command:VisuMZ_1_BattleCore, MOVE: Move To Target(s)
          :              :Targets (Moving) = ["user"]
          :              :Targets (Destination) = ["next 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 = ["next target"]
          :              :Mirror Animation = false
          :              :Wait For Animation? = true
          ◆Plugin Command:VisuMZ_1_BattleCore, MECH: Action Effect
          :              :Targets = ["next target"]

    And what happens is the player character pauses for half a second, does nothing, and then goes back to the home spot. I've tried to do the random target thing before this part and that also doesn't work, and I've tried to do the random target thing and then make a label for it to jump to and that also doesn't work. And then I try the random target thing with "current target" but that also doesn't work. The player character will attack the blank space where the dead enemy was and there will be a damage number over it but of course that's it. Here's what that looks like:

    Code:
          ◆Plugin Command:VisuMZ_1_BattleCore, TARGET: Random Target
          :              :Force Random? = true
          :              :Jump To Label = Next
          ◆Label:Next
          ◆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"]
  19. mobiusclimber said:
    I've tried to do the random target thing and then make a label for it to jump to
    It doesn't mean anything if you say Jump to Label and the label is literally on the next line. The whole point of jumping to a label is you're jumping - you're skipping some section of your event to go to another section. You can delete that.

    mobiusclimber said:
    Here's what that looks like:
    Please post the full action sequence. If this is it, it doesn't make sense with what you're describing because there's only one attack happening, no check for a dead target, etc.

    If it isn't it, then we need to see it all to try to see what you might be doing incorrectly. This looks fine to me for choosing a random target, walking up to it, and hitting it. But that doesn't include any of the stuff you say you're having a problem with.