Ejemplo n.º 1
0
        public static Container LogCorpseCreated(Mobile owner, HairInfo hair, FacialHairInfo facialhair,
                                                 List <Item> initialContent, List <Item> equipItems)
        {
            WriteLine(owner, "A corpse has been created!");

            return(null);
        }
Ejemplo n.º 2
0
        public static Container HandleCreateCorpse(
            Mobile owner,
            HairInfo hair,
            FacialHairInfo facialhair,
            List <Item> initialContent,
            List <Item> equipItems)
        {
            Container c = null;

            if (_CreateCorpseSuccessor != null)
            {
                c = _CreateCorpseSuccessor(owner, hair, facialhair, initialContent, equipItems);
            }

            if (c == null || c.Deleted)
            {
                c = Corpse.Mobile_CreateCorpseHandler(owner, hair, facialhair, initialContent, equipItems);
            }

            if (c != null && !c.Deleted)
            {
                var d = GetDungeon(owner);

                if (d != null && !d.Deleted)
                {
                    d.OnCorpseCreated(owner, c);
                }
            }

            return(c);
        }
Ejemplo n.º 3
0
 public MilitiaFighterCorpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems) : base(
         owner,
         hair,
         facialhair,
         equipItems
         )
 {
 }
Ejemplo n.º 4
0
        public static Container Mobile_CreateCorpseHandler(
            Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> initialContent, List <Item> equipItems)
        {
            var c = new Corpse(owner, hair, facialhair, equipItems);

            owner.Corpse = c;

            for (int i = 0; i < initialContent.Count; ++i)
            {
                Item item = initialContent[i];

                if (owner.Player && item.Parent == owner.Backpack)
                {
                    c.AddItem(item);
                }
                else
                {
                    c.DropItem(item);
                }

                if (owner.Player)
                {
                    c.SetRestoreInfo(item, item.Location);
                }
            }

            if (!owner.Player)
            {
                c.AssignInstancedLoot();
                c.HasAssignedInstancedLoot = true;
            }
            else
            {
                PlayerMobile pm = owner as PlayerMobile;

                if (pm != null)
                {
                    c.RestoreEquip = pm.EquipSnapshot;
                }
            }

            Point3D loc = owner.Location;
            Map     map = owner.Map;

            if (map == null || map == Map.Internal)
            {
                loc = owner.LogoutLocation;
                map = owner.LogoutMap;
            }

            c.MoveToWorld(loc, map);

            return(c);
        }
Ejemplo n.º 5
0
        public FacialHairEquipUpdate(Mobile parent)
            : base(0x2E, 15)
        {
            var hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.FacialHairHue;

            Stream.Write(FacialHairInfo.FakeSerial(parent.Serial));
            Stream.Write((short)parent.FacialHairItemID);
            Stream.Write((byte)0);
            Stream.Write((byte)Layer.FacialHair);
            Stream.Write(parent.Serial);
            Stream.Write((short)hue);
        }
Ejemplo n.º 6
0
        public CorpseEquip(Mobile beholder, Corpse beheld) : base(0x89)
        {
            List <Item> list = new List <Item>();

            for (int a = 0; a < beheld.EquipItems.Count; a++)
            {
                list.Add(beheld.EquipItems[a]);
            }

            int count = list.Count;

            if (beheld.Hair != null && beheld.Hair.ItemID > 0)
            {
                count++;
            }

            if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
            {
                count++;
            }

            EnsureCapacity(8 + (count * 5));

            m_Stream.Write((int)beheld.Serial);

            for (int i = 0; i < list.Count; ++i)
            {
                Item item = list[i];

                if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld)
                {
                    m_Stream.Write((byte)(item.Layer + 1));
                    m_Stream.Write((int)item.Serial);
                }
            }

            if (beheld.Hair != null && beheld.Hair.ItemID > 0)
            {
                m_Stream.Write((byte)(Layer.Hair + 1));
                m_Stream.Write((int)HairInfo.FakeSerial(beheld.Owner) - 2);
            }

            if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
            {
                m_Stream.Write((byte)(Layer.FacialHair + 1));
                m_Stream.Write((int)FacialHairInfo.FakeSerial(beheld.Owner) - 2);
            }

            m_Stream.Write((byte)Layer.Invalid);
        }
Ejemplo n.º 7
0
        public CorpseEquip(Mobile beholder, Corpse beheld) : base(0x89)
        {
            var list = beheld.EquipItems;

            var count = list.Count;

            if (beheld.Hair?.ItemID > 0)
            {
                count++;
            }

            if (beheld.FacialHair?.ItemID > 0)
            {
                count++;
            }

            EnsureCapacity(8 + count * 5);

            Stream.Write(beheld.Serial);

            for (var i = 0; i < list.Count; ++i)
            {
                var item = list[i];

                if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld)
                {
                    Stream.Write((byte)(item.Layer + 1));
                    Stream.Write(item.Serial);
                }
            }

            if (beheld.Hair?.ItemID > 0)
            {
                Stream.Write((byte)(Layer.Hair + 1));
                Stream.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
            }

            if (beheld.FacialHair?.ItemID > 0)
            {
                Stream.Write((byte)(Layer.FacialHair + 1));
                Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
            }

            Stream.Write((byte)Layer.Invalid);
        }
Ejemplo n.º 8
0
        public CorpseEquip(Mobile beholder, Corpse beheld)
            : base(0x89)
        {
            System.Collections.Generic.List <Item> list = beheld.EquipItems;

            int count = list.Count;

            if (beheld.Hair != null && beheld.Hair.ItemID > 0)
            {
                count++;
            }
            if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
            {
                count++;
            }

            EnsureCapacity(8 + (count * 5));

            m_Stream.Write(beheld.Serial);

            for (int i = 0; i < list.Count; ++i)
            {
                Item item = list[i];

                if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld)
                {
                    m_Stream.Write((byte)(item.Layer + 1));
                    m_Stream.Write(item.Serial);
                }
            }

            if (beheld.Hair != null && beheld.Hair.ItemID > 0)
            {
                m_Stream.Write((byte)(Layer.Hair + 1));
                m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
            }

            if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
            {
                m_Stream.Write((byte)(Layer.FacialHair + 1));
                m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
            }

            m_Stream.Write((byte)Layer.Invalid);
        }
Ejemplo n.º 9
0
        public static void SendCorpseEquip(this NetState ns, Mobile beholder, Corpse beheld)
        {
            if (ns.CannotSendPackets())
            {
                return;
            }

            var list = beheld.EquipItems;

            var maxLength = 8 + (list.Count + 2) * 5;
            var writer    = new SpanWriter(stackalloc byte[maxLength]);

            writer.Write((byte)0x89);
            writer.Seek(2, SeekOrigin.Current);
            writer.Write(beheld.Serial);

            for (var i = 0; i < list.Count; ++i)
            {
                var item = list[i];

                if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld)
                {
                    writer.Write((byte)(item.Layer + 1));
                    writer.Write(item.Serial);
                }
            }

            if (beheld.Hair?.ItemID > 0)
            {
                writer.Write((byte)(Layer.Hair + 1));
                writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
            }

            if (beheld.FacialHair?.ItemID > 0)
            {
                writer.Write((byte)(Layer.FacialHair + 1));
                writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
            }

            writer.Write((byte)Layer.Invalid);

            writer.WritePacketLength();
            ns.Send(writer.Span);
        }
Ejemplo n.º 10
0
        public new static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair,
            List<Item> initialContent, List<Item> equipItems)
        {
            var pm = owner as PlayerMobile;
            if (pm == null || BountyInformation.GetBounty(pm) <= 0)
                return Corpse.Mobile_CreateCorpseHandler(owner, hair, facialhair, initialContent, equipItems);

            Corpse c = new BountyCorpse(owner, hair, facialhair, equipItems);

            owner.Corpse = c;

            for (var i = 0; i < initialContent.Count; ++i)
            {
                var item = initialContent[i];

                if (Core.AOS && item.Parent == owner.Backpack)
                    c.AddItem(item);
                else
                    c.DropItem(item);

                if (Core.AOS)
                    c.SetRestoreInfo(item, item.Location);
            }

            if (Core.AOS)
            {
                c.RestoreEquip = pm.EquipSnapshot;
            }

            var loc = owner.Location;
            var map = owner.Map;

            if (map == null || map == Map.Internal)
            {
                loc = owner.LogoutLocation;
                map = owner.LogoutMap;
            }

            c.MoveToWorld(loc, map);

            return c;
        }
Ejemplo n.º 11
0
        public static Container CreateDummyCorpse(Mobile mob)
        {
            HairInfo hair = null;

            if (mob.HairItemID != 0)
            {
                hair = new HairInfo(mob.HairItemID, mob.HairHue);
            }

            FacialHairInfo facialhair = null;

            if (mob.FacialHairItemID != 0)
            {
                facialhair = new FacialHairInfo(mob.FacialHairItemID, mob.FacialHairHue);
            }

            return(Mobile.CreateCorpseHandler != null
                ? Mobile.CreateCorpseHandler(mob, hair, facialhair, new List <Item>(), new List <Item>())
                : null);
        }
Ejemplo n.º 12
0
		public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems)
			: this(owner, hair, facialhair, equipItems, false)
		{ }
Ejemplo n.º 13
0
        public override void Kill()
        {
            //Stop the protection timer, if we have one.
            Spells.Second.ProtectionSpell.StopTimer(this);
            //Stop the reflect timer, if we have one.
            MagicReflectSpell.StopTimer(this);

            EndAction(typeof(BasePotion));

            #region base.Kill() (used for the auto cut "lastcorpse" fix)
            if (!CanBeDamaged())
                return;
            if (!Alive || IsDeadBondedPet)
                return;
            if (Deleted)
                return;
            if (!Region.OnBeforeDeath(this))
                return;
            if (!OnBeforeDeath())
                return;

            BankBox box = FindBankNoCreate();

            if (box != null && box.Opened)
                box.Close();

            if (NetState != null)
                NetState.CancelAllTrades();

            if (Spell != null)
                Spell.OnCasterKilled();

            if (Target != null)
                Target.Cancel(this, TargetCancelType.Canceled);

            DisruptiveAction();

            Warmode = false;

            DropHolding();

            Hits = 0;
            Stam = 0;
            Mana = 0;

            Poison = null;
            Combatant = null;

            if (Paralyzed)
                Paralyzed = false;

            if (Frozen)
                Frozen = false;

            List<Item> content = new List<Item>();
            List<Item> equip = new List<Item>();
            List<Item> moveToPack = new List<Item>();

            List<Item> itemsCopy = new List<Item>(Items);

            Container pack = Backpack;

            for (int i = 0; i < itemsCopy.Count; ++i)
            {
                Item item = itemsCopy[i];

                if (item == pack)
                    continue;

                DeathMoveResult res = GetParentMoveResultFor(item);

                switch (res)
                {
                    case DeathMoveResult.MoveToCorpse:
                        {
                            content.Add(item);
                            equip.Add(item);
                            break;
                        }
                    case DeathMoveResult.MoveToBackpack:
                        {
                            moveToPack.Add(item);
                            break;
                        }
                }
            }

            if (pack != null)
            {
                List<Item> packCopy = new List<Item>(pack.Items);

                for (int i = 0; i < packCopy.Count; ++i)
                {
                    Item item = packCopy[i];

                    DeathMoveResult res = GetInventoryMoveResultFor(item);

                    if (res == DeathMoveResult.MoveToCorpse)
                        content.Add(item);
                    else
                        moveToPack.Add(item);
                }

                for (int i = 0; i < moveToPack.Count; ++i)
                {
                    Item item = moveToPack[i];

                    if (RetainPackLocsOnDeath && item.Parent == pack)
                        continue;

                    pack.DropItem(item);
                }
            }

            HairInfo hair = null;
            if (HairItemID != 0)
                hair = new HairInfo(HairItemID, HairHue);

            FacialHairInfo facialhair = null;
            if (FacialHairItemID != 0)
                facialhair = new FacialHairInfo(FacialHairItemID, FacialHairHue);



            #region auto cut "serial" fix
            int maxCorpses = Utility.Random(1, 4);

            maxCorpses += Utility.Random(2);

            for (int i = 0; i < maxCorpses; i++)
            {
                Point3D loc = Location;
                loc.X += Utility.RandomMinMax(-1, 1);
                loc.Y += Utility.RandomMinMax(-1, 1);

                FakeCorpse fc = new FakeCorpse(this);
                fc.MoveToWorld(loc, Map.Felucca);

                fc.Stackable = true;
                fc.Amount = 590;
                fc.Amount = Body.BodyID-2; // protocol defines that for itemid 0x2006, amount=body
                fc.Stackable = false;
            }
            #endregion

            Container c = (CreateCorpseHandler == null ? null : CreateCorpseHandler(this, hair, facialhair, content, equip));

            if (Map != null)
            {
                Packet animPacket = null;
                Packet remPacket = null;

                IPooledEnumerable eable = Map.GetClientsInRange(Location);

                foreach (NetState state in eable)
                {
                    if (state != NetState && (!state.Mobile.HasFilter || InLOS(state.Mobile)))
                    {
                        //Fix be here
                        if (animPacket == null)
                            animPacket = Packet.Acquire(new DeathAnimation(this, null));

                        state.Send(animPacket);

                        if (!state.Mobile.CanSee(this))
                        {
                            if (remPacket == null)
                                remPacket = RemovePacket;

                            state.Send(remPacket);
                        }
                    }
                }

                Packet.Release(animPacket);

                eable.Free();
            }

            Region.OnDeath(this);
            OnDeath(c);
            #endregion
        }
Ejemplo n.º 14
0
        public static Container CreatePlayerCorpse(Mobile mob)
        {
            if (mob == null)
            {
                return(null);
            }

            var content    = new List <Item>();
            var equip      = new List <Item>();
            var moveToPack = new List <Item>();
            var itemsCopy  = new List <Item>(mob.Items);

            Container pack = mob.Backpack;

            foreach (Item item in itemsCopy)
            {
                if (item == pack)
                {
                    continue;
                }

                DeathMoveResult res = mob.GetParentMoveResultFor(item);

                switch (res)
                {
                case DeathMoveResult.MoveToCorpse:
                {
                    content.Add(item);
                    equip.Add(item);
                    break;
                }

                case DeathMoveResult.MoveToBackpack:
                {
                    moveToPack.Add(item);
                    break;
                }
                }
            }

            if (pack != null)
            {
                var packCopy = new List <Item>();

                if (pack.Items != null && pack.Items.Count > 0)
                {
                    packCopy.AddRange(pack.Items);

                    foreach (Item item in packCopy)
                    {
                        DeathMoveResult res = mob.GetInventoryMoveResultFor(item);

                        if (res == DeathMoveResult.MoveToCorpse)
                        {
                            content.Add(item);

                            //RunUO SVN 610 - Core change instead.
                            var         subItems = new List <Item>();
                            List <Item> lookup   = item.LookupItems();

                            if (lookup != null && lookup.Count > 0)
                            {
                                subItems.AddRange(lookup);
                            }

                            moveToPack.AddRange(
                                subItems.Where(
                                    subItem =>
                                    !subItem.Deleted && (subItem.LootType == LootType.Blessed || subItem.Insured)));
                        }
                        else
                        {
                            moveToPack.Add(item);
                        }
                    }
                }

                foreach (Item item in moveToPack.Where(item => !mob.RetainPackLocsOnDeath || item.Parent != pack))
                {
                    pack.DropItem(item);
                }
            }

            HairInfo hair = null;

            if (mob.HairItemID != 0)
            {
                hair = new HairInfo(mob.HairItemID, mob.HairHue);
            }

            FacialHairInfo facialhair = null;

            if (mob.FacialHairItemID != 0)
            {
                facialhair = new FacialHairInfo(mob.FacialHairItemID, mob.FacialHairHue);
            }

            return(Mobile.CreateCorpseHandler != null
                ? Mobile.CreateCorpseHandler(mob, hair, facialhair, content, equip)
                : null);
        }
Ejemplo n.º 15
0
        public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems)
            : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            this.Stackable = true;
            this.Amount = owner.Body; // protocol defines that for itemid 0x2006, amount=body
            this.Stackable = false;

            this.Movable = false;
            this.Hue = owner.Hue;
            this.Direction = owner.Direction;
            this.Name = owner.Name;

            this.m_Owner = owner;

            this.m_CorpseName = GetCorpseName(owner);

            this.m_TimeOfDeath = DateTime.Now;

            this.m_AccessLevel = owner.AccessLevel;
            this.m_Guild = owner.Guild as Guild;
            this.m_Kills = owner.Kills;
            this.SetFlag(CorpseFlag.Criminal, owner.Criminal);

            this.m_Hair = hair;
            this.m_FacialHair = facialhair;

            // This corpse does not turn to bones if: the owner is not a player
            this.SetFlag(CorpseFlag.NoBones, !owner.Player);

            this.m_Looters = new List<Mobile>();
            this.m_EquipItems = equipItems;

            this.m_Aggressors = new List<Mobile>(owner.Aggressors.Count + owner.Aggressed.Count);
            //bool addToAggressors = !( owner is BaseCreature );

            bool isBaseCreature = (owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = owner.Aggressors[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    this.m_Killer = info.Attacker;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (!isBaseCreature && !info.CriminalAggression)
                    this.m_Aggressors.Add(info.Attacker);
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = owner.Aggressed[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    this.m_Killer = info.Defender;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (!isBaseCreature)
                    this.m_Aggressors.Add(info.Defender);
            }

            if (isBaseCreature)
            {
                BaseCreature bc = (BaseCreature)owner;

                Mobile master = bc.GetMaster();
                if (master != null)
                    this.m_Aggressors.Add(master);

                List<DamageStore> rights = BaseCreature.GetLootingRights(bc.DamageEntries, bc.HitsMax);
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight)
                        this.m_Aggressors.Add(ds.m_Mobile);
                }
            }

            this.BeginDecay(m_DefaultDecayTime);

            this.DevourCorpse();
        }
Ejemplo n.º 16
0
        public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems)
            : base(0x2006)
        {
            Movable = false;

            Stackable = true;       // To supress console warnings, stackable must be true
            Amount    = owner.Body; // Protocol defines that for itemid 0x2006, amount=body
            Stackable = false;

            Name = owner.Name;
            Hue  = owner.Hue;

            Direction = owner.Direction;
            Light     = (LightType)Direction;

            m_Owner = owner;

            m_CorpseName = GetCorpseName(owner);

            TimeOfDeath = DateTime.UtcNow;

            m_AccessLevel = owner.AccessLevel;
            Guild         = owner.Guild as Guild;
            Kills         = owner.Kills;

            SetFlag(CorpseFlag.Criminal, owner.Criminal);
            SetFlag(CorpseFlag.Murderer, owner.Murderer);

            Hair       = hair;
            FacialHair = facialhair;

            // This corpse does not turn to bones if: the owner is not a player
            SetFlag(CorpseFlag.NoBones, !owner.Player);

            // Flagging looters as criminal can happen by default
            SetFlag(CorpseFlag.LootCriminal, true);

            m_Looters    = new List <Mobile>();
            m_EquipItems = equipItems;

            m_Aggressors = new List <Mobile>(owner.Aggressors.Count + owner.Aggressed.Count);
            //bool addToAggressors = !( owner is BaseCreature );

            BaseCreature bc = owner as BaseCreature;

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = owner.Aggressors[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Attacker;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (bc == null && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = owner.Aggressed[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Defender;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (bc == null)
                {
                    m_Aggressors.Add(info.Defender);
                }
            }

            if (bc != null)
            {
                Mobile master = bc.GetMaster();

                if (master != null)
                {
                    m_Aggressors.Add(master);
                }

                List <DamageStore> rights = bc.GetLootingRights();
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight)
                    {
                        m_Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(owner.CorpseDecayTime);
            DevourCorpse();

            if (owner is PlayerMobile)
            {
                if (PlayerCorpses == null)
                {
                    PlayerCorpses = new Dictionary <Corpse, int>();
                }

                PlayerCorpses[this] = 0;
            }
        }
Ejemplo n.º 17
0
        public void TestMobileIncoming(
            ProtocolChanges protocolChanges, int hairItemId, int hairHue, int facialHairItemId, int facialHairHue
            )
        {
            var beholder = new Mobile(0x1)
            {
                Name = "Random Mobile 1"
            };

            beholder.DefaultMobileInit();

            var beheld = new Mobile(0x2)
            {
                Name = "Random Mobile 2"
            };

            beheld.DefaultMobileInit();
            beheld.AddItem(
                new Item((Serial)0x1000)
            {
                Layer = Layer.OneHanded
            }
                );

            // Test Dupe
            beheld.AddItem(
                new Item((Serial)0x1001)
            {
                Layer = Layer.OneHanded
            }
                );

            beheld.HairItemID       = hairItemId;
            beheld.HairHue          = hairHue;
            beheld.FacialHairItemID = facialHairItemId;
            beheld.FacialHairHue    = facialHairHue;

            var ns = new NetState(null)
            {
                ProtocolChanges = protocolChanges
            };

            var data = new MobileIncoming(ns, beholder, beheld).Compile();

            var sa         = ns.StygianAbyss;
            var newPacket  = ns.NewMobileIncoming;
            var itemIdMask = newPacket ? 0xFFFF : 0x7FFF;

            Span <bool> layers = stackalloc bool[256];

#if NO_LOCAL_INIT
            layers.Clear();
#endif

            var items = beheld.Items;
            var count = items.Count;

            if (beheld.HairItemID > 0)
            {
                count++;
            }

            if (beheld.FacialHairItemID > 0)
            {
                count++;
            }

            var length = 23 + count * 9; // Max Size

            Span <byte> expectedData = stackalloc byte[length];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0x78);
            pos += 2; // Length

            var isSolidHue = beheld.SolidHueOverride >= 0;

            expectedData.Write(ref pos, beheld.Serial);
            expectedData.Write(ref pos, (ushort)beheld.Body);
            expectedData.Write(ref pos, (ushort)beheld.X);
            expectedData.Write(ref pos, (ushort)beheld.Y);
            expectedData.Write(ref pos, (byte)beheld.Z);
            expectedData.Write(ref pos, (byte)beheld.Direction);
            expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : beheld.Hue));
            expectedData.Write(ref pos, (byte)beheld.GetPacketFlags(sa));
            expectedData.Write(ref pos, (byte)Notoriety.Compute(beholder, beheld));

            byte layer;

            for (var i = 0; i < items.Count; i++)
            {
                var item = items[i];

                layer = (byte)item.Layer;

                if (!item.Deleted && !layers[layer] && beholder.CanSee(item))
                {
                    layers[layer] = true;

                    expectedData.Write(ref pos, item.Serial);

                    var hue      = isSolidHue ? beheld.SolidHueOverride : item.Hue;
                    var itemID   = item.ItemID & itemIdMask;
                    var writeHue = newPacket || hue != 0;

                    if (!newPacket)
                    {
                        itemID |= 0x8000;
                    }

                    expectedData.Write(ref pos, (ushort)itemID);
                    expectedData.Write(ref pos, layer);
                    if (writeHue)
                    {
                        expectedData.Write(ref pos, (ushort)hue);
                    }
                }
            }

            layer = (byte)Layer.Hair;
            var itemId = beheld.HairItemID;

            if (itemId > 0 && !layers[layer])
            {
                expectedData.Write(ref pos, HairInfo.FakeSerial(beheld));
                var hue = isSolidHue ? beheld.SolidHueOverride : beheld.HairHue;
                itemId &= itemIdMask;
                var writeHue = newPacket || hue != 0;

                if (!newPacket)
                {
                    itemId |= 0x8000;
                }

                expectedData.Write(ref pos, (ushort)itemId);
                expectedData.Write(ref pos, layer);
                if (writeHue)
                {
                    expectedData.Write(ref pos, (ushort)hue);
                }
            }

            layer  = (byte)Layer.FacialHair;
            itemId = beheld.FacialHairItemID;

            if (itemId > 0 && !layers[layer])
            {
                expectedData.Write(ref pos, FacialHairInfo.FakeSerial(beheld));
                var hue = isSolidHue ? beheld.SolidHueOverride : beheld.FacialHairHue;
                itemId &= itemIdMask;
                var writeHue = newPacket || hue != 0;

                if (!newPacket)
                {
                    itemId |= 0x8000;
                }

                expectedData.Write(ref pos, (ushort)itemId);
                expectedData.Write(ref pos, layer);
                if (writeHue)
                {
                    expectedData.Write(ref pos, (ushort)hue);
                }
            }

#if NO_LOCAL_INIT
            expectedData.Write(ref pos, 0); // Zero serial, terminate list
#else
            pos += 4;
#endif

            expectedData.Slice(1, 2).Write((ushort)pos); // Length
            expectedData = expectedData.Slice(0, pos);

            AssertThat.Equal(data, expectedData);
        }
Ejemplo n.º 18
0
        public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> initialContent, List <Item> equipItems)
        {
            bool shouldFillCorpse = true;

            //if ( owner is BaseCreature )
            //	shouldFillCorpse = !((BaseCreature)owner).IsBonded;

            Corpse c;

            if (owner is MilitiaFighter)
            {
                c = new MilitiaFighterCorpse(owner, hair, facialhair, shouldFillCorpse ? equipItems : new List <Item>());
            }
            else
            {
                c = new Corpse(owner, hair, facialhair, shouldFillCorpse ? equipItems : new List <Item>());
            }

            owner.Corpse = c;

            if (shouldFillCorpse)
            {
                for (int i = 0; i < initialContent.Count; ++i)
                {
                    Item item = initialContent[i];

                    if (Core.AOS && owner.Player && item.Parent == owner.Backpack)
                    {
                        c.AddItem(item);
                    }
                    else
                    {
                        c.DropItem(item);
                    }

                    if (owner.Player && Core.AOS)
                    {
                        c.SetRestoreInfo(item, item.Location);
                    }
                }

                if (!owner.Player)
                {
                    c.AssignInstancedLoot();
                }
                else if (Core.AOS)
                {
                    PlayerMobile pm = owner as PlayerMobile;

                    if (pm != null)
                    {
                        c.RestoreEquip = pm.EquipSnapshot;
                    }
                }
            }
            else
            {
                c.Carved = true;                 // TODO: Is it needed?
            }

            Point3D loc = owner.Location;
            Map     map = owner.Map;

            if (map == null || map == Map.Internal)
            {
                loc = owner.LogoutLocation;
                map = owner.LogoutMap;
            }

            c.MoveToWorld(loc, map);

            return(c);
        }
Ejemplo n.º 19
0
 public BountyCorpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems)
     : base(owner, hair, facialhair, equipItems)
 {
 }
Ejemplo n.º 20
0
        public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems) : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            Stackable = true;
            Amount    = owner.Body;
            Stackable = false;

            Movable   = false;
            Hue       = owner.Hue;
            Direction = owner.Direction;
            Name      = owner.Name;

            Owner = owner;

            CorpseName = GetCorpseName(owner);

            TimeOfDeath = DateTime.UtcNow;

            AccessLevel = owner.AccessLevel;

            //TEST: GUILD
            //Guild = owner.Guild as Guild;

            Kills    = owner.MurderCounts;
            Criminal = owner.Criminal;

            Hair       = hair;
            FacialHair = facialhair;

            NoBones = !owner.Player;

            m_EquipItems = equipItems;

            Aggressors = new List <Mobile>(owner.Aggressors.Count + owner.Aggressed.Count);

            bool addToAggressors = !(owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = owner.Aggressors[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    Killer   = info.Attacker;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (addToAggressors && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = owner.Aggressed[i];

                if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
                {
                    Killer   = info.Defender;
                    lastTime = (DateTime.UtcNow - info.LastCombatTime);
                }

                if (addToAggressors)
                {
                    Aggressors.Add(info.Defender);
                }
            }

            if (!addToAggressors)
            {
                BaseCreature bc = (BaseCreature)owner;

                Mobile master = bc.GetMaster();

                if (master != null)
                {
                    m_Aggressors.Add(master);
                }

                List <DamageStore> rights = BaseCreature.GetLootingRights(bc.DamageEntries, bc.HitsMax);

                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight)
                    {
                        Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(m_DefaultDecayTime);
        }
Ejemplo n.º 21
0
        public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> initialContent, List <Item> equipItems)
        {
            bool shouldFillCorpse = true;

            Corpse c = null;

            if (owner == null)
            {
                return(c);
            }

            c = new Corpse(owner, hair, facialhair, shouldFillCorpse ? equipItems : new List <Item>());

            if (c == null)
            {
                return(c);
            }

            owner.Corpse = c;

            if (shouldFillCorpse)
            {
                for (int i = 0; i < initialContent.Count; ++i)
                {
                    Item item = initialContent[i];

                    if (item == null)
                    {
                        continue;
                    }

                    c.DropItem(item);
                }
            }

            else
            {
                c.Carved = true;
            }

            Point3D loc = owner.Location;
            Map     map = owner.Map;

            if (map == null || map == Map.Internal)
            {
                loc = owner.LogoutLocation;
                map = owner.LogoutMap;
            }

            c.MoveToWorld(loc, map);

            //Creature or Player Ocean Corpse Advanced Decay Rate
            if (!(c.Map == null || c.Map == Map.Internal))
            {
                if (c.Map.Tiles != null)
                {
                    LandTile     landTile = c.Map.Tiles.GetLandTile(c.X, c.Y);
                    StaticTile[] tiles    = c.Map.Tiles.GetStaticTiles(c.X, c.Y, true);

                    bool landHasWater   = false;
                    bool staticHasWater = false;

                    if ((landTile.ID >= 168 && landTile.ID <= 171) || (landTile.ID >= 310 && landTile.ID <= 311))
                    {
                        landHasWater = true;
                    }

                    for (int i = 0; i < tiles.Length; ++i)
                    {
                        StaticTile tile = tiles[i];

                        bool isWater = (tile.ID >= 0x1796 && tile.ID <= 0x17B2);

                        if (isWater)
                        {
                            staticHasWater = true;
                        }
                    }

                    if ((landHasWater || staticHasWater) && c.TotalItems == 0)
                    {
                        if (c.m_DecayTimer != null)
                        {
                            c.m_DecayTimer.Stop();
                        }

                        //Empty PlayerMobile is 30 Seconds Decay
                        if (c.Owner is PlayerMobile)
                        {
                            c.BeginDecay(TimeSpan.FromSeconds(30));
                        }

                        //Empty Creature is 10 Seconds Decay
                        else
                        {
                            c.BeginDecay(TimeSpan.FromSeconds(10));
                        }
                    }
                }
            }

            return(c);
        }
Ejemplo n.º 22
0
 public MilitiaFighterCorpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems)
     : base(owner, hair, facialhair, equipItems)
 {
 }
Ejemplo n.º 23
0
 public RemoveFacialHair(Mobile parent)
     : base(0x1D, 5)
 {
     Stream.Write(FacialHairInfo.FakeSerial(parent.Serial));
 }
Ejemplo n.º 24
0
        public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> initialContent, List <Item> equipItems)
        {
            bool shouldFillCorpse = true;

            //if ( owner is BaseCreature )
            //	shouldFillCorpse = !((BaseCreature)owner).IsBonded;

            Corpse c = new Corpse(owner, hair, facialhair, shouldFillCorpse ? equipItems : new List <Item>());

            owner.Corpse = c;

            if (shouldFillCorpse)
            {
                for (int i = 0; i < initialContent.Count; ++i)
                {
                    Item item = initialContent[i];

                    c.DropItem(item);
                }
            }
            else
            {
                c.Carved = true;                 // TODO: Is it needed?
            }

            Point3D loc = owner.Location;
            Map     map = owner.Map;

            if (map == null || map == Map.Internal)
            {
                loc = owner.LogoutLocation;
                map = owner.LogoutMap;
            }

            c.MoveToWorld(loc, map);

            return(c);
        }
Ejemplo n.º 25
0
        public new static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair,
                                                               List <Item> initialContent, List <Item> equipItems)
        {
            var pm = owner as PlayerMobile;

            if (pm == null || BountyInformation.GetBounty(pm) <= 0)
            {
                return(Corpse.Mobile_CreateCorpseHandler(owner, hair, facialhair, initialContent, equipItems));
            }

            Corpse c = new BountyCorpse(owner, hair, facialhair, equipItems);

            //UOSI Logging
            //MoreLogging.WriteLine(owner, "A BountyCorpse has been created!");

            owner.Corpse = c;

            for (var i = 0; i < initialContent.Count; ++i)
            {
                var item = initialContent[i];

                if (Core.AOS && item.Parent == owner.Backpack)
                {
                    c.AddItem(item);
                }
                else
                {
                    c.DropItem(item);
                }

                if (Core.AOS)
                {
                    c.SetRestoreInfo(item, item.Location);
                }
            }

            if (Core.AOS)
            {
                c.RestoreEquip = pm.EquipSnapshot;
            }

            var loc = owner.Location;
            var map = owner.Map;

            if (map == null || map == Map.Internal)
            {
                loc = owner.LogoutLocation;
                map = owner.LogoutMap;
            }

            c.MoveToWorld(loc, map);

            return(c);
        }
Ejemplo n.º 26
0
        public CorpseContent(Mobile beholder, Corpse beheld)
            : base(0x3C)
        {
            List <Item> items = beheld.EquipItems;
            int         count = items.Count;

            if (beheld.Hair != null && beheld.Hair.ItemID > 0)
            {
                count++;
            }
            if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
            {
                count++;
            }

            EnsureCapacity(5 + (count * 19));

            long pos = m_Stream.Position;

            int written = 0;

            m_Stream.Write((ushort)0);

            for (int i = 0; i < items.Count; ++i)
            {
                Item child = items[i];

                if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
                {
                    m_Stream.Write((int)child.Serial);
                    m_Stream.Write((ushort)child.ItemID);
                    m_Stream.Write((byte)0); // signed, itemID offset
                    m_Stream.Write((ushort)child.Amount);
                    m_Stream.Write((short)child.X);
                    m_Stream.Write((short)child.Y);
                    m_Stream.Write((int)beheld.Serial);
                    m_Stream.Write((ushort)child.Hue);

                    ++written;
                }
            }

            if (beheld.Hair != null && beheld.Hair.ItemID > 0)
            {
                m_Stream.Write((int)HairInfo.FakeSerial(beheld.Owner) - 2);
                m_Stream.Write((ushort)beheld.Hair.ItemID);
                m_Stream.Write((byte)0); // signed, itemID offset
                m_Stream.Write((ushort)1);
                m_Stream.Write((short)0);
                m_Stream.Write((short)0);
                m_Stream.Write((int)beheld.Serial);
                m_Stream.Write((ushort)beheld.Hair.Hue);

                ++written;
            }

            if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
            {
                m_Stream.Write((int)FacialHairInfo.FakeSerial(beheld.Owner) - 2);
                m_Stream.Write((ushort)beheld.FacialHair.ItemID);
                m_Stream.Write((byte)0); // signed, itemID offset
                m_Stream.Write((ushort)1);
                m_Stream.Write((short)0);
                m_Stream.Write((short)0);
                m_Stream.Write((int)beheld.Serial);
                m_Stream.Write((ushort)beheld.FacialHair.Hue);

                ++written;
            }

            m_Stream.Seek(pos, SeekOrigin.Begin);
            m_Stream.Write((ushort)written);
        }
Ejemplo n.º 27
0
        public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems)
            : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            Stackable = true;
            Amount    = owner.Body;          // protocol defines that for itemid 0x2006, amount=body
            Stackable = false;

            Movable   = false;
            Hue       = owner.Hue;
            Direction = owner.Direction;
            Name      = owner.Name;

            m_Owner = owner;

            m_CorpseName = GetCorpseName(owner);

            m_TimeOfDeath = DateTime.Now;

            m_AccessLevel = owner.AccessLevel;
            m_Guild       = owner.Guild as Guild;
            m_Kills       = owner.Kills;
            SetFlag(CorpseFlag.Criminal, owner.Criminal);

            m_Hair       = hair;
            m_FacialHair = facialhair;

            // This corpse does not turn to bones if: the owner is not a player
            SetFlag(CorpseFlag.NoBones, !owner.Player);

            m_Looters    = new List <Mobile>();
            m_EquipItems = equipItems;

            m_Aggressors = new List <Mobile>(owner.Aggressors.Count + owner.Aggressed.Count);
            //bool addToAggressors = !( owner is BaseCreature );

            bool isBaseCreature = (owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = owner.Aggressors[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Attacker;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (!isBaseCreature && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = owner.Aggressed[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Defender;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (!isBaseCreature)
                {
                    m_Aggressors.Add(info.Defender);
                }
            }

            if (isBaseCreature)
            {
                BaseCreature bc = (BaseCreature)owner;

                Mobile master = bc.GetMaster();
                if (master != null)
                {
                    m_Aggressors.Add(master);
                }

                List <DamageStore> rights = BaseCreature.GetLootingRights(bc.DamageEntries, bc.HitsMax);
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = rights[i];

                    if (ds.m_HasRight)
                    {
                        m_Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(m_DefaultDecayTime);

            DevourCorpse();
        }
Ejemplo n.º 28
0
		public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems, bool champspawn)
			: base(0x2006)
		{
			if (owner != null && owner.CustomTeam)
			{
				List<XmlTeam> ownerTeams = XmlAttach.GetTeams(owner);

				foreach (XmlTeam copy in ownerTeams.Select(
					team => new XmlTeam
					{
						TeamGreen = team.TeamGreen,
						TeamHarmAllowed = team.TeamHarmAllowed
					}))
				{
					copy.TeamVal = copy.TeamVal;

					XmlAttach.AttachTo(this, copy);
				}
			}

			// To supress console warnings, stackable must be true
			Stackable = true;
			Amount = owner == null ? 400 : (int)owner.Body; // protocol defines that for itemid 0x2006, amount=body
			Stackable = false;

			Movable = false;
			Hue = owner == null ? 0 : owner.Hue;
			Direction = owner == null ? Direction.North : owner.Direction;
			Name = owner == null ? "unidentifiable remains" : owner.Name;

			var bc = owner as BaseCreature;

			m_Owner = owner;

			m_CorpseName = GetCorpseName(owner);

			m_TimeOfDeath = DateTime.UtcNow;

			m_AccessLevel = owner == null ? AccessLevel.Player : owner.AccessLevel;
			m_Guild = owner == null ? null : owner.Guild as Guild;
			m_Kills = bc != null && bc.AlwaysMurderer ? 100 : owner == null ? 0 : owner.Kills;
			SetFlag(CorpseFlag.Criminal, owner != null && owner.Criminal);

			Hair = hair;
			FacialHair = facialhair;

			// This corpse does not turn to bones if: the owner is not a player
			SetFlag(CorpseFlag.NoBones, owner == null || !owner.Player);
			m_BloodHue = owner == null ? 0x22 : owner.BloodHue;

			m_Looters = new List<Mobile>();
			m_EquipItems = equipItems;

			m_Aggressors = new List<Mobile>(owner == null ? 0 : owner.Aggressors.Count + owner.Aggressed.Count);

			bool addToAggressors = bc == null;
			TimeSpan lastTime = TimeSpan.MaxValue;

			if (owner != null)
			{
				foreach (AggressorInfo info in owner.Aggressors)
				{
					if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
					{
						m_Killer = info.Attacker;
						lastTime = (DateTime.UtcNow - info.LastCombatTime);
					}

					if (addToAggressors && !info.CriminalAggression)
					{
						m_Aggressors.Add(info.Attacker);
					}
				}

				foreach (AggressorInfo info in owner.Aggressed)
				{
					if ((DateTime.UtcNow - info.LastCombatTime) < lastTime)
					{
						m_Killer = info.Defender;
						lastTime = (DateTime.UtcNow - info.LastCombatTime);
					}

					if (addToAggressors)
					{
						m_Aggressors.Add(info.Defender);
					}
				}
			}

			if (!addToAggressors)
			{
				Mobile master = bc.GetMaster();

				if (master != null)
				{
					m_Aggressors.Add(master);
				}

				List<DamageStore> rights = BaseCreature.GetLootingRights(bc.DamageEntries, bc.HitsMax);

				foreach (DamageStore ds in rights.Where(ds => ds.m_HasRight))
				{
					m_Aggressors.Add(ds.m_Mobile);
				}
			}

			TimeSpan decayTime = m_DefaultDecayTime;

			if (champspawn)
			{
				decayTime = TimeSpan.FromSeconds(120.0);
			}

			BeginDecay(decayTime);

			DevourCorpse();

			_Instances.Add(this);
		}
Ejemplo n.º 29
0
		public static Container Mobile_CreateCorpseHandler(
			Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> initialContent, List<Item> equipItems)
		{
			var bc = owner as BaseCreature;

			bool champspawn = false;

			if (bc != null)
			{
				var region = Region.Find(owner.Location, owner.Map) as ChampionSpawnRegion;

				if (region != null)
				{
					ChampionSpawn spawn = region.Spawn;

					if (spawn != null && spawn.IsChampionSpawn(bc))
					{
						champspawn = true;
					}
				}
			}

			Corpse c;
			Corpse p = null;

			if (owner is MilitiaFighter)
			{
				c = new MilitiaFighterCorpse(owner, hair, facialhair, equipItems);
			}
			else
			{
				c = new Corpse(owner, hair, facialhair, equipItems, champspawn);
			}

			owner.Corpse = c;

			var proxyEquip = new List<Item>();

			for (int i = initialContent.Count - 1; i >= 0; i--)
			{
				Item item = initialContent[i];

				if (owner.Player)
				{
					c.DropItem(owner, item);
				}
				else
				{
					if (equipItems.Contains(item))
					{
						proxyEquip.Add(DupeProxyEquipped(item));
					}

					if (item.GetSavedFlag(0x02))
					{
						item.LootType = LootType.Blessed;
						item.SetSavedFlag(0x02, false);
					}

					if (!item.GetSavedFlag(0x01))
					{
						c.DropItem(owner, item);
					}
				}
			}

			if (proxyEquip.Count > 0)
			{
				c.Stackable = true;
				c.Amount = 508; //Original corpse is invisible
				c.Stackable = false;
				c.Hair = null;
				c.FacialHair = null;

				if (owner is MilitiaFighter)
				{
					p = new MilitiaFighterCorpse(owner, hair, facialhair, proxyEquip);
				}
				else
				{
					p = new Corpse(owner, hair, facialhair, proxyEquip);
				}

				foreach (Item t in proxyEquip)
				{
					p.DropItem(owner, t);
				}

				p.ProxyCorpse = c;
				owner.Corpse = p;
			}

			if (c.EraAOS)
			{
				var pm = owner as PlayerMobile;

				if (pm != null)
				{
					c.RestoreEquip = pm.EquipSnapshot;
				}
			}

			Point3D loc = owner.Location;
			Map map = owner.Map;

			if (map == null || map == Map.Internal)
			{
				loc = owner.LogoutLocation;
				map = owner.LogoutMap;
			}

			c.MoveToWorld(loc, map);

			if (p != null)
			{
				p.MoveToWorld(loc, map);
			}

			return p ?? c;
		}
Ejemplo n.º 30
0
		public static Container Mobile_CreateCorpseHandler( Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> initialContent, List<Item> equipItems )
		{
			bool shouldFillCorpse = true;

			Corpse c = new Corpse( owner, hair, facialhair, shouldFillCorpse ? equipItems : new List<Item>() );

			owner.Corpse = c;

			if ( shouldFillCorpse )
			{
				for ( int i = 0; i < initialContent.Count; ++i )
				{
					Item item = initialContent[i];

					c.DropItem( item );
                    c.SetRestoreInfo( item, item.Location );
				}
			}
			else
			{
				c.Carved = true; // TODO: Is it needed?
			}

			Point3D loc = owner.Location;
			Map map = owner.Map;

			if ( map == null || map == Map.Internal )
			{
				loc = owner.LogoutLocation;
				map = owner.LogoutMap;
			}

			c.MoveToWorld( loc, map );

			return c;
		}
Ejemplo n.º 31
0
        public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> initialContent, List<Item> equipItems)
        {
            bool shouldFillCorpse = true;

            //if ( owner is BaseCreature )
            //	shouldFillCorpse = !((BaseCreature)owner).IsBonded;

            Corpse c;
            if (owner is MilitiaFighter)
                c = new MilitiaFighterCorpse(owner, hair, facialhair, shouldFillCorpse ? equipItems : new List<Item>());
            else
                c = new Corpse(owner, hair, facialhair, shouldFillCorpse ? equipItems : new List<Item>());

            owner.Corpse = c;

            if (shouldFillCorpse)
            {
                for (int i = 0; i < initialContent.Count; ++i)
                {
                    Item item = initialContent[i];

                    if (Core.AOS && owner.Player && item.Parent == owner.Backpack)
                        c.AddItem(item);
                    else
                        c.DropItem(item);

                    if (owner.Player && Core.AOS)
                        c.SetRestoreInfo(item, item.Location);
                }

                if (!owner.Player)
                {
                    c.AssignInstancedLoot();
                }
                else if (Core.AOS)
                {
                    PlayerMobile pm = owner as PlayerMobile;

                    if (pm != null)
                        c.RestoreEquip = pm.EquipSnapshot;
                }
            }
            else
            {
                c.Carved = true; // TODO: Is it needed?
            }

            Point3D loc = owner.Location;
            Map map = owner.Map;

            if (map == null || map == Map.Internal)
            {
                loc = owner.LogoutLocation;
                map = owner.LogoutMap;
            }

            c.MoveToWorld(loc, map);

            return c;
        }
Ejemplo n.º 32
0
        public MobileIncomingOld(Mobile beholder, Mobile beheld) : base(0x78)
        {
            var m_Version     = ++m_VersionTL.Value;
            var m_DupedLayers = m_DupedLayersTL.Value;

            var eq    = beheld.Items;
            var count = eq.Count;

            if (beheld.HairItemID > 0)
            {
                count++;
            }
            if (beheld.FacialHairItemID > 0)
            {
                count++;
            }

            EnsureCapacity(23 + count * 9);

            var hue = beheld.Hue;

            if (beheld.SolidHueOverride >= 0)
            {
                hue = beheld.SolidHueOverride;
            }

            Stream.Write(beheld.Serial);
            Stream.Write((short)beheld.Body);
            Stream.Write((short)beheld.X);
            Stream.Write((short)beheld.Y);
            Stream.Write((sbyte)beheld.Z);
            Stream.Write((byte)beheld.Direction);
            Stream.Write((short)hue);
            Stream.Write((byte)beheld.GetOldPacketFlags());
            Stream.Write((byte)Notoriety.Compute(beholder, beheld));

            for (var i = 0; i < eq.Count; ++i)
            {
                var item = eq[i];

                var layer = (byte)item.Layer;

                if (!item.Deleted && beholder.CanSee(item) && m_DupedLayers[layer] != m_Version)
                {
                    m_DupedLayers[layer] = m_Version;

                    hue = item.Hue;

                    if (beheld.SolidHueOverride >= 0)
                    {
                        hue = beheld.SolidHueOverride;
                    }

                    var itemID   = item.ItemID & 0x7FFF;
                    var writeHue = hue != 0;

                    if (writeHue)
                    {
                        itemID |= 0x8000;
                    }

                    Stream.Write(item.Serial);
                    Stream.Write((ushort)itemID);
                    Stream.Write(layer);

                    if (writeHue)
                    {
                        Stream.Write((short)hue);
                    }
                }
            }

            if (beheld.HairItemID > 0)
            {
                if (m_DupedLayers[(int)Layer.Hair] != m_Version)
                {
                    m_DupedLayers[(int)Layer.Hair] = m_Version;
                    hue = beheld.HairHue;

                    if (beheld.SolidHueOverride >= 0)
                    {
                        hue = beheld.SolidHueOverride;
                    }

                    var itemID = beheld.HairItemID & 0x7FFF;

                    var writeHue = hue != 0;

                    if (writeHue)
                    {
                        itemID |= 0x8000;
                    }

                    Stream.Write(HairInfo.FakeSerial(beheld));
                    Stream.Write((ushort)itemID);
                    Stream.Write((byte)Layer.Hair);

                    if (writeHue)
                    {
                        Stream.Write((short)hue);
                    }
                }
            }

            if (beheld.FacialHairItemID > 0)
            {
                if (m_DupedLayers[(int)Layer.FacialHair] != m_Version)
                {
                    m_DupedLayers[(int)Layer.FacialHair] = m_Version;
                    hue = beheld.FacialHairHue;

                    if (beheld.SolidHueOverride >= 0)
                    {
                        hue = beheld.SolidHueOverride;
                    }

                    var itemID = beheld.FacialHairItemID & 0x7FFF;

                    var writeHue = hue != 0;

                    if (writeHue)
                    {
                        itemID |= 0x8000;
                    }

                    Stream.Write(FacialHairInfo.FakeSerial(beheld));
                    Stream.Write((ushort)itemID);
                    Stream.Write((byte)Layer.FacialHair);

                    if (writeHue)
                    {
                        Stream.Write((short)hue);
                    }
                }
            }

            Stream.Write(0); // terminate
        }
Ejemplo n.º 33
0
 public MercenaryCorpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems)
     : base(owner, hair, facialhair, equipItems)
 {
 }
Ejemplo n.º 34
0
        public static Container Mobile_CreateCorpseHandler(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> initialContent, List <Item> equipItems)
        {
            Corpse c = new Corpse(owner, hair, facialhair, equipItems);

            owner.Corpse = c;

            for (int i = 0; i < initialContent.Count; ++i)
            {
                Item item = (Item)initialContent[i];

                if (owner.IsPlayer && item.Parent == owner.Backpack)
                {
                    c.AddItem(item);
                }
                else
                {
                    c.DropItem(item);
                }

                if (owner.IsPlayer)
                {
                    c.SetRestoreInfo(item, item.Location);
                }
            }

            Point3D loc = owner.Location;
            Map     map = owner.Map;

            if (map == null || map == Map.Internal)
            {
                loc = owner.LogoutLocation;
                map = owner.LogoutMap;
            }

            c.MoveToWorld(loc, map);

            return(c);
        }
Ejemplo n.º 35
0
        public CorpseContent(Mobile beholder, Corpse beheld)
            : base(0x3C)
        {
            var items = beheld.EquipItems;
            var count = items.Count;

            if (beheld.Hair?.ItemID > 0)
            {
                count++;
            }

            if (beheld.FacialHair?.ItemID > 0)
            {
                count++;
            }

            EnsureCapacity(5 + count * 19);

            var pos = Stream.Position;

            var written = 0;

            Stream.Write((ushort)0);

            for (var i = 0; i < items.Count; ++i)
            {
                var child = items[i];

                if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
                {
                    Stream.Write(child.Serial);
                    Stream.Write((ushort)child.ItemID);
                    Stream.Write((byte)0); // signed, itemID offset
                    Stream.Write((ushort)child.Amount);
                    Stream.Write((short)child.X);
                    Stream.Write((short)child.Y);
                    Stream.Write(beheld.Serial);
                    Stream.Write((ushort)child.Hue);

                    ++written;
                }
            }

            if (beheld.Hair?.ItemID > 0)
            {
                Stream.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
                Stream.Write((ushort)beheld.Hair.ItemID);
                Stream.Write((byte)0); // signed, itemID offset
                Stream.Write((ushort)1);
                Stream.Write((short)0);
                Stream.Write((short)0);
                Stream.Write(beheld.Serial);
                Stream.Write((ushort)beheld.Hair.Hue);

                ++written;
            }

            if (beheld.FacialHair?.ItemID > 0)
            {
                Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
                Stream.Write((ushort)beheld.FacialHair.ItemID);
                Stream.Write((byte)0); // signed, itemID offset
                Stream.Write((ushort)1);
                Stream.Write((short)0);
                Stream.Write((short)0);
                Stream.Write(beheld.Serial);
                Stream.Write((ushort)beheld.FacialHair.Hue);

                ++written;
            }

            Stream.Seek(pos, SeekOrigin.Begin);
            Stream.Write((ushort)written);
        }
Ejemplo n.º 36
0
        public static void SendCorpseContent(this NetState ns, Mobile beholder, Corpse beheld)
        {
            if (ns.CannotSendPackets())
            {
                return;
            }

            var list             = beheld.EquipItems;
            var hairItemID       = beheld.Hair?.ItemID ?? 0;
            var facialHairItemID = beheld.FacialHair?.ItemID ?? 0;
            var count            = list.Count;

            if (hairItemID > 0)
            {
                count++;
            }

            if (facialHairItemID > 0)
            {
                count++;
            }

            var maxLength = 5 + count * (ns.ContainerGridLines ? 20 : 19);
            var writer    = new SpanWriter(stackalloc byte[maxLength]);

            writer.Write((byte)0x3C);
            writer.Seek(4, SeekOrigin.Current); // Length and Count

            var written = 0;

            for (var i = 0; i < list.Count; ++i)
            {
                var child = list[i];

                if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
                {
                    writer.Write(child.Serial);
                    writer.Write((ushort)child.ItemID);
                    writer.Write((byte)0); // signed, itemID offset
                    writer.Write((ushort)child.Amount);
                    writer.Write((short)child.X);
                    writer.Write((short)child.Y);
                    if (ns.ContainerGridLines)
                    {
                        writer.Write((byte)0); // Grid Location?
                    }
                    writer.Write(beheld.Serial);
                    writer.Write((ushort)child.Hue);

                    ++written;
                }
            }

            if (hairItemID > 0)
            {
                writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
                writer.Write((ushort)hairItemID);
                writer.Write((byte)0); // signed, itemID offset
                writer.Write((ushort)1);
                writer.Write(0);       // X/Y
                if (ns.ContainerGridLines)
                {
                    writer.Write((byte)0); // Grid Location?
                }
                writer.Write(beheld.Serial);
                writer.Write((ushort)beheld.Hair !.Hue);

                ++written;
            }

            if (facialHairItemID > 0)
            {
                writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
                writer.Write((ushort)facialHairItemID);
                writer.Write((byte)0); // signed, itemID offset
                writer.Write((ushort)1);
                writer.Write(0);       // X/Y
                if (ns.ContainerGridLines)
                {
                    writer.Write((byte)0); // Grid Location?
                }
                writer.Write(beheld.Serial);
                writer.Write((ushort)beheld.FacialHair !.Hue);

                ++written;
            }

            writer.Seek(1, SeekOrigin.Begin);
            writer.Write((ushort)writer.BytesWritten);
            writer.Write((ushort)written);
            writer.Seek(0, SeekOrigin.End);
            ns.Send(writer.Span);
        }
Ejemplo n.º 37
0
			public static Container CREATECORPSE(TriggerObject trigObject, Mobile mob)
			{
				if (mob == null)
				{
					return null;
				}

				var content = new List<Item>();
				var equip = new List<Item>();
				var moveToPack = new List<Item>();
				var itemsCopy = new List<Item>(mob.Items);

				Container pack = mob.Backpack;

				foreach (Item item in itemsCopy)
				{
					if (item == pack)
					{
						continue;
					}

					DeathMoveResult res = mob.GetParentMoveResultFor(item);

					switch (res)
					{
						case DeathMoveResult.MoveToCorpse:
							{
								content.Add(item);
								equip.Add(item);
								break;
							}
						case DeathMoveResult.MoveToBackpack:
							{
								moveToPack.Add(item);
								break;
							}
					}
				}

				if (pack != null)
				{
					var packCopy = new List<Item>();

					if (pack.Items != null && pack.Items.Count > 0)
					{
						packCopy.AddRange(pack.Items);

						foreach (Item item in packCopy)
						{
							DeathMoveResult res = mob.GetInventoryMoveResultFor(item);

							if (res == DeathMoveResult.MoveToCorpse)
							{
								content.Add(item);

								//RunUO SVN 610 - Core change instead.
								var subItems = new List<Item>();
								var lookup = item.LookupItems();

								if (lookup != null && lookup.Count > 0)
								{
									subItems.AddRange(lookup);
								}

								moveToPack.AddRange(
									subItems.Where(subItem => !subItem.Deleted && (subItem.LootType == LootType.Blessed || subItem.Insured)));
							}
							else
							{
								moveToPack.Add(item);
							}
						}
					}

					foreach (Item item in moveToPack.Where(item => !mob.RetainPackLocsOnDeath || item.Parent != pack))
					{
						pack.DropItem(item);
					}
				}

				HairInfo hair = null;

				if (mob.HairItemID != 0)
				{
					hair = new HairInfo(mob.HairItemID, mob.HairHue);
				}

				FacialHairInfo facialhair = null;

				if (mob.FacialHairItemID != 0)
				{
					facialhair = new FacialHairInfo(mob.FacialHairItemID, mob.FacialHairHue);
				}

				return Mobile.CreateCorpseHandler != null ? Mobile.CreateCorpseHandler(mob, hair, facialhair, content, equip) : null;
			}
Ejemplo n.º 38
0
        public static Container CreateDummyCorpse(Mobile mob)
        {
            HairInfo hair = null;

            if (mob.HairItemID != 0)
            {
                hair = new HairInfo(mob.HairItemID, mob.HairHue);
            }

            FacialHairInfo facialhair = null;

            if (mob.FacialHairItemID != 0)
            {
                facialhair = new FacialHairInfo(mob.FacialHairItemID, mob.FacialHairHue);
            }

            return Mobile.CreateCorpseHandler != null
                ? Mobile.CreateCorpseHandler(mob, hair, facialhair, new List<Item>(), new List<Item>())
                : null;
        }