/// <param name="swingFlag">usually 1</param> /// <returns>The actual damage (all resistances subtracted)</returns> public static uint SendMeleeDamage(WorldObject attacker, WorldObject target, DamageType type, HitInfo hitInfo, uint totalAmount, uint absorbed, uint resisted, uint blocked, VictimState victimState) { uint amount = totalAmount - blocked - absorbed - resisted; using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_ATTACKERSTATEUPDATE, 70)) { packet.WriteUInt((uint)hitInfo); attacker.EntityId.WritePacked(packet); target.EntityId.WritePacked(packet); packet.WriteUInt(totalAmount); packet.WriteByte(1); packet.WriteByte((uint)type); packet.WriteFloat(amount); packet.WriteUInt(amount); packet.WriteUInt(absorbed); packet.WriteUInt(resisted); packet.WriteUInt((uint)victimState); packet.Write(absorbed == 0 ? 0 : -1); packet.WriteUInt(0); packet.WriteUInt(blocked); target.PushPacketToSurroundingArea(packet, true, false); } return amount; }
/// <summary> /// Usually caused by jumping too high, diving too long, standing too close to fire etc /// </summary> public static void SendEnvironmentDamage(WorldObject target, EnviromentalDamageType type, uint totalDamage) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_ENVIRONMENTALDAMAGELOG, 21)) { target.EntityId.WritePacked(packet); packet.WriteByte((byte)type); packet.WriteUInt(totalDamage); packet.WriteULong(0); target.PushPacketToSurroundingArea(packet, true, false); } }
/// <summary> /// Any spell and ranged damage /// </summary> /// <param name="totalAmount">Total amount</param> /// <returns>The actual amount, with all mali subtracted</returns> public static void SendMagicDamage(EntityId caster, WorldObject target, uint spellId, uint amount, DamageType type, uint absorbed, uint resisted, uint blocked, bool critical) { /*if (victimState == VICTIMSTATE.DEFLECT) // resist return MagicResist(target,submitter,spellId);*/ // TODO: Magic miss, ranged dodge, etc. using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELLNONMELEEDAMAGELOG, 40)) { target.EntityId.WritePacked(packet); caster.WritePacked(packet); packet.Write(spellId); packet.WriteUInt(amount); packet.WriteByte((byte)type); packet.WriteUInt(absorbed); packet.WriteUInt(resisted); packet.WriteByte(type == DamageType.Physical ? 1 : 0); // pyshical damage? packet.WriteByte(0); packet.WriteUInt(blocked); packet.WriteByte(critical ? 7 : 6); packet.Write(0); target.PushPacketToSurroundingArea(packet, true, false); } }
/// <summary> /// Used for Periodic leech effects, mostly Cannibalism /// </summary> /// <param name="school">AuraTickFlags.PeriodicHeal</param> /// <returns></returns> public static void SendPeriodicDamage(WorldObject caster, WorldObject target, uint spellId, Spells.AuraTickFlags type, uint amount) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_PERIODICAURALOG, 32)) { caster.EntityId.WritePacked(packet); target.EntityId.WritePacked(packet); packet.WriteUInt(spellId); packet.WriteUInt(1); // count packet.WriteUInt((uint)type); packet.WriteUInt(amount); target.PushPacketToSurroundingArea(packet, true, false); } }