コード例 #1
0
        public PotionTastingGump( DrinkPotion potion, Mobile taster )
            : base(0, 0)
        {
            this.Closable=true;
            this.Disposable=false;
            this.Dragable=true;
            this.Resizable=false;

            string htmlText = "<CENTER><BASEFONT COLOR=#5BAE0A>";

            List<string> effects = new List<string>();
            List<string> sideEffects = new List<string>();

            foreach ( KeyValuePair<CustomEffect, int> kvp in potion.Effects )
            {
                CustomPotionEffect effect = CustomPotionEffect.GetEffect( kvp.Key );
                if ( effect != null )
                {
                    if ( kvp.Value > 0 )
                        effects.Add( effect.Name );
                    else
                        sideEffects.Add( effect.Name );
                }
            }

            foreach ( string name in effects )
                htmlText += "+ " + name + "<BR>";

            htmlText += "<BASEFONT COLOR=#BF2121>";

            foreach ( string name in sideEffects )
                htmlText += "- " + name + "<BR>";

            this.AddPage(0);
            this.AddBackground(198, 119, 249, 265, 9270);
            this.AddBackground(208, 192, 228, 186, 83);
            this.AddHtml( 222, 209, 199, 152, htmlText, (bool)false, (bool)true);
            this.AddImage(190, 114, 30079);
            this.AddImage(193, 332, 30080);
            this.AddImage(396, 292, 30081);
            this.AddHtml( 220, 136, 207, 22, "<CENTER><BASEFONT COLOR=#AAAA11>" + potion.Name, (bool)false, (bool)false);

            if ( Utility.RandomDouble() < 0.05 )
                this.AddLabel(243, 169, 39, "Hmm, tastes like chicken.");
            else
                this.AddImage(278, 175, 30061);
        }
コード例 #2
0
        public int AttemptCraft()
        {
            Bottle emptyBottle = m_Brewer.Backpack.FindItemByType( typeof( Bottle ) ) as Bottle;
            if ( m_Ingredients.Count == 0 )
                return -3;	// there's nothing to craft

            else if ( emptyBottle == null )
                return -5;	// the bottle must be in your pack

            else if ( Type == PotionType.Bomb && m_Range < 0 )
                return -6;	// not enough bomb in this bomb potion, MISTAR
            else if ( Type == PotionType.Oil && m_Duration <= 0 )
                return -7;

            object bottleParent = emptyBottle.Parent;
            Type[] types = new Type[m_Ingredients.Count];
            int[] amounts = new int[m_Ingredients.Count];
            int i = 0;

            foreach ( KeyValuePair<Type, int> kvp in m_Ingredients ) // build the ingredients list so we can remove them faster
            {
                types[i] = kvp.Key;
                amounts[i] = kvp.Value;
                i++;
            }

            if ( m_Brewer.Backpack.ConsumeTotal( types, amounts ) != -1 ) // couldn't find them
                return -1; // not enough resources

            if ( CraftChance() > Utility.RandomDouble() )
            {
                CustomPotion potion;

                if ( Type == PotionType.Bomb )
                {
                    potion = new BombPotion( m_Bottle );
                    ((BombPotion)potion).ExplosionRange = m_Range;
                    ((BombPotion)potion).InstantExplosion = m_InstantExplosion;
                }
                else if ( Type == PotionType.Oil )
                {
                    potion = new OilPotion( m_Bottle );
                    ((OilPotion)potion).Duration = m_Duration;
                    ((OilPotion)potion).Corrosivity = m_Corrosivity;
                }
                else
                    potion = new DrinkPotion( m_Bottle );

                emptyBottle.Consume( 1 );
                potion.Name = m_Name;
                //potion.Hue = GetFinalHue(); // This has been disabled since the ingredient hues look funny on bottles

                foreach (KeyValuePair<CustomEffect, int> kvp in m_PotionEffects)
                {
                    if (kvp.Value != 0)
                    {
                        if (m_Brewer is PlayerMobile && (kvp.Key.GetType() == typeof(MadnessEffect) || kvp.Key.GetType() == typeof(ConfusionEffect) || kvp.Key.GetType() == typeof(OintmentEffect)))
                        {
                            PlayerMobile pm = m_Brewer as PlayerMobile;
                            int effectBonus = 0;
                            switch (pm.Feats.GetFeatLevel(FeatList.Pathology))
                            {
                                case 0: break;
                                case 1: break;
                                case 2: effectBonus = (int)(kvp.Value * 0.1); break;
                                case 3: effectBonus = (int)(kvp.Value * 0.3); break;
                                default: break;
                            }
                            potion.AddEffect(kvp.Key, kvp.Value + effectBonus);
                        }
                        else
                            potion.AddEffect(kvp.Key, kvp.Value);
                    }
                }

                if ( !( bottleParent is BaseContainer ) || !((BaseContainer)bottleParent).TryDropItem( m_Brewer, potion, false ) )
                    m_Brewer.AddToBackpack( potion );

                return 1; // craft succeeded
            }

            else
                return -2; // craft failed
        }