This is mainly for Lord Ruthven, but this will be a short tutorial on how to implement this descriptor.
Step 1. On your enemy object, add <LeachHealth/> to its XML.
Step 2. In file 'Descriptors.cs', make a public bool variable named 'LeachHealth', preferably under the other object descriptions. Then in the class 'ObjectDesc', write to your variable using your XML tag.
Code:
public bool LeachHealth { get; private set; }
LeachHealth = elem.Element("LeachHealth") != null;
Step 3. In file 'Player.cs', find 'public void Damage', and add this code underneath the reduction of player HP. We do this just because it's after the damage calculations.
Code:
if (chr.ObjectDesc.LeachHealth)
{
Enemy enemy = chr as Enemy;
if (enemy.HP > 0 && enemy.HP < chr.ObjectDesc.MaxHP)
{
enemy.HP += dmg;
chr.Owner.BroadcastPacket(new ShowEffectPacket
{
EffectType = EffectType.Potion,
TargetId = chr.Id,
Color = new ARGB(0xffffffff)
}, null);
chr.Owner.BroadcastPacket(new NotificationPacket
{
ObjectId = chr.Id,
Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"+" + dmg + "\"}}",
Color = new ARGB(0xff00ff00)
}, null);
}
}
Then you're done. Now your Lord Ruthven will heal itself from damaging players. You could take this a step further by making the tag a projectile descriptor, which should be self explanatory.