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.
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);
}
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 );
}
public override void AlterMeleeDamageFrom( Mobile from, ref int damage )
{
if ( from is BaseCreature )
{
damage = Utility.RandomMinMax( 20, 80 );
}
base.AlterMeleeDamageFrom(from, ref damage);
}
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
}