Advertisement
shekohex

Update.cs

Jul 8th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Arab_TQ.Network.GamePackets
  5. {
  6.     public class Update : Writer, Interfaces.IPacket
  7.     {
  8.         public struct UpdateStruct
  9.         {
  10.             public uint Type;
  11.             public ulong Value1;
  12.             public ulong Value2;
  13.         }
  14.  
  15.         public class Flags
  16.         {
  17.  
  18.             public const ulong
  19.                 Normal = 0x0,
  20.                 FlashingName = 0x1,
  21.                 Poisoned = 0x2,
  22.                 Invisible = 0x4,
  23.                 XPList = 0x10,
  24.                 Dead = 0x20,
  25.                 TeamLeader = 0x40,
  26.                 StarOfAccuracy = 0x80,
  27.                 MagicShield = 0x100,
  28.                 Stigma = 0x200,
  29.                 Ghost = 0x400,
  30.                 FadeAway = 0x800,
  31.                 RedName = 0x4000,
  32.                 BlackName = 0x8000,
  33.                 ReflectMelee = 0x20000,
  34.                 Superman = 0x40000,
  35.                 Ball = 0x80000,
  36.                 Ball2 = 0x100000,
  37.                 Invisibility = 0x400000,
  38.                 Cyclone = 0x800000,
  39.                 Dodge = 0x4000000,
  40.                 Fly = 0x8000000,
  41.                 Intensify = 0x10000000,
  42.                 CastPray = 0x40000000,
  43.                 Praying = 0x80000000,
  44.                 HeavenBlessing = 0x200000000,
  45.                 TopGuildLeader = 0x400000000,
  46.                 TopDeputyLeader = 0x800000000,
  47.                 MonthlyPKChampion = 0x1000000000,
  48.                 WeeklyPKChampion = 0x2000000000,
  49.                 TopWarrior = 0x4000000000,
  50.                 TopTrojan = 0x8000000000,
  51.                 TopArcher = 0x10000000000,
  52.                 TopWaterTaoist = 0x20000000000,
  53.                 TopFireTaoist = 0x40000000000,
  54.                 TopNinja = 0x80000000000,
  55.                 ShurikenVortex = 0x400000000000,
  56.                 FatalStrike = 0x800000000000,
  57.                 Flashy = 0x1000000000000,
  58.                 Ride = 0x4000000000000,
  59.                TopSpouse = 1UL << 51,
  60.             OrangeSparkles = 1UL << 52,
  61.             PurpleSparkles = 1UL << 53,
  62.             Frightened = 1UL << 54,
  63.             SpeedIncreased = 1UL << 55,
  64.             MoveSpeedRecovered = 1UL << 56,
  65.             DivineShield = 1UL << 57,
  66.             Dizzy = 1UL << 58,
  67.             Freeze = 1UL << 59,
  68.             Confused = 1UL << 60;
  69.         }
  70.         public class Flags2
  71.         {
  72.  
  73.             public const ulong
  74.                WeeklyTop8Pk = 0x01,
  75.             WeeklyTop2PkGold = 0x2,
  76.             WeeklyTop2PkBlue = 0x4,
  77.             MonthlyTop8Pk = 0x8,
  78.             MontlyTop2Pk = 0x10,
  79.             MontlyTop3Pk = 0x20,
  80.             Top8Fire = 0x40,
  81.             Top2Fire = 0x80,
  82.             Top3Fire = 0x100,
  83.             Top8Water = 0x200,
  84.             Top2Water = 0x400,
  85.             Top3Water = 0x800,
  86.             Top8Ninja = 0x1000,
  87.             Top2Ninja = 0x2000,
  88.             Top3Ninja = 0x4000,
  89.             Top8Warrior = 0x8000,
  90.             Top2Warrior = 0x10000,
  91.             Top2Pirate = 0x1000000000000000,
  92.             Top3Warrior = 0x20000,
  93.             Top8Trojan = 0x40000,
  94.             Top2Trojan = 0x80000,
  95.             Top3Trojan = 0x100000,
  96.             Top8Archer = 0x200000,
  97.             Top2Archer = 0x400000,
  98.             Top3Archer = 0x800000,
  99.             Top3SpouseBlue = 0x1000000,
  100.             Top2SpouseBlue = 0x2000000,
  101.             Top3SpouseYellow = 0x4000000,
  102.             Contestant = 0x8000000,
  103.             ChainBoltActive = 0x10000000,
  104.             AzureShield = 0x20000000,
  105.             AzureShieldFade = 0x40000000,
  106.             CarryingFlag = 0x80000000,//blank next one?
  107.             TyrantAura = 0x400000000,
  108.             FendAura = 0x1000000000,
  109.             MetalAura = 0x4000000000,
  110.             WoodAura = 0x10000000000,
  111.             WaterAura = 0x40000000000,
  112.             FireAura = 17592186044416,
  113.             EarthAura = 0x400000000000,
  114.             SoulShackle = 140737488355328,
  115.             Oblivion = 0x1000000000000,
  116.             Top8Monk = 0x8000000000000,
  117.             Top2Monk = 0x10000000000000,
  118.             LionShield = 0x200000000000000,
  119.             OrangeHaloGlow = 1125899906842624,
  120.             LowVigorUnableToJump = 1125899906842624,
  121.             TopSpouse = 2251799813685248,
  122.             GoldSparkle = 4503599627370496,
  123.             VioletSparkle = 9007199254740992,
  124.             Dazed = 18014398509481984,//no movement
  125.             BlueRestoreAura = 36028797018963968,
  126.             MoveSpeedRecovered = 72057594037927936,
  127.             SuperShieldHalo = 144115188075855872,
  128.             HUGEDazed = 288230376151711744,//no movement
  129.             IceBlock = 576460752303423488, //no movement
  130.             Confused = 1152921504606846976,//reverses movement
  131.             Top3Monk = 0x20000000000000,
  132.             CannonBarrage = 1UL << 120,
  133.             BlackbeardsRage = 1UL << 121,
  134.             Fatigue = 1UL << 126,
  135.             TopMonk = 0x4000000000000L,
  136.             TopPirate = 1UL << 58;
  137.         }
  138.         public class Flags3
  139.         {
  140.             public const uint
  141.               MagicDefender = 0x01,
  142.               Assassin = 0x20000,
  143.               AutoHunting = (uint)1UL << 20,
  144.               BladeFlurry = 0x40000,
  145.               KineticSpark = 0x80000;
  146.         }
  147.         public const byte
  148.                 Hitpoints = 0,
  149.                 MaxHitpoints = 1,
  150.                 Mana = 2,
  151.                 MaxMana = 3,
  152.                 Money = 4,
  153.                 Experience = 5,
  154.                 PKPoints = 6,
  155.                 Class = 7,
  156.                 Stamina = 8,
  157.                 WHMoney = 9,
  158.                 Atributes = 10,
  159.                 Mesh = 11,
  160.                 Level = 12,
  161.                 Spirit = 13,
  162.                 Vitality = 14,
  163.                 Strength = 15,
  164.                 Agility = 16,
  165.                 HeavensBlessing = 17,
  166.                 DoubleExpTimer = 18,
  167.                 CursedTimer = 20,
  168.                 Reborn = 22,
  169.                 StatusFlag = 25,
  170.                 HairStyle = 26,
  171.                 XPCircle = 27,
  172.                 LuckyTimeTimer = 28,
  173.                 ConquerPoints = 29,
  174.                 OnlineTraining = 31,
  175.                 MentorBattlePower = 36,
  176.                 Merchant = 38,
  177.                 VIPLevel = 39,
  178.                 QuizPoints = 40,
  179.                 EnlightPoints = 41,
  180.                 HonorPoints = 42,
  181.                 GuildBattlepower = 44,
  182.                 BoundConquerPoints = 45,
  183.                 RaceShopPoints = 47,
  184.                 MagicDefenderIcone = 49,
  185.                 DefensiveStance = 56;
  186.  
  187.         byte[] Buffer;
  188.         const byte minBufferSize = 40;
  189.         public Update(bool Create)
  190.         {
  191.             if (Create)
  192.             {
  193.                 Buffer = new byte[minBufferSize + 8];
  194.                 WriteUInt16(minBufferSize, 0, Buffer);
  195.                 WriteUInt16(10017, 2, Buffer);
  196.                 WriteUInt32((uint)Time32.timeGetTime().GetHashCode(), 4, Buffer);
  197.             }
  198.         }
  199.  
  200.         public uint UID
  201.         {
  202.             get { return BitConverter.ToUInt32(Buffer, 8); }
  203.             set { WriteUInt32(value, 8, Buffer); }
  204.         }
  205.         public uint self
  206.         {
  207.             get { return BitConverter.ToUInt32(Buffer, 12); }
  208.             set { WriteUInt32(value, 12, Buffer); }
  209.         }
  210.         public uint UpdateCount
  211.         {
  212.             get { return BitConverter.ToUInt32(Buffer, 12); }
  213.             set
  214.             {
  215.                 byte[] buffer = new byte[minBufferSize + 8 + 24 * value];
  216.                 Buffer.CopyTo(buffer, 0);
  217.                 WriteUInt16((ushort)(minBufferSize + 24 * value), 0, buffer);
  218.                 Buffer = buffer;
  219.                 WriteUInt32(value, 12, Buffer);
  220.             }
  221.         }
  222.         public void Append(byte type, byte value)
  223.         {
  224.             this.UpdateCount++;
  225.             ushort offset = (ushort)(12 + 4 + ((this.UpdateCount - 1) * 20));
  226.             Writer.WriteUInt32(type, offset, this.Buffer);
  227.             Writer.WriteUInt64((ulong)value, offset + 4, this.Buffer);
  228.             Writer.WriteUInt64(value, offset + 8, Buffer);
  229.         }
  230.         public void Append(byte type, ushort value)
  231.         {
  232.             this.UpdateCount++;
  233.             ushort offset = (ushort)(12 + 4 + ((this.UpdateCount - 1) * 20));
  234.             Writer.WriteUInt32(type, offset, this.Buffer);
  235.             Writer.WriteUInt64((ulong)value, offset + 4, this.Buffer);
  236.             Writer.WriteUInt64(value, offset + 4, Buffer);
  237.         }
  238.  
  239.         public void AppendFull(byte type, ulong val1, ulong val2, uint val3)
  240.         {
  241.             UpdateCount = UpdateCount + 1;
  242.             ushort offset = (ushort)(16 + ((UpdateCount - 1) * 20));
  243.             WriteUInt32(type, offset, Buffer);
  244.             WriteUInt64(val1, offset + 4, Buffer);
  245.             WriteUInt64(val2, offset + 12, Buffer);
  246.             WriteUInt32(val3, offset + 20, Buffer);
  247.         }
  248.  
  249.         public void PoPAppend(byte type, ulong val1, ulong val2)
  250.         {
  251.             UpdateCount = UpdateCount + 1;
  252.             ushort offset = (ushort)(16 + ((UpdateCount - 1) * 20));
  253.             WriteUInt32(type, offset, Buffer);
  254.             WriteUInt64(val1, offset + 8, Buffer);
  255.             WriteUInt64(val2, offset + 16, Buffer);
  256.         }
  257.         public void Append(byte type, uint[] value)
  258.         {
  259.             UpdateCount = UpdateCount + 1;
  260.             ushort offset = (ushort)(12 + 4 + (UpdateCount - 1) * 24);
  261.             WriteUInt32(type, offset, Buffer);
  262.             for (byte x = 0; x < value.Length; x++)
  263.                 WriteUInt32(value[x], (ushort)((offset + 4) + x * 4), Buffer);
  264.         }
  265.         public void Append(byte type, uint value)
  266.         {
  267.             this.UpdateCount++;
  268.             ushort offset = (ushort)(12 + 4 + ((this.UpdateCount - 1) * 20));
  269.             Writer.WriteUInt32(type, offset, this.Buffer);
  270.             Writer.WriteUInt64((ulong)value, offset + 4, this.Buffer);
  271.         }
  272.  
  273.         public void Append(byte type, ulong value)
  274.         {
  275.             this.UpdateCount++;
  276.             ushort offset = (ushort)(12 + 4 + ((this.UpdateCount - 1) * 20));
  277.             Writer.WriteUInt32(type, offset, this.Buffer);
  278.             Writer.WriteUInt64(value, offset + 4, this.Buffer);
  279.         }
  280.  
  281.         public void Append2(byte type, byte value)
  282.         {
  283.             this.UpdateCount++;
  284.             ushort offset = (ushort)(12 + 4 + ((this.UpdateCount - 1) * 20));
  285.             Writer.WriteUInt32(type, offset, this.Buffer);
  286.             Writer.WriteUInt64((ulong)value, offset + 12, this.Buffer);
  287.         }
  288.         public void Append2(byte type, ushort value)
  289.         {
  290.             this.UpdateCount++;
  291.             ushort offset = (ushort)(12 + 4 + ((this.UpdateCount - 1) * 20));
  292.             Writer.WriteUInt32(type, offset, this.Buffer);
  293.             Writer.WriteUInt64((ulong)value, offset + 12, this.Buffer);
  294.         }
  295.  
  296.         public void Append2(byte type, uint value)
  297.         {
  298.             this.UpdateCount++;
  299.             ushort offset = (ushort)(12 + 4 + ((this.UpdateCount - 1) * 20));
  300.             Writer.WriteUInt32(type, offset, this.Buffer);
  301.             Writer.WriteUInt64((ulong)value, offset + 12, this.Buffer);
  302.         }
  303.  
  304.         public void Append2(byte type, ulong value)
  305.         {
  306.             this.UpdateCount++;
  307.             ushort offset = (ushort)(12 + 4 + ((this.UpdateCount - 1) * 20));
  308.             Writer.WriteUInt32(type, offset, this.Buffer);
  309.             Writer.WriteUInt64(value, offset + 12, this.Buffer);
  310.         }
  311.  
  312.         public void Clear()
  313.         {
  314.             byte[] buffer = new byte[minBufferSize + 8];
  315.             WriteUInt16(minBufferSize, 0, Buffer);
  316.             WriteUInt16(10017, 2, Buffer);
  317.             WriteUInt32(UID, 8, buffer);
  318.             WriteUInt32((uint)Time32.timeGetTime().GetHashCode(), 4, Buffer);
  319.             Buffer = buffer;
  320.         }
  321.  
  322.         public List<UpdateStruct> Updates
  323.         {
  324.             get
  325.             {
  326.                 List<UpdateStruct> structs = new List<UpdateStruct>();
  327.                 ushort offset = 16;
  328.                 if (UpdateCount > 0)
  329.                 {
  330.                     for (int c = 0; c < UpdateCount; c++)
  331.                     {
  332.                         UpdateStruct st = new UpdateStruct();
  333.                         st.Type = BitConverter.ToUInt32(Buffer, offset); offset += 4;
  334.                         st.Value1 = BitConverter.ToUInt64(Buffer, offset); offset += 8;
  335.                         st.Value2 = BitConverter.ToUInt64(Buffer, offset); offset += 8;
  336.                         structs.Add(st);
  337.                     }
  338.                 }
  339.                 return structs;
  340.             }
  341.         }
  342.  
  343.         public byte[] ToArray()
  344.         {
  345.             return Buffer;
  346.         }
  347.  
  348.         public void Deserialize(byte[] buffer)
  349.         {
  350.             Buffer = buffer;
  351.         }
  352.  
  353.         public void Send(Client.GameClient client)
  354.         {
  355.             client.Send(Buffer);
  356.         }
  357.         public void Append(byte type, byte value, byte second, byte second2, byte second3, byte second4, byte second5, byte second6, byte second7)
  358.         {
  359.             UpdateCount = UpdateCount + 1;
  360.             ushort offset = (ushort)(UpdateCount * 16);//12
  361.             WriteUInt32(type, offset, Buffer);
  362.             WriteUInt64(value, offset + 4, Buffer);
  363.             WriteByte(second, offset + 12, Buffer);
  364.             WriteByte(second2, offset + 13, Buffer);
  365.             WriteByte(second3, offset + 14, Buffer);
  366.             WriteByte(second4, offset + 15, Buffer);
  367.             WriteByte(second5, offset + 16, Buffer);
  368.             WriteByte(second6, offset + 17, Buffer);
  369.             WriteByte(second7, offset + 18, Buffer);
  370.         }
  371.         public void Append(ulong val1, ulong val2, uint val3, uint val4, uint val5, uint val6, uint val7)
  372.         {
  373.             UpdateCount = 2;
  374.             WriteUInt32(0x19, 16, Buffer);
  375.             WriteUInt64(val1, 20, Buffer);
  376.             WriteUInt64(val2, 28, Buffer);
  377.             WriteUInt32(val3, 36, Buffer);
  378.             WriteUInt32(val4, 40, Buffer);
  379.             WriteUInt32(val5, 44, Buffer);
  380.             WriteUInt32(val6, 48, Buffer);
  381.             WriteUInt32(val7, 52, Buffer);
  382.         }
  383.     }
  384. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement