Beispiel #1
0
        protected virtual bool DropGold(uint gold)
        {
            if (EXPOwner != null && EXPOwner.CanGainGold(gold) && !Settings.DropGold)
            {
                EXPOwner.WinGold(gold);
                return true;
            }

            uint count = gold / Settings.MaxDropGold == 0 ? 1 : gold / Settings.MaxDropGold + 1;
            for (int i = 0; i < count; i++)
            {
                ItemObject ob = new ItemObject(this, i != count - 1 ? Settings.MaxDropGold : gold % Settings.MaxDropGold)
                {
                    Owner = EXPOwner,
                    OwnerTime = Envir.Time + Settings.Minute,
                };

                ob.Drop(Settings.DropRange);
            }

            return true;
        }
Beispiel #2
0
        protected virtual bool DropItem(UserItem item)
        {
            if (CurrentMap.Info.NoDropMonster) return false;

            ItemObject ob = new ItemObject(this, item)
            {
                Owner = EXPOwner,
                OwnerTime = Envir.Time + Settings.Minute,
            };

            return ob.Drop(Settings.DropRange);
        }
Beispiel #3
0
        private bool FillTargetList(Point location)
        {
            int range = CreatureRules.SemiAutoPickupRange;

            TargetList.Clear();
            for (int d = 0; d <= range; d++)
            {
                for (int y = location.Y - d; y <= location.Y + d; y++)
                {
                    if (y < 0)
                    {
                        continue;
                    }
                    if (y >= CurrentMap.Height)
                    {
                        break;
                    }

                    for (int x = location.X - d; x <= location.X + d; x += Math.Abs(y - location.Y) == d ? 1 : d * 2)
                    {
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= CurrentMap.Width)
                        {
                            break;
                        }

                        Cell cell = CurrentMap.GetCell(x, y);
                        if (!cell.Valid || cell.Objects == null)
                        {
                            continue;
                        }

                        for (int i = 0; i < cell.Objects.Count; i++)
                        {
                            MapObject ob = cell.Objects[i];
                            if (ob == null)
                            {
                                continue;
                            }
                            if (ob.Race != ObjectType.Item)
                            {
                                continue;
                            }
                            if (ob.Owner != null && ob.Owner != this && ob.Owner != Master && !IsMasterGroupMember(ob.Owner))
                            {
                                continue;
                            }

                            ItemObject item = (ItemObject)ob;
                            if (item.Item != null)
                            {
                                if (!((PlayerObject)Master).CanGainItem(item.Item))
                                {
                                    continue;
                                }
                                if (CheckItemAgainstFilter(item.Item.Info.Type))
                                {
                                    if (item.Item.Info.Grade >= ItemFilter.PickupGrade)
                                    {
                                        TargetList.Add(ob);
                                    }
                                    break;
                                }
                            }
                            else
                            {
                                if (item.Gold > 0)
                                {
                                    if (!((PlayerObject)Master).CanGainGold(item.Gold))
                                    {
                                        continue;
                                    }
                                    if (ItemFilter.PetPickupAll || ItemFilter.PetPickupGold)
                                    {
                                        TargetList.Add(ob);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(TargetList.Count > 0);
        }
Beispiel #4
0
        public void PickUpItem(Point location)
        {
            if (Dead || Master == null)
            {
                return;
            }

            Cell cell = CurrentMap.GetCell(location);

            if (!cell.Valid || cell.Objects == null)
            {
                return;
            }
            for (int i = 0; i < cell.Objects.Count; i++)
            {
                MapObject ob = cell.Objects[i];
                if (ob == null)
                {
                    continue;
                }
                if (ob.Race != ObjectType.Item)
                {
                    continue;
                }
                if (ob.Owner != null && ob.Owner != this && ob.Owner != Master && !IsMasterGroupMember(ob.Owner))
                {
                    continue;
                }

                ItemObject item = (ItemObject)ob;
                if (item == null)
                {
                    continue;
                }
                if (item.Item != null)
                {
                    if (!((PlayerObject)Master).CanGainItem(item.Item))
                    {
                        continue;
                    }

                    if (item.Item.Info.ShowGroupPickup && IsMasterGroupMember(Master))
                    {
                        for (int j = 0; j < Master.GroupMembers.Count; j++)
                        {
                            Master.GroupMembers[j].ReceiveChat(Name + " Picked up: {" + item.Item.Name + "}", ChatType.Hint);
                        }
                    }

                    if (item.Item.Info.Grade == ItemGrade.Mythical || item.Item.Info.Grade == ItemGrade.Legendary)
                    {
                        Master.ReceiveChat("Pet Picked up: {" + item.Item.Name + "}", ChatType.Hint);
                        ((PlayerObject)Master).Enqueue(new S.IntelligentCreaturePickup {
                            ObjectID = ObjectID
                        });
                    }

                    ((PlayerObject)Master).GainItem(item.Item);
                    CurrentMap.RemoveObject(ob);
                    ob.Despawn();
                    return;
                }
                else
                {
                    if (ob == null)
                    {
                        continue;
                    }
                    if (!((PlayerObject)Master).CanGainGold(item.Gold))
                    {
                        continue;
                    }
                    ((PlayerObject)Master).GainGold(item.Gold);
                    CurrentMap.RemoveObject(ob);
                    ob.Despawn();
                    return;
                }
            }
        }
        private bool DropItem(UserItem item, int range = 1)
        {
            ItemObject ob = new ItemObject(this, item);

            if (!ob.Drop(range)) return false;

            if (item.Info.Type == ItemType.Meat)
                item.CurrentDura = (ushort)Math.Max(0, item.CurrentDura - 2000);

            return true;
        }
Beispiel #6
0
        private void FindItemTarget()
        {
            int range = shortcheck ? 4 : CreatureRules.AutoPickupRange;

            for (int d = 0; d <= range; d++)
            {
                for (int y = CurrentLocation.Y - d; y <= CurrentLocation.Y + d; y++)
                {
                    if (y < 0)
                    {
                        continue;
                    }
                    if (y >= CurrentMap.Height)
                    {
                        break;
                    }

                    for (int x = CurrentLocation.X - d; x <= CurrentLocation.X + d; x += Math.Abs(y - CurrentLocation.Y) == d ? 1 : d * 2)
                    {
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= CurrentMap.Width)
                        {
                            break;
                        }

                        Cell cell = CurrentMap.GetCell(x, y);
                        if (!cell.Valid || cell.Objects == null)
                        {
                            continue;
                        }

                        for (int i = 0; i < cell.Objects.Count; i++)
                        {
                            MapObject ob = cell.Objects[i];
                            if (ob == null)
                            {
                                continue;
                            }
                            if (ob.Race != ObjectType.Item)
                            {
                                continue;
                            }
                            if (ob.Owner != null && ob.Owner != this && ob.Owner != Master && !IsMasterGroupMember(ob.Owner))
                            {
                                continue;
                            }

                            ItemObject item = (ItemObject)ob;
                            if (item.Item != null)
                            {
                                if (!((PlayerObject)Master).CanGainItem(item.Item))
                                {
                                    continue;
                                }
                                if (CheckItemAgainstFilter(item.Item.Info.Type))
                                {
                                    //Master.ReceiveChat("YEAH ITEM I CAN GAIN {" + item.Item.FriendlyName + "} " + item.Item.Info.Type.ToString(), ChatType.System);
                                    if (item.Item.Info.Grade >= ItemFilter.PickupGrade)
                                    {
                                        Target = ob;
                                    }
                                    shortcheck = false;
                                    return;
                                }
                            }
                            else
                            {
                                if (item.Gold > 0)
                                {
                                    if (!((PlayerObject)Master).CanGainGold(item.Gold))
                                    {
                                        continue;
                                    }
                                    if (ItemFilter.PetPickupAll || ItemFilter.PetPickupGold)
                                    {
                                        //Master.ReceiveChat("YEAH GOLD I CAN GAIN {" + item.Gold + "}", ChatType.System);
                                        Target     = ob;
                                        shortcheck = false;
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            shortcheck = false;
        }
        public void DropGold(uint gold)
        {
            if (Account.Gold < gold) return;

            ItemObject ob = new ItemObject(this, gold);

            if (!ob.Drop(5)) return;
            Account.Gold -= gold;
            Enqueue(new S.LoseGold { Gold = gold });
        }
Beispiel #8
0
        protected virtual bool DropGold(uint gold)
        {
            if (EXPOwner != null && EXPOwner.CanGainGold(gold))
            {
                EXPOwner.WinGold(gold);
                return true;
            }

            ItemObject ob = new ItemObject(this, gold)
            {
                Owner = EXPOwner,
                OwnerTime = Envir.Time + Settings.Minute,
            };

            return ob.Drop(Settings.DropRange);
        }
        protected virtual bool DropItem(UserItem item)
        {
            ItemObject ob = new ItemObject(this, item)
            {
                Owner = EXPOwner,
                OwnerTime = Envir.Time + Settings.Minute,
            };

            return ob.Drop(Settings.DropRange);
        }
Beispiel #10
0
        protected bool DropGold(uint gold)
        {
            if (this.LinkedMonster.EXPOwner != null && this.LinkedMonster.EXPOwner.CanGainGold(gold))
            {
                this.LinkedMonster.EXPOwner.WinGold(gold);
                return true;
            }

            Point droplocation = new Point(DropArea.Left + (DropArea.Width / 2), DropArea.Top);
            ItemObject ob = new ItemObject(this.LinkedMonster, gold, droplocation)
            {
                Owner = this.LinkedMonster.EXPOwner,
                OwnerTime = Envir.Time + Settings.Minute,
            };

            return ob.DragonDrop(DropArea.Width / 2);
        }
Beispiel #11
0
        protected bool DropItem(UserItem item)
        {
            Point droplocation = new Point(DropArea.Left + (DropArea.Width / 2), DropArea.Top);
            ItemObject ob = new ItemObject(this.LinkedMonster, item, droplocation)
            {
                Owner = this.LinkedMonster.EXPOwner,
                OwnerTime = Envir.Time + Settings.Minute,
            };

            return ob.DragonDrop(DropArea.Width / 2);
        }