AwesomeCool

Bratty and spoiled little sister
Veteran
Joined
Jul 20, 2013
Messages
2,862
Reaction score
1,947
First Language
English
Primarily Uses
N/A
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.

Put these scripts in the same order as the links are in the script section.

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:

dzD90Ma.png


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.

C991LZp.png


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:

RWkbxnP.png


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:

rmOpzqX.png


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.
get_region_event_is_in(id) is going to check if the event is in region 2 (or the region you picked for the region surrounding the ending point). get_region_player_is_in is going to check if the player is in region 1. get_event_position_relative_to_player(id) is going to be used to see what direction to move the player if he is in the ending sport (to allow the npc to move there).

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):

SVgfMC5.png


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. :)
 

GrandmaDeb

Modern Exteriors Posted!
Veteran
Joined
Apr 25, 2012
Messages
4,467
Reaction score
2,967
Primarily Uses
Hi AwesomeCool. I have been looking over your tutorial. =]


I am having a brain freeze. Is this just supposed to allow the NPC to walk around you if you stand in a place that blocks an NPC path?


Because obviously if the NPC freezes until you move, he just goes on about his business once you move out of the way, right?
 

Latest Threads

Latest Posts

Latest Profile Posts

Theydies and gentlethems, presenting Touch the Stars character #1: Anna Smith and her transformed form, Sagittaria!1624568259771.png
Anyone seen Dsiver around?
I wish character bust packs had options for both side-facing and front-facing for the same characters.
Looks like I'm going to have to cancel another game.
For now it is in testing phase: Changing the game icon from Rm2k/2k3 without needing to edit the executable.
Rm2k-DinChangeIcon.png

Forum statistics

Threads
112,531
Messages
1,069,006
Members
146,218
Latest member
mpseee
Top