Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Threading;
- using System.Collections.Generic;
- using System.Linq;
- using ArcheBuddy.Bot.Classes;
- namespace Radar{
- public class Radar : Core
- {
- public static string GetPluginAuthor()
- {
- return "2face";
- }
- public static string GetPluginVersion()
- {
- return "1.0.0.0";
- }
- public static string GetPluginDescription()
- {
- return "Radar Plugin";
- }
- private Form f;
- private Label label;
- private Thread formThread;
- System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
- int WIDTH = 400, HEIGHT = 400, HAND = 150;
- int u; //in degree
- int cx, cy; //center of the circle
- int x, y; //HAND coordinate
- int tx, ty, lim = 20;
- Bitmap bmp;
- Pen p;
- Pen p2;
- Graphics g;
- private System.Windows.Forms.PictureBox pictureBox1;
- Double rOriginX;
- Double rOriginY;
- Creature creature = null;
- int doodX;
- int doodY;
- // Create font and brush.
- Font drawFont = new Font("Arial", 10);
- 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();
- private void InitializeForm()
- {
- f = new Form();
- f.Width = 500;
- f.Height = 500;
- f.Text = "Archeage Radar";
- f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
- 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(400, 400);
- 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(386, 325);
- f.Controls.Add(pictureBox1);
- f.Name = "Form1";
- f.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- f.Text = "RADAR";
- // f.Load += new System.EventHandler(f.Form1_Load);
- ((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/Tree";
- tbb2.Text = "Player";
- tbb3.Text = "Mobs";
- tbb4.Text = "Objects";
- tbb1.Style = ToolBarButtonStyle.ToggleButton;
- tbb2.Style = ToolBarButtonStyle.ToggleButton;
- tbb3.Style = ToolBarButtonStyle.ToggleButton;
- tbb4.Style = ToolBarButtonStyle.ToggleButton;
- toolBar1.Buttons.Add(tbb1);
- toolBar1.Buttons.Add(tbb2);
- toolBar1.Buttons.Add(tbb3);
- toolBar1.Buttons.Add(tbb4);
- 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);
- Log((cursorPos.X + rOriginX).ToString() + " " + (cursorPos.Y + rOriginY).ToString());
- }
- public void drawGatherNodes(){
- foreach(var dood in getDoodads()){
- skill = getDoodadSkill(dood);
- if(skill != null && (skill.name == "Chop Tree" || skill.name == "Mine Ore")){
- doodX = Convert.ToInt32(rOriginX - dood.X);
- doodY = Convert.ToInt32(rOriginY - dood.Y);
- drawDot(doodX, doodY, dood.name, Color.Blue);
- }
- }
- }
- public void drawAllObjects(){
- foreach(var dood in getDoodads()){
- doodX = Convert.ToInt32(rOriginX - dood.X);
- doodY = Convert.ToInt32(rOriginY - dood.Y);
- drawDot(doodX, doodY, dood.name, Color.Blue);
- }
- }
- public void drawDot(int x, int y, String text, Color color){
- p2.Color = color;
- g.DrawEllipse(p2, x, y, 2, 2);
- g.DrawString(text, drawFont, drawBrush, x, y - 15);
- }
- public void drawCreatures(){
- int objX = 0;
- int objY = 0;
- foreach(var obj in getCreatures()){
- objX = Convert.ToInt32(rOriginX - obj.X);
- objY = Convert.ToInt32(rOriginY - obj.Y);
- if(tbb2.Pushed && (obj.type == BotTypes.Player)){
- drawDot(objX, objY, obj.name, Color.Yellow);
- }
- if(tbb3.Pushed && (obj.type == BotTypes.Npc)){
- drawDot(objX, objY, obj.name, Color.Red);
- }
- }
- }
- private void t_Tick(object sender, EventArgs e)
- {
- rOriginX = me.X + ( WIDTH / 2);
- rOriginY = me.Y + ( HEIGHT / 2);
- skill = null;
- p = new Pen(Color.Green, 1f);
- p2 = new Pen(Color.Red, 2f);
- g = Graphics.FromImage(bmp);
- g.Clear(Color.Black);
- if(tbb4.Pushed){
- drawAllObjects();
- }else if(tbb1.Pushed){
- drawGatherNodes();
- }
- if(tbb2.Pushed || tbb3.Pushed){
- drawCreatures();
- }
- //calculate x, y coordinate of HAND
- int tu = (u - lim) % 360;
- //draw circle
- g.DrawEllipse(p, 0, 0, WIDTH, HEIGHT); //bigger circle
- g.DrawEllipse(p, 80, 80, WIDTH - 160, HEIGHT - 160); //smaller circle
- //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
- //load bitmap in picturebox1
- pictureBox1.Image = bmp;
- p.Dispose();
- p2.Dispose();
- g.Dispose();
- //update
- u++;
- if (u == 360)
- {
- u = 0;
- }
- }
- 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(error.ToString());
- }
- }
- public void PluginRun()
- {
- formThread = new Thread(RunForm);
- formThread.SetApartmentState(ApartmentState.STA);
- formThread.Start();
- while (true)
- Thread.Sleep(100);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement