Script Call: Actor ID of Actor who performed the last action?

● ARCHIVED · READ-ONLY
Started by Dwain 7 posts View original ↗
  1. I have a common event which does different things based on which actor landed a deathblow. Or at least that's what I want it to do.

    In order to achieve this I want to store the Actor ID of the last/current actor who just killed the enemy in a variable, so I can then use that information to run some conditionals based on which actor ID it is.

    Something along the lines of:
    $gameVariables.setValue(120, BattleManager._action._targetIndex);

    This gives me the ID of the enemy that was killed, but what I want is the ID of the actor who killed him.

    I'm sure there must be a simple way of seeing who is the currently active battler? Any help would be much appreciated because this has been an issue in my project since forever :(
  2. I'd recommend using Yanfly's SkillCore plugin if not already.
    If you do you can insert this code into the skill's notetag.

    <Before Eval>
    $gameVariables.setValue(1, user.index()+1);
    $gameVariables.setValue(2, target.index()+1);

    if (user.isActor())
    $gameVariables.setValue(3, user.actorId());
    else
    $gameVariables.setValue(3, user.enemyId());

    if (target.isActor())
    $gameVariables.setValue(4, target.actorId());
    else
    $gameVariables.setValue(4, target.enemyId());
    </Before Eval>


    This code stores 4 variables for later use (i.e. in your common event):
    • the troop/party id of the caster (starts at 0, hence the +1)
    • the troop/party id of the target (also starts at 0)
    • the actor/enemy id of the caster (automatically checks which)
    • the actor/enemy id of the target (also checks which)
    Feel free to delete the lines you don't need.
  3. ShadowHawkDragon said:
    I'd recommend using Yanfly's SkillCore plugin if not already.
    If you do you can insert this code into the skill's notetag.




    This code stores 4 variables for later use (i.e. in your common event):
    • the troop/party id of the caster (starts at 0, hence the +1)
    • the troop/party id of the target (also starts at 0)
    • the actor/enemy id of the caster (automatically checks which)
    • the actor/enemy id of the target (also checks which)
    Feel free to delete the lines you don't need.

    Thank you, I will give this a try however it is not 100% ideal as I would have to use this on every single actor's skill! If it works though it could be worth it. Is there no way to script call this information without having to use these notetags?
  4. if you are using MV 1.5.0 or higher you can use
    Yanfly's 'Lunatic Pack – Action Beginning and End Effects' (needs battle core)

    } else if (data.match(/TARGETCASTER[ ](\d+)/i)) {
    $gameVariables.setValue(1, user.index()+1);
    $gameVariables.setValue(2, target.index()+1);

    if (user.isActor())
    $gameVariables.setValue(3, user.actorId());
    else
    $gameVariables.setValue(3, user.enemyId());

    if (target.isActor())
    $gameVariables.setValue(4, target.actorId());
    else
    $gameVariables.setValue(4, target.enemyId());
    Copy this into the 'effect code' at the bottom above where is says "Add new effects above this line"

    Then you only need to add the line below to each skill's notetag and any changes you make to the above code (such as changing which variables it uses) will apply to all skills using it.
    <End Action: targetcaster 0>
    The number at the end doesn't matter, just couldn't get it to work without.

    There may be a simpler method but that's outside my knowledge.
  5. I'm going to give these a try in my project now, will let you know results.
  6. The SkillCore code works! Thank you so much :)
  7. glad to have helped.
    The Lunatic Pack code the should be easier to use in the long term but is more prone to mistakes when setting up (and requires more plugins).