Advertisement
XConquer

AutoLooter

Oct 7th, 2022
1,166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 13.17 KB | None | 0 0
  1. World.cs
  2. void Bufferscallback Agregar :
  3.  
  4. #region AutoHuntGold
  5.             if (client.Player.Auto)
  6.             {
  7.                AutoHunt.Looter(client);
  8.             }
  9.             #endregion
  10.  
  11. misma clase void Characterscallback agregas el mismo codigo.
  12.  
  13. ================================================================
  14. AutoHunt.cs o class AutoHunt
  15.  
  16.    public unsafe class AutoHunt
  17.     {
  18.         public enum Mode : byte
  19.         {
  20.             None,
  21.             Start,
  22.             EndAuto,
  23.             EXPGained,
  24.             Unknown4,
  25.             Unknown5,
  26.             KilledBy,
  27.             ChangedMap
  28.         }
  29.         byte[] Packet;
  30.  
  31.         public AutoHunt()
  32.         {
  33.             Packet = new byte[100];
  34.             fixed (byte* Pack = Packet)
  35.             {
  36.                 *(ushort*)(Pack + (Packet.Length - 8)) = 0;
  37.                 *((ushort*)(Pack + 2)) = (ushort)PacketID.AutoHunt;
  38.             }
  39.         }
  40.         public Mode Action
  41.         {
  42.             get { return (Mode)Packet[4]; }
  43.             set { fixed (byte* Pack = Packet) *((byte*)(Pack + 4)) = (byte)value; }
  44.         }
  45.         public ushort Icon
  46.         {
  47.             get { return BitConverter.ToUInt16(Packet, 6); }
  48.             set { fixed (byte* Pack = Packet) *((ushort*)(Pack + 6)) = value; }
  49.         }
  50.         public ulong EXPGained
  51.         {
  52.             get { return BitConverter.ToUInt64(Packet, 14); }
  53.             set { fixed (byte* Pack = Packet) *((ulong*)(Pack + 14)) = value; }
  54.         }
  55.         public uint Unknown
  56.         {
  57.             get { return BitConverter.ToUInt32(Packet, 22); }
  58.             set { fixed (byte* Pack = Packet) *((uint*)(Pack + 22)) = value; }
  59.         }
  60.         public string KilledName
  61.         {
  62.             set { Writer.WriteStringWithLength(value, 23, Packet); }
  63.         }
  64.         public byte[] ToArray()
  65.         {
  66.             fixed (void* Pack = Packet)
  67.                 return Packet;
  68.         }
  69.         public void Deserialize(byte[] Pack)
  70.         {
  71.             Packet = Pack;
  72.         }
  73.         public static void Looter(GameState client)
  74.         {
  75.          
  76.  
  77.           //  if (client.Inventory.Count > 39)
  78.             {
  79.  
  80.                
  81.                 {
  82.                   //  if (client.Inventory.Count < 40)
  83.                     {
  84.                         foreach (var obj in client.Screen.Objects)
  85.                         {
  86.                             if (obj.MapObjType == MapObjectType.Item)
  87.                             {
  88.                                 var floorItem = obj as FloorItem;
  89.                                 if (floorItem == null) continue;
  90.                                 if (floorItem.ValueType == FloorItem.FloorValueType.Money)
  91.                                 {
  92.                                     client.Send(Constants.PickupGold(floorItem.Value));
  93.                                     client.SendScreen(floorItem, false);
  94.                                     client.Player.Money += floorItem.Value;
  95.                                     floorItem.Type = 2;
  96.                                     client.RemoveScreenSpawn(floorItem, true);
  97.                                 }
  98.                                 if (floorItem.ValueType == FloorItem.FloorValueType.ConquerPoints)
  99.                                 {
  100.                                     client.Send(Constants.PickupConquerPoints(floorItem.Value));
  101.                                     client.SendScreen(floorItem, false);
  102.                                     client.Player.ConquerPoints += floorItem.Value;
  103.                                     floorItem.Type = 2;
  104.                                     client.RemoveScreenSpawn(floorItem, true);
  105.                                 }
  106.                             }
  107.                         }
  108.                     }
  109.                 }
  110.              
  111.                 return;
  112.             }
  113.         }
  114.         public static void Process(byte[] packet, Client.GameState client)
  115.         {
  116.             AutoHunt AutoHunt = new AutoHunt();
  117.             AutoHunt.Deserialize(packet);
  118.             switch (AutoHunt.Action)
  119.             {
  120.                 case AutoHunt.Mode.Start:
  121.                     {
  122.                         AutoHunt.Action = AutoHunt.Mode.Start;
  123.                         client.Player.AddFlag3((ulong)Update.Flags3.AutoHunting);
  124.                         client.Player.autohuntxp = 0;
  125.                         client.Player.Auto = true;
  126.                         break;
  127.                     }
  128.                 case AutoHunt.Mode.EndAuto:
  129.                     {
  130.                         AutoHunt.Action = AutoHunt.Mode.EndAuto;
  131.                         AutoHunt.EXPGained = client.Player.autohuntxp;
  132.                         client.Player.RemoveFlag3((ulong)Update.Flags3.AutoHunting);
  133.                         client.Player.autohuntxp = 0;
  134.                         client.Player.Auto = false;
  135.                         break;
  136.                     }
  137.                 case AutoHunt.Mode.EXPGained:
  138.                     {
  139.                         AutoHunt.Action = AutoHunt.Mode.EXPGained;
  140.                         AutoHunt.EXPGained = client.Player.autohuntxp;
  141.                         client.Player.RemoveFlag3((ulong)Update.Flags3.AutoHunting);
  142.                         client.Player.autohuntxp = 0;
  143.                         client.Player.Auto = false;
  144.                         break;
  145.                     }
  146.                 default: System.Console.WriteLine("[AutoHunt] Unknown Action: " + AutoHunt.Action + ""); break;
  147.             }
  148.             client.Send(AutoHunt.ToArray());
  149.         }
  150.     }
  151. ==============================================
  152. PacketHandler.cs
  153.  #region AutoHunting (1070) o case 1070 como quieras, la comentas y agregas esta nueva :
  154. case 1070:
  155.                     {
  156.                         AutoHunt.Process(packet, client);
  157.                         break;
  158.                     }
  159.  
  160.  
  161. en la misma clase void LoginMessages te tirara error el region autohunt de esa variable lo borras y pones este
  162.  client.Send(new AutoHunt() { Icon = 341 }.ToArray());
  163.  
  164. Misma clase buscas void pickupitems y lo reemplazas por el Siguiente :
  165.  private static void PickupItem(FloorItem floorItem, Client.GameState client)
  166.         {
  167.             FloorItem item;
  168.             if ((!client.Screen.TryGetFloorItem(floorItem.UID, out floorItem) || client.Trade.InTrade) || ((client.Player.X != floorItem.X) || (client.Player.Y != floorItem.Y)))
  169.             {
  170.                 return;
  171.             }
  172.             uint uID = (floorItem.Owner == null) ? 0 : floorItem.Owner.Player.UID;
  173.             if ((((uID == 0) || (uID != client.Player.UID)) && (uID != 0)) && (Time32.Now < floorItem.OnFloor.AddSeconds(10)))
  174.             {
  175.                 if ((client.Team != null) && client.Team.IsTeammate(uID))
  176.                 {
  177.                     if (client.Team.PickupItems && (floorItem.ValueType == FloorItem.FloorValueType.Item))
  178.                     {
  179.                         if ((floorItem.ItemID != 0x109a00) && (floorItem.ItemID != 0x109a01))
  180.                         {
  181.                             goto Label_0154;
  182.                         }
  183.                     }
  184.                     else if (client.Team.PickupMoney && (floorItem.ValueType != FloorItem.FloorValueType.Item))
  185.                     {
  186.                         goto Label_0154;
  187.                     }
  188.                 }
  189.                 client.Send(Constants.FloorItemNotAvailable);
  190.                 return;
  191.             }
  192.         Label_0154:
  193.             item = new FloorItem(true);
  194.             if (floorItem.ValueType != FloorItem.FloorValueType.Item)
  195.             {
  196.                 client.Map.RemoveFloorItem(floorItem);
  197.             }
  198.             item.Type = 3;
  199.             item.UID = client.Player.UID;
  200.             item.X = client.Player.X;
  201.             item.Y = client.Player.Y;
  202.             switch (floorItem.ValueType)
  203.             {
  204.                 case FloorItem.FloorValueType.Item:
  205.                     if (client.Inventory.Count > 0x27)
  206.                     {
  207.                         client.Send(Constants.FullInventory);
  208.                         return;
  209.                     }
  210.                     client.SendScreen(item, false);
  211.                     floorItem.Type = 2;
  212.                     client.RemoveScreenSpawn(floorItem, true);
  213.                     client.Map.RemoveFloorItem(floorItem);
  214.                     if (Database.ConquerItemInformation.BaseInformations.ContainsKey(floorItem.Item.ID))
  215.                         client.Send(Constants.PickupItem(Database.ConquerItemInformation.BaseInformations[floorItem.Item.ID].Name));
  216.                     foreach (Client.GameState state in Kernel.GamePool.Values)
  217.                     {
  218.                         state.Screen.Remove(floorItem);
  219.                     }
  220.                     if (floorItem.Item.MobDropped)
  221.                     {
  222.                         Database.ConquerItemInformation iteminfo = new Database.ConquerItemInformation(floorItem.Item.ID, floorItem.Item.Plus);
  223.                         #region AutoHunt
  224.                         if (client.Player.Auto)
  225.                         {
  226.                             AutoHunt AutoHunt = new AutoHunt();
  227.                             AutoHunt.Action = AutoHunt.Mode.Unknown5;
  228.                             AutoHunt.EXPGained = client.Player.autohuntxp;
  229.                             client.Send(AutoHunt.ToArray());
  230.                             AutoHunt.Action = AutoHunt.Mode.Unknown5;
  231.                             AutoHunt.EXPGained = client.Player.autohuntxp;
  232.                             client.Send(AutoHunt.ToArray());
  233.                             client.IncreaseExperience(client.Player.autohuntxp, false);
  234.                             client.Player.RemoveFlag3((ulong)Update.Flags3.AutoHunting);
  235.                             client.Player.autohuntxp = 0;
  236.                             client.Player.Auto = false;
  237.                             client.Inventory.Add(floorItem.Item, Game.Enums.ItemUse.CreateAndAdd);
  238.                         }
  239.                         #endregion
  240.  
  241.                         if (iteminfo.BaseInformation.StackSize == 0)
  242.                         {
  243.                             client.Inventory.Add(floorItem.Item, Game.Enums.ItemUse.CreateAndAdd);
  244.                         }
  245.                         else
  246.                         {
  247.                             ConquerItem _ExistingItem;
  248.                             if (client.Inventory.GetStackContainer(iteminfo.BaseInformation.ID, iteminfo.BaseInformation.StackSize, 1, out _ExistingItem))
  249.                             {
  250.                                 _ExistingItem.StackSize++;
  251.                                 Database.ConquerItemTable.UpdateStack(_ExistingItem);
  252.                                 _ExistingItem.Mode = Game.Enums.ItemMode.Update;
  253.                                 _ExistingItem.Send(client);
  254.                             }
  255.                             else
  256.                             {
  257.                                 floorItem.Item.StackSize = 1;
  258.                                 client.Inventory.Add(floorItem.Item, Game.Enums.ItemUse.CreateAndAdd);
  259.                             }
  260.                         }
  261.                         //Data data = new Data(true);
  262.                         //data.ID = Data.OpenCustom;
  263.                         //data.UID = client.Player.UID;
  264.                         //data.TimeStamp = Time32.Now;
  265.                         //data.dwParam = 3382;
  266.                         //data.wParam1 = client.Player.X;
  267.                         //data.wParam2 = client.Player.Y;
  268.                         //client.Send(data);
  269.                     }
  270.                     else
  271.                     {
  272.                         client.Inventory.Add(floorItem.Item, Game.Enums.ItemUse.Add);
  273.                         //Data data = new Data(true);
  274.                         //data.ID = Data.OpenCustom;
  275.                         //data.UID = client.Player.UID;
  276.                         //data.TimeStamp = Time32.Now;
  277.                         //data.dwParam = 3382;
  278.                         //data.wParam1 = client.Player.X;
  279.                         //data.wParam2 = client.Player.Y;
  280.                         //client.Send(data);
  281.                     }
  282.                     return;
  283.  
  284.                 case FloorItem.FloorValueType.Money:
  285.                     client.Send(Constants.PickupGold(floorItem.Value));
  286.                     client.SendScreen(item, false);
  287.                     client.Player.Money += floorItem.Value;
  288.                     floorItem.Type = 2;
  289.                     client.RemoveScreenSpawn(floorItem, true);
  290.                     return;
  291.  
  292.                 case FloorItem.FloorValueType.ConquerPoints:
  293.                     client.Send(Constants.PickupConquerPoints(floorItem.Value));
  294.                     client.SendScreen(item, false);
  295.                     client.Player.ConquerPoints += floorItem.Value;// Math.Min(floorItem.Value, 300);
  296.                     floorItem.Type = 2;
  297.                     client.RemoveScreenSpawn(floorItem, true);
  298.                     return;
  299.             }
  300.         }
  301. ===================================================================
  302.  
  303. Tecnicamente ya deberia funcionar Bien tanto el agarrar items como Oro. tambien hace falta añadirlo en otros lados como ser en el caso de teletransporte, en caso de que salga eventos o en caso de que te maten que Auto Reviva y siga el camino.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement