Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Project_Terror_v2.Game.MsgServer
- {
- public unsafe class MsgUpdate
- {
- public class OnlineTraining
- {
- public const byte
- Show = 0,
- InTraining = 1,
- Review = 2,
- IncreasePoints = 3,
- ReceiveExperience = 4,
- Remove = 5;
- }
- [Flags]
- public enum Flags : int
- {
- Normal = 3,//0x0,
- FlashingName = 0,
- Poisoned = 1,
- Invisible = 2,
- XPList = 4,
- Dead = 5,
- TeamLeader = 6,
- StarOfAccuracy = 7,
- MagicShield = 8,
- Shield = 8,
- Stigma = 9,
- Ghost = 10,
- FadeAway = 11,
- RedName = 14,
- BlackName = 15,
- ReflectMelee = 17,
- Superman = 18,
- Ball = 19,
- Ball2 = 20,
- Invisibility = 22,
- Cyclone = 23,
- Dodge = 26,
- Fly = 27,
- Intensify = 28,
- CastPray = 30,
- Praying = 31,
- Cursed = 32,
- HeavenBlessing = 33,
- TopGuildLeader = 34,
- TopDeputyLeader = 35,
- MonthlyPKChampion = 36,
- WeeklyPKChampion = 37,
- TopWarrior = 38,
- TopTrojan = 39,
- TopArcher = 40,
- TopWaterTaoist = 41,
- TopFireTaoist = 42,
- TopNinja = 43,
- ShurikenVortex = 46,
- FatalStrike = 47,
- Flashy = 48,
- Ride = 50,
- TopSpouse = 51,
- OrangeSparkle = 52,
- DarkSparkle = 53,
- FreezeSmall = 54,
- HeavenSparkle = 55,
- IncMoveSpeed = 56,
- GodlyShield = 57,
- Stun = 58,
- Freeze = 59,
- ChaosCycle = 60,
- Top8Weekly = 63,
- Top4Weekly = 64,
- Top2Weekly = 65,
- ChaintBolt = 92,
- AzureShield = 93,
- ScurvyBomb = 96,//that is use for abuse.
- TyrantAura = 98,
- FeandAura = 100,
- MetalAura = 102,
- WoodAura = 104,
- WaterAura = 106,
- FireAura = 108,
- EartAura = 110,
- SoulShackle = 111,
- Oblivion = 112,
- ShieldBlock = 113,
- TopMonk = 114,
- TopPirate = 122,
- PoisonStar = 119,
- CannonBarrage = 120,
- BlackbeardsRage = 121,
- DefensiveStance = 126,
- MagicDefender = 128,
- RemoveName = 129,
- PurpleBall = 131,
- BlueBall = 132,
- PathOfShadow = 145,
- BladeFlurry = 146,
- KineticSpark = 147,
- //AutoHunt = 148,
- SuperCyclone = 150,
- DragonFlow = 148,//20
- DragonFury = 158,//30
- DragonCyclone = 159,//31
- DragonSwing = 160//32
- }
- [Flags]
- public enum DataType : uint
- {
- Hitpoints = 0,
- MaxHitpoints = 1,
- Mana = 2,
- MaxMana = 3,
- Money = 4,
- Experience = 5,
- PKPoints = 6,
- Class = 7,
- Stamina = 8,
- WHMoney = 9,
- Atributes = 10,
- Mesh = 11,
- Level = 12,
- Spirit = 13,
- Vitality = 14,
- Strength = 15,
- Agility = 16,
- HeavensBlessing = 17,
- DoubleExpTimer = 18,
- CursedTimer = 20,
- Reborn = 22,
- VirtutePoints = 23,
- StatusFlag = 25,
- HairStyle = 26,
- XPCircle = 27,
- LuckyTimeTimer = 28,
- ConquerPoints = 29,
- OnlineTraining = 31,
- ExtraBattlePower = 36,
- ArsenalBp = 37,
- Merchant = 38,
- VIPLevel = 39,
- QuizPoints = 40,
- EnlightPoints = 41,
- ClanShareBp = 42,
- GuildBattlePower = 44,
- Contestant = 48,
- AzureShield = 49,
- FirsRebornClass = 51,
- SecondRebornClass = 50,
- Team = 52,
- SoulShackle = 54,
- Fatigue = 55,
- DefensiveStance = 56,
- WoodResist = 60,
- WaterResist = 61,
- FireResist = 62,
- MetalResist = 63,
- EarthResist = 64,
- Blessed = 66,
- gMagicAtk = 67,
- gAttack = 68,
- IncreaseMStrike = 60,
- IncreasePStrike = 59,
- IncreaseImunity = 61,
- IncreaseBreack = 62,
- IncreaseAntiBreack = 63,
- IncreaseMaxHp = 64,
- IncreasePAttack = 65,
- IncreaseMAttack = 66,
- IncreaseFinalPDamage = 67,
- IncreaseFinalMDamage = 68,
- IncreaseFinalPAttack = 69,
- IncreaseFinalMAttack = 70,
- ExpProtection = 73,
- DragonSwing = 75,
- DragonFury = 74
- }
- private byte[] Buffer;
- public unsafe MsgUpdate(uint count = 1)
- {
- Buffer = new byte[40 + DataPacket.SizeOf_Data * count + 8];
- fixed (byte* buff = Buffer)
- {
- UpdatePacket* upd = (UpdatePacket*)buff;
- upd->Leng = (ushort)(40 + DataPacket.SizeOf_Data * count);
- upd->Type = Game.GamePackets.Update;
- upd->Stamp = Extensions.Time32.Now.GetHashCode();
- upd->Count = count;
- *(ulong*)(buff + (Buffer.Length - 8)) = ServerSockets.Packet.TQServer;
- }
- }
- public uint UID
- {
- get
- {
- fixed (byte* iUpdate = Buffer)
- return ((UpdatePacket*)iUpdate)->UID;
- }
- set
- {
- fixed (byte* iUpdate = Buffer)
- ((UpdatePacket*)iUpdate)->UID = value;
- }
- }
- public void Append(DataType ID, long Value, int UpdateNumber = 0)
- {
- fixed (byte* iUpdate = Buffer)
- {
- *((DataPacket*)(iUpdate + 16 + (UpdateNumber * DataPacket.SizeOf_Data))) =
- DataPacket.Create(ID, Value);
- }
- }
- public void Append(DataType ID, uint Flag,uint Time, uint Dmg, uint Level , int UpdateNumber = 0)
- {
- uint[] Value = new uint[5] { Flag, Time, Dmg, Level, 0 }; // 20 byte`s
- fixed (byte* iUpdate = Buffer)
- {
- *((DataPacket*)(iUpdate + 16 + (UpdateNumber * DataPacket.SizeOf_Data))) =
- DataPacket.Create(ID, Value);
- }
- }
- public void Append(DataType ID, uint[] Value, int UpdateNumber = 0)
- {
- fixed (byte* iUpdate = Buffer)
- {
- *((DataPacket*)(iUpdate + 16 + (UpdateNumber * DataPacket.SizeOf_Data))) =
- DataPacket.Create(ID, Value);
- }
- }
- public byte* GetArray()
- {
- fixed (byte* buff = Buffer)
- return buff;
- }
- public static implicit operator byte*(MsgUpdate big)
- {
- fixed (byte* buff = big.Buffer)
- return buff;
- }
- public struct DataPacket
- {
- public const byte SizeOf_Data = 28;
- public DataType Typ;
- public unsafe fixed byte Value[SizeOf_Data - 4];
- public unsafe static DataPacket Create(DataType ID, long value)
- {
- DataPacket dat = new DataPacket();
- dat.Typ = ID;
- *(long*)(dat.Value) = value;
- return dat;
- }
- public unsafe static DataPacket Create(DataType ID, uint[] value)
- {
- DataPacket dat = new DataPacket();
- dat.Typ = ID;
- byte offset = 0;
- for (int x = 0; x < value.Length; x++)
- {
- *(uint*)(dat.Value + offset) = value[x];
- offset += 4;
- }
- return dat;
- }
- }
- public struct UpdatePacket
- {
- public ushort Leng;
- public ushort Type;
- public int Stamp;
- public uint UID;
- public uint Count;
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Extensions
- {
- public class BitVector32
- {
- public uint[] bits;
- public int Size { get { return 32 * bits.Length; } }
- public BitVector32(int BitCount)
- {
- int sections = BitCount / 32;
- if (BitCount % 32 != 0)
- sections += 1;
- bits = new uint[sections];
- }
- public void Add(int index)
- {
- if (index < Size)
- {
- int idx = index / 32;
- uint bites = (uint)(1 << (index % 32));
- bits[idx] |= bites;
- }
- }
- public void Remove(int index)
- {
- if (index < Size)
- {
- int idx = index / 32;
- uint bites = (uint)(1 << (index % 32));
- bits[idx] &= ~bites;
- }
- }
- public bool Contain(int index)
- {
- if (index > Size) return false;
- int idx = index / 32;
- uint bites = (uint)(1 << (index % 32));
- return ((bits[idx] & bites) == bites);
- }
- public void Clear()
- {
- ushort siz = (byte)(Size / 32);
- for (byte x = 0; x < siz; x++)
- {
- bits[x] = 0;
- }
- }
- }
- }
- public void AddSpellFlag(Game.MsgServer.MsgUpdate.Flags Flag, int Secounds, bool RemoveOnDead, int StampSecounds = 0)
- {
- if (BitVector.ContainFlag((int)Flag))
- BitVector.TryRemove((int)Flag);
- AddFlag(Flag, Secounds, RemoveOnDead, StampSecounds);
- }
- public bool AddFlag(Game.MsgServer.MsgUpdate.Flags Flag, int Secounds, bool RemoveOnDead,int StampSecounds =0, uint showamount = 0, uint amount =0)
- {
- if (!BitVector.ContainFlag((int)Flag))
- {
- BitVector.TryAdd((int)Flag, Secounds, RemoveOnDead, StampSecounds);
- UpdateFlagOffset();
- if ((int)Flag >= 52 && (int)Flag <= 60)
- {
- unsafe
- {
- Game.MsgServer.MsgGameUpdate upd = new Game.MsgServer.MsgGameUpdate(1);
- upd.UID = UID;
- upd.Append((Game.MsgServer.MsgGameUpdate.DataType)Flag, true, showamount, (uint)Secounds, amount, 0);
- Send(upd);
- }
- }
- return true;
- }
- return false;
- }
- public bool RemoveFlag(Game.MsgServer.MsgUpdate.Flags Flag)
- {
- if (BitVector.ContainFlag((int)Flag))
- {
- BitVector.TryRemove((int)Flag);
- UpdateFlagOffset();
- if ((int)Flag >= 52 && (int)Flag <= 60)
- {
- unsafe
- {
- Game.MsgServer.MsgGameUpdate upd = new Game.MsgServer.MsgGameUpdate(1);
- upd.UID = UID;
- upd.Append((Game.MsgServer.MsgGameUpdate.DataType)Flag, false, 0, 0, 0, 0);
- Send(upd);
- }
- }
- return true;
- }
- return false;
- }
- public bool UpdateFlag(Game.MsgServer.MsgUpdate.Flags Flag, int Secounds, bool SetNewTimer, int MaxTime)
- {
- return BitVector.UpdateFlag((int)Flag, Secounds, SetNewTimer, MaxTime);
- }
- public void ClearFlags()
- {
- BitVector.GetClear();
- UpdateFlagOffset();
- }
- public bool ContainFlag(Game.MsgServer.MsgUpdate.Flags Flag)
- {
- return BitVector.ContainFlag((int)Flag);
- }
- public bool CheckInvokeFlag(Game.MsgServer.MsgUpdate.Flags Flag, Extensions.Time32 timer32)
- {
- return BitVector.CheckInvoke((int)Flag, timer32);
- }
- private unsafe void UpdateFlagOffset()
- {
- for (int x = 0; x < BitVector.bits.Length; x++)
- *(uint*)(SpawnPacket + BitVector32 + x * 4) = BitVector.bits[x];
- SendUpdate(BitVector.bits, Game.MsgServer.MsgUpdate.DataType.StatusFlag, true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement