She won't move!

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: She won't move!
Law Bringer
Member # 2984
Profile Homepage #0
This script snippet is in a conditional block in the start state.

It gets called every tick in the town, as long as it is day - that means, as long as ticks%5000 is between 500 and 4500.

print_str("It is day.");
if (dist_to_waypoint(6,0)>0)
{
print_str("I'm not at my counter.");
if (approach_waypoint(6,0,0)==0)
{
print_str("I'm moving.");
} else print_str("I'm not moving.");
} else print_str("I'm at my counter.");
It is day. Waypoint 0 is on the chair behind the counter of the shop, the vendor is in the adjoining bedroom (see illustration below).

The output produced is

quote:

It is day.
I'm not at my counter.
I'm moving.
[repeat ad nauseum]
However, the vendor remains rooted to her position. As you can see, I removed the (unlocked) door that might have obstructed her path, but that hasn't changed anything.

However, her memory cell #0 is set to 2, meaning she's completely immobile. But that immobility should only extend to her basicnpc AI, since it is explicitly implemented in that script. If she is actually commanded to move with approach_waypoint(), shouldn't that supersede the mobility set in her memory cells?

IMAGE(http://stuff.ermarian.net/arancaytar/images/screenshots/moveit.jpg)

Edit: Yes, I realize this is an extremely fancy thing to want to do. I've already started to implement my fallback plan, which is to just make that vendor sit at her counter 24/7. But it would still be nice to have a little more realism.

[ Monday, April 09, 2007 11:20: Message edited by: Dr. Johann Georg Faust ]

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
Lifecrafter
Member # 6193
Profile Homepage #1
Giving a character 0 mobility makes a character completely immobile, even if it's called in a town state, even if it's used on PC's and joined NPCs (that's right). They cannot move. End of story. However, you can put a set_mobility() call in the town state so the character can start moving, and then take away her mobility when she gets to the spot.

I would handle this by hidden groups, because NPCs can't open doors. Basically you'd have to have either no door, a curtain, or multiple waypoints, one in front of the door, that would flip the terrain open when she gets there (Not fun at all)

Edit: Setting the merchant's memory cell to 1 should fix the mobility problem, although the doors will still mess her up.

[ Monday, April 09, 2007 11:36: Message edited by: The Gators Win it All....... Again ]

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Law Bringer
Member # 4153
Profile Homepage #2
You could fix the door with a system of messages between a customized door script and the creature script. Unnecessarily complex, but eh. :P

--------------------
Gamble with Gaea, and she eats your dice.

I hate undead. I really, really, really, really hate undead. With a passion.
Posts: 4130 | Registered: Friday, March 26 2004 08:00
Lifecrafter
Member # 6193
Profile Homepage #3
Yeah, and basically the creature won't know the door is passable, so you'd have to tell it to walk to the door, then walk to the next destination.

I think the most likely solution would be to make a fake door that's passable, and ring it in special rectangles so that the party can't cross through it without opening the 'door' first.

Or you could just use curtains.

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Law Bringer
Member # 2984
Profile Homepage #4
Well, now I simply have her as part of a hidden group that only activates at day.

Same result, a tenth of the effort.

But hey, these are the kind of things you have to learn when you get acquainted with scripting. :)

I also now understand how a simple memory cell can actually zap her mobility even outside the basicnpc script.

It's because the basicnpc script not only doesn't command her to move when memory cell #0 is 2. It also explicitly orders her never to move at all.

if (get_memory_cell(0) == 2)
set_mobility(ME,0);
break;


--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
Law Bringer
Member # 4153
Profile Homepage #5
You know you can use set_creature_memory_cell() to toggle that, right? Couple that with a set_mobility() call and you should be able to unfreeze that NPC and keep her from freezing up again.

I've wound up pulling similar strings in SoG with the talknode in memory cell 3. Very effective.

EDIT: Clarification... I was eating a wrap when I typed the first version.

[ Monday, April 09, 2007 17:37: Message edited by: Ephesos ]

--------------------
Gamble with Gaea, and she eats your dice.

I hate undead. I really, really, really, really hate undead. With a passion.
Posts: 4130 | Registered: Friday, March 26 2004 08:00
Law Bringer
Member # 2984
Profile Homepage #6
I can imagine it is. I was going to give her a different dialogue if the player tried to enter the shop at night time (along the lines of "get the hell out of my house!").

However, I've had trouble locking and unlocking doors by setting memory cell #0 to different values. Is there something else that needs to be set as well for it to take effect immediately (like set_mobility has to be called explicitly to update the mobility)?

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
Shock Trooper
Member # 5459
Profile Homepage #7
I've never been able to unlock/lock a door by setting the memory cell 0 to different values either. But you can also unlock doors by setting the door's flag (memory cells 2 and 3, assign them in the editor.) to 1.

--------------------
These are my scenarios. I may have too much free time but I really don't care.
Backwater Calls, Magus of Cattalon, Rats Aplenty
Get them here
Visit The Lyceum for all your rating needs.
Posts: 211 | Registered: Sunday, January 30 2005 08:00
Law Bringer
Member # 2984
Profile Homepage #8
Okay, so I have to use an SDF for that. Gotcha.

But I guess it also means I can't change the difficulty of a lock on the fly. Shame... I can think of a few nifty tricks one could do with that. Think "this door requires 3 more Living Tools to open", or something like that.

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
Law Bringer
Member # 2984
Profile Homepage #9
quote:
Originally written by Ephesos:

You could fix the door with a system of messages between a customized door script and the creature script. Unnecessarily complex, but eh. :P
Vendor sends message to door: "Open Sesame"

Door sends message to vendor: "Thank you for making a simple door very happy. Buy Sirius Cybernetics Happy People Doorways™!"

:P

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
Lifecrafter
Member # 6193
Profile Homepage #10
You would still need waypoints to tell the creature to approach the door.

By the way, you CAN change a door's lock difficulty, but not with the standard door script. You can use messaging calls, and move the lock setting code to the start_state:
if(my_curent_message() > 0) {
i_am_locked = 1;
set_mechanism_difficulty(my_current_message());
set_physical_strength(my_current_message());
if (i_am_open == 1) {
flip_terrain(my_loc_x(),my_loc_y());
i_am_open = 0;
}
}
if(my_current_message() == 0){
i_am_locked = 0;
set_mechanism_difficulty(0);
set_physical_strength(0);
}
Theoretically that should work.

[ Tuesday, April 10, 2007 06:00: Message edited by: The Gators Win it All....... Again ]

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
? Man, ? Amazing
Member # 5755
Profile #11
To add even more unnecessary complexity, if watching the shopkeeper go sit in her chair is soooo bloody important, why not just set up a cutscene that shows that movement if the party is there at the right time? Then use the hidden group option to actually move the character.

--------------------
quote:
Originally written by Kelandon:

Well, I'm at least pretty sure that Salmon is losing.


Posts: 4114 | Registered: Monday, April 25 2005 07:00
Shaper
Member # 3442
Profile Homepage #12
I did something like this in TV, which just erased the night creature and replaced it with the day one.

To clean it up slightly, I added an if call to see if it was day, and then flashed up a message_dialog to explain that the people were waking up, going outside etc. That way, people didn't just appear in front of the party.

Your way is better, for sure, but I thought I'd add another way to do this.

--------------------
And when you want to Live
How do you start?
Where do you go?
Who do you need to know?


*Name by Slarty, so blame him if it's filthy...
Posts: 2864 | Registered: Monday, September 8 2003 07:00
Law Bringer
Member # 4153
Profile Homepage #13
quote:
Originally written by The Gators Win it All....... Again:

you CAN change a door's lock difficulty, but not with the standard door script.
Yes you can. Well, using door.txt and the town script.

set_terrain_memory_cell(which script, which cell, value) in the START_STATE or wherever works.

--------------------
Gamble with Gaea, and she eats your dice.

I hate undead. I really, really, really, really hate undead. With a passion.
Posts: 4130 | Registered: Friday, March 26 2004 08:00
Law Bringer
Member # 2984
Profile Homepage #14
Didn't have an effect for me.

But perhaps this was back when the entire state didn't execute at all. I'd have to test it again.

--------------------
Encyclopaedia ErmarianaForum ArchivesForum StatisticsRSS [Topic / Forum]
My BlogPolarisI eat novels for breakfast.
Polaris is dead, long live Polaris.
Look on my works, ye mighty, and despair.
Posts: 8752 | Registered: Wednesday, May 14 2003 07:00
Lifecrafter
Member # 6193
Profile Homepage #15
Ephesos: No, you can't. Mechanism difficulty is set in the init_state, so changing the memory cell won't have an effect. To make it work you have to add code to the start_state that will reset the mechanism difficulty (like the code I posted above)

[ Wednesday, April 11, 2007 06:19: Message edited by: The Gators Win it All....... Again ]

--------------------
Guaranteed to blow your mind.

Frostbite: Get It While It's...... Hot?
Posts: 900 | Registered: Monday, August 8 2005 07:00
Infiltrator
Member # 3040
Profile #16
I've actually thought fairly extensively about NPC's moving through doors, and I've arrived at some possibly workable solutions. One method might look as follows:

1) Duplicate the door terrains to create another set that looks the same but is not blocked for movement.

2) Alter basicnpc.txt (or create a new NPC script) to do the following: At the beginning of the NPC's turn, change all door terrains in the town into the second, non-movement-blocking variety. At the end of the NPC's turn, change them back into regular doors.

3) Change the door.txt script (or create a new door script) to do the following: Every turn, make a note of the placement of all NPCs surrounding the door. In the next turn, if the door was closed and the arrangement of NPCs has changed in the appropriate manner, open the door (and optionally print a message or play a sound).

This configuration would not alter doors from the player's perspective, since the doors would be normal while the player moved. Some interesting problems to consider might be locked doors, locked doors to which some NPCs have keys, and so on. Other complexities might be line of sight issues, for instance when to print a message or play a sound.

I'm fairly confident that all of these issues could be solved, given enough motivation. I lack that motivation, but hopefully I've provided a blueprint for someone else to work with.

I've had more technical ideas than I've posted here (e.g. about how exactly to implement the door/npc scripts), so if anyone has any desire to actually implement this and wants suggestions, let me know.

--------------------
5.0.1.0.0.0.0.1.0...
Posts: 508 | Registered: Thursday, May 29 2003 07:00