public CraftContext GetContext( Mobile m )
		{
			if ( m == null )
				return null;

			if ( m.Deleted )
			{
				m_ContextTable.Remove( m );
				return null;
			}

			CraftContext c = (CraftContext)m_ContextTable[m];

			if ( c == null )
				m_ContextTable[m] = c = new CraftContext();

			return c;
		}
Exemple #2
0
		public CraftContext GetContext( Mobile m )
		{
			if ( m == null )
				return null;

			if ( m.Deleted )
			{
				m_ContextTable.Remove( m );
				return null;
			}

			CraftContext c = null;
			m_ContextTable.TryGetValue( m, out c );

			if ( c == null )
				m_ContextTable[m] = c = new CraftContext();

			return c;
		}
Exemple #3
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            // Back Button
            if (info.ButtonID == 0)
            {
                CraftGump craftGump = new CraftGump(m_From, m_CraftSystem, m_Tool, null);
                m_From.SendGump(craftGump);
            }
            else             // Make Button
            {
                int num = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.ItemType);

                if (num > 0)
                {
                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, num));
                }
                else
                {
                    Type type = null;

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    if (context != null)
                    {
                        CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
                        int            resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                        if (resIndex > -1)
                        {
                            type = res.GetAt(resIndex).ItemType;
                        }
                    }

                    m_CraftSystem.CreateItem(m_From, m_CraftItem.ItemType, type, m_Tool, m_CraftItem);
                }
            }
        }
Exemple #4
0
        public CraftContext GetContext(Mobile m)
        {
            if (m == null)
            {
                return(null);
            }

            if (m.Deleted)
            {
                m_ContextTable.Remove(m);
                return(null);
            }

            CraftContext c = null;

            m_ContextTable.TryGetValue(m, out c);

            if (c == null)
            {
                m_ContextTable[m] = c = new CraftContext();
            }

            return(c);
        }
Exemple #5
0
        public static void Do(Mobile from, CraftSystem craftSystem, BaseTool tool)
        {
            int num = craftSystem.CanCraft(from, tool, null);

            if (num > 0 && num != 1044267)
            {
                from.SendGump(new CraftGump(from, craftSystem, tool, num));
            }

            else
            {
                CraftContext context = craftSystem.GetContext(from);

                if (context == null)
                {
                    return;
                }

                from.Target = new InternalTarget(craftSystem, tool);

                switch (context.RecycleOption)
                {
                case CraftRecycleOption.RecycleItem:
                    from.SendMessage("Target an item to recycle.");
                    break;

                case CraftRecycleOption.RecycleAllNonExceptional:
                    from.SendMessage("Target the type of item you wish to recycle. All non-exceptional items of that type found in your pack will be processed.");
                    break;

                case CraftRecycleOption.RecycleAll:
                    from.SendMessage("Target the type of item you wish to recycle. All items of that type found in your pack will be processed.");
                    break;
                }
            }
        }
Exemple #6
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (!this.CheckDeed(from))
                {
                    return;
                }

                bool usingDeed = (this.m_Deed != null);
                bool toDelete  = false;

                // TODO: Make an IRepairable

                if (this.m_CraftSystem.CanCraft(from, this.m_Tool, targeted.GetType()) == 1044267)
                {
                    number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
                }
                else if (this.m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426; // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423; // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153; // You don't have the required skills to attempt this item.	//TODO: How does OSI handle this with deeds with golems?
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789; // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number   = 1044279; // You repair the item.
                                    toDelete = true;

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);
                                }
                                else
                                {
                                    number = 1044037; // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037; // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = this.m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (this.m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !this.IsSpecialWeapon(weapon))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (!Core.AOS && weapon.PoisonCharges != 0)
                    {
                        number = 1005012; // You cannot repair an item while a caustic substance is on it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                                                                    // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else if (targeted is DragonsEnd || targeted is KatrinasCrook || targeted is JaanasStaff) // Quick fix
                    {
                        number = 1044277;                                                                    // That item cannot be repaired.
                    }
                    else
                    {
                        if (this.CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (this.CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            this.m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                            //daat99 OWLTR start - tokens on repairs
                            if (OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.CRAFT_GIVE_TOKENS))
                            {
                                TokenSystem.GiveTokensToPlayer(from as PlayerMobile, Utility.Random(5));
                            }
                            //daat99 OWLTR end - tokens on repairs
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            this.m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = this.m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (this.m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !this.IsSpecialArmor(armor))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!armor.IsChildOf(from.Backpack) && (!Core.ML || armor.Parent != from))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                                                 // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else if (armor is LordBlackthornsExemplar || armor is SentinelsGuard) // quick fix
                    {
                        number = 1044277;                                                 // That item cannot be repaired.
                    }
                    else
                    {
                        if (this.CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (this.CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            this.m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            this.m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)targeted;
                    SkillName    skill    = this.m_CraftSystem.MainSkill;
                    int          toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (this.m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !this.IsSpecialClothing(clothing) && !((targeted is TribalMask) || (targeted is HornedTribalMask)))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!clothing.IsChildOf(from.Backpack) && (!Core.ML || clothing.Parent != from))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (clothing.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (this.CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            clothing.MaxHitPoints -= toWeaken;
                            clothing.HitPoints     = Math.Max(0, clothing.HitPoints - toWeaken);
                        }

                        if (this.CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            this.m_CraftSystem.PlayCraftEffect(from);
                            clothing.HitPoints = clothing.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            this.m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (!usingDeed && targeted is BlankScroll)
                {
                    SkillName skill = this.m_CraftSystem.MainSkill;

                    if (from.Skills[skill].Value >= 50.0)
                    {
                        ((BlankScroll)targeted).Consume(1);
                        RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(this.m_CraftSystem), from.Skills[skill].Value, from);
                        from.AddToBackpack(deed);

                        number = 500442; // You create the item and put it in your backpack.
                    }
                    else
                    {
                        number = 1047005; // You must be at least apprentice level to create a repair service contract.
                    }
                }
                else if (targeted is Item)
                {
                    number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426; // You can't repair that.
                }

                if (!usingDeed)
                {
                    CraftContext context = this.m_CraftSystem.GetContext(from);
                    from.SendGump(new CraftGump(from, this.m_CraftSystem, this.m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);

                    if (toDelete)
                    {
                        this.m_Deed.Delete();
                    }
                }
            }
Exemple #7
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267)
                {
                    number = 1044282;                     // You must be near a forge and and anvil to repair items.
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon = (BaseWeapon)targeted;
                    SkillName  skill  = m_CraftSystem.MainSkill;

                    double repairChance = (from.Skills[skill].Value / 100);

                    double missingHitPointsScalar = ((double)weapon.MaxHitPoints - (double)weapon.HitPoints) / (double)weapon.MaxHitPoints;

                    int repairDurabilityDamage = (int)(Math.Round((missingHitPointsScalar * .1) * (double)weapon.MaxHitPoints));

                    if (repairDurabilityDamage < 1)
                    {
                        repairDurabilityDamage = 1;
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null)
                    {
                        number = 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.PoisonCharges != 0)
                    {
                        number = 1005012;                         // You cannot repair an item while a caustic substance is on it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints < 10)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (Utility.RandomDouble() <= repairChance)
                        {
                            number = 1044279; // You repair the item.

                            if (ReduceDurabilityOnSuccess(weapon))
                            {
                                weapon.MaxHitPoints -= repairDurabilityDamage;
                            }

                            weapon.HitPoints = weapon.MaxHitPoints;

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        else
                        {
                            number = 044280; // You fail to repair the item. [And the contract is destroyed]

                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }

                else if (targeted is BaseArmor)
                {
                    BaseArmor armor = (BaseArmor)targeted;
                    SkillName skill = m_CraftSystem.MainSkill;

                    double repairChance = (from.Skills[skill].Value / 100);

                    double missingHitPointsScalar = ((double)armor.MaxHitPoints - (double)armor.HitPoints) / (double)armor.MaxHitPoints;

                    int repairDurabilityDamage = (int)(Math.Round((missingHitPointsScalar * .1) * (double)armor.MaxHitPoints));

                    if (repairDurabilityDamage < 1)
                    {
                        repairDurabilityDamage = 1;
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!armor.IsChildOf(from.Backpack) && (armor.Parent != from))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints < 10)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (Utility.RandomDouble() <= repairChance)
                        {
                            number = 1044279; // You repair the item.

                            if (ReduceDurabilityOnSuccess(armor))
                            {
                                armor.MaxHitPoints -= repairDurabilityDamage;
                            }

                            armor.HitPoints = armor.MaxHitPoints;

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        else
                        {
                            number = 044280; // You fail to repair the item. [And the contract is destroyed]

                            m_CraftSystem.PlayCraftEffect(from);
                        }
                    }
                }

                /*
                 *              else if ( targeted is BaseClothing )
                 *              {
                 *                      BaseClothing clothing = (BaseClothing)targeted;
                 *                      SkillName skill = m_CraftSystem.MainSkill;
                 *                      int toWeaken = 0;
                 *
                 *                      if ( Core.AOS )
                 *                      {
                 *                              toWeaken = 1;
                 *                      }
                 *
                 *                      else if ( skill != SkillName.Tailoring )
                 *                      {
                 *                              double skillLevel = from.Skills[skill].Base;
                 *
                 *                              if ( skillLevel >= 90.0 )
                 *                                      toWeaken = 1;
                 *                              else if ( skillLevel >= 70.0 )
                 *                                      toWeaken = 2;
                 *                              else
                 *                                      toWeaken = 3;
                 *                      }
                 *
                 *                      if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !((targeted is TribalMask) || (targeted is HornedTribalMask)) )
                 *                      {
                 *                              number = 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                 *                      }
                 *
                 *                      else if ( !clothing.IsChildOf( from.Backpack ) && ( !Core.ML || clothing.Parent != from ) )
                 *                      {
                 *                              number = 1044275; // The item must be in your backpack to repair it.
                 *                      }
                 *
                 *                      else if ( clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints )
                 *                      {
                 *                              number = 1044281; // That item is in full repair
                 *                      }
                 *
                 *                      else if ( clothing.MaxHitPoints <= toWeaken )
                 *                      {
                 *                              number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                 *                      }
                 *
                 *                      else
                 *                      {
                 *                              if ( CheckWeaken( from, skill, clothing.HitPoints, clothing.MaxHitPoints ) )
                 *                              {
                 *                                      clothing.MaxHitPoints -= toWeaken;
                 *                                      clothing.HitPoints = Math.Max( 0, clothing.HitPoints - toWeaken );
                 *                              }
                 *
                 *                              if ( CheckRepairDifficulty( from, skill, clothing.HitPoints, clothing.MaxHitPoints ) )
                 *                              {
                 *                                      number = 1044279; // You repair the item.
                 *                                      m_CraftSystem.PlayCraftEffect( from );
                 *                                      clothing.HitPoints = clothing.MaxHitPoints;
                 *                              }
                 *
                 *                              else
                 *                              {
                 *                                      number = 1044280; // You fail to repair the item. [And the contract is destroyed]
                 *                                      m_CraftSystem.PlayCraftEffect( from );
                 *                              }
                 *                      }
                 *              }
                 */

                else if (targeted is Item)
                {
                    number = 1044277;                     // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }
                CraftContext context = m_CraftSystem.GetContext(from);

                from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
            }
Exemple #8
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem is DefBlacksmithy)
                {
                    bool anvil, forge;
                    DefBlacksmithy.CheckAnvilAndForge(from, 2, out anvil, out forge);

                    if (anvil && forge)
                    {
                        // You must be near a forge and and anvil to repair items.
                        number = 1044282;
                    }
                }

                if (m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426;                         // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423;                         // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153;                             // You don't have the required skills to attempt this item.
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789;                             // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number = 1044279;                                     // You repair the item.

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);

                                    if (m_Contract != null)
                                    {
                                        m_Contract.Delete();
                                    }
                                }
                                else
                                {
                                    number = 1044037;                                     // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037;                                 // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (m_Tool == null)
                        {
                            skillLevel = m_SkillLevel;
                        }

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        if (m_Contract != null)
                        {
                            // You cannot repair that item with this type of repair contract.
                            number = 1061136;
                        }
                        else
                        {
                            // You cannot repair that using this type of tool.
                            number = 1061139;
                        }
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHits <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.Hits, weapon.MaxHits))
                        {
                            weapon.MaxHits -= toWeaken;
                            weapon.Hits     = Math.Max(0, weapon.Hits - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.Hits, weapon.MaxHits))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.Hits = weapon.MaxHits;

                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                weapon.Cheater_Name = String.Format("This item repaired by GM {0}", from.Name);
                            }
                        }
                        else
                        {
                            if (m_Contract != null)
                            {
                                // You fail to repair the item and the repair contract is destroyed.
                                number = 1061137;
                            }
                            else
                            {
                                // You fail to repair the item.
                                number = 1044280;
                            }

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        if (m_Contract != null)
                        {
                            m_Contract.Delete();
                        }
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (m_Tool == null)
                        {
                            skillLevel = m_SkillLevel;
                        }

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        if (m_Contract != null)
                        {
                            // You cannot repair that item with this type of repair contract.
                            number = 1061136;
                        }
                        else
                        {
                            // You cannot repair that using this type of tool.
                            number = 1061139;
                        }
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;

                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                armor.Cheater_Name = String.Format("This item repaired by GM {0}", from.Name);
                            }
                        }
                        else
                        {
                            if (m_Contract != null)
                            {
                                // You fail to repair the item and the repair contract is destroyed.
                                number = 1061137;
                            }
                            else
                            {
                                // You fail to repair the item.
                                number = 1044280;
                            }

                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        if (m_Contract != null)
                        {
                            m_Contract.Delete();
                        }
                    }
                }
                else if (targeted is Item)
                {
                    number = 1044283;                     // You cannot repair that.

                    SkillName skill = m_CraftSystem.MainSkill;

                    double value = from.Skills[skill].Value;

                    if (targeted is BlankScroll)
                    {
                        Item contract = null;

                        if (value < 50.0)
                        {
                            // You must be at least apprentice level to create a repair service contract.
                            number = 1047005;
                        }
                        else
                        {
                            if (skill == SkillName.Blacksmith)
                            {
                                contract = new RepairContract(ContractType.Blacksmith, value, from.Name);
                            }
                            else if (skill == SkillName.Carpentry)
                            {
                                contract = new RepairContract(ContractType.Carpenter, value, from.Name);
                            }
                            else if (skill == SkillName.Fletching)
                            {
                                contract = new RepairContract(ContractType.Fletcher, value, from.Name);
                            }
                            else if (skill == SkillName.Tailoring)
                            {
                                contract = new RepairContract(ContractType.Tailor, value, from.Name);
                            }
                            else if (skill == SkillName.Tinkering)
                            {
                                contract = new RepairContract(ContractType.Tinker, value, from.Name);
                            }
                        }

                        if (contract != null)
                        {
                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                contract.Cheater_Name = String.Format("This item crafted by GM {0}", from.Name);
                            }

                            from.AddToBackpack(contract);

                            number = 1044154;                             // You create the item.

                            BlankScroll scroll = targeted as BlankScroll;

                            if (scroll.Amount >= 2)
                            {
                                scroll.Amount -= 1;
                            }
                            else
                            {
                                scroll.Delete();
                            }
                        }
                    }
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                if (m_Tool != null)
                {
                    CraftContext context = m_CraftSystem.GetContext(from);

                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);
                }
            }
        public async void CraftItem(CraftItem item)
        {
            var num = CraftSystem.CanCraft(From, Tool, item.ItemType);

            if (num > 0)
            {
                From.SendGump(new CraftGump(From, CraftSystem, Tool, num));
            }
            else if (From.NextSkillTime > Core.TickCount)
            {
                From.SendGump(new CraftGump(From, CraftSystem, Tool, 1045157)); // You must wait to perform another action.
            }
            else
            {
                Type type = null;

                CraftContext context = CraftSystem.GetContext(From);

                if (context != null)
                {
                    CraftSubResCol res      = item.UseSubRes2 ? CraftSystem.CraftSubRes2 : CraftSystem.CraftSubRes;
                    int            resIndex = item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex;

                    if (resIndex >= 0 && resIndex < res.Count)
                    {
                        type = res.GetAt(resIndex).ItemType;
                    }
                }

                var success          = false;
                var fromPrevLocation = From.Location;

                for (var i = context.CraftNumber; i >= 0; i--)
                {
                    if (i == 0)
                    {
                        From.SendAsciiMessage(89, "You finished looping.");
                        return;
                    }

                    var badCraft = CraftSystem.CanCraft(From, Tool, item.ItemType);
                    if (badCraft > 0)
                    {
                        From.SendAsciiMessage(89, "Looping aborted.");
                        return;
                    }

                    if (From.Location != fromPrevLocation)
                    {
                        From.SendAsciiMessage(89, "You moved. Looping aborted.");
                        return;
                    }

                    From.CloseGump <CraftGump>();
                    From.CloseGump <CraftGumpItem>();

                    CraftSystem.CreateItem(From, item.ItemType, type, Tool, item, ref success);

                    if (!success)
                    {
                        return;
                    }

                    From.SendAsciiMessage(89, $"Looping [{i} more to go].");

                    var loopDelay = ((int)(CraftSystem.Delay * CraftSystem.MaxCraftEffect) + (int)ZhConfig.Crafting.AutoLoop.Delay) * 1000;

                    From.NextSkillTime = Core.TickCount + loopDelay;

                    await Timer.Pause(loopDelay);
                }
            }
        }
Exemple #10
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_MakeTimer != null)
            {
                m_MakeTimer.Stop();
            }

            if (info.ButtonID <= 0)
            {
                return;                 // Canceled
            }
            int type  = info.ButtonID / 1000;
            int index = info.ButtonID % 1000;

            CraftSystem   system  = m_CraftSystem;
            CraftGroupCol groups  = system.CraftGroups;
            CraftContext  context = system.GetContext(m_From);

            switch (type)
            {
            case 0:                     // Create Item
            {
                if (context == null)
                {
                    break;
                }

                CraftItem item = system.CraftItems.GetAt(index);

                if (item != null)
                {
                    CraftItem(item);
                }

                break;
            }

            case 1:                     // Item Details && Make Last
            {
                if (context == null)
                {
                    break;
                }

                switch (index)
                {
                case 999:                                         // Make Last
                {
                    CraftItem item = context.LastMade;

                    if (item != null)
                    {
                        CraftItem(item);
                    }
                    else
                    {
                        // You haven't made anything yet.
                        m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page));
                    }

                    break;
                }

                default:                                         // Item Details
                {
                    CraftItem item = system.CraftItems.GetAt(index);

                    if (item != null)
                    {
                        m_From.SendGump(new CraftGumpItem(m_From, system, item, m_Tool));
                    }

                    break;
                }
                }

                break;
            }

            case 2:                     // Enhance Item
            {
                if (system.CanEnhance)
                {
                    Enhance.BeginTarget(m_From, system, m_Tool);
                }

                break;
            }

            case 3:                     // Toggle use resource hue
            {
                if (context == null)
                {
                    break;
                }

                context.DoNotColor = !context.DoNotColor;

                m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                break;
            }

            case 4:                     // 2nd resource selected
            {
                if (index >= 0 && index < system.CraftSubRes2.Count)
                {
                    CraftSubRes res = system.CraftSubRes2.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }

                break;
            }

            case 5:                     // Resource selected
            {
                if (index >= 0 && index < system.CraftSubRes.Count)
                {
                    CraftSubRes res = system.CraftSubRes.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }

                break;
            }

            case 6:                     // Craft system features
            {
                if (context == null)
                {
                    break;
                }

                switch (index)
                {
                case 0:                                         // Toggle mark option
                {
                    if (!system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.MarkItem:
                        context.MarkOption = CraftMarkOption.DoNotMark;
                        break;

                    case CraftMarkOption.DoNotMark:
                        context.MarkOption = CraftMarkOption.PromptForMark;
                        break;

                    case CraftMarkOption.PromptForMark:
                        context.MarkOption = CraftMarkOption.MarkItem;
                        break;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 1:                                         // Toggle mark option (KR Version)
                {
                    if (!system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.PromptForMark:
                    case CraftMarkOption.MarkItem:
                        context.MarkOption = CraftMarkOption.DoNotMark;
                        break;

                    case CraftMarkOption.DoNotMark:
                        context.MarkOption = CraftMarkOption.MarkItem;
                        break;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 2:                                         // Toggle quest item option
                {
                    context.QuestItem = !context.QuestItem;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 3:                                         // Make last
                {
                    context.MakeLast = !context.MakeLast;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 4:                                         // Reset Make number
                {
                    context.Total = 1;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 5:                                         // Make Max
                {
                    if (!context.MakeMax)
                    {
                        context.Total = 9999;
                    }
                    else
                    {
                        context.Total  = 1;
                        context.Making = null;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                default:                                         // Make number
                {
                    int amount = index - 100;
                    Utility.FixMinMax(ref amount, 1, 100);

                    context.Total = amount;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }
                }

                break;
            }

            case 7:                     // Smelt item
            {
                if (system.Resmelt)
                {
                    Resmelt.Do(m_From, system, m_Tool);
                }

                break;
            }

            case 8:                     // Repair item
            {
                if (system.Repair)
                {
                    Repair.Do(m_From, system, m_Tool);
                }

                break;
            }

            case 9:                     // Show group && Last 10
            {
                if (context == null)
                {
                    break;
                }

                switch (index)
                {
                case 0:                                         // Alter Item (Gargoyle)
                {
                    if (system.Alter)
                    {
                        Alter.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 99:                                         // Last 10
                {
                    context.LastGroupIndex = 501;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));

                    break;
                }

                default:                                         // Show group
                {
                    index--;

                    if (index >= 0 && index < groups.Count)
                    {
                        context.LastGroupIndex = index;
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }

                    break;
                }
                }

                break;
            }

            case 12:                     // Cancel Make
            {
                context.Total = 1;

                m_From.SendLocalizedMessage(501806);                                   // Request cancelled.
                m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                break;
            }
            }
        }
Exemple #11
0
            protected override void OnTick()
            {
                m_iCount++;

                m_From.DisruptiveAction();

                if (m_iCount < m_iCountMax)
                {
                    m_CraftSystem.PlayCraftEffect(m_From);
                }
                else
                {
                    m_From.EndAction(typeof(CraftSystem));

                    int badCraft = m_CraftSystem.CanCraft(m_From, m_Tool, m_CraftItem.m_Type);

                    if (badCraft > 0)
                    {
                        if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0)
                        {
                            m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, badCraft));
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(badCraft);
                        }

                        return;
                    }

                    int  quality           = 1;
                    bool allRequiredSkills = true;

                    m_CraftItem.CheckSkills(m_From, m_TypeRes, m_CraftSystem, ref quality, ref allRequiredSkills, false);

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    if (context == null)
                    {
                        return;
                    }

                    if (typeof(CustomCraft).IsAssignableFrom(m_CraftItem.ItemType))
                    {
                        CustomCraft cc = null;

                        try { cc = Activator.CreateInstance(m_CraftItem.ItemType, new object[] { m_From, m_CraftItem, m_CraftSystem, m_TypeRes, m_Tool, quality }) as CustomCraft; }
                        catch { }

                        if (cc != null)
                        {
                            cc.EndCraftAction();
                        }

                        return;
                    }

                    bool makersMark = false;

                    if (quality == 2 && m_From.Skills[m_CraftSystem.MainSkill].Base >= 100.0)
                    {
                        makersMark = m_CraftItem.IsMarkable(m_CraftItem.ItemType);
                    }

                    if (makersMark && context.MarkOption == CraftMarkOption.PromptForMark)
                    {
                        m_From.SendGump(new QueryMakersMarkGump(quality, m_From, m_CraftItem, m_CraftSystem, m_TypeRes, m_Tool));
                    }
                    else
                    {
                        if (context.MarkOption == CraftMarkOption.DoNotMark)
                        {
                            makersMark = false;
                        }

                        m_CraftItem.CompleteCraft(quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null);
                    }
                }
            }
Exemple #12
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID <= 0)
            {
                return; // Canceled
            }
            int buttonID = info.ButtonID - 1;
            int type     = buttonID % 7;
            int index    = buttonID / 7;

            CraftSystem   system  = this.m_CraftSystem;
            CraftGroupCol groups  = system.CraftGroups;
            CraftContext  context = system.GetContext(this.m_From);

            #region Stygian Abyss
            if (Locked)
            {
                if (type == 6 && index == 11)
                {
                    // Cancel Make
                    AutoCraftTimer.EndTimer(m_From);
                }
                return;
            }
            #endregion

            switch (type)
            {
            case 0:     // Show group
            {
                if (context == null)
                {
                    break;
                }

                if (index >= 0 && index < groups.Count)
                {
                    context.LastGroupIndex = index;
                    this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null));
                }

                break;
            }

            case 1:     // Create item
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        this.CraftItem(group.CraftItems.GetAt(index));
                    }
                }

                break;
            }

            case 2:     // Item details
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        this.m_From.SendGump(new CraftGumpItem(this.m_From, system, group.CraftItems.GetAt(index), this.m_Tool));
                    }
                }

                break;
            }

            case 3:     // Create item (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    this.CraftItem(lastTen[index]);
                }

                break;
            }

            case 4:     // Item details (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    this.m_From.SendGump(new CraftGumpItem(this.m_From, system, lastTen[index], this.m_Tool));
                }

                break;
            }

            case 5:     // Resource selected
            {
                if (this.m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes.GetAt(index);

                    if (this.m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null));
                    }
                }
                else if (this.m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes2.GetAt(index);

                    if (this.m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null));
                    }
                }

                break;
            }

            case 6:     // Misc. buttons
            {
                switch (index)
                {
                case 0:             // Resource selection
                {
                    if (system.CraftSubRes.Init)
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null, CraftPage.PickResource));
                    }

                    break;
                }

                case 1:             // Smelt item
                {
                    if (system.Resmelt)
                    {
                        Resmelt.Do(this.m_From, system, this.m_Tool);
                    }

                    break;
                }

                case 2:             // Make last
                {
                    if (context == null)
                    {
                        break;
                    }

                    CraftItem item = context.LastMade;

                    if (item != null)
                    {
                        this.CraftItem(item);
                    }
                    else
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, 1044165, this.m_Page));                 // You haven't made anything yet.
                    }
                    break;
                }

                case 3:             // Last 10
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.LastGroupIndex = 501;
                    this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null));

                    break;
                }

                case 4:             // Toggle use resource hue
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.DoNotColor = !context.DoNotColor;

                    this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, null, this.m_Page));

                    break;
                }

                case 5:             // Repair item
                {
                    if (system.Repair)
                    {
                        Repair.Do(this.m_From, system, this.m_Tool);
                    }

                    break;
                }

                case 6:             // Toggle mark option
                {
                    if (context == null || !system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.MarkItem:
                        context.MarkOption = CraftMarkOption.DoNotMark;
                        break;

                    case CraftMarkOption.DoNotMark:
                        context.MarkOption = CraftMarkOption.PromptForMark;
                        break;

                    case CraftMarkOption.PromptForMark:
                        context.MarkOption = CraftMarkOption.MarkItem;
                        break;
                    }

                    this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, null, this.m_Page));

                    break;
                }

                case 7:             // Resource selection 2
                {
                    if (system.CraftSubRes2.Init)
                    {
                        this.m_From.SendGump(new CraftGump(this.m_From, system, this.m_Tool, null, CraftPage.PickResource2));
                    }

                    break;
                }

                case 8:             // Enhance item
                {
                    if (system.CanEnhance)
                    {
                        Enhance.BeginTarget(this.m_From, system, this.m_Tool);
                    }

                    break;
                }

                    #region Stygian Abyss
                case 9:             // Alter Item (Gargoyle)
                {
                    if (system.CanAlter)
                    {
                        if (Server.SkillHandlers.Imbuing.CheckSoulForge(m_From, 1, false))
                        {
                            AlterItem.BeginTarget(this.m_From, system, this.m_Tool);
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(1111867);                 // You must be near a soulforge to alter an item.
                        }
                    }
                    break;
                }

                case 10:             // Quest Item/Non Quest Item toggle
                {
                    //if (context == null || !system.QuestOption)
                    //break;
                    switch (context.QuestOption)
                    {
                    case CraftQuestOption.QuestItem:
                        context.QuestOption = CraftQuestOption.NonQuestItem;
                        break;

                    case CraftQuestOption.NonQuestItem:
                        context.QuestOption = CraftQuestOption.QuestItem;
                        break;
                    }

                    this.m_From.SendGump(new CraftGump(this.m_From, this.m_CraftSystem, this.m_Tool, null, this.m_Page));

                    break;
                }

                case 11:             // Cancel Make
                {
                    AutoCraftTimer.EndTimer(m_From);
                    break;
                }
                    #endregion
                }
                break;
            }
            }
        }
Exemple #13
0
        public void AddContext(Mobile m, CraftContext c)
        {
            if (c == null || m == null || c.System != this)
                return;

            m_ContextTable[m] = c;
        }
Exemple #14
0
        private CraftGump(Mobile from, CraftSystem craftSystem, ITool tool, object notice, CraftPage page)
            : base(40, 40)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            AddPage(0);

            AddBackground(0, 0, 530, 497, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 145, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 477);

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);  // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>

            AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 445, 150, 18, 1011441, LabelColor, false, false); // EXIT

            AddButton(115, 442, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0);
            AddHtmlLocalized(150, 445, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE

            // Repair option
            if (m_CraftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM
            }
            // ****************************************

            // Mark option
            if (m_CraftSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM
            }
            // ****************************************

            // Enhance option
            if (m_CraftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM
            }
            // ****************************************

            // Alter option
            if (m_CraftSystem.CanAlter)
            {
                AddButton(270, 402, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0);
                AddHtmlLocalized(304, 405, 250, 18, 1094726, LabelColor, false, false); // ALTER ITEM (Gargoyle)
            }
            // ****************************************

            // Quest item
            AddButton(270, 422, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 425, 150, 18, context != null && context.QuestOption == CraftQuestOption.QuestItem ? 1112534 : 1112533, LabelColor, false, false); // QUEST ITEM
            // ****************************************

            AddButton(270, 442, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 445, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST

            int total = 1;
            int made  = 0;

            if (Locked && AutoCraftTimer.AutoCraftTable.ContainsKey(m_From))
            {
                AutoCraftTimer timer = AutoCraftTimer.AutoCraftTable[m_From];

                if (timer != null)
                {
                    total = timer.Amount;
                    made  = timer.Attempts;
                }
                else
                {
                    if (context != null)
                    {
                        total = context.MakeTotal;
                    }
                }
            }

            string args = string.Format("{0}\t{1}", made.ToString(), total.ToString());

            AddHtmlLocalized(270, 468, 150, 18, 1079443, args, LabelColor, false, false); //~1_DONE~/~2_TOTAL~ COMPLETED

            // Resmelt option
            if (m_CraftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM
            }
            // ****************************************

            if (notice is int note && note > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, note, LabelColor, false, false);
            }
Exemple #15
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                bool usingDeed = (m_Deed != null) || (m_Addon != null);
                bool toDelete  = false;
                int  number;

                double value = 0;

                if (m_Deed != null)
                {
                    value = m_Deed.SkillLevel;
                }
                else if (m_Addon != null)
                {
                    var tool = m_Addon.Tools.Find(x => x.System == m_CraftSystem);

                    if (tool.Charges == 0)
                    {
                        from.SendLocalizedMessage(1019073);// This item is out of charges.
                        // m_Addon.Using = false;
                        m_Addon.User = null;
                        return;
                    }

                    value = tool.SkillValue;
                }
                else
                {
                    value = from.Skills[m_CraftSystem.MainSkill].Base;
                }

                if (m_CraftSystem is DefTinkering && targeted is IRepairableMobile)
                {
                    if (TryRepairMobile(from, (IRepairableMobile)targeted, usingDeed, out toDelete))
                    {
                        number = 1044279; // You repair the item.

                        m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, (IRepairableMobile)targeted);
                    }
                    else
                    {
                        number = 500426; // You can't repair that.
                    }
                }
                else if (targeted is Item)
                {
                    if (from.InRange(((Item)targeted).GetWorldLocation(), 2))
                    {
                        if (!CheckDeed(from))
                        {
                            if (m_Addon != null)
                            {
                                // m_Addon.Using = false;
                                m_Addon.User = null;
                            }

                            return;
                        }

                        if (!AllowsRepair(targeted, m_CraftSystem))
                        {
                            from.SendLocalizedMessage(500426); // You can't repair that.

                            if (m_Addon != null)
                            {
                                // m_Addon.Using = false;
                                m_Addon.User = null;
                            }

                            return;
                        }

                        if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267)
                        {
                            number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
                        }
                        else if (!usingDeed && m_CraftSystem is DefTinkering && targeted is BrokenAutomatonHead)
                        {
                            if (((BrokenAutomatonHead)targeted).TryRepair(from))
                            {
                                number = 1044279; // You repair the item.
                            }
                            else
                            {
                                number = 1044280; // You fail to repair the item.
                            }
                        }
                        else if (targeted is BaseWeapon weapon)
                        {
                            SkillName skill    = m_CraftSystem.MainSkill;
                            int       toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = value;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !CheckSpecial(weapon))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (!Core.AOS && weapon.PoisonCharges != 0)
                            {
                                number = 1005012; // You cannot repair an item while a caustic substance is on it.
                            }
                            else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (weapon.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (weapon.NegativeAttributes.NoRepair > 0)
                            {
                                number = 1044277; // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                                {
                                    weapon.MaxHitPoints -= toWeaken;
                                    weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    weapon.HitPoints = weapon.MaxHitPoints;

                                    m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, weapon);
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (targeted is BaseArmor armor)
                        {
                            SkillName skill    = m_CraftSystem.MainSkill;
                            int       toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = value;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !CheckSpecial(armor))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!armor.IsChildOf(from.Backpack) && (!Core.ML || armor.Parent != from))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (armor.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (armor.NegativeAttributes.NoRepair > 0)
                            {
                                number = 1044277; // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                                {
                                    armor.MaxHitPoints -= toWeaken;
                                    armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    armor.HitPoints = armor.MaxHitPoints;

                                    m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, armor);
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (targeted is BaseJewel jewel)
                        {
                            SkillName skill    = m_CraftSystem.MainSkill;
                            int       toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = value;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (m_CraftSystem.CraftItems.SearchForSubclass(jewel.GetType()) == null && !CheckSpecial(jewel))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!jewel.IsChildOf(from.Backpack))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (jewel.MaxHitPoints <= 0 || jewel.HitPoints == jewel.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (jewel.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (jewel.NegativeAttributes.NoRepair > 0)
                            {
                                number = 1044277; // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, jewel.HitPoints, jewel.MaxHitPoints))
                                {
                                    jewel.MaxHitPoints -= toWeaken;
                                    jewel.HitPoints     = Math.Max(0, jewel.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, jewel.HitPoints, jewel.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    jewel.HitPoints = jewel.MaxHitPoints;

                                    m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, jewel);
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (targeted is BaseClothing clothing)
                        {
                            SkillName skill    = m_CraftSystem.MainSkill;
                            int       toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = value;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !CheckSpecial(clothing))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!clothing.IsChildOf(from.Backpack) && (!Core.ML || clothing.Parent != from))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (clothing.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278;                              // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (clothing.NegativeAttributes.NoRepair > 0) // quick fix
                            {
                                number = 1044277;                              // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                                {
                                    clothing.MaxHitPoints -= toWeaken;
                                    clothing.HitPoints     = Math.Max(0, clothing.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    clothing.HitPoints = clothing.MaxHitPoints;

                                    m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, clothing);
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (targeted is BaseTalisman talisman)
                        {
                            SkillName skill    = m_CraftSystem.MainSkill;
                            int       toWeaken = 0;

                            if (Core.AOS)
                            {
                                toWeaken = 1;
                            }
                            else if (skill != SkillName.Tailoring)
                            {
                                double skillLevel = value;

                                if (skillLevel >= 90.0)
                                {
                                    toWeaken = 1;
                                }
                                else if (skillLevel >= 70.0)
                                {
                                    toWeaken = 2;
                                }
                                else
                                {
                                    toWeaken = 3;
                                }
                            }

                            if (!(m_CraftSystem is DefTinkering))
                            {
                                number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                            }
                            else if (!talisman.IsChildOf(from.Backpack) && (!Core.ML || talisman.Parent != from))
                            {
                                number = 1044275; // The item must be in your backpack to repair it.
                            }
                            else if (talisman.MaxHitPoints <= 0 || talisman.HitPoints == talisman.MaxHitPoints)
                            {
                                number = 1044281; // That item is in full repair
                            }
                            else if (talisman.MaxHitPoints <= toWeaken)
                            {
                                number = 1044278;         // That item has been repaired many times, and will break if repairs are attempted again.
                            }
                            else if (!talisman.CanRepair) // quick fix
                            {
                                number = 1044277;         // That item cannot be repaired.
                            }
                            else
                            {
                                if (CheckWeaken(from, skill, talisman.HitPoints, talisman.MaxHitPoints))
                                {
                                    talisman.MaxHitPoints -= toWeaken;
                                    talisman.HitPoints     = Math.Max(0, talisman.HitPoints - toWeaken);
                                }

                                if (CheckRepairDifficulty(from, skill, talisman.HitPoints, talisman.MaxHitPoints))
                                {
                                    number = 1044279; // You repair the item.
                                    m_CraftSystem.PlayCraftEffect(from);
                                    talisman.HitPoints = talisman.MaxHitPoints;

                                    m_CraftSystem.OnRepair(from, m_Tool, m_Deed, m_Addon, talisman);
                                }
                                else
                                {
                                    number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                                    m_CraftSystem.PlayCraftEffect(from);
                                }

                                toDelete = true;
                            }
                        }
                        else if (targeted is BlankScroll)
                        {
                            if (!usingDeed)
                            {
                                SkillName skill = m_CraftSystem.MainSkill;

                                if (from.Skills[skill].Value >= 50.0)
                                {
                                    ((BlankScroll)targeted).Consume(1);
                                    RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from);
                                    from.AddToBackpack(deed);

                                    number = 500442; // You create the item and put it in your backpack.
                                }
                                else
                                {
                                    number = 1047005; // You must be at least apprentice level to create a repair service contract.
                                }
                            }
                            else
                            {
                                number = 1061136; // You cannot repair that item with this type of repair contract.
                            }
                        }
                        else
                        {
                            number = 500426; // You can't repair that.
                        }
                    }
                    else
                    {
                        number = 500446; // That is too far away.
                    }
                }
                else
                {
                    number = 500426; // You can't repair that.
                }

                if (!usingDeed)
                {
                    CraftContext context = m_CraftSystem.GetContext(from);
                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else
                {
                    if (m_Addon != null && !m_Addon.Deleted)
                    {
                        var tool = m_Addon.Tools.Find(x => x.System == m_CraftSystem);

                        tool.Charges--;

                        from.SendGump(new RepairBenchGump(from, m_Addon));

                        from.SendLocalizedMessage(number);
                    }
                    else
                    {
                        from.SendLocalizedMessage(number);

                        if (toDelete)
                        {
                            m_Deed.Delete();
                        }
                    }
                }
            }
Exemple #16
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (!CheckDeed(from))
                {
                    return;
                }


                bool usingDeed = (m_Deed != null);
                bool toDelete  = false;

                //TODO: Make a IRepairable

                if (m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426; // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423; // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = (usingDeed) ? m_Deed.SkillLevel : from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153; // You don't have the required skills to attempt this item.	//TODO: How does OSI handle this with deeds with golems?
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789; // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number   = 1044279; // You repair the item.
                                    toDelete = true;

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);
                                }
                                else
                                {
                                    number = 1044037; // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037; // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)targeted;
                    SkillName    skill    = m_CraftSystem.MainSkill;
                    int          toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null)
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!clothing.IsChildOf(from.Backpack))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (clothing.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            clothing.MaxHitPoints -= (short)toWeaken;
                            clothing.HitPoints     = (short)Math.Max(0, clothing.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            clothing.HitPoints = clothing.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }

                /*else if (!usingDeed && targeted is BlankScroll)
                 * {
                 *  SkillName skill = m_CraftSystem.MainSkill;
                 *
                 *  if (from.Skills[skill].Value >= 50.0)
                 *  {
                 *      ((BlankScroll)targeted).Consume(1);
                 *      RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from);
                 *      from.AddToBackpack(deed);
                 *
                 *      number = 500442; // You create the item and put it in your backpack.
                 *  }
                 *  else
                 *      number = 1047005; // You must be at least apprentice level to create a repair service contract.
                 * }*/
                else if (targeted is Item)
                {
                    number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426; // You can't repair that.
                }

                if (!usingDeed)
                {
                    CraftContext context = m_CraftSystem.GetContext(from);
                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else if (toDelete)
                {
                    m_Deed.Delete();
                }
            }
Exemple #17
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426;                         // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423;                         // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153;                             // You don't have the required skills to attempt this item.
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789;                             // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number = 1044279;                                     // You repair the item.

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);
                                }
                                else
                                {
                                    number = 1044037;                                     // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037;                                 // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.MaxHits <= 0 || weapon.Hits == weapon.MaxHits)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHits <= toWeaken)
                    {
                        number = 500424;                         // You destroyed the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        weapon.Delete();
                    }
                    else if (from.CheckSkill(skill, -285.0, 100.0))
                    {
                        number = 1044279;                         // You repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        weapon.MaxHits -= toWeaken;
                        weapon.Hits     = weapon.MaxHits;
                    }
                    else
                    {
                        number = 1044280;                         // You fail to repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        weapon.MaxHits -= toWeaken;

                        if (weapon.Hits - toWeaken < 0)
                        {
                            weapon.Hits = 0;
                        }
                        else
                        {
                            weapon.Hits -= toWeaken;
                        }
                    }

                    if (weapon.MaxHits <= toWeaken)
                    {
                        from.SendLocalizedMessage(1044278);                           // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !IsSpecialArmor(armor))
                    {
                        number = 1044277;                         // That item cannot be repaired.
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 500424;                         // You destroyed the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        armor.Delete();
                    }
                    else if (from.CheckSkill(skill, -285.0, 100.0))
                    {
                        number = 1044279;                         // You repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        armor.MaxHitPoints -= toWeaken;
                        armor.HitPoints     = armor.MaxHitPoints;
                    }
                    else
                    {
                        number = 1044280;                         // You fail to repair the item.
                        m_CraftSystem.PlayCraftEffect(from);
                        armor.MaxHitPoints -= toWeaken;

                        if (armor.HitPoints - toWeaken < 0)
                        {
                            armor.HitPoints = 0;
                        }
                        else
                        {
                            armor.HitPoints -= toWeaken;
                        }
                    }

                    if (armor.MaxHitPoints <= toWeaken)
                    {
                        from.SendLocalizedMessage(1044278);                           // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                }
                else if (targeted is Item)
                {
                    SkillName skill = m_CraftSystem.MainSkill;
                    if (targeted is BlankScroll)
                    {
                        if (skill == SkillName.Blacksmith && from.Skills[SkillName.Blacksmith].Value >= 55.0)
                        {
                            BlackSmithRepair r1 = new BlackSmithRepair();
                            r1.SkillLevel = from.Skills[SkillName.Blacksmith].Value;
                            r1.Maker      = from.Name;
                            r1.Uses       = 8;
                            from.AddToBackpack(r1);
                            number = 1044154;
                            BlankScroll i_blank = targeted as BlankScroll;
                            if (i_blank.Amount >= 2)
                            {
                                i_blank.Amount -= 1;
                            }
                            else
                            {
                                i_blank.Delete();
                            }
                        }
                        else if (skill == SkillName.Tailoring && from.Skills[SkillName.Tailoring].Value >= 55.0)
                        {
                            TailorRepair r1 = new TailorRepair();
                            r1.SkillLevel = from.Skills[SkillName.Tailoring].Value;
                            r1.Maker      = from.Name;
                            r1.Uses       = 8;
                            from.AddToBackpack(r1);
                            number = 1044154;
                            BlankScroll i_blank = targeted as BlankScroll;
                            if (i_blank.Amount >= 2)
                            {
                                i_blank.Amount -= 1;
                            }
                            else
                            {
                                i_blank.Delete();
                            }
                        }
                        else
                        {
                            number = 1044277;                     // That item cannot be repaired.
                        }
                    }
                    else
                    {
                        number = 1044277;                 // That item cannot be repaired.
                    }
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                CraftContext context = m_CraftSystem.GetContext(from);

                from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
            }
Exemple #18
0
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page)
            : base(40, 40)
        {
            this.m_From        = from;
            this.m_CraftSystem = craftSystem;
            this.m_Tool        = tool;
            this.m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            this.AddPage(0);

            this.AddBackground(0, 0, 550, 587, 5054);
            this.AddImageTiled(10, 10, 530, 22, 2624);   //Section for Gump Heading
            this.AddImageTiled(10, 375, 132, 45, 2624);  //Section for Notices
            this.AddImageTiled(146, 375, 395, 45, 2624); //Section across from Notices
            this.AddImageTiled(10, 422, 530, 155, 2624); //Section where Exit is
            this.AddImageTiled(10, 37, 200, 335, 2624);  //Section for Categories
            this.AddImageTiled(215, 37, 325, 335, 2624); //Section for Sublisted Items
            this.AddAlphaRegion(10, 10, 530, 567);

            if (craftSystem.GumpTitleNumber > 0)
            {
                this.AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                this.AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            this.AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);  // <CENTER>CATEGORIES</CENTER>
            this.AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER>
            this.AddHtmlLocalized(10, 385, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>

            this.AddButton(15, 542, 4017, 4019, 0, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(50, 545, 150, 18, 1011441, LabelColor, false, false); // EXIT

            this.AddButton(270, 542, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(305, 545, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST

            this.AddButton(270, 502, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0);
            this.AddLabel(304, 505, 1152, @"ALTER ITEM (GARGOYLE)");

            this.AddButton(270, 522, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(305, 525, 150, 18, 1112533 + (context == null ? 0 : (int)context.QuestOption), LabelColor, false, false); // QUEST ITEM

            this.AddButton(115, 542, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(150, 545, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE

            // Mark option
            if (craftSystem.MarkOption)
            {
                this.AddButton(270, 462, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                this.AddHtmlLocalized(305, 465, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                this.AddButton(15, 442, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                this.AddHtmlLocalized(50, 445, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
                this.AddButton(270, 442, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                this.AddHtmlLocalized(305, 445, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM
            }
            // ****************************************

            // Enhance option
            if (craftSystem.CanEnhance)
            {
                this.AddButton(270, 482, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                this.AddHtmlLocalized(305, 485, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                this.AddHtmlLocalized(170, 377, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                this.AddHtml(170, 377, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                Type resourceType = craftSystem.CraftSubRes.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                    //daat99 OWLTR start - craft from storage
                    ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, resourceType);
                    if (storageCount > 0)
                    {
                        if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue)
                        {
                            resourceCount += (int)storageCount;
                        }
                        else
                        {
                            resourceCount = int.MaxValue;
                        }
                    }
                    //daat99 OWLTR end - craft from storage
                }

                this.AddButton(15, 462, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    this.AddHtmlLocalized(50, 465, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    this.AddLabel(50, 465, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                Type resourceType = craftSystem.CraftSubRes2.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                    //daat99 OWLTR start - craft from storage
                    ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, resourceType);
                    if (storageCount > 0)
                    {
                        if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue)
                        {
                            resourceCount += (int)storageCount;
                        }
                        else
                        {
                            resourceCount = int.MaxValue;
                        }
                    }
                    //daat99 OWLTR end - craft from storage
                }

                this.AddButton(15, 482, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    this.AddHtmlLocalized(50, 485, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    this.AddLabel(50, 485, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            this.CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                this.CreateResList(false, from);
            }
            else if (page == CraftPage.PickResource2)
            {
                this.CreateResList(true, from);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                this.CreateItemList(context.LastGroupIndex);
            }
        }
Exemple #19
0
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = (opt ? this.m_CraftSystem.CraftSubRes2 : this.m_CraftSystem.CraftSubRes);
            //daat99 OWLTR start - recipe craft
            bool b_RecipeCraft  = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.RECIPE_CRAFT),
                 b_Blacksmithy  = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.BLACKSMITH_RECIPES),
                 b_BowFletching = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.BOWFLETCH_RECIPES),
                 b_Carpentry    = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.CARPENTRY_RECIPES),
                 b_Masonry      = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.MASONRY_RECIPES),
                 b_Tailoring    = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.TAILORING_RECIPES),
                 b_Tinkering    = OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.TINKERING_RECIPES);

            if (b_RecipeCraft)
            {
                NewDaat99Holder dh       = (NewDaat99Holder)daat99.Daat99OWLTR.TempHolders[m_From];
                int             i_Lenght = 0;
                for (int i = 0; i < res.Count; ++i)
                {
                    int index = i_Lenght % 10;

                    CraftSubRes subResource = res.GetAt(i);
                    if (!dh.Resources.Contains(CraftResources.GetFromType(subResource.ItemType)) || (!b_Blacksmithy && m_CraftSystem is DefBlacksmithy) ||
                        (!b_BowFletching && m_CraftSystem is DefBowFletching) || (!b_Carpentry && m_CraftSystem is DefCarpentry) ||
                        (!b_Masonry && m_CraftSystem is DefMasonry) || (!b_Tailoring && m_CraftSystem is DefTailoring) ||
                        (!b_Tinkering && m_CraftSystem is DefTinkering))
                    {
                        if (index == 0)
                        {
                            if (i > 0)
                            {
                                AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                            }

                            AddPage((i / 10) + 1);

                            if (i > 0)
                            {
                                AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                            }

                            CraftContext context = m_CraftSystem.GetContext(m_From);

                            AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                            AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                        }

                        AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                        if (subResource.NameNumber > 0)
                        {
                            AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, LabelColor, false, false);
                        }
                        else
                        {
                            AddLabel(255, 60 + (index * 20), LabelHue, subResource.NameString);
                        }
                        i_Lenght++;
                    }
                }
            }
            else
            {
                //daat99 OWLTR end - recipe craft
                for (int i = 0; i < res.Count; ++i)
                {
                    int index = i % 10;

                    CraftSubRes subResource = res.GetAt(i);

                    if (index == 0)
                    {
                        if (i > 0)
                        {
                            this.AddButton(485, 290, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                        }

                        this.AddPage((i / 10) + 1);

                        if (i > 0)
                        {
                            this.AddButton(455, 290, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                        }

                        CraftContext context = this.m_CraftSystem.GetContext(this.m_From);

                        this.AddButton(220, 290, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                        this.AddHtmlLocalized(255, 293, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                    }

                    int resourceCount = 0;

                    if (from.Backpack != null)
                    {
                        Item[] items = from.Backpack.FindItemsByType(subResource.ItemType, true);

                        for (int j = 0; j < items.Length; ++j)
                        {
                            resourceCount += items[j].Amount;
                        }
                        //daat99 OWLTR start - craft from storage
                        ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, subResource.ItemType);
                        if (storageCount > 0)
                        {
                            if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue)
                            {
                                resourceCount += (int)storageCount;
                            }
                            else
                            {
                                resourceCount = int.MaxValue;
                            }
                        }
                        //daat99 OWLTR end - craft from storage
                    }

                    this.AddButton(220, 70 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                    if (subResource.NameNumber > 0)
                    {
                        this.AddHtmlLocalized(255, 73 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
                    }
                    else
                    {
                        this.AddLabel(255, 70 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount));
                    }
                }
            }
        }
Exemple #20
0
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page)
            : base(40, 40)
        {
            this.m_From        = from;
            this.m_CraftSystem = craftSystem;
            this.m_Tool        = tool;
            this.m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            this.AddPage(0);

            AddBackground(0, 0, 530, 497, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 145, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 477);

            if (craftSystem.GumpTitleNumber > 0)
            {
                this.AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                this.AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);  // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>

            this.AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(50, 445, 150, 18, 1011441, LabelColor, false, false); // EXIT

            this.AddButton(115, 442, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(150, 445, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE

            // Repair option
            if (m_CraftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM
            }
            // ****************************************

            // Mark option
            if (m_CraftSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM
            }
            // ****************************************

            // Enhance option
            if (m_CraftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM
            }
            // ****************************************

            #region SA
            // Alter option
            if (Core.SA && m_CraftSystem.CanAlter)
            {
                AddButton(270, 402, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0);
                AddHtmlLocalized(304, 405, 250, 18, 1094726, LabelColor, false, false); // ALTER ITEM (Gargoyle)
            }
            // ****************************************

            // Quest item
            if (Core.SA)
            {
                AddButton(270, 422, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 425, 150, 18, context != null && context.QuestOption == CraftQuestOption.QuestItem ? 1112534 : 1112533, LabelColor, false, false); // QUEST ITEM
            }
            // ****************************************
            #endregion

            AddButton(270, 442, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 445, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST

            #region Stygian Abyss
            int total = 1;
            int made  = 0;

            if (Locked && AutoCraftTimer.AutoCraftTable.ContainsKey(m_From))
            {
                AutoCraftTimer timer = AutoCraftTimer.AutoCraftTable[m_From];

                if (timer != null)
                {
                    total = timer.Amount;
                    made  = timer.Attempts;
                }
                else
                {
                    if (context != null)
                    {
                        total = context.MakeTotal;
                    }
                }
            }

            string args = String.Format("{0}\t{1}", made.ToString(), total.ToString());

            AddHtmlLocalized(270, 468, 150, 18, 1079443, args, LabelColor, false, false); //~1_DONE~/~2_TOTAL~ COMPLETED
            #endregion

            // Resmelt option
            if (m_CraftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                this.AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                this.AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                Type resourceType = craftSystem.CraftSubRes.ResType;
                //Type resourceType2 = GetAltType(resourceType);

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                    //daat99 OWLTR start - craft from storage
                    ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, resourceType);
                    if (storageCount > 0)
                    {
                        if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue)
                        {
                            resourceCount += (int)storageCount;
                        }
                        else
                        {
                            resourceCount = int.MaxValue;
                        }
                    }
                    //daat99 OWLTR end - craft from storage
                }

                this.AddButton(15, 382, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    if (context.DoNotColor)
                    {
                        AddLabel(50, 385, LabelHue, "*");
                    }

                    AddHtmlLocalized(50 + (context.DoNotColor ? 13 : 0), 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 382, LabelHue, (context.DoNotColor ? "*" : "") + String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                Type resourceType = craftSystem.CraftSubRes2.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                    //daat99 OWLTR start - craft from storage
                    ulong storageCount = MasterStorageUtils.GetPlayersStorageItemCount(from as Mobiles.PlayerMobile, resourceType);
                    if (storageCount > 0)
                    {
                        if (storageCount < int.MaxValue && storageCount + (ulong)resourceCount < int.MaxValue)
                        {
                            resourceCount += (int)storageCount;
                        }
                        else
                        {
                            resourceCount = int.MaxValue;
                        }
                    }
                    //daat99 OWLTR end - craft from storage
                }

                this.AddButton(15, 402, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 405, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 405, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            this.CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                this.CreateResList(false, from);
            }
            else if (page == CraftPage.PickResource2)
            {
                this.CreateResList(true, from);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                this.CreateItemList(context.LastGroupIndex);
            }
        }
Exemple #21
0
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = (opt ? this.m_CraftSystem.CraftSubRes2 : this.m_CraftSystem.CraftSubRes);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        this.AddButton(485, 290, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                    }

                    this.AddPage((i / 10) + 1);

                    if (i > 0)
                    {
                        this.AddButton(455, 290, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    CraftContext context = this.m_CraftSystem.GetContext(this.m_From);

                    this.AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                    this.AddHtmlLocalized(255, 260, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(subResource.ItemType, true);

                    for (int j = 0; j < items.Length; ++j)
                    {
                        resourceCount += items[j].Amount;
                    }

                    Type alt = GetAltType(subResource.ItemType);

                    if (alt != null)
                    {
                        Item[] items2 = m_From.Backpack.FindItemsByType(alt, true);

                        for (int j = 0; j < items2.Length; ++j)
                        {
                            resourceCount += items2[j].Amount;
                        }
                    }
                }

                this.AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (subResource.NameNumber > 0)
                {
                    this.AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    this.AddLabel(255, 60 + (index * 20), LabelHue, String.Format("{0} ({1})", subResource.NameString, resourceCount));
                }
            }
        }
Exemple #22
0
        public void Craft(Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool)
        {
            if (from.BeginAction(typeof(CraftSystem)))
            {
                if (RequiredExpansion == Expansion.None || (from.NetState != null && from.NetState.SupportsExpansion(RequiredExpansion)))
                {
                    bool   allRequiredSkills = true;
                    double chance            = GetSuccessChance(from, typeRes, craftSystem, false, ref allRequiredSkills);

                    if (allRequiredSkills && chance >= 0.0)
                    {
                        if (this.Recipe == null || !(from is PlayerMobile) || ((PlayerMobile)from).HasRecipe(this.Recipe))
                        {
                            int badCraft = craftSystem.CanCraft(from, tool, m_Type);

                            if (badCraft <= 0)
                            {
                                int    resHue    = 0;
                                int    maxAmount = 0;
                                object message   = null;

                                if (ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message))
                                {
                                    message = null;

                                    if (ConsumeAttributes(from, ref message, false))
                                    {
                                        CraftContext context = craftSystem.GetContext(from);

                                        if (context != null)
                                        {
                                            context.OnMade(this);
                                        }

                                        int iMin    = craftSystem.MinCraftEffect;
                                        int iMax    = (craftSystem.MaxCraftEffect - iMin) + 1;
                                        int iRandom = Utility.Random(iMax);
                                        iRandom += iMin + 1;
                                        new InternalTimer(from, craftSystem, this, typeRes, tool, iRandom).Start();
                                    }
                                    else
                                    {
                                        from.EndAction(typeof(CraftSystem));
                                        from.SendGump(new CraftGump(from, craftSystem, tool, message));
                                    }
                                }
                                else
                                {
                                    from.EndAction(typeof(CraftSystem));
                                    from.SendGump(new CraftGump(from, craftSystem, tool, message));
                                }
                            }
                            else
                            {
                                from.EndAction(typeof(CraftSystem));
                                from.SendGump(new CraftGump(from, craftSystem, tool, badCraft));
                            }
                        }
                        else
                        {
                            from.EndAction(typeof(CraftSystem));
                            from.SendGump(new CraftGump(from, craftSystem, tool, 1072847)); // You must learn that recipe from a scroll.
                        }
                    }
                    else
                    {
                        from.EndAction(typeof(CraftSystem));
                        from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); // You don't have the required skills to attempt this item.
                    }
                }
                else
                {
                    from.EndAction(typeof(CraftSystem));
                    from.SendGump(new CraftGump(from, craftSystem, tool, RequiredExpansionMessage(RequiredExpansion))); //The {0} expansion is required to attempt this item.
                }
            }
            else
            {
                from.SendLocalizedMessage(500119); // You must wait to perform another action
            }
        }
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            AddPage(0);

            AddBackground(0, 0, 530, 437, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 85, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 417);

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);               // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false);              // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false);              // <CENTER>NOTICES</CENTER>

            AddButton(15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor, false, false);               // EXIT

//MODDED FROM this to	AddButton( 270, 402, 4005, 4007, GetButtonID( 6, 2 ), GumpButtonType.Reply, 0 );
//MODDED FROM this to	AddHtmlLocalized( 305, 405, 150, 18, 1044013, LabelColor, false, false ); // MAKE LAST
            AddButton(170, 402, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(205, 405, 150, 18, 1044013, LabelColor, false, false);               // MAKE LAST
//I ADDED
            bool autoloop = false;

            if (context != null && context.AutoLoop)
            {
                autoloop = true;
            }
            AddButton(320, 342, autoloop ? 209 : 208, autoloop ? 208 : 209, GetButtonID(6, 11), GumpButtonType.Reply, 0);
            AddHtml(355, 345, 150, 18, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, "Auto Loop"), false, false);
            AddHtml(320, 370, 150, 18, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, "Make Count"), false, false);
            int count = 0;

            if (context != null && context.TotalCount > 0)
            {
                count = context.TotalCount;
            }
//			AddImageTiled(415, 371, 50, 20, 2524);//bage
            AddImageTiled(414, 370, 52, 22, 2624);            //black
            AddTextEntry(415, 371, 50, 20, 1152, 100, count > 0 ? count.ToString():"");
//original
//			AddImageTiled(414, 370, 52, 22, 2624);//black
//			AddImageTiled(415, 371, 50, 20, 2524);//bage
//
//			AddTextEntry(415, 371, 50, 20, 261, 100, count>0 ? count.ToString():"");
//original
//I ADDED

            // Mark option
            if (craftSystem.MarkOption)
            {
//Moded from this to				AddButton( 270, 362, 4005, 4007, GetButtonID( 6, 6 ), GumpButtonType.Reply, 0 );
//Moded from this to				AddHtmlLocalized( 305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false ); // MARK ITEM
                AddButton(170, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(205, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false);                   // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false);                   // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
//Modded this from to				AddButton( 270, 342, 4005, 4007, GetButtonID( 6, 5 ), GumpButtonType.Reply, 0 );
//Modded this from to				AddHtmlLocalized( 305, 345, 150, 18, 1044260, LabelColor, false, false ); // REPAIR ITEM
                AddButton(170, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(205, 345, 150, 18, 1044260, LabelColor, false, false);                   // REPAIR ITEM
            }
            // ****************************************

            // Enhance option
            if (craftSystem.CanEnhance)
            {
//Modded this from to				AddButton( 270, 382, 4005, 4007, GetButtonID( 6, 8 ), GumpButtonType.Reply, 0 );
//Modded this from to				AddHtmlLocalized( 305, 385, 150, 18, 1061001, LabelColor, false, false ); // ENHANCE ITEM
                AddButton(170, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(205, 385, 150, 18, 1061001, LabelColor, false, false);                   // ENHANCE ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                Type resourceType = craftSystem.CraftSubRes.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 362, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                Type resourceType = craftSystem.CraftSubRes2.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 385, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                CreateResList(false, from);
            }
            else if (page == CraftPage.PickResource2)
            {
                CreateResList(true, from);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                CreateItemList(context.LastGroupIndex);
            }
        }
Exemple #24
0
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page)
            : base(50, 50)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump <CraftGump>();
            from.CloseGump <CraftGumpItem>();

            AddPage((int)CraftPage.None);

            AddBackground(0, 0, 530, 497, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 145, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 497);

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, FontColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 302, 150, 25, 1044012, FontColor, false, false);               // <CENTER>NOTICES</CENTER>

            AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 445, 150, 18, 1011441, FontColor, false, false);               // EXIT

            AddButton(270, 442, 4005, 4007, 1999, GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 445, 150, 18, 1044013, FontColor, false, false);               // MAKE LAST

            AddButton(115, 442, 4017, 4019, 12000, GumpButtonType.Reply, 0);
            AddHtmlLocalized(150, 445, 150, 18, 1112698, FontColor, false, false);               // CANCEL MAKE

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, 7000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, FontColor, false, false);                   // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, 8000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, FontColor, false, false);                   // REPAIR ITEM
            }
            // ****************************************

            // Alter option
            if (craftSystem.Alter)
            {
                AddButton(270, 402, 4005, 4007, 9000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 405, 300, 18, 1094726, FontColor, false, false);                   // ALTER ITEM (GARGOYLE)
            }
            // ****************************************

            AddHtmlLocalized(10, 37, 200, 22, 1044010, FontColor, false, false);               // <CENTER>CATEGORIES</CENTER>

            CreateGroupList();

            if (craftSystem.CraftSubRes.Init)
            {
                CreateResList(false);
            }

            if (craftSystem.CraftSubRes2.Init)
            {
                CreateResList(true);
            }

            AddPage(0);

            // Enhance option
            if (craftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, 2000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, FontColor, false, false);                   // ENHANCE ITEM
            }
            // ****************************************

            if (craftSystem.CraftSubRes2.Init)
            {
                AddButton(15, 382, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 10);
            }

            if (craftSystem.CraftSubRes.Init)
            {
                AddButton(15, 362, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 9);
            }

            if (context != null && context.LastGroupIndex > -1)
            {
                CreateItemList(context.LastGroupIndex);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                AddPage(0);

                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;
                int    amount;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString = subResource.NameString;
                    nameNumber = subResource.NameNumber;
                    amount     = GetAmount(subResource.ItemType);
                }
                else
                {
                    amount = GetAmount(craftSystem.CraftSubRes.ResType);
                }

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 365, 170, 18, nameNumber, amount.ToString(), LabelColor, false, false);
                    AddKRHtmlLocalized(50, 365, 170, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 362, LabelHue, nameString);
                }

                AddPage(9);

                AddButton(220, 260, 4005, 4007, 3000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                AddPage(0);

                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;
                int    amount;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString = subResource.NameString;
                    nameNumber = subResource.NameNumber;
                    amount     = GetAmount(subResource.ItemType);
                }
                else
                {
                    amount = GetAmount(craftSystem.CraftSubRes2.ResType);
                }

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 385, 150, 18, nameNumber, amount.ToString(), LabelColor, false, false);
                    AddKRHtmlLocalized(50, 385, 150, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 385, LabelHue, nameString);
                }

                AddPage(10);

                AddButton(220, 260, 4005, 4007, 3001, GumpButtonType.Reply, 0);
                AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
            }
            // ****************************************

            // Notice
            if (notice is int && (int)notice > 0)
            {
                AddPage(0);
                AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                AddPage(0);
                AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }
            // ****************************************

            // Mark option
            if (craftSystem.MarkOption)
            {
                AddPage(0);

                AddButton(270, 362, 4005, 4007, 6000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false);                      // MARK ITEM

                if (context != null && context.MarkOption == CraftMarkOption.MarkItem)
                {
                    AddKRButton(0, 0, 0, 0, 6001, GumpButtonType.Page, 0);
                }
            }
            // ****************************************

            // Quest Item option
            bool questItem = (context != null && context.QuestItem);

            AddPage(0);

            AddButton(270, 422, 0xFA5, 0xFA7, 6002, GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 425, 150, 18, questItem ? 1112534 : 1112533, LabelColor, false, false);
            // ****************************************

            if (context != null)
            {
                if (context.MakeLast)
                {
                    AddKRButton(0, 0, 0, 0, 6003, GumpButtonType.Page, 0);
                }

                if (context.MakeNumber)
                {
                    AddKRButton(0, 0, 0, 0, context.Total + 6100, GumpButtonType.Page, 0);
                }

                if (context.MakeMax)
                {
                    AddKRButton(0, 0, 0, 0, 6005, GumpButtonType.Page, 0);
                }
            }

            if (context != null)
            {
                if (context.Success)
                {
                    context.Done++;
                }

                int done = 0, total = 1;

                done  = context.Done;
                total = context.Total;

                AddHtmlLocalized(270, 465, 200, 18, 1079443, String.Format("{0}@{1}", done, total), FontColor, false, false);                     // ~1_DONE~/~2_TOTAL~ COMPLETED

                if (context.Making != null && context.Success)
                {
                    m_MakeTimer = Timer.DelayCall(TimeSpan.FromSeconds(1.25), new TimerCallback(DoMake));
                }

                context.Success = false;
            }
        }
Exemple #25
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID <= 0)
            {
                return;                 // Canceled
            }
            int buttonID = info.ButtonID - 1;
            int type     = buttonID % 7;
            int index    = buttonID / 7;

            CraftSystem   system  = m_CraftSystem;
            CraftGroupCol groups  = system.CraftGroups;
            CraftContext  context = system.GetContext(m_From);

            switch (type)
            {
            case 0:                     // Show group
            {
                if (context == null)
                {
                    break;
                }

                if (index >= 0 && index < groups.Count)
                {
                    context.LastGroupIndex = index;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                }

                break;
            }

            case 1:                     // Create item
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        CraftItem(group.CraftItems.GetAt(index));
                    }
                }

                break;
            }

            case 2:                     // Item details
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool));
                    }
                }

                break;
            }

            case 3:                     // Create item (last 10)
            {
                if (context == null)
                {
                    break;
                }

                ArrayList lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    CraftItem((CraftItem)lastTen[index]);
                }

                break;
            }

            case 4:                     // Item details (last 10)
            {
                if (context == null)
                {
                    break;
                }

                ArrayList lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    m_From.SendGump(new CraftGumpItem(m_From, system, (CraftItem)lastTen[index], m_Tool));
                }

                break;
            }

            case 5:                     // Resource selected
            {
                if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }
                else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes2.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }

                break;
            }

            case 6:                     // Misc. buttons
            {
                switch (index)
                {
                case 0:                                         // Resource selection
                {
                    if (system.CraftSubRes.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource));
                    }

                    break;
                }

                case 1:                                         // Smelt item
                {
                    if (system.Resmelt)
                    {
                        Resmelt.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 2:                                         // Make last
                {
                    if (context == null)
                    {
                        break;
                    }

                    CraftItem item = context.LastMade;

                    if (item != null)
                    {
                        CraftItem(item);
                    }
                    else
                    {
                        m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page));                                                         // You haven't made anything yet.
                    }
                    break;
                }

                case 3:                                         // Last 10
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.LastGroupIndex = 501;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));

                    break;
                }

                case 4:                                         // Toggle use resource hue
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.DoNotColor = !context.DoNotColor;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 5:                                         // Repair item
                {
                    if (system.Repair)
                    {
                        Repair.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 6:                                         // Toggle mark option
                {
                    if (context == null || !system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break;

                    case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break;

                    case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 7:                                         // Resource selection 2
                {
                    if (system.CraftSubRes2.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2));
                    }

                    break;
                }

                case 8:                                         // Enhance item
                {
                    if (system.CanEnhance)
                    {
                        Enhance.BeginTarget(m_From, system, m_Tool);
                    }

                    break;
                }
                }

                break;
            }
            }
        }
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40,
                                                                                                                     40)
        {
            From        = from;
            CraftSystem = craftSystem;
            Tool        = tool;
            m_Page      = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump <CraftGump>();
            from.CloseGump <CraftGumpItem>();

            AddPage(0);

            AddBackground(0, 0, 530, 487, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 150, 45, 2624);
            AddImageTiled(165, 342, 355, 45, 2624);
            AddImageTiled(10, 392, 510, 85, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 467);

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);  // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER>
            AddHtml(10, 302, 150, 25, "<BASEFONT COLOR=#FFFFFF><CENTER>MAKE AMOUNT</CENTER></BASEFONT>", false,
                    false);
            AddHtmlLocalized(10, 352, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>

            AddButton(15, 452, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 455, 150, 18, 1011441, LabelColor, false, false); // EXIT

            AddButton(320, 452, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(355, 455, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST

            // Mark option
            if (craftSystem.MarkOption)
            {
                AddButton(320, 412, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(355, 415, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption),
                                 LabelColor, false, false); // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                AddButton(15, 392, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 395, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
                AddButton(320, 392, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(355, 395, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM
            }
            // ****************************************

            // Fortify option
            if (craftSystem.Fortify)
            {
                AddButton(320, 432, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtml(355, 435, 150, 18, "<BASEFONT COLOR=#FFFFFF>FORTIFY ITEM</BASEFONT>", false,
                        false); // FORTIFY ITEM
            }
            // ****************************************

            // Make amount
            AddImage(180, 302, 2443);
            AddTextEntry(190, 304, 30, 18, LabelHue, 0, context.CraftNumber.ToString());
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                AddHtmlLocalized(170, 345, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                AddHtml(170, 345, 350, 40, $"<BASEFONT COLOR=#{FontColor:X6}>{notice}</BASEFONT>", false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = context == null ? -1 : context.LastResourceIndex;

                Type resourceType = craftSystem.CraftSubRes.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                AddButton(15, 412, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 415, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 412, LabelHue, $"{nameString} ({resourceCount} Available)");
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = context == null ? -1 : context.LastResourceIndex2;

                Type resourceType = craftSystem.CraftSubRes2.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                AddButton(15, 432, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 435, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 435, LabelHue, $"{nameString} ({resourceCount} Available)");
                }
            }
            // ****************************************

            CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                CreateResList(false, from);
            }
            else if (page == CraftPage.PickResource2)
            {
                CreateResList(true, from);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                CreateItemList(context.LastGroupIndex);
            }
        }
        public void DrawResource()
        {
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool cropScroll = (m_CraftItem.Resources.Count > 1) &&
                              m_CraftItem.Resources.GetAt(m_CraftItem.Resources.Count - 1).ItemType == typeofBlankScroll &&
                              typeofSpellScroll.IsAssignableFrom(m_CraftItem.ItemType);

            for (int i = 0; i < m_CraftItem.Resources.Count - (cropScroll ? 1 : 0) && i < 4; i++)
            {
                Type   type;
                string nameString;
                int    nameNumber;

                CraftRes craftResource = m_CraftItem.Resources.GetAt(i);

                type       = craftResource.ItemType;
                nameString = craftResource.NameString;
                nameNumber = craftResource.NameNumber;

                // Resource Mutation
                if (type == res.ResType && resIndex > -1)
                {
                    CraftSubRes subResource = res.GetAt(resIndex);

                    type = subResource.ItemType;

                    nameString = subResource.NameString;
                    nameNumber = subResource.GenericNameNumber;

                    if (nameNumber <= 0)
                    {
                        nameNumber = subResource.NameNumber;
                    }
                }
                // ******************

                if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, type))
                {
                    retainedColor = true;
                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1044152, LabelColor, false, false);                        // * The item retains the color of this material
                    AddLabel(500, 219 + (i * 20), LabelHue, "*");
                }

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(170, 219 + (i * 20), LabelHue, nameString);
                }

                AddLabel(430, 219 + (i * 20), LabelHue, craftResource.Amount.ToString());
            }

            if (m_CraftItem.NameNumber == 1041267)               // runebook
            {
                AddHtmlLocalized(170, 219 + (m_CraftItem.Resources.Count * 20), 310, 18, 1044447, LabelColor, false, false);
                AddLabel(430, 219 + (m_CraftItem.Resources.Count * 20), LabelHue, "1");
            }

            if (cropScroll)
            {
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044379, LabelColor, false, false);                    // Inscribing scrolls also requires a blank scroll and mana.
            }
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID <= 0)
            {
                return;                 // Canceled
            }
            int buttonID = info.ButtonID - 1;
            int type     = buttonID % 7;
            int index    = buttonID / 7;

            CraftSystem   system  = m_CraftSystem;
            CraftGroupCol groups  = system.CraftGroups;
            CraftContext  context = system.GetContext(m_From);

//I ADDED
            if (context != null)
            {
                context.Count      = 0;
                context.TotalCount = 0;
                TextRelay text = info.GetTextEntry(100);
                if (text.Text != null)
                {
                    string   keywordstring = text.Text;
                    string[] keywords      = keywordstring.Split(' ');
                    if (keywords.Length > 0)
                    {
                        string keyword = keywords[0];
                        try
                        {
                            int value;
                            if (Int32.TryParse(keyword, out value))
                            {
                                if (value > 0)
                                {
                                    context.TotalCount = value;
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
//I ADDED

            switch (type)
            {
            case 0:                     // Show group
            {
                if (context == null)
                {
                    break;
                }

                if (index >= 0 && index < groups.Count)
                {
                    context.LastGroupIndex = index;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                }

                break;
            }

            case 1:                     // Create item
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        CraftItem(group.CraftItems.GetAt(index));
                    }
                }

                break;
            }

            case 2:                     // Item details
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool));
                    }
                }

                break;
            }

            case 3:                     // Create item (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    CraftItem(lastTen[index]);
                }

                break;
            }

            case 4:                     // Item details (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool));
                }

                break;
            }

            case 5:                     // Resource selected
            {
                if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }
                else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes2.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }

                break;
            }

            case 6:                     // Misc. buttons
            {
                switch (index)
                {
                case 0:                                 // Resource selection
                {
                    if (system.CraftSubRes.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource));
                    }

                    break;
                }

                case 1:                                 // Smelt item
                {
                    if (system.Resmelt)
                    {
                        Resmelt.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 2:                                 // Make last
                {
                    if (context == null)
                    {
                        break;
                    }

                    CraftItem item = context.LastMade;

                    if (item != null)
                    {
                        CraftItem(item);
                    }
                    else
                    {
                        m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page));                                             // You haven't made anything yet.
                    }
                    break;
                }

                case 3:                                 // Last 10
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.LastGroupIndex = 501;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));

                    break;
                }

                case 4:                                 // Toggle use resource hue
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.DoNotColor = !context.DoNotColor;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 5:                                 // Repair item
                {
                    if (system.Repair)
                    {
                        Repair.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 6:                                 // Toggle mark option
                {
                    if (context == null || !system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break;

                    case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break;

                    case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 7:                                 // Resource selection 2
                {
                    if (system.CraftSubRes2.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2));
                    }

                    break;
                }

                case 8:                                 // Enhance item
                {
                    if (system.CanEnhance)
                    {
                        Enhance.BeginTarget(m_From, system, m_Tool);
                    }

                    break;
                }

//I ADDED
                case 11:                                 // LOOP
                {
                    if (context == null)
                    {
                        break;
                    }
                    context.AutoLoop = (!context.AutoLoop);
                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));
                    break;
                }
//I ADDED
                }

                break;
            }
            }
        }
Exemple #29
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (!CheckDeed(from))
                {
                    return;
                }

                bool usingDeed = (m_Deed != null);
                bool toDelete  = false;

                // TODO: Make an IRepairable

                if (m_CraftSystem.CanCraft(from, m_Tool, targeted.GetType()) == 1044267)
                {
                    number = 1044282;                     // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed)? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !IsSpecialWeapon(weapon))
                    {
                        number = (usingDeed)? 1061136 : 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (weapon.PoisonCharges != 0)
                    {
                        number = 1005012;                         // You cannot repair an item while a caustic substance is on it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed)? 1061137 : 1044280;                             // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed)? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null)
                    {
                        number = (usingDeed)? 1061136 : 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!armor.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed)? 1061137 : 1044280;                             // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)targeted;
                    SkillName    skill    = m_CraftSystem.MainSkill;
                    int          toWeaken = 0;

                    if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !IsSpecialClothing(clothing) && !((targeted is TribalMask) || (targeted is HornedTribalMask)))
                    {
                        number = (usingDeed) ? 1061136 : 1044277;                         // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!clothing.IsChildOf(from.Backpack))
                    {
                        number = 1044275;                         // The item must be in your backpack to repair it.
                    }
                    else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                    {
                        number = 1044281;                         // That item is in full repair
                    }
                    else if (clothing.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;                         // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            clothing.MaxHitPoints -= toWeaken;
                            clothing.HitPoints     = Math.Max(0, clothing.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            number = 1044279;                             // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            clothing.HitPoints = clothing.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280;                             // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (!usingDeed && targeted is BlankScroll)
                {
                    SkillName skill = m_CraftSystem.MainSkill;

                    if (from.Skills[skill].Value >= 50.0)
                    {
                        ((BlankScroll)targeted).Consume(1);
                        RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(m_CraftSystem), from.Skills[skill].Value, from);
                        from.AddToBackpack(deed);

                        number = 500442;                         // You create the item and put it in your backpack.
                    }
                    else
                    {
                        number = 1047005;                         // You must be at least apprentice level to create a repair service contract.
                    }
                }
                else if (targeted is Item)
                {
                    number = (usingDeed)? 1061136 : 1044277;                     // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426;                     // You can't repair that.
                }

                if (!usingDeed)
                {
                    CraftContext context = m_CraftSystem.GetContext(from);
                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);

                    if (toDelete)
                    {
                        m_Deed.Delete();
                    }
                }
            }
Exemple #30
0
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page)
            : base(30, 30)             // eddited by sam for woodworking changes
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            AddPage(0);             //edited by sam

            AddBackground(0, 0, 530, 437, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 85, 2624);
            AddImageTiled(10, 37, 300, 380, 2624);            //edited by sam to fix gump
            AddImageTiled(215, 37, 305, 380, 2624);           //edited by sam to fix gump
            AddAlphaRegion(10, 10, 510, 417);


            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 50, 200, 100, 1044010, LabelColor, false, false);             // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 50, 305, 100, 1044011, LabelColor, false, false);            // <CENTER>SELECTIONS</CENTER>
            //edited by sam removed notice tab

            AddButton(15, 400, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 400, 150, 18, 1011441, LabelColor, false, false);             // EXIT

            AddButton(270, 400, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 400, 150, 18, 1044013, LabelColor, false, false);             // MAKE LAST

            // Mark option
            if (craftSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false);                 // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false);                 // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false);                 // REPAIR ITEM
            }
            // ****************************************

            // Enhance option
            if (craftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false);                 // ENHANCE ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString = subResource.NameString;
                    nameNumber = subResource.NameNumber;
                }

                AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 365, 250, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 362, LabelHue, nameString);
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString = subResource.NameString;
                    nameNumber = subResource.NameNumber;
                }

                AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 385, 250, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 385, LabelHue, nameString);
                }
            }
            // ****************************************

            CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                CreateResList(false);
            }
            else if (page == CraftPage.PickResource2)
            {
                CreateResList(true);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                CreateItemList(context.LastGroupIndex);
            }
        }
Exemple #31
0
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res     = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            CraftContext   context = m_CraftSystem.GetContext(m_From);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                    }

                    AddPage((i / 10) + 1);

                    if (i > 0)
                    {
                        AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                    AddHtmlLocalized(
                        255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(subResource.ItemType, true);

                    resourceCount += items.Sum(t => t.Amount);
                }

                AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (m_From.NetState.Version >= m_ResourceCountClient)
                {
                    if (subResource.NameNumber > 0)
                    {
                        AddHtmlLocalized(
                            255,
                            63 + (index * 20),
                            250,
                            18,
                            subResource.NameNumber,
                            resourceCount.ToString(CultureInfo.InvariantCulture),
                            LabelColor,
                            false,
                            false);
                    }
                    else
                    {
                        AddLabel(255, 60 + (index * 20), LabelHue, subResource.NameString);
                    }
                }
                else if (subResource.NameNumber > 0)
                {
                    AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(
                        255,
                        60 + (index * 20),
                        LabelHue,
                        String.Format("{0} ({1})", subResource.NameString, resourceCount.ToString(CultureInfo.InvariantCulture)));
                }
            }
        }
Exemple #32
0
        public CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page = CraftPage.None) : base(40, 40)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump <CraftGump>();
            from.CloseGump <CraftGumpItem>();

            AddPage(0);

            AddBackground(0, 0, 530, 437, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 85, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 417);

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor);  // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor); // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor); // <CENTER>NOTICES</CENTER>

            AddButton(15, 402, 4017, 4019, 0);
            AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor); // EXIT

            AddButton(270, 402, 4005, 4007, GetButtonID(6, 2));
            AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor); // MAKE LAST

            // Mark option
            if (craftSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6));
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor); // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1));
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor); // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5));
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor); // REPAIR ITEM
            }
            // ****************************************

            // Enhance option
            if (craftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8));
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor); // ENHANCE ITEM
            }
            // ****************************************

            if (notice is int noticeInt && noticeInt > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, noticeInt, LabelColor);
            }
Exemple #33
0
        private CraftGump(Mobile from, CraftSystem craftSystem, IBaseTool tool, object notice, CraftPage page)
            : base(40, 40)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            AddPage(0);

            AddBackground(0, 0, 530, 437, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 25, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 85, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 417);

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 38, 200, 22, 1044010, LabelColor, false, false);             // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 38, 305, 22, 1044011, LabelColor, false, false);            // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 293, 150, 22, 1044012, LabelColor, false, false);            // <CENTER>NOTICES</CENTER>

            AddButton(15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor, false, false);             // EXIT

            AddButton(270, 402, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor, false, false);             // MAKE LAST

            // Mark option
            if (craftSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(
                    305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false);
                // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false);                 // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false);                 // REPAIR ITEM
            }
            // ****************************************

            // Enhance option
            if (craftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false);                 // ENHANCE ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                Type resourceType = craftSystem.CraftSubRes.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    resourceCount += items.Sum(t => t.Amount);
                }

                AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(
                        50, 365, 250, 18, nameNumber, resourceCount.ToString(CultureInfo.InvariantCulture), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 362, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                Type resourceType = craftSystem.CraftSubRes2.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    resourceCount += items.Sum(t => t.Amount);
                }

                AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(
                        50, 385, 250, 18, nameNumber, resourceCount.ToString(CultureInfo.InvariantCulture), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 385, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            CreateGroupList();

            switch (page)
            {
            case CraftPage.PickResource:
                CreateResList(false, from);
                break;

            case CraftPage.PickResource2:
                CreateResList(true, from);
                break;

            default:
            {
                if (context != null && context.LastGroupIndex > -1)
                {
                    CreateItemList(context.LastGroupIndex);
                }
            }
            break;
            }
        }