public void VisibulletHit(VisibulletPacket pkt)
{
//Possible bug I can see right now:
// If enemy does not exist, no condition effects can be applied.
if (pkt.EnemyId == -2)
{
HP = 0;
UpdateCount++;
Death("Unknown");
return;
}
Entity enemy = Owner.GetEntity(pkt.EnemyId);
string killer = "Unknown";
if (!HasConditionEffect(ConditionEffects.Invulnerable))
HP -= pkt.Damage;
ConditionEffects? ceffects = null;
if (enemy != null)
{
killer = enemy.ObjectDesc.DisplayId ??
enemy.ObjectDesc.ObjectId;
Projectile proj = (enemy as IProjectileOwner).Projectiles[pkt.BulletId];
if (proj != null)
{
if(!HasConditionEffect(ConditionEffects.Invincible))
ceffects = proj.ConditionEffects;
ApplyConditionEffect(proj.Descriptor.Effects);
}
}
UpdateCount++;
Owner.BroadcastPacket(new DamagePacket()
{
TargetId = this.Id,
Effects = (!ceffects.HasValue) ? 0 : (ConditionEffects)ceffects,
Damage = (ushort)pkt.Damage,
Killed = HP <= 0,
BulletId = pkt.BulletId,
ObjectId = pkt.EnemyId
}, this);
if (HP <= 0) Death(killer);
}