Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.79 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using System.Threading;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using ArcheBuddy.Bot.Classes;
  8.  
  9. namespace Radar{
  10. public class Radar : Core
  11. {
  12. public static string GetPluginAuthor()
  13. {
  14. return "2face";
  15. }
  16.  
  17. public static string GetPluginVersion()
  18. {
  19. return "1.0.0.0";
  20. }
  21.  
  22. public static string GetPluginDescription()
  23. {
  24. return "Radar Plugin";
  25. }
  26.  
  27. private Form f;
  28. private Label label;
  29. private Thread formThread;
  30.  
  31. System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
  32. int WIDTH = 400, HEIGHT = 400, HAND = 150;
  33. int u; //in degree
  34. int cx, cy; //center of the circle
  35. int x, y; //HAND coordinate
  36. int tx, ty, lim = 20;
  37. Bitmap bmp;
  38. Pen p;
  39. Pen p2;
  40. Graphics g;
  41. private System.Windows.Forms.PictureBox pictureBox1;
  42.  
  43. Double rOriginX;
  44. Double rOriginY;
  45. Creature creature = null;
  46. int doodX;
  47. int doodY;
  48.  
  49. // Create font and brush.
  50. Font drawFont = new Font("Arial", 10);
  51. SolidBrush drawBrush = new SolidBrush(Color.White);
  52. Skill skill = null;
  53.  
  54. ToolBarButton tbb1 = new ToolBarButton();
  55. ToolBarButton tbb2 = new ToolBarButton();
  56. ToolBarButton tbb3 = new ToolBarButton();
  57. ToolBarButton tbb4 = new ToolBarButton();
  58. ToolBarButton tbb5 = new ToolBarButton();
  59. private void InitializeForm()
  60. {
  61. f = new Form();
  62. f.Width = 500;
  63. f.Height = 500;
  64. f.Text = "Archeage Radar";
  65. f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
  66. f.MaximizeBox = false;
  67. f.MinimizeBox = false;
  68. f.TopMost = true;
  69.  
  70. pictureBox1 = new System.Windows.Forms.PictureBox();
  71. ((System.ComponentModel.ISupportInitialize)(pictureBox1)).BeginInit();
  72. f.SuspendLayout();
  73. //
  74. // pictureBox1
  75. //
  76. pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
  77. pictureBox1.Location = new System.Drawing.Point(0, 0);
  78. pictureBox1.Name = "pictureBox1";
  79. pictureBox1.Size = new System.Drawing.Size(400, 400);
  80. pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  81. pictureBox1.TabIndex = 0;
  82. pictureBox1.TabStop = false;
  83. //
  84. // Form1
  85. //
  86. f.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  87. f.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  88. f.ClientSize = new System.Drawing.Size(386, 325);
  89. f.Controls.Add(pictureBox1);
  90. f.Name = "Form1";
  91. f.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  92. f.Text = "RADAR";
  93. // f.Load += new System.EventHandler(f.Form1_Load);
  94. ((System.ComponentModel.ISupportInitialize)(pictureBox1)).EndInit();
  95. f.ResumeLayout(false);
  96.  
  97. //create Bitmap
  98. bmp = new Bitmap(WIDTH + 1, HEIGHT + 1);
  99. //background color
  100. f.BackColor = Color.Black;
  101. //center
  102. cx = WIDTH / 2;
  103. cy = HEIGHT / 2;
  104. //initial degree of HAND
  105. u = 0;
  106. //timer
  107.  
  108. t.Interval = 250; //in millisecond
  109. t.Tick += new EventHandler(this.t_Tick);
  110. t.Start();
  111.  
  112. pictureBox1.Click += PBox_Click;
  113.  
  114. ToolBar toolBar1 = new ToolBar();
  115. tbb1.Text = "Ore/Tree";
  116. tbb2.Text = "Player";
  117. tbb3.Text = "Mobs";
  118. tbb4.Text = "Objects";
  119. tbb1.Style = ToolBarButtonStyle.ToggleButton;
  120. tbb2.Style = ToolBarButtonStyle.ToggleButton;
  121. tbb3.Style = ToolBarButtonStyle.ToggleButton;
  122. tbb4.Style = ToolBarButtonStyle.ToggleButton;
  123. toolBar1.Buttons.Add(tbb1);
  124. toolBar1.Buttons.Add(tbb2);
  125. toolBar1.Buttons.Add(tbb3);
  126. toolBar1.Buttons.Add(tbb4);
  127. f.Controls.Add(toolBar1);
  128. }
  129.  
  130. public Skill getDoodadSkill(DoodadObject dood){
  131. Skill sk = null;
  132. if(dood != null){
  133. foreach(var obj in dood.getUseSkills()){
  134. sk = obj;
  135. }
  136. }
  137. return sk;
  138. }
  139.  
  140. public void PBox_Click(object sender, EventArgs e)
  141. {
  142. Point cursorPos = f.PointToClient(Cursor.Position);
  143. Double z = getZFromHeightMap(cursorPos.X + rOriginX, cursorPos.Y + rOriginY);
  144. MoveTo(cursorPos.X + rOriginX, cursorPos.Y + rOriginY, z);
  145. Thread.Sleep(250);
  146.  
  147.  
  148. Log((cursorPos.X + rOriginX).ToString() + " " + (cursorPos.Y + rOriginY).ToString());
  149. }
  150.  
  151. public void drawGatherNodes(){
  152. foreach(var dood in getDoodads()){
  153. skill = getDoodadSkill(dood);
  154. if(skill != null && (skill.name == "Chop Tree" || skill.name == "Mine Ore")){
  155. doodX = Convert.ToInt32(rOriginX - dood.X);
  156. doodY = Convert.ToInt32(rOriginY - dood.Y);
  157. drawDot(doodX, doodY, dood.name, Color.Blue);
  158. }
  159. }
  160. }
  161.  
  162. public void drawAllObjects(){
  163. foreach(var dood in getDoodads()){
  164. doodX = Convert.ToInt32(rOriginX - dood.X);
  165. doodY = Convert.ToInt32(rOriginY - dood.Y);
  166. drawDot(doodX, doodY, dood.name, Color.Blue);
  167. }
  168. }
  169.  
  170.  
  171.  
  172. public void drawDot(int x, int y, String text, Color color){
  173. p2.Color = color;
  174. g.DrawEllipse(p2, x, y, 2, 2);
  175. g.DrawString(text, drawFont, drawBrush, x, y - 15);
  176. }
  177.  
  178. public void drawCreatures(){
  179. int objX = 0;
  180. int objY = 0;
  181. foreach(var obj in getCreatures()){
  182. objX = Convert.ToInt32(rOriginX - obj.X);
  183. objY = Convert.ToInt32(rOriginY - obj.Y);
  184. if(tbb2.Pushed && (obj.type == BotTypes.Player)){
  185. drawDot(objX, objY, obj.name, Color.Yellow);
  186. }
  187. if(tbb3.Pushed && (obj.type == BotTypes.Npc)){
  188. drawDot(objX, objY, obj.name, Color.Red);
  189. }
  190.  
  191. }
  192. }
  193.  
  194.  
  195. private void t_Tick(object sender, EventArgs e)
  196. {
  197. rOriginX = me.X + ( WIDTH / 2);
  198. rOriginY = me.Y + ( HEIGHT / 2);
  199. skill = null;
  200.  
  201. p = new Pen(Color.Green, 1f);
  202. p2 = new Pen(Color.Red, 2f);
  203.  
  204. g = Graphics.FromImage(bmp);
  205. g.Clear(Color.Black);
  206.  
  207. if(tbb4.Pushed){
  208. drawAllObjects();
  209. }else if(tbb1.Pushed){
  210. drawGatherNodes();
  211. }
  212.  
  213. if(tbb2.Pushed || tbb3.Pushed){
  214. drawCreatures();
  215. }
  216.  
  217. //calculate x, y coordinate of HAND
  218. int tu = (u - lim) % 360;
  219.  
  220. //draw circle
  221. g.DrawEllipse(p, 0, 0, WIDTH, HEIGHT); //bigger circle
  222. g.DrawEllipse(p, 80, 80, WIDTH - 160, HEIGHT - 160); //smaller circle
  223.  
  224. //draw perpendicular line
  225. g.DrawLine(p, new Point(cx, 0), new Point(cx, HEIGHT)); // UP-DOWN
  226. g.DrawLine(p, new Point(0, cy), new Point(WIDTH, cy)); //LEFT-RIGHT
  227.  
  228. //load bitmap in picturebox1
  229. pictureBox1.Image = bmp;
  230.  
  231. p.Dispose();
  232. p2.Dispose();
  233. g.Dispose();
  234.  
  235. //update
  236. u++;
  237. if (u == 360)
  238. {
  239. u = 0;
  240. }
  241. }
  242.  
  243. private void RunForm()
  244. {
  245. try
  246. {
  247. InitializeForm();
  248. Console.WriteLine("InitializeForm done");
  249. Application.Run(f);
  250. }
  251. catch (Exception error)
  252. {
  253. Log(error.ToString());
  254. }
  255. }
  256.  
  257. public void PluginStop()
  258. {
  259. try
  260. {
  261. if (f != null)
  262. {
  263. f.Invoke(new Action(() => f.Close()));
  264. f.Invoke(new Action(() => f.Dispose()));
  265. }
  266. if (formThread.ThreadState == System.Threading.ThreadState.Running)
  267. {
  268. formThread.Abort();
  269. formThread.Join();
  270. }
  271. }
  272. catch (Exception error)
  273. {
  274. Log(error.ToString());
  275. }
  276. }
  277.  
  278. public void PluginRun()
  279. {
  280. formThread = new Thread(RunForm);
  281. formThread.SetApartmentState(ApartmentState.STA);
  282. formThread.Start();
  283. while (true)
  284. Thread.Sleep(100);
  285. }
  286. }
  287. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement