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!

[RunUO 1.0 Final/2.0 RC1] Sleepable Beds

ssalter

Account Terminated
[RunUO 1.0 Final/2.0 RC1] Sleepable Beds

UPDATE
These bed scripts allow a player to lie down on them and 'sleep'.
Inspiration for this was David's Sleeping NPC's scripts and much of that code was used as a base for this release.

[add sleep and get a list of 10 types of sleeping beds. These are deedable Addons.
large beds aligned EW and NS
small beds aligned EW and NS
futons aligned EW and NS
elven beds aligned EW and NS
tall elven beds aligned EW and NS

The player avatar on the bed will snore and little "ZZZ"s will float above their head. Only the player can wake themself up. If someone else disturbs the sleeper there could be dire results.

This was written, tested and used for a year and a half or so on a RunUO 1.0 shard. We used to sell them as house furnishings to players as a gold sink. :)

This has been tested on a 2.0 build 64 test shard as well and everything appears to work fine.

Just download the release and dump it in your custom scripts folder and restart. Let me know if there are any problems.

Note: In RunUO 1.0, the futon is not a base script although the graphic is in the mul files if you have patched up to OSI. If you DO NOT have a futon script, download that as well. With RunUO 2.0, you don't need to worry about it, it is already there.

Update: Added elven and small beds. Fixed the annoying Z displacement when you wake up. Redid sleeping body position on most beds so they look more natural. Added code so that a bed can only be slept in if an owner, co-owner or friend doubleclicks the bed inside a house.
 

Attachments

  • futon.cs
    693 bytes · Views: 1,522
  • sleepablebeds.rar
    27.9 KB · Views: 2,021

zardoz

Sorceror
This is superb, BUT, there is the making of a nice exploit here. You can click the bed from outside the house it is placed in. You then get into sleep mode and as such, can't do a lot. However, on waking, you are moved UP to the same level as the bed, even if your X,Y remains the same. I can envisage that this could be used to enable a player to be moved to a more advantagous location.

a) This should not be usable if not in line of sight and beyond a set range.
b) I can't see why the player has to be moved on waking, if a) is true.


Just my 2cents worth...

Z.

Update: For me, the following code change to the sleeping beds makes this slightly more secure.

Code:
        public void DoubleClick( Mobile from )
        {
            Mobile m_Player = from as PlayerMobile;

[B]                if (!m_Player.CanSee( this ) || !m_Player.InLOS( this ) )
                {
                m_Player.LocalOverheadMessage( MessageType.Regular, 0x33, true, "You are too far from the bed!" );
                    return;
                }[/B]

            if(m_Player.CantWalk && !m_Sleeping)
            {
                m_Player.LocalOverheadMessage( MessageType.Regular, 0x33, true, "You are already sleeping somewhere!" );
            }
            else
            {
 

Macil

Sorceror
Love it so far, any plans on making more beds?

And a suggestion, maybe make it so health, mana and strength regenerate quickly while sleeping? Kind of like in past Ultimas?
 

Boulder

Sorceror
sleepable beeds

love it works great wish i new how to make it in deeds so i could get them to players
 

otimpyre

Sorceror
Great script

After years of standing next to my UO bed and saying what good is it? My char can finally lay down. Thank you. The elven beds and other bed types would be a nice update. :)
 

zardoz

Sorceror
To make each of the Addons deedable, add the following lines at the top of the scripts, making name changes as required.

Code:
    public class SleeperEWAddon : BaseAddon
    {
[B]        public override BaseAddonDeed Deed
        {
            get
            {
                return new SleeperEWAddonDeed ();
            }
        }[/B]
        public SleeperEWAddon ( Serial serial ) : base ( serial )
        {
        }

And at the end of each Addon script, again making name changes as required.

Code:
[B]    public class SleeperEWAddonDeed : BaseAddonDeed
    {
        public override BaseAddon Addon
        {
            get
            {
                return new SleeperEWAddon ();
            }
        }

        [Constructable]
        public SleeperEWAddonDeed ()
        {
            Name = "a sleepable bed facing east deed.";
        }

        public SleeperEWAddonDeed ( Serial serial )
            : base ( serial )
        {
        }

        public override void Serialize ( GenericWriter writer )
        {
            base.Serialize ( writer );
            writer.Write ( 0 ); // Version
        }

        public override void Deserialize ( GenericReader reader )
        {
            base.Deserialize ( reader );
            int version = reader.ReadInt ();
        }
    }[/B]

I could upload my updated scripts, but I am not yet sure of the ethics and protocol of so doing. The last thing I want to do is tread on anyones toes.

Z.
 

ssalter

Account Terminated
zardoz said:
To make each of the Addons deedable, add the following

Thanks! We always kept the sleepable beds at Home Deco, a special building that we stocked with deco for players to purchase. Staff would just go out and place the beds for the players. Don't know why I never added the deeding code. Just never thought about it. :)

I modified the scripts and reuploaded the zip file. Included a note in the script headers that the deedable code is yours.


As to adding other bed types, sure! Another thing I just never did. I'll add scripts for the elven beds and whatever sleeping arrangements there are these days.
 

zardoz

Sorceror
You are very kind, but no credit was needed. :) Did you get to look at my comments in post #5 above, regarding a possible exploit?

Regards,
Z.
 

zardoz

Sorceror
Macil said:
Love it so far, any plans on making more beds?

And a suggestion, maybe make it so health, mana and strength regenerate quickly while sleeping? Kind of like in past Ultimas?


Make this change to SleeperBedBody.cs to enable the above. Alter the restore rate by changing the /10 divisor to something else.

Code:
        private class InternalTimer : Timer
        {
            private Mobile m_Owner;
            private Item m_Body;
            private DateTime shutitoff = DateTime.Now + TimeSpan.FromSeconds(300);
            public InternalTimer( Mobile m, Item body ) : base( TimeSpan.FromSeconds(10),TimeSpan.FromSeconds(10) )
            {

                m_Owner = m;
                m_Body = body;
            }
            protected override void OnTick()
            {
                if (DateTime.Now < shutitoff)
                {
                    if(m_Body != null)
                        m_Body.PublicOverheadMessage(0,m_Owner.SpeechHue,false,"zZz");
[B]                    if(m_Owner != null)
                    {
                        m_Owner.PlaySound(  m_Owner.Female ? 819 : 1093);

                        if ( m_Owner.Hits < m_Owner.HitsMax )
                        {
                            m_Owner.Hits += ( m_Owner.HitsMax / 10 );
                            if ( m_Owner.Hits > m_Owner.HitsMax )
                                m_Owner.Hits = m_Owner.HitsMax;
                        }

                        if ( m_Owner.Stam < m_Owner.StamMax )
                        {
                            m_Owner.Stam += ( m_Owner.StamMax / 10 );
                            if ( m_Owner.Stam > m_Owner.StamMax )
                                m_Owner.Stam = m_Owner.StamMax;
                        }

                        if ( m_Owner.Mana < m_Owner.ManaMax )
                        {
                            m_Owner.Mana += ( m_Owner.ManaMax / 10 );
                            if ( m_Owner.Mana > m_Owner.ManaMax )
                                m_Owner.Mana = m_Owner.ManaMax;
                        }
                    }[/B]
                }
                else
                {
                    Stop();
                    m_Body.PublicOverheadMessage(0,m_Owner.SpeechHue, false,"You fall into a deep, quiet sleep.");
                }
            }
        }

Regards,
Z.
 

ssalter

Account Terminated
I did but I'm not sure how any sort of exploit could occur. Regardless, players can only place these in their own houses. I'll put a check in to make sure that the mobile that DClicks the bed is in the same house as the bed and is either the owner, coowner or a friend. That should take care of any potential misuses.

zardoz said:
You are very kind, but no credit was needed. :) Did you get to look at my comments in post #5 above, regarding a possible exploit?

Regards,
Z.
 
I liked the concept too but found the issue that if the bed is redeeded it leaves the character stuck.... I therefore moved all the wake code over to the sleeperbody.... which left me with the issue that the bed would not clear sleeping.... I personally solved this by makeing the bed take one owner (in my case, the first person to doubleclick it after being placed) the bed will then tell any future characters that try to use it other than its owner "this is not your bed....
 

ssalter

Account Terminated
Aye, I am sure there are many ways people could utilize the system to create havoc. I didn't include an owner property because we had guild towns where different guild members would utilize the same beds at different times. It was also good for people sharing houses. It would be a good addition though as long as it was player controlled. They could use it in default mode or in "owner" mode I suppose.


silverwolfe said:
I liked the concept too but found the issue that if the bed is redeeded it leaves the character stuck.... I therefore moved all the wake code over to the sleeperbody.... which left me with the issue that the bed would not clear sleeping.... I personally solved this by makeing the bed take one owner (in my case, the first person to doubleclick it after being placed) the bed will then tell any future characters that try to use it other than its owner "this is not your bed....
 

Liacs

Sorceror
wow, this is great. As I am a big fan of Davids sleeping NPC's, this is the creme on the cake for me. Thanks a lot for this. I can't ait to try it out tonight! :)

Lia
 
Top