• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

How to make NPCs block players from continuing past them?

PocketAne

Shy Genwunner
8
Posts
6
Years
    • Seen Mar 18, 2022
    Okay, this is my first post here in Pok?Community and I literally have no idea what I am doing, but, hey. Won't know if I don't try. I'm currently am making a Pok?mon fan game and I'm having a touch of trouble.
    I'm creating a sidequest on my route 1 and want to give it a bit more character. I'm trying to get an NPC to block the exit of the route until the sidequest, (after its initial activation) is completed by the player, but, I literally have no idea how to do it.
    For a more precise example, let's say an Old Man is blocking your path to the next route and the only way to get past him is to defeat the town's Gym Leader. Afterwards, he either disappears completely or after you talk to him again, he sees your badge and lets you pass.
    I've searched the internet and the only aid I can find is how to create obstacles like trees and boulders to be cut or smashed. If I am correct, what I want to accomplish has something to do with Control switches or Control variables. Hey, maybe its both.

    Any aid would very much be appreciated. :)
     
    226
    Posts
    8
    Years
    • Seen Jul 19, 2023
    Here is a very quick answer to your question. There are several ways to do it, here is mine. The structure of your event should be something like this:

    Page 1
    - Set the NPC graphics (although it's optional, you could make the same event in which for example the player realizes he cannot go further on his own, without a NPC being there)
    - Set the Event Trigger as "Event Touch"
    - Set his name to "Trainer(X)" where "X" is the range of view of the NPC. This is important because it allows the event to have a "sight".
    - Create a conditional branch where the condition is the one that is not met by the player yet (ex: Defeated Gym 1 = Off). Under the conditional branch:
    -Insert the Script "Kernel.pbNoticePlayer(get_character(0))", which makes the NPC moving to the player when the player enters its area of sight (the area of sight is defined by the name of the event, "Trainer(X)")
    - Insert some text if you want to
    - Now you should Set Move Route for the player to turn back (for example, if you want your player to be unable to go up, you should make him go down 1 step each time he tries to pass without meeting the condition). Add a "Wait for move completion" afterwards.
    - Now, if your event had to walk to reach the player, he should go back to his initial position (otherwise the player could possibly bypass him). Again you should Set a Move Route for him to take "1 Step backward" and by checking the box "Ignore If Can't Move". Add as many "step backward" as necessary.
    - I don't know if this last step is really necessary, but I use it for caution. Sometimes events with the trigger "Event touch" trigger two times in a row. What I do to prevent this is to set Self-Switch A to On, Wait 2 frames, then set it to Off again. This way the event will not repeat itself. While the switch A is on I use a 2nd page with the NPC's graphics and nothing else.

    So if your event has graphics (if it is a NPC and not an empty event), create a Page 2 with the condition "Self Switch A On" and the NPC's graphic. It is only useful for displaying the NPC's graphic while resetting the event's trigger.

    On Page 3 you should display what happens when the condition is met. For example you set "Defeated Gym 1" as a Condition for the event to appear and set the trigger as Action Button. This way, when the condition is met, you can have the NPC saying something.
    You could also put what happens when the condition is met in the "Else" branch on your first page (just remember that the Trigger of the 1st page is set on "Event touch").
     

    PocketAne

    Shy Genwunner
    8
    Posts
    6
    Years
    • Seen Mar 18, 2022
    ---------------------------
    Pokemon Essentials
    ---------------------------
    Exception: RuntimeError

    Message: Script error within event 4, map 33 (Test Route 1):

    Exception: SyntaxError

    Message: (eval):2:in `pbExecuteScript'compile error
    (eval):2: syntax error
    (eval):2: syntax error

    ***Line '(0))' shouldn't begin with '('. Try

    putting the '(' at the end of the previous line instead,

    or using 'extendtext.exe'.

    ***Full script:

    Kernel.pbNoticePlayer(get_character
    (0))




    Interpreter:276:in `pbExecuteScript'

    Interpreter:1606:in `command_355'

    Interpreter:494:in `execute_command'

    Interpreter:193:in `update'

    Interpreter:106:in `loop'

    Interpreter:198:in `update'

    Scene_Map:103:in `update'

    Scene_Map:101:in `loop'

    Scene_Map:114:in `update'

    Scene_Map:68:in `main'



    This exception was logged in

    C:\Users\PocketAne\Saved Games/Pokemon Essentials/errorlog.txt.

    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK
    ---------------------------

    First off all, thanks so much for replying. Secondly, I most be doing something wrong because everytime I copy and paste the script you've given me, I keep getting this when interact with the NPC/Event. ~_~
     

    PocketAne

    Shy Genwunner
    8
    Posts
    6
    Years
    • Seen Mar 18, 2022
    Disregard anything post before this one. I found what I was doing wrong! Thank you so much for the assistance! You rock, girl!{:3}
     

    PocketAne

    Shy Genwunner
    8
    Posts
    6
    Years
    • Seen Mar 18, 2022
    Here is a very quick answer to your question. There are several ways to do it, here is mine. The structure of your event should be something like this:

    Page 1
    - Set the NPC graphics (although it's optional, you could make the same event in which for example the player realizes he cannot go further on his own, without a NPC being there)
    - Set the Event Trigger as "Event Touch"
    - Set his name to "Trainer(X)" where "X" is the range of view of the NPC. This is important because it allows the event to have a "sight".
    - Create a conditional branch where the condition is the one that is not met by the player yet (ex: Defeated Gym 1 = Off). Under the conditional branch:
    -Insert the Script "Kernel.pbNoticePlayer(get_character(0))", which makes the NPC moving to the player when the player enters its area of sight (the area of sight is defined by the name of the event, "Trainer(X)")
    - Insert some text if you want to
    - Now you should Set Move Route for the player to turn back (for example, if you want your player to be unable to go up, you should make him go down 1 step each time he tries to pass without meeting the condition). Add a "Wait for move completion" afterwards.
    - Now, if your event had to walk to reach the player, he should go back to his initial position (otherwise the player could possibly bypass him). Again you should Set a Move Route for him to take "1 Step backward" and by checking the box "Ignore If Can't Move". Add as many "step backward" as necessary.
    - I don't know if this last step is really necessary, but I use it for caution. Sometimes events with the trigger "Event touch" trigger two times in a row. What I do to prevent this is to set Self-Switch A to On, Wait 2 frames, then set it to Off again. This way the event will not repeat itself. While the switch A is on I use a 2nd page with the NPC's graphics and nothing else.

    So if your event has graphics (if it is a NPC and not an empty event), create a Page 2 with the condition "Self Switch A On" and the NPC's graphic. It is only useful for displaying the NPC's graphic while resetting the event's trigger.

    On Page 3 you should display what happens when the condition is met. For example you set "Defeated Gym 1" as a Condition for the event to appear and set the trigger as Action Button. This way, when the condition is met, you can have the NPC saying something.
    You could also put what happens when the condition is met in the "Else" branch on your first page (just remember that the Trigger of the 1st page is set on "Event touch").

    I actuall have one more question. How do you make the NPC that is blocking the route's exit follow your player's movement while staying in place? (Ex. Police NPC who is standing facing forward while on the left side of the path snaps into the player's direction while staying in place, stopping the player without having to move towards them)

    Is that possible to do?~_~
     

    Telemetius

    Tele*
    267
    Posts
    9
    Years
  • Is the move route you're looking for "Turn towards Player"? You could put it inside the NPC's custom movements tab.
     
    Last edited:
    Back
    Top