NosTale.lua

You may request or share scripts for MicroMacro in this forum.
Post Reply
Message
Author
crackpod
Posts: 11
Joined: Mon Dec 29, 2008 8:30 am

NosTale.lua

#1 Post by crackpod » Tue Dec 30, 2008 6:06 pm

Wow, played a bit around with MicroMacro and in general Lua and tried something funny class-based with it:
http://paste.pocoo.org/show/9zgsPZt4IJVqFTPuGnkw/

Some of you may find that useful so I'm posting it, I probably won't use it. Some things to note:
If NosTale updates you may need to find the pointer for the hp and mp structs again but that probably won't be a problem if you are familiar
with CheatEngine.

PS: Let me know if it works for you, I can't be to sure since I were coding while running Linux and WINE.
PPS: The class module rocks! xD
PPPS:

A basic bot could look like this:
http://paste.pocoo.org/show/0d6gn2hnV1NXcuhBQwZU/

(You will have to set the right keys)

Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

Re: NosTale.lua

#2 Post by Mesosmagnet » Tue Jan 13, 2009 4:20 pm

Hi, I am back and playing Nostale again. Its amazing how few botters and hackers there are in this game although there is no protection.

I tried to test your script but error 299 keeps popping up, saying only part of the memoryReadInt was processed.

This is the bot I used quite a few months back. I updated the addresses but it doesnt seem to work. Can u help me a little?

Code: Select all

---------------------------------------------------------------------------------------------------
--SETTINGS
---------------------------------------------------------------------------------------------------

HP_potion		= 100;
MP_potion		= 50;
HP_restatm	= 150;
MP_restatm	= 100;

key_attack		= key.VK_SPACE;
key_pickup		= key.VK_TILDE;
key_skill1		= key.VK_1;
keyskill2		= key.VK_2;
keyskill3		= key.VK_3;

key_hppotion	= key.VK_4;
key_mppotion	= key.VK_5;

-----------------------------------------------------------------------------------------------------
--ADDRESSES
-----------------------------------------------------------------------------------------------------


proc		= 0;
win		= 0;
HP_addr		= 0x06EBA64C;
HPmax_addr	= 0x06EBA648;
MP_addr		= 0x06EB8324;
MPmax_addr	= 0x06EB8320;
Target_addr	= 0x04157D40;
HP		= 0;
HPmax		= 0;
MP		= 0;
MPmax		= 0;
target		= 0;




-------------------------------------------------------------------------------------------------------
--FUNCTIONS
-------------------------------------------------------------------------------------------------------


--pickup items
function pickup()
  keyboardPress(key.VK_TILDE);
end

--select nearby monster
function target_monster()
  keyboardPress(key.VK_SPACE);
end

--fight timer
function fight_timer()
  keyboardPress(key.VK_SPACE);
end

--check if you have a target
function have_target()
  if( target == 1 ) then
   return true;
  else
   return false; 
  end
end



--updates variables from client
function update_var()
  HP	= memoryReadInt(proc, HP_addr);
  HPmax	= memoryReadInt(proc, HPmax_addr);
  MP	= memoryReadInt(proc, MP_addr);
  MPmax	= memoryReadInt(proc, MPmax_addr);
  target	= memoryReadInt(proc, Target_addr);
end

-- toggle can_heal to true, disable timer
function can_rest_timer()
  unregisterTimer("can_rest_timer");
  can_rest = true;
end

--rest until healed
function rest_heal()
  if( can_rest == false ) then return; end

  printf("Entering rest state\t%s\n", os.date("%X"));

  keyboardPress(key.VK_T);

  need_heal	= true;
  last_hp= HP;
  while( need_heal ) do
    yrest(100);

    if( HP == HPmax and MP == MPmax ) then
      need_heal = false;
    end

    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
end


--use hp potion
function hp_potion()
  keyboardPress(key.VK_4);
end

--use mp potion
function mp_potion()
  keyboardPress(key.VK_5)
end


--bot fight
function bot_fight()
  registerTimer("fight_timer", 3000, fight_timer);
  while( target == 1 ) do
    if( HP < HP_potion) then hp_potion(); end
    if( MP < MP_potion) then mp_potion(); end
    if( math.random(100) > 50 ) then
      keyboardPress(key.VK_SPACE);
    end
  end
  unregisterTimer("fight_timer");

   for i=0, 8 do
    pickup();
    yrest(50);
   end
  

  can_rest = false;
  registerTimer("can_rest_timer", 3000, can_rest_timer);

end


--can_rest_timer
function can_rest_timer()
  unregisterTimer("can_rest_timer");
  can_rest = true;
end

-----------------------------------------------------------------------------------------------------------------
--MAIN BOT FUNCTIONS
-----------------------------------------------------------------------------------------------------------------


function main()
  win = findWindow("Nomad of Silver Spirit - Nostale");
  local wx,wy,ww,wh = windowRect(win);

  if( win == 0 ) then printf("Error! Could not locate Nostale window!\n"); return; end;
  hdc = openDC(win);
  -- proc = openProcess( "NostaleX.dat" );
  proc = findProcessByWindow(win);
  attach(win);
  setPriority(PRIORITY_HIGH);

  registerTimer("update_var", 100, update_var);

  while( true ) do
    if( HP < HP_potion ) then hp_potion(); end
    if( MP < MP_potion ) then mp_potion(); end
    if( HP < HP_restatm and can_rest == true ) then rest_heal(); end
    if( MP < MP_restatm and can_rest == true ) then rest_heal(); end

    yrest(100);


    target_monster();
    yrest(200);
    if( target == 1 ) then
      can_rest = fasle;
      if( target == 1 ) then bot_fight(); end
      can_rest = true;
    end
    pickup();
  end

  detach();
  closeProcess(proc);
end

startMacro(main);
i am using micromacro v0.98


EDIT: ok i found out that those addresses I used were not static and changed each time I relogged. Is that the reason we use offsets? I dont know how to find offsets. Maybe you could teach me a little? Or point me in the right direction?

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

Re: NosTale.lua

#3 Post by Administrator » Tue Jan 13, 2009 6:18 pm

Mesomagnet: Yes, the problem is caused because those addresses are not static, and that is why we use pointers and offsets. Here's the tutorial on finding pointers and offsets: http://solarimpact.servegame.com/phpBB3 ... p?f=5&t=65

Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

Re: NosTale.lua

#4 Post by Mesosmagnet » Tue Jan 13, 2009 9:56 pm

I noticed in the pointer tutorial thread that 3cmSailorfuku mentioned that in nostale there might be more than 10 levels of pointers. So I would have to search for the pointer that points to the HP address I found, then find the pointer that points to the pointer of the HP address I found, and keep repeating until I get a green static address?
I only managed to scan up to one level, and then nothing else show up when i try to find what "writes to" the pointer.

I also tried using the "Pointer Scan" function but it returned 5000 over addresses.

EDIT: i cant get the usual way to work, CE doesnt show any address writing to the pointer. And I am re-running the Pointer Scan and I set the level to 13 and it has been over 30 minutes and it still hasnt finished.

I did a little searching and found this tutorialhttp://forum.cheatengine.org/viewtopic.php?t=4606. As I am now waiting for the Pointer Scanner to finish running I have not tried this method yet, thus I would like to ask whether this method will work for Nostale?

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

Re: NosTale.lua

#5 Post by Administrator » Tue Jan 13, 2009 11:12 pm

The method in that link you gave is way too complicated and a lot of work. The method in my tutorial is relatively simple and works almost every time. Cheat Engine's automatic pointer lookup rarely works for me, so that could explain why 3cmSailorfuku reported such complexity. I'd suggest you follow my tutorial to 2 or 3 iterations, as that is what is most commonly needed for games.

Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

Re: NosTale.lua

#6 Post by Mesosmagnet » Tue Jan 13, 2009 11:39 pm

I might be doing something wrong, as when I try to find the pointer that points to the
what writes to CurrentHP
what writes to CurrentHP
what writes to CurrentHP
pointer(lvl1) &amp; offset
pointer(lvl1) & offset
pointer(lvl1) & offset
searched for value and got these addresses. Added into table and searched for what writes to those addresses. Nothing writes to those addresses.
searched for value and got these addresses. Added into table and searched for what writes to those addresses. Nothing writes to those addresses.
searched for value and got these addresses. Added into table and searched for what writes to those addresses. Nothing writes to those addresses.


I probably am doing the last part wrong. Could you please explain what I should do next?

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

Re: NosTale.lua

#7 Post by 3cmSailorfuku » Wed Jan 14, 2009 9:03 am

Mesosmagnet wrote:I might be doing something wrong, as when I try to find the pointer that points to the
1.jpg
what writes to CurrentHP
2.jpg
pointer(lvl1) & offset
3.jpg
searched for value and got these addresses. Added into table and searched for what writes to those addresses. Nothing writes to those addresses.


I probably am doing the last part wrong. Could you please explain what I should do next?
On the last step, you click on Add Adress -> Pointer -> Adress: Pick One from the found adresses. Offset: 4c.
And like Elverion mentioned, my statement was meant for the automatic pointer lookup.

Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

Re: NosTale.lua

#8 Post by Mesosmagnet » Sat Jan 17, 2009 1:47 pm

I know I sound really stupid but I after following through many many times over I still get the same results.

After adding one of the addresses that came up after step 3 as 3cmSailorfuku said, I right click on one of the addresses and click "Find out what writes to this address"...a small window then pops up saying
"This is a pointer"
"Find out what writes to this pointer"
"Find what reads from the address pointed at by this pointer"
For quite some time now I have been choosing the 1st option - Find what writes to this pointer
and even when I am loosing HP and regenerating nothing shows up on the window.
So I tried the other option - Find what reads from the address pointed at by this pointer
but that lead to another dead end as it just lead back to the same address I searched for in the beginning.

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

Re: NosTale.lua

#9 Post by 3cmSailorfuku » Sat Jan 17, 2009 2:14 pm

Mesosmagnet wrote:I know I sound really stupid but I after following through many many times over I still get the same results.

After adding one of the addresses that came up after step 3 as 3cmSailorfuku said, I right click on one of the addresses and click "Find out what writes to this address"...a small window then pops up saying
"This is a pointer"
"Find out what writes to this pointer"
"Find what reads from the address pointed at by this pointer"
For quite some time now I have been choosing the 1st option - Find what writes to this pointer
and even when I am loosing HP and regenerating nothing shows up on the window.
So I tried the other option - Find what reads from the address pointed at by this pointer
but that lead to another dead end as it just lead back to the same address I searched for in the beginning.
You're already done. It only has one pointer.

Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

Re: NosTale.lua

#10 Post by Mesosmagnet » Sat Jan 17, 2009 2:39 pm

EDIT: I finally found a static pointer.

But I still need some help. Since it is a double pointer, how do I add it into the script?
HP = memoryReadIntPtr(proc, (memoryReadIntPtr(proc, 00784D70, 0xAC)), 0x4c); << doesnt work

HP_pointer = memoryReadIntPtr(proc, 00784D70, 0xAC);
HP = memoryReadIntPtr( proc, HP_pointer , 0x4C); << doesnt work either.
Last edited by Mesosmagnet on Sun Jan 18, 2009 6:20 am, edited 1 time in total.

tcflying
Posts: 29
Joined: Thu Dec 18, 2008 12:07 pm

Re: NosTale.lua

#11 Post by tcflying » Sun Jan 18, 2009 6:12 am

okay, i got your problem and now see it made a working one. maybe some problem with it. but works. you can improve it yourself.

Code: Select all

startKey = key.VK_DELETE;
stopKey = key.VK_END;


local proc = openProcess( findProcessByExe("NostaleX.dat") );
local charAddress = memoryReadInt(proc, 0x01F94DFC);
local charAddress1 = memoryReadInt(proc, 0x00782d38);
local HP = memoryReadInt(proc, charAddress + 0x4C);
local MaxHP = memoryReadInt(proc, charAddress + 0x48);
local IF_Target = memoryReadInt(proc, charAddress1 + 0x60);


function HP()
    local hp = memoryReadInt(proc, charAddress + 0x4C)
    return hp
end

function MaxHP()
    local MaxHP = memoryReadInt(proc, charAddress + 0x48)
    return MaxHP
end

function IF_SIT()
    local IFS = memoryReadInt(proc, charAddress + 0x6D)
    return IFS
end

function IF_Target()
    local IFT = memoryReadInt(proc, charAddress1 + 0x60)
    return IFT
end


function main()

    attach(findWindow("NosTale"))

    while(true) do

if( HP()/MaxHP()*100 ) <= 60 then
keyboardPress(key.VK_T)
yrest(10000)
keyboardPress(key.VK_T)
yrest(1000)


	  

elseif( HP()/MaxHP()*100 >= 60 ) and IF_SIT()  then
keyboardPress(key.VK_T)
yrest(500)


while (IF_Target()) do
 
keyboardPress(key.VK_SPACE)
yrest(2000)
keyboardPress(key.VK_W)
yrest(100)
keyboardPress(key.VK_W)
yrest(100)
keyboardPress(key.VK_W)
yrest(100)
keyboardPress(key.VK_E)
yrest(2000)
end

else

while (IF_Target()) do
keyboardPress(key.VK_SPACE)
yrest(2000)
keyboardPress(key.VK_W)
yrest(100)
keyboardPress(key.VK_W)
yrest(100)
keyboardPress(key.VK_W)
yrest(100)
keyboardPress(key.VK_E)
yrest(2000)
end



end

end
end

startMacro(main);


Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

Re: NosTale.lua

#12 Post by Mesosmagnet » Sun Jan 18, 2009 6:21 am

Wow, Thank you. I will study your script. =)

EDIT: eerrmm tcflying, when I run your script I get error 299, saying memoryReadInt failure
error 299
error 299
the address I got for character pointer =
00784D70 for Hp (with 2 offset 0xAC & 0x4C/0x48) and Mp (with 2 offset 0xB0 & 0x4C/0x48)
00784074 for target (with 2 offsets 0xBC & 0x18)

now if I only knew how to add them into the script...

tcflying
Posts: 29
Joined: Thu Dec 18, 2008 12:07 pm

Re: NosTale.lua

#13 Post by tcflying » Sun Jan 18, 2009 8:33 am

it's fine. because i don't play this game. so don't test it fullly. i think there must be some problem with the code.
i will try to test it later and improve it.

btw the pointer is for german client. i think it's easy to find the us version. you may try to get that. if need help. just tell me here.

Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

Re: NosTale.lua

#14 Post by Mesosmagnet » Sun Jan 18, 2009 9:33 am

Owh...no wonder the addresses were diffrent =)
I really liked the way you coded your script. It is quite diffrent from the type I ahve been using till now.
I have one question...the Global version uses a double pointer. Where the first pointer points to the second pointer which only then points to the HP address. Could you tell/show me how I can put that into my script?
I have been doing it this way:

Code: Select all

proc 	= 0;
win 	= 0;
Char_ptr 	= 00784D70;
HP_ptr	= 0;
HP	= 0;

function main()

 win = findWindow("Nomad of Silver Spirit - Nostale");
 hdc = openDC(win);
 proc = findProcessByWindow(win);
 attach(win);

HP_ptr 	= memoryReadIntPtr( proc, Char_ptr, 0xAC);
HP	= memoryReadIntPtr( proc, HP_ptr, 0x4C);
printf("\n\t%d\n", HP);

end

startMacro(main);
but there always is an error.
To be precise the error is:

Code: Select all

...micromacro\scripts\update.lua: 19: bad argument #1 to 'memoryReadIntPtr' ((null))
[/color]

Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

Re: NosTale.lua

#15 Post by Mesosmagnet » Sun Jan 18, 2009 12:19 pm

Please IGNORE my previous post.

I just found out that I made a huge mistake in the

Code: Select all

proc = findProcessByWindow(win); << NO openProcess()

NEW:
proc = openProcess( findProcessByExe("NostaleX.dat") ) << Thanks to tcflying
EDIT: As a programming student I should be punished for this mistake. Only now I realize that memoryReadIntPtr reads integer values and if a character is present it converts it into an integer thus causing error. Now I know that the only thing that is able to store an address is a file pointer or a string(character array). I tried using memoryReadStringPtr but obviously that lead to some problems returning some gibberish symbols. I need some help please.


The code I used was:

Code: Select all

proc		= 0;
win		= 0;
char_Ptr		= 0x00784D70;
HP_Ptr_offset	= 0xAC;
curHP_offset	= 0x4C;
maxHP_offset	= 0x48;
MP_Ptr_offset	= 0xB0;
curMP_offset	= 0x4C;
maxMP_offset	= 0x48;

char_target		= 0x00784D74;
target_Ptr_offset	= 0xBC;
target_offset	= 0x18;

HP_Ptr		= 0;
MP_Ptr		= 0;
target_Ptr		= 0;

HP		= 0;
HPmax		= 0;
MP		= 0;
MPmax		= 0;
target		= 0;

function main()

 win = findWindow("Nomad of Silver Spirit - Nostale");
 hdc = openDC(win);
 proc = openProcess( findProcessByExe("NostaleX.dat") );
 attach(win);

  HP_Ptr = memoryReadStringPtr(proc, char_Ptr, HP_Ptr_offset);
  HP = memoryReadIntPtr( proc , HP_Ptr, curHP_offset);
  HPmax = memoryReadIntPtr(proc, HP_Ptr, maxHP_offset);

  MP_Ptr = memoryReadStringPtr(proc, char_Ptr, MP_Ptr_offset);
  MP = memoryReadIntPtr(proc, MP_Ptr, curMP_offset);
  MPmax = memoryReadIntPtr(proc, MP_Ptr, maxMP_offset);

  target_Ptr = memoryReadStringPtr(proc, char_target, target_Ptr_offset);
  target = memoryReadIntPtr(proc, target_Ptr, target_offset);

printf("\n\t%s\n", HP_Ptr);
printf("\n\t%d\n", HP);
printf("\n\t%d\n", HPmax);
printf("\n\t%s\n", MP_Ptr);
printf("\n\t%d\n", MP);
printf("\n\t%d\n", MPmax);
printf("\n\t%s\n", target_Ptr);
printf("\n\t%d\n", target);

end

startMacro(main);


Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

Re: NosTale.lua

#16 Post by Mesosmagnet » Mon Jan 19, 2009 1:47 pm

Although it might be too late I would like to apologize to the Thread Starter for hijacking your thread for so long. It was all thanks to you that I was brought back to the world of nostale and learn many new things. =)

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests