Check that NPC and Player are Facing the Same Direction

Discussion in 'RPG Maker VX Ace' started by Esjitu, Jul 14, 2017.

    Tags:
  1. Esjitu

    Esjitu Villager Member

    Messages:
    22
    Likes Received:
    10
    First Language:
    English
    Primarily Uses:
    RMMV
    Having a bit of trouble creating an event where, if you approach an NPC face-to-face, they talk normally, but if you approach them from the side or behind, you pickpocket them.

    The way I thought to set it up was to have a bunch of conditional branches to check that the NPC and player are facing the same direction - so if the NPC is facing down, check if the player is facing up, do X. Else, do Y. Then check if the NPC is facing up, and again that the player is facing down, and so on. I made a similar multi-check event before with a bunch of nested conditionals in this way (though for that it was checking for switches) so this SHOULD work, even if it looks a bit messy.

    The problem is, when you interact with the NPC, of course he turns to face the player...so it'll always see that the NPC and player are facing the same direction. Of course this could be fixed by turning direction fix on, but I want the NPC to be able to walk around normally until the player interacts with them, THEN have it check if they're facing the same direction before deciding the action.

    What's the best way to go about this? I tried a few different things with move routes and self-switches but I couldn't get anything to work the way I want it to. Ex. I can't have the first action be a move route with direction fix, because the NPC will already be facing the player just by talking to them. I would like the NPC to be able to move around normally with autonomous movement (which means setting the event to direction fix won't work) but when you interact it should check that they're facing the same direction. I can't think of a way to do that without the event being set to direction fix by default...but then I can't get the NPC to move and walk around like a normal person.

    Is this possible and I'm just missing something, or is there no way to do this without just making the NPC static so you always know what direction they'll be facing when the player approaches?
     
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,333
    Likes Received:
    6,446
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    that is what the direction fix option is for - it prevents the event from changing direction toward the player when interacting.

    If that NPC walks around, you need to disable it before each move command and reactivate it after the move. You do that in the move route settings, there is a command for that there.
     
    #2
  3. Esjitu

    Esjitu Villager Member

    Messages:
    22
    Likes Received:
    10
    First Language:
    English
    Primarily Uses:
    RMMV
    So I'd set the autonomous movement to a custom move route (instead of, say, random) and do something like:

    direction fix off
    move left
    direction fix on
    direction fix off
    move down
    direction fix on

    etc? Is that what you mean?
     
    #3
  4. Andar

    Andar Veteran Veteran

    Messages:
    28,333
    Likes Received:
    6,446
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    yes, exactly - you can even set the custom autonomous route to random, or if that event is controlled by another one use the set move route command in the same way.
     
    #4
  5. Esjitu

    Esjitu Villager Member

    Messages:
    22
    Likes Received:
    10
    First Language:
    English
    Primarily Uses:
    RMMV
    It doesn't seem to be working for me. I set up a test actor with the following:

    [​IMG]
    [​IMG]

    When I talk to him, he still turns to face me.
     
    #5
  6. Shaz

    Shaz Veteran Veteran

    Messages:
    37,579
    Likes Received:
    11,292
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
  7. dsiver144

    dsiver144 Peaceful Days Dev Veteran

    Messages:
    248
    Likes Received:
    747
    Location:
    Vietnam
    First Language:
    Vietnamese
    Primarily Uses:
    RMVXA
    After using Shaz no lock script. You can make that this way to check if player and event are facing face-to-face:
    Using this script line in Conditional Branch: $game_map.events[@event_id].direction == 10 - $game_player.direction
     
    Last edited: Jul 14, 2017
    #7
  8. Esjitu

    Esjitu Villager Member

    Messages:
    22
    Likes Received:
    10
    First Language:
    English
    Primarily Uses:
    RMMV
    I used a bunch of nested conditional branches, but that sounds much more efficient!!

    I got the no lock script set up and with that + the above-mentioned direction fix-toggling move route everything seems to be working as intended now. Thanks to everyone for the help!!
     
    #8

Share This Page