Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: Guide on how to prevent a player from blocking npc paths
- Original author: AwesomeCool
- Original date: April 26, 2015
- Source thread: https://forums.rpgmakerweb.com/threads/guide-on-how-to-prevent-a-player-from-blocking-npc-paths.39329/
- Source forum path: Game Development Engines > RPG Maker Tutorials > RMVXAce Tutorials
Summary
This tutorial is made to help get rid of the problem of players being able to block paths of npcs (which causes npcs to just stand there). Note: This guide assumes you have some experience with VX Ace For this tutorial you will need two script snippets and one script. https://www.dropbox.com/s/kiy7c8peif10vhc/Regions%20and%20Events%20-%20AwesomeCool.rb?dl=0 by Me
Archived First Post
This tutorial is made to help get rid of the problem of players being able to block paths of npcs (which causes npcs to just stand there).
Note: This guide assumes you have some experience with VX Ace
For this tutorial you will need two script snippets and one script.
Step 1:
Create a npc that will be moving around a map of some kind. It is a good idea to keep track of the event id for this method (it's event id is the events default name). For this tutorial I made it so I have to talk to him to get him to move on the first event page.
Here is Bill's (my npc) first page:
Step 2:
Let's have the npc Bill follow a path after self switch A gets turned on. So lets have the second page have a custom move route using Theo's script.
For this to work we will use find_path(x,y) in the move route dialog window. the x and y coordinates are where you want the npc to move too.
Should look something like this:
step 3:
At the spot where you want the npc's trail to come to an end, put a region there (I used region 1). Then put a second region around the region at the end point (I used region 2). These two regions will indicate if the player is on top of the ending point of the npc and if the npc is close to getting to the location.
What my map looked like:
Step 4:
Now we are going to need another event to control when the player is blocking the end point of the npc. (in parallel process mode) It can be left blank in terms of image
We are going to need three functions from the first script to make this work:
To do this, in the new event's page make a condition branch that checks if Bill (event id 1) is in region 2 (ex: get_region_event_is_in(1) == 2 ). Make sure to use script option on page 4 of the conditional branch pop-up window to get this check to work. Within this condition branch another condition branch should be added that checks what region the player is in (ex: get_region_player_is_in == 1).
In this condition branch, add four more conditional branches that check if the event is to the left, right, above, or below the player (ex: get_event_position_relative_to_player(1) == "right"). Note that right needs to be in-between "" marks. within each of these branches make the player move in the opposite direction of the check for the branch (ex: if you check to see if the event is to the right of the player, then move the player to the left).
This will cause the player to move out of the way of the npc when he gets close to his destination.
(optional) Step 5:
Make it so the second event stops checking if the player is in the way when the destination is reached.
like this (this switch will make the event go to the next page):
Demo:
Here is a link to the demo of the tutorial that I tested.
Link: https://www.dropbox.com/s/c8kjy2e8awskndu/NPC%20tutorial%201.zip?dl=0
Hope this tutorial helps you out (it is my first tutorial).
Thank you for your time.
Note: This guide assumes you have some experience with VX Ace
For this tutorial you will need two script snippets and one script.
- https://www.dropbox.com/s/kiy7c8peif10vhc/Regions%20and%20Events%20-%20AwesomeCool.rb?dl=0 by Me
- http://forums.rpgmakerweb.com/index.php?/topic/35677-theo-pathfinding-and-event-chase-player/?hl=%2Btheo+%2Bpathfinding by Theo
- https://www.dropbox.com/s/849fwy8v1y9yy6q/theo%20pathfinding%20bug%20fix.rb?dl=0 by me (used to fix some issues with theos script)
Step 1:
Create a npc that will be moving around a map of some kind. It is a good idea to keep track of the event id for this method (it's event id is the events default name). For this tutorial I made it so I have to talk to him to get him to move on the first event page.
Here is Bill's (my npc) first page:
Step 2:
Let's have the npc Bill follow a path after self switch A gets turned on. So lets have the second page have a custom move route using Theo's script.
For this to work we will use find_path(x,y) in the move route dialog window. the x and y coordinates are where you want the npc to move too.
Should look something like this:
step 3:
At the spot where you want the npc's trail to come to an end, put a region there (I used region 1). Then put a second region around the region at the end point (I used region 2). These two regions will indicate if the player is on top of the ending point of the npc and if the npc is close to getting to the location.
What my map looked like:
Step 4:
Now we are going to need another event to control when the player is blocking the end point of the npc. (in parallel process mode) It can be left blank in terms of image
We are going to need three functions from the first script to make this work:
- get_region_event_is_in(id) - id is the event id of the event (Bill) that the npc is currently in
- get_region_player_is_in - what region the player is in
- get_event_position_relative_to_player(id) - is the event (Bill) to the right, left, above, or behind the player. id will be Bill's event id in this case.
To do this, in the new event's page make a condition branch that checks if Bill (event id 1) is in region 2 (ex: get_region_event_is_in(1) == 2 ). Make sure to use script option on page 4 of the conditional branch pop-up window to get this check to work. Within this condition branch another condition branch should be added that checks what region the player is in (ex: get_region_player_is_in == 1).
In this condition branch, add four more conditional branches that check if the event is to the left, right, above, or below the player (ex: get_event_position_relative_to_player(1) == "right"). Note that right needs to be in-between "" marks. within each of these branches make the player move in the opposite direction of the check for the branch (ex: if you check to see if the event is to the right of the player, then move the player to the left).
This will cause the player to move out of the way of the npc when he gets close to his destination.
(optional) Step 5:
Make it so the second event stops checking if the player is in the way when the destination is reached.
like this (this switch will make the event go to the next page):
Demo:
Here is a link to the demo of the tutorial that I tested.
Link: https://www.dropbox.com/s/c8kjy2e8awskndu/NPC%20tutorial%201.zip?dl=0
Hope this tutorial helps you out (it is my first tutorial).
Thank you for your time.
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...