Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
how do i skip/jump in a loop
Results 1 to 4 of 4

Thread: how do i skip/jump in a loop

  1. #1
    Junior Member
    Join Date
    Feb 2016
    Posts
    2

    how do i skip/jump in a loop

    Hello!
    Starting to learn c# and for the life of me can't figure out how to get a cavebot to jump loops. I made a "Friendly" mode so it only attacks blacksquared mobs, but I wan't there to be an option to cancel that aswell.
    Heres my code:
    Code:
                            foreach (Creature c in new Battlelist().GetCreatures())
                            {
                                
                              if (chkFriendly.Checked && c.HasAttackedMeRecently(2000))
                             {
    
    
                                 if (c.Type == (byte)Constants.Type.CREATURE)
                                 {
                                     if (c.Z == player.Z)
                                     {
                                         int x = Math.Abs(player.X - c.X);
                                         int y = Math.Abs(player.Y - c.Y);
                                         int rng = Int32.Parse(txtRange.Text);
    
                                         if (x <= rng && y <= rng)
                                         {
    
                                             if (target == null) target = c;
                                             if (c.Location.DistanceTo(target.Location) < player.Location.DistanceTo(target.Location))
                                             {
                                                 if (x == 1 && y == 1)
                                                 {
                                                     target = c;
                                                 }
                                                 else
                                                 {
                                                     target = c;
                                                 }
                                             }
                                         }
                                    }
    
                                 }
                                   
                                }
                            }
                            if (target != null)
                            {
                                //int x = Math.Abs(player.X - target.X);
                                //int y = Math.Abs(player.Y - target.Y);
                                fromX = target.X - player.X;
                                fromY = target.Y - player.Y;
                                fromX *= tileX;
                                fromY *= tileY;
                                int pX = (p2.X - p1.X) / 2 + p1.X; //865
                                int pY = (p2.Y - p1.Y) / 2 + p1.Y; // 425
                                fromX += pX;
                                fromY += pY;
                                foundTarget = true;
                            }
                            if (foundTarget)
                            {
                                Attack();
                                Thread.Sleep(500);
                                continue;
                            }
    
                            //if not walk
                            if (chkwalker.Checked) Walker();
                      }
    Now, my question is. I want to add an checkbox like chkAggressive and if thats checked, then to jump over the "if chkFriendly"

  2. #2
    Code:
    foreach (Creature c in new Battlelist().GetCreatures())
                            {
                                
                              if (chkFriendly.Checked && !c.HasAttackedMeRecently(2000))
                                      continue;
    
                                 if (c.Type == (byte)Constants.Type.CREATURE)
                                 {
                                     if (c.Z == player.Z)
                                     {
                                         int x = Math.Abs(player.X - c.X);
                                         int y = Math.Abs(player.Y - c.Y);
                                         int rng = Int32.Parse(txtRange.Text);
                                      }
                                  }
    }

  3. #3
    Senior Member
    Join Date
    Mar 2009
    Location
    Brazil
    Posts
    266
    Code:
    bool validTarget = false;
    
    foreach (Creature c in new Battlelist().GetCreatures())
    {
    	validTarget = true;
    	
    	if (chkFriendly.Checked) 
    	{
    		if (!c.HasAttackedMeRecently(2000))
    			validTarget = false;
    	}
    Last edited by Ash Katchup; 02-23-2016 at 05:50 PM.

  4. #4
    Junior Member
    Join Date
    Jan 2015
    Posts
    27
    Tibia API?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •