public BuffStat(BuffValueTypes flag) { Flag = flag; N = 0; R = 0; TM = 0; }
public byte[] ToMapBuffValues(BuffValueTypes pBuffFlags = BuffValueTypes.All) { var pw = new PacketWriter(); var ps = Parent.PrimaryStats; var currentTime = DateTime.UtcNow; BuffValueTypes added = 0; var buffWriter = new PacketWriter(); ps.BuffSpeed.EncodeForRemote(ref added, currentTime, stat => buffWriter.WriteByte((byte)stat.Value), pBuffFlags); ps.BuffComboAttack.EncodeForRemote(ref added, currentTime, stat => buffWriter.WriteByte((byte)stat.Value), pBuffFlags); ps.BuffCharges.EncodeForRemote(ref added, currentTime, stat => buffWriter.WriteInt(stat.ReferenceId), pBuffFlags); ps.BuffStun.EncodeForRemote(ref added, currentTime, stat => buffWriter.WriteInt(stat.ReferenceId), pBuffFlags); ps.BuffDarkness.EncodeForRemote(ref added, currentTime, stat => buffWriter.WriteInt(stat.ReferenceId), pBuffFlags); ps.BuffSeal.EncodeForRemote(ref added, currentTime, stat => buffWriter.WriteInt(stat.ReferenceId), pBuffFlags); ps.BuffWeakness.EncodeForRemote(ref added, currentTime, stat => buffWriter.WriteInt(stat.ReferenceId), pBuffFlags); ps.BuffPoison.EncodeForRemote(ref added, currentTime, stat => { pw.WriteShort(stat.Value); pw.WriteInt(stat.ReferenceId); }, pBuffFlags); ps.BuffSoulArrow.EncodeForRemote(ref added, currentTime, null, pBuffFlags); ps.BuffShadowPartner.EncodeForRemote(ref added, currentTime, null, pBuffFlags); ps.BuffDarkSight.EncodeForRemote(ref added, currentTime, null, pBuffFlags); pw.WriteUInt((uint)added); pw.WriteBytes(buffWriter.ToArray()); return(pw.ToArray()); }
public static void AddMapBuffValues(Character chr, Packet pw, BuffValueTypes pBuffFlags = BuffValueTypes.ALL) { CharacterPrimaryStats ps = chr.PrimaryStats; long currentTime = MasterThread.CurrentTime; BuffValueTypes added = 0; int tmp = pw.Position; pw.WriteUInt(0); // Placeholder ps.BuffSpeed.EncodeForRemote(ref added, currentTime, stat => pw.WriteByte((byte)stat.N), pBuffFlags); ps.BuffComboAttack.EncodeForRemote(ref added, currentTime, stat => pw.WriteByte((byte)stat.N), pBuffFlags); ps.BuffCharges.EncodeForRemote(ref added, currentTime, stat => pw.WriteInt(stat.R), pBuffFlags); ps.BuffStun.EncodeForRemote(ref added, currentTime, stat => pw.WriteInt(stat.R), pBuffFlags); ps.BuffDarkness.EncodeForRemote(ref added, currentTime, stat => pw.WriteInt(stat.R), pBuffFlags); ps.BuffSeal.EncodeForRemote(ref added, currentTime, stat => pw.WriteInt(stat.R), pBuffFlags); ps.BuffWeakness.EncodeForRemote(ref added, currentTime, stat => pw.WriteInt(stat.R), pBuffFlags); ps.BuffPoison.EncodeForRemote(ref added, currentTime, stat => { pw.WriteShort(stat.N); pw.WriteInt(stat.R); }, pBuffFlags); ps.BuffSoulArrow.EncodeForRemote(ref added, currentTime, null, pBuffFlags); ps.BuffShadowPartner.EncodeForRemote(ref added, currentTime, null, pBuffFlags); ps.BuffDarkSight.EncodeForRemote(ref added, currentTime, null, pBuffFlags); pw.SetUInt(tmp, (uint)added); }
public BuffStat(BuffValueTypes flag) { Flag = flag; Value = 0; ReferenceId = 0; ExpireTime = DateTime.MinValue; }
private static void SendDebuffRemote(Character chr, BuffValueTypes removedFlags) { var pw = new PacketWriter(ServerOperationCode.RemotePlayerSkillDebuff); pw.WriteInt(chr.Id); pw.WriteUInt((uint)removedFlags); chr.Map?.Send(pw, chr); }
public void TryResetByReference(int reference, ref BuffValueTypes flag) { if (N == 0 || R != reference) { return; } flag |= Reset(); }
public static void SendPlayerDebuffed(Character chr, BuffValueTypes buffFlags) { Packet pw = new Packet(ServerMessages.RESET_FOREIGN_BUFF); pw.WriteInt(chr.ID); pw.WriteUInt((uint)buffFlags); chr.Field.SendPacket(chr, pw, chr); }
public override bool DecodeForCC(Packet pr, BuffValueTypes flag) { if (base.DecodeForCC(pr, flag)) { tLastDamaged = pr.ReadLong(); return(true); } return(false); }
public override bool EncodeForCC(Packet pr, ref BuffValueTypes flag, long currentTime) { if (base.EncodeForCC(pr, ref flag, currentTime)) { pr.WriteLong(tLastDamaged); return(true); } return(false); }
public override bool TryReset(long currentTime, ref BuffValueTypes flag) { if (CurrentTime - tLastDamaged >= 4000) { Owner.DamageHP(N); tLastDamaged = CurrentTime; } return(base.TryReset(currentTime, ref flag)); }
private static void SendBuffRemote(Character chr, BuffValueTypes flagsAdded, short pDelay) { var pw = new PacketWriter(ServerOperationCode.RemotePlayerSkillBuff); pw.WriteInt(chr.Id); pw.WriteBytes(chr.Buffs.ToMapBuffValues(flagsAdded)); pw.WriteShort(pDelay); chr.Map?.Send(pw, chr); }
public static void SendBuff(Character chr, BuffValueTypes flagsAdded, short pDelay = 0) { if (flagsAdded == 0) { return; } SendBuffLocal(chr, flagsAdded, pDelay); SendBuffRemote(chr, flagsAdded, pDelay); }
public override bool TryReset(DateTime currentTime, ref BuffValueTypes flag) { if (DateTime.UtcNow - _tLastDamaged >= TimeSpan.FromMilliseconds(4000)) { _owner.PrimaryStats.Health -= Value; _tLastDamaged = DateTime.UtcNow; } return(base.TryReset(currentTime, ref flag)); }
public static void SendPlayerBuffed(Character chr, BuffValueTypes pBuffs, short delay = 0) { Packet pw = new Packet(ServerMessages.GIVE_FOREIGN_BUFF); pw.WriteInt(chr.ID); BuffPacket.AddMapBuffValues(chr, pw, pBuffs); pw.WriteShort(delay); // the delay. usually 0, but is carried on through OnStatChangeByMobSkill / DoActiveSkill_(Admin/Party/Self)StatChange chr.Field.SendPacket(chr, pw, chr); }
public virtual bool TryReset(long currentTime, ref BuffValueTypes flag) { if (N == 0 || TM >= currentTime) { return(false); } flag |= Reset(); return(true); }
public static void SendDebuff(Character chr, BuffValueTypes removedFlags) { if (removedFlags == 0) { return; } SendDebuffLocal(chr, removedFlags); SendDebuffRemote(chr, removedFlags); }
public virtual bool TryReset(DateTime currentTime, ref BuffValueTypes flag) { if (Value == 0 || ExpireTime >= currentTime) { return(false); } flag |= Reset(); return(true); }
public void EncodeForRemote(ref BuffValueTypes flag, long currentTime, Action <BuffStat> func, BuffValueTypes specificFlag = BuffValueTypes.ALL) { if (!IsSet(currentTime) || !specificFlag.HasFlag(Flag)) { return; } flag |= Flag; func?.Invoke(this); }
public void EncodeForLocal(Packet pw, ref BuffValueTypes flag, long currentTime, BuffValueTypes specificFlag = BuffValueTypes.ALL) { if (!IsSet(currentTime) || !specificFlag.HasFlag(Flag)) { return; } flag |= Flag; pw.WriteShort(N); pw.WriteInt(R); pw.WriteShort((short)((TM - currentTime) / 100)); // If its not divided, it will not flash. }
private static void SendDebuffLocal(Character chr, BuffValueTypes removedFlags) { var pw = new PacketWriter(ServerOperationCode.SkillsGiveDebuff); pw.WriteUInt((uint)removedFlags); if (removedFlags.HasFlag(BuffValueTypes.SpeedBuffElement)) { pw.WriteByte(0); // FIX: This should be the 'movement info index' } chr.Send(pw); }
public virtual bool EncodeForCC(Packet pr, ref BuffValueTypes flag, long currentTime) { if (!IsSet(currentTime)) { return(false); } flag |= Flag; pr.WriteShort(N); pr.WriteInt(R); pr.WriteLong(TM); return(true); }
public void EncodeForLocal(PacketWriter pw, ref BuffValueTypes flag, DateTime currentTime, BuffValueTypes specificFlag = BuffValueTypes.All) { if (!IsActive(currentTime) || !specificFlag.HasFlag(Flag)) { return; } flag |= Flag; pw.WriteShort(Value); pw.WriteInt(ReferenceId); pw.WriteShort((short)((ExpireTime - currentTime).TotalMilliseconds / 100)); }
public void FinalizeBuff(BuffValueTypes added, short delay, bool sendPacket = true) { if (added == 0) { return; } if (!sendPacket) { return; } SendBuff(Parent, added, delay); }
public void FinalizeDebuff(BuffValueTypes removed, bool sendPacket = true) { if (removed == 0) { return; } if (!sendPacket) { return; } SendDebuff(Parent, removed); }
private static void SendBuffLocal(Character chr, BuffValueTypes flagsAdded, short pDelay) { var pw = new PacketWriter(ServerOperationCode.SkillsGiveBuff); chr.PrimaryStats.EncodeForLocal(pw, flagsAdded); pw.WriteShort(pDelay); if (flagsAdded.HasFlag(BuffValueTypes.SpeedBuffElement)) { pw.WriteByte(0); // FIX: This should be the 'movement info index' } pw.WriteLong(0); chr.Send(pw); }
public void Dispell() { var ps = Character.PrimaryStats; BuffValueTypes removed = 0; removed |= ps.BuffWeakness.Reset(); removed |= ps.BuffPoison.Reset(); removed |= ps.BuffCurse.Reset(); removed |= ps.BuffDarkness.Reset(); removed |= ps.BuffSeal.Reset(); removed |= ps.BuffStun.Reset(); FinalizeDebuff(removed); }
public virtual bool DecodeForCC(Packet pr, BuffValueTypes flag) { if (!flag.HasFlag(Flag)) { Reset(); return(false); } else { N = pr.ReadShort(); R = pr.ReadInt(); TM = pr.ReadLong(); return(true); } }
public static void SetTempStats(Character chr, BuffValueTypes pFlagsAdded, short pDelay = 0) { if (pFlagsAdded == 0) { return; } Packet pw = new Packet(ServerMessages.FORCED_STAT_SET); chr.PrimaryStats.EncodeForLocal(pw, pFlagsAdded); pw.WriteShort(pDelay); if ((pFlagsAdded & BuffValueTypes.SPEED_BUFF_ELEMENT) != 0) { pw.WriteByte(0); // FIX: This should be the 'movement info index' } chr.SendPacket(pw); }
public static void ResetTempStats(Character chr, BuffValueTypes removedFlags) { if (removedFlags == 0) { return; } Packet pw = new Packet(ServerMessages.FORCED_STAT_RESET); pw.WriteUInt((uint)removedFlags); if ((removedFlags & BuffValueTypes.SPEED_BUFF_ELEMENT) != 0) { pw.WriteByte(0); // FIX: This should be the 'movement info index' } chr.SendPacket(pw); }
public void FinalizeDebuff(BuffValueTypes removed, bool sendPacket = true) { if (removed == 0) { return; } Trace.WriteLine($"Removed buffs {removed}"); Character.FlushDamageLog(); if (!sendPacket) { return; } BuffPacket.ResetTempStats(Character, removed); MapPacket.SendPlayerDebuffed(Character, removed); }