コード例 #1
0
ファイル: Ore.cs プロジェクト: libcs/game.ultimaonline.io
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Ore.Deleted)
                {
                    return;
                }

                if (!from.InRange(m_Ore.GetWorldLocation(), 2))
                {
                    from.SendLocalizedMessage(501976); // The ore is too far away.
                    return;
                }

                #region Combine Ore
                if (targeted is BaseOre)
                {
                    BaseOre ore = (BaseOre)targeted;

                    if (!ore.Movable)
                    {
                        return;
                    }
                    else if (m_Ore == ore)
                    {
                        from.SendLocalizedMessage(501972); // Select another pile or ore with which to combine this.
                        from.Target = new InternalTarget(ore);
                        return;
                    }
                    else if (ore.Resource != m_Ore.Resource)
                    {
                        from.SendLocalizedMessage(501979); // You cannot combine ores of different metals.
                        return;
                    }

                    int worth = ore.Amount;

                    if (ore.ItemID == 0x19B9)
                    {
                        worth *= 8;
                    }
                    else if (ore.ItemID == 0x19B7)
                    {
                        worth *= 2;
                    }
                    else
                    {
                        worth *= 4;
                    }

                    int sourceWorth = m_Ore.Amount;

                    if (m_Ore.ItemID == 0x19B9)
                    {
                        sourceWorth *= 8;
                    }
                    else if (m_Ore.ItemID == 0x19B7)
                    {
                        sourceWorth *= 2;
                    }
                    else
                    {
                        sourceWorth *= 4;
                    }

                    worth += sourceWorth;

                    int plusWeight = 0;
                    int newID      = ore.ItemID;

                    if (ore.DefaultWeight != m_Ore.DefaultWeight)
                    {
                        if (ore.ItemID == 0x19B7 || m_Ore.ItemID == 0x19B7)
                        {
                            newID = 0x19B7;
                        }
                        else if (ore.ItemID == 0x19B9)
                        {
                            newID      = m_Ore.ItemID;
                            plusWeight = ore.Amount * 2;
                        }
                        else
                        {
                            plusWeight = m_Ore.Amount * 2;
                        }
                    }

                    if ((ore.ItemID == 0x19B9 && worth > 120000) || ((ore.ItemID == 0x19B8 || ore.ItemID == 0x19BA) && worth > 60000) || (ore.ItemID == 0x19B7 && worth > 30000))
                    {
                        from.SendLocalizedMessage(1062844); // There is too much ore to combine.
                        return;
                    }
                    else if (ore.RootParent is Mobile && (plusWeight + ((Mobile)ore.RootParent).Backpack.TotalWeight) > ((Mobile)ore.RootParent).Backpack.MaxWeight)
                    {
                        from.SendLocalizedMessage(501978); // The weight is too great to combine in a container.
                        return;
                    }

                    ore.ItemID = newID;

                    if (ore.ItemID == 0x19B9)
                    {
                        ore.Amount = worth / 8;
                    }
                    else if (ore.ItemID == 0x19B7)
                    {
                        ore.Amount = worth / 2;
                    }
                    else
                    {
                        ore.Amount = worth / 4;
                    }

                    m_Ore.Delete();
                    return;
                }
                #endregion

                if (IsForge(targeted))
                {
                    double difficulty;

                    switch (m_Ore.Resource)
                    {
                    default: difficulty = 50.0; break;

                    case CraftResource.DullCopper: difficulty = 65.0; break;

                    case CraftResource.ShadowIron: difficulty = 70.0; break;

                    case CraftResource.Copper: difficulty = 75.0; break;

                    case CraftResource.Bronze: difficulty = 80.0; break;

                    case CraftResource.Gold: difficulty = 85.0; break;

                    case CraftResource.Agapite: difficulty = 90.0; break;

                    case CraftResource.Verite: difficulty = 95.0; break;

                    case CraftResource.Valorite: difficulty = 99.0; break;
                    }

                    double minSkill = difficulty - 25.0;
                    double maxSkill = difficulty + 25.0;

                    if (difficulty > 50.0 && difficulty > from.Skills[SkillName.Mining].Value)
                    {
                        from.SendLocalizedMessage(501986); // You have no idea how to smelt this strange ore!
                        return;
                    }

                    if (m_Ore.ItemID == 0x19B7 && m_Ore.Amount < 2)
                    {
                        from.SendLocalizedMessage(501987); // There is not enough metal-bearing ore in this pile to make an ingot.
                        return;
                    }

                    if (from.CheckTargetSkill(SkillName.Mining, targeted, minSkill, maxSkill))
                    {
                        int toConsume = m_Ore.Amount;

                        if (toConsume <= 0)
                        {
                            from.SendLocalizedMessage(501987); // There is not enough metal-bearing ore in this pile to make an ingot.
                        }
                        else
                        {
                            if (toConsume > 30000)
                            {
                                toConsume = 30000;
                            }

                            int ingotAmount;

                            if (m_Ore.ItemID == 0x19B7)
                            {
                                ingotAmount = toConsume / 2;

                                if (toConsume % 2 != 0)
                                {
                                    --toConsume;
                                }
                            }
                            else if (m_Ore.ItemID == 0x19B9)
                            {
                                ingotAmount = toConsume * 2;
                            }
                            else
                            {
                                ingotAmount = toConsume;
                            }

                            BaseIngot ingot = m_Ore.GetIngot();
                            ingot.Amount = ingotAmount;

                            m_Ore.Consume(toConsume);
                            from.AddToBackpack(ingot);
                            //from.PlaySound( 0x57 );

                            from.SendLocalizedMessage(501988); // You smelt the ore removing the impurities and put the metal in your backpack.
                        }
                    }
                    else
                    {
                        if (m_Ore.Amount < 2)
                        {
                            if (m_Ore.ItemID == 0x19B9)
                            {
                                m_Ore.ItemID = 0x19B8;
                            }
                            else
                            {
                                m_Ore.ItemID = 0x19B7;
                            }
                        }
                        else
                        {
                            m_Ore.Amount /= 2;
                        }

                        from.SendLocalizedMessage(501990); // You burn away the impurities but are left with less useable metal.
                    }
                }
            }
コード例 #2
0
ファイル: Ore.cs プロジェクト: libcs/game.ultimaonline.io
 public InternalTarget(BaseOre ore) : base(2, false, TargetFlags.None)
 {
     m_Ore = ore;
 }