Triggering NPC to follow and interact

● ARCHIVED · READ-ONLY
Started by BardicHeart 9 posts View original ↗
  1. Okay, first off I'm fairly new to VX Ace, I have  fairly good grasp of basic events but know very little about scripting.

    Here's what I'm trying to do.

    I want to create an NPC, say a mouse or rat for example.  Normally it wanders about randomly but does nothing.  That part is easy.

    Next I want to create a trigger so that when a certain condition is met, the mouse will follow the character around.  I think I have this part figured out.  I use a change move route command, set speed, and it will follow the character.  The trigger event is a bit more tricky.  I set this mouse event to run a parallel process then set a condition branch.  Setting an item in inventory is easy enough, say a "Pied Piper Flute" or "Cheese In Back Pocket".  Now the mouse follows the character around and continues as long as the item is in inventory.  I'd like to use other events, for example I can set a State for a specific actor, is there any way to set as state for all/any actor?   Setting it to use a variable seems clear enough but I'm not clear how to connect that variable with a specific actor?   For example, I'd like to eventually be able to set a variable for an actor such as "Charm"   When Charm is high, some people might start to follow that actor, pester them, etc.  When Charm is low, NPC might ignore the actor.  I'm not sure how to set up such a variable or if its possible, and that might be best left for a separate thread (I would like to set up a variety of custom variables for each actor, things like Faith, Charm, Reputation, Courage, etc. which I could use in various ways in future games I'd like to do.).

    Lastly, once the mouse catches up to the actor, I'd like to set an event creating an interaction.  This might be a fight, or a conversation, or kiss the mouse and it turns into a prince... or frog... or whatever.  These are just examples, the basic concept is something I can use for many things.

    Thanks in advance for any help.
  2. Well after some experimenting I may have solved my own question.  This is what I did, if anyone has any better way of doing it I'd love to hear it.

    First I created an item in my database called "catnip"

    Next I placed some on the map a character could pick, which adds one of catnip to their inventory.

    Next I created a cat event.

    On the first event tab I set it to random movement, set the trigger to Parallel Process and then created a condition branch

    The condition was if there was catnip in the inventory, it set a Self Switch A to ON, otherwise nothing happens

    On Tab 2, with the condition set to Self Switch A on, I set the movement to Approach, Normal speed, and Trigger to Event Touch

    Then I set up a text message "The cat makes a plaintiff meow.  Do you give it the catnip?"

    Then set up a choice, Yes or No

    Yes removed catnip from inventory, No doesn't

    Next I set a Move Route to 1 step back, then 3 Wait commands at 600 (as part of the move route) and did not set the move route to require the player to wait.

    Then Set Self Switch A to OFF

    You pick the catnip, the cat runs up and meows.  If you give it the catnip it goes back to wandering randomly.  If you don't it follows you around until you do.

    Each time you refuse it backs up one step and waits 30 sec before following you again.

    That solves my issue, I can easily modify this to allow various encounters, start fights, etc.  Will come in handy for a variety of things.
  3. BardicHeart, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


    You do not need the event pages to be parallel process, and you do not need a conditional branch to turn on a self switch. Simply put the condition on the second page (above the sprite) to be Catnip in Inventory.
  4. Okay, didn't see the harm in updating my post (and I didn't see the edit button, its faded out and hard to see), but whatever.

    Back on topic, thanks for the tip, I tried it and it works and simplifies the event a bit.
  5. Yeah, it's a bit hard to see, but it becomes clearly visible when you move the mouse over your post. Now you know ;)


    Next time you have a solved thread, please click the "Mark Solved" on the post that provided the solution, rather than your own post. If you look at the top, it shows the "Best Answer" as the one you've marked, so should be the post that actually contains the answer, rather than the one that says "yeah, that worked." ... just for others who might be looking for a similar answer and finds your thread in a search.
  6. Okay, as I experimented with this I ran into a new problem with it.

    Here's what I've got so far...

    First page of event just has the usual wandering cat.

    2nd page of event has the Condition  Item - Catnip in inventory and is set to Event Touch

    so far so good.

    In the event contents I have some dialog (cat meowing and begging, etc.)

    A choice to give it the catnip or not.

    If you don't there's another dialog and a move route that moves the cat back and makes it wait (using two Wait commands set at 600 each) before it comes back after you again.  Kitty REALLY wants its catnip and isn't giving up!

    If you do give it the catnip, I tried to get a lil fancy and here's where things start going wonky

    If you choose Yes, and give it the catnip, 1 catnip it removed from inventory... okay so far

    Next a Self Switch is set to A.. also okay

    Next a Control Timer is started set to 5 min... sort of okay, this is where my troubles begin.

    On page 3, the condition is set to self switch A is ON.  This page is set as a parallel process (doesn't seem to work otherwise)

    There is a condition branch with its condition set to the timer being at 0 or less.

    When it runs to 0, it sets Self Switch A to OFF and the cat will now go back to its normal behavior and if you still have catnip it will want more.

    I thought this was kinda of a cute idea... me an my bright ideas.  LOL 

    Here's my troubles.

    First, the above does work... the cat will wander about for 5 min and then start chasing you again if you still have any catnip left.

    But, first problem, the control timer puts a timer on screen that counts down.  I don't want this and can't figure out a way to hide it.

    Second, after it counts down to zero, it stays there and doesn't go away... and I can't figure out how to remove that either.

    So, my timer works but not in a way that is useful to me.  Thoughts?  Suggestions?  Plaintiff plea for help...
  7. Why are you using another page? Why not just let the first page take over again? If you don't have any catnip, the cat event will switch back to page 1, where it just wanders around. If you get catnip again it'll start following you again.


    Why the timer? Why not just let it start following you again as soon as you have more catnip? Yes, Control Timer puts a timer on the screen, and you can only have one running at a time. That means if you have two cats and give them both catnip, there are going to be problems. The timer stays on the screen because you haven't done a Control Timer > Stop command.
  8. A 3rd page is needed in order for the timer and switch to work correctly.  It requires a parallel process.  That doesn't work if I put it on the 2nd page, plus if you have too many parallel processing going at once it can lag the game.  Doing it this way reduced the time that process is running.

    Why the timer, to create a delay between the time you give the cat some catnip and when it wants more.  Thought that part was obvious.  Why do it?  Why not, I'm just experimenting and learning.  I can think of a number of situations where I might want to use something like this in a game in various ways.  For example, a game where you have to feed and raise pets... delay is the time before it gets hungry again.  Or maybe its a guard dog and you feed it something to calm it down, the delay is the amount of time before it goes back on "guard" again.

    Thanks for explaining the timer, those were things I didn't know.  So now I need to find some other way of creating a timed delay.  The one thing I did like about the timer is that while it was running the cat would wander about, which was something I did want.  Just need to find another way of doing that now without using that Timer.  Naturally if I an alternative doesn't need a parallel process (and i'd prefer that) then the 3rd page wouldn't be needed either.
  9. Look for my Multi Timer script. It will allow you to accomplish this with your self switch and 3rd page, but without the parallel process, no counter on the screen, and you can have multiple events all with their own timers.