Scan Enemy through switches/common events?

Discussion in 'RPG Maker MV' started by coticka, Jun 14, 2019 at 8:08 AM.

    Tags:
  1. coticka

    coticka Veteran Veteran

    Messages:
    49
    Likes Received:
    2
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Hello friends. I am currently trying to figure out a way how I can set up a switch with a variable and perhaps a common event to be called when using an item on an enemy, and I think I need some help. So would it be along the lines of-
    -Item is used on enemy.
    -Switch is turned on.
    -Variable is called for the certain troop.
    -Common Event is activated.
    Or something along those lines? I'm having a hard time thinking how I could specify which common event to call
    based on which enemy is chosen to use the item on during battle.
    If anyone can point me in the right direction that'd be most helpful.
     
    #1
  2. CaRa_CrAzY

    CaRa_CrAzY Undefined Custom Title Member

    Messages:
    27
    Likes Received:
    12
    Location:
    São Paulo - Brazil
    First Language:
    Portuguese
    Primarily Uses:
    Other
    I think you can't do it properly solely on Events, because that would require you to set multiple conditional branches for each common event for each troop, and since common events does not support calls based on variable IDs, this would be a very repetitive labor. Time is a valuable resource! Don't waste it on repetitive labor.

    However, It is pretty simple while using scripts calls (Last item in the third event command tab, if I am not mistaken):
    Code:
    $gameTemp.reserveCommonEvent(n)
    Just change the n inside brackets to the common event's ID you need to call.

    If you are able to store the targeted troop's index inside a variable it should be as simple as:
    Code:
    $gameTemp.reserveCommonEvent($gameVariables.value(n))
    Just change the n inside brackets to the variable's ID you want to use as a holder for the enemies IDs.

    But we have a problem here, which is...
    I think there isn't an event way to retrieve the information about which troop is being targeted, so you would have to build extremely complex events in battle just to retrieve a simple information, like in the old days of the 2k/3 era of custom battle systems built solely on events.

    Luckily we have a way to retrieve that info using the item's formula.
    Instead of putting some damage in there, we can assign the targeted enemy's ID to a game variable:
    Code:
    $gameVariables.setValue(n, b.enemyId())
    Do not forget to change the n inside the brackets to the ID of the variable you want to use for keeping the enemy IDs.

    These are the posts I found most of this info:
    Get Targeted Enemy ID
    List of Script Calls

    Now, it's up to you to call those common events and set them up.
     
    #2
  3. coticka

    coticka Veteran Veteran

    Messages:
    49
    Likes Received:
    2
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Ahh, okay I see. I was toying around with it and tried having the item apply a state to the enemy when used.
    Then, in a troop event there would be a conditional branch set to moment that checks individually for each enemy if it has
    the state applied, then it would call the correct common event for that enemy type and erase the state.
    The problem is, and I don't really know why but- The common event refuses to call from that conditional branch.
    Even though it can be called just fine if placed by itself. Strange.
    But I'll try this method as well.
     
    #3
  4. CaRa_CrAzY

    CaRa_CrAzY Undefined Custom Title Member

    Messages:
    27
    Likes Received:
    12
    Location:
    São Paulo - Brazil
    First Language:
    Portuguese
    Primarily Uses:
    Other
    Can you post a screenshot from those conditional branches you mentioned?
     
    #4
  5. coticka

    coticka Veteran Veteran

    Messages:
    49
    Likes Received:
    2
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Sure.
     

    Attached Files:

    #5
  6. CaRa_CrAzY

    CaRa_CrAzY Undefined Custom Title Member

    Messages:
    27
    Likes Received:
    12
    Location:
    São Paulo - Brazil
    First Language:
    Portuguese
    Primarily Uses:
    Other
    Are sure the state isn't gone by its own when the check is made?
     
    #6
  7. coticka

    coticka Veteran Veteran

    Messages:
    49
    Likes Received:
    2
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Yep. I gave the state an icon (just to make sure it's applying) and I see it over the enemies' head.
     
    #7

Share This Page