feat: Adds reflect damage ability. Fixes magical barrier (#1184)

This commit is contained in:
Kamron Batman 2022-10-08 10:39:28 -07:00 • committed by GitHub
parent 3c5e9eaec9
commit 2806e5d4b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 86 additions and 64 deletions

View file

@ -194,24 +194,35 @@ namespace Server
totalDamage = m.Hits;
}
var bcFrom = from as BaseCreature;
if (from is { Deleted: false, Alive: true })
{
var reflectPhys = AosAttributes.GetValue(m, AosAttribute.ReflectPhysical);
var reflectPhysAbility = bcFrom?.GetAbility(MonsterAbilityType.ReflectPhysicalDamage) as ReflectPhysicalDamage;
if (reflectPhys != 0 && from is BaseCreature bcFrom)
if (reflectPhysAbility
?.CanTrigger(bcFrom, MonsterAbilityTrigger.CombatAction) == true)
{
var magicalBarrier = bcFrom.GetAbility(MonsterAbilityType.MagicalBarrier);
magicalBarrier.AlterMeleeDamageFrom(bcFrom, m, ref reflectPhys);
reflectPhys += reflectPhysAbility.PercentReflected;
m.SendLocalizedMessage(1070844); // The creature repels the attack back at you.
}
if (reflectPhys != 0)
if (reflectPhys > 0)
{
var reflectDamage = Scale(
damage * phys * (100 - (ignoreArmor ? 0 : m.PhysicalResistance)) / 10000,
reflectPhys
);
from.Damage(reflectDamage, m);
bcFrom
?.GetAbility(MonsterAbilityType.MagicalBarrier)
?.AlterMeleeDamageFrom(bcFrom, m, ref reflectDamage);
if (reflectDamage > 0)
{
from.Damage(reflectDamage, m);
}
}
}

View file

@ -14,5 +14,6 @@ public enum MonsterAbilityType
DeathExplosion,
MassDrainLife,
MagicalBarrier,
EnergyBoltCounter
EnergyBoltCounter,
ReflectPhysicalDamage
}

View file

@ -0,0 +1,11 @@
namespace Server.Mobiles;
public class ReflectPhysicalDamage : MonsterAbility
{
// This is handled manually in AOS.Damage()
public override MonsterAbilityTrigger AbilityTrigger => MonsterAbilityTrigger.CombatAction;
public override MonsterAbilityType AbilityType => MonsterAbilityType.ReflectPhysicalDamage;
public virtual int PercentReflected => 10;
}

View file

@ -64,6 +64,9 @@ namespace Server.Mobiles
public override bool Uncalmable => true;
private static MonsterAbility[] _abilities = { new ReflectPhysicalDamage() };
public override MonsterAbility[] GetMonsterAbilities() => _abilities;
public override void GenerateLoot()
{
AddLoot(LootPack.FilthyRich);
@ -71,12 +74,6 @@ namespace Server.Mobiles
AddLoot(LootPack.Gems, 2);
}
/* TODO: Repel Magic
* 10% chance of repelling a melee attack (why did they call it repel magic anyway?)
* Cliloc: 1070844
* Effect: damage is dealt to the attacker, no damage is taken by the fan dancer
*/
private void ThrowFan(Mobile to)
{
if (!(Utility.RandomDouble() < 0.8) || to.InRange(this, 1))