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

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
attacking/targeting - looking for help.
Results 1 to 6 of 6

Thread: attacking/targeting - looking for help.

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    19

    attacking/targeting - looking for help.

    Hi.

    I would like to create targeting in my bot. Unfortunately I have some problems with that.
    That is a code what I found:
    Code:
    procedure Attack(name:string;typeof:string;id:integer);
    var
    i,target,attacking:integer;
    nazwa:String;
    PacketBuffer: array [0..200] of byte;
    ProcessID: Cardinal;
    begin
    for i:=1 to 149 do
    Begin
    nazwa:=MemReadString(BATTLELIST_start+i*156+Distance_Name);
    if ((nazwa=name) and (MemReadInteger(BATTLELIST_start+i*156+Distance_IsVisible)<> 0)) then
    begin
    if typeof='name' then target:=MemReadInteger(BATTLELIST_start+i*156+Distance_ID);
    if typeof='id' then target:=MemReadInteger(BATTLELIST_start+id*156+Distance_ID);
    end;
    end;
    MemWriteInteger(Target_ID,target,SizeOf(target));
    attacking:=MemReadInteger(Target_ID);
    GetWindowThreadProcessId(FindWindow('TibiaClient',Nil), @ProcessID);
    packetBuffer[0] := $05;
    packetBuffer[1] := $00;
    packetBuffer[2] := $A1;
    CopyMemory(@packetBuffer[3], @attacking, 4);
    SendPacket(ProcessID, @PacketBuffer, TRUE, FALSE);
    end;
    The problem is that I don't know how could I make it work. I should make a button, but I don't know what should I write there.
    At this moment it looks like that:
    attack ('Goblin', 'monster', 1);
    Do not ask me why 'monster', and why '1' I was just trying...

  2. #2
    Junior Member
    Join Date
    Mar 2014
    Posts
    19
    @edit
    It's unselecting monster when monster is already selected (by myself).

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    9
    nvm I dont really know Delphi, I just started taking classes in it, maybe I can help you in a few months :P
    Last edited by Faun; 05-12-2014 at 07:39 PM.

  4. #4
    Senior Member
    Join Date
    Mar 2009
    Location
    Brazil
    Posts
    266
    You're incorrectly using the function.

    Before copying a code and pasting it on your project, try to understand what it does.

    This function gets 3 parameters:
    -1st: the creature's name that you want to attack;
    -2nd: the "way" you want to find this target. It can be 'name' or 'id' (which actually isn't the creature ID but it's INDEX/POSITION on the battlist)
    -3rd: the creature index on the battlelist (the param is only used if you put 'id' on the 2nd param);

    Eg.:

    Attack('Dragon','name',0);

    The function will attack the FIRST Dragon it can find on the battlelist.

    Attack('Dragon','id',3)

    The function will attack the creature that is on the 3rd index of the battlelist IF it's a dragon.

    *on my opinion, this second option is really useless / dumb*

  5. #5
    Junior Member
    Join Date
    Mar 2014
    Posts
    19
    Unfortunetly it sending wrong packets to the game and it doing nothing.
    Check it:
    GAMECLIENT1>( hex ) 05 00 A1 54 72 61 69 //b3
    That's the packet what bot is sending.
    05 00 A1 59 0B 00 40
    That's the packet what could be. It's working wrong. Have you got any other attacking procedure?

  6. #6
    Senior Member
    Join Date
    Mar 2009
    Location
    Brazil
    Posts
    266
    The attacking packet has the following structure:
    -05
    -00
    -A1
    -Creature ID
    -Attack count

    You can take a look at: https://code.google.com/p/tibiaapi/s...ttackPacket.cs

    Unfortunately i'm not into packets so i can't help you more than this...

    Also there is a few ways to attack a creature:
    -Through packet (as you're doing)
    -Clicking on the battlelist / clicking on the screen
    -Hooking an internal function
    http://tpforums.org/forum/threads/61...ll=1#post26554

Posting Permissions

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