using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;
namespace AntRadar
{
public class AntRadar : Core
{
// Archege uses Y Bottom = 0;
// Radar uses Y Top = 0;
public static string GetPluginAuthor()
{
return "XantX";
}
public static string GetPluginVersion()
{
return "1.0.0.0";
}
public static string GetPluginDescription()
{
return "ant's Radar Plugin";
}
private Form f;
private Label label;
private Thread formThread;
System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
int WIDTH = 600;
int HEIGHT = 600;
int HAND = 150;
int u; //in degree
int cx, cy; //center of the circle
int x, y; //HAND coordinate
int tx, ty, lim = 20;
double myLastX, myLastY;
Bitmap bmp;
Graphics g;
private System.Windows.Forms.PictureBox pictureBox1;
Double rOriginX;
Double rOriginY;
Double rOriginZ;
Creature creature = null;
int doodX;
int doodY;
double myPrevX = 0;
double myPrevY = 0;
double prevAngle = 90;
// Create font and brush.
Font drawFont = new Font("Courier", 11);
SolidBrush drawBrush = new SolidBrush(Color.White);
Skill skill = null;
ToolBarButton tbb1 = new ToolBarButton();
ToolBarButton tbb2 = new ToolBarButton();
ToolBarButton tbb3 = new ToolBarButton();
ToolBarButton tbb4 = new ToolBarButton();
ToolBarButton tbb5 = new ToolBarButton();
ToolBarButton tbb6 = new ToolBarButton();
ToolBarButton tbb7 = new ToolBarButton();
ToolBarButton tbb8 = new ToolBarButton();
ToolBarButton tbb9 = new ToolBarButton();
ToolBarButton tbb10 = new ToolBarButton();
Pen p = new Pen(Color.Green, 1f);
Pen p2 = new Pen(Color.Red, 2f);
Pen p3 = new Pen(Color.Blue, 3f);
private void InitializeForm()
{
f = new Form();
f.Width = 500;
f.Height = 500;
f.Text = "ant's Archeage Radar";
f.FormBorderStyle = FormBorderStyle.Sizable;
f.MaximizeBox = false;
f.MinimizeBox = false;
f.TopMost = true;
pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(pictureBox1)).BeginInit();
f.SuspendLayout();
//
// pictureBox1
//
pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
pictureBox1.Location = new System.Drawing.Point(0, 0);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new System.Drawing.Size(WIDTH, HEIGHT);
pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
pictureBox1.TabIndex = 0;
pictureBox1.TabStop = false;
//
// Form1
//
f.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
f.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
f.ClientSize = new System.Drawing.Size(WIDTH-14, HEIGHT - 75);
f.Controls.Add(pictureBox1);
f.Name = "Ant Radar";
f.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
f.Text = "Ant Radar";
((System.ComponentModel.ISupportInitialize)(pictureBox1)).EndInit();
f.ResumeLayout(false);
//create Bitmap
bmp = new Bitmap(WIDTH + 1, HEIGHT + 1);
//background color
f.BackColor = Color.Black;
//center
cx = WIDTH / 2;
cy = HEIGHT / 2;
//initial degree of HAND
u = 0;
//timer
t.Interval = 250; //in millisecond
t.Tick += new EventHandler(this.t_Tick);
t.Start();
pictureBox1.Click += PBox_Click;
ToolBar toolBar1 = new ToolBar();
tbb1.Text = "Ore";
tbb2.Text = "Trees";
tbb3.Text = "Mobs";
tbb4.Text = "Everything - Debug";
tbb5.Text = "Hide Text";
tbb6.Text = "Fixed World";
tbb7.Text = "Player - Friendly";
tbb8.Text = "Player - Enemy";
tbb1.Style = ToolBarButtonStyle.ToggleButton;
tbb2.Style = ToolBarButtonStyle.ToggleButton;
tbb3.Style = ToolBarButtonStyle.ToggleButton;
tbb4.Style = ToolBarButtonStyle.ToggleButton;
tbb5.Style = ToolBarButtonStyle.ToggleButton;
tbb6.Style = ToolBarButtonStyle.ToggleButton;
tbb7.Style = ToolBarButtonStyle.ToggleButton;
tbb8.Style = ToolBarButtonStyle.ToggleButton;
toolBar1.Buttons.Add(tbb1);
toolBar1.Buttons.Add(tbb2);
toolBar1.Buttons.Add(tbb3);
toolBar1.Buttons.Add(tbb4);
toolBar1.Buttons.Add(tbb5);
toolBar1.Buttons.Add(tbb6);
toolBar1.Buttons.Add(tbb7);
toolBar1.Buttons.Add(tbb8);
f.Controls.Add(toolBar1);
}
public Skill getDoodadSkill(DoodadObject dood){
Skill sk = null;
if(dood != null){
foreach(var obj in dood.getUseSkills()){
sk = obj;
}
}
return sk;
}
public void PBox_Click(object sender, EventArgs e)
{
Point cursorPos = f.PointToClient(Cursor.Position);
//Double z = getZFromHeightMap(cursorPos.X + rOriginX, cursorPos.Y + rOriginY);
//MoveTo(cursorPos.X + rOriginX, cursorPos.Y + rOriginY, z);
//Thread.Sleep(250);
// HARDCODED
cursorPos.X -= WIDTH / 2;
cursorPos.Y -= HEIGHT / 2;
cursorPos.X /= 2;
cursorPos.Y /= 2;
//Log(cursorPos.X.ToString());
//Log(cursorPos.Y.ToString());
// Not sure how to get the correct Z position
SetMapPos((rOriginX + cursorPos.X),(rOriginY - cursorPos.Y),me.Z);
//Log((cursorPos.X + me.X).ToString() + " " + (cursorPos.Y + me.Y).ToString());
}
public void drawOre()
{
foreach(var dood in getDoodads())
{
skill = getDoodadSkill(dood);
if(skill != null && (skill.name == "Mine Ore"))
{
drawWorldDot(dood.X,dood.Y,dood.Z,dood.name,Color.Blue);
}
}
}
public void drawTrees()
{
foreach(var dood in getDoodads())
{
skill = getDoodadSkill(dood);
if(skill != null && (skill.name == "Chop Tree"))
{
drawWorldDot(dood.X,dood.Y,dood.Z,dood.name,Color.Blue);
}
}
}
public void drawAllObjects()
{
foreach(var dood in getDoodads())
{
drawWorldDot(dood.X, dood.Y, dood.Z , dood.name, Color.Blue);
}
}
public void drawWorldDot(double x, double y, double z, String text, Color color)
{
double relx,rely,relz;
relx = x - rOriginX;
rely = y - rOriginY;
relz = z - me.Z;
double scale = WIDTH / 400 * 0.8;
relx *= scale;
rely *= scale;
relz *= scale;
// + "[" + x.ToString() + "," + y.ToString() + "," + z.ToString() + "]"
drawDot(cx + (int)relx , cy + -(int)rely ,text,color);
}
public void drawDot(int x, int y, String text, Color color)
{
p2.Color = color;
g.DrawEllipse(p2, x, y, 2, 2);
if (tbb5.Pushed)
g.DrawString("", drawFont, drawBrush, x - (6 * (text.Count()/2)), y);
else
g.DrawString(text, drawFont, drawBrush, x - (6 * (text.Count()/2)), y);
}
public void drawCreatures()
{
foreach(var obj in getCreatures())
{
if(obj.type == BotTypes.Npc)
{
drawWorldDot(obj.X,obj.Y,obj.Z,obj.name,Color.Orange);
}
}
}
public void drawFriendlies()
{
foreach(var obj in getCreatures())
{
if(obj.type == BotTypes.Player && obj.factionId == me.factionId)
{
drawWorldDot(obj.X,obj.Y,obj.Z,obj.name,Color.Aquamarine);
}
}
}
public void drawEnemies()
{
foreach(var obj in getCreatures())
{
if(obj.type == BotTypes.Player && obj.factionId != me.factionId)
{
drawWorldDot(obj.X,obj.Y,obj.Z,obj.name,Color.Red);
}
}
}
public void drawSelf()
{
drawWorldDot(me.X, me.Y, me.Z, "Me", Color.White);
// draw the line in which you are looking
double diffy, diffx, angle;
diffx = me.X - myLastX;
diffy = me.Y - myLastY;
angle = Math.Atan2(diffy,diffx);
double vx,vy;
if (angle != 0)
{
vx = Math.Cos(angle);
vy = Math.Sin(angle);
prevAngle = angle;
}
else
{
vx = Math.Cos(prevAngle);
vy = Math.Sin(prevAngle);
}
vx *= 75;
vy *= 75;
myLastX = me.X;
myLastY = me.Y;
g.DrawLine(p3,new Point(cx + (int)(me.X - rOriginX),cy - (int)(me.Y - rOriginY)),new Point((int)(cx+vx + (int)(me.X - rOriginX)),(int)(cy-vy) - (int)(me.Y - rOriginY)));
}
public void drawNSEW()
{
//draw perpendicular line
g.DrawLine(p, new Point(cx, 0), new Point(cx, HEIGHT)); // UP-DOWN
g.DrawLine(p, new Point(0, cy), new Point(WIDTH, cy)); //LEFT-RIGHT
drawDot(cx,HEIGHT-25,"S",Color.Green);
drawDot(cx,0,"N",Color.Green);
drawDot(WIDTH-25,cy,"E",Color.Green);
drawDot(0,cy,"W",Color.Green);
}
private void t_Tick(object sender, EventArgs e)
{
if (!tbb6.Pushed)
{
rOriginX = me.X;
rOriginY = me.Y;
rOriginZ = me.Z;
}
//Log(angle(me.target, me).ToString());
g = Graphics.FromImage(bmp);
g.Clear(Color.Black);
drawNSEW();
drawSelf();
if(tbb4.Pushed)
{
drawAllObjects();
pictureBox1.Image = bmp;
g.Dispose();
return;
}
if(tbb1.Pushed)
{
drawOre();
}
if(tbb2.Pushed)
{
drawTrees();
}
if(tbb3.Pushed)
{
drawCreatures();
}
if(tbb7.Pushed)
{
drawFriendlies();
}
if(tbb8.Pushed)
{
drawEnemies();
}
//load bitmap in picturebox1
pictureBox1.Image = bmp;
g.Dispose();
}
private void RunForm()
{
try
{
InitializeForm();
Console.WriteLine("InitializeForm done");
Application.Run(f);
}
catch (Exception error)
{
Log(error.ToString());
}
}
public void PluginStop()
{
try
{
if (f != null)
{
f.Invoke(new Action(() => f.Close()));
f.Invoke(new Action(() => f.Dispose()));
}
if (formThread.ThreadState == System.Threading.ThreadState.Running)
{
formThread.Abort();
formThread.Join();
}
}
catch (Exception error)
{
Log("Ant Radar Exited");
}
}
public void PluginRun()
{
Log("Start Of Ant Radar");
formThread = new Thread(RunForm);
formThread.SetApartmentState(ApartmentState.STA);
formThread.Start();
while (true)
Thread.Sleep(100);
if (!tbb6.Pushed)
{
rOriginX = me.X;
rOriginY = me.Y;
rOriginZ = me.Z;
}
g = Graphics.FromImage(bmp);
g.Clear(Color.Black);
drawNSEW();
drawSelf();
if(tbb4.Pushed)
{
drawAllObjects();
pictureBox1.Image = bmp;
g.Dispose();
return;
}
if(tbb1.Pushed)
{
drawOre();
}
if(tbb2.Pushed)
{
drawTrees();
}
if(tbb3.Pushed)
{
drawCreatures();
}
if(tbb7.Pushed)
{
drawFriendlies();
}
if(tbb8.Pushed)
{
drawEnemies();
}
//load bitmap in picturebox1
pictureBox1.Image = bmp;
g.Dispose();
}
}
}