public void WhenGetTarget()
 {
     uint   nbits  = 0x1d00ffff; // 4 bits
     var    result = TargetHelper.GetTarget(nbits);
     var    hex    = result.ToHexString();
     string s      = "";
 }
示例#2
0
 /// <summary>
 ///Overrides base.OnTarget and handles entity targets.
 ///      Allowed parameters are :
 ///       * Object inherited from UOEntity
 ///       * Object inherited from Serial
 ///       * ID of datatype "uint"
 /// </summary>
 protected override bool OnTarget(params object[] args)
 {
     if (base.OnTarget(args))
     {
         if (args != null)
         {
             if (args.Length.Equals(1))
             {
                 if (args[0] is UOEntity)
                 {
                     return(TargetHelper.GetTarget().TargetTo(((UOEntity)args[0]).Serial));
                 }
                 if (args[0] is Serial)
                 {
                     return(TargetHelper.GetTarget().TargetTo((Serial)args[0]));
                 }
                 if (args[0] is uint)
                 {
                     return(TargetHelper.GetTarget().TargetTo(new Serial((uint)args[0])));
                 }
             }
         }
     }
     return(false);
 }
示例#3
0
 /// <summary>
 ///Function wich controls the targeting workflow.
 /// </summary>
 public virtual bool Action(params object[] args)
 {
     if (TargetHelper.GetTarget().WaitForTarget(Delay))
     {
         return(OnTarget(args) ? OnFinish(args) : OnCancel(args));
     }
     return(OnTimeout(args));
 }
        private JObject GetBlockTemplate(JObject response)
        {
            var transactions = MemoryPool.Instance().GetTransactions();
            var blockChain   = _blockChainStore.GetBlockChain();

            if (transactions == null || !transactions.Any())
            {
                response["result"] = null;
                return(response);
            }

            var currentBlock       = blockChain.GetCurrentBlock();
            var height             = blockChain.GetCurrentBlockHeight();
            var previousBlockHash  = currentBlock.GetHashHeader().ToHexString();
            var transactionBuilder = new TransactionBuilder();
            var nonce = BitConverter.GetBytes(NonceHelper.GetNonceUInt64());
            var value = transactions.Sum(t => _transactionHelper.GetFee(t.Transaction, _network));
            var coinBaseTransaction = transactionBuilder.NewCoinbaseTransaction()
                                      .SetInput((uint)height + 1, nonce)
                                      .AddOutput(value, Script.CreateCorrectScript())
                                      .Build();
            var result        = new JObject();
            var jTransactions = new JArray();

            foreach (var transaction in transactions)
            {
                jTransactions.Add(transaction.Transaction.Serialize().ToHexString());
            }


            var currentTime    = DateTime.UtcNow.ToUnixTimeUInt32();
            var coinBaseTxnObj = new JObject();

            coinBaseTxnObj.Add("data", coinBaseTransaction.Serialize().ToHexString());
            result.Add("coinbasetxn", coinBaseTxnObj);
            result.Add("expires", "120");
            result.Add("longpollid", "");
            result.Add("height", blockChain.GetCurrentBlockHeight() + 1);
            result.Add("curtime", currentTime);
            result.Add("previousblockhash", previousBlockHash);
            result.Add("transactions", jTransactions);
            result.Add("version", BlockHeader.CURRENT_VERSION);
            result.Add("target", TargetHelper.GetTarget(Constants.DEFAULT_NBITS).ToHexString());
            result.Add("bits", Constants.DEFAULT_NBITS);
            response["result"] = result;
            return(response);
        }
示例#5
0
        public static void InsureItem(Loot _loot)
        {
            Stealth.Client.RequestContextMenu(Self.Serial.Value);
            Stealth.Client.SetContextMenuHook(Self.Serial.Value, 9);

            Thread.Sleep(1500);

            var _helper = TargetHelper.GetTarget();

            _helper.AutoTargetTo(_loot.Serial);

            Thread.Sleep(500);

            Stealth.Client.CancelMenu();
            Stealth.Client.CancelTarget();

            ConsoleMessage("Insured Item: {0}", _loot.Serial.Value);
        }
示例#6
0
 /// <summary>
 ///Overrides base.OnTarget and handles tile and location targets.
 ///      Allowed parameters are :
 ///       * (Point3D Point)
 ///       * (ushort Tile, Point3D Point)
 ///       * (int X, int Y, int Z)
 ///       * (Ushort Tile, int X, int Y, int Z "uint"
 /// </summary>
 protected override bool OnTarget(params object[] args)
 {
     if (base.OnTarget(args))
     {
         if (args != null)
         {
             if (args.Length.Equals(1))
             {
                 if (args[0] is Point3D)
                 {
                     return(TargetHelper.GetTarget().TargetTo(((Point3D)args[0])));
                 }
             }
             if (args.Length.Equals(2))
             {
                 if ((args[0] is ushort) && (args[1] is Point3D))
                 {
                     return(TargetHelper.GetTarget().TargetTo((ushort)args[0], ((Point3D)args[1])));
                 }
             }
             if (args.Length.Equals(3))
             {
                 if ((args[0] is int) && (args[1] is int) && (args[2] is int))
                 {
                     return(TargetHelper.GetTarget().TargetTo(new Point3D((int)args[1], (int)args[2], (int)args[3])));
                 }
             }
             if (args.Length.Equals(4))
             {
                 if ((args[0] is ushort) && (args[1] is int) && (args[2] is int) && (args[3] is int))
                 {
                     return(TargetHelper.GetTarget().TargetTo((ushort)args[0], new Point3D((int)args[1], (int)args[2], (int)args[3])));
                 }
             }
         }
     }
     return(false);
 }
示例#7
0
        public void Check(Block block)
        {
            if (block == null)
            {
                throw new ArgumentNullException(nameof(block));
            }

            var merkleRoot           = block.BlockHeader.MerkleRoot; // Check MERKLE-ROOT.
            var calculatedMerkleRoot = block.GetMerkleRoot();

            if (!merkleRoot.SequenceEqual(calculatedMerkleRoot))
            {
                throw new ValidationException(ErrorCodes.InvalidMerkleRoot);
            }

            var blockChain   = _blockChainStore.GetBlockChain(); // Check PREVIOUS BLOCK.
            var currentBlock = blockChain.GetCurrentBlock();

            if (!currentBlock.GetHashHeader().SequenceEqual(block.BlockHeader.PreviousBlockHeader))
            {
                throw new ValidationException(ErrorCodes.InvalidPreviousHashHeader);
            }

            var hash         = currentBlock.GetHashHeader();
            var currentNBits = Constants.DEFAULT_NBITS; // TODO : CALCULATE THE DEFAULT NBITS : https://bitcoin.org/en/developer-guide#proof-of-work
            var target       = TargetHelper.GetTarget(currentNBits);

            if (!TargetHelper.IsValid(hash, target))
            {
                throw new ValidationException(ErrorCodes.NotEnoughDifficult);
            }

            foreach (var transaction in block.Transactions) // Check ALL TRANSACTIONS.
            {
                _transactionValidator.Check(transaction);
            }
        }
示例#8
0
        private ChopTreeResult ChopTree(Item hatchet, StealthAPI.StaticItemRealXY tile)
        {
            hatchet.DoubleClick();
            TargetHelper.GetTarget().WaitForTarget(5000);

            DateTime dateTime    = DateTime.Now;
            DateTime maxDateTime = dateTime.AddMilliseconds(LUMBERJACKING_HIT_TIMEOUT);

            TargetHelper.GetTarget().TargetTo(tile.Tile, new Data.Point3D(tile.X, tile.Y, tile.Z));

            while (DateTime.Now < maxDateTime)
            {
                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("You hack at the tree for a while, but fail to produce any useable wood", dateTime, DateTime.Now) >= 0)
                {
                    return(ChopTreeResult.CONTINUE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("You put the logs in your pack", dateTime, DateTime.Now) >= 0)
                {
                    return(ChopTreeResult.CONTINUE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("There is nothing here to chop", dateTime, DateTime.Now) >= 0)
                {
                    return(ChopTreeResult.DONE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("It appears immune to your blow", dateTime, DateTime.Now) >= 0)
                {
                    return(ChopTreeResult.DONE);
                }

                Thread.Sleep(50);
            }

            return(ChopTreeResult.DONE);
        }
示例#9
0
        static void Main(string[] args)
        {
            ObjectOptions.ToolTipDelay = 500;

            Self.Backpack.DoubleClick();

            Stealth.Client.Wait(1000);

            Stealth.Client.AddItemToContainer += OnAdd;
            Stealth.Client.ClilocSpeech       += OnClilocSpeech;
            Stealth.Client.Speech             += OnSpeech;

            ConsoleMessage("Target loot bag");

            LootBag = RequestTarget();
            LootBag.DoubleClick();

            Stealth.Client.Wait(1000);

            List <Item> _backpackItems = new List <Item>();
            List <uint> _findList      = new List <uint>();

            Stealth.Client.FindTypeEx(0xFFFF, 0xFFFF, Self.Backpack.Serial.Value, true);
            if (!(Stealth.Client.GetFindCount() == 0))
            {
                _findList = Stealth.Client.GetFindList();
            }

            foreach (uint _item in _findList)
            {
                Stealth.Client.Ignore(_item);
                Scanner.Ignore(_item);
            }

            ConsoleMessage("starting loot routine...", ConsoleColor.DarkYellow);
            Looting      = true;
            LootingItems = false;

            Scanner.Initialize();

            Scanner.Range         = 5;
            Scanner.VerticalRange = 5;

            Stealth.Client.SetFindDistance(5);
            Stealth.Client.SetFindVertical(5);
            Stealth.Client.SetMoveThroughNPC(0);

            var _virtuehelper = VirtueHelper.GetVirtues();
            var _targethelper = TargetHelper.GetTarget();

            while (Stealth.Client.GetConnectedStatus())
            {
                try
                {
                    #region Combat
                    Stealth.Client.ClearBadLocationList();

                    var _monster = Item.Find(typeof(FanDancer), 0x0, false).OrderBy(x => x.Distance).ToList();

                    //ConsoleMessage("{0},{1}", Self.Location.X, Self.Location.Y);

                    _virtuehelper.Request();

                    /*
                     * If current target is dead, find a new target
                     * if new target is 100% hp, honor target
                     * else follow current target until it's dead if we're not looting
                     *
                     */

                    if (CurrentTarget == null || CurrentTarget.Dead || !CurrentTarget.Valid)
                    {
                        if (_monster.Any())
                        {
                            CurrentTarget = _monster.First().Cast <Mobile>();
                            ConsoleMessage("Current target set to: {0}", ConsoleColor.Magenta, CurrentTarget.Serial.Value.ToString());

                            Stealth.Client.UseVirtue(Virtue.Honor);
                            Stealth.Client.WaitTargetObject(CurrentTarget.Serial.Value);

                            Self.Attack(CurrentTarget.Serial);
                        }
                    }

                    //entrance room

                    /*if (((ushort)CurrentTarget.Location.X >= 79 && (ushort)CurrentTarget.Location.X <= 97)
                     *  && ((ushort)CurrentTarget.Location.Y >= 326 && (ushort)CurrentTarget.Location.Y <= 344))*/


                    //bloody room

                    /*if (((ushort)CurrentTarget.Location.X >= 104 && (ushort)CurrentTarget.Location.X <= 115)
                    *   && ((ushort)CurrentTarget.Location.Y >= 640 && (ushort)CurrentTarget.Location.Y <= 660))*/


                    if (((ushort)CurrentTarget.Location.X >= 79 && (ushort)CurrentTarget.Location.X <= 97) &&
                        ((ushort)CurrentTarget.Location.Y >= 326 && (ushort)CurrentTarget.Location.Y <= 344))
                    {
                        Self.Movement.newMoveXY((ushort)CurrentTarget.Location.X, (ushort)CurrentTarget.Location.Y, true, 0, true);
                        Self.Attack(CurrentTarget.Serial);
                    }

                    /* For leafblade
                     * if (Self.Mana > 35 && Self.HealthPercent > 70)
                     *  Self.UseSecondaryAbility();
                     * else if (Self.Mana > 35 && Self.HealthPercent < 70)
                     *  Self.UsePrimaryAbility();
                     */

                    if (Self.Mana > 35)
                    {
                        Self.UsePrimaryAbility();
                    }

                    //if (Self.HealthPercent < 50)
                    //Self.Cast("Evasion");
                    //if (Self.HealthPercent < 80 && !Confidence)
                    //Self.Cast("Confidence");

                    #endregion

                    #region Loot
                    var _corpses = Item.Find(typeof(Corpse), 0x0, false).OrderBy(x => x.Distance).ToList();

                    if (_corpses.Count > 0)
                    {
                        foreach (Corpse _corpse in _corpses)
                        {
                            if (_corpse.Distance < 3)
                            {
                                LootCorpse(_corpse);
                                Scanner.Ignore(_corpse.Serial);
                            }
                            else
                            {/*
                              * if (((ushort)_corpse.Location.X >= 79 && (ushort)_corpse.Location.X <= 97)
                              * && ((ushort)_corpse.Location.Y >= 326 && (ushort)_corpse.Location.Y <= 344))*/
                             //Bloody room

                                /*if (((ushort)_corpse.Location.X >= 104 && (ushort)_corpse.Location.X <= 115)
                                *   && ((ushort)_corpse.Location.Y >= 640 && (ushort)_corpse.Location.Y <= 660))*/
                                if (((ushort)_corpse.Location.X >= 79 && (ushort)_corpse.Location.X <= 97) &&
                                    ((ushort)_corpse.Location.Y >= 326 && (ushort)_corpse.Location.Y <= 344))
                                {
                                    Self.Movement.MoveXYZ((ushort)_corpse.Location.X, (ushort)_corpse.Location.Y, (sbyte)_corpse.Location.Z, 1, 1, true);
                                    LootCorpse(_corpse);
                                    Scanner.Ignore(_corpse.Serial);
                                }
                            }
                        }
                    }
                    #endregion

                    Thread.Sleep(2000);
                }
                catch (Exception ex)
                {
                    ConsoleMessage("Error in main routine: {0}", ex.StackTrace);
                }
            }
        }
示例#10
0
        private MineTileResult MineTile(Item pickaxe, StealthAPI.StaticItemRealXY tile)
        {
            pickaxe.DoubleClick();
            TargetHelper.GetTarget().WaitForTarget(5000);

            DateTime dateTime    = DateTime.Now;
            DateTime maxDateTime = dateTime.AddMilliseconds(MINING_HIT_TIMEOUT);

            TargetHelper.GetTarget().TargetTo(tile.Tile, new Data.Point3D(tile.X, tile.Y, tile.Z));

            while (DateTime.Now < maxDateTime)
            {
                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("You loosen some rocks but fail to find any useable ore", dateTime, DateTime.Now) >= 0)
                {
                    return(MineTileResult.CONTINUE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("You put the", dateTime, DateTime.Now) >= 0)
                {
                    return(MineTileResult.CONTINUE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("There is nothing here to mine", dateTime, DateTime.Now) >= 0)
                {
                    return(MineTileResult.DONE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("Try mining elsewhere", dateTime, DateTime.Now) >= 0)
                {
                    return(MineTileResult.DONE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("That is too far", dateTime, DateTime.Now) >= 0)
                {
                    return(MineTileResult.DONE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("You have no line of sight to that location", dateTime, DateTime.Now) >= 0)
                {
                    return(MineTileResult.DONE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("You cannot mine", dateTime, DateTime.Now) >= 0)
                {
                    return(MineTileResult.DONE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("Try mining in rock", dateTime, DateTime.Now) >= 0)
                {
                    return(MineTileResult.DONE);
                }

                if (StealthAPI.Stealth.Client.InJournalBetweenTimes("You decide not to mine for now", dateTime, DateTime.Now) >= 0)
                {
                    return(MineTileResult.DONE);
                }

                Thread.Sleep(50);
            }

            return(MineTileResult.DONE);
        }