Jump to content
Moopler
Razz

Code Packet based reactor mining

Recommended Posts

As Nexon patched no delay mining I thought I'd release my packet handlers as it isn't of much use to me. In order to turn this into a bot you would need to gather the following information:

  • Reactors spawned
  • Reactors despawned
  • Hitting the reactor
  • Reactor hit response

Packet handlers

Reactor spawned (Recv 0x036A in v116.2)

        private void OnReactorSpawned(PacketReader reader)
        {
            reader.Reset();

            uint id = reader.ReadUInt32();
            uint templateId = reader.ReadUInt32();
            reader.ReadInt8();
            short x = reader.ReadInt16();
            short y = reader.ReadInt16();

            ReactorModel reactor = new ReactorModel()
            {
                Id = id,
                TemplateId = templateId,
                Position = new Point(x, y)
            };

            Execute(() =>
            {
                Context.ReactorPool.Add(reactor);
            });
        
            ReactorQueue.Enqueue(reactor);                   
        }

Reactor despawned (Recv 0x036E)

        private void OnReactorDespawned(PacketReader reader)
        {
            reader.Reset();

            uint id = reader.ReadUInt32();

            ReactorModel reactor = Context.ReactorPool.Where(x => x.Id == id).FirstOrDefault();
            if (reactor != default(ReactorModel))
            {
                Execute(() =>
                {
                    Context.ReactorPool.Remove(reactor);
                });
            }

        }

Hitting the reactor (Send 0x02EE v116.2)

        private void SendHitReactorPacket(uint id)
        {
            PacketWriter writer = new PacketWriter(ChannelHeaders.S_HitHerbVein);
            writer.WriteUInt32(id);
            writer.WriteInt32(0);
            writer.WriteUInt32(3);
            writer.WriteUInt16(0);
            writer.WriteInt32(0);

            Connection.SendPacket(writer);
        }

Reactor response (Recv 0x0368 v116.2)

        private async void OnReactorHitResponse(PacketReader reader)
        {
            uint id = reader.ReadUInt32();

            await Task.Delay(600);
            SendHitReactorPacket(id);
        }

Loop (Bonus present from me)

        public void ReactorMiningLoop()
        {
            Task.Factory.StartNew(() =>
            {
                while(Connection.Connected)
                {
                    ReactorModel reactor = default(ReactorModel);
                    ReactorQueue.TryDequeue(out reactor);

                    if(reactor != default(ReactorModel))
                    {
                        SendHitReactorPacket(reactor.Id);
                    }                        

                    Thread.Sleep(500);
                }
            });
        }

Remarks

  • You can break herbs when you've chosen mining as your skill and vice versa
    • You will not receive a reward for this(no drop nor exp)
  • reader.Reset() is used to reset my packetreader to the beginning of the packet. It is of no use to you
  • You would have to play around with the delays and mining concurrency as Nexon implemented some measures to prevent no delaying

Have fun implementing this in your bots :yay:

  • Like 1

Share this post


Link to post
4 hours ago, xScriptZx said:

ND mining is not patched and I would be really happy if you delete this... xDDD

Lol :drop:

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×