Script issue with NPCs moving

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Script issue with NPCs moving
Apprentice
Member # 5234
Profile #0
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. :)

Thanks a lot!

--------------------
Online Blades of Avernum Wiki Reference
Posts: 7 | Registered: Friday, November 26 2004 08:00
Triad Mage
Member # 7
Profile Homepage #1
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.

--------------------
"At times discretion should be thrown aside, and with the foolish we should play the fool." - Menander
====
Drakefyre's Demesne - Happy Happy Joy Joy
Encyclopedia Ermariana - Trapped in the Closet
====
You can take my Mac when you pry my cold, dead fingers off the mouse!
Posts: 9436 | Registered: Wednesday, September 19 2001 07:00
The Establishment
Member # 6
Profile #2
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.

--------------------
Your flower power is no match for my glower power!
Posts: 3726 | Registered: Tuesday, September 18 2001 07:00
Apprentice
Member # 5234
Profile #3
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. :)

--------------------
Online Blades of Avernum Wiki Reference
Posts: 7 | Registered: Friday, November 26 2004 08:00
Shock Trooper
Member # 5181
Profile Homepage #4
quote:
Originally written by Tanabi:


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

Hide them from the player somewhere.
Posts: 262 | Registered: Thursday, November 11 2004 08:00
Agent
Member # 2820
Profile #5
You could make a silly custom terrain type just reserved for monsters asleep. You could have the terrain script have a memory cell to contain which monster is "sleeping" in it. When a character moves into the space, the character is relocated next to the bed.

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00