RR Switch

Datum: 22/11/2014 23:25:19

Staženo: 463x

Popis:

Kdo zná pochopí ... 


Hodnocení: 3.4/10 (129 hlasy)

Download file:cs

Příkazy:

  • ,reflex

Kód:

using System;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Text;
using Phoenix;
using Phoenix.WorldData;
using System.Linq;
using Phoenix.Communication;
using Phoenix.Runtime;
using Phoenix.Runtime.Reflection;

namespace Scripts.smoce
{       
  public class ultima_smoce_net
	{

        /// <summary>
        /// Timer na změnu dalšího...
        /// </summary>
        public const int timer = 30; //sec

        /// <summary>
        /// Timer na změnu dalšího...
        /// </summary>
        public const int timer_remove = 10; //sec

        /// <summary>
        /// Zapnout PRINT hlasky:
        /// True - Ano 
        /// False - Ne
        /// </summary>
        public const bool print = true;

        /// <summary>
        /// true - ano
        /// false - ne
        /// Sundavat pri stisknuti z ruky do backpacku RING
        /// </summary>
        public const bool unring = true; 

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////


        private const ushort ring_type = 0x108A; // all same is!

        private const ushort rr = 0x0496; // Name: "Reflex Ring (5 charges)" && Name: "Reflex Ring (0 charges)"
        private const ushort grr = 0x0B21; // Name: "Great Reflex Ring"
        private const ushort grrcharges = 0x0020; // Name: "Great Reflex Ring (9 charges)"
       // private const ushort grrchargess = 0x0000; // Name: "Great Gold Ring (6 charges)"  

        private  Dictionary<Serial, DateTime> pozite = new Dictionary<Serial, DateTime>();
        private  List<Serial> prazdny = new List<Serial>();
        private  DateTime timers;


         [Command]
        public void reflex()
        { 
             
             //jeli timer u poziteho prstenu vetsi jak 180s smaze se.
          
            List<Serial> itemsToRemove = new List<Serial>();

            foreach (var pair in pozite)
            {
                TimeSpan timer = DateTime.Now - pair.Value;

                if (timer.Seconds >= timer_remove)
                {
                    itemsToRemove.Add(pair.Key);
                }
            }

            foreach (Serial item in itemsToRemove)
            { 
                pozite.Remove(item); 
            }            
                
            string[] linesback;  
            foreach (UOItem prsten in from c in World.Player.Backpack.AllItems where c.Graphic == ring_type && !prazdny.Contains(c.Serial) && !pozite.ContainsKey(c.Serial) && (c.Color == rr || c.Color == grr || c.Color == grrcharges ) select c)//|| c.Color == grrchargess
            {
                UO.DeleteJournal();
                EnsureItem(prsten);

                string[] lines = prsten.Name.Split('(');
                if (lines.Length >= 2)
                {
                  linesback = lines[1].Split(' ');
                }
                else { linesback = new string[] { "1" }; }

                if (Int32.Parse(linesback[0]) > 0 && linesback[0] != "")
                {
                    prsten.Equip();
                    UO.Wait(500);
                    if (World.Player.Layers[Layer.Ring] == prsten.Serial)
                    {
                        pozite.Add(prsten.Serial, DateTime.Now);
                        timers = DateTime.Now;
                        UO.Print("Nasazen: {0} Nabiti {1}", prsten.Name, linesback[0].ToString());
                        // sundava prsteny do backpacku
                        unrings();
                        return;
                    }
                    if (UO.InJournal("It too soon to use it again") || UO.InJournal("The item should be equipped to use") || UO.InJournal("You have to wait"))
                    { 
                        UO.Print("Jeste nemuzes pouzit REFLEX !");
                       // TimeSpan asds = DateTime.Now - timers;
                       // string vystup;
                       // if ((asds.Seconds - timer) <= 0) {vystup = "Nevim"; } else {vystup = (asds.Seconds - timer).ToString(); } 
                       // UO.Print("[Asi {0}]", vystup);
                        return;
                    }
                     
                }
                else
                {
                    if (Int32.Parse(linesback[0]) == 0)
                    {
                        prazdny.Add(prsten.Serial);
                    }
                }
                
            } 
        } 


         private void unrings()
         {
             if (unring == true && World.Player.Weight <= (World.Player.MaxWeight - 20))
             {
                 World.Player.Layers[Layer.Ring].Move(0, World.Player.Backpack);
             }
             else
             {
                 if (unring == true)
                 {
                     info("Mas vysokou vahu na sundani prstenu!", false);
                 }
             } 
         }


         private void info(string hlaska,bool hlava)
         {
             info(0x00baf, hlaska,hlava);
         }

         private void info(ushort color , string hlaska, bool hlava)
         {
              if (print)
                 {
                         if (!hlava)
                         {
                              UO.Print(color, "Reflex: {0}", hlaska); 
                         }
                         else
                         {
                             World.Player.Print(color, "Reflex: {0}", hlaska);
                         }

                 }
         }

         public static void EnsureItem(UOItem item)
         {
            // if (String.IsNullOrEmpty(item.Name)) 
             item.Click();
             UO.Wait(100);
         }
		}
	}
	
	  

Nový komentář