Author Topic: Moving NPCs via Events  (Read 2851 times)

Offline MaskedGamer

  • Beginner
  • Bow Bearer
  • *
  • Posts: 26
  • An adventure like all before.
Moving NPCs via Events
« on: July 31, 2009, 09:22:58 am »
Sorry to make another topic but I'm having problems getting an event to work.  I want to move an NPC via the "Move NPC" event command but it only works temporarily.  I can move an NPC halfway across the map or just to the next space over but as soon as I move away for a distance, the NPC returns to it's original position.  Have I set the NPC placement settings incorrectly for a move to be permanent or does the command not work like I think it does?
Building, getting bored, building again, getting bored again, repeat.
[Current Project: Daeyln (working title)]

Offline dmpdesign

  • Moonlight Retiree
  • Administrator
  • Dark Slayer Destroyer
  • *****
  • Posts: 1864
    • http://swordofmoonlight.com
Re: Moving NPCs via Events
« Reply #1 on: July 31, 2009, 01:09:29 pm »
Interesting.  I have heard of people having issues with that.

Here is my recommeded solution...(I haven't tried it though so it may not work).

Create a dummy object on your map if you haven't already, and create a counter with the NPC name as the name of the counter.

Now this can probably be done a few different ways..but this is likely the easiest way.

Set up your event on the dummy object, have the event be always on but looking for a counter value.

When you want to move the npc to the second destination use something to move the counter value to say counter=1.  Now the always on event connected to the dummy object will move the npc to the new location as long as that counter=1.  So this way, even when the game tries to respawn the npc at its original location, the always on event will warp him back to the spot he should be in....so that you never actually see him in the original spot.

Its messy I guess but should work.

An alternative method would be to place the NPC in both locations on the map, and have their placement set to triggered by event, rather than always appear.

Then like above, trigger an event that turns off the original NPC and activates the same NPC in the 2nd location.

Either way should work.

And by all means, if you run into issues, post about them, don't be sorry!
- Todd DuFore (DMPDesign)
Site Founder

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Moving NPCs via Events
« Reply #2 on: July 31, 2009, 03:52:55 pm »
First off, by "move" I'm assuming you mean "warp". A move NPC instruction would be awesome but does not exist.

But yeah, this is a pain. Unlike the move object instruction, where the current location of the object is remembered, even when saving/loading games...

As near as I can tell what is really going on, is the NPC or monster does not actually warp unless it is loaded into memory, as in you are nearby it. And it will reset itself as soon as you encounter it's usual respawn point. I don't know if this is another bug or intentional. But it is certainly not intuitive, so I'm guessing it's a bug.

I've seen on one of Tom's map where he warps an NPC that seems to disappear forever. I haven't really looked into it though.

The way I handle this is usually make the warp an always on event with a condition so the npc will warp before it becomes visable. The only reason to do that afaik is for convenience in the map editor, so you don't have to deal with multiple instances of an npc.

Offline MaskedGamer

  • Beginner
  • Bow Bearer
  • *
  • Posts: 26
  • An adventure like all before.
Re: Moving NPCs via Events
« Reply #3 on: August 02, 2009, 08:03:08 am »
Darn that memory and things loading in to it.  It seems like the easiest way to get around this is to make a double for the quest and just add it and remove the original for the duration of the quest.

Edit:
So, here's what I did: turn the original NPC in to an "event" NPC, attached a script to it that makes the NPC visible once and then stops (change to a blank leaf), removed the NPC and made the copy visible, then removed the copy and made the original visible.  It feels like a really round-about way to get this done but it works without using a variable.  Inter-map quests need to use a variable though.

This has given me some insight in to the way enemies spawn too.  I'll have to go back and redo the way I've set them up.
« Last Edit: August 02, 2009, 08:38:27 pm by MaskedGamer »
Building, getting bored, building again, getting bored again, repeat.
[Current Project: Daeyln (working title)]

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Moving NPCs via Events
« Reply #4 on: August 07, 2009, 06:23:31 pm »
^That reminds me, is there even an instruction to hide/show NPCs?? I forget.

PS: Next time you post an addendum like that, don't edit it in, because most likely everyone will not see it :doh:

Was a freak accident I saw it. Just make another post...

Offline MaskedGamer

  • Beginner
  • Bow Bearer
  • *
  • Posts: 26
  • An adventure like all before.
Re: Moving NPCs via Events
« Reply #5 on: August 20, 2009, 06:21:08 am »
Some boards are strict on that kind of double posting so editing is what I did.  I'll just make new posts from now on.

There is a command to hide and show NPCs, or rather remove NPCs from a map and show Event NPCs.  They work based on how the NPCs spawn though.   NPCs that spawn as events can be controlled nicely but normal spawns are a bit more finicky.
Building, getting bored, building again, getting bored again, repeat.
[Current Project: Daeyln (working title)]

Offline Holy_Diver

  • Holy Diver
  • Archmage of Light
  • *****
  • Posts: 2280
  • This account won't read/reply to Private Messages
Re: Moving NPCs via Events
« Reply #6 on: August 20, 2009, 04:51:05 pm »
I've never understood why people much less boards discourage double posting, unless they assume no one reads the board in real-time nor cares to follow a discussion!! It makes sense if you think of a bulletin board as classified ads, but not as a conversation. It could be a throwback to the time when most bulletin boards were really just logs of mailing lists... many such boards still exist where the line between bulletin board and mailing list is blurred, and it can be embarrassing when you don't realize your really posting to a mailing list, because obviously the dynamics are different.

Basically if you have an afterthought in a mailing list you gotta wait until someone replies to put it out, or things can get confusing.
« Last Edit: August 20, 2009, 04:53:03 pm by Holy Diver »