|
You last visited: Today at 21:17
Advertisement
[Relase] Jellbot by JD in .NET
Discussion on [Relase] Jellbot by JD in .NET within the DarkOrbit forum part of the Browsergames category.
06/05/2013, 10:47
|
#1
|
elite*gold: 0
Join Date: Jul 2010
Posts: 521
Received Thanks: 283
|
[Relase] Jellbot by JD in .NET
hi all now i'll post the jellbot made by JD in.net (i'm not the owner so if you'll use this code you must specify that the original source in C# is of JD's propriety) if there are some errors please report here  the code in C# is not of my propriety but is JD's propriety, you can use this code for doing whatever you want it's OS  but remember every time to add that the original code is of JD
Quote:
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Net.Sockets
Imports System.Threading
Imports System.IO
Imports System.Xml.Linq
Imports System.Net
Namespace UriWars
Public Partial Class Form1
Inherits Form
Private client As Socket
Private PingTimer As System.Threading.Timer
Private ReceiveThread As Thread
Private RedrawThread As Thread
Private BotThread As Thread
Private Maps As MapsParser
Private runLogic As Boolean = True
Private State As LogicState = LogicState.Login
Private UserID As String = ""
Private SessionID As String = ""
Private MapName As String = ""
' ============= Collection of Shitz =============
Private CurrentMap As Classes.Map = Nothing
Private Hero As Classes.Hero = Nothing
Private Boxes As New List(Of Classes.Box)()
Private Ores As New List(Of Classes.Ore)()
Private Portals As New List(Of Classes.Portal)()
Private Ships As New List(Of Classes.Ship)()
Private SpaceStations As New List(Of Classes.Station)()
' ============= End Collection of Shitz =============
Public Sub New(uid As String, sid As String, map As String)
UserID = uid
SessionID = sid
MapName = map
InitializeComponent()
RedrawThread = New Thread(Function()
While True AndAlso Not Me.IsDisposed
Try
Me.Invoke(New MethodInvoker(Me.pictureBox1.Invalidate))
Thread.Sleep(100)
Catch generatedExceptionName As ThreadAbortException
Throw
Catch
Thread.Sleep(100)
End Try
End While
End Function)
RedrawThread.IsBackground = True
RedrawThread.Priority = ThreadPriority.Lowest
RedrawThread.Start()
Maps = New MapsParser()
Maps.Load("https://fb-uridiumwars.bpsecure.com/src/swf/spacemap/xml/maps.php")
Connect()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs)
System.Diagnostics.Trace.WriteLine("[FORM] Loaded")
End Sub
Private Sub Connect()
client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
client.Connect(Maps.GetMapIPsByName()(MapName), 8080)
client.Send(Helpers.CreateLegacyPacket("LOGIN", UserID, SessionID, "2.15", "3"))
System.Diagnostics.Trace.WriteLine("[LOGIN] " & Helpers.CreateLegacyPacketStr("LOGIN", UserID, SessionID, "2.15", "3"))
ReceiveThread = New Thread(Function()
While client.Connected
Dim pack As String = Receive()
If pack IsNot Nothing Then
PacketHandler(pack)
End If
Thread.Sleep(1)
End While
End Function)
ReceiveThread.IsBackground = True
ReceiveThread.Start()
client.Send(Helpers.CreateLegacyPacket("RDY", "MAP"))
Ping()
BotThread = New Thread(New ThreadStart(AddressOf RunLogic))
BotThread.IsBackground = True
BotThread.Start()
End Sub
Private Sub Ping()
If PingTimer Is Nothing Then
PingTimer = New System.Threading.Timer(Function(e)
Ping()
End Function, Nothing, 25000, 25000)
End If
client.Send(Helpers.CreateLegacyPacket("PNG"))
End Sub
Private packets As [Byte]()
Private CurrPos As Integer
Private Length As Integer
Private Function Receive() As String
Dim PacketLength As Integer = 0
Dim PacketPosition As Integer = 0
Dim [Continue] As Boolean = True
Dim packet As [Byte]() = New [Byte](4999) {}
Try
While [Continue]
If CurrPos = Length Then
CurrPos = 0
packets = New [Byte](999) {}
Length = client.Receive(packets, 1000, SocketFlags.None)
End If
If Length = 0 Then
Return Nothing
End If
While CurrPos < Length
If packets(CurrPos) = 10 Then
PacketLength = PacketPosition + 1
packet(PacketPosition) = 13
CurrPos += 1
[Continue] = False
Exit While
ElseIf packets(CurrPos) = 0 Then
packet(PacketPosition) = 13
Else
packet(PacketPosition) = packets(CurrPos)
End If
PacketPosition += 1
CurrPos += 1
End While
End While
Dim Packet2 As [Byte]() = New [Byte](PacketLength - 1) {}
For i As Integer = 0 To PacketLength - 1
Packet2(i) = packet(i)
Next
Return Encoding.UTF8.GetString(Packet2).Replace(vbCr & vbCr & vbCr, "")
Catch generatedExceptionName As SocketException
Return Nothing
End Try
End Function
Private Sub PacketHandler(data As String)
System.Diagnostics.Trace.WriteLine(data)
Dim args As String() = data.Replace(vbNullChar & vbCr & vbLf, "").Split("|"C)
If args.Length = 1 Then
Return
End If
Select Case args(1)
Case "I"
If True Then
Hero = New Classes.Hero(Integer.Parse(args(2)), Integer.Parse(args(4)), Integer.Parse(args(27)), args(28), args(3), Integer.Parse(args(12)), _
Integer.Parse(args(13)), Integer.Parse(args(15)), Integer.Parse(args(16)), Integer.Parse(args(29)), Integer.Parse(args(5)), Convert.ToBoolean(Integer.Parse(args(30))))
Exit Select
End If
Case "m"
If True Then
CurrentMap = New Classes.Map(Convert.ToInt32(args(2)), Convert.ToInt32(args(3)), Convert.ToInt32(args(4)))
If CurrentMap.Id = 255 Then
MessageBox.Show("WARNING YOU ARE IN THE TUTORIAL MAP!")
client.Disconnect(True)
Return
End If
LoadMap()
State = LogicState.Idle
Exit Select
End If
Case "p"
If True Then
Portals.Add(New Classes.Portal(Convert.ToInt32(args(2)), Convert.ToInt32(args(5)), Convert.ToInt32(args(6))))
Exit Select
End If
Case "s"
If True Then
SpaceStations.Add(New Classes.Station(0, Convert.ToInt32(args(7)), Convert.ToInt32(args(8)), Convert.ToInt32(args(5))))
Exit Select
End If
Case "C"
If True Then
Ships.RemoveAll(Function(ship) ship.UserID.Equals(Integer.Parse(args(2))))
Ships.Add(Classes.Ship.Create(Integer.Parse(args(2 )), Integer.Parse(args(3)), Integer.Parse(args(11)), args(5), args(6), Integer.Parse(args(7)), _
Integer.Parse(args(8)), Integer.Parse(args(9)), Integer.Parse(args(10)), Integer.Parse(args(13)), Integer.Parse(args(14)), Convert.ToBoolean(Integer.Parse(args(16))), _
Convert.ToBoolean(Integer.Parse(args(17)))))
Exit Select
End If
Case "R", "K"
If True Then
SyncLock Ships
Ships.RemoveAll(Function(ship) ship.UserID = Integer.Parse(args(2)))
End SyncLock
If Hero.SelectedShip IsNot Nothing AndAlso Hero.SelectedShip.UserID = Integer.Parse(args(2)) Then
Hero.SelectedShip = Nothing
End If
Exit Select
End If
Case "1"
If True Then
Dim shp As Classes.Ship = Ships.FirstOrDefault(Function(ship) ship.UserID = Integer.Parse(args(2)))
If shp IsNot Nothing Then
shp.Move(Integer.Parse(args(3)), Integer.Parse(args(4)), Integer.Parse(args(5)))
End If
Exit Select
End If
Case "A"
If True Then
Select Case args(2)
Case "v"
If True Then
Hero.SetSpeed(Integer.Parse(args(3)))
Exit Select
End If
Case "HPT"
If True Then
Hero.SetHp(Integer.Parse(args(3)), Integer.Parse(args(4)))
Exit Select
End If
Case "SHD"
If True Then
Hero.SetShield(Integer.Parse(args(3)), Integer.Parse(args(4)))
Exit Select
End If
End Select
Exit Select
End If
Case "N"
If True Then
Dim shp As Classes.Ship = Ships.FirstOrDefault(Function(ship) ship.UserID = Integer.Parse(args(2)))
If shp IsNot Nothing Then
shp.SetHp(Integer.Parse(args(5)), Integer.Parse(args(6)))
shp.SetShield(Integer.Parse(args(3)), Integer.Parse(args(4)))
Hero.SelectedShip = shp
End If
Exit Select
End If
Case "Y"
If True Then
Dim id As Integer = Integer.Parse(args(3))
If Hero.UserID = id Then
Hero.UpdateHpShieldNano(Integer.Parse(args(5)), 0, Integer.Parse(args(6)))
Else
Dim shp As Classes.Ship = Ships.FirstOrDefault(Function(ship) ship.UserID = id)
If shp IsNot Nothing Then
shp.UpdateHpShieldNano(Integer.Parse(args(5)), 0, Integer.Parse(args(6)))
End If
End If
Exit Select
End If
' ============= Boxes =============
' Bonux Box
Case "c"
If True Then
SyncLock Boxes
If Not AntiBot.honeyBoxes.Contains(args(2)) Then
Boxes.Add(New Classes.Box(args(2), Convert.ToInt32(args(3)), Convert.ToInt32(args(4)), Convert.ToInt32(args(5))))
Else
System.Diagnostics.Trace.WriteLine("[WARNING] Found HoneyBox " & args(2) & "!!", "Warning")
End If
End SyncLock
Exit Select
End If
Case "2"
If True Then
SyncLock Boxes
Boxes.RemoveAll(Function(p) p.Code.Equals(args(2)))
End SyncLock
Exit Select
End If
' ORE
Case "q"
If True Then
SyncLock Ores
Ores.RemoveAll(Function(p) p.Code.Equals(args(2)))
End SyncLock
Exit Select
End If
Case "r"
If True Then
SyncLock Ores
If Not AntiBot.honeyBoxes.Contains(args(2)) Then
Ores.Add(New Classes.Ore(args(2), Integer.Parse(args(3)), Integer.Parse(args(4)), Integer.Parse(args(5))))
Else
System.Diagnostics.Trace.WriteLine("[WARNING] Found HoneyBox " & args(2) & "!!", "Warning")
End If
End SyncLock
Exit Select
End If
' ============= End Boxes =============
End Select
End Sub
Private Sub MoveTo(x As Integer, y As Integer)
client.Send(Helpers.CreateLegacyPacket("1", x.ToString(), y.ToString(), CInt(Math.Truncate(Hero.Position.x)).ToString(), CInt(Math.Truncate(Hero.Position.y)).ToString()))
Hero.Move(x, y)
End Sub
Private Sub MoveTo(x As Double, y As Double)
client.Send(Helpers.CreateLegacyPacket("1", CInt(Math.Truncate(x)).ToString(), CInt(Math.Truncate(y)).ToString(), CInt(Math.Truncate(Hero.Position.x)).ToString(), CInt(Math.Truncate(Hero.Position.y)).ToString()))
Hero.Move(CInt(Math.Truncate(x)), CInt(Math.Truncate(y)))
End Sub
Private Sub Repair()
client.Send(Helpers.CreateLegacyPacket("S", "ROB"))
End Sub
Private Sub LoadMap()
If CurrentMap Is Nothing Then
Return
End If
If InvokeRequired Then
Invoke(New Action(Function() LoadMap()))
Return
End If
Try
pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom
pictureBox1.BackgroundImage = System.Drawing.Image.FromFile(Environment.CurrentD irectory & "\images\" & CurrentMap.Id & ".jpg")
Catch generatedExceptionName As FileNotFoundException
Try
pictureBox1.BackgroundImage = System.Drawing.Image.FromFile(Environment.CurrentD irectory & "\images\0.jpg")
Catch generatedExceptionName As FileNotFoundException
Dim img As Image = New Bitmap(pictureBox1.Size.Width, pictureBox1.Size.Height)
Dim g = Graphics.FromImage(img)
g.FillRectangle(New SolidBrush(Color.Black), 0, 0, pictureBox1.Size.Width, pictureBox1.Size.Height)
pictureBox1.BackgroundImage = img
End Try
End Try
End Sub
Private Sub RunLogic()
Dim lastDeg As Double = 0
While client.Connected AndAlso runLogic
If State = LogicState.Login Then
Thread.Sleep(100)
Continue While
End If
If State <> LogicState.Repairing AndAlso State <> LogicState.NeedRepair AndAlso Hero.Hp <= Hero.Hp * 0.2 Then
State = LogicState.NeedRepair
Dim port = Portals.OrderBy(Function(p) p.Position.DistanceTo(Hero.Position)).FirstOrDefau lt()
If port IsNot Nothing Then
MoveTo(port.Position.x, port.Position.y)
Thread.Sleep(50)
Continue While
End If
End If
If State = LogicState.NeedRepair Then
If Not Hero.IsMoving Then
State = LogicState.Repairing
Repair()
Continue While
Else
Thread.Sleep(50)
Continue While
End If
End If
If State = LogicState.Repairing Then
If Hero.Hp = Hero.Maxhp Then
State = LogicState.Idle
Continue While
Else
Thread.Sleep(100)
Continue While
End If
End If
If State = LogicState.SearchingBox Then
Dim nearestBox As Classes.Box = Boxes.OrderBy(Function(box) box.Position.DistanceTo(Hero.Position)).FirstOrDef ault()
If nearestBox Is Nothing Then
If Hero.IsMoving Then
Thread.Sleep(50)
Else
MoveTo(Helpers.Random(100, CurrentMap.SizeX), Helpers.Random(100, CurrentMap.SizeY))
End If
State = LogicState.Idle
Else
MoveTo(nearestBox.Position.x, nearestBox.Position.y)
State = LogicState.CollectingBox
Thread.Sleep(50)
Continue While
End If
End If
If State = LogicState.CollectingBox Then
If Hero.IsMoving Then
Thread.Sleep(50)
Continue While
Else
Dim nearestBox As Classes.Box = Boxes.OrderBy(Function(box) box.Position.DistanceTo(Hero.Position)).FirstOrDef ault()
If nearestBox IsNot Nothing Then
If nearestBox.Position.DistanceTo(Hero.Position) < 50 Then
client.Send(Helpers.CreateLegacyPacket("x", nearestBox.Code))
SyncLock Boxes
Boxes.RemoveAll(Function(b) b.Code = nearestBox.Code)
End SyncLock
Else
MoveTo(nearestBox.Position.x, nearestBox.Position.y)
End If
Continue While
Else
State = LogicState.Idle
Continue While
End If
End If
End If
If State = LogicState.SearchingAlien Then
Dim nearestShip As Classes.Ship = Ships.OrderBy(Function(ship) ship.Position.DistanceTo(Hero.Position)).FirstOrDe fault(Function(ship) ship.IsNPC)
If nearestShip Is Nothing Then
If Hero.IsMoving Then
Thread.Sleep(50)
Else
MoveTo(Helpers.Random(100, CurrentMap.SizeX), Helpers.Random(100, CurrentMap.SizeY))
End If
Else
Hero.SelectedShip = nearestShip
MoveTo(nearestShip.Position.x, nearestShip.Position.y)
client.Send(Helpers.CreateLegacyPacket("SEL", nearestShip.UserID.ToString()))
client.Send(Helpers.CreateLegacyPacket("u", "1"))
client.Send(Helpers.CreateLegacyPacket("a", nearestShip.UserID.ToString()))
State = LogicState.KillingAlien
Thread.Sleep(50)
Continue While
End If
End If
If State = LogicState.KillingAlien Then
Dim target As Classes.Ship = Hero.SelectedShip
If target IsNot Nothing Then
' deltaY = P2_y - P1_y
' deltaX = P2_x - P1_x
Dim deltaX As Double = target.Position.x - Hero.Position.x
Dim deltaY As Double = target.Position.y - Hero.Position.y
'double currentDeg = Math.Atan2(deltaY, deltaX) / Math.PI * 180 + 180;
Dim newPosition As New Classes.Vector(target.Position.x + 700 * Math.Cos(lastDeg += 25), target.Position.y + 700 * Math.Sin(lastDeg += 25))
MoveTo(newPosition.x, newPosition.y)
Thread.Sleep(300)
Continue While
Else
State = LogicState.Idle
End If
End If
If State = LogicState.Idle Then
If Ships.Where(Function(ship) ship.IsNPC).Count() > 0 AndAlso Boxes.Count > 0 Then
State = LogicState.SearchingBox
ElseIf Ships.Where(Function(ship) ship.IsNPC).Count() > 0 Then
State = LogicState.SearchingAlien
Else
State = LogicState.SearchingBox
End If
End If
End While
End Sub
Private Sub button1_Click(sender As Object, e As EventArgs)
Connect()
End Sub
Private Sub pictureBox1_Paint(sender As Object, e As PaintEventArgs)
Try
Dim g As Graphics = e.Graphics
Dim stations As Classes.Station()
Dim ships__1 As Classes.Ship()
Dim boxes__2 As Classes.Box()
Dim ores__3 As Classes.Ore()
Dim portals__4 As Classes.Portal()
SyncLock SpaceStations
stations = SpaceStations.ToArray()
End SyncLock
SyncLock Ships
ships__1 = Ships.ToArray()
End SyncLock
SyncLock Boxes
boxes__2 = Boxes.ToArray()
End SyncLock
SyncLock Ores
ores__3 = Ores.ToArray()
End SyncLock
SyncLock Portals
portals__4 = Portals.ToArray()
End SyncLock
For Each station As Classes.Station In stations
Dim img As Image
Select Case station.Company
Case Else
'case 1:
' img = SH_IT.Properties.Resources.mmo_station;
' break;
'case 2:
' img = SH_IT.Properties.Resources.eic_station;
' break;
'case 3:
' img = SH_IT.Properties.Resources.vru_station;
' break;
img = New Bitmap(50, 50)
Exit Select
End Select
g.DrawImage(img, CSng((station.Position.x - 750) / CurrentMap.ByX), CSng((station.Position.y - 750) / CurrentMap.ByY), 35, 35)
Next
For Each box As Classes.Box In boxes__2
Dim box_color As Color = Color.Aqua
If box.Type = 0 Then
Continue For
ElseIf box.Type = 1 Then
box_color = Color.DarkOrange
ElseIf box.Type = 2 Then
box_color = Color.Yellow
ElseIf box.Type = 21 Then
box_color = Color.DarkCyan
ElseIf box.Type = 22 Then
box_color = Color.DarkGoldenrod
ElseIf box.Type = 31 Then
box_color = Color.Magenta
ElseIf box.Type = 32 Then
box_color = Color.Firebrick
End If
g.FillRectangle(New SolidBrush(box_color), CSng(box.Position.x / CurrentMap.ByX), CSng(box.Position.y / CurrentMap.ByY), 2, 2)
Next
For Each ore As Classes.Ore In ores__3
g.FillRectangle(New SolidBrush(Color.Gray), CSng(ore.Position.x / CurrentMap.ByX), CSng(ore.Position.y / CurrentMap.ByY), 2, 2)
Next
Dim EnemyDot As New Pen(Color.Orange, 1)
EnemyDot.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash
For Each ship As Classes.Ship In ships__1
Dim color__5 As Color = Color.FromArgb(0, 127, 255)
If Hero IsNot Nothing Then
If ship.IsNPC OrElse ship.Faction <> Hero.Faction Then
color__5 = Color.Red
End If
If ship.ClanDiplomacy = 1 Then
color__5 = Color.Lime
End If
If ship.ClanDiplomacy = 2 Then
color__5 = Color.DarkOrange
End If
If ship.ClanDiplomacy = 3 Then
color__5 = Color.Red
End If
End If
Dim currPos = ship.Position
g.FillRectangle(New SolidBrush(color__5), CSng(currPos.x / CurrentMap.ByX), CSng(currPos.y / CurrentMap.ByY), 2, 2)
If Not ship.IsNPC AndAlso ship.Faction <> Hero.Faction AndAlso ship.ClanDiplomacy <> 1 AndAlso ship.ClanDiplomacy <> 2 Then
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
g.DrawRectangle(EnemyDot, CSng(currPos.x / CurrentMap.ByX) - 3, CSng(currPos.y / CurrentMap.ByY) - 3, 8, 8)
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.[Default]
End If
Next
If Hero IsNot Nothing AndAlso CurrentMap IsNot Nothing Then
Dim currPos = Hero.Position
Dim pen = New Pen(Color.Gray, 0.5F)
g.DrawLine(pen, 0, CSng(currPos.y / CurrentMap.ByY), 415, CSng(currPos.y / CurrentMap.ByY))
g.DrawLine(pen, CSng(currPos.x / CurrentMap.ByX), 0, CSng(currPos.x / CurrentMap.ByX), 225)
If Hero.IsMoving Then
g.DrawLine(pen, CSng(currPos.x / CurrentMap.ByX), CSng(currPos.y / CurrentMap.ByY), CSng(Hero.Destination.x / CurrentMap.ByX), CSng(Hero.Destination.y / CurrentMap.ByY))
End If
End If
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
For Each port As Classes.Portal In portals__4
g.DrawEllipse(New Pen(Color.FromArgb(255, 255, 255, 255)), CSng((port.Position.x) / CurrentMap.ByX) - 5, CSng((port.Position.y) / CurrentMap.ByY) - 5, 10, 10)
Next
If Hero IsNot Nothing AndAlso Hero.SelectedShip IsNot Nothing Then
Dim HPText As String = [String].Format("HP: {0}/{1}", Hero.SelectedShip.Hp, Hero.SelectedShip.Maxhp)
Dim ShieldText As String = [String].Format("Shield: {0}/{1}", Hero.SelectedShip.Shield, Hero.SelectedShip.Maxshield)
Dim AlienText As String = Hero.SelectedShip.Username
Dim HPlength As SizeF = g.MeasureString(HPText, New Font("Arial", 7, FontStyle.Regular))
Dim Shieldlength As SizeF = g.MeasureString(ShieldText, New Font("Arial", 7, FontStyle.Regular))
Dim Alienlength As SizeF = g.MeasureString(AlienText, New Font("Arial", 7, FontStyle.Regular))
Dim width As Single = Math.Max(HPlength.Width, Math.Max(Alienlength.Width, Shieldlength.Width))
g.DrawString(ShieldText, New Font("Arial", 7, FontStyle.Regular), New SolidBrush(Color.LightBlue), pictureBox1.Size.Width - width - 2, 212)
g.DrawString(HPText, New Font("Arial", 7, FontStyle.Regular), New SolidBrush(Color.LightGreen), pictureBox1.Size.Width - width - 2, 212 - HPlength.Height - 1)
g.DrawString(AlienText, New Font("Arial", 7, FontStyle.Regular), New SolidBrush(Color.Red), pictureBox1.Size.Width - width - 2, 212 - HPlength.Height - Shieldlength.Height - 2)
Else
g.DrawString("By -jD- and Freakazoide", New Font("Arial", 7, FontStyle.Regular), New SolidBrush(Color.Violet), 308, 210)
End If
Catch
End Try
End Sub
Private Sub pictureBox1_MouseDown(sender As Object, e As MouseEventArgs)
Dim x As Integer = CInt(Math.Truncate(Math.Round(e.X * CurrentMap.ByX)))
Dim y As Integer = CInt(Math.Truncate(Math.Round(e.Y * CurrentMap.ByY)))
client.Send(Helpers.CreateLegacyPacket("1", x.ToString(), y.ToString(), CInt(Math.Truncate(Hero.Position.x)).ToString(), CInt(Math.Truncate(Hero.Position.y)).ToString()))
Hero.Move(x, y)
End Sub
Private Enum LogicState
Login
Roaming
CollectingBox
SearchingBox
Fleeing
SearchingAlien
KillingAlien
MovingToPortal
Jumping
Repairing
NeedRepair
NeedSell
Selling
Idle
End Enum
End Class
NotInheritable Class Helpers
Private Sub New()
End Sub
Shared numGen As New Random()
Public Shared Function CreateLegacyPacket(content As String) As Byte()
Return Encoding.UTF8.GetBytes(content & vbLf & vbNullChar)
End Function
Public Shared Function CreateLegacyPacket(ParamArray packet As String()) As Byte()
Dim content As String = [String].Join("|", packet) & vbLf & vbNullChar
Return Encoding.UTF8.GetBytes(content)
End Function
Public Shared Function CreateLegacyPacketStr(ParamArray packet As String()) As String
Return [String].Join("|", packet) & vbLf & vbNullChar
End Function
Public Shared Function Random(low As Integer, high As Integer) As Integer
Return numGen.[Next](low, high)
End Function
End Class
Friend Class MapsParser
Private webclient As WebClient
Private mapsfile As XDocument
Private IsLoaded As Boolean
Private url As String
Public Sub New()
IsLoaded = False
webclient = New WebClient()
webclient.Proxy = Nothing
End Sub
Public Sub Load(url As String)
Me.url = url
IsLoaded = False
mapsfile = XDocument.Parse(webclient.DownloadString(url))
IsLoaded = True
End Sub
Public Function GetMapIPs() As Dictionary(Of Integer, String)
If Not IsLoaded Then
Load(url)
End If
Dim ret_dic As New Dictionary(Of Integer, String)()
Dim root As XElement = mapsfile.Element("maps")
For Each element As XElement In root.Elements("map")
ret_dic.Add(Convert.ToInt32(element.Attribute("id" ).Value), element.Element("gameserverIP").Value)
Next
Return ret_dic
End Function
Public Function GetMapIPsByName() As Dictionary(Of String, String)
If Not IsLoaded Then
Load(url)
End If
Dim ret_dic As New Dictionary(Of String, String)()
Dim root As XElement = mapsfile.Element("maps")
For Each element As XElement In root.Elements("map")
If Not ret_dic.ContainsKey(element.Attribute("name").Valu e) Then
ret_dic.Add(element.Attribute("name").Value, element.Element("gameserverIP").Value)
End If
Next
Return ret_dic
End Function
Public Function GetFilteredIPs() As String
If Not IsLoaded Then
Load(url)
End If
Dim temp As New XDocument(mapsfile)
Dim root As XElement = temp.Element("maps")
For Each element As XElement In root.Elements("map")
element.Element("gameserverIP").Value = "127.0.0.1"
Next
Return temp.ToString()
End Function
Public Function GetUnFilteredIPs() As String
If Not IsLoaded Then
Load(url)
End If
Return mapsfile.ToString()
End Function
End Class
NotInheritable Class Classes
Private Sub New()
End Sub
Public Class Vector
Public Sub New()
End Sub
Public Sub New(x As Double, y As Double)
Me.x = x
Me.y = y
End Sub
Public x As Double
Public y As Double
Public Function DistanceTo(otherdude As Vector) As Double
Return Math.Sqrt(((otherdude.x - x) * (otherdude.x - x)) + ((otherdude.y - y) * (otherdude.y - y)))
End Function
End Class
Public Class Map
Implements ICloneable
Public Sub New(id__1 As Integer, sizeX__2 As Integer, sizeY__3 As Integer, Optional name As String = "")
Id = id__1
SizeX = sizeX__2
SizeY = sizeY__3
ByX = SizeX \ 415
ByY = SizeY \ 225
MapName = name
End Sub
Public Sub New(name As String)
MapName = name
Id = 0
SizeX = 0
SizeY = 0
ByX = 0
ByY = 0
End Sub
Public Property Id() As Integer
Get
Return m_Id
End Get
Private Set
m_Id = Value
End Set
End Property
Private m_Id As Integer
Public Property SizeX() As Integer
Get
Return m_SizeX
End Get
Private Set
m_SizeX = Value
End Set
End Property
Private m_SizeX As Integer
Public Property SizeY() As Integer
Get
Return m_SizeY
End Get
Private Set
m_SizeY = Value
End Set
End Property
Private m_SizeY As Integer
Public Property ByX() As Single
Get
Return m_ByX
End Get
Private Set
m_ByX = Value
End Set
End Property
Private m_ByX As Single
Public Property ByY() As Single
Get
Return m_ByY
End Get
Private Set
m_ByY = Value
End Set
End Property
Private m_ByY As Single
Public Property MapName() As String
Get
Return m_MapName
End Get
Private Set
m_MapName = Value
End Set
End Property
Private m_MapName As String
Public Sub Clear()
End Sub
Public Function Clone() As Object Implements ICloneable.Clone
Dim Copy As New Map(Me.MapName)
Copy.Id = Id
Copy.SizeX = SizeX
Copy.SizeY = SizeY
Copy.ByX = ByX
Copy.ByY = ByY
Return Copy
End Function
End Class
Public Class Box
Protected m_code As String
Protected m_type As Integer
Protected x As Integer
Protected y As Integer
Public Sub New(code As String, type As Integer, x As Integer, y As Integer)
Me.m_code = code
Me.m_type = type
Me.x = x
Me.y = y
End Sub
Public ReadOnly Property Code() As String
Get
Return m_code
End Get
End Property
Public ReadOnly Property Position() As Vector
Get
Return New Vector(x, y)
End Get
End Property
Public ReadOnly Property Type() As Integer
Get
Return m_type
End Get
End Property
End Class
Public Class Ore
Protected m_code As String
Protected m_type As Integer
Protected x As Integer
Protected y As Integer
Public Sub New(code As String, type As Integer, x As Integer, y As Integer)
Me.m_code = code
Me.m_type = type
Me.x = x
Me.y = y
End Sub
Public ReadOnly Property Code() As String
Get
Return m_code
End Get
End Property
Public ReadOnly Property Position() As Vector
Get
Return New Vector(x, y)
End Get
End Property
Public ReadOnly Property Type() As Integer
Get
Return m_type
End Get
End Property
End Class
Public Class Ship
Public Shared Function Create(id As Integer, shipId As Integer, rank As Integer, clan As String, username As String, posX As Integer, _
posY As Integer, company As Integer, clanId As Integer, clandiplomacy As Integer, galaxygatesdone As Integer, isNpc As Boolean, _
cloaked As Boolean) As Ship
Return New Ship(id, shipId, rank, clan, username, posX, _
posY, company, clanId, clandiplomacy, galaxygatesdone, isNpc, _
cloaked)
End Function
Public Sub New(id As Integer, shipType__1 As Integer, rank__2 As Integer, clan__3 As String, username__4 As String, posX__5 As Integer, _
posY__6 As Integer, faction__7 As Integer, clanId__8 As Integer, clandiplomacy__9 As Integer, galaxygatesdone As Integer, isNpc__10 As Boolean, _
cloaked__11 As Boolean)
UserID = id
ShipType = shipType__1
Clan = clan__3
Username = username__4
PosX = posX__5
PosY = posY__6
Faction = faction__7
ClanID = clanId__8
Rank = rank__2
'IsEnemy = isenemy;
ClanDiplomacy = clandiplomacy__9
GatesDone = galaxygatesdone
IsNPC = isNpc__10
Cloaked = cloaked__11
IsTaggedByOtherPlayer = False
lastMove = DateTime.Now
moveDuration = 0
End Sub
Public Property UserID() As Integer
Get
Return m_UserID
End Get
Protected Set
m_UserID = Value
End Set
End Property
Private m_UserID As Integer
Public Property ShipType() As Integer
Get
Return m_ShipType
End Get
Set
m_ShipType = Value
End Set
End Property
Private m_ShipType As Integer
Public Property Rank() As Integer
Get
Return m_Rank
End Get
Set
m_Rank = Value
End Set
End Property
Private m_Rank As Integer
Public Property Clan() As String
Get
Return m_Clan
End Get
Set
m_Clan = Value
End Set
End Property
Private m_Clan As String
Public Property Username() As String
Get
Return m_Username
End Get
Set
m_Username = Value
End Set
End Property
Private m_Username As String
Public Property Map() As String
Get
Return m_Map
End Get
Set
m_Map = Value
End Set
End Property
Private m_Map As String
Protected Property PosX() As Integer
Get
Return m_PosX
End Get
Set
m_PosX = Value
End Set
End Property
Private m_PosX As Integer
Protected Property PosY() As Integer
Get
Return m_PosY
End Get
Set
m_PosY = Value
End Set
End Property
Private m_PosY As Integer
Public Property Faction() As Integer
Get
Return m_Faction
End Get
Set
m_Faction = Value
End Set
End Property
Private m_Faction As Integer
Public Property ClanID() As Integer
Get
Return m_ClanID
End Get
Set
m_ClanID = Value
End Set
End Property
Private m_ClanID As Integer
Public Property ClanDiplomacy() As Integer
Get
Return m_ClanDiplomacy
End Get
Set
m_ClanDiplomacy = Value
End Set
End Property
Private m_ClanDiplomacy As Integer
Public Property GatesDone() As Integer
Get
Return m_GatesDone
End Get
Set
m_GatesDone = Value
End Set
End Property
Private m_GatesDone As Integer
Public Property IsNPC() As Boolean
Get
Return m_IsNPC
End Get
Set
m_IsNPC = Value
End Set
End Property
Private m_IsNPC As Boolean
Public Property Cloaked() As Boolean
Get
Return m_Cloaked
End Get
Set
m_Cloaked = Value
End Set
End Property
Private m_Cloaked As Boolean
Public Property IsTaggedByOtherPlayer() As Boolean
Get
Return m_IsTaggedByOtherPlayer
End Get
Set
m_IsTaggedByOtherPlayer = Value
End Set
End Property
Private m_IsTaggedByOtherPlayer As Boolean
Public Property Hp() As Integer
Get
Return m_Hp
End Get
Set
m_Hp = Value
End Set
End Property
Private m_Hp As Integer
Public Property Maxhp() As Integer
Get
Return m_Maxhp
End Get
Set
m_Maxhp = Value
End Set
End Property
Private m_Maxhp As Integer
Public Property NanoHull() As Integer
Get
Return m_NanoHull
End Get
Set
m_NanoHull = Value
End Set
End Property
Private m_NanoHull As Integer
Public Property MaxNanoHull() As Integer
Get
Return m_MaxNanoHull
End Get
Set
m_MaxNanoHull = Value
End Set
End Property
Private m_MaxNanoHull As Integer
Public Property Shield() As Integer
Get
Return m_Shield
End Get
Set
m_Shield = Value
End Set
End Property
Private m_Shield As Integer
Public Property Maxshield() As Integer
Get
Return m_Maxshield
End Get
Set
m_Maxshield = Value
End Set
End Property
Private m_Maxshield As Integer
Public Property Title() As Integer
Get
Return m_Title
End Get
Set
m_Title = Value
End Set
End Property
Private m_Title As Integer
Public Property Velocity() As Integer
Get
Return m_Velocity
End Get
Set
m_Velocity = Value
End Set
End Property
Private m_Velocity As Integer
Private lastMove As DateTime
Private moveDuration As Double
' MILLISECONDS
Private moveDestination As Vector
Private direction As Vector
'double moveDistance;
Private Moving As Boolean = False
Public Function DistanceTo(otherdude As Vector) As Double
Return Math.Sqrt(((otherdude.x - PosX) * (otherdude.x - PosX)) + ((otherdude.y - PosY) * (otherdude.y - PosY)))
End Function
Public Sub Move(x As Integer, y As Integer, duration As Integer)
Dim currPosition As Vector = Position
Me.PosX = CInt(Math.Truncate(currPosition.x))
Me.PosY = CInt(Math.Truncate(currPosition.y))
Moving = True
direction = New Vector(x - PosX, y - PosY)
moveDestination = New Vector(x, y)
'moveDistance = Math.Sqrt((x * x) + (y * y));
moveDuration = duration
' * 1000;
lastMove = DateTime.Now
End Sub
Public ReadOnly Property IsMoving() As Boolean
Get
Return Moving
End Get
End Property
Public ReadOnly Property Position() As Vector
Get
If Moving Then
Dim timeElapsed As Double = (DateTime.Now - lastMove).TotalMilliseconds
If timeElapsed < moveDuration Then
Return New Vector(PosX + (direction.x * (timeElapsed / moveDuration)), PosY + (direction.y * (timeElapsed / moveDuration)))
Else
Moving = False
PosX = CInt(Math.Truncate(PosX + direction.x))
PosY = CInt(Math.Truncate(PosY + direction.y))
Return New Vector(PosX, PosY)
End If
Else
Return New Vector(PosX, PosY)
End If
End Get
End Property
Public ReadOnly Property Destination() As Vector
Get
Return moveDestination
End Get
End Property
Public Sub SetHp(hp__1 As Integer, maxhp__2 As Integer)
Hp = hp__1
Maxhp = maxhp__2
End Sub
Public Sub SetShield(shield__1 As Integer, maxshield__2 As Integer)
Shield = shield__1
Maxshield = maxshield__2
End Sub
Public Sub SetNanoHull(hull As Integer, maxHull As Integer)
NanoHull = hull
MaxNanoHull = maxHull
End Sub
Public Sub UpdateHpShieldNano(hp__1 As Integer, nanoHull__2 As Integer, shield__3 As Integer)
Hp = hp__1
NanoHull = nanoHull__2
Shield = shield__3
End Sub
Public Sub UpdateHpShieldNano(hp__1 As Integer, maxhp__2 As Integer, nanoHull__3 As Integer, maxnano As Integer, shield__4 As Integer, maxshield__5 As Integer)
Hp = hp__1
NanoHull = nanoHull__3
Shield = shield__4
Maxhp = maxhp__2
Maxshield = maxshield__5
MaxNanoHull = maxnano
End Sub
Public Sub SetTitle(title_id As Integer)
Title = title_id
End Sub
Public Sub UpdatePosition(x As Integer, y As Integer)
PosX = x
PosY = y
Moving = False
End Sub
End Class
Public Class Hero
Inherits Ship
Public Sub New(id As Integer, shipType As Integer, rank As Integer, clan As String, username As String, posX As Integer, _
posY As Integer, faction As Integer, clanId As Integer, galaxygatesdone As Integer, speed As Integer, cloaked As Boolean)
MyBase.New(id, shipType, rank, clan, username, posX, _
posY, faction, clanId, 0, galaxygatesdone, False, _
cloaked)
Me.Velocity = speed
End Sub
Public Shared Overloads Function Create(id As Integer, shipId As Integer, rank As Integer, clan As String, username As String, posX As Integer, _
posY As Integer, company As Integer, clanId As Integer, galaxygatesdone As Integer, speed As Integer, cloaked As Boolean) As Hero
Return New Hero(id, shipId, rank, clan, username, posX, _
posY, company, clanId, galaxygatesdone, speed, cloaked)
End Function
Private lastMove As DateTime
Private moveDuration As Double
' MILLISECONDS
Private moveDestination As Vector
Private direction As Vector
Private moveDistance As Double
Private Moving As Boolean = False
Public SelectedShip As Ship = Nothing
Public PreviousSelectedShip As Ship = Nothing
Public AutolockedShip As Boolean = False
Public Attacking As Boolean = False
Public CurrentAmmo As Short = 26
Public RequestedAbility As Integer = -1
Public Overloads Sub Move(x As Integer, y As Integer)
Dim currPosition As Vector = Position
Me.PosX = CInt(Math.Truncate(currPosition.x))
Me.PosY = CInt(Math.Truncate(currPosition.y))
Moving = True
direction = New Vector(x - PosX, y - PosY)
moveDestination = New Vector(x, y)
moveDistance = Math.Sqrt(((x - PosX) * (x - PosX)) + ((y - PosY) * (y - PosY)))
moveDuration = (moveDistance / Velocity) * 1000
lastMove = DateTime.Now
End Sub
Public Sub SetSpeed(speed As Integer)
Velocity = speed
If Moving Then
moveDuration = (Math.Sqrt(((moveDestination.x - PosX) * (moveDestination.x - PosX)) + ((moveDestination.y - PosY) * (moveDestination.y - PosY))) / Velocity) * 1000
End If
End Sub
Public Shadows ReadOnly Property IsMoving() As Boolean
Get
Return Moving
End Get
End Property
Public ReadOnly Property DestinationDistance() As Double
Get
Return moveDistance
End Get
End Property
Public Shadows ReadOnly Property Destination() As Vector
Get
Return moveDestination
End Get
End Property
Public Shadows ReadOnly Property Position() As Vector
Get
If Moving Then
Dim timeElapsed As Double = (DateTime.Now - lastMove).TotalMilliseconds
If timeElapsed < moveDuration Then
Return New Vector(PosX + (direction.x * (timeElapsed / moveDuration)), PosY + (direction.y * (timeElapsed / moveDuration)))
Else
Moving = False
PosX = CInt(Math.Truncate(PosX + direction.x))
PosY = CInt(Math.Truncate(PosY + direction.y))
Return New Vector(PosX, PosY)
End If
Else
Return New Vector(PosX, PosY)
End If
End Get
End Property
End Class
Public Class Portal
Protected m_id As Integer
Protected x As Integer
Protected y As Integer
Public Sub New(id As Integer, x As Integer, y As Integer)
Me.m_id = id
Me.x = x
Me.y = y
End Sub
Public ReadOnly Property ID() As Integer
Get
Return m_id
End Get
End Property
Public ReadOnly Property Position() As Vector
Get
Return New Vector(x, y)
End Get
End Property
End Class
Public Class Station
Protected m_id As Integer
Protected x As Integer
Protected y As Integer
Protected m_company As Integer
Public Sub New(id As Integer, x As Integer, y As Integer, company As Integer)
Me.m_id = id
Me.x = x
Me.y = y
Me.m_company = company
End Sub
Public ReadOnly Property ID() As Integer
Get
Return m_id
End Get
End Property
Public ReadOnly Property Company() As Integer
Get
Return m_company
End Get
End Property
Public ReadOnly Property Position() As Vector
Get
Return New Vector(x, y)
End Get
End Property
End Class
End Class
End Namespace
|
|
|
|
06/05/2013, 10:48
|
#2
|
elite*gold: 0
Join Date: Jun 2011
Posts: 946
Received Thanks: 173
|
wat am i supposed to do with this ???
u stole jd's property?
|
|
|
06/05/2013, 10:49
|
#3
|
elite*gold: 0
Join Date: Jan 2012
Posts: 1,997
Received Thanks: 3,422
|
Already on epvp.
|
|
|
06/05/2013, 10:50
|
#4
|
elite*gold: 0
Join Date: Jul 2010
Posts: 521
Received Thanks: 283
|
it's a source code of the jellbot in .NET you can use it for studying but it doesn't work on real darkorbit because is a bot for Uridium Wars  but it can be used in some private servers maybe
Quote:
Originally Posted by NoCheatImPGM
Already on epvp.
|
there's even in .NET? i saw that JD written this in C#
|
|
|
06/05/2013, 10:53
|
#5
|
elite*gold: 0
Join Date: Jan 2012
Posts: 1,997
Received Thanks: 3,422
|
Oooooops exscuse me ^^ yes you right
|
|
|
06/05/2013, 10:57
|
#6
|
elite*gold: 0
Join Date: Jul 2010
Posts: 521
Received Thanks: 283
|
Quote:
Originally Posted by NoCheatImPGM
Oooooops exscuse me ^^ yes you right
|
Don't worry
|
|
|
06/05/2013, 11:07
|
#7
|
elite*gold: 0
Join Date: Sep 2012
Posts: 8,002
Received Thanks: 3,863
|
Please put it in a spoiler.
|
|
|
06/05/2013, 11:22
|
#8
|
elite*gold: 0
Join Date: Jul 2010
Posts: 521
Received Thanks: 283
|
Done
|
|
|
06/05/2013, 13:11
|
#9
|
elite*gold: 0
Join Date: May 2012
Posts: 59
Received Thanks: 9
|
you give it to. exe file?
|
|
|
06/05/2013, 13:16
|
#10
|
elite*gold: 0
Join Date: May 2012
Posts: 868
Received Thanks: 947
|
Dude, it's right here (  ), why create another thread ?
|
|
|
06/05/2013, 13:33
|
#11
|
elite*gold: 0
Join Date: Jul 2010
Posts: 521
Received Thanks: 283
|
Quote:
Originally Posted by chichi011
Dude, it's right here (  ), why create another thread ?
|
that's in C# this is in vb.NET
|
|
|
06/05/2013, 13:42
|
#12
|
elite*gold: 0
Join Date: May 2012
Posts: 868
Received Thanks: 947
|
Quote:
Originally Posted by Pandemonium2100
that's in C# this is in vb.NET
|
So what ? Basically the same, if you know one of them it only takes you about a week to get comfortable with the other one, the only different thing is the syntax.
|
|
|
06/05/2013, 13:53
|
#13
|
elite*gold: 0
Join Date: Jul 2010
Posts: 521
Received Thanks: 283
|
yep i know but for who that doesn't have time is useful
|
|
|
06/05/2013, 13:57
|
#14
|
elite*gold: 2
Join Date: Aug 2012
Posts: 1,029
Received Thanks: 1,109
|
Quote:
Originally Posted by Pandemonium2100
yep i know but for who that doesn't have time is useful 
|
i think the most people just c&p the code you wrote in the spoiler. They won't learn anything about this, because you translated it from C# to VB... they should try to convert it by themself.
Good for C&P , but nothing where someone could learn from
|
|
|
06/05/2013, 14:01
|
#15
|
elite*gold: 1
Join Date: Jun 2012
Posts: 5,819
Received Thanks: 3,200
|
Quote:
Originally Posted by Pandemonium2100
it's a source code of the jellbot in .NET you can use it for studying but it doesn't work on real darkorbit because is a bot for Uridium Wars  but it can be used in some private servers maybe
there's even in .NET? i saw that JD written this in C#
|
Are u mad? C# is .NET!
|
|
|
Similar Threads
|
[RELASE] OFFICIAL SERVER SKILLX4 APRIL 28/04/2011 new relase
05/28/2011 - Metin2 Hacks, Bots, Cheats, Exploits & Macros - 17 Replies
I managed to create this new file pc.epk the hack shield of the official metin2 client can not detect. It took me a lot to create it and it works perfectly. skill dmg x 4 for all skills.
Working 28/04/2011
http://t1.gstatic.com/images?q=tbn:ANd9GcSCU9pcO2 vvTQ5nFRtDW-WCzvd4JxwDEIQaAcDcwPbjwJFb_0YH&t=1
: Free File Hosting, Online Storage & File Upload with FileServe
Comment me:)
ps. copy this file into the pack folder :cool:
|
All times are GMT +1. The time now is 21:18.
|
|