Triggering events based on the specific enemy actor is attacking?

Discussion in 'RPG Maker MV' started by brothew, Jul 13, 2018.

  1. brothew

    brothew Warper Member

    Messages:
    4
    Likes Received:
    0
    First Language:
    English
    I'm looking for a way to trigger events based on the specific enemy the actor is currently attacking.

    For example, if Hero 1 is fighting both a Dragon and a Slime, and he attacks the Dragon, I'd like a specific event to occur. But if he attacks the Slime, even with the same attack he used on the Dragon, I'd like a different event to occur.

    For single-enemy troops, this is easy enough to do. Just set a skill calling a common event that itself relies on a conditional branch set by a switch. That switch can be turned on/off in the troop's battle event, and there are plugins that can allow it to be turned on/off at the end of the battle so that it resets for the next battle, where it can change if the troop changes. But that's only useful if you have just one enemy type per troop to worry about. What I'm trying to do is make it so that you can do it with a mixed-enemy troop.

    To give you a more concrete example, I want to do this so that I can display different pictures (using show picture commands) depending on the enemy type attacked. So in the above example, I want to make sure the pictures I'm using for when Hero 1 attacks the Dragon are not the same as the ones that show up when he attacks the Slime in the same battle, and vice-versa.

    Can this be done either via plugins or eventing? Maybe a way to flag the enemy such that when it's hit, it either toggles a switch or sets a variable to a certain value, and that switch or variable triggers the appropriate picture to appear? Thanks in advance for any assistance, and let me know if you need more information.
     
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,343
    Likes Received:
    6,451
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    It can be done by eventing, but it is a bit complex.

    Make an invisible state that does nothing and have the skill apply it to the targeted enemy.
    In the common event, check every enemy for which has been targetted (=has the state)
    Do whatever you want based on that enemy and remove the state afterward.
     
    #2
  3. brothew

    brothew Warper Member

    Messages:
    4
    Likes Received:
    0
    First Language:
    English
    @Andar I appreciate the response. I tried this, but I'm not sure how to make it so that the effect changes between different enemy types. For example, if I have "Attack" apply "Dragon State" to a Dragon, and the common event has something happen when Dragon State is active, how can I also have that same Attack skill apply "Slime State" to a Slime, and still give the player the choice of which enemy to attack at any given point?

    Common event only seems to have the ability to check for enemy #s, not specific enemy types regardless of their position on the battlefield. Applying states at the start of battle doesn't work either, because if enemy #1 is a Dragon, and enemy #2 is a Slime, I could set those states, but how would the common event know how to distinguish between which enemy is actually being attacked?
     
    #3
  4. Andar

    Andar Veteran Veteran

    Messages:
    28,343
    Likes Received:
    6,451
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    You don't - it works the other way around.

    The skill applies a target state that is neither dragon state nor slime state.
    The common event then uses this to determine which enemy # was targeted.
    With that info you can use a script call to check which type of enemy it is, and depending on that info the common event decides to apply the dragon state or the slime state or do whatever.
     
    #4
  5. brothew

    brothew Warper Member

    Messages:
    4
    Likes Received:
    0
    First Language:
    English
    @Andar Hmm, yeah, that seems a bit cumbersome. Thanks for the info, but I think I might just not use heterogeneous troops anyway, which will simplify things. It's not essential to the game, anyway.
     
    #5
  6. mrcopra

    mrcopra Veteran Veteran

    Messages:
    448
    Likes Received:
    145
    Location:
    Your Heart
    First Language:
    Not English
    Primarily Uses:
    N/A
    Try to put this in Formula "v[x]=b._enemyId"
    this will put enemy's id in variable x
    then you can trigger the common event with it
     
    #6

Share This Page