Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Travian Bot

  1. #1
    Remend
    Remend is offline
    New member
    Join Date
    2010 Nov
    Posts
    6
    Thanks Thanks Given 
    2
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    Unhappy Travian Bot

    Hello, I'm currently working on a bot for the browser game travian, using Delphi 7. I have some problems though.
    I would like the bot to follow specific links, which I don't know but they are button-like, is there a way to do this?

    Game link: travian

    Thanks in advance

  2. #2
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    Re: Travian Bot

    Remend
    Please, be more specific: where exactly the problem? If you don't know links, then sniff http requests (you can use httpfox plugin for firefox)
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  3. #3
    Remend
    Remend is offline
    New member
    Join Date
    2010 Nov
    Posts
    6
    Thanks Thanks Given 
    2
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    Re: Travian Bot

    I can easily list all the links of the site with:

    Code:
    for i := 0 to WebBrowser1.OleObject.Document.Links.Length - 1 do
        begin
          Listbox1.Items.Add(WebBrowser1.OleObject.Document.Links.item(i).href);
        end;
    end;
    But I want to follow a specific link, for example I would like to follow the link in red box as shown in the picture below

    [thumb]http://img192.imageshack.us/img192/2961/travianrevex.jpg[/thumb]

    Sorry for the game's language

  4. #4
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    Re: Travian Bot

    hm, just get all http requests when you click on this link. I think it's only one way: get http request, get parameters from request, host etc
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  5. The Following User Says Thank You to Dwar For This Useful Post:


  6. #5
    Remend
    Remend is offline
    New member
    Join Date
    2010 Nov
    Posts
    6
    Thanks Thanks Given 
    2
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    Re: Travian Bot

    Thank you for your answer it helped a lot. I just want to ask one more thing. As you can see there are 4 kind of resources for this game. These are 486/2300 and the other 3 (I don't care about the fourth).The question is how can I use them in a variable? I only want 486 value not /2300.

    Thanks a lot

  7. #6
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    Re: Travian Bot

    These values come from the server? Or they are calculated on client side? If from server, then you should parse html and find needed string/tags with value 486
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  8. #7
    Remend
    Remend is offline
    New member
    Join Date
    2010 Nov
    Posts
    6
    Thanks Thanks Given 
    2
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    Re: Travian Bot

    These values come from server. The value 486 means that you have 486 wood out of maximum capacity, which is 2300. Also the value 486 is not a constant as you gain more wood over time, so searching for 486 is meaningless as it changes.
    This is the html code for the resources:



    Code:
    <div id="res">
    	<div id="resWrap">
    		<table cellpadding="1" cellspacing="1">
    			<tr>
    									<td></td>
    
    					<td id="l4" title="132">954/2300</td>
    									<td></td>
    					<td id="l3" title="132">1869/2300</td>
    									<td></td>
    					<td id="l2" title="132">1509/2300</td>
    									<td></td>
    					<td id="l1" title="87">1926/2300</td>
    
    														<td></td>
    				<td>159/246</td>
    			</tr>
    		</table>
    	</div>
    </div>

  9. #8
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    Re: Travian Bot

    Html is clean, you can write regex expression to get values from strings <td id="l4" title="132">954/2300</td> etc. Moreover, it seems that all data are well formatted (id="res" -> id="resWrap" -> id="l4") so parsing will not be difficult
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  10. #9
    Remend
    Remend is offline
    New member
    Join Date
    2010 Nov
    Posts
    6
    Thanks Thanks Given 
    2
    Thanks Thanks Received 
    0
    Thanked in
    0 Posts
    Rep Power
    0

    Re: Travian Bot

    I came up with a solution. First finding the item then using it:

    Code:
     lbl_wood.Caption := WebBrowser1.OleObject.Document.all.item(183).InnerText;
    At this point I would like to ask how can I seperate 486 from 486/2300, I know this could be very easy but I can't solve it yet

  11. #10
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    Re: Travian Bot

    it's simple:
    var ss : TStringlist;
    begin
    ss := TStringlist.Create;
    ss.Delimiter := '/';
    ss.DelimitedText := '486/2300';


    or you can use cycle to find '/', then split string
    var i : short;
    temp_str : string;
    str_val1, str_val2 : integer;
    begin
    temp_str := '486/2300';
    for I := 0 to length(temp_str) - 1 do
    if temp_str[i+1] = '/' then
    break;
    str_val1 := strtoint( copy(temp_str,0, i));
    str_val2 := strtoint( copy(temp_str, i+2, length(temp_str)));
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  12. The Following User Says Thank You to Dwar For This Useful Post:


Page 1 of 2 12 LastLast

Posting Permissions

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