Checking which enemy indexes were damaged by multi-target attack?

Discussion in 'Javascript/Plugin Support' started by Damascus7, Aug 2, 2019.

  1. Damascus7

    Damascus7 Villager Member

    Messages:
    26
    Likes Received:
    9
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm working on a script that splits Slimes if they are hit by a certain attack. For single target attacks, it's simple enough, I'm just putting this in the notetags for the weapon or skill that makes the Slimes split. In Post-Damage Eval in Yanfly's Action Sequences so it only runs on slimes that actually get hit by the attack.

    Code:
    $gameVariables.setValue(23, b.index());
    $gameTemp.reserveCommonEvent(13);
    Which just checks which slime was hit, then runs the event that splits the according slime.

    However I'm hung up on how to implement it for multi-target attacks. Basically I want the script to check which slimes were hit by the attack (as opposed to evading it), and runs the events only for those targets that were damaged. b.index isn't going to cut it since that will just return a single number, and I don't know how to get it to return the indexes of only the damaged slimes.
     
    #1
  2. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,474
    Likes Received:
    2,864
    Location:
    Philippines
    First Language:
    Tagalog
    You probably should just do the check in the damage formula so that it runs for each target that gets hit.
     
    #2
  3. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,116
    Likes Received:
    690
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Also, note that by default only one common event can be queued at a time, not sure if it'll give the event time to execute between targets.

    If you're using Yanfly's Action Sequence Pack 1, one option could be to try something like this as part of a <target action> block (i.e. runs once per target):
    Code:
    change variable 23 = b.index()
    common event: 13
    That should ensure the common event plays per target~ :kaophew:
     
    #3
  4. Damascus7

    Damascus7 Villager Member

    Messages:
    26
    Likes Received:
    9
    First Language:
    English
    Primarily Uses:
    RMMV
    I managed to make it work with flipping a number of switches for each target damaged and then calling a single common event. In the notetags, it looks like this:

    Code:
    if ((b.index()) === 0) {
    $gameSwitches.setValue(1, true);
    }
    if ((b.index()) === 1) {
    $gameSwitches.setValue(3, true);
    }
    if ((b.index()) === 2) {
    $gameSwitches.setValue(4, true);
    }
    if ((b.index()) === 3) {
    $gameSwitches.setValue(5, true);
    }
    $gameSwitches.setValue(6, true);
    }
    The final switch triggers a common event in the troop script, which will then go down the list of switches and check each one.

    Thanks for the advice!
     
    #4
    caethyril likes this.

Share This Page