ServUO- Pet Damage cap for PVP

ronfellows

Citizen
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
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.
 

ronfellows

Citizen
I have OnDamage(int amount, Mobile from, bool willKill) on line 3568 but I'n not sure how to plug all of that in. I'm very new to all of this :(
 

Attachments

  • PlayerMobile.cs
    181.3 KB · Views: 4

Lokai

Moderator
ServUO Developer
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);
        }
 

ronfellows

Citizen
I added that bit of code in but it does not seem to be changing anything game side.
 

Attachments

  • PlayerMobile.cs
    181.5 KB · Views: 0

Lemke

Citizen
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

Rookie
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
            }
 

Naviehs

Citizen
What if we wanted to damage cap pvp?
Post automatically merged:

int PVP_DAMAGE_CAP = 30;

if (from != null && from.Player)

{
amount = Math.Min(amount, PVP_DAMAGE_CAP); // pick the lesser of amount or the pet damage cap
}

Isnt working..
 
Last edited:
I'm wanting to revive this post, I use Runuo 2.6 and I've tried all 3 suggestions above and none of them have worked for me. If someone could help, it would be much appreciated