I just want to know how possible this is...
NPC schedules:
I'll use the banker for example, he works every day from X to X, and at night time he locks up the bank and goes to his house and sleeps in his bed, then in the morning he wakes up and goes back to work.
I'd like all working NPCs to do this, how realistic would it be to be able to accomplish even 1 npc being able to do this?
Thanks for your reply
NPC schedules
-
Mindless Automaton
- UOX3 Apprentice
- Posts: 189
- Joined: Wed May 10, 2006 3:48 am
- Has thanked: 0
- Been thanked: 1 time
- Contact:
I was working on a fisherman script to do something like this.
He would walk starting in the AM:
Dock, pub for lunch, back to dock, to a butcher/fishcleaning shop,
Pub again, home.
I was going to code in some actions to do while hanging out at the dock/shop, etc.
The issue I ran into was pathfinding. If another NPC walked in front of him, he'd stop, the route was over. And since I coded it to walk X steps to each location, when the next route started, he wouldn't be in the correct location, so he'd walk off into buildings and such.
Maybe it would be possible to add something to check that he was at the right coordinate and then continue to there if not..
Anyways, I'll slap up what I hacked together later if I can find it.
He would walk starting in the AM:
Dock, pub for lunch, back to dock, to a butcher/fishcleaning shop,
Pub again, home.
I was going to code in some actions to do while hanging out at the dock/shop, etc.
The issue I ran into was pathfinding. If another NPC walked in front of him, he'd stop, the route was over. And since I coded it to walk X steps to each location, when the next route started, he wouldn't be in the correct location, so he'd walk off into buildings and such.
Maybe it would be possible to add something to check that he was at the right coordinate and then continue to there if not..
Anyways, I'll slap up what I hacked together later if I can find it.
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
-
Mindless Automaton
- UOX3 Apprentice
- Posts: 189
- Joined: Wed May 10, 2006 3:48 am
- Has thanked: 0
- Been thanked: 1 time
- Contact:
Sorry for the delay, but here it is:
You'll want to dump it on one of the poor schmucks on Britains docks naturally. Also, I thiink doors auto open for the npcs, but I can't remember.
Also I thing NPCs autoopen/close doors so I didnt have to code in the open door part.
Code: Select all
// The Fair Zane the Fisherman in Britain job script 3206
// Could be any NPC, but you probably won't want 2 fishing
// in the same spot.
// maybe an array of fishing spots & randomly pick one.
function onAISliver( tChar )
{
var hour = GetHour();
var minute = GetMinute();
var hDisp = hour.toString();
var mDisp = minute.toString();
if( minute < 10 )
mDisp = "0" + mDisp;
var curr_time = hDisp + ":" + mDisp; //set up the clock
if ( curr_time == "5:00" )
{
//get breakfast?
// wake up and go fish
tChar.WalkTo( 1468, 1711, 1000 ); //walk to door
// open in door
tChar.WalkTo( 1484, 1768, 1000 ); //walk to docks
tChar.TextMessage( "Time for some fishin'." );
// Turn character towards water set dir = 4?; DIRECTION=SE?
// Casting animation
// Skill checks for catching fish.
// Need to open doors!
}
if ( curr_time == "12:00" )
{
// go to pub for lunch
tChar.TextMessage( "Time for some lunch." );
tChar.WalkTo( 1432, 1731, 1000 ); //walk to inn door
// open in door
// check for if blocked (someone else is sitting there) choose another seat
tChar.WalkTo( 1427, 1724, 1000 ); //walk to seat
}
if ( curr_time == "12:30" )
{
// go fish some more
tChar.TextMessage( "Time for some fishin'." );
tChar.WalkTo( 1431, 1771, 1000 ); //walk to door
// open in door
tChar.WalkTo( 1484, 1768, 1000 ); //walk to docks
}
if ( curr_time == "17:00" )
{
// go to butcher & sell fish
tChar.TextMessage( "Time for sellin' fish." );
tChar.WalkTo( 1452, 1728, 1000 ); // walk to door
// open in door
tChar.WalkTo( 1451, 1723, 1000 ); // move to center
}
// fish sell for about 2 gold each
// butcher sells fish steaks for 6 gold
// need to find an inn that sells cooked fish for price
// runner for the butcher that delivers products 1 or 2 gold per deliver?
if ( curr_time == "18:00" )
{
// go to pub for dinner
tChar.TextMessage( "Time for dinner." );
tChar.WalkTo( 1452, 1727, 1000 ); //walk to door
// open in door
tChar.WalkTo( 1432, 1731, 1000 ); //walk to inn door
// open in door
// check for if blocked (someone else is sitting there) choose another seat
tChar.WalkTo( 1427, 1724, 1000 ); //walk to seat
}
// time before/after dinner to do shopping or whatever..
// check for if blocked (someone else is sitting there)
if ( curr_time == "21:00" )
{
// go to home for sleep
tChar.TextMessage( "Yawn, time for bed." );
tChar.WalkTo( 1468, 1712, 1000 ); //walk to door
// open in door
tChar.WalkTo( 1468, 1705, 1000 ); //walk to bed
tChar.TextMessage( "I'm sleeping, but I can't figure out how to lay down!" );
}
}
Also I thing NPCs autoopen/close doors so I didnt have to code in the open door part.
Last edited by Mindless Automaton on Wed Sep 30, 2009 5:41 pm, edited 1 time in total.
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
-
Mindless Automaton
- UOX3 Apprentice
- Posts: 189
- Joined: Wed May 10, 2006 3:48 am
- Has thanked: 0
- Been thanked: 1 time
- Contact:
Just some other tweaks I'd have added if I continued:
PC Check - Basically if a PC is NOT in the region, I'd just have the NPCs teleport to each location instead of walk it out.
Action - I commented in the code a bit, but I'd code up actions for the NPC depending on the current location. Ie.. if he was on the dock, he would equip his fishing pole and pretend to fish, maybe a random # to see if he caught a fish, etc.
Over all, adding this code to all your NPCs would probably grind your server to a halt as everyone attempted to go to lunch at 12pm
PC Check - Basically if a PC is NOT in the region, I'd just have the NPCs teleport to each location instead of walk it out.
Action - I commented in the code a bit, but I'd code up actions for the NPC depending on the current location. Ie.. if he was on the dock, he would equip his fishing pole and pretend to fish, maybe a random # to see if he caught a fish, etc.
Over all, adding this code to all your NPCs would probably grind your server to a halt as everyone attempted to go to lunch at 12pm
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
-
Razimus
- UOX3 Neophyte
- Posts: 30
- Joined: Sat Feb 05, 2005 8:22 am
- Location: Shangri-La
- Has thanked: 0
- Been thanked: 0
- Contact:
Thanks Automaton for the reply and script! I wouldn't be so complex to have every npc go to lunch, maybe a few, and in my shard it there would only be about 100 working npcs, I already have a list of their names and professions, www.serpentisle.com/locals.html , I'm going to try to remake Ultima VII : Part Two. I could divide the times for work/play/tavern so they don't all do it at once, the monitor trainers, they train, go to the tavern go to bed, stuff like that, a lot of the moonshade mages just walk around their own house and at night go to sleep, not too complex there, same with the fawnians, of course it's currently a dream, but one day hopefully the shard will exist.
--- Razimus aka Perivolcanae Ze Dragon