Code: Select all
---------------------------------------------------------------------------------------------------
--SETTINGS
---------------------------------------------------------------------------------------------------
HP_potion = 500;
MP_potion = 50;
HP_restatm = 1000;
MP_restatm = 300;
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;
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 = 0x00784D70;
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;
-------------------------------------------------------------------------------------------------------
--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_Ptr = memoryReadIntPtr(proc, char_Ptr, HP_Ptr_offset);
HP = memoryReadInt( proc , HP_Ptr + curHP_offset);
HPmax = memoryReadInt(proc, HP_Ptr + maxHP_offset);
MP_Ptr = memoryReadIntPtr(proc, char_Ptr, MP_Ptr_offset);
MP = memoryReadInt(proc, MP_Ptr + curMP_offset);
MPmax = memoryReadInt(proc, MP_Ptr + maxMP_offset);
target_Ptr = memoryReadIntPtr(proc, char_target, target_Ptr_offset);
target = memoryReadInt(proc, target_Ptr + target_offset);
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
buff();
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_6);
yrest(1000);
end
--use mp potion
function mp_potion()
keyboardPress(key.VK_7)
yrest(1000);
end
--bot fight
function bot_fight()
registerTimer("fight_timer", 3000, fight_timer);
if( HP < HP_potion) then hp_potion(); end
if( MP < MP_potion) then mp_potion(); end
if( target == 1 ) then
keyboardPress(key.VK_2);
yrest(200);
keyboardPress(key.VK_3);
yrest(200);
keyboardPress(key.VK_SPACE);
end
if( math.random(100) > 60 ) then
keyboardPress(key.VK_4);
yrest(1000);end
end
unregisterTimer("fight_timer");
for i=0, 8 do
pickup();
yrest(50);
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
-- buff
function buff()
keyboardPress(key.VK_0);
yrest(1000);
keyboardPress(key.VK_9);
yrest(1000);
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( findProcessByExe("NostaleX.dat") );
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
if( HP > HP_restatm and can_rest == true ) then buff();end
yrest(100);
target_monster();
yrest(200);
if( target == 1 ) then
can_rest = fasle;
if( target == 1 ) then bot_fight();
while( target == 1 ) do
if( HP < HP_potion) then hp_potion(); end
if( MP < MP_potion) then mp_potion(); end
if( math.random(100) > 0 ) then
keyboardPress(key.VK_2);
yrest(200);
keyboardPress(key.VK_3);
yrest(200);
keyboardPress(key.VK_SPACE);
end
if( math.random(100) > 60 ) then
keyboardPress(key.VK_4);
yrest(1000);end
end
for i=0, 8 do
pickup();
yrest(50);
end
can_rest = false;
end
can_rest = true;
end
pickup();
end
detach();
closeProcess(proc);
end
startMacro(main);
ps. This script is not perfect and it can be improved with
- chat function ( so GMs dont ban you )
- moving function ( to increase range of botting )
- specific job functions ( to properly utilize skills of each job )
- pet/partner HP check functions ( so that your partner/pet has maximum survivability )
- others that I cant really think of right now.
So if anyone knows how to create those functions and is willing to share I would be glad to learn from you =)