Exemplo n.º 1
0
        private ItemListEntry[] BuildMenu(ItemListEntry[] entries)
        {
            if (m_Mobile == null || entries == null || entries.Length == 0)
            {
                return(EmptyILE);
            }

            ArrayList list = new ArrayList();

            for (int i = 0; i < entries.Length; i++)
            {
                ItemListEntry entry = entries[i];
                if (entry is CraftSubMenu)
                {
                    if (BuildMenu(((CraftSubMenu)entry).SubItems).Length > 0)
                    {
                        list.Add(entry);
                    }
                }
                else if (entry is CraftSystemItem)
                {
                    CraftSystemItem item = (CraftSystemItem)entry;

                    if (CanCraft(item))
                    {
                        list.Add(entry);
                    }
                }
                else
                {
                    list.Add(entry);
                }
            }
            return((ItemListEntry[])list.ToArray(typeof(ItemListEntry)));
        }
Exemplo n.º 2
0
        public override void Finish( CraftSystemItem item )
        {
            End();

            if ( m_Mobile.Deleted || !m_Mobile.Alive || m_Wood == null || m_Wood.Deleted )
                return;

            if ( !CheckTool() )
                return;

            if ( item.CreateType == typeof( Shaft ) )
            {
                if ( HasResources( m_Wood.Amount, typeof( Shaft ) ) )
                {
                    if ( m_Mobile.CheckSkill( item.Skill, item.MinSkill, item.MaxSkill ) )
                    {
                        Item created = new Shaft( m_Wood.Amount );
                        m_Wood.Delete();
                        OnSuccess( created );
                    }
                    else
                    {
                        OnFailure();
                    }
                }
                else
                {
                    OnNotEnoughResources();
                }
            }
            else
            {
                base.Finish(item);
            }
        }
Exemplo n.º 3
0
 public virtual void Finish(CraftSystemItem item)
 {
     if (!m_Mobile.Deleted && m_Mobile.Alive && CheckTool())
     {
         if (!ConsumeResources(item.ResourceCost, item.CreateType))
         {
             OnNotEnoughResources();
         }
         else if (!m_Mobile.CheckSkill(item.Skill, item.MinSkill, item.MaxSkill))
         {
             OnFailure();
         }
         else
         {
             Item obj = item.Create() as Item;
             if (obj != null)
             {
                 OnSuccess(obj);
             }
             else
             {
                 OnFailure();
             }
         }
     }
     End();
 }
Exemplo n.º 4
0
 protected override bool CanCraft(CraftSystemItem item)
 {
     return(m_Mobile.Skills[SkillName.Magery].Value >= item.MinSkill &&
            m_Mobile.Skills[SkillName.Inscribe].Value >= item.MinSkill &&
            item is CSI_Scroll &&
            Spellbook.Find(m_Mobile, ((CSI_Scroll)item).SpellID) != null);
 }
Exemplo n.º 5
0
            public AlchemyTimer(CraftSystemItem item, AlchemySystem sys) : base(TimeSpan.Zero, TimeSpan.FromSeconds(2.75))
            {
                m_From = sys.Mobile;
                m_Sys  = sys;
                m_Item = item;

                Priority = TimerPriority.TwoFiftyMS;
                m_Index  = 0;
            }
Exemplo n.º 6
0
 public override void OnItemSelected(CraftSystemItem item)
 {
     if (!ConsumeResources(item.ResourceCost, item.CreateType))
     {
         OnNotEnoughResources();
     }
     else
     {
         new AlchemyTimer(item, this).Start();
     }
 }
Exemplo n.º 7
0
        public override void OnItemSelected(CraftSystemItem item)
        {
            if (m_Mobile.Deleted || !m_Mobile.Alive)
            {
                End();
                return;
            }

            CSI_Scroll scr = item as CSI_Scroll;

            if (scr == null)
            {
                End();
                return;
            }
            if (Spellbook.Find(m_Mobile, scr.SpellID) == null)
            {
                m_Mobile.SendAsciiMessage("You do not have that spell!");
                End();
                return;
            }

            Spell spell = SpellRegistry.NewSpell(scr.SpellID, m_Mobile, null);

            if (spell == null)
            {
                End();
                return;
            }

            int mana = spell.ScaleMana(spell.GetMana());

            if (m_Mobile.Mana < mana)
            {
                m_Mobile.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana for this spell.
                End();
                return;
            }
            else if (!spell.ConsumeReagents())
            {
                m_Mobile.LocalOverheadMessage(MessageType.Regular, 0x22, 502630);                   // More reagents are needed for this spell.
                End();
                return;
            }

            m_Mobile.Mana -= mana;

            base.OnItemSelected(item);
        }
Exemplo n.º 8
0
        public virtual void OnItemSelected(CraftSystemItem item)
        {
            if (m_Mobile.Deleted || !m_Mobile.Alive)
            {
                End();
                return;
            }

            if (this.SoundEffect != -1)
            {
                m_Mobile.PlaySound(this.SoundEffect);
            }

            new CraftTimer(CraftDelay, item, this).Start();
        }
Exemplo n.º 9
0
        public override void Finish(CraftSystemItem item)
        {
            if (m_Mobile.Deleted || !m_Mobile.Alive)
            {
                End();
                return;
            }

            if (!m_Mobile.CheckSkill(item.Skill, item.MinSkill, item.MaxSkill))
            {
                OnFailure();
            }
            else
            {
                Item bottle = null;
                if (m_Mobile.Backpack != null)
                {
                    bottle = m_Mobile.Backpack.FindItemByType(typeof(Bottle), true);
                }

                if (bottle != null && bottle.Amount > 0)
                {
                    Item obj = item.Create() as Item;
                    if (obj != null)
                    {
                        bottle.Consume();
                        OnSuccess(obj);
                    }
                    else
                    {
                        OnFailure();
                    }
                }
                else
                {
                    ((MortarPestle)Tool).PotionToMake = item.CreateType;
                    Tool.OnDoubleClick(m_Mobile);
                }
            }

            End();
        }
Exemplo n.º 10
0
        public override void Finish( CraftSystemItem item )
        {
            if ( m_Mobile.Deleted || !m_Mobile.Alive )
            {
                End();
                return;
            }

            if ( !m_Mobile.CheckSkill( item.Skill, item.MinSkill, item.MaxSkill ) )
            {
                OnFailure();
            }
            else
            {
                Item bottle = null;
                if ( m_Mobile.Backpack != null )
                    bottle = m_Mobile.Backpack.FindItemByType( typeof( Bottle ), true );

                if ( bottle != null && bottle.Amount > 0 )
                {
                    Item obj = item.Create() as Item;
                    if ( obj != null )
                    {
                        bottle.Consume();
                        OnSuccess( obj );
                    }
                    else
                    {
                        OnFailure();
                    }
                }
                else
                {
                    ((MortarPestle)Tool).PotionToMake = item.CreateType;
                    Tool.OnDoubleClick( m_Mobile );
                }
            }

            End();
        }
Exemplo n.º 11
0
        public override void Finish(CraftSystemItem item)
        {
            End();

            if (m_Mobile.Deleted || !m_Mobile.Alive || m_Wood == null || m_Wood.Deleted)
            {
                return;
            }

            if (!CheckTool())
            {
                return;
            }

            if (item.CreateType == typeof(Shaft))
            {
                if (HasResources(m_Wood.Amount, typeof(Shaft)))
                {
                    if (m_Mobile.CheckSkill(item.Skill, item.MinSkill, item.MaxSkill))
                    {
                        Item created = new Shaft(m_Wood.Amount);
                        m_Wood.Delete();
                        OnSuccess(created);
                    }
                    else
                    {
                        OnFailure();
                    }
                }
                else
                {
                    OnNotEnoughResources();
                }
            }
            else
            {
                base.Finish(item);
            }
        }
Exemplo n.º 12
0
        protected static int GetResourcesFor(Type find, ItemListEntry[] entries)
        {
            for (int i = 0; i < entries.Length; i++)
            {
                if (entries[i] is CraftSystemItem)
                {
                    CraftSystemItem csi = (CraftSystemItem)entries[i];
                    if (csi.CreateType.IsSubclassOf(find))
                    {
                        return(csi.ResourceCost);
                    }
                }
                else if (entries[i] is CraftSubMenu)
                {
                    int sub = GetResourcesFor(find, ((CraftSubMenu)entries[i]).SubItems);
                    if (sub != -1)
                    {
                        return(sub);
                    }
                }
            }

            return(-1);
        }
Exemplo n.º 13
0
            public AlchemyTimer( CraftSystemItem item, AlchemySystem sys )
                : base(TimeSpan.Zero, TimeSpan.FromSeconds( 2.75 ))
            {
                m_From = sys.Mobile;
                m_Sys = sys;
                m_Item = item;

                Priority = TimerPriority.TwoFiftyMS;
                m_Index = 0;
            }
Exemplo n.º 14
0
 public override void OnItemSelected( CraftSystemItem item )
 {
     if ( !ConsumeResources( item.ResourceCost, item.CreateType ) )
         OnNotEnoughResources();
     else
         new AlchemyTimer( item, this ).Start();
 }
Exemplo n.º 15
0
 public CraftTimer( TimeSpan delay, CraftSystemItem item, CraftSystem sys )
     : base(delay)
 {
     this.Priority = TimerPriority.TwoFiftyMS;
     m_Sys = sys;
     m_Item = item;
 }
Exemplo n.º 16
0
 protected virtual bool CanCraft( CraftSystemItem item )
 {
     return m_Mobile.Skills[item.Skill].Value >= item.MinSkill && HasResources( item.ResourceCost, item.CreateType );
 }
Exemplo n.º 17
0
        public virtual void OnItemSelected( CraftSystemItem item )
        {
            if ( m_Mobile.Deleted || !m_Mobile.Alive )
            {
                End();
                return;
            }

            if ( this.SoundEffect != -1 )
                m_Mobile.PlaySound( this.SoundEffect );

            new CraftTimer( CraftDelay, item, this ).Start();
        }
Exemplo n.º 18
0
 public virtual void Finish( CraftSystemItem item )
 {
     if ( !m_Mobile.Deleted && m_Mobile.Alive && CheckTool() )
     {
         if ( !ConsumeResources( item.ResourceCost, item.CreateType ) )
         {
             OnNotEnoughResources();
         }
         else if ( !m_Mobile.CheckSkill( item.Skill, item.MinSkill, item.MaxSkill ) )
         {
             OnFailure();
         }
         else
         {
             Item obj = item.Create() as Item;
             if ( obj != null )
                 OnSuccess( obj );
             else
                 OnFailure();
         }
     }
     End();
 }
Exemplo n.º 19
0
 protected override bool CanCraft(CraftSystemItem item)
 {
     return m_Mobile.Skills[SkillName.Magery].Value >= item.MinSkill &&
         m_Mobile.Skills[SkillName.Inscribe].Value >= item.MinSkill &&
         item is CSI_Scroll &&
         Spellbook.Find( m_Mobile, ((CSI_Scroll)item).SpellID ) != null ;
 }
Exemplo n.º 20
0
        public override void OnItemSelected(CraftSystemItem item)
        {
            if ( m_Mobile.Deleted || !m_Mobile.Alive )
            {
                End();
                return;
            }

            CSI_Scroll scr = item as CSI_Scroll;
            if ( scr == null )
            {
                End();
                return;
            }
            if ( Spellbook.Find( m_Mobile, scr.SpellID ) == null )
            {
                m_Mobile.SendAsciiMessage( "You do not have that spell!" );
                End();
                return;
            }

            Spell spell = SpellRegistry.NewSpell( scr.SpellID, m_Mobile, null );
            if ( spell == null )
            {
                End();
                return;
            }

            int mana = spell.ScaleMana( spell.GetMana() );
            if ( m_Mobile.Mana < mana )
            {
                m_Mobile.LocalOverheadMessage( MessageType.Regular, 0x22, 502625 ); // Insufficient mana for this spell.
                End();
                return;
            }
            else if ( !spell.ConsumeReagents() )
            {
                m_Mobile.LocalOverheadMessage( MessageType.Regular, 0x22, 502630 ); // More reagents are needed for this spell.
                End();
                return;
            }

            m_Mobile.Mana -= mana;

            base.OnItemSelected( item );
        }
Exemplo n.º 21
0
        public override void Finish(CraftSystemItem item)
        {
            if (!CheckTool())
            {
                End();
                return;
            }

            if (!ConsumeResources(item.ResourceCost, item.CreateType))
            {
                OnNotEnoughResources();
            }
            else if (!m_Mobile.CheckSkill(item.Skill, item.MinSkill, item.MaxSkill))
            {
                OnFailure();
            }
            else
            {
                Item obj = item.Create() as Item;
                if (obj != null)
                {
                    OnSuccess(obj);

                    if (m_Mobile.Skills[SkillName.Blacksmith].Value >= item.MaxSkill || (item.MaxSkill > 100 && m_Mobile.Skills[SkillName.Blacksmith].Value > 99.0 && Utility.Random(10) == 0))
                    {
                        if (obj is BaseArmor)
                        {
                            ((BaseArmor)obj).Quality = CraftQuality.Exceptional;
                        }
                        else if (obj is BaseWeapon)
                        {
                            ((BaseWeapon)obj).Quality = CraftQuality.Exceptional;
                        }
                        if (m_Mobile.Skills[SkillName.Blacksmith].Value >= 99.0)
                        {
                            if (obj is BaseArmor)
                            {
                                ((BaseArmor)obj).Crafter = m_Mobile;
                            }
                            else if (obj is BaseWeapon)
                            {
                                ((BaseWeapon)obj).Crafter = m_Mobile;
                            }
                        }
                        m_Mobile.SendAsciiMessage("Due to your exceptional skill, it's quality is higher than average.");
                    }
                    else if (m_Mobile.Skills[SkillName.Blacksmith].Value <= item.MinSkill + ((item.MaxSkill - item.MinSkill) * 0.25))
                    {
                        if (obj is BaseArmor)
                        {
                            ((BaseArmor)obj).Quality = CraftQuality.Low;
                        }
                        else if (obj is BaseWeapon)
                        {
                            ((BaseWeapon)obj).Quality = CraftQuality.Low;
                        }
                        m_Mobile.SendAsciiMessage("You were barely able to make this item.  It's quality is below average.");
                    }
                }
                else
                {
                    OnFailure();
                }
            }

            End();
        }
Exemplo n.º 22
0
 public override void OnItemSelected(CraftSystemItem item)
 {
     base.OnItemSelected(item);
     m_Mobile.Emote("*{0} begins carving.*", m_Mobile.Name);
     m_Mobile.PlaySound(85);
 }
Exemplo n.º 23
0
 public override void OnItemSelected(CraftSystemItem item)
 {
     base.OnItemSelected (item);
     m_Mobile.Emote( "*{0} begins carving.*", m_Mobile.Name );
     m_Mobile.PlaySound( 85 );
 }
Exemplo n.º 24
0
        public override void Finish( CraftSystemItem item )
        {
            if ( !CheckTool() )
            {
                End();
                return;
            }

            if ( !ConsumeResources( item.ResourceCost, item.CreateType ) )
            {
                OnNotEnoughResources();
            }
            else if ( !m_Mobile.CheckSkill( item.Skill, item.MinSkill, item.MaxSkill ) )
            {
                OnFailure();
            }
            else
            {
                Item obj = item.Create() as Item;
                if ( obj != null )
                {
                    OnSuccess( obj );

                    if ( m_Mobile.Skills[SkillName.Blacksmith].Value >= item.MaxSkill || ( item.MaxSkill > 100 && m_Mobile.Skills[SkillName.Blacksmith].Value > 99.0 && Utility.Random( 10 ) == 0 ) )
                    {
                        if ( obj is BaseArmor )
                            ((BaseArmor)obj).Quality = CraftQuality.Exceptional;
                        else if ( obj is BaseWeapon )
                            ((BaseWeapon)obj).Quality = CraftQuality.Exceptional;
                        if ( m_Mobile.Skills[SkillName.Blacksmith].Value >= 99.0 )
                        {
                            if ( obj is BaseArmor )
                                ((BaseArmor)obj).Crafter = m_Mobile;
                            else if ( obj is BaseWeapon )
                                ((BaseWeapon)obj).Crafter = m_Mobile;
                        }
                        m_Mobile.SendAsciiMessage( "Due to your exceptional skill, it's quality is higher than average." );
                    }
                    else if ( m_Mobile.Skills[SkillName.Blacksmith].Value <= item.MinSkill+((item.MaxSkill-item.MinSkill)*0.25) )
                    {
                        if ( obj is BaseArmor )
                            ((BaseArmor)obj).Quality = CraftQuality.Low;
                        else if ( obj is BaseWeapon )
                            ((BaseWeapon)obj).Quality = CraftQuality.Low;
                        m_Mobile.SendAsciiMessage( "You were barely able to make this item.  It's quality is below average." );
                    }
                }
                else
                {
                    OnFailure();
                }
            }

            End();
        }
Exemplo n.º 25
0
 protected virtual bool CanCraft(CraftSystemItem item)
 {
     return(m_Mobile.Skills[item.Skill].Value >= item.MinSkill && HasResources(item.ResourceCost, item.CreateType));
 }
Exemplo n.º 26
0
 public CraftTimer(TimeSpan delay, CraftSystemItem item, CraftSystem sys) : base(delay)
 {
     this.Priority = TimerPriority.TwoFiftyMS;
     m_Sys         = sys;
     m_Item        = item;
 }