RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[1.0-2.0] Sleeping npc's

David

Moderate
otimpyre said:
Be nice if they snored. Or if it could set there title to sleeping then reset to "Blah"
Maybe they could run off an emote script. And occasionly play sound

case "snore":
SoundInt = 34;
break;
Just a thought. Great script thanx

Voran is correct regarding the snoring. It was ommited on purpose. You can however easily add a title for the SleepingBody. Each creature type which you want to change the title for will need a SleepingName attribute. Here is an example
Code:
namespace Server.Mobiles 
{ 
	[CorpseName( "a corpse" )]
	[SleepingName( "a sleeping local" )]  // <----- Add this line -----<
	public class Townsperson : BaseCreature 
	{
Otherwise the title will default to the npc's name prepended with "Sleeping ".
 

Krystofer

Sorceror
Most excellent!

I spent weeks on top of weeks scripting systems like this for a NWN project, added a huge amount of immersion... My shard is story based and time sensitive, this makes a huge difference. Many many thanks.
 

David

Moderate
Use the [props command to assign the Mobile which goes to sleep, and make sure Active is true. It should work. You may want to set Debug to true while you are testing it, but be aware that anyone can see the debug text.

Sometimes if you play with the time settings in just the wrong way it can get confused. If that happens just wait one UO day (default 2 hours) and it will straighten itself out.
 

Voran

Wanderer
I have found a bit of a major bug with this - but sadly, the person I need to blame is me, not David!
*grins*
Here are the updated Awaken spells, so that when some nosey player casts them on a slumbering NPC, it won't suddenly vanish.
Awaken.cs
Code:
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Gumps;
using Server.Spells;
using Server.Targeting;
using Server.Network;
using Server.Regions;

namespace Server.Spells.Linear
{
	public class AwakenSpell : LinearSpell
	{
		private static SpellInfo m_Info = new SpellInfo(
				"Awaken", "An Zu",
				SpellCircle.First,
				218,
				9002,
				Reagent.SulfurousAsh
			);
	

      public override double CastDelay{ get{ return 1.0; } }
      public override double RequiredSkill{ get{ return 0.0; } }
      public override int RequiredMana{ get{ return 5; } }

		public AwakenSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
		{
		}

		public override void OnCast()
		{
			Caster.Target = new InternalTarget( this );
		}

	

		public void Target( SleepingBody slumber )
		{
			if ( !Caster.CanSee( slumber ) )
			{
				Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
			}
			
			else if ( CheckSequence() )
			{
				
				if(slumber!=null)
				{
				
						slumber.Owner.RevealingAction();
				slumber.Owner.Frozen=false;
				slumber.Owner.Squelched=false;
			slumber.Owner.Map=slumber.Map;
					slumber.Owner.Location=slumber.Location;
				slumber.Owner.Animate(21, 6, 1, false, false, 0);;
				
				
					slumber.Delete();
				slumber.Owner.SendMessage("You wake up!");
				}
				Caster.SendMessage("You awaken them!");
					
				
				
			}

			FinishSequence();
		}

		private class InternalTarget : Target
		{
			private AwakenSpell m_Owner;

			public InternalTarget( AwakenSpell owner ) : base( 12, false, TargetFlags.None )
			{
				m_Owner = owner;
			}

			protected override void OnTarget( Mobile from, object o )
			{
				if ( o is SleepingBody )
				{
					m_Owner.Target( (SleepingBody) o );
				}
				else
				{
					from.SendMessage("That cannot be awoken." ); // I cannot mark that object.
				}
			}

			protected override void OnTargetFinish( Mobile from )
			{
				m_Owner.FinishSequence();
			
			}
		}
	}
}

AwakenAll.cs
Code:
using System;
using System.Collections;
using Server.Misc;
using Server.Targeting;
using Server.Network;
using Server.Items;

namespace Server.Spells.First
{
	public class AwakenAllSpell : Spell
	{
		private static SpellInfo m_Info = new SpellInfo(
				"Awaken All", "Vas An Zu",
				SpellCircle.First,
				218,
				9031,
				Reagent.Garlic,
				Reagent.Ginseng
			);

		public AwakenAllSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
		{
		}

		public override void OnCast()
		{
			Caster.Target = new InternalTarget( this );
		}

		public void Target( IPoint3D p )
		{
			if ( !Caster.CanSee( p ) )
			{
				Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
			}
			else if (  CheckSequence() )
			{
				SpellHelper.Turn( Caster, p );

				
				ArrayList targets = new ArrayList();
	if(this.Scroll!=null)
				Scroll.Consume();
				Map map = Caster.Map;

				if ( map != null )
				{
					
					IPooledEnumerable eable = map.GetItemsInRange( new Point3D( p ), 3 );

					foreach ( Item m in eable )
					{
					

						if (  Caster.CanSee( m )&& m is SleepingBody  )
							targets.Add( m );
					}

					eable.Free();
				}

				for ( int i = 0; i < targets.Count; ++i )
				{
					
					SleepingBody m = (SleepingBody)targets[i];

				
				if(m!=null)
					{
						m.Owner.RevealingAction();
				m.Owner.Frozen=false;
				m.Owner.Squelched=false;
			m.Owner.Map=m.Map;
						m.Owner.Location=m.Location;
				m.Owner.Animate(21, 6, 1, false, false, 0);
				
						m.Owner.SendMessage("You wake up!");
					
					m.Delete();
					}
				Caster.SendMessage("You awaken them!");
					
				}
			}

			FinishSequence();
		}

		private class InternalTarget : Target
		{
			private AwakenAllSpell m_Owner;

			public InternalTarget( AwakenAllSpell owner ) : base( 12, true, TargetFlags.None )
			{
				m_Owner = owner;
			}

			protected override void OnTarget( Mobile from, object o )
			{
				if(o is SleepingBody)
				{
				IPoint3D p = o as IPoint3D;

				if ( p != null )
					m_Owner.Target( p );
				}
				else
					from.SendMessage("That is not a slumbering being");
				}

			protected override void OnTargetFinish( Mobile from )
			{
				m_Owner.FinishSequence();
			}
		}
	}
}

These are to replace the UVII spells of the same name, if used.
IF YOU DON'T USE THE UVII SPELLS, YOU DO NOT NEED THESE TWO SCRIPTS.

I'll include them in the next release of the UVII spells that I get around to.
*aware that it's been almost a year since the last update*
 

David

Moderate
*chuckles* Good catch, thanks Voran! :)

Rob24, the Sleeper device will cause any Mobile to go to sleep on a regular schedule based on a UO day. It is used to make vendors close up shop or make certian creatures sleep when you want them to. It is of most use to a role-playing shard.
 

Voran

Wanderer
I've done some small updates to both the sleeping body and the whole UVII Spell System. I'll aim to post an update on Sunday.
I'm stumped for how to write the last 3 spells, so I'm going to start including Ultima VII Part Two spells :)

Sleeping body updates include "Optimised Snorage", to remove some timers.
 

Liacs

Sorceror
And locked doors?

Hallo Voran,

wouldn't it also be possible to just lock doors at a certain times? I like the idea to have a real night but the corpses look kind of messy to me. They are never really in the bed... they always look like they just want to fall out of their beds *grins* Or perhaps I have to try big beds?

Greetz

Lia
 

Voran

Wanderer
It's David's script, not mine :)
But I think they look fine on the bed - it's always best to test them to get just the right direction and z location, though
 

Liacs

Sorceror
oh, sorry David, sorry Voran that I mixed you up...
I think I still have to try a bit more with them...

if you say they are laying nicely it is just me I guess...

Lia
 

Joeku

Lord
I'm not completely sure, as I am not using this, but I came across and am trying to help out ^^
In SleepingBody.cs:
Code:
		[Constructable] 
		public SleepingBody( Mobile owner, bool blessed, bool isSpell ) : base( 0x2006 )
		{
			Stackable = true; // To supress console warnings, stackable must be true
			Amount = owner.Body; // protocol defines that for itemid 0x2006, amount=body
			Stackable = false;
			m_Blessed = blessed;
			Movable = false;

			m_Owner = owner;
			Name = m_Owner.Name;
			m_SleepingBodyName = GetBodyName( owner );
			Hue = m_Owner.Hue;
			Direction = m_Owner.Direction;
			m_spell = isSpell;
Make it this:
Code:
		[Constructable] 
		public SleepingBody( Mobile owner, bool blessed, bool isSpell ) : base( 0x2006 )
		{
			Stackable = true; // To supress console warnings, stackable must be true
			Amount = owner.Body; // protocol defines that for itemid 0x2006, amount=body
			Stackable = false;
			m_Blessed = blessed;
			Movable = false;
			[COLOR=Red]Visible = false;[/COLOR]

			m_Owner = owner;
			Name = m_Owner.Name;
			m_SleepingBodyName = GetBodyName( owner );
			Hue = m_Owner.Hue;
			Direction = m_Owner.Direction;
			m_spell = isSpell;
I hope that helps!
 
H

hudel

Guest
It's a very nice system. I trie it on my homeshard. The addition to make the sleeping bodys invisible would help on an small shard, where not every NPC has his own house and place to sleep.

I can set the sleeping place as far away as I want, the npc spawn always after his "sleepingtime" on the placed sleeper, right? When I set a "Sleeper" for every npc and the npc is a vendor that spawns on a spawner, what appears when the npc respawns? Do I have to reset all "sleepers"?

Thanks for sharing it.

One question: I've seen, that the time in RunUO seems on my shard very oddly. I got the respond from a NPC that it is midnight but the sun was shining. I looked at my admin wristwatch ;) and I saw, that was 12.00. When he said it is noon, then it is middle of the night. Can someone please tell me how I can adjust that problem?
 

Liacs

Sorceror
one other question: how can I manage to let the sleepers give a warning a few minutes before they go to sleep, something like: "hurry up, I am tired!" or stuff like that?

That would be awsome!

Thanks a lot

Lia
 

brodock

Sorceror
i know this is on archive...
but here is a small sugestion that can make it a little more realistic...
why not make vendor walk to bed instead of teleport it to there... (paths)
 

David

Moderate
This script works without modification in RunUO 2.0.
(Desired improvements notwithstanding--that is for another day.)

enjoy.
 
Top