Jump to content

Script issue with NPCs moving


Tanabi

Recommended Posts

Hello there;

 

I've got a series of scripts that involve NPCs traveling the map. However, on the way from point A to point B, there's usually a door or two in the path. This is proving to be problematic.

 

Right now, what I'm doing is sort of an artificial waypoint system; I have the NPC going to the first door, checking the door tile, toggling the door if necesary, moving a step forward, closing the door behind him, then journeying onward.

 

This is proving to be both labor intensive, and isn't working so well. He goes up to the door, then stops. Nothing else happens. Plus, the method is striking me as generally klunky and inefficient.

 

What I'm wondering, is can anyone come up with a way for an NPC to go from point A to point B and -automatically- open all the doors along the way?

 

Note! Locks do NOT have to be checked, assume the NPC can open whether or not it's locked. It would be preferable if the NPC closed the door behind him, but not necesary.

 

I've got a couple ideas I may try, I need to write them out on paper first, but I figured I'd pose the question to you guys and see if anyone has some wisdom in the matter already. smile

 

Thanks a lot!

Link to comment
Share on other sites

If you want to cheat and only use this once, you can count the steps on the path, create a step timer, and when it gets to step x, open door A, step x+2, close door A, step Y, open door B, step Y+2, close door B, etc.

 

There are better ways to do this. You can put something in the creature script to check for doors around him. I'm not sure if there's a call for this, but it doesn't really matter, since you can use my_loc_X and my_loc_y to check for anything nearby.

Link to comment
Share on other sites

The town script of Valzier in A Perfect Forest does some door opening. Unfortunately, with two doors in his way, there was no need to make this automatic.

 

What you could do is check every spot around the NPC in the start state and open any doors available. You may want to make the NPC face the appropriate direction as well. This is still a bit messy, however.

Link to comment
Share on other sites

Okay, I've found a solution to my door problem.

 

Basically, there's no automatic way around it; it would be possible to make an automatic way, but it would be just crazy and not worth the effort.

 

Instead, I fixed what I had. What I do now, is open the door and use relocate_character to immediately push the character through the door. Then, I close the door and use the normal move command to have him walk to the next door. This may look slightly goofy to anyone watching the character, but, it works and it makes the code simpler.

 

Turns out the bug in my code, was relying on move_to_loc_x_y. move_to_loc_x_y will not move a character to an adjacent space, I guess because it's too "near".

 

Thanks to the people who replied; I'm coupling this with my time-code to make NPCs travel to different places on the map based on times, thus doing NPC scheduling sort of like Ultima V. Shop's'll open and close and whatnot. May be kind of CPU heavy, but I plan on having the schedules configurable so you can turn it off while playing the scenario if you don't like it.

 

Unfortunately you can't have people 'stand' on beds to make them go to sleep anymore; beds are obsticals. So I don't really know what to do with 'sleeping' NPCs yet. Suggestions would be welcome. smile

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...