예제 #1
0
        public override void Lift(Item item, int amount, out bool rejected, out LRReason reject)
        {
            rejected = true;
            reject = LRReason.Inspecific;

            if (item == null)
                return;

            Mobile from = this;
            NetState state = NetState;

            if (from.AccessLevel >= AccessLevel.GameMaster || DateTime.Now >= from.NextActionTime)
            {
                if (from.CheckAlive())
                {
                    from.DisruptiveAction();

                    if (from.Holding != null)
                    {
                        reject = LRReason.AreHolding;
                    }
                    else if (from.AccessLevel < AccessLevel.GameMaster && !from.InRange(item.GetWorldLocation(), 3))
                    {
                        reject = LRReason.OutOfRange;
                    }
                    else if (!from.CanSee(item) || !from.InLOS(item))
                    {
                        reject = LRReason.OutOfSight;
                    }
                    else if (!item.VerifyMove(from))
                    {
                        reject = LRReason.CannotLift;
                    }
                    else if (!item.IsAccessibleTo(from))
                    {
                        reject = LRReason.CannotLift;
                    }
                    else if (from.AccessLevel == AccessLevel.Player && (from.Frozen || from.Paralyzed))
                    {
                        reject = LRReason.CannotLift;
                    }
                    else if (!item.CheckLift(from, item, ref reject))
                    {
                    }
                    else
                    {
                        object root = item.RootParent;

                        bool canLoot;
                        if (root is Corpse)
                        {
                            Corpse corpse = (Corpse)root;
                            CustomRegion cs = Region.Find(corpse.Location, corpse.Map) as CustomRegion;

                            if (cs != null)
                            {
                                if (AccessLevel >= AccessLevel.GameMaster || (cs.Controller.CanLootOwnCorpse && cs.Controller.CanLootPlayerCorpse))
                                    canLoot = true;
                                else if (corpse.Owner == this)
                                    canLoot = cs.Controller.CanLootOwnCorpse;
                                else if (corpse.Owner is PlayerMobile)
                                    canLoot = cs.Controller.CanLootPlayerCorpse;
                                else
                                    canLoot = cs.Controller.CanLootNPCCorpse;
                            }
                            else
                                canLoot = true;
                        }
                        else
                            canLoot = true;

                        if (!canLoot)
                        {
                            SendAsciiMessage("You can't loot here.");
                            reject = LRReason.Inspecific;
                        }
                        else if (root != null && root is Mobile && !((Mobile) root).CheckNonlocalLift(from, item))
                        {
                            reject = LRReason.TryToSteal;
                        }
                        else if (!from.OnDragLift(item) || !item.OnDragLift(from))
                        {
                            reject = LRReason.Inspecific;
                        }
                        else if (!from.CheckAlive())
                        {
                            reject = LRReason.Inspecific;
                        }
                        else if (item.EventItem && !IsInEvent && AccessLevel < AccessLevel.GameMaster)
                        {
                            SendAsciiMessage("You can't use event items!");
                            reject = LRReason.Inspecific;
                        }
                        else if (!item.EventItem && IsInEvent && AccessLevel < AccessLevel.GameMaster)
                        {
                            SendAsciiMessage("You can only use event items!");
                            reject = LRReason.Inspecific;
                        }
                        else
                        {
                            item.SetLastMoved();

                            if (item.Spawner != null)
                            {
                                item.Spawner.Remove(item);
                                item.Spawner = null;
                            }

                            if (amount == 0)
                                amount = 1;

                            if (amount > item.Amount)
                                amount = item.Amount;

                            int oldAmount = item.Amount;
                            //item.Amount = amount; //Set in LiftItemDupe

                            if (amount < oldAmount)
                                LiftItemDupe(item, amount);
                            //item.Dupe( oldAmount - amount );

                            Map map = from.Map;

                            if (DragEffects && map != null && (root == null || root is Item))
                            {
                                IPooledEnumerable eable = map.GetClientsInRange(from.Location);
                                Packet p = null;

                                foreach (NetState ns in eable)
                                {
                                    if (ns.Mobile != from && ns.Mobile.CanSee(from) && (!ns.Mobile.HasFilter || InLOS(ns.Mobile)))
                                    {
                                        if (p == null)
                                        {
                                            IEntity src;

                                            if (root == null)
                                                src = new Entity(Serial.Zero, item.Location, map);
                                            else
                                                src = new Entity(((Item) root).Serial, ((Item) root).Location, map);

                                            p = Packet.Acquire(new DragEffect(src, from, item.ItemID, item.Hue, amount));
                                        }

                                        ns.Send(p);
                                    }
                                }

                                Packet.Release(p);

                                eable.Free();
                            }

                            Point3D fixLoc = item.Location;
                            Map fixMap = item.Map;
                            bool shouldFix = (item.Parent == null);

                            item.RecordBounce();
                            item.OnItemLifted(from, item);
                            item.Internalize();

                            from.Holding = item;

                            from.NextActionTime = DateTime.Now + TimeSpan.FromSeconds(0.4);

                            if (fixMap != null && shouldFix)
                                fixMap.FixColumn(fixLoc.X, fixLoc.Y);

                            reject = LRReason.Inspecific;
                            rejected = false;
                        }
                    }
                }
                else
                {
                    reject = LRReason.Inspecific;
                }
            }
            else
            {
                SendActionMessage();
                reject = LRReason.Inspecific;
            }

            if (rejected && state != null)
            {
                state.Send(new LiftRej(reject));

                if (item.Parent is Item)
                {
                    if (state.ContainerGridLines)
                        state.Send(new ContainerContentUpdate6017(item));
                    else
                        state.Send(new ContainerContentUpdate(item));
                }
                else if (item.Parent is Mobile)
                    state.Send(new EquipUpdate(item));
                else
                    item.SendInfoTo(state);

                if (ObjectPropertyList.Enabled && item.Parent != null)
                    state.Send(item.OPLPacket);
            }
        }