Advertisement
Guest User

Untitled

a guest
Dec 19th, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Forms;
  7. using Buddy.BehaviorTree;
  8. using Buddy.Common;
  9. using Buddy.CommonBot;
  10. using Buddy.Common.Plugins;
  11. using Buddy.Swtor;
  12. using Buddy.Common.Math;
  13. using Buddy.Swtor.Objects;
  14.  
  15. namespace Buddywing.Plugins
  16. {
  17.     class AutoPVP : IPlugin
  18.     {
  19.         #region Implementation of IEquatable<IPlugin>
  20.  
  21.         /// <summary>
  22.         /// Indicates whether the current object is equal to another object of the same type.
  23.         /// </summary>
  24.         /// <returns>
  25.         /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
  26.         /// </returns>
  27.         /// <param name="other">An object to compare with this object.</param>
  28.         public bool Equals(IPlugin other)
  29.         {
  30.             return other.Name == Name;
  31.         }
  32.  
  33.         #endregion
  34.  
  35.         #region Implementation of IPlugin
  36.  
  37.         public string Author
  38.         {
  39.             get { return "Wbulot"; }
  40.         }
  41.  
  42.         public Version Version
  43.         {
  44.             get { return new Version(1, 0, 0); }
  45.         }
  46.  
  47.         public string Name
  48.         {
  49.             get { return "AutoPVP"; }
  50.         }
  51.  
  52.         public string Description
  53.         {
  54.             get { return "Cast spell for you"; }
  55.         }
  56.  
  57.         public Window DisplayWindow
  58.         {
  59.             get { return null; }
  60.         }
  61.  
  62.         /// <summary> Executes the pulse action. This is called every "tick" of the bot. </summary>
  63.         public void OnPulse()
  64.         {
  65.  
  66.         }
  67.  
  68.         public static List<Vector3> EnemyPoints = new List<Vector3>();
  69.  
  70.         public static List<TorCharacter> GetTorCharacters()
  71.         {
  72.             using (BuddyTor.Memory.AcquireFrame())
  73.             {
  74.                 var npcs = ObjectManager.GetObjects<TorNpc>();
  75.                 var objects = npcs.Cast<TorCharacter>().ToList();
  76.                 var torPlayers = ObjectManager.GetObjects<TorPlayer>();
  77.                 objects.AddRange(torPlayers);
  78.                 //foreach (var item in objects)
  79.                 //{
  80.                 //}
  81.                 return objects;
  82.             }
  83.         }
  84.  
  85.         private static int PointsAroundPoint(Vector3 pt, List<Vector3> l, float dist)
  86.         {
  87.             using (BuddyTor.Memory.AcquireFrame())
  88.             {
  89.                 var maxDistance = dist * dist;
  90.                 return l.Count(p => p.DistanceSqr(pt) <= maxDistance);
  91.             }
  92.         }
  93.  
  94.         public static bool CheckDpsAoe(int minMobs, float distance, Vector3 center)
  95.         {
  96.             EnemyPoints = new List<Vector3>();
  97.             var objects = GetTorCharacters();
  98.             foreach (var c in objects)
  99.             {
  100.                 if (c.IsHostile && c.IsDead == false)
  101.                 {
  102.                     EnemyPoints.Add(c.Position);
  103.                     Logging.Write(c.Name);
  104.                 }
  105.             }
  106.             return PointsAroundPoint(center, EnemyPoints, distance) >= minMobs;
  107.         }
  108.  
  109.         private static void Routine()
  110.         {
  111.             BuddyTor.Update();
  112.             BuddyTor.Me.SetTarget(BuddyTor.Me.CurrentTarget);
  113.  
  114.             if (BuddyTor.Me.CurrentTarget != null)
  115.             {
  116.                 Logging.Write(BuddyTor.Me.CurrentTarget.Name);
  117.             }
  118.             else
  119.             {
  120.                 Logging.Write("Il n'y a pas de cible !!");
  121.             }
  122.  
  123.             if (BuddyTor.Me.IsCasting == false)
  124.             {
  125.                 if (BuddyTor.Me.HasBuff("Puissance de Force") == false)
  126.                 {
  127.                     Logging.Write("Cast Puissance de Force");
  128.                     AbilityManager.Cast("Puissance de Force", BuddyTor.Me);
  129.                 }
  130.  
  131.                 if (AbilityManager.CanCast("Camouflage de Force", BuddyTor.Me) == true && BuddyTor.Me.HealthPercent < 30)
  132.                 {
  133.                     Logging.Write("Cast Camouflage de Force");
  134.                     AbilityManager.Cast("Camouflage de Force", BuddyTor.Me);
  135.                 }
  136.  
  137.                 if (AbilityManager.CanCast("La Force nous garde", BuddyTor.Me) == true && BuddyTor.Me.HealthPercent < 40)
  138.                 {
  139.                     Logging.Write("Cast La Force nous garde");
  140.                     AbilityManager.Cast("La Force nous garde", BuddyTor.Me);
  141.                 }
  142.  
  143.                 if (AbilityManager.CanCast("Retour de sabre", BuddyTor.Me) == true && BuddyTor.Me.HealthPercent < 50)
  144.                 {
  145.                     Logging.Write("Cast Retour de sabre");
  146.                     AbilityManager.Cast("Retour de sabre", BuddyTor.Me);
  147.                 }
  148.  
  149.                 if (AbilityManager.CanCast("R??primande", BuddyTor.Me) == true && BuddyTor.Me.HealthPercent < 75)
  150.                 {
  151.                     Logging.Write("Cast R??primande");
  152.                     AbilityManager.Cast("R??primande", BuddyTor.Me);
  153.                 }
  154.  
  155.                 if (AbilityManager.CanCast("Zen", BuddyTor.Me) == true)
  156.                 {
  157.                     Logging.Write("Cast Zen");
  158.                     AbilityManager.Cast("Zen", BuddyTor.Me);
  159.                 }
  160.  
  161.                 if (AbilityManager.CanCast("Balayage de Force", BuddyTor.Me) == true)
  162.                 {
  163.                     if (CheckDpsAoe(2, 0.5f, BuddyTor.Me.Position) == true)
  164.                     {
  165.                         Logging.Write("Cast Balayage de Force");
  166.                         AbilityManager.Cast("Balayage de Force", BuddyTor.Me);
  167.                     }
  168.                 }
  169.  
  170.                 if (AbilityManager.CanCast("Effroi", BuddyTor.Me) == true)
  171.                 {
  172.                     if (CheckDpsAoe(3, 0.7f, BuddyTor.Me.Position) == true)
  173.                     {
  174.                         Logging.Write("Cast Effroi");
  175.                         AbilityManager.Cast("Effroi", BuddyTor.Me);
  176.                     }
  177.                 }
  178.  
  179.                 if (BuddyTor.Me.CurrentTarget != null)
  180.                 {
  181.                     if (AbilityManager.CanCast("Pr??cision", BuddyTor.Me.CurrentTarget) == true && BuddyTor.Me.CurrentTarget.Distance <= 0.4)
  182.                     {
  183.                         Logging.Write("Pr??cision");
  184.                         AbilityManager.Cast("Pr??cision", BuddyTor.Me.CurrentTarget);
  185.                     }
  186.  
  187.                     if (BuddyTor.Me.ActionPoints < 3)
  188.                     {
  189.                         if (AbilityManager.CanCast("Frappe acharn??e", BuddyTor.Me.CurrentTarget) == true)
  190.                         {
  191.                             Logging.Write("Cast Frappe acharn??e");
  192.                             AbilityManager.Cast("Frappe acharn??e", BuddyTor.Me.CurrentTarget);
  193.                         }
  194.  
  195.                         if (AbilityManager.CanCast("Frappe", BuddyTor.Me.CurrentTarget) == true)
  196.                         {
  197.                             Logging.Write("Cast Frappe");
  198.                             AbilityManager.Cast("Frappe", BuddyTor.Me.CurrentTarget);
  199.                         }
  200.                     }
  201.  
  202.                     if (AbilityManager.CanCast("Pacification", BuddyTor.Me.CurrentTarget) == true && BuddyTor.Me.CurrentTarget.HealthPercent > 50)
  203.                     {
  204.                         Logging.Write("Cast Pacification");
  205.                         AbilityManager.Cast("Pacification", BuddyTor.Me.CurrentTarget);
  206.                     }
  207.  
  208.                     if (AbilityManager.CanCast("Fente cyclone", BuddyTor.Me.CurrentTarget) == true)
  209.                     {
  210.                         if (CheckDpsAoe(2, 0.3f, BuddyTor.Me.CurrentTarget.Position) == true && BuddyTor.Me.CurrentTarget.Distance <= 0.5)
  211.                         {
  212.                             Logging.Write("Cast Fente cyclone");
  213.                             AbilityManager.Cast("Fente cyclone", BuddyTor.Me.CurrentTarget);
  214.                         }
  215.                     }
  216.  
  217.                     if (BuddyTor.Me.CurrentTarget.IsCasting && AbilityManager.CanCast("Coup de pied de Force", BuddyTor.Me.CurrentTarget) == true)
  218.                     {
  219.                         Logging.Write("Cast Coup de pied de Force");
  220.                         AbilityManager.Cast("Coup de pied de Force", BuddyTor.Me.CurrentTarget);
  221.                     }
  222.  
  223.                     if (AbilityManager.CanCast("Saut de Force", BuddyTor.Me.CurrentTarget) == true)
  224.                     {
  225.                         Logging.Write("Cast Saut de force");
  226.                         AbilityManager.Cast("Saut de Force", BuddyTor.Me.CurrentTarget);
  227.                     }
  228.  
  229.                     if (BuddyTor.Me.ActionPoints < 3)
  230.                     {
  231.                         if (AbilityManager.CanCast("Frappe acharn??e", BuddyTor.Me.CurrentTarget) == true)
  232.                         {
  233.                             Logging.Write("Cast Frappe acharn??e");
  234.                             AbilityManager.Cast("Frappe acharn??e", BuddyTor.Me.CurrentTarget);
  235.                         }
  236.  
  237.                         if (AbilityManager.CanCast("Frappe", BuddyTor.Me.CurrentTarget) == true)
  238.                         {
  239.                             Logging.Write("Cast Frappe");
  240.                             AbilityManager.Cast("Frappe", BuddyTor.Me.CurrentTarget);
  241.                         }
  242.                     }
  243.  
  244.                     if (AbilityManager.CanCast("D??luge de lames", BuddyTor.Me.CurrentTarget) == true)
  245.                     {
  246.                         Logging.Write("Cast D??luge de lames");
  247.                         AbilityManager.Cast("D??luge de lames", BuddyTor.Me.CurrentTarget);
  248.                     }
  249.  
  250.                     if (BuddyTor.Me.CurrentTarget.Distance > 0.4 && BuddyTor.Me.CurrentTarget.Distance <= 1)
  251.                     {
  252.                         if (AbilityManager.CanCast("Temp??te de lame", BuddyTor.Me.CurrentTarget) == true)
  253.                         {
  254.                             Logging.Write("Cast Temp??te de lame");
  255.                             AbilityManager.Cast("Temp??te de lame", BuddyTor.Me.CurrentTarget);
  256.                         }
  257.  
  258.                         if (AbilityManager.CanCast("Stase de Force", BuddyTor.Me.CurrentTarget) == true)
  259.                         {
  260.                             Logging.Write("Cast Stase de Force");
  261.                             AbilityManager.Cast("Stase de Force", BuddyTor.Me.CurrentTarget);
  262.                         }
  263.                     }
  264.                 }
  265.             }
  266.             else
  267.             {
  268.                 Logging.Write("On est en train de caster, donc wait");
  269.             }
  270.         }
  271.  
  272.         /// <summary> Executes the initialize action. This is called at initial bot startup. (When the bot itself is started, not when Start() is called) </summary>
  273.         public void OnInitialize()
  274.         {
  275.             Hotkeys.RegisterHotkey("Routine", Routine, Keys.D1);
  276.         }
  277.  
  278.         /// <summary> Executes the shutdown action. This is called when the bot is shutting down. (Not when Stop() is called) </summary>
  279.         public void OnShutdown()
  280.         {
  281.         }
  282.  
  283.         /// <summary> Executes the enabled action. This is called when the user has enabled this specific plugin via the GUI. </summary>
  284.         public void OnEnabled()
  285.         {
  286.         }
  287.  
  288.         /// <summary> Executes the disabled action. This is called whent he user has disabled this specific plugin via the GUI. </summary>
  289.         public void OnDisabled()
  290.         {
  291.         }
  292.  
  293.         #endregion
  294.     }
  295. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement