Inheritance: Server.Items.Container, IHasQuantity
Beispiel #1
0
        public bool GetWaterFromContainer(Mobile from, object target)
        {
            if (target is BaseBeverage)
            {
                BaseBeverage beverage = target as BaseBeverage;

                if (beverage.Quantity >= 1 && beverage.Content == BeverageType.Water)
                {
                    beverage.Quantity--;
                    return(true);
                }
            }

            else if (target is BaseWaterContainer)
            {
                BaseWaterContainer waterContainer = target as BaseWaterContainer;

                if (waterContainer.Quantity >= 1)
                {
                    waterContainer.Quantity--;
                    return(true);
                }
            }

            else if (target is IWaterSource)
            {
                IWaterSource waterSource = target as IWaterSource;

                if (waterSource.Quantity >= 1)
                {
                    waterSource.Quantity--;
                    return(true);
                }
            }

            else
            {
                Item         item = (Item)target;
                IWaterSource waterSource;

                waterSource = (item as IWaterSource);

                if (waterSource == null && item is AddonComponent)
                {
                    waterSource = (((AddonComponent)item).Addon as IWaterSource);

                    if (waterSource != null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        public static bool IsWaterContainer(object target)
        {
            if (target is BaseBeverage)
            {
                BaseBeverage beverage = target as BaseBeverage;

                if (beverage.Content == BeverageType.Water)
                {
                    return(true);
                }
            }

            else if (target is BaseWaterContainer)
            {
                BaseWaterContainer waterContainer = target as BaseWaterContainer;

                return(true);
            }

            else if (target is IWaterSource)
            {
                IWaterSource waterSource = target as IWaterSource;

                return(true);
            }

            else
            {
                Item         item = (Item)target;
                IWaterSource waterSource;

                waterSource = (item as IWaterSource);

                if (waterSource == null && item is AddonComponent)
                {
                    waterSource = (((AddonComponent)item).Addon as IWaterSource);

                    if (waterSource != null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #3
0
        public virtual void Pour_OnTarget(Mobile from, object targ)
        {
            if (IsEmpty || !Pourable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (!bev.ValidateUse(from, true))
                {
                    return;
                }

                if (bev.IsFull && bev.Content == this.Content)
                {
                    from.SendLocalizedMessage(500848);   // Couldn't pour it there.  It was already full.
                }
                else if (!bev.IsEmpty)
                {
                    from.SendLocalizedMessage(500846);   // Can't pour it there.
                }
                else
                {
                    bev.Content  = this.Content;
                    bev.Poison   = this.Poison;
                    bev.Poisoner = this.Poisoner;

                    if (this.Quantity > bev.MaxQuantity)
                    {
                        bev.Quantity   = bev.MaxQuantity;
                        this.Quantity -= bev.MaxQuantity;
                    }
                    else
                    {
                        bev.Quantity += this.Quantity;
                        this.Quantity = 0;
                    }

                    from.PlaySound(0x4E);
                }
            }
            else if (from == targ)
            {
                if (from.Thirst < 20)
                {
                    from.Thirst += 1;
                }

                if (ContainsAlchohol)
                {
                    int bac = 0;

                    switch (this.Content)
                    {
                    case BeverageType.Ale: bac = 1; break;

                    case BeverageType.Wine: bac = 2; break;

                    case BeverageType.Cider: bac = 3; break;

                    case BeverageType.Liquor: bac = 4; break;
                    }

                    from.BAC += bac;

                    if (from.BAC > 60)
                    {
                        from.BAC = 60;
                    }

                    CheckHeaveTimer(from);
                }

                from.PlaySound(Utility.RandomList(0x30, 0x2D6));

                if (m_Poison != null)
                {
                    from.ApplyPoison(m_Poisoner, m_Poison);
                }

                --Quantity;
            }
            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (Content != BeverageType.Water)
                {
                    from.SendLocalizedMessage(500842);   // Can't pour that in there.
                }
                else if (bwc.Items.Count != 0)
                {
                    from.SendLocalizedMessage(500841);   // That has something in it.
                }
                else
                {
                    int itNeeds = Math.Min(bwc.MaxQuantity - bwc.Quantity, Quantity);

                    if (itNeeds > 0)
                    {
                        bwc.Quantity += itNeeds;
                        Quantity     -= itNeeds;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is PlantItem)
            {
                ((PlantItem)targ).Pour(from, this);
            }
            else
            {
                from.SendLocalizedMessage(500846);   // Can't pour it there.
            }
        }
Beispiel #4
0
        public virtual void Fill_OnTarget(Mobile from, object targ)
        {
            if (!IsEmpty || !Fillable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (bev.IsEmpty || !bev.ValidateUse(from, true))
                {
                    return;
                }

                this.Content  = bev.Content;
                this.Poison   = bev.Poison;
                this.Poisoner = bev.Poisoner;

                if (bev.Quantity > this.MaxQuantity)
                {
                    this.Quantity = this.MaxQuantity;
                    bev.Quantity -= this.MaxQuantity;
                }
                else
                {
                    this.Quantity += bev.Quantity;
                    bev.Quantity   = 0;
                }
            }
            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (Quantity == 0 || Content == BeverageType.Water && !IsFull)
                {
                    int iNeed = Math.Min(MaxQuantity - Quantity, bwc.Quantity);

                    if (iNeed > 0 && !bwc.IsEmpty && !IsFull)
                    {
                        bwc.Quantity -= iNeed;
                        Quantity     += iNeed;
                        Content       = BeverageType.Water;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is Item)
            {
                Item         item = (Item)targ;
                IWaterSource src;

                src = item as IWaterSource;

                if (src == null && item is AddonComponent)
                {
                    src = ((AddonComponent)item).Addon as IWaterSource;
                }

                if (src == null || src.Quantity <= 0)
                {
                    return;
                }

                if (from.Map != item.Map || !from.InRange(item.GetWorldLocation(), 2) || !from.InLOS(item))
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045);   // I can't reach that.
                    return;
                }

                this.Content  = BeverageType.Water;
                this.Poison   = null;
                this.Poisoner = null;

                if (src.Quantity > this.MaxQuantity)
                {
                    this.Quantity = this.MaxQuantity;
                    src.Quantity -= this.MaxQuantity;
                }
                else
                {
                    this.Quantity += src.Quantity;
                    src.Quantity   = 0;
                }

                from.SendLocalizedMessage(1010089);   // You fill the container with water.
            }
            else if (targ is Cow)
            {
                Cow cow = (Cow)targ;

                if (cow.TryMilk(from))
                {
                    Content  = BeverageType.Milk;
                    Quantity = MaxQuantity;
                    from.SendLocalizedMessage(1080197);   // You fill the container with milk.
                }
            }
        }
Beispiel #5
0
        public virtual void Fill_OnTarget(Mobile from, object targ)
        {
            if (!IsEmpty || !Fillable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (bev.IsEmpty || !bev.ValidateUse(from, true))
                {
                    return;
                }

                this.Content  = bev.Content;
                this.Poison   = bev.Poison;
                this.Poisoner = bev.Poisoner;

                if (bev.Quantity > this.MaxQuantity)
                {
                    this.Quantity = this.MaxQuantity;
                    bev.Quantity -= this.MaxQuantity;
                }
                else
                {
                    this.Quantity += bev.Quantity;
                    bev.Quantity   = 0;
                }
            }
            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (Quantity == 0 || (Content == BeverageType.Water && !IsFull))
                {
                    int iNeed = Math.Min((MaxQuantity - Quantity), bwc.Quantity);

                    if (iNeed > 0 && !bwc.IsEmpty && !IsFull)
                    {
                        bwc.Quantity -= iNeed;
                        Quantity     += iNeed;
                        Content       = BeverageType.Water;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is Item)
            {
                Item         item = (Item)targ;
                IWaterSource src;

                src = (item as IWaterSource);

                if (src == null && item is AddonComponent)
                {
                    src = (((AddonComponent)item).Addon as IWaterSource);
                }

                if (src == null || src.Quantity <= 0)
                {
                    return;
                }

                if (from.Map != item.Map || !from.InRange(item.GetWorldLocation(), 2) || !from.InLOS(item))
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045);                       // I can't reach that.
                    return;
                }

                this.Content  = BeverageType.Water;
                this.Poison   = null;
                this.Poisoner = null;

                if (src.Quantity > this.MaxQuantity)
                {
                    this.Quantity = this.MaxQuantity;
                    src.Quantity -= this.MaxQuantity;
                }
                else
                {
                    this.Quantity += src.Quantity;
                    src.Quantity   = 0;
                }

                from.SendLocalizedMessage(1010089);                   // You fill the container with water.
            }
            else if (targ is Cow)
            {
                Cow cow = (Cow)targ;

                if (cow.TryMilk(from))
                {
                    Content  = BeverageType.Milk;
                    Quantity = MaxQuantity;
                    from.SendLocalizedMessage(1080197);                       // You fill the container with milk.
                }
            }
            else if (targ is LandTarget)
            {
                int tileID = ((LandTarget)targ).TileID;

                PlayerMobile player = from as PlayerMobile;

                if (player != null)
                {
                    QuestSystem qs = player.Quest;

                    if (qs is WitchApprenticeQuest)
                    {
                        FindIngredientObjective obj = qs.FindObjective(typeof(FindIngredientObjective)) as FindIngredientObjective;

                        if (obj != null && !obj.Completed && obj.Ingredient == Ingredient.SwampWater)
                        {
                            bool contains = false;

                            for (int i = 0; !contains && i < m_SwampTiles.Length; i += 2)
                            {
                                contains = (tileID >= m_SwampTiles[i] && tileID <= m_SwampTiles[i + 1]);
                            }

                            if (contains)
                            {
                                Delete();

                                player.SendLocalizedMessage(1055035);                                   // You dip the container into the disgusting swamp water, collecting enough for the Hag's vile stew.
                                obj.Complete();
                            }
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public virtual void Pour_OnTarget(Mobile from, object targ)
        {
            if (IsEmpty || !Pourable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (!bev.ValidateUse(from, true))
                {
                    return;
                }

                if (bev.IsFull && bev.Content == this.Content)
                {
                    from.SendLocalizedMessage(500848);                       // Couldn't pour it there.  It was already full.
                }
                else if (!bev.IsEmpty)
                {
                    from.SendLocalizedMessage(500846);                       // Can't pour it there.
                }
                else
                {
                    bev.Content  = this.Content;
                    bev.Poison   = this.Poison;
                    bev.Poisoner = this.Poisoner;

                    if (this.Quantity > bev.MaxQuantity)
                    {
                        bev.Quantity   = bev.MaxQuantity;
                        this.Quantity -= bev.MaxQuantity;
                    }
                    else
                    {
                        bev.Quantity += this.Quantity;
                        this.Quantity = 0;
                    }

                    from.PlaySound(0x4E);
                }
            }
            else if (from == targ)
            {
                if (from.Thirst < 20)
                {
                    from.Thirst += 1;
                }

                if (ContainsAlchohol)
                {
                    int bac = 0;

                    switch (this.Content)
                    {
                    case BeverageType.Ale: bac = 1; break;

                    case BeverageType.Wine: bac = 2; break;

                    case BeverageType.Cider: bac = 3; break;

                    case BeverageType.Liquor: bac = 4; break;
                    }

                    from.BAC += bac;

                    if (from.BAC > 60)
                    {
                        from.BAC = 60;
                    }

                    CheckHeaveTimer(from);
                }

                from.PlaySound(Utility.RandomList(0x30, 0x2D6));

                if (m_Poison != null)
                {
                    from.ApplyPoison(m_Poisoner, m_Poison);
                }

                --Quantity;
            }
            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (Content != BeverageType.Water)
                {
                    from.SendLocalizedMessage(500842);                       // Can't pour that in there.
                }
                else if (bwc.Items.Count != 0)
                {
                    from.SendLocalizedMessage(500841);                       // That has something in it.
                }
                else
                {
                    int itNeeds = Math.Min((bwc.MaxQuantity - bwc.Quantity), Quantity);

                    if (itNeeds > 0)
                    {
                        bwc.Quantity += itNeeds;
                        Quantity     -= itNeeds;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is PlantItem)
            {
                ((PlantItem)targ).Pour(from, this);
            }
            else if (targ is AddonComponent &&
                     (((AddonComponent)targ).Addon is WaterVatEast || ((AddonComponent)targ).Addon is WaterVatSouth) &&
                     this.Content == BeverageType.Water)
            {
                PlayerMobile player = from as PlayerMobile;

                if (player != null)
                {
                    SolenMatriarchQuest qs = player.Quest as SolenMatriarchQuest;

                    if (qs != null)
                    {
                        QuestObjective obj = qs.FindObjective(typeof(GatherWaterObjective));

                        if (obj != null && !obj.Completed)
                        {
                            BaseAddon vat = ((AddonComponent)targ).Addon;

                            if (vat.X > 5784 && vat.X < 5814 && vat.Y > 1903 && vat.Y < 1934 &&
                                ((qs.RedSolen && vat.Map == Map.Trammel) || (!qs.RedSolen && vat.Map == Map.Felucca)))
                            {
                                if (obj.CurProgress + Quantity > obj.MaxProgress)
                                {
                                    int delta = obj.MaxProgress - obj.CurProgress;

                                    Quantity       -= delta;
                                    obj.CurProgress = obj.MaxProgress;
                                }
                                else
                                {
                                    obj.CurProgress += Quantity;
                                    Quantity         = 0;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(500846);                   // Can't pour it there.
            }
        }
Beispiel #7
0
        public virtual void Pour_OnTarget(Mobile from, object targ)
        {
            if (IsEmpty || !Pourable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (!bev.ValidateUse(from, true))
                {
                    return;
                }

                if (bev.IsFull && bev.Content == this.Content)
                {
                    from.SendLocalizedMessage(500848);                       // Couldn't pour it there.  It was already full.
                }
                else if (!bev.IsEmpty)
                {
                    from.SendLocalizedMessage(500846);                       // Can't pour it there.
                }
                else
                {
                    bev.Content  = this.Content;
                    bev.Poison   = this.Poison;
                    bev.Poisoner = this.Poisoner;

                    if (this.Quantity > bev.MaxQuantity)
                    {
                        bev.Quantity   = bev.MaxQuantity;
                        this.Quantity -= bev.MaxQuantity;
                    }
                    else
                    {
                        bev.Quantity += this.Quantity;
                        this.Quantity = 0;
                    }

                    from.PlaySound(0x4E);
                }
            }
            else if (from == targ)
            {
                // increase characters thirst value based on type of drink // WIZARD
                if (from.Thirst < 20)
                {
                    switch (this.Content)
                    {
                    case BeverageType.Water: from.Thirst += 5; break;

                    case BeverageType.Milk: from.Thirst += 4; break;

                    case BeverageType.Ale: from.Thirst += 3; break;

                    case BeverageType.Wine: from.Thirst += 2; break;

                    case BeverageType.Cider: from.Thirst += 3; break;

                    case BeverageType.Liquor: from.Thirst += 1; break;
                    }
                    // Send message to character about their current thirst value
                    int iThirst = from.Thirst;
                    if (iThirst < 5)
                    {
                        from.SendMessage("You take a drink but are still extremely thirsty");
                    }
                    else if (iThirst < 10)
                    {
                        from.SendMessage("You take a drink and feel less thirsty");
                    }
                    else if (iThirst < 15)
                    {
                        from.SendMessage("You take a drink and feel much less thirsty");
                    }
                    else
                    {
                        from.SendMessage("You take a drink and are no longer thirsty");
                    }

                    Server.Items.DrinkingFunctions.DrinkBenefits(from);
                }
                else
                {
                    from.Thirst = 20;
                }

                if (ContainsAlchohol)
                {
                    int bac = 0;

                    switch (this.Content)
                    {
                    case BeverageType.Ale: bac = 1; break;

                    case BeverageType.Wine: bac = 2; break;

                    case BeverageType.Cider: bac = 3; break;

                    case BeverageType.Liquor: bac = 4; break;
                    }

                    from.BAC += bac;

                    if (from.BAC > 60)
                    {
                        from.BAC = 60;
                    }

                    CheckHeaveTimer(from);
                }

                from.PlaySound(Utility.RandomList(0x30, 0x2D6));

                if (m_Poison != null)
                {
                    from.ApplyPoison(m_Poisoner, m_Poison);
                }

                --Quantity;
            }
            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if ((!this.IsEmpty || this.Content == BeverageType.Water) && bwc.Items.Count == 0)
                {
                    int It_Needs = Math.Min((bwc.MaxQuantity - bwc.Quantity), Quantity);

                    if (It_Needs > 0 && (!IsEmpty && !bwc.IsFull))
                    {
                        bwc.Quantity += It_Needs;
                        Quantity     -= It_Needs;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is PlantItem)
            {
                ((PlantItem)targ).Pour(from, this);
            }
            else
            {
                from.SendLocalizedMessage(500846);                   // Can't pour it there.
            }
        }
Beispiel #8
0
        public virtual void Fill_OnTarget(Mobile from, object targ)
        {
            if (!IsEmpty || !Fillable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is Aquarium)
            {
                Aquarium aquarium = targ as Aquarium;

                if (aquarium.WaterLevel < Aquarium.MaxWaterLevel)
                {
                    int waterNeeded = Aquarium.MaxWaterLevel - aquarium.WaterLevel;
                    int waterUsed   = waterNeeded;

                    if (Quantity < waterUsed)
                    {
                        waterUsed = Quantity;
                    }

                    aquarium.WaterLevel += waterUsed;
                    Quantity            -= waterUsed;

                    from.PlaySound(0x4E);

                    from.CloseGump(typeof(AquariumGump));
                    from.SendMessage("You add water to the aquarium.");
                }
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (bev.IsEmpty || !bev.ValidateUse(from, true))
                {
                    return;
                }

                this.Content  = bev.Content;
                this.Poison   = bev.Poison;
                this.Poisoner = bev.Poisoner;

                if (bev.Quantity > this.MaxQuantity)
                {
                    this.Quantity = this.MaxQuantity;
                    bev.Quantity -= this.MaxQuantity;
                }
                else
                {
                    this.Quantity += bev.Quantity;
                    bev.Quantity   = 0;
                }
            }

            if (targ is Aquarium)
            {
                Aquarium aquarium = targ as Aquarium;

                if (aquarium.WaterLevel < Aquarium.MaxWaterLevel)
                {
                    int waterNeeded = Aquarium.MaxWaterLevel - aquarium.WaterLevel;
                    int waterAdded  = waterNeeded;

                    if (Quantity < waterAdded)
                    {
                        waterAdded = Quantity;
                    }

                    Quantity            -= waterAdded;
                    aquarium.WaterLevel += waterAdded;

                    from.PlaySound(0x4E);

                    from.CloseGump(typeof(AquariumGump));
                    from.SendMessage("You add water to the aquarium.");
                }

                else
                {
                    from.SendMessage("That aquarium is already full of water.");
                }
            }

            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (Quantity == 0 || (Content == BeverageType.Water && !IsFull))
                {
                    int iNeed = Math.Min((MaxQuantity - Quantity), bwc.Quantity);

                    if (iNeed > 0 && !bwc.IsEmpty && !IsFull)
                    {
                        bwc.Quantity -= iNeed;
                        Quantity     += iNeed;
                        Content       = BeverageType.Water;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is Item)
            {
                Item         item = (Item)targ;
                IWaterSource src;

                src = (item as IWaterSource);

                if (src == null && item is AddonComponent)
                {
                    src = (((AddonComponent)item).Addon as IWaterSource);
                }

                if (src == null || src.Quantity <= 0)
                {
                    return;
                }

                if (from.Map != item.Map || !from.InRange(item.GetWorldLocation(), 2) || !from.InLOS(item))
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
                    return;
                }

                this.Content  = BeverageType.Water;
                this.Poison   = null;
                this.Poisoner = null;

                if (src.Quantity > this.MaxQuantity)
                {
                    this.Quantity = this.MaxQuantity;
                    src.Quantity -= this.MaxQuantity;
                }
                else
                {
                    this.Quantity += src.Quantity;
                    src.Quantity   = 0;
                }

                from.SendLocalizedMessage(1010089); // You fill the container with water.
            }

            else if (targ is LandTarget)
            {
                int tileID = ((LandTarget)targ).TileID;

                PlayerMobile player = from as PlayerMobile;

                if (player != null)
                {
                }
            }
        }
Beispiel #9
0
        public virtual void Pour_OnTarget(Mobile from, object targ)
        {
            if (IsEmpty || !Pourable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is Aquarium)
            {
                Aquarium aquarium = targ as Aquarium;

                int waterNeeded = Aquarium.MaxWaterLevel - aquarium.WaterLevel;
                int waterUsed   = waterNeeded;

                if (Quantity < waterUsed)
                {
                    waterUsed = Quantity;
                }

                aquarium.WaterLevel += waterUsed;
                Quantity            -= waterUsed;

                from.PlaySound(0x4E);

                from.CloseGump(typeof(AquariumGump));
                from.SendMessage("You add water to the aquarium.");
            }

            else if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (!bev.ValidateUse(from, true))
                {
                    return;
                }

                if (bev.IsFull && bev.Content == this.Content)
                {
                    from.SendLocalizedMessage(500848);                       // Couldn't pour it there.  It was already full.
                }

                else if (!bev.IsEmpty)
                {
                    from.SendLocalizedMessage(500846);                       // Can't pour it there.
                }

                else
                {
                    bev.Content  = this.Content;
                    bev.Poison   = this.Poison;
                    bev.Poisoner = this.Poisoner;

                    if (this.Quantity > bev.MaxQuantity)
                    {
                        bev.Quantity   = bev.MaxQuantity;
                        this.Quantity -= bev.MaxQuantity;
                    }
                    else
                    {
                        bev.Quantity += this.Quantity;
                        this.Quantity = 0;
                    }

                    from.PlaySound(0x4E);
                }
            }

            else if (from == targ)
            {
                if (from.Thirst < 20)
                {
                    from.Thirst += 1;
                }

                if (ContainsAlchohol)
                {
                    int bac = 0;

                    switch (this.Content)
                    {
                    case BeverageType.Ale: bac = 1; break;

                    case BeverageType.Wine: bac = 2; break;

                    case BeverageType.Cider: bac = 3; break;

                    case BeverageType.Liquor: bac = 4; break;
                    }

                    from.BAC += bac;

                    if (from.BAC > 60)
                    {
                        from.BAC = 60;
                    }

                    CheckHeaveTimer(from);

                    OnDrink(from);
                }

                from.PlaySound(Utility.RandomList(0x30, 0x2D6));

                if (m_Poison != null)
                {
                    from.ApplyPoison(m_Poisoner, m_Poison);
                }

                --Quantity;
            }

            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (Content != BeverageType.Water)
                {
                    from.SendLocalizedMessage(500842);                       // Can't pour that in there.
                }
                else if (bwc.Items.Count != 0)
                {
                    from.SendLocalizedMessage(500841);                       // That has something in it.
                }
                else
                {
                    int itNeeds = Math.Min((bwc.MaxQuantity - bwc.Quantity), Quantity);

                    if (itNeeds > 0)
                    {
                        bwc.Quantity += itNeeds;
                        Quantity     -= itNeeds;

                        from.PlaySound(0x4E);
                    }
                }
            }

            else if (targ is AddonComponent && (((AddonComponent)targ).Addon is WaterVatEast || ((AddonComponent)targ).Addon is WaterVatSouth) &&
                     this.Content == BeverageType.Water)
            {
                PlayerMobile player = from as PlayerMobile;
            }

            else
            {
                from.SendLocalizedMessage(500846);                   // Can't pour it there.
            }
        }
Beispiel #10
0
        public virtual void Pour_OnTarget(Mobile from, object targ)
        {
            if (IsEmpty || !Pourable || !ValidateUse(from, false))
            {
                return;
            }

            if (targ is BaseBeverage)
            {
                BaseBeverage bev = (BaseBeverage)targ;

                if (!bev.ValidateUse(from, true))
                {
                    return;
                }

                if (bev.IsFull && bev.Content == Content)
                {
                    from.SendLocalizedMessage(500848);
                }
                else if (!bev.IsEmpty)
                {
                    from.SendLocalizedMessage(500846);
                }
                else
                {
                    bev.Content  = Content;
                    bev.Poison   = Poison;
                    bev.Poisoner = Poisoner;

                    if (Quantity > bev.MaxQuantity)
                    {
                        bev.Quantity = bev.MaxQuantity;
                        Quantity    -= bev.MaxQuantity;
                    }
                    else
                    {
                        bev.Quantity += Quantity;
                        Quantity      = 0;
                    }

                    from.PlaySound(0x4E);
                }
            }
            else if (from == targ)
            {
                // increase characters thirst value based on type of drink
                if (from.Thirst < 20)
                {
                    switch (Content)
                    {
                    case BeverageType.Water: from.Thirst += 5; break;

                    case BeverageType.Milk: from.Thirst += 4; break;

                    case BeverageType.Ale: from.Thirst -= 3; break;

                    case BeverageType.Wine: from.Thirst -= 1; break;

                    case BeverageType.Cider: from.Thirst += 3; break;

                    case BeverageType.Liquor: from.Thirst -= 2; break;
                    }

                    int iThirst = from.Thirst;
                    if (iThirst < 5)
                    {
                        from.SendMessage("You take a drink but are still extremely thirsty");
                    }
                    else if (iThirst < 10)
                    {
                        from.SendMessage("You take a drink and feel less thirsty");
                    }
                    else if (iThirst < 14)
                    {
                        from.SendMessage("You take a drink and feel much less thirsty");
                    }
                    else if (iThirst < 18)
                    {
                        from.SendMessage("You take a drink and feel more refreshed");
                    }
                    else
                    {
                        from.SendMessage("You take a drink and are no longer thirsty");
                    }
                }
                else
                {
                    from.Thirst = 20;
                }

                if (ContainsAlchohol)
                {
                    int bac = 0;

                    switch (Content)
                    {
                    case BeverageType.Ale: bac = 1; break;

                    case BeverageType.Wine: bac = 2; break;

                    case BeverageType.Cider: bac = 3; break;

                    case BeverageType.Liquor: bac = 4; break;
                    }

                    from.BAC += bac;

                    if (from.BAC > 60)
                    {
                        from.BAC = 60;
                    }

                    CheckHeaveTimer(from);
                }

                from.PlaySound(Utility.RandomList(0x30, 0x2D6));

                if (m_Poison != null)
                {
                    from.ApplyPoison(m_Poisoner, m_Poison);
                }

                --Quantity;
            }
            else if (targ is BaseWaterContainer)
            {
                BaseWaterContainer bwc = targ as BaseWaterContainer;

                if (this.Content != BeverageType.Water)
                {
                    from.SendLocalizedMessage(500842); // Can't pour that in there.
                }
                else if (bwc.Items.Count != 0)
                {
                    from.SendLocalizedMessage(500841); // That has something in it.
                }
                else
                {
                    int itNeeds = Math.Min((bwc.MaxQuantity - bwc.Quantity), Quantity);

                    if (itNeeds > 0)
                    {
                        bwc.Quantity += itNeeds;
                        Quantity     -= itNeeds;

                        from.PlaySound(0x4E);
                    }
                }
            }
            else if (targ is PlantItem)
            {
                ((PlantItem)targ).Pour(from, this);
            }
            else if (targ is AddonComponent &&
                     (((AddonComponent)targ).Addon is WaterVatEast || ((AddonComponent)targ).Addon is WaterVatSouth) &&
                     this.Content == BeverageType.Water)
            {
                PlayerMobile player = from as PlayerMobile;

                if (player != null)
                {
                    SolenMatriarchQuest qs = player.Quest as SolenMatriarchQuest;

                    if (qs != null)
                    {
                        QuestObjective obj = qs.FindObjective(typeof(GatherWaterObjective));

                        if (obj != null && !obj.Completed)
                        {
                            BaseAddon vat = ((AddonComponent)targ).Addon;

                            if (vat.X > 5784 && vat.X < 5814 && vat.Y > 1903 && vat.Y < 1934 &&
                                ((qs.RedSolen && vat.Map == Map.Trammel) || (!qs.RedSolen && vat.Map == Map.Felucca)))
                            {
                                if (obj.CurProgress + Quantity > obj.MaxProgress)
                                {
                                    int delta = obj.MaxProgress - obj.CurProgress;

                                    Quantity       -= delta;
                                    obj.CurProgress = obj.MaxProgress;
                                }
                                else
                                {
                                    obj.CurProgress += Quantity;
                                    Quantity         = 0;
                                }
                            }
                        }
                    }
                }
            }
            else if (targ is WaterElemental)
            {
                if (this is Pitcher && Content == BeverageType.Water)
                {
                    EndlessDecanter.HandleThrow(this, (WaterElemental)targ, from);
                }
            }
            else
            {
                from.SendLocalizedMessage(500846); // Can't pour it there.
            }
        }