Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Shaiya
You last visited: Today at 23:29

  • Please register to post and access all features, it's quick, easy and FREE!

 

Shaiya Bot Trouble

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Nov 2008
Posts: 20
Received Thanks: 4
Shaiya Bot Trouble

Hello everyone,
Im trying to Edit a Script bot posted earlier on the forum. This is what i have right now.

Quote:
------------------------------------------------
-- HOTKEYS
------------------------------------------------
startKey = key.VK_INSERT;
stopKey = key.VK_DELETE;

key_switchtarget = key.VK_TILDE;

key_attack = key.VK_1;
key_pickup = key.VK_0;

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

key_buff1 = key.VK_5;
key_buff2 = key.VK_6;

key_hp_potion = key.VK_7;
key_mp_potion = key.VK_8;
key_sp_potion = key.VK_9;

key_sit = key.VK_C;

key_left = key.VK_A;
key_right = key.VK_D;
key_forward = key.VK_W;
key_back = key.VK_S;


------------------------------------------------
-- SKILLS
------------------------------------------------
-- Set to 0 if you don't want to use a skill
skill1_time = secondsToTimer(0);
skill2_time = secondsToTimer(0);
skill3_time = secondsToTimer(0);


------------------------------------------------
-- BUFFS
------------------------------------------------
-- Set a buff to 0 if you don't want to use it
buff1_time = minutesToTimer(10);
buff2_time = minutesToTimer(5);
buff3_time = minutesToTimer(0);

------------------------------------------------
-- POTIONS
------------------------------------------------
-- All potion use values are specified in %
-- Set the values to 0 to not use that potion
HP_potion_use = 50;
MP_potion_use = 0;
SP_potion_use = 0;


------------------------------------------------
-- SITTING
------------------------------------------------
-- All sitting values are specified in %
-- We will only sit while out of battle
-- Set the values to 0 to not use sitting
HP_sit = 0;
MP_sit = 0;
SP_sit = 0;


--[[************************************************** *******************
************************************************** ************************
DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
************************************************** ************************
************************************************** **********************]]

------------------------------------------------
-- Memory addresses
------------------------------------------------
playerptr_addr = 0x00849274;

HP_offset = 304;
MaxHP_offset = 308;
MP_offset = 312;
MaxMP_offset = 316;
SP_offset = 320;
MaxSP_offset = 324;

targetid_addr = 0x006f3be0; -- short, 65535 if none selected
-- REMOVED -- targettype_addr = 0x00619B1F; -- byte, 0 = player/NPC, 7 = monster

sitcheck_addr = 0x00643648; -- byte, 0 = standing, 7 = sitting

x_coor_addr = 0x0084929C;
y_coor_addr = 0x008492A4;


------------------------------------------------
-- Variable setup
------------------------------------------------
HP = 10000;
MaxHP = HP;
MP = 10000;
MaxMP = MP;
SP = 10000;
MaxSP = SP;

skill1_ready = true;
skill2_ready = true;
skill3_ready = true;

buff1_ready = true;
buff2_ready = true;
buff3_ready = true;

x_coor = 1;
y_coor = 1;
cur_x_coor = 1;
cur_y_coor = 1;
set = 1;
------------------------------------------------
-- Functions
------------------------------------------------

skill1_toggle = function () skill1_ready = true; end;
skill2_toggle = function () skill2_ready = true; end;
skill3_toggle = function () skill3_ready = true; end;

buff1_toggle = function () buff1_ready = true; end;
buff2_toggle = function () buff2_ready = true; end;
buff3_toggle = function () buff3_ready = true; end;


function use_hp_potion()
keyboardPress(key_hp_potion);
printf("Using HP potion\n");
end


function use_mp_potion()
keyboardPress(key_mp_potion);
printf("Using MP potion\n");
end


function use_sp_potion()
keyboardPress(key_sp_potion);
printf("Using SP potion\n");
end


function sit()
if( HP_sit == 0 ) then
return; end

printf("Sitting.\n");

local sitting = false;
while( sitting == false ) do
keyboardPress(key_sit);
yrest(1000);

sitting = memoryReadByte(proc, sitcheck_addr) ~= 0;
end

local lasthp = HP;

while( true ) do
if( HP == MaxHP and MP == MaxMP and SP == MaxSP ) then
switch_target();
break;
end

if( HP < (lasthp - 10) ) then
printf("Exiting rest...under attack\n");
break;
else
lasthp = HP;
end

yrest(100);
end

sitting = true;
while( sitting ) do
keyboardPress(key_sit);
yrest(1000);

sitting = memoryReadByte(proc, sitcheck_addr) ~= 0;
end

printf("Standing... Resuming bot\n");
yrest(1000);
end


function pickup()
printf("Pickup!\n");
if( key_pickup == 0 ) then return; end

local i;
for i = 0, 5 do
keyboardPress(key_pickup);
yrest(500);
end

yrest(1000);
end


function update_vars()
HP = memoryReadIntPtr(proc, playerptr_addr, HP_offset);
MaxHP = memoryReadIntPtr(proc, playerptr_addr, MaxHP_offset);

MP = memoryReadIntPtr(proc, playerptr_addr, MP_offset);
MaxMP = memoryReadIntPtr(proc, playerptr_addr, MaxMP_offset);

SP = memoryReadIntPtr(proc, playerptr_addr, SP_offset);
MaxSP = memoryReadIntPtr(proc, playerptr_addr, MaxSP_offset);

if ( set == 1 ) then
x_coor = memoryReadFloat(proc, x_coor_addr);
y_coor = memoryReadFloat(proc, y_coor_addr);
set = 0;
end;

end


function have_target()
local readid = memoryReadShort(proc, targetid_addr);
printf (readid);
return ( readid ~= 0xFFFFFFFF );
end

function find_target()
keyboardPress(key_attack);
printf ("possibly");
end

function switch_target()
keyboardPress(key_switchtarget);
end

function starting_loc()
local x;
local y;
while ( true ) do
cur_x_coor = memoryReadFloat (proc, x_coor_addr);
cur_y_coor = memoryReadFloat (proc, y_coor_addr);
keyboardPress (key_forward);
x = memoryReadFloat (proc, x_coor_addr);
y = memoryReadFloat (proc, y_coor_addr);
if (x_coor - cur_x_coor > x_coor - x or y_coor - cur_y_coor > y_coor - y) then
keyboardPress (key_left);
end;
if (x < x_coor + 2 or x > x_coor - 2 and y < y_coor + 2 or y > y_coor - 2) then
break;
end;
end
end


------------------------------------------------
-- FIGHT
------------------------------------------------
function fight()
local beginTime = os.time();
local attack_ready = true;

local attack_toggle = function () attack_ready = true; end;
registerTimer("attack_timer", secondsToTimer(3), attack_toggle);

local targetid = memoryReadByte(proc, targetid_addr);
printf("TARGETID: ", targetid);

cur_x_coor = memoryReadFloat (proc, x_coor_addr);

cur_y_coor = memoryReadFloat (proc, y_coor_addr);

if (cur_x_coor > x_coor +40 or cur_x_coor < x_coor - 40) then
starting_loc()
end;

if (cur_y_coor > y_coor +40 or cur_y_coor < y_coor - 40) then
starting_loc()
end;

while( have_target() ) do
local curtarget = memoryReadByte(proc, targetid_addr);

if( targetid ~= curtarget ) then break; end;

local currentTime = os.time();
if( os.difftime(currentTime, beginTime) > 60 ) then -- more than 1 minute has passed
break; -- exit combat
end

if( skill1_ready and skill1_time > 0 ) then
keyboardPress(key_skill1); skill1_ready = false; yrest(1000);
registerTimer("skill1_toggle", skill1_time, skill1_toggle);
end;

if( skill2_ready and skill2_time > 0) then
keyboardPress(key_skill2); skill2_ready = false; yrest(1000);
registerTimer("skill2_toggle", skill2_time, skill2_toggle);
end;

if( skill3_ready and skill3_time > 0) then
keyboardPress(key_skill3); skill3_ready = false; yrest(1000);
registerTimer("skill3_toggle", skill3_time, skill3_toggle);
end;

if( attack_ready ) then
keyboardPress(key_attack); attack_ready = false; yrest(1000); end;

if( (HP/MaxHP*100) < HP_potion_use and HP_potion_use > 0 ) then use_hp_potion(); end
if( (MP/MaxMP*100) < MP_potion_use and MP_potion_use > 0 ) then use_mp_potion(); end
if( (SP/MaxSP*100) < SP_potion_use and SP_potion_use > 0 ) then use_sp_potion(); end

if( buff1_ready and buff1_time > 0 ) then
keyboardPress(key_buff1); buff1_ready = false; yrest(2000); end;
if( buff2_ready and buff2_time > 0 ) then
keyboardPress(key_buff2); buff2_ready = false; yrest(2000); end;
if( buff3_ready and buff3_time > 0 ) then
keyboardPress(key_buff3); buff3_ready = false; yrest(2000); end;


yrest(100);
end

printf("Target lost.\n");

unregisterTimer("attack_timer");

pickup()
end


------------------------------------------------
-- MAIN
------------------------------------------------
function main()
proc = openProcess(findProcessByExe("game.exe"));
win = findWindow("Shaiya");
attach(win);
setPriority(PRIORITY_HIGH);

registerTimer("update_vars", 100, update_vars);

if( skill1_time ) then registerTimer("skill1_toggle", skill1_time, skill1_toggle); end
if( skill2_time ) then registerTimer("skill2_toggle", skill2_time, skill2_toggle); end
if( skill3_time ) then registerTimer("skill3_toggle", skill3_time, skill3_toggle); end

if( buff1_time ) then registerTimer("buff1_toggle", buff1_time, buff1_toggle); end;
if( buff2_time ) then registerTimer("buff2_toggle", buff2_time, buff2_toggle); end;
if( buff3_time ) then registerTimer("buff3_toggle", buff3_time, buff3_toggle); end;

while( true ) do
keyboardPress(key_attack);

yrest(200);

if( have_target() ) then
fight();
end

if( buff1_ready and buff1_time > 0 ) then
keyboardPress(key_buff1); buff1_ready = false; yrest(2000); end;
if( buff2_ready and buff2_time > 0 ) then
keyboardPress(key_buff2); buff2_ready = false; yrest(2000); end;

if( buff3_ready and buff3_time > 0 ) then
keyboardPress(key_buff3); buff3_ready = false; yrest(2000); end;

if( (HP/MaxHP*100) < HP_potion_use and HP_potion_use > 0 ) then use_hp_potion(); end
if( (MP/MaxMP*100) < MP_potion_use and MP_potion_use > 0 ) then use_mp_potion(); end
if( (SP/MaxSP*100) < SP_potion_use and SP_potion_use > 0 ) then use_sp_potion(); end

if( (HP/MaxHP*100) < HP_sit and (HP_sit > 0) ) then sit(); end
if( (MP/MaxMP*100) < MP_sit and (MP_sit > 0) ) then sit(); end
if( (SP/MaxSP*100) < SP_sit and (SP_sit > 0) ) then sit(); end

end
end

startMacro(main);
But this morning while changing the code a bit the bot stopped working and now i cant find why. I have input some 'printf' lines to see what parts of the code are accessed and everything seems to work as it should. But in-game the hotkeys wont press. For example the function 'find_target()'.

I first got this script from .

So could someone with some scripting knowledge help me out and show me where i have gone wrong.

Thx Guyz



craka is offline  
Old   #2
 
elite*gold: 20
Join Date: Jun 2009
Posts: 787
Received Thanks: 2,641
Try removing the attach(win) code. Sometimes these scripts have a hard time successfully attaching to a window. The only thing that will happen is that when it sends the key presses that it will send it to the top most window which should be your game if your playing.


lilprohacker is offline  
Thanks
1 User
Old   #3
 
elite*gold: 0
Join Date: Nov 2008
Posts: 20
Received Thanks: 4
Wow, thanx it did fix it. Now i can get back on editing this. Thanx again.
craka is offline  
Reply



« Previous Thread | Next Thread »



All times are GMT +2. The time now is 23:29.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2017 elitepvpers All Rights Reserved.