Advertisement
sibble

Untitled

Sep 17th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using ScriptSDK;
  8. using ScriptSDK.API;
  9. using ScriptSDK.Mobiles;
  10. using ScriptSDK.Engines;
  11. using XScript;
  12.  
  13.  
  14. namespace SpiderVsSpider
  15. {
  16.     class Program
  17.     {
  18.         public static PlayerMobile Self = PlayerMobile.GetPlayer();
  19.         public static Mobile SpiderA = new Mobile(new Serial(703003));
  20.         public static Mobile SpiderB = new Mobile(new Serial(4697258));
  21.         public static bool IsCasting = false;
  22.         public static bool IsAttacking = false;
  23.         public static DateTime AttackTime;
  24.  
  25.         static List<Mobile> Spiders = new List<Mobile>
  26.         {
  27.             new Mobile(new Serial(703003)),
  28.             new Mobile(new Serial(4697258))
  29.         };
  30.  
  31.  
  32.         /// <summary>
  33.         /// Method for posting messages to the console
  34.         /// with a timestamp
  35.         /// </summary>
  36.         /// <param name="message">string: message to send to the console</param>
  37.         /// <param name="args">(optional)object[]: additional arguments</param>
  38.         public static void ConsoleMessage(string message, params object[] args)
  39.         {
  40.             Console.Write("[{0}-{1}] ", Self.Name, DateTime.Now.ToString("hh:mm:ss"));
  41.             Console.WriteLine(message, args);
  42.         }
  43.  
  44.         /// <summary>
  45.         /// Method for posting messages to the console
  46.         /// with a timestamp and optional color
  47.         /// </summary>
  48.         /// <param name="message">string: message to send to the console</param>
  49.         /// <param name="color">(optional)enum ConsoleColor: the color you want the message to be</param>
  50.         /// <param name="args">(optional)object[]: additional arguments</param>
  51.         public static void ConsoleMessage(string message, ConsoleColor color = ConsoleColor.White, params object[] args)
  52.         {
  53.             Console.Write("[{0}-{1}] ", Self.Name, DateTime.Now.ToString("hh:mm:ss"));
  54.             Console.ForegroundColor = color;
  55.             Console.WriteLine(message, args);
  56.             Console.ResetColor();
  57.         }
  58.  
  59.         [STAThread]
  60.         static void Main(string[] args)
  61.         {
  62.             while (Stealth.Client.GetConnectedStatus())
  63.             {
  64.                 //Spiders = Spiders.OrderBy(x => x.HealthPercent).ToList();
  65.                 foreach (Mobile _spider in Spiders)
  66.                 {
  67.                     var _currentHealth = _spider.HealthPercent;
  68.                     var _hits = _spider.Hits;
  69.                     var _maxHits = _spider.MaxHits;
  70.                     var _serial = _spider.Serial.Value;
  71.  
  72.                     Thread.Sleep(50);
  73.                     if (_currentHealth < 70 && !IsCasting)
  74.                     {
  75.                         ConsoleMessage("Healing {0} because HP%: {1}, MaxHits: {2}, Hits: {3}", ConsoleColor.Yellow,
  76.                             _serial,
  77.                             _currentHealth,
  78.                             _maxHits,
  79.                             _hits);
  80.  
  81.                         Heal(_serial);
  82.                     }
  83.                     if (_currentHealth < 30 || Self.Mana < 10)
  84.                     {
  85.                         ConsoleMessage("Telling pets to stop attacking!", ConsoleColor.Red);
  86.                         Stealth.Client.SendTextToUO("all stop");
  87.                         Thread.Sleep(1000);
  88.                         Stealth.Client.CancelTarget();
  89.                         Stealth.Client.UseSkill("Meditation");
  90.                     }
  91.                 }
  92.  
  93.                 TimeSpan _attackDuration = (DateTime.Now - AttackTime);
  94.  
  95.                 if (Spiders.All(x => x.HealthPercent > 40) && _attackDuration.Seconds > 20)
  96.                 {
  97.                     AttackTime = DateTime.Now;
  98.                     ConsoleMessage("Telling pets to start attacking.", ConsoleColor.Green);
  99.                     IsAttacking = true;
  100.                     Stealth.Client.CancelTarget();
  101.                     Stealth.Client.SendTextToUO("a attack");
  102.                     Stealth.Client.WaitTargetObject(SpiderB.Serial.Value);
  103.  
  104.                     Thread.Sleep(500);
  105.  
  106.                     Stealth.Client.CancelTarget();
  107.                     Stealth.Client.SendTextToUO("b attack");
  108.                     Stealth.Client.WaitTargetObject(SpiderA.Serial.Value);
  109.                     IsAttacking = false;
  110.                 }
  111.  
  112.                 Thread.Sleep(500);
  113.             }
  114.         }
  115.  
  116.         static void Heal(uint Target)
  117.         {
  118.             IsCasting = true;
  119.             Stealth.Client.CancelTarget();
  120.             Self.Cast("Greater Heal", Target);
  121.             Thread.Sleep(1100);
  122.             IsCasting = false;
  123.         }
  124.     }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement