ServUO- Pet Damage cap for PVP

ronfellows

Member
Sep 9, 2017
21
1
www.uorevival.com
Shard Name
UO Revival
Is there a way to cap pet damage for PVP? I currently have the old pet system and some custom tameables that are hitting players way too hard. Any help would be greatly appreciated.
 

Lokai

Moderator
ServUO Developer
Dec 4, 2014
1,280
218
Western New York State
Shard Name
Test Center
Donate
Donate money to this user
PlayerMobile, around line 3579, find OnDamage(int amount, Mobile from, bool willKill)

In there, you can add a check to see if "from" is a BaseCreature, and if it is Controlled (ie. it's a pet) then adjust the amount to return to base.OnDamage at the end.
 

Lokai

Moderator
ServUO Developer
Dec 4, 2014
1,280
218
Western New York State
Shard Name
Test Center
Donate
Donate money to this user
Here is your new OnDamage. The "40" you replace with whatever you want to cap damage at.

C#:
        public override void OnDamage(int amount, Mobile from, bool willKill)
        {
            int PET_DAMAGE_CAP = 40;
            
            if (from is BaseCreature && ((BaseCreature)from).Controlled)
            {
                amount = Math.Min(amount, PET_DAMAGE_CAP); // pick the lesser of amount or the pet damage cap
            }
            
            int disruptThreshold;

            if (!Core.AOS)
            {
                disruptThreshold = 0;
            }
            else if (from != null && from.Player)
            {
                disruptThreshold = 19;
            }
            else
            {
                disruptThreshold = 26;
            }

            if (Core.SA)
            {
                disruptThreshold += Dex / 12;
            }

            if (amount > disruptThreshold)
            {
                BandageContext c = BandageContext.GetContext(this);

                if (c != null)
                {
                    c.Slip();
                }
            }

            if (Confidence.IsRegenerating(this))
            {
                Confidence.StopRegenerating(this);
            }

            WeightOverloading.FatigueOnDamage(this, amount);

            if (m_ReceivedHonorContext != null)
            {
                m_ReceivedHonorContext.OnTargetDamaged(from, amount);
            }
            if (m_SentHonorContext != null)
            {
                m_SentHonorContext.OnSourceDamaged(from, amount);
            }

            if (willKill && from is PlayerMobile)
            {
                Timer.DelayCall(TimeSpan.FromSeconds(10), ((PlayerMobile)@from).RecoverAmmo);
            }

            #region Mondain's Legacy
            if (InvisibilityPotion.HasTimer(this))
            {
                InvisibilityPotion.Iterrupt(this);
            }
            #endregion

            UndertakersStaff.TryRemoveTimer(this);

            base.OnDamage(amount, from, willKill);
        }
 

Lemke

Well-Known Member
Sep 26, 2015
66
5
37
I sugest you to modify a bit your pets...at least the pets are used by players like dragons,greater dragons,cusidhes,hyriu...you can add this:

C#:
public override void AlterMeleeDamageTo( Mobile to, ref int damage )
{
        if ( to is PlayerMobile )
            {
                PlayerMobile creature = (PlayerMobile)to;
                damage = damage / 2;    // Damage / 2. You can use too: damage = Utility.RandomMinMax( 20, 80 );
                //damage = damage * 3;  // Change multiplier here as you wish
            }
             base.AlterMeleeDamageTo( to, ref damage );
}
Try it,its a nice solution,you can use it on monsters too,or to get damage reduced or augmented vs "x" monster using this:

C#:
public override void AlterMeleeDamageFrom( Mobile from, ref int damage )
        {
            if ( from is BaseCreature )
            {
                damage = Utility.RandomMinMax( 20, 80 );
            }
            base.AlterMeleeDamageFrom(from, ref damage);
        }
 

Visam

Well-Known Member
Mar 19, 2015
222
29
47
The way I did it is in AOS.cs search for the top line of the code and add the rest. (works on current version of ServUO and has for a long time.

C#:
        public static int Damage(IDamageable damageable, Mobile from, int damage, bool ignoreArmor, int phys, int fire, int cold, int pois, int nrgy, int chaos, int direct, bool keepAlive, DamageType type = DamageType.Melee)
        {
            if (damageable is PlayerMobile && from is BaseCreature && ((BaseCreature)from).Controlled)
            {
                damage = Math.Min(damage, 40); // Pet Dmg Cap to players
                phys = Math.Min(phys, 40); // Pet phys Cap to players
                fire = Math.Min(fire, 40); // Pet fire Cap to players
                cold = Math.Min(cold, 40); // Pet cold Cap to players
                pois = Math.Min(pois, 40); // Pet pois Cap to players
                nrgy = Math.Min(nrgy, 40); // Pet nrgy Cap to players
                chaos = Math.Min(chaos, 40); // Pet chaos Cap to players
                direct = Math.Min(direct, 40); // Pet direct Cap to players
            }
 
  • Like
Reactions: Lokai