World of Kungfu Bot (Updated)

You may request or share scripts for MicroMacro in this forum.
Message
Author
User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: World of Kungfu Bot (Updated)

#21 Post by 3cmSailorfuku » Sun Feb 03, 2008 7:41 pm

elverion wrote:Actually I'm not even sure how would be the best to go about this. There are several ways it can be done.

It might be easiest to just inject some DLLs into the target process, and have MicroMacro send a message requesting that the DLL call the functions from within the program. It's actually kind of a lot of work, I guess, but I'd like to have the system not dependent on having modified clients.
There's no other real way to go around that "not having modified clients", I don't even know myself another way than hooking and sending requests. You only could put it on kernel level to assure that it works for some of the games atleast. A hook would be total necessary I think.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: World of Kungfu Bot (Updated)

#22 Post by Administrator » Sun Feb 03, 2008 11:14 pm

Well, right, what I meant by not modifying the client is not decompiling, adding/removing code from it, and recompiling. A hook wouldn't actually modify the binary of the client; just manipulate it's memory space during runtime.

If you want to go ahead and do some research on different methods we might be able to achieve this, that would be awesome.

I'm still working on setting up hosting. A friend of mine and I will probably share an account and split the cost. We aren't going to be needing 3 terabytes bandwidth a month separate, so it works out well.

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: World of Kungfu Bot (Updated)

#23 Post by 3cmSailorfuku » Mon Feb 04, 2008 9:30 am

elverion wrote:Well, right, what I meant by not modifying the client is not decompiling, adding/removing code from it, and recompiling. A hook wouldn't actually modify the binary of the client; just manipulate it's memory space during runtime.

If you want to go ahead and do some research on different methods we might be able to achieve this, that would be awesome.

I'm still working on setting up hosting. A friend of mine and I will probably share an account and split the cost. We aren't going to be needing 3 terabytes bandwidth a month separate, so it works out well.
Ofcourse it wouldnt, I couldnt even imagine why you would want to modify a client executable for a hook. Except maybe IsDebuggerPresent or Anitcheat, etc. :P

If you want you may use the "special" words for such stuff, that just got me confused.
just manipulate it's memory space during runtime. = Stack :)

Perhaps you could take a look into OpenKore for the XKore code (Its not c++), it uses the games dll to deliver system messages as "Announcements" ingame. If you want to take a look at good examples you should look for diablo hack sources, there are quite enough and well documented sources and most of them rely on hooks and more advanced memory poking.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: World of Kungfu Bot (Updated)

#24 Post by Administrator » Mon Feb 04, 2008 3:10 pm

Yeah, I wrote a couple cheats for America's Army that relied on hooking. The one that I thought was funniest was when i had 56 kills, 7 deaths on bridge crossing, with an M24. Occasionally I had to let them kill me to prevent it from being too obvious (such as when I knew they were sneaking up behind me, but I didn't want to turn around because it would be obvious I knew they were there).

But anyways, there are a lot of cheats that require modifying client files. I just want to try and stay clear from that, as it's beyond the scope of my software.

felix_fx2
Posts: 11
Joined: Fri Feb 01, 2008 9:01 pm

Re: World of Kungfu Bot (Updated)

#25 Post by felix_fx2 » Mon Feb 04, 2008 4:59 pm

elverion wrote:Actually I'm not even sure how would be the best to go about this. There are several ways it can be done.

It might be easiest to just inject some DLLs into the target process, and have MicroMacro send a message requesting that the DLL call the functions from within the program. It's actually kind of a lot of work, I guess, but I'd like to have the system not dependent on having modified clients.
not wise even when it can be very easy to gain control. if so u'll have to put up with one bunch of noobs to support

here i tried to add one more class in, but admist in fine-tuning it. i am free if i dun have user who have problems with their pcs at work.

P.S; i work helpdesk, but only for around 300 users.
Attachments
kungfubow.lua
(9.38 KiB) Downloaded 407 times

Seventhhen
Posts: 1
Joined: Thu Mar 06, 2008 1:41 pm

Re: World of Kungfu Bot (Updated)

#26 Post by Seventhhen » Thu Mar 06, 2008 1:51 pm

I was reading your posts regarding movement.
From a practical standpoint, given that you have the pointers/offsets for the map, and that the script runs against a 1024x780 window...

Use the double left-click on mini-map to move relative to where you are (character is always centered). I did a quick test and you can move the mouse and double click on whereever you want to go...you'd just need a coordinate system for movement and a way to calculate the distance, maybe a timer to estimate time for travel?

Example:
You are at 100, 100 (map)
You want to go to 200, 200 (map)
You know that the center of the map is mouse coord 900x100 (roughly)
You know that clicking a given number of pixels in any direction from center of the map will take you so far...at least for that map.
You could guess how long it takes to travel so you're waiting a reasonable time before taking another script action.

You could probably use an include script for various paths of travel (so you don't mess up your main script)?

felix_fx2
Posts: 11
Joined: Fri Feb 01, 2008 9:01 pm

Re: World of Kungfu Bot (Updated)

#27 Post by felix_fx2 » Thu May 08, 2008 3:07 pm

any new updates.

Hp offset no longer valid.

idk, the window name has been changed also.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: World of Kungfu Bot (Updated)

#28 Post by Administrator » Thu May 08, 2008 8:24 pm

Window name is irrelevant. You can select the window from the executable.
proc = openProcess( findProcessByExe("GongfuClient.exe") );
Also, you can use the tutorials here to help you lookup the new pointer. The offset is probably the same, but the pointer itself often changes across different versions.

felix_fx2
Posts: 11
Joined: Fri Feb 01, 2008 9:01 pm

Re: World of Kungfu Bot (Updated)

#29 Post by felix_fx2 » Thu May 15, 2008 10:46 pm

elverion, hackbar just went to look for the new offsets.

Code: Select all

HP_ptr         = "005F3608";
HP_offset      = 192;


MP_ptr         = "005F3608";
MP_offset      = 200;
here's the window i am looking for now.

Code: Select all

function main()
  win = findWindow("Kungfu Client*");
  hdc = openDC(win);
  proc = openProcess( findProcessByExe("GongfuClient.exe") );
  attach(win);

supercraz
Posts: 10
Joined: Tue May 20, 2008 5:13 am

Re: World of Kungfu Bot (Updated)

#30 Post by supercraz » Tue May 20, 2008 5:20 am

hey i got this error when i try to run the bot.



Kungfu.lua:281: bad argument #1 to 'memoryReadIntPtr' <<null>>

Code: Select all

-------------------------------------------------
--World of Kung Fu Bot

--Mystikfox
--Hackbar
--Mangler
-------------------------------------------------
-- Variable declaration -- do not edit
-------------------------------------------------
CLASS_WARRIOR   = 0;
CLASS_MAGE      = 1;
HP              = 10000;
MP              = 10000;
SP              = 10000;


HP_ptr         = "0x005F3608";
HP_offset      = 192;


MP_ptr         = "0x005F3608";
MP_offset      = 200;


SP_ptr         = "020F2910";
SP_offset      = 312;


-------------------------------------------------


-------------------------------------------------
-- character configuration YOU HAVE TO CHANGE THIS STUFF FOR THE BOT TO WORK RIGHT
-------------------------------------------------
class           = CLASS_WARRIOR;
key_attack      = key.VK_1;
key_pickup      = key.VK_TILDE;
key_sit         = key.VK_Z;

key_skill1      = key.VK_2;
key_skill2      = key.VK_3;
key_skill3      = key.VK_4;

key_hppotion    = key.VK_F1;
key_mppotion    = key.VK_F2;
key_sppotion    = key.VK_F3;

-- rest or use potions when low on HP/MP/SP 
HP_potion    = 60;
MP_potion    = 0;
SP_potion    = 0;

HP_sit          = 100;
MP_sit          = 0;
SP_sit          = 0;

-- chance to cast
skill1_chance   = 100;
skill2_chance   = 80;
skill3_chance   = 0;

-- MP cost
skill1_cost     = 38;
skill2_cost     = 20;
skill3_cost     = 80;


have_pig        = 1;            -- set to 1 if you have a fortune pig and want to
				-- skip the manual pickup function	

-- buff stuff
-- NOTE:  set on 10 minutes
-- buff / scroll durations in msec 	time = minutes x 60000
-- to de- activate non used buffs / scrolls replace "1" with "0"
-- to activate buff / scroll replace "0" with "1"
-- scrolls can be used too as buff
-------------------------

buff1_duration 		= 600000;
buff_1			= 0;
buff_key1               = key.VK_8;

buff2_duration 		= 600000;
buff_2         		= 0;
buff_key2                = key.VK_9;

--dont change these
buff1_needed 	= true;
buff2_needed 	= true;




-- cast times in milliseconds
skill1_casttime        = 2000;
skill2_casttime        = 1000;
skill3_casttime        = 3000;

-- skill cool downs in milliseconds (not working)
skill1_cooldown        = 3000;
skill2_cooldown        = 8000;
skill3_cooldown        = 9000;
-------------------------------------------------

function hp_potion()
  keyboardPress(key_hppotion);
end

function mp_potion()
  keyboardPress(key_mppotion);
end

function sp_potion()
  keyboardPress(key_sppotion);
end

-- so we aren't spamming the attack key...
-- we will use a timer to press it once
-- every 3 seconds.
function attack_timer()
  keyboardPress(key_attack);
end

function fight_warrior()
  registerTimer("attack_timer", 3000, attack_timer);

  while( have_target() ) do
    if( HP < HP_potion ) then
      hp_potion(); end
    if( MP < MP_potion ) then
      mp_potion(); end
--    if( SP < SP_potion ) then
--      sp_potion(); end
    keyboardPress(key_skill1);
    yrest(120); 
    keyboardPress(key_skill2);
    yrest(120);  
    keyboardPress(key_skill3);
    yrest(120);
    coroutine.yield();	
  end

  unregisterTimer("attack_timer");

  yrest(1000);
end

function fight_mage()
  while( have_target() ) do
    if( HP < HP_potion ) then
      hp_potion(); end
    if( MP < MP_potion ) then
      mp_potion(); end
    
    local roll = math.random(100);
    if( roll <= skill1_chance and MP >= skill1_cost ) then
      -- cast skill 1
      keyboardPress(key_skill1);
      yrest(skill1_casttime);
    else
      keyboardPress(key_attack);
    end
    
    if( roll <= skill2_chance and MP >= skill2_cost ) then
    -- cast skill 1
    keyboardPress(key_skill2);
    yrest(skill2_casttime);
    else
    keyboardPress(key_attack);
    end

    yrest(100);
    coroutine.yield();
  end

  yrest(1000);
end

-- heal until full HP & MP
function rest_heal()
  if( can_rest == false ) then return; end
  
    keyboardHold(key_sit);
    yrest(50);
    keyboardRelease(key_sit);
  
    -- set a timer to toggle healing in 30 seconds
    registerTimer("heal_rest_timer", 30000, heal_rest_timer);
  
    need_heal = true;
    last_hp = HP;
    while( need_heal ) do
      yrest(100);
      if (HP < last_hp)  then
        print("Under attack! Exiting rest.");
        can_rest = false;
        registerTimer("can_rest_timer", 3000, can_rest_timer);
        break;
      else
        last_hp = HP;
      end
    end
  
    keyboardHold(key_sit);
    yrest(50);
    keyboardRelease(key_sit);
  
  yrest(200);
end

-- toggle can_heal to true, disable timer
function can_rest_timer()
  unregisterTimer("can_rest_timer");
  can_rest = true;
  print("Can rest again.");
end

-- tell heal_rest we no longer need rest
function heal_rest_timer()
  need_heal = false;
end

-- toggle cast needed for buff1
function buff1_timer()
  buff1_needed = true;
end

-- toggle cast needed for buff2
function buff2_timer()
  buff2_needed = true;
end

-- pickup nearby items
function pickup()
  keyboardHold(key_pickup);
  yrest(50);
  keyboardRelease(key_pickup);
  yrest(775)
  keyboardHold(key_pickup);
  yrest(50);
  keyboardRelease(key_pickup);
end



-- you have died! oh noes!
function death_return()
  keyboardPress(key.VK_SNAPSHOT);
  print(os.date("Looks like somebody got you killed.	%X"))
  print("A screen capture has been taken. Open MS Paint and paste it.");
  stopPE(); -- this turns the macro off!
  coroutine.yield(); -- yield to make sure the protected environment stops
end


function move_forward()
  keyboardHold(key.VK_W);
  if( math.random(100) >= 80 )
    then keyboardHold(key.VK_A);
  else if( math.random(100) >= 80 )
    then keyboardHold(key.VK_D); end
  end

  yrest( math.random(2000) );

  keyboardRelease(key.VK_W);
  keyboardRelease(key.VK_A);
  keyboardRelease(key.VK_D);
end









-- update client variables by reading from it's memory
function update_vars()
  HP = memoryReadIntPtr(proc, HP_ptr, HP_offset);
 
  MP = memoryReadIntPtr(proc, MP_ptr, MP_offset);
 
  --SP = memoryReadIntPtr(proc, SP_ptr, SP_offset);
end



-- rotate camera
function rotate_cam()
  wx,wy = windowRect(win);

  mouseSet(wx+512, wy+384);
  yrest(100);
  mouseRHold();
  yrest(100);
  mouseSet(wx+514, wy+384);
  yrest(100);
  mouseRRelease();
  yrest(100);
end



-- selects a nearby monster
function target_monster()
  keyboardHold(key.VK_TAB);
  yrest(50);
  keyboardRelease(key.VK_TAB);
end




-- checks if you have a target
function have_target()
  r,g,b = getPixel(hdc, 506, 31);
  --print(r,g,b); unneeded testcode
  -- check for the goldish color in the monster's HP window
  if( r >= 205 and r <= 225 and g >= 205 and g <= 230 and b >= 185 and b<= 200 ) then
    return true;
  else
    return false;
  end
end



-------------------------------------------------
-- FUNCTION MAIN
-------------------------------------------------
function main()
  win = findWindow("Kungfu Client");
  hdc = openDC(win);
  proc = openProcess( findProcess("GongfuClient.exe") );
  attach(win);

  registerTimer("update_vars", 100, update_vars);
  registerTimer("buff1_timer", buff1_duration, buff1_timer);
  registerTimer("buff2_timer", buff2_duration, buff2_timer);

  
  --pixeltest(); commented test code
  while( 1 ) do
    if( HP == 0 ) then death_return(); end
    if( HP < HP_potion ) then hp_potion(); end
    if( MP < MP_potion ) then mp_potion(); end
    if( HP < HP_sit and can_rest == true ) then rest_heal(); end
    if( MP < MP_sit and can_rest == true ) then rest_heal(); end

    yrest(100);
    target_monster();
    yrest(200);
    if( have_target() ) then
      can_rest = false; -- prevent resting during battle
                        -- for the few that have this bug
      if( class == CLASS_WARRIOR) then fight_warrior(); end
      if( class == CLASS_MAGE) then fight_mage(); end
      can_rest = true;
    else
   
      rotate_cam();
      if( math.random(100) > 90 ) then
        move_forward(); end
    end
    
    
    
   
    if(have_pig == 0) then
    pickup();
    end
    
    if( buff_1 == 1 ) then 
	if( buff1_needed ) then
          keyboardPress(buff_key1);
          print(os.date("buff 1 casted	%X"))
	  buff1_needed = false;
	  yrest(1000);
	end
    end
    if( buff_2 == 1 ) then 
      if( buff2_needed ) then
        keyboardPress(buff_key2);
        print(os.date("buff 1 casted	%X"))
    	buff1_needed = false;
    	yrest(1000);
      end
    end
  end

  detach();
  closeProcess(proc);
end

startMacro(main);
-------------------------------------------------
Im fist type character using the latest micromacro v0.97

Please help me Thank you in advance!

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: World of Kungfu Bot (Updated)

#31 Post by Administrator » Tue May 20, 2008 7:02 am

8. Always use code tags. Whether it be 1 line or 100,000. If you're posting code, precede it by [code] and end it with [/code]. Example:
[code]printf("Hello World");[/code]
Next time, please read and follow the rules. I've already made the change for you this time.

You've got it nearly correct, but there are a few errors. You need to remove the quotes around the addresses (but leave the 0x).

Since the error is generated on line 281, we can go to that line (CTRL+G in notepad) and check the function call. 'proc' is the first argument, which is nil, and was noted in the error message. Because of this we can assume that our call to openProcess() has failed.

Code: Select all

proc = openProcess( findProcess("GongfuClient.exe") );
findProcess() finds by window title. You need to change it to findProcessByExe("GongfuClient.exe") for it to search by executable.

supercraz
Posts: 10
Joined: Tue May 20, 2008 5:13 am

Re: World of Kungfu Bot (Updated)

#32 Post by supercraz » Tue May 20, 2008 7:48 am

Hey i done that ty. but i got another error now.

kunfu.lua:25: malformed number near '020f2910'

sorry i new to this. :)

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: World of Kungfu Bot (Updated)

#33 Post by Administrator » Tue May 20, 2008 8:08 am

On line 25 (as stated in the error), you have this:
SP_ptr = "020F2910";
After removing the quotes, you have 020F2910, which is *NOT* a valid number. Remember to precede it with 0x so that Lua sees it as hexidecimal.

supercraz
Posts: 10
Joined: Tue May 20, 2008 5:13 am

Re: World of Kungfu Bot (Updated)

#34 Post by supercraz » Tue May 20, 2008 9:03 am

I get error. lol Sorry. kungfu.lua:334 ')' expected near 'client'

function main()
win = findWindow(Kungfu Client);
hdc = openDC(win);
proc = openProcess( findProcessByExe(GongfuClient.exe) );
attach(win);

supercraz
Posts: 10
Joined: Tue May 20, 2008 5:13 am

Re: World of Kungfu Bot (Updated)

#35 Post by supercraz » Tue May 20, 2008 9:10 am

Wow sorry im an idiot.. got it now TYVM.

Works great thanks

supercraz
Posts: 10
Joined: Tue May 20, 2008 5:13 am

Re: World of Kungfu Bot (Updated)

#36 Post by supercraz » Thu May 22, 2008 5:27 pm

is there a way to make the bot walk/run much smoother and keep the bot in a corrdinate area? so it says in the radius from where it started?

Thanks

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: World of Kungfu Bot (Updated)

#37 Post by Administrator » Thu May 22, 2008 7:15 pm

The unsmoothness to walking is because the bot spams the hotkeys, hence interrupting the animation sequence. It should be client sided only, so no harm is really done. You could gather the coordinates of your character and use this to turn your character back if he/she strays too far, but it's more trouble than it's worth.

supercraz
Posts: 10
Joined: Tue May 20, 2008 5:13 am

Re: World of Kungfu Bot (Updated)

#38 Post by supercraz » Fri May 30, 2008 4:53 am

how about setting up something that tells the script that the armor is low and logs off? is that possible

supercraz
Posts: 10
Joined: Tue May 20, 2008 5:13 am

Re: World of Kungfu Bot (Updated)

#39 Post by supercraz » Fri May 30, 2008 5:27 am

Code: Select all

-------------------------------------------------
--World of Kung Fu Bot

--Mystikfox
--Hackbar
--Mangler
-------------------------------------------------
-- Variable declaration -- do not edit
-------------------------------------------------
CLASS_WARRIOR   = 0;
CLASS_MAGE      = 1;
HP              = 10000;
MP              = 10000;
SP              = 10000;


HP_ptr         = 0x005F3608;
HP_offset      = 192;


MP_ptr         = 0x005F3608;
MP_offset      = 200;


SP_ptr         = 0x020F2910;
SP_offset      = 312;


-------------------------------------------------


-------------------------------------------------
-- character configuration YOU HAVE TO CHANGE THIS STUFF FOR THE BOT TO WORK RIGHT
-------------------------------------------------
class           = CLASS_WARRIOR;
key_attack      = key.VK_1;
key_pickup      = key.VK_TILDE;
key_sit         = key.VK_Z;

key_skill1      = key.VK_2;
key_skill2      = key.VK_3;
key_skill3      = key.VK_4;

key_hppotion    = key.VK_F1;
key_mppotion    = key.VK_F2;
key_sppotion    = key.VK_F3;

-- rest or use potions when low on HP/MP/SP 
HP_potion    = 60;
MP_potion    = 0;
SP_potion    = 0;

HP_sit          = 100;
MP_sit          = 0;
SP_sit          = 0;

-- chance to cast
skill1_chance   = 100;
skill2_chance   = 80;
skill3_chance   = 0;

-- MP cost
skill1_cost     = 38;
skill2_cost     = 20;
skill3_cost     = 80;


have_pig        = 1;            -- set to 1 if you have a fortune pig and want to
				-- skip the manual pickup function	

-- buff stuff
-- NOTE:  set on 10 minutes
-- buff / scroll durations in msec 	time = minutes x 60000
-- to de- activate non used buffs / scrolls replace "1" with "0"
-- to activate buff / scroll replace "0" with "1"
-- scrolls can be used too as buff
-------------------------

buff1_duration 		= 600000;
buff_1			= 0;
buff_key1               = key.VK_8;

buff2_duration 		= 600000;
buff_2         		= 0;
buff_key2                = key.VK_9;

--dont change these
buff1_needed 	= true;
buff2_needed 	= true;




-- cast times in milliseconds
skill1_casttime        = 2000;
skill2_casttime        = 1000;
skill3_casttime        = 3000;

-- skill cool downs in milliseconds (not working)
skill1_cooldown        = 3000;
skill2_cooldown        = 8000;
skill3_cooldown        = 9000;
-------------------------------------------------

function hp_potion()
  keyboardPress(key_hppotion);
end

function mp_potion()
  keyboardPress(key_mppotion);
end

function sp_potion()
  keyboardPress(key_sppotion);
end

-- so we aren't spamming the attack key...
-- we will use a timer to press it once
-- every 3 seconds.
function attack_timer()
  keyboardPress(key_attack);
end

function fight_warrior()
  registerTimer("attack_timer", 3000, attack_timer);

  while( have_target() ) do
    if( HP < HP_potion ) then
      hp_potion(); end
    if( MP < MP_potion ) then
      mp_potion(); end
--    if( SP < SP_potion ) then
--      sp_potion(); end
    keyboardPress(key_skill1);
    yrest(120); 
    keyboardPress(key_skill2);
    yrest(120);  
    keyboardPress(key_skill3);
    yrest(120);
    coroutine.yield();	
  end

  unregisterTimer("attack_timer");

  yrest(1000);
end

function fight_mage()
  while( have_target() ) do
    if( HP < HP_potion ) then
      hp_potion(); end
    if( MP < MP_potion ) then
      mp_potion(); end
    
    local roll = math.random(100);
    if( roll <= skill1_chance and MP >= skill1_cost ) then
      -- cast skill 1
      keyboardPress(key_skill1);
      yrest(skill1_casttime);
    else
      keyboardPress(key_attack);
    end
    
    if( roll <= skill2_chance and MP >= skill2_cost ) then
    -- cast skill 1
    keyboardPress(key_skill2);
    yrest(skill2_casttime);
    else
    keyboardPress(key_attack);
    end

    yrest(100);
    coroutine.yield();
  end

  yrest(1000);
end

-- heal until full HP & MP
function rest_heal()
  if( can_rest == false ) then return; end
  
    keyboardHold(key_sit);
    yrest(50);
    keyboardRelease(key_sit);
  
    -- set a timer to toggle healing in 30 seconds
    registerTimer("heal_rest_timer", 30000, heal_rest_timer);
  
    need_heal = true;
    last_hp = HP;
    while( need_heal ) do
      yrest(100);
      if (HP < last_hp)  then
        print("Under attack! Exiting rest.");
        can_rest = false;
        registerTimer("can_rest_timer", 3000, can_rest_timer);
        break;
      else
        last_hp = HP;
      end
    end
  
    keyboardHold(key_sit);
    yrest(50);
    keyboardRelease(key_sit);
  
  yrest(200);
end

-- toggle can_heal to true, disable timer
function can_rest_timer()
  unregisterTimer("can_rest_timer");
  can_rest = true;
  print("Can rest again.");
end

-- tell heal_rest we no longer need rest
function heal_rest_timer()
  need_heal = false;
end

-- toggle cast needed for buff1
function buff1_timer()
  buff1_needed = true;
end

-- toggle cast needed for buff2
function buff2_timer()
  buff2_needed = true;
end

-- pickup nearby items
function pickup()
  keyboardHold(key_pickup);
  yrest(50);
  keyboardRelease(key_pickup);
  yrest(775)
  keyboardHold(key_pickup);
  yrest(50);
  keyboardRelease(key_pickup);
end



-- you have died! oh noes!
function death_return()
  keyboardPress(key.VK_SNAPSHOT);
  print(os.date("Looks like somebody got you killed.	%X"))
  print("A screen capture has been taken. Open MS Paint and paste it.");
  stopPE(); -- this turns the macro off!
  coroutine.yield(); -- yield to make sure the protected environment stops
end


function move_forward()
  keyboardHold(key.VK_W);
  if( math.random(100) >= 80 )
    then keyboardHold(key.VK_A);
  else if( math.random(100) >= 80 )
    then keyboardHold(key.VK_D); end
  end

  yrest( math.random(2000) );

  keyboardRelease(key.VK_W);
  keyboardRelease(key.VK_A);
  keyboardRelease(key.VK_D);
end









-- update client variables by reading from it's memory
function update_vars()
  HP = memoryReadIntPtr(proc, HP_ptr, HP_offset);
 
  MP = memoryReadIntPtr(proc, MP_ptr, MP_offset);
 
  --SP = memoryReadIntPtr(proc, SP_ptr, SP_offset);
end



-- rotate camera
function rotate_cam()
  wx,wy = windowRect(win);

  mouseSet(wx+512, wy+384);
  yrest(100);
  mouseRHold();
  yrest(100);
  mouseSet(wx+514, wy+384);
  yrest(100);
  mouseRRelease();
  yrest(100);
end



-- selects a nearby monster
function target_monster()
  keyboardHold(key.VK_TAB);
  yrest(50);
  keyboardRelease(key.VK_TAB);
end




-- checks if you have a target
function have_target()
  r,g,b = getPixel(hdc, 506, 31);
  --print(r,g,b); unneeded testcode
  -- check for the goldish color in the monster's HP window
  if( r >= 205 and r <= 225 and g >= 205 and g <= 230 and b >= 185 and b<= 200 ) then
    return true;
  else
    return false;
  end
end



-------------------------------------------------
-- FUNCTION MAIN
-------------------------------------------------
function main()
  win = findWindow("Kungfu Client");
  hdc = openDC(win);
  proc = openProcess( findProcessByExe("GongfuClient.exe") );
  attach(win);

  registerTimer("update_vars", 100, update_vars);
  registerTimer("buff1_timer", buff1_duration, buff1_timer);
  registerTimer("buff2_timer", buff2_duration, buff2_timer);

  
  --pixeltest(); commented test code
  while( 1 ) do
    if( HP == 0 ) then death_return(); end
    if( HP < HP_potion ) then hp_potion(); end
    if( MP < MP_potion ) then mp_potion(); end
    if( HP < HP_sit and can_rest == true ) then rest_heal(); end
    if( MP < MP_sit and can_rest == true ) then rest_heal(); end

    yrest(100);
    target_monster();
    yrest(200);
    if( have_target() ) then
      can_rest = false; -- prevent resting during battle
                        -- for the few that have this bug
      if( class == CLASS_WARRIOR) then fight_warrior(); end
      if( class == CLASS_MAGE) then fight_mage(); end
      can_rest = true;
    else
   
      rotate_cam();
      if( math.random(100) > 90 ) then
        move_forward(); end
    end
    
    
    
   
    if(have_pig == 0) then
    pickup();
    end
    
    if( buff_1 == 1 ) then 
	if( buff1_needed ) then
          keyboardPress(buff_key1);
          print(os.date("buff 1 casted	%X"))
	  buff1_needed = false;
	  yrest(1000);
	end
    end
    if( buff_2 == 1 ) then 
      if( buff2_needed ) then
        keyboardPress(buff_key2);
        print(os.date("buff 1 casted	%X"))
    	buff1_needed = false;
    	yrest(1000);
      end
    end
  end

  detach();
  closeProcess(proc);
end

startMacro(main);
-------------------------------------------------
if you can do it can you modifi this script and repost it please?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: World of Kungfu Bot (Updated)

#40 Post by Administrator » Fri May 30, 2008 5:07 pm

Second notice: use code tags when posting code.

You will need to start by finding the address(es) related to the armor value. I do not even have the game, so you will need to do it.

A simpler method might be to just have it log off after 1 hour or so.

Put this somewhere above function main()

Code: Select all

function exitGame()
  printf("Exiting game...\n");
  keyboardHold(key.VK_LALT);
  keyboardPress(key.VK_F4);
  keyboardRelease(key.VK_LAULT);

  stopPE();
end
Put this inside function main()

Code: Select all

  registerTimer("exitGame", hoursToTimer(1.0), exitGame);

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests