示例#1
0
 public static void EquipItem(PlayerMobile from, Item item)
 {
     if (item != null)
     {
         from.EquipItem(item);
     }
 }
示例#2
0
        public static void EquipLastWeaponRequest(NetState state, IEntity e, EncodedReader reader)
        {
            PlayerMobile from = state.Mobile as PlayerMobile;

            if (from != null)
            {
                if (from.LastWeapon != null && from.LastWeapon.IsChildOf(from.Backpack))
                {
                    Item toEquip  = from.LastWeapon;
                    Item toDisarm = from.FindItemOnLayer(Layer.OneHanded);

                    if (toDisarm == null || !toDisarm.Movable)
                    {
                        toDisarm = from.FindItemOnLayer(Layer.TwoHanded);
                    }

                    if (toDisarm != null && toDisarm.Movable)
                    {
                        from.Backpack.DropItem(toDisarm);
                    }

                    from.EquipItem(toEquip);
                }
            }
        }
        public void LoadPlayer(PlayerMobile pm)
        {
            Backpack pack = (Backpack)pm.Backpack;

            //pm.SendMessage(String.Format("SettingBackpack"));

            TeleportAllPets(pm, (Point3D)PlayerLocations[pm.Serial], (Map)PlayerMaps[pm.Serial]);

            pm.Location = (Point3D)PlayerLocations[pm.Serial];
            PlayerLocations.Remove(pm.Serial);
            //pm.SendMessage(String.Format("SettingLocation"));

            pm.Map = (Map)PlayerMaps[pm.Serial];
            PlayerMaps.Remove(pm.Serial);
            //pm.SendMessage(String.Format("SettingMap"));

            ArrayList items = (ArrayList)PlayerItems[pm.Serial];

            PlayerItems.Remove(pm.Serial);
            //pm.SendMessage(String.Format("Setting Arraylist of Items"));
            for (int i = 0; i < items.Count; ++i)
            {
                //pm.SendMessage(String.Format("LoadPlayer() {0} / {1}.", i , items.Count));
                Item item = (Item)items[i];
                if (item.Layer == Layer.Invalid)
                {
                    //pm.SendMessage(String.Format("Layer Invalid!"));
                    item.Location = (Point3D)ItemLocations[item.Serial];
                    ItemLocations.Remove(item.Serial);
                    pack.AddItem(item);
                }
                else
                {
                    Item test = (Item)pm.FindItemOnLayer(item.Layer);

                    if (test == null || test == item)
                    {
                        ItemLocations.Remove(item.Serial);
                        pm.EquipItem(item);
                        test = (Item)pm.FindItemOnLayer(item.Layer);
                        if (test == null)
                        {
                            pack.AddItem(item);
                        }
                    }
                    else
                    {
                        item.Location = (Point3D)ItemLocations[item.Serial];
                        ItemLocations.Remove(item.Serial);
                        if (item != pm.Backpack && item != pm.BankBox)
                        {
                            pack.AddItem(item);
                        }
                    }
                }
            }
        }
示例#4
0
        private static void EquipItem(PlayerMobile from, Item item, int hue)
        {
            if (item != null)
            {
                item.Hue = hue;

                from.EquipItem(item);
            }
        }
示例#5
0
        private void ResetPlayers()
        {
            foreach (KeyValuePair <PlayerMobile, TourneyEntry> item in m_Participants)
            {
                PlayerMobile m = item.Key;
                Refresh(m);
                m.Frozen = true;

                //Undress
                List <Item> dress = new List <Item>(m.Items);
                foreach (Item item2 in dress)
                {
                    if (item2 == m.Backpack)
                    {
                        continue;
                    }
                    DeathMoveResult res = m.GetParentMoveResultFor(item2);
                    if (res == DeathMoveResult.MoveToBackpack || res == DeathMoveResult.MoveToCorpse)
                    {
                        m.Backpack.AddItem(item2);
                    }
                }

                //Clear backapck
                if (m_StolenBackpack.ContainsKey(m))
                {
                    m.Backpack.Delete();
                }
                else
                {
                    m.BankBox.DropItem(m.Backpack);
                }

                //New backpack
                Backpack pack = new Backpack();
                pack.Movable = false;
                m.AddItem(pack);

                //Supply items
                AddItems(pack);

                //Robe
                m.EquipItem(new DeathRobe());

                //Team colour
                m.SolidHueOverride = item.Value.Team;

                //Move to base
                TeamBase bas = bases[item.Value.Team];
                if (bas != null)
                {
                    m.MoveToWorld(bas.Location, bas.Map);
                }
            }
        }
示例#6
0
        private static void EventSink_EquipLastWeaponMacroUsed(EquipLastWeaponMacroEventArgs e)
        {
            PlayerMobile pm = e.Mobile as PlayerMobile;

            if (!pm.CanBeginAction(typeof(EquipLastWeapon)))
            {
                pm.SendLocalizedMessage(500119);                   // You must wait to perform another action.
                return;
            }

            pm.BeginAction(typeof(EquipLastWeapon));

            Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(Expire_Callback), pm);

            if (pm != null && pm.Backpack != null)
            {
                BaseWeapon weapon = pm.LastEquipedWeapon;
                Item       hand1  = pm.FindItemOnLayer(Layer.OneHanded);
                Item       hand2  = pm.FindItemOnLayer(Layer.TwoHanded);

                if (weapon != null)
                {
                    if (!weapon.IsChildOf(pm.Backpack))
                    {
                        pm.SendLocalizedMessage(1063109);                           // Your last weapon must be in your backpack to be able to switch it quickly.
                        return;
                    }

                    if (weapon.Layer == Layer.TwoHanded && hand2 is BaseShield)
                    {
                        pm.SendLocalizedMessage(1063114);                           // You cannot pick up your last weapon!
                        return;
                    }

                    Item olditem = hand2 is BaseWeapon ? hand2 : hand1;

                    if (olditem != null && !pm.AddToBackpack(olditem))
                    {
                        pm.SendLocalizedMessage(1063110);                           // Your backpack cannot hold the weapon in your hand.
                    }
                    else if (pm.EquipItem(weapon))
                    {
                        pm.SendLocalizedMessage(1063112);                           // You pick up your last weapon.
                        pm.LastEquipedWeapon = olditem as BaseWeapon;
                    }
                    else
                    {
                        pm.SendLocalizedMessage(1063113);                           // You put your weapon into your backpack, but cannot pick up your last weapon!
                    }
                }
            }
        }
        private void MovePlayerToSpot(PlayerMobile player)
        {
            player.UndressItem(player, Server.Layer.OuterTorso);
            player.UndressItem(player, Server.Layer.Shoes);

            if (SingletonEvent.Instance.IsTeamMode)
            {
                player.TeamID = currentTeam;

                if (currentTeam == 1)
                {
                    player.FixedParticles(0x3709, 1, 30, 9965, 5, 7, EffectLayer.Waist);
                    player.EquipItem(new TeamARobe());
                    player.EquipItem(new TeamAShoes());
                    player.MoveToWorld(this.ArenaRespawnAPoint, this.Map);
                    player.FixedParticles(0x3709, 1, 30, 9965, 5, 7, EffectLayer.Waist);
                    currentTeam = 2;
                }
                else
                {
                    player.FixedParticles(0x3709, 1, 30, 9965, 5, 7, EffectLayer.Waist);
                    player.EquipItem(new TeamBRobe());
                    player.EquipItem(new TeamBShoes());
                    player.MoveToWorld(this.ArenaRespawnBPoint, this.Map);
                    player.FixedParticles(0x3709, 1, 30, 9965, 5, 7, EffectLayer.Waist);
                    currentTeam = 1;
                }
            }
            else
            {
                player.TeamID = 0;

                player.FixedParticles(0x3709, 1, 30, 9965, 5, 7, EffectLayer.Waist);
                player.EquipItem(new TeamARobe()
                {
                    Name = "Dimens Event"
                });
                player.EquipItem(new TeamAShoes()
                {
                    Name = "Dimens Event"
                });
                player.MoveToWorld(this.ArenaRespawnPoint, this.Map);
                player.FixedParticles(0x3709, 1, 30, 9965, 5, 7, EffectLayer.Waist);
            }
        }
示例#8
0
        public static void EquipLastWeaponRequest(NetState state, IEntity e, EncodedReader reader)
        {
            PlayerMobile from = state.Mobile as PlayerMobile;

            if (from == null || from.Backpack == null)
            {
                return;
            }

            if (from.IsStaff() || Core.TickCount - from.NextActionTime >= 0)
            {
                BaseWeapon toEquip  = from.LastWeapon;
                BaseWeapon toDisarm = from.FindItemOnLayer(Layer.OneHanded) as BaseWeapon;

                if (toDisarm == null)
                {
                    toDisarm = from.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon;
                }

                if (toDisarm != null)
                {
                    from.Backpack.DropItem(toDisarm);
                    from.NextActionTime = Core.TickCount + Mobile.ActionDelay;
                }

                if (toEquip != toDisarm && toEquip != null && toEquip.Movable && toEquip.IsChildOf(from.Backpack))
                {
                    from.EquipItem(toEquip);
                    from.NextActionTime = Core.TickCount + Mobile.ActionDelay;
                }
            }
            else
            {
                from.SendActionMessage();
            }
        }
示例#9
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            PlayerMobile from = (PlayerMobile)sender.Mobile;

            if (from.Deleted || !from.Alive)
            {
                return;
            }

            if (info.ButtonID < 8)
            {
                base.OnResponse(sender, info);
                return;
            }

            switch (info.ButtonID)
            {
            case 8:
                //Vemotes
                break;

            case 9:
                from.SendGump(new GumpLanguage(from, false));
                break;

            case 10:
                from.SendGump(new GumpLanguage(from, true));
                break;

            case 11:
                from.SendMessage(from.Experience.XP.ToString() + " points d'experiences");
                break;

            case 12:
                //Titre
                break;

            case 13:
                from.SendGump(new ConditionGump((Mobile)from));
                break;

            case 14:
                from.SendGump(new DecorationGump((Mobile)from));
                break;

            case 15:
                if (m_chevelurePage > 0)
                {
                    from.SendGump(new FicheCommandesGump(from, --m_chevelurePage, m_barbePage, m_tatooPage));
                }
                else
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                }
                break;

            case 16:
                if (m_chevelurePage < CheveluresPages)
                {
                    from.SendGump(new FicheCommandesGump(from, ++m_chevelurePage, m_barbePage, m_tatooPage));
                }
                else
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                }
                break;

            case 17:
                if (m_barbePage > 0)
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, --m_barbePage, m_tatooPage));
                }
                else
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                }
                break;

            case 18:
                if (m_barbePage < BarbesPages)
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, ++m_barbePage, m_tatooPage));
                }
                else
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                }
                break;

            case 19:
                if (m_tatooPage > 0)
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, --m_tatooPage));
                }
                else
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                }
                break;

            case 20:
                if (m_tatooPage < TatooPages)
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, ++m_tatooPage));
                }
                else
                {
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                }
                break;

            case 21:
                if (XP.CanEvolve((PlayerMobile)from))
                {
                    XP.Evolve((PlayerMobile)from);
                }
                from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                break;

            case 11025:
                if (from.FindItemOnLayer(Layer.Tatoo) != null)
                {
                    if (from.FindItemOnLayer(Layer.Tatoo) is GenericTatoo)
                    {
                        from.FindItemOnLayer(Layer.Tatoo).Delete();
                    }
                }
                from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                return;

            case 12366:
                from.HairItemID = 0;
                from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                return;

            case 12367:
                from.FacialHairItemID = 0;
                from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                return;
            }

            for (int i = 0; i < m_Chevelures.Length; i++)
            {
                if (m_Chevelures[i] == info.ButtonID)
                {
                    from.HairItemID = info.ButtonID;
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                }
            }
            for (int i = 0; i < m_Barbes.Length; i++)
            {
                if (m_Barbes[i] == info.ButtonID)
                {
                    from.FacialHairItemID = info.ButtonID;
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                }
            }
            for (int i = 0; i < m_Tatoos.Length; i++)
            {
                if (m_Tatoos[i] == info.ButtonID)
                {
                    GenericTatoo Tatoo = new GenericTatoo(info.ButtonID);
                    if (from.FindItemOnLayer(Layer.Tatoo) != null)
                    {
                        if (from.FindItemOnLayer(Layer.Tatoo) is GenericTatoo)
                        {
                            from.FindItemOnLayer(Layer.Tatoo).Delete();
                        }
                    }

                    if (!from.EquipItem(Tatoo))
                    {
                        Tatoo.Delete();
                    }
                    //from.FacialHairItemID = info.ButtonID;
                    from.SendGump(new FicheCommandesGump(from, m_chevelurePage, m_barbePage, m_tatooPage));
                }
            }
        }
示例#10
0
        private void SetCustomRace(Mobile m)
        {
            if (!(m is PlayerMobile))
            {
                return;
            }

            PlayerMobile pm = m as PlayerMobile;

            switch (m_Race)
            {
            case CustomRace.None:
            {
                //TODO: Maybe add a message of some sort.
            }
            break;

            case CustomRace.ResetToHuman:
            {
                Commands.ResetRace.DoResetRace(m);
            }
            break;

            case CustomRace.Vampire:
            {
                if (HasCustomRace(pm))
                {
                    return;
                }

                OverrideOriginalValues(pm);

                VampireShroud shroud = new VampireShroud();
                shroud.Owner = m;
                m.AddToBackpack(shroud);
                shroud.OnDoubleClick(m);

                m.Hue            = 1175;
                pm.HasCustomRace = true;
            }
            break;

            case CustomRace.Goblin:
            {
                if (HasCustomRace(pm))
                {
                    return;
                }

                OverrideOriginalValues(pm);

                m.HairItemID = 0x141B;
                m.HairHue    = 2212;
                m.Hue        = 2212;

                m.Say("Har!");
                pm.HasCustomRace = true;

                Effects.PlaySound(m.Location, m.Map, 1271);
            }
            break;

            case CustomRace.Daemon:
            {
                if (HasCustomRace(pm))
                {
                    return;
                }

                DaemonClaws claws = new DaemonClaws();
                pm.EquipItem(claws);

                OverrideOriginalValues(pm);

                m.HairItemID     = 7947;
                m.HairHue        = 1171;
                m.Hue            = 1171;
                pm.HasCustomRace = true;

                Effects.PlaySound(m.Location, m.Map, 357);
            }
            break;

            case CustomRace.WoodlandElf:
            {
                if (HasCustomRace(pm))
                {
                    return;
                }

                OverrideOriginalValues(pm);

                if (m.Female == false)
                {
                    WoodlandRobe robe = new WoodlandRobe();
                    robe.Owner = m;
                    m.AddToBackpack(robe);
                    robe.OnDoubleClick(m);
                }
                else
                {
                    WoodlandDress dress = new WoodlandDress();
                    dress.Owner = m;
                    m.AddToBackpack(dress);
                    dress.OnDoubleClick(m);
                }

                WoodlandHat hat = new WoodlandHat();
                hat.Owner = m;
                m.AddToBackpack(hat);
                hat.OnDoubleClick(m);

                m.Hue = 1434;
                m.Say("Aaye!");
                pm.HasCustomRace = true;
            }
            break;

            case CustomRace.Dwarf:
            {
                if (HasCustomRace(pm))
                {
                    return;
                }

                OverrideOriginalValues(pm);

                m.Hue = 1160;
                m.Say("Where be the ale?");
                pm.HasCustomRace = true;
            }
            break;

            case CustomRace.ShadowMage:
            {
                if (HasCustomRace(pm))
                {
                    return;
                }

                OverrideOriginalValues(pm);

                ShadowShroud shroud = new ShadowShroud();
                shroud.Owner = m;
                m.AddToBackpack(shroud);
                shroud.OnDoubleClick(m);

                m.Say("I will give my life to protect the dragons!");
                m.Hue            = 1907;
                pm.HasCustomRace = true;
            }
            break;

            case CustomRace.ShadowApprentice:
            {
                if (HasCustomRace(pm))
                {
                    return;
                }

                OverrideOriginalValues(pm);

                ShadowRobe robe = new ShadowRobe();
                robe.Owner = m;
                m.AddToBackpack(robe);
                robe.OnDoubleClick(m);

                m.Say("I will give my life to protect the dragons!");
                pm.HasCustomRace = true;
            }
            break;
            }

            Point3D loc = m.Location;

            Effects.SendLocationParticles(EffectItem.Create(new Point3D(loc.X + 1, loc.Y, loc.Z), m.Map, EffectItem.DefaultDuration), 0x376A, 9, 10, 9502);
            Effects.SendLocationParticles(EffectItem.Create(new Point3D(loc.X, loc.Y - 1, loc.Z), m.Map, EffectItem.DefaultDuration), 0x376A, 9, 10, 9502);
            Effects.SendLocationParticles(EffectItem.Create(new Point3D(loc.X - 1, loc.Y, loc.Z), m.Map, EffectItem.DefaultDuration), 0x376A, 9, 10, 9502);
            Effects.SendLocationParticles(EffectItem.Create(new Point3D(loc.X, loc.Y + 1, loc.Z), m.Map, EffectItem.DefaultDuration), 0x376A, 9, 10, 9502);
            Effects.SendLocationParticles(EffectItem.Create(new Point3D(loc.X, loc.Y, loc.Z), m.Map, EffectItem.DefaultDuration), 0, 0, 0, 5014);
        }
示例#11
0
        public static void RestoreState(
            PlayerMobile m,
            Serial serial,
            bool moveExisting,
            bool logging,
            out int created,
            out int deleted,
            out int ignored,
            out int moved)
        {
            var pack = m.Backpack;

            if (pack == null || pack.Deleted)
            {
                m.AddItem(
                    pack = new Backpack
                {
                    Movable = false
                });
            }

            var bank = m.BankBox;

            if (bank == null || bank.Deleted)
            {
                m.AddItem(
                    bank = new BankBox(m)
                {
                    Movable = false
                });
            }

            if (serial == Serial.MinusOne)
            {
                serial = m.Serial;
            }

            var root = VitaNexCore.DataDirectory + "/PlayerBackup/" + m.Account.Username + "/" + serial;

            var idxFile = IOUtility.EnsureFile(root + ".idx");
            var binFile = IOUtility.EnsureFile(root + ".bin");

            var logFile = logging ? IOUtility.EnsureFile(root + ".log") : null;
            var log     = logging ? new StringBuilder() : null;

            if (log != null)
            {
                log.AppendLine();
                log.AppendLine(new String('*', 10));
                log.AppendLine();
                log.AppendLine("RESTORE:\tDate[{0}]\tMobile[{1}]", DateTime.UtcNow, m);
                log.AppendLine();
            }

            int idxCreated = 0, idxDeleted = 0, idxIgnored = 0, idxMoved = 0;

            idxFile.Deserialize(
                idx =>
            {
                idx.GetVersion();

                var ser = idx.ReadInt();

                if (ser != m.Serial.Value)
                {
                    if (log != null)
                    {
                        log.AppendLine("INVALID:\tSerial[{0:X8}]", ser);
                    }

                    return;
                }

                long idxLength;
                int idxCount;

                ReadLength(idx, false, out idxLength, out idxCount);

                if (log != null)
                {
                    log.AppendLine("INDEX:\tCount[{0}]\tLength[{1}]", idxCount, idxLength);
                }

                var items = new Tuple <Item, Serial, long, long, string> [idxCount];

                binFile.Deserialize(
                    bin =>
                {
                    bin.GetVersion();

                    var restored = new Dictionary <Item, Serial>();

                    Backpack oldPack = null;
                    BankBox oldBank  = null;

                    for (var i = 0; i < idxCount; i++)
                    {
                        Type type;
                        Serial s, parent;
                        long binIndex, binLength;

                        ReadIndex(idx, out type, out s, out parent, out binIndex, out binLength);

                        var valid  = s.IsValid && s.IsItem;
                        var exists = World.Items.ContainsKey(s);

                        Item item = null;

                        if (exists)
                        {
                            item = World.Items[s];

                            if (item == null || item.Deleted)
                            {
                                World.Items.Remove(s);
                                exists = false;
                            }
                        }

                        object logItem;
                        string status;

                        if (!exists && valid && type.IsEqualOrChildOf <Item>())
                        {
                            item = type.CreateInstanceSafe <Item>(s);

                            if (item == null)
                            {
                                ++idxIgnored;

                                logItem = s;
                                status  = "NULL";
                            }
                            else if (item.Deleted)
                            {
                                ++idxDeleted;

                                item    = null;
                                logItem = s;
                                status  = "DELETED";
                            }
                            else
                            {
                                ++idxCreated;

                                World.AddItem(item);

                                logItem = item;
                                status  = "CREATED";
                            }
                        }
                        else if (exists && valid && moveExisting && item.RootParent != m)
                        {
                            ++idxMoved;

                            logItem = item;
                            status  = "MOVE";
                        }
                        else
                        {
                            ++idxIgnored;

                            item    = null;
                            logItem = s;
                            status  = exists ? "EXISTS" : "INVALID";
                        }

                        if (log != null)
                        {
                            log.AppendLine(
                                "DATA:\tIndex[{0}]\t\tLength[{1}]\tStatus[{2}]\tItem[{3}]\t\t\tParent[{4}]",
                                //
                                binIndex,
                                binLength,
                                status,
                                logItem,
                                parent);
                        }

                        items[i] = Tuple.Create(item, parent, binIndex, binLength, status);
                    }

                    foreach (var t in items)
                    {
                        var item   = t.Item1;
                        var parent = t.Item2;
                        var index  = t.Item3;
                        var length = t.Item4;
                        var status = t.Item5;

                        bin.Seek(index, SeekOrigin.Begin);

                        if (item == null)
                        {
                            bin.Seek(index + length, SeekOrigin.Begin);
                            continue;
                        }

                        Exception x = null;

                        if (status == "MOVE")
                        {
                            bin.Seek(index + length, SeekOrigin.Begin);

                            status = "IGNORED";
                        }
                        else
                        {
                            try
                            {
                                item.Deserialize(bin);

                                status = "LOADED";
                            }
                            catch (Exception e)
                            {
                                --idxCreated;
                                ++idxDeleted;

                                item.Delete();
                                x = e;

                                status = "ERROR";
                            }
                        }

                        if (log != null)
                        {
                            log.AppendLine(
                                "READ:\tIndex[{0}]\tLength[{1}]\tStatus[{2}]\tItem[{3}]\t\t\tParent[{4}]",
                                index,
                                length,
                                status,
                                item,
                                parent);

                            if (x != null)
                            {
                                log.AppendLine();
                                log.AppendLine(new String('*', 10));
                                log.AppendLine(x.ToString());
                                log.AppendLine(new String('*', 10));
                                log.AppendLine();
                            }
                        }

                        if (parent == m.Serial)
                        {
                            if (item is BankBox)
                            {
                                oldBank = (BankBox)item;
                            }
                            else if (item is Backpack)
                            {
                                oldPack = (Backpack)item;
                            }
                        }

                        restored.Add(item, parent);
                    }

                    if (log != null)
                    {
                        log.AppendLine();
                    }

                    Point3D p;

                    foreach (var kv in restored.Where(kv => !kv.Key.Deleted).OrderBy(kv => kv.Value))
                    {
                        var item = kv.Key;

                        if ((item == oldPack || item == oldBank) && item != pack && item != bank)
                        {
                            if (item.Parent is Item)
                            {
                                ((Item)item.Parent).RemoveItem(item);
                            }
                            else if (item.Parent is Mobile)
                            {
                                ((Mobile)item.Parent).RemoveItem(item);
                            }

                            item.Parent = null;
                            continue;
                        }

                        var parent = World.FindEntity(kv.Value);

                        if (item != pack && item != bank && (item.Parent == oldPack || item.Parent == oldBank))
                        {
                            ((Item)item.Parent).RemoveItem(item);
                        }

                        if (parent != null)
                        {
                            if (item == pack || item == bank)
                            {
                                m.AddItem(item);
                            }
                            else if (parent == pack || parent == oldPack)
                            {
                                p = item.Location;
                                pack.DropItem(item);
                                item.Location = p;
                            }
                            else if (parent == bank || parent == oldBank)
                            {
                                p = item.Location;
                                bank.DropItem(item);
                                item.Location = p;
                            }
                            else if (parent is Container)
                            {
                                if (parent.Deleted)
                                {
                                    bank.DropItem(item);
                                }
                                else
                                {
                                    p = item.Location;
                                    ((Container)parent).DropItem(item);
                                    item.Location = p;
                                }
                            }
                            else if (parent is Mobile)
                            {
                                if (!m.EquipItem(item))
                                {
                                    pack.DropItem(item);
                                }
                            }
                            else
                            {
                                bank.DropItem(item);
                            }

                            item.SetLastMoved();
                            item.UpdateTotals();
                            item.Delta(ItemDelta.Update);
                        }
                        else if (Cleanup.IsBuggable(item))
                        {
                            --idxCreated;
                            ++idxDeleted;

                            item.Delete();
                        }
                        else
                        {
                            item.Internalize();
                        }
                    }

                    if (oldPack != null && oldPack != pack && !restored.ContainsKey(oldPack))
                    {
                        oldPack.Delete();
                    }

                    if (oldBank != null && oldBank != bank && !restored.ContainsKey(oldBank))
                    {
                        oldBank.Delete();
                    }

                    if (log != null)
                    {
                        log.AppendLine();
                    }

                    foreach (var kv in restored)
                    {
                        if (kv.Key.Deleted)
                        {
                            if (log != null)
                            {
                                log.AppendLine("DELETED:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Value);
                            }
                        }
                        else if (kv.Key.RootParent == m && kv.Key.Map == Map.Internal && kv.Key.Location == Point3D.Zero)
                        {
                            if (log != null)
                            {
                                log.AppendLine("INTERNAL:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Value);
                            }
                        }
                        else if (kv.Key.RootParent != m)
                        {
                            if (log != null)
                            {
                                log.AppendLine("IGNORED:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Value);
                            }
                        }
                        else
                        {
                            if (log != null)
                            {
                                log.AppendLine("RESTORED:\tItem[{0}]\t\tParent[{1}]", kv.Key, kv.Key.Parent);
                            }
                        }
                    }

                    restored.Clear();

                    m.SendEverything();
                });
            });

            created = idxCreated;
            deleted = idxDeleted;
            ignored = idxIgnored;
            moved   = idxMoved;

            if (log == null)
            {
                return;
            }

            log.AppendLine();
            log.AppendLine(
                "RESULT:\tCreated[{0}]\t\tDeleted[{1}]\t\tIgnored[{2}]\t\tMoved[{3}]",
                created,
                deleted,
                ignored,
                moved);

            logFile.AppendText(false, log.ToString());
        }
示例#12
0
        public void Target(Corpse c)
        {
            Mobile m = c.Owner;

            if (m == null)
            {
            }
            else if (!Caster.CanSee(c))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (m == Caster)
            {
                Caster.SendLocalizedMessage(501039);                   // Thou can not resurrect thyself.
            }
            else if (!Caster.Alive)
            {
                Caster.SendLocalizedMessage(501040);                   // The resurrecter must be alive.
            }
            else if (m.Alive)
            {
                Caster.SendLocalizedMessage(501041);                   // Target is not dead.
            }
            else if (!Caster.InRange(c, 1))
            {
                Caster.SendLocalizedMessage(501042);                   // Target is not close enough.
            }
            else if (!m.Player)
            {
                Caster.SendLocalizedMessage(501043);                   // Target is not a being.
            }
            else if (CheckBSequence(m, true))
            {
                PlayerMobile pm = m as PlayerMobile;

                if (pm != null)
                {
                    SpellHelper.Turn(Caster, pm);

                    pm.PlaySound(0x214);
                    Effects.SendTargetEffect(pm, 0x376A, 10, 16);

                    if (pm.MortEngine.TimerEvanouie != null)
                    {
                        pm.MortEngine.TimerEvanouie.Stop();
                        pm.MortEngine.TimerEvanouie = null;
                    }

                    if (pm.MortEngine.TimerMort != null)
                    {
                        pm.MortEngine.TimerMort.Stop();
                        pm.MortEngine.TimerMort = null;
                    }

                    pm.Location = c.Location;
                    pm.MortEngine.EndroitMort  = c.Location;
                    pm.MortEngine.RisqueDeMort = false;
                    pm.MortEngine.Mort         = false;
                    pm.Frozen = false;

                    ArrayList list = new ArrayList();

                    foreach (Item item in c.Items)
                    {
                        list.Add(item);
                    }

                    foreach (Item item in list)
                    {
                        if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair)
                        {
                            item.Delete();
                        }

                        if (item is RaceSkin || c.EquipItems.Contains(item))
                        {
                            if (!pm.EquipItem(item))
                            {
                                pm.AddToBackpack(item);
                            }
                        }
                        else
                        {
                            pm.AddToBackpack(item);
                        }
                    }

                    pm.Direction = c.Direction;
                    pm.Animate(21, 5, 1, false, false, 0);

                    c.Delete();

                    pm.Resurrect();

                    pm.CheckRaceSkin();
                }
            }
            FinishSequence();
        }
示例#13
0
        public override void OnCast()
        {
            if (Caster == null || Caster.Deleted || !Caster.Alive)
            {
                return;
            }

            foreach (Item itema in Caster.GetItemsInRange(1 + (int)(Caster.Skills[SkillName.ArtMagique].Base / 10)))
            {
                if (itema != null && itema is Corpse)
                {
                    Corpse c = (Corpse)itema;

                    if (c != null && c.Owner != null && c.Owner is PlayerMobile)
                    {
                        PlayerMobile pm = (PlayerMobile)(c.Owner);

                        if (pm.MortEngine.MortCurrentState == MortState.Assomage)
                        {
                            //pm.AddFatigue(-100);

                            SpellHelper.Turn(Caster, pm);

                            pm.PlaySound(0x214);
                            Effects.SendTargetEffect(pm, 0x376A, 10, 16);

                            if (pm.MortEngine.TimerEvanouie != null)
                            {
                                pm.MortEngine.TimerEvanouie.Stop();
                                pm.MortEngine.TimerEvanouie = null;
                            }

                            if (pm.MortEngine.TimerMort != null)
                            {
                                pm.MortEngine.TimerMort.Stop();
                                pm.MortEngine.TimerMort = null;
                            }

                            pm.Location = c.Location;
                            pm.MortEngine.EndroitMort  = c.Location;
                            pm.MortEngine.RisqueDeMort = false;
                            pm.MortEngine.Mort         = false;
                            pm.Frozen = false;

                            pm.Direction = c.Direction;
                            pm.MoveToWorld(c.Location, c.Map);
                            pm.Animate(21, 5, 1, false, false, 0);

                            pm.Resurrect();

                            if (c != null)
                            {
                                ArrayList list = new ArrayList();

                                foreach (Item item in c.Items)
                                {
                                    list.Add(item);
                                }

                                foreach (Item item in list)
                                {
                                    if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair)
                                    {
                                        item.Delete();
                                    }

                                    if (item is RaceSkin || c.EquipItems.Contains(item))
                                    {
                                        if (!pm.EquipItem(item))
                                        {
                                            pm.AddToBackpack(item);
                                        }
                                    }
                                    else
                                    {
                                        pm.AddToBackpack(item);
                                    }
                                }
                            }

                            pm.CheckRaceSkin();
                            pm.CheckStatTimers();

                            pm.MortEngine.MortCurrentState = MortState.Ebranle;
                        }
                    }
                }
            }
        }
示例#14
0
            public void GoToPrison()
            {
                try
                {
                    if (m_Player == null || m_Player.Deleted)
                    {
                        return;
                    }

                    Account acct = m_Player.Account as Account;

                    // stable the players pets
                    StablePets(m_Staff, m_Player);

                    // drop holding
                    Item held = m_Player.Holding;
                    if (held != null)
                    {
                        held.ClearBounce();
                        if (m_Player.Backpack != null)
                        {
                            m_Player.Backpack.DropItem(held);
                        }
                    }
                    m_Player.Holding = null;

                    // move their items to the bank, overload if needed
                    Backpack  bag   = new Backpack();
                    ArrayList equip = new ArrayList(m_Player.Items);

                    if (m_Player.Backpack != null)
                    {
                        // count clothing items
                        int WornCount = 0;
                        foreach (Item i in equip)
                        {
                            if (Moongate.RestrictedItem(m_Player, i) == false)
                            {
                                continue;                                       // not clothes
                            }
                            else
                            {
                                WornCount++;
                            }
                        }

                        // Unequip any items being worn
                        foreach (Item i in equip)
                        {
                            if (Moongate.RestrictedItem(m_Player, i) == false)
                            {
                                continue;
                            }
                            else
                            {
                                m_Player.Backpack.DropItem(i);
                            }
                        }

                        // Get a count of all items in the player's backpack.
                        ArrayList items = new ArrayList(m_Player.Backpack.Items);

                        // Drop our new bag in the player's bank
                        m_Player.BankBox.DropItem(bag);

                        // Run through all items in player's pack, move them to the bag we just dropped in the bank
                        foreach (Item i in items)
                        {
                            m_Player.Backpack.RemoveItem(i);
                            bag.DropItem(i);
                        }
                    }

                    // handle imprisoning of logged out players
                    m_Player.MoveToWorld(m_Location, Map.Felucca);
                    if (m_Player.NetState == null)
                    {
                        m_Player.LogoutLocation = m_Location;
                        m_Player.Map            = Map.Internal;
                    }

                    // make them an inmate
                    m_Player.Inmate = true;

                    // Give them a Deathrobe, Stinger dagger, and a blank spell book
                    if (m_Player.Alive)
                    {
                        Item robe = new Server.Items.DeathRobe();
                        if (!m_Player.EquipItem(robe))
                        {
                            robe.Delete();
                        }
                    }

                    Item aiStinger = new Server.Items.AIStinger();
                    if (!m_Player.AddToBackpack(aiStinger))
                    {
                        aiStinger.Delete();
                    }

                    Item spellbook = new Server.Items.Spellbook();
                    if (!m_Player.AddToBackpack(spellbook))
                    {
                        spellbook.Delete();
                    }

                    m_Player.ShortTermCriminalCounts += 3;                                                              // how long you will stay
                    m_Player.LongTermCriminalCounts++;                                                                  // how many times you've been to prison

                    if (!m_Player.Alive && m_Player.NetState != null)
                    {
                        m_Player.CloseGump(typeof(Server.Gumps.ResurrectGump));
                        m_Player.SendGump(new Server.Gumps.ResurrectGump(m_Player, Server.Gumps.ResurrectMessage.Healer));
                    }

                    int sentence = (int)m_Player.ShortTermCriminalCounts * 4;                     // decay time in prison is 4 hours per count
                    m_Player.SendMessage("You have been imprisoned for {0} hours.", sentence);
                    m_Staff.SendMessage("{0} has been imprisoned for {1} hours.", m_Player.Name, sentence);

                    LogHelper Logger = new LogHelper("Prison.log", false, true);

                    Logger.Log(LogType.Mobile, m_Player, string.Format("{0}:{1}:{2}:{3}",
                                                                       m_Staff.Name,
                                                                       m_Staff.Location,
                                                                       m_Comment,
                                                                       sentence));
                    Logger.Finish();

                    Commands.CommandLogging.WriteLine(m_Staff, "{0} imprisoned {1}(Username: {2}) for {4} hours with reason: {3}.",
                                                      m_Staff.Name, m_Player.Name, acct.Username, m_Comment, sentence);
                    acct.Comments.Add(new AccountComment(m_Staff.Name, DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nImprisoned for " + sentence + " hours. Reason: " + m_Comment));
                }
                catch (Exception ex)
                {
                    LogHelper.LogException(ex);
                }
            }
示例#15
0
        public override void Detransformer(PlayerMobile from)
        {
            base.Detransformer(from);

            from.EquipItem(new CorpsNordique(from.Hue));
        }
示例#16
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (from.Deleted)
            {
                return;
            }

            switch (info.ButtonID)
            {
            case 1:
                if (!(m_From.MortEngine.MortCurrentState == MortState.MortVivant))
                {
                    m_From.MortEngine.AmeLastFed = DateTime.Now;

                    m_From.MortEngine.MortVivant       = true;
                    m_From.MortEngine.MortCurrentState = MortState.MortVivant;

                    MortVivantEvoTimer timer = new MortVivantEvoTimer(m_From);
                    m_From.MortEngine.MortVivantTimer = timer;
                    timer.Start();

                    m_From.Hits   = (m_From.HitsMax / 2) + Utility.RandomMinMax(-5, 5);
                    m_From.Frozen = true;
                    //if (Temrael.beta)
                    //    m_From.Map = Map.Ilshenar;
                    m_From.Location        = m_From.MortEngine.EndroitMort;
                    m_From.MortEngine.Mort = false;
                    m_From.Resurrect();
                    m_From.Frozen = false;

                    if (m_From.Corpse != null)
                    {
                        ArrayList list = new ArrayList();

                        foreach (Item item in m_From.Corpse.Items)
                        {
                            list.Add(item);
                        }

                        foreach (Item item in list)
                        {
                            if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair)
                            {
                                item.Delete();
                            }

                            if (item is RaceSkin || (m_From.Corpse is Corpse && ((Corpse)m_From.Corpse).EquipItems.Contains(item)))
                            {
                                if (!m_From.EquipItem(item))
                                {
                                    m_From.AddToBackpack(item);
                                }
                            }
                            else
                            {
                                m_From.AddToBackpack(item);
                            }
                        }

                        m_From.Corpse.Delete();
                    }

                    m_From.CheckStatTimers();
                    m_From.CheckRaceSkin();
                }
                break;
            }
        }