How to get the enemy index of a targeted troop member?

● ARCHIVED · READ-ONLY
Started by Blaink 12 posts View original ↗
  1. Hello!

    How do I get the enemy ID of a targeted troop member? This is all I can figure so far. This should return the troop index of the targeted enemy... maybe? haha:

    $gameTroop.members()[(BattleManager._action._targetIndex)]

    ... but I need the enemy ID of the targeted enemy.

    Trying to understand java script... I don't know how your brains work. lol. Please help a mere mortal. Thanks!

    (RPG MAKER MV)
  2. In the damage formula, I think you can just do b.index() to get the index of the target. This could be an actor or an enemy, depending on who is using the skill and its scope.
  3. ***Ignore this post- was intended to be a reply****
  4. Thanks for the quick response Shaz!

    So, hoping to set variable 1 to the enemy index of the target, I set up a skill and set the damage formula to:
    $gameVariables.setVaue(1, (b.index))
    ...with the sole intention of setting variable 1 to the enemy ID of the targeted enemy.

    However, the battle test returned this:

    "Type error: undefined is not a function"

    What am I doing wrong?

    Thanks again!
    Shaz said:
    In the damage formula, I think you can just do b.index() to get the index or the target. This could be an actor or an enemy, depending on who is using the skill and its scope.
  5. You've just got the parentheses in the wrong place

    $gameVariables.setValue(1, b.index())
  6. Blaink said:
    Thanks for the quick response Shaz!

    So, hoping to set variable 1 to the enemy index of the target, I set up a skill and set the damage formula to:
    $gameVariables.setVaue(1, (b.index))
    ...with the sole intention of setting variable 1 to the enemy ID of the targeted enemy.

    However, the battle test returned this:

    "Type error: undefined is not a function"

    What am I doing wrong?

    Thanks again!
    Actually, i see the type error in "vaue" which i corrected to value, but now variable 1 is being set to " function () { return $gameTroop.members().indexOf(this)
  7. Ah I see! wrong parenthesis... however this is just returning the troop index... instead of the enemy ID
    Shaz said:
    You've just got the parentheses in the wrong place

    $gameVariables.setValue(1, b.index())
  8. (I should have named this thread with "Enemy ID" Instead of "Enemy Index" maybe)
  9. I'm sorry - I thought you were just after the index.

    In that case, it's this:

    $gameVariables.setValue(1, b.enemyId())
  10. Shaz said:
    I'm sorry - I thought you were just after the index.

    In that case, it's this:

    $gameVariables.setValue(1, b.enemyId())
    Thank you so so much :thumbsup-left:
  11. Shaz said:
    I'm sorry - I thought you were just after the index.

    In that case, it's this:

    $gameVariables.setValue(1, b.enemyId())

    Do you happen to know how to get the Id in script?
    Like for returning targeted actorId there's;

    $gameParty._targetActorId
  12. [NECRO]Dagothe[/NECRO]

    This is an old, old thread and your question is different. Please create a new thread for your question. Add a link back to this one if you really think it's relevant.