Advertisement
Smudla

Taming

Aug 1st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.09 KB | None | 0 0
  1. using System.Linq;
  2. using Phoenix.WorldData;
  3.  
  4. namespace Phoenix.Scripts.DP.Skills
  5. {
  6.     public class Taming
  7.     {
  8.         [Executable("tamingtrain"), BlockMultipleExecutions("taming")]
  9.         public void Train()
  10.         {
  11.             UOItem staff = World.Player.Layers.FindType(0x13F4, 0x04B9);
  12.             Tame(staff);
  13.         }
  14.  
  15.         [Executable("taming"), BlockMultipleExecutions("taming")]
  16.         public void Normal()
  17.         {
  18.             UOItem staff = World.Player.Layers.FindType(0x13F4, 0x096D);
  19.             if (!staff.Exist)
  20.             {
  21.                 staff = World.Player.Layers.FindType(0x13F4, 0x076B);
  22.                 if (!staff.Exist)
  23.                     throw new ScriptErrorException("Taming staff not found.");
  24.  
  25.                 UOItem shrink = World.Player.Layers.FindType(0x1843, 0x0724);
  26.                 if (!shrink.Exist)
  27.                 {
  28.                     shrink = World.Player.Layers.FindType(0x0F09, 0x045E);
  29.                     if (!shrink.Exist)
  30.                         throw new ScriptErrorException("Shrink not found.");
  31.                 }
  32.                 using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(staff))
  33.                 {
  34.                     shrink.WaitTarget();
  35.                     staff.Use();
  36.                     if (!ew.Wait(2000))
  37.                         throw new ScriptErrorException("Error during taming staff charging.");
  38.                     UO.Wait(500);
  39.                 }
  40.                 staff = World.Player.Layers.FindType(0x13F4, 0x096D);
  41.             }
  42.  
  43.             Tame(staff);
  44.  
  45.             foreach (UOItem item in World.Ground)
  46.                 if (Enumerable.Range(0x20C8, 0x2137 - 0x20C8).Any(i => i == item.Graphic))
  47.                     item.GrabEx();
  48.         }
  49.  
  50.         private void Tame(UOItem staff)
  51.         {
  52.             if (!staff.Exist)
  53.                 throw new ScriptErrorException("Invalid staff.");
  54.  
  55.             UOCharacter animal = new UOCharacter(UIManager.TargetObject());
  56.             if (!animal.Exist)
  57.                 throw new ScriptErrorException("Invalid target.");
  58.  
  59.             do
  60.             {
  61.                 Journal.Clear();
  62.                 animal.WaitTarget();
  63.                 staff.Use();
  64.                 UO.Wait(1000);
  65.                 Journal.WaitForText(pass.Concat(end).ToArray());
  66.             } while (!Journal.Contains(end));
  67.         }
  68.  
  69.         private string[] pass = {
  70.                                     "Your taming failed, try again.",
  71.                                     "Ochoceni se nezdarilo",
  72.                                 };
  73.  
  74.         private string[] end = {
  75.                                    "byl tamnut",
  76.                                    "Not tamable.",
  77.                                    "Too far..",
  78.                                    "You are not able to tame this animal",
  79.                                    "Jsi moc daleko",
  80.                                    "toto zvire nelze ochocit.",
  81.                                    "zviratko uz ma majitele",
  82.                                    "toto zvire nedokazes"
  83.                                };
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement