Exemple #1
0
        public virtual void OnTarget(Mobile from, object obj)
        {
            if (Deleted)
            {
                return;
            }

            ForestWyrm pet = obj as ForestWyrm;

            if (pet == null || pet.HasBarding)
            {
                from.SendLocalizedMessage(1053025);                   // That is not an unarmored swamp dragon.
            }
            else if (!pet.Controlled || pet.ControlMaster != from)
            {
                from.SendLocalizedMessage(1053026);                   // You can only put barding on a tamed swamp dragon that you own.
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1060640);                   // The item must be in your backpack to use it.
            }
            else
            {
                pet.BardingExceptional = this.Exceptional;
                pet.BardingCrafter     = this.Crafter;
                pet.BardingHP          = pet.BardingMaxHP;
                pet.BardingResource    = this.Resource;
                pet.HasBarding         = true;
                pet.Hue = this.Hue;

                this.Delete();

                from.SendLocalizedMessage(1053027);                   // You place the barding on your swamp dragon.  Use a bladed item on your dragon to remove the armor.
            }
        }
Exemple #2
0
        public static int Damage(Mobile m, Mobile from, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy, int chaos, int direct, bool keepAlive, bool archer, bool deathStrike)
        {
            if (m == null || m.Deleted || !m.Alive || damage <= 0)
            {
                return(0);
            }

            if (!Core.AOS)
            {
                m.Damage(damage, from);
                return(damage);
            }

            Fix(ref phys);
            Fix(ref fire);
            Fix(ref cold);
            Fix(ref pois);
            Fix(ref nrgy);

            int totalDamage;

            if (!ignoreArmor)
            {
                // Armor Ignore on OSI ignores all defenses, not just physical.
                int resPhys = m.PhysicalResistance;
                int resFire = m.FireResistance;
                int resCold = m.ColdResistance;
                int resPois = m.PoisonResistance;
                int resNrgy = m.EnergyResistance;

                totalDamage  = damage * phys * (100 - resPhys);
                totalDamage += damage * fire * (100 - resFire);
                totalDamage += damage * cold * (100 - resCold);
                totalDamage += damage * pois * (100 - resPois);
                totalDamage += damage * nrgy * (100 - resNrgy);

                totalDamage /= 10000;

                if (totalDamage < 1)
                {
                    totalDamage = 1;
                }
            }
            else
            {
                totalDamage = damage;
            }

            #region Dragon Barding
            if ((!Core.AOS || from == null || !from.Player) && m.Player && m.Mount is ForestWyrm)
            {
                ForestWyrm pet = m.Mount as ForestWyrm;

                if (pet != null && pet.HasBarding)
                {
                    int percent  = (pet.BardingExceptional ? 20 : 10);
                    int absorbed = Scale(totalDamage, percent);

                    totalDamage   -= absorbed;
                    pet.BardingHP -= absorbed;

                    if (pet.BardingHP < 0)
                    {
                        pet.HasBarding = false;
                        pet.BardingHP  = 0;

                        m.SendLocalizedMessage(1053031); // Your dragon's barding has been destroyed!
                    }
                }
            }
            #endregion

            if (keepAlive && totalDamage > m.Hits)
            {
                totalDamage = m.Hits;
            }

            m.Damage(totalDamage, from);
            return(totalDamage);
        }
Exemple #3
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is BaseWeapon)
                {
                    if (from.CheckTargetSkill(SkillName.ArmsLore, targeted, 0, 100))
                    {
                        BaseWeapon weap = (BaseWeapon)targeted;

                        if (weap.MaxHitPoints != 0)
                        {
                            int hp = (int)((weap.HitPoints / (double)weap.MaxHitPoints) * 10);

                            if (hp < 0)
                            {
                                hp = 0;
                            }
                            else if (hp > 9)
                            {
                                hp = 9;
                            }

                            from.SendLocalizedMessage(1038285 + hp);
                        }

                        int damage = (weap.MaxDamage + weap.MinDamage) / 2;
                        int hand   = (weap.Layer == Layer.OneHanded ? 0 : 1);

                        if (damage < 3)
                        {
                            damage = 0;
                        }
                        else
                        {
                            damage = (int)Math.Ceiling(Math.Min(damage, 30) / 5.0);
                        }

                        WeaponType type = weap.Type;

                        if (type == WeaponType.Ranged)
                        {
                            from.SendLocalizedMessage(1038224 + (damage * 9));
                        }
                        else if (type == WeaponType.Piercing)
                        {
                            from.SendLocalizedMessage(1038218 + hand + (damage * 9));
                        }
                        else if (type == WeaponType.Slashing)
                        {
                            from.SendLocalizedMessage(1038220 + hand + (damage * 9));
                        }
                        else if (type == WeaponType.Bashing)
                        {
                            from.SendLocalizedMessage(1038222 + hand + (damage * 9));
                        }
                        else
                        {
                            from.SendLocalizedMessage(1038216 + hand + (damage * 9));
                        }

                        if (weap.Poison != null && weap.PoisonCharges > 0)
                        {
                            from.SendLocalizedMessage(1038284); // It appears to have poison smeared on it.
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(500353); // You are not certain...
                    }
                }
                else if (targeted is BaseArmor)
                {
                    if (from.CheckTargetSkill(SkillName.ArmsLore, targeted, 0, 100))
                    {
                        BaseArmor arm = (BaseArmor)targeted;

                        if (arm.MaxHitPoints != 0)
                        {
                            int hp = (int)((arm.HitPoints / (double)arm.MaxHitPoints) * 10);

                            if (hp < 0)
                            {
                                hp = 0;
                            }
                            else if (hp > 9)
                            {
                                hp = 9;
                            }

                            from.SendLocalizedMessage(1038285 + hp);
                        }


                        from.SendLocalizedMessage(1038295 + (int)Math.Ceiling(Math.Min(arm.ArmorRating, 35) / 5.0));
                    }
                    else
                    {
                        from.SendLocalizedMessage(500353); // You are not certain...
                    }
                }
                else if (targeted is ForestWyrm && ((ForestWyrm)targeted).HasBarding)
                {
                    ForestWyrm pet = (ForestWyrm)targeted;

                    if (from.CheckTargetSkill(SkillName.ArmsLore, targeted, 0, 100))
                    {
                        int perc = (4 * pet.BardingHP) / pet.BardingMaxHP;

                        if (perc < 0)
                        {
                            perc = 0;
                        }
                        else if (perc > 4)
                        {
                            perc = 4;
                        }

                        pet.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1053021 - perc, from.NetState);
                    }
                    else
                    {
                        from.SendLocalizedMessage(500353); // You are not certain...
                    }
                }
                else
                {
                    from.SendLocalizedMessage(500352); // This is neither weapon nor armor.
                }

                EventSink.InvokeSkillUsed(new SkillUsedEventArgs(from, from.Skills[SkillName.ArmsLore]));
            }
        protected override void OnTarget(Mobile from, object targeted)
        {
            if (m_Item.Deleted)
            {
                return;
            }

            if (targeted is ICarvable)
            {
                ((ICarvable)targeted).Carve(from, m_Item);
            }
            else if (targeted is ForestWyrm && ((ForestWyrm)targeted).HasBarding)
            {
                ForestWyrm pet = (ForestWyrm)targeted;

                if (!pet.Controlled || pet.ControlMaster != from)
                {
                    from.SendLocalizedMessage(1053022);                       // You cannot remove barding from a swamp dragon you do not own.
                }
                else
                {
                    pet.HasBarding = false;
                }
            }
            #region CropSystem
            else if (targeted is Weeds)
            {
                ((Weeds)targeted).Delete();

                from.SendMessage("You slice the roots of the weed and toss them away.");
            }
            else if (targeted is Food && ((Food)targeted).SeedType != null)
            {
                try
                {
                    Food food   = targeted as Food;
                    int  amount = (food.Amount * Utility.RandomMinMax(2, 6));
                    Item seed   = Activator.CreateInstance(food.SeedType, amount) as Item;

                    if (seed != null)
                    {
                        from.AddToBackpack(seed);
                        from.SendMessage(String.Format("You slice open the plant{0} and remove {1} seeds.",
                                                       (food.Amount > 1 ? "s" : ""), (food.Amount > 1 ? "their" : "its")));
                    }

                    food.Delete();
                }
                catch { }
            }
            else if (targeted is Flax)
            {
                int amount = (((Flax)targeted).Amount * Utility.RandomMinMax(2, 6));

                from.AddToBackpack(new FlaxSeed(amount));
                from.SendMessage("You cut off the stalk of the flax and throw it away, keeping the seeds for later use.");

                ((Flax)targeted).Delete();
            }
            else if (targeted is WheatSheaf)
            {
                int amount = (((WheatSheaf)targeted).Amount * Utility.RandomMinMax(3, 8));

                from.AddToBackpack(new WheatSeed(amount));
                from.SendMessage("You split open the wheat and take all the seeds you can find.");

                ((WheatSheaf)targeted).Delete();
            }
            else if (targeted is Rose)
            {
                from.AddToBackpack(new RoseBud(Utility.RandomMinMax(3, 6)));
                from.SendMessage("You break away the petals of the flowers and gently remove the buds.");

                ((Rose)targeted).Delete();
            }
            #endregion
            else
            {
                HarvestSystem     system = Lumberjacking.System;
                HarvestDefinition def    = Lumberjacking.System.Definition;

                int     tileID;
                Map     map;
                Point3D loc;

                if (!system.GetHarvestDetails(from, m_Item, targeted, out tileID, out map, out loc))
                {
                    from.SendLocalizedMessage(500494);                       // You can't use a bladed item on that!
                }
                else if (!def.Validate(tileID))
                {
                    from.SendLocalizedMessage(500494);                       // You can't use a bladed item on that!
                }
                else
                {
                    HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

                    if (bank == null)
                    {
                        return;
                    }

                    if (bank.Current < 5)
                    {
                        from.SendLocalizedMessage(500493);                           // There's not enough wood here to harvest.
                    }
                    else
                    {
                        bank.Consume(5, from);

                        Item item = new Kindling();

                        if (from.PlaceInBackpack(item))
                        {
                            from.SendLocalizedMessage(500491);                               // You put some kindling into your backpack.
                            from.SendLocalizedMessage(500492);                               // An axe would probably get you more wood.
                        }
                        else
                        {
                            from.SendLocalizedMessage(500490);                               // You can't place any kindling into your backpack!

                            item.Delete();
                        }
                    }
                }
            }
        }