Shaiya Fighter Bot

For any other game that doesn't have its own section.
Post Reply
Message
Author
jim151222
Posts: 8
Joined: Wed Jul 09, 2008 5:21 am

Re: Shaiya Fighter Bot

#81 Post by jim151222 » Sat Jul 12, 2008 3:46 am

deaznracer wrote:
jim151222 wrote:hey is it possible to implement an auto-item switch...e.g. when durability is getting low on armors and weapon the bot runs a process which swaps them for spares set up in inventory?
or is that not possible?
it's possible

so how would i go about implementing that into this script? would i just need to find the memory value and offsets of the current piece of equipments durability?

deaznracer
Posts: 59
Joined: Tue May 20, 2008 5:45 am

Re: Shaiya Fighter Bot

#82 Post by deaznracer » Sun Jul 13, 2008 2:20 am

jim151222 wrote:
deaznracer wrote:
jim151222 wrote:hey is it possible to implement an auto-item switch...e.g. when durability is getting low on armors and weapon the bot runs a process which swaps them for spares set up in inventory?
or is that not possible?
it's possible

so how would i go about implementing that into this script? would i just need to find the memory value and offsets of the current piece of equipments durability?
yes find the memory address and offset. Then do a registertimer to keep updating the the endurance left on the weapon. Once it gets to the number that you want to switch off at ,Then I would use num0 which is 2nd hotkey 0 to switch off with the new weapon. whichever hot key you prefer.

pheiv
Posts: 3
Joined: Mon Jul 14, 2008 9:40 pm

Re: Shaiya Fighter Bot

#83 Post by pheiv » Mon Jul 14, 2008 10:23 pm

Started.
...\micromacro\scripts\fighter.lua:587: bad argument #1 to 'memoryReadIntPtr' <<null>>

The bot casts 1 buff and shuts down. That's the error message up there. What's the problem?
I am running "no gg" also and tried this in "windowed mode".

Here's the code

Code: Select all

on  = true;
off = false;
------------------------------------------------
-- HOTKEYS
------------------------------------------------
macro_running       = on; -- leave this ON!

startKey = key.VK_INSERT;
stopKey = key.VK_DELETE;

key_switchtarget = key.VK_TILDE;

key_attack  = key.VK_1;
key_pickup  = key.VK_2;

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

key_buff1   = key.VK_6;
key_buff2   = key.VK_7;

key_hp_potion = key.VK_8;
key_hp_potion1 = key.VK_NUMPAD1;
key_hp_potion2 = key.VK_NUMPAD2;
key_hp_potion3 = key.VK_NUMPAD3;
key_hp_potion4 = key.VK_NUMPAD4;
key_hp_potion5 = key.VK_NUMPAD5;
key_hp_potion6 = key.VK_NUMPAD6;
key_hp_potion7 = key.VK_NUMPAD7;
key_hp_potion8 = key.VK_NUMPAD8;
key_hp_potion9 = key.VK_NUMPAD9;
key_hp_potion0 = key.VK_NUMPAD0;
key_mp_potion = key.VK_9;
key_sp_potion = key.VK_0;

key_sit       = key.VK_C;
key_move_down = key.VK_S;
key_move_right= key.VK_E;
key_myself    = key.VK_F1;
key_jump      = key.VK_SPACE;
key_home      = key.VK_HOME;
key_right     = key.VK_RIGHT;
do_jump       = 0;
--- Don't touch the code above or the program will act differently/not work unless you kknow how to-----------------------


--------------------------------------------------------
-- If the target's hp is not full how many time you want it to scan for targets with full hp.
-- Note: Lag issue will happen. if the target's Hp is still loading it will switch targets.
-- This code prevents it from ksing other people's damaged mobs
-- Default is 4 but adjust it to your mobs zone
--------------------------------------------------------

how_many_scanTarget = 4;

--------------------------------------------------------
-- How many seconds you want to keep locking on the target. If the target's Hp is full for more than 15 
-- seconds then that means you are stuck behind a wall, So the macro will change target.
-- Default is 15, if the mob is more spread apart adjust it with a higher number.
--------------------------------------------------------
 
how_many_seconds    = 15;


--------------------------------------------------------
--How many time you want to pick up items after mob is dead.
--Default is 3. In some cases 4 should pick up every drop.
--------------------------------------------------------


how_many_pickup     = 3; 


--------------------------------------------------------
-- Choose what range of Colored Mob you would want your Fighter
-- To kill. This way your fighter does not run all over the map.
-- Default is min 3 max 3. Which means the micro will only target blue mobs.
--------------------------------------------------------
target_difficulty_color_min= 3;
target_difficulty_color_max= 5;
--white  = 1
--cyan   = 2
--blue   = 3
--green  = 4
--yellow = 5
--orange = 6
--red    = 7
--purple = 8
--grey   = 9


------------------------------------------------
-- SKILLS secondsToTimer(x);
------------------------------------------------
-- Set to 0 if you don't want to use a skill
skill1_time = secondsToTimer(60);
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(5);
buff2_time = minutesToTimer(5);

------------------------------------------------
-- 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 = 15;
SP_potion_use = 15;


------------------------------------------------
-- 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 = 60;
MP_sit = 10;
SP_sit = 10;


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

------------------------------------------------
-- Memory addresses
------------------------------------------------
playerptr_addr = 0x007835B4;

HP_offset = 296;
MaxHP_offset = 300;
MP_offset = 304;
MaxMP_offset = 308;
SP_offset = 312;
MaxSP_offset = 316;

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

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

--------------------------------------------------------------------------
function init_window()
  win = findWindow("Shaiya");
  if(win == nil) then
    printf(error_init);
    macro_running = false;
  end
end
function init_process()
  proc = openProcess( findProcessByExe("game.exe") );
  if(proc == 0) then
    printf("error opening process.\n");
    macro_running = false;
  end
end
function init_hdc()
  hdc = openDC(get_win());
  local wx, wy, ww, wh = windowRect(get_win());

end
function get_hdc()
  return hdc;
end
function get_win()
  return win;
end
function debug_message(msg)
  if (g_debug) then
    print(msg);
    logMessage(msg);
  end
end
window_mode = false;

g_debug = true;
function target()
  keyboardPress(key_switchtarget);
  yrest(200);
end

function moveBreak()
  keyboardHold(key_move_down);
  yrest(500);
  keyboardRelease(key_move_down);
end

function pickup()
  printf("Pickup!\n");
  if( key_pickup == 0 ) then return; end
    local i;
    for i = 0, how_many_pickup do
      keyboardPress(key_pickup);
      yrest(500);
  end
end

--------------------------------------------------------------------------------
-- Memory Addresses.
TARGET_POS_X_ADDRESS = 0x1FCFE80;
TARGET_POS_Y_ADDRESS = 0x1FCFE84;
TARGET_POS_Z_ADDRESS = 0x1FCFE88;
TARGET_TYPE_ADDR     = 0x0619B1F;

-- Field Values.
TARGET_UNKNOWN  = 0;
TARGET_DAMAGED  = 1;
TARGET_FULL     = 2;
TARGET_DEAD     = 3;

TARGET_BAR_COLOR = {
  r_min=150, r_max=180,
  g_min=10, g_max=40,
  b_min=50, b_max=80
};

TARGET_HEALTH_BAR_PIXEL_OFFSET_1 = {x=36, y=36};
TARGET_HEALTH_BAR_PIXEL_OFFSET_2 = {x=165, y=36};
TARGET_HEALTH_BAR_PIXEL_OFFSET_3 = {x=100, y=36};

-- Target Name Color
TARGET_NAME_COLOR_SCAN_OFFSET_1 = {x=98, y=15};
TARGET_NAME_COLOR_SCAN_OFFSET_2 = {x=110, y=15};


target_name_color = {
  unknown=0,
  white=1,
  cyan=2,
  blue=3,
  green=4,
  yellow=5,
  orange=6,
  red=7,
  purple=8,
  grey=9,
};

--[[TARGET_NAME_COLOR_WHITE    = 1;
TARGET_NAME_COLOR_CYAN     = 2;
TARGET_NAME_COLOR_BLUE     = 3;
TARGET_NAME_COLOR_GREEN    = 4;
TARGET_NAME_COLOR_YELLOW   = 5;
TARGET_NAME_COLOR_ORANGE   = 6;
TARGET_NAME_COLOR_RED      = 7;
TARGET_NAME_COLOR_PURPLE   = 8;
TARGET_NAME_COLOR_GREY     = 9;]]


-- In order of difficulty, from easiest to hardest.
target_name_color_rgb = {
  [target_name_color["white"]]   = {r_min=255, r_max=255,
                                    g_min=255, g_max=255,
                                    b_min=255, b_max=255},
  [target_name_color["cyan"]]    = {r_min=120, r_max=140,
                                    g_min=255, g_max=255,
                                    b_min=255, b_max=255},
  [target_name_color["blue"]]    = {r_min=0, r_max=0,
                                    g_min=0, g_max=0,
                                    b_min=253, b_max=255},
  [target_name_color["green"]]   = {r_min=0, r_max=0,
                                    g_min=1, g_max=255,
                                    b_min=0, b_max=0},
  [target_name_color["yellow"]]  = {r_min=253, r_max=255,
                                    g_min=253, g_max=255,
                                    b_min=0, b_max=0},
  [target_name_color["orange"]]  = {r_min=255, r_max=255,
                                    g_min=128, g_max=128,
                                    b_min=0, b_max=0},
  [target_name_color["red"]]     = {r_min=255, r_max=255,
                                    g_min=0, g_max=0,
                                    b_min=0, b_max=0},
  [target_name_color["purple"]]  = {r_min=255, r_max=255,
                                    g_min=0, g_max=0,
                                    b_min=255, b_max=255},
  --[target_name_color["grey"]]  = {r_min=255, r_max=255,
   --                               g_min=255, g_max=255,
   --                               b_min=255, b_max=255},
}


TARGET_TYPE_FRIENDLY  = 0;
TARGET_TYPE_NOTHING   = -1;

-- Status Info Bar, offset.
STATUSINFOBAR_POS = {x=0, y=0};


-- Looks at pixels in the status info bar in the h/w device context,
-- to determine the status of the monster.
-- note - this has known errors, changing the colour bit value, or restarting PC
--        seems to fix it.
-- @return TARGET_UNKNOWN does not have any detectable red bar.
--         TARGET_DAMAGED if some red bar exists.
--         TARGET_FULL full red bar.
function status()
  local pos_1 = {x=(STATUSINFOBAR_POS["x"] + TARGET_HEALTH_BAR_PIXEL_OFFSET_1["x"]),
			    y=(STATUSINFOBAR_POS["y"] + TARGET_HEALTH_BAR_PIXEL_OFFSET_1["y"])};
  local pos_2 = {x=(STATUSINFOBAR_POS["x"] + TARGET_HEALTH_BAR_PIXEL_OFFSET_2["x"]),
			    y=(STATUSINFOBAR_POS["y"] + TARGET_HEALTH_BAR_PIXEL_OFFSET_2["y"])};
  local pos_3 = {x=(STATUSINFOBAR_POS["x"] + TARGET_HEALTH_BAR_PIXEL_OFFSET_3["x"]),
			    y=(STATUSINFOBAR_POS["y"] + TARGET_HEALTH_BAR_PIXEL_OFFSET_3["y"])};
  --printf("x1:%d y1:%d x2:%d y2:%d\n", pos_1["x"], pos_1["y"], pos_2["x"], pos_2["y"]);

  local l_hdc = get_hdc();
-- s(RGB) begining E(RGB) end M(RGB) middle;
  local sr,sg,sb;
  local er,eg,eb;
local mr,mg,mb;
  if (window_mode) then
    local wx, wy = windowRect(get_win());
    --debug_message(sprintf("win_x: %d, wim_y: %d\n", wx, wy));

    sr,sg,sb = getPixel(l_hdc, (wx + pos_1["x"]), (wy + pos_1["y"]));
    er,eg,eb = getPixel(l_hdc, (wx + pos_2["x"]), (wy + pos_2["y"]));
mr,mg,mb = getPixel(l_hdc, (wx + pos_3["x"]), (wy + pos_3["y"]));
  else
    sr,sg,sb = getPixel(l_hdc, pos_1["x"], pos_1["y"]);
    er,eg,eb = getPixel(l_hdc, pos_2["x"], pos_2["y"]);
mr,mg,mb = getPixel(l_hdc, pos_3["x"], pos_3["y"]);
  end
  --closeDC(hdc);
  --debug_message(sprintf("sr: %d, sg: %d, sb: %d", sr, sg, sb));
  --debug_message(sprintf("er: %d, eg: %d, eb: %d", er, eg, eb));
--debug_message(sprintf("mr: %d, mg: %d, mb: %d", mr, mg, mb));
  if ((sr >= TARGET_BAR_COLOR["r_min"] and
        sr <= TARGET_BAR_COLOR["r_max"]) and
      (sg >= TARGET_BAR_COLOR["g_min"] and
        sg <= TARGET_BAR_COLOR["g_max"]) and
      (sb >= TARGET_BAR_COLOR["b_min"] and
        sb <= TARGET_BAR_COLOR["b_max"]))
  then
      if((er <= TARGET_BAR_COLOR["r_min"] and
          er <= TARGET_BAR_COLOR["r_max"]) and
        (eg <= TARGET_BAR_COLOR["g_min"] and
          eg <= TARGET_BAR_COLOR["g_max"]) and
        (eb <= TARGET_BAR_COLOR["b_min"] and
          eb <= TARGET_BAR_COLOR["b_max"])) 
      then
	if((mr <= TARGET_BAR_COLOR["r_min"] and
          mr <= TARGET_BAR_COLOR["r_max"]) and
          (mg <= TARGET_BAR_COLOR["g_min"] and
          mg <= TARGET_BAR_COLOR["g_max"]) and
          (mb <= TARGET_BAR_COLOR["b_min"] and
          mb <= TARGET_BAR_COLOR["b_max"])) 
      	then
	  emergencyHeal=1;
	end
        return TARGET_DAMAGED;     
      end
	return TARGET_FULL;
  end
  return TARGET_UNKNOWN;
end
-- Gets the monster difficulty color, by reading each pixel in a small fixed 
-- line in the middle through the top of the lower case letters,
-- in the monster name label.
-- @return The color index of the name text on success, 0 on failure.
function get_difficulty_color()
  local pos_1 = {x=(STATUSINFOBAR_POS["x"] + TARGET_NAME_COLOR_SCAN_OFFSET_1["x"]),
                     y=(STATUSINFOBAR_POS["y"] + TARGET_NAME_COLOR_SCAN_OFFSET_1["y"])};
  local pos_2 = {x=(STATUSINFOBAR_POS["x"] + TARGET_NAME_COLOR_SCAN_OFFSET_2["x"]),
                     y=(STATUSINFOBAR_POS["y"] + TARGET_NAME_COLOR_SCAN_OFFSET_2["y"])};

  local pr, pg, pb;
  --local l_color = TARGET_NAME_COLOR_UNKNOWN;
  --local hdc = openDC(shaiya_win);
  local l_hdc = get_hdc();
  for i=pos_1["x"], pos_2["x"] do
    for j=pos_1["y"], pos_2["y"] do
      if (window_mode) then
          local wx, wy = windowRect(get_win());
          printf("win_x: %d, wim_y: %d\n", wx, wy);
          pr, pg, pb = getPixel(l_hdc, wx + i, wy + j);
        else
          pr, pg, pb = getPixel(l_hdc, i, j);
        end
        debug_message(sprintf("pr: %d, pg: %d, pb: %d", pr, pg, pb));
        for k,v in pairs(target_name_color_rgb) do
          --printf("v[r]: %d, v[g]: %d, v[b]: %d\n", v["r"], v["g"], v["b"]);
          if(pr >= v["r_min"] and pr <= v["r_max"] and
              pg >= v["g_min"] and pg <= v["g_max"] and
              pb >= v["b_min"] and pb <= v["b_max"]) then
            printf("target_difficulty_color: %s\n", k);
            return k;
          end
        end
    end
  end
  --closeDC(hdc);
  return target_name_color["unknown"];
end

-------------------------------------------------------------------
-- Modification to see if Target is Dead or FULL HP

function targetstatus()
  local pos_1 = {x=(STATUSINFOBAR_POS["x"] + TARGET_HEALTH_BAR_PIXEL_OFFSET_1["x"]),
			    y=(STATUSINFOBAR_POS["y"] + TARGET_HEALTH_BAR_PIXEL_OFFSET_1["y"])};

  --printf("x1:%d y1:%d x2:%d y2:%d\n", pos_1["x"], pos_1["y"], pos_2["x"], pos_2["y"]);

  local l_hdc = get_hdc();
-- s(RGB) begining E(RGB) end M(RGB) middle;
  local sr,sg,sb;
  if (window_mode) then
    local wx, wy = windowRect(get_win());
    --debug_message(sprintf("win_x: %d, wim_y: %d\n", wx, wy));
    sr,sg,sb = getPixel(l_hdc, (wx + pos_1["x"]), (wy + pos_1["y"]));

  else
    sr,sg,sb = getPixel(l_hdc, pos_1["x"], pos_1["y"]);
  end
  --closeDC(hdc);
  --debug_message(sprintf("sr: %d, sg: %d, sb: %d", sr, sg, sb));
  --debug_message(sprintf("er: %d, eg: %d, eb: %d", er, eg, eb));
--debug_message(sprintf("mr: %d, mg: %d, mb: %d", mr, mg, mb));
  if ((sr <= TARGET_BAR_COLOR["r_min"] and
        sr <= TARGET_BAR_COLOR["r_max"]) and
      (sg <= TARGET_BAR_COLOR["g_min"] and
        sg <= TARGET_BAR_COLOR["g_max"]) and
      (sb <= TARGET_BAR_COLOR["b_min"] and
        sb <= TARGET_BAR_COLOR["b_max"]))
  then

	return TARGET_DEAD;
  end
  return TARGET_FULL;
end
------------------------------------------------------------------------


-----------------------------------------------------------------------------------
--*******Cycle Target to see if It matches your minimum and maximum color monster ********
function cycle_target()
  --printf("self.switched_targets: %d\n", self.switched_targets);
  --printf("self.max_switch_targets: %d\n", self.max_switch_targets);

    --debug_message("new_target");
    target();
    local target_status = status();
    --printf("target_color: %d\n", target_color);
    --printf("target_status=%d\n", target_status);
    logMessage(sprintf("target_status=%d", target_status));
    
    if (target_status == TARGET_FULL) then
      local l_color = get_difficulty_color();
      local l_color_min = target_difficulty_color_min;
      local l_color_max = target_difficulty_color_max;
--printf("target_color_min: %s\n", l_color_min);
--    printf("target_color_max: %s\n", l_color_max);
printf("getting difficulty Color \n");
      --printf("l_color: %s\n", l_color);
      
if (l_color >= l_color_min and l_color <= l_color_max) then
       return true;
      end
    end
return false;
end
-----------------------------------------------------------------------------------
function cycle_target2()
    if (target_status == TARGET_FULL) then
      local l_color = get_difficulty_color();
      local l_color_min = target_difficulty_color_min;
      local l_color_max = target_difficulty_color_max;     
      if (l_color >= l_color_min and l_color <= l_color_max) then
       return true;
      end
    end
return false;
end
------------------------------------------------
-- 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;

------------------------------------------------
-- 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;


function use_hp_potion()
  keyboardPress(key_hp_potion);
  keyboardPress(key_hp_potion1);
  keyboardPress(key_hp_potion2);
  keyboardPress(key_hp_potion3);
  keyboardPress(key_hp_potion4);
  keyboardPress(key_hp_potion5);
  keyboardPress(key_hp_potion6);
  keyboardPress(key_hp_potion7);
  keyboardPress(key_hp_potion8);
  keyboardPress(key_hp_potion9);
  keyboardPress(key_hp_potion0);
  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 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);
end


function have_target()
  local readid = memoryReadShort(proc, targetid_addr);

  return ( readid ~= 0xFFFF );
end

function find_target()
  keyboardPress(key_attack);
end

function switch_target()
  keyboardPress(key_switchtarget);
end

------------------------------------------------
-- FIGHT2
------------------------------------------------
function fight2()
   local beginTime  = os.time();
   local attackLoop = true;
   local skillsonetime = 0;
  keyboardPress(key_attack);
yrest(200);
  
printf("Attacking Target \n");

  while (attackLoop) do
    local targetStatus = targetstatus();
    local Tstatus = status();
    if(targetStatus == TARGET_DEAD) then
       printf("Target Dead \n\n");
       pickup();
       attackLoop = false;
       moveBreak();
    else      
      local currentTime = os.time();
      if( os.difftime(currentTime, beginTime) > how_many_seconds ) then 
         moveBreak();
         beginTime  = os.time();
         if(Tstatus == TARGET_FULL) then
           do_jump = do_jump+1;
           printf("Changing Targets: Obsticle \n\n");
           attackLoop = false;
         end
      else
         if(skillsonetime == 0 and Tstatus == TARGET_DAMAGED) then
           skillsonetime = 1+skillsonetime;
           keyboardPress(key_skill1);
         end;
         keyboardPress(key_attack);
         yrest(2000);
      end
    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
  end
end




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


  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;

local reAttack = 0;

  while( macro_running ) do
    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(cycle_target()) then
       fight2();
       if(do_jump == 1) then
          keyboardHold(key_move_down);
          keyboardPress(key_jump);
          yrest(1000);
          keyboardPress(key_jump);
          yrest(1000);
          keyboardRelease(key_move_down);
          keyboardHold(key_move_right);
          yrest(2000);
          keyboardRelease(key_move_right);
          do_jump = 0;
       end
       reAttack = 0;
    else
       reAttack = 1 + reAttack;
    end
--printf(reAttack);
    if ( reAttack == how_many_scanTarget ) then
       reAttack = 0;
       keyboardPress(key_myself);
       yrest(500);
       keyboardHold(key_right);
       yrest(500);
       keyboardRelease(key_right);
    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

  if ((HP/MaxHP*100) <= 0) then
    --user_alive = false;
    printf("\n\nPlayer is DEAD");
    keyboardPress(key.VK_DELETE);
    --force_close();
  end    
  end
end

startMacro(main);

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

Re: Shaiya Fighter Bot

#84 Post by Administrator » Mon Jul 14, 2008 11:51 pm

You probably do not have the GameGuard bypass. Download and install it following the instructions here.

caccolone
Posts: 24
Joined: Mon Jun 09, 2008 8:23 am
Location: Frankfurt - Germany

Re: Shaiya Fighter Bot

#85 Post by caccolone » Tue Jul 15, 2008 8:20 am

heya all again :) after some time spent in testing the last version of fighter bot ima back here to leave my impressions on this good work
I dont need talk too much to explain, I can say only exceptional, it works to perfection! my fighter is almost 50 um now :o :lol: :lol: :lol: :lol: :lol: great job Deaz, thank you for this.
now I only need suggestions on where to train my fighter without risking being noticed too, at these levels is difficult to find good places, and new map still hard for leave bot alone ( also fury got almost always these maps :? )

about healer bot :
I'm still working on my HM priest but is still around level 40 and I cant use with my main character but seems work very well

mad
Posts: 1
Joined: Sun Jul 20, 2008 7:13 pm

Re: Shaiya Fighter Bot

#86 Post by mad » Tue Jul 22, 2008 12:21 pm

HI guys

first of all thanks for this nice script :mrgreen:
Here you are my problem :Since few days I try to target some green mobs but unfortunatelly I cannot target
the script work only if is allowed to target all of them .

See enclosed the script and the error message


Thanks for your help :D
Attachments
fighterc.lua
(21.89 KiB) Downloaded 557 times
Screen.JPG

MonkeyShinobi
Posts: 2
Joined: Fri Jul 25, 2008 12:11 pm

Re: Shaiya Fighter Bot

#87 Post by MonkeyShinobi » Fri Jul 25, 2008 12:28 pm

deaznracer wrote:
botforlive wrote:not sure whats going on.. this is the new script wont attack just stands around
go to function status()

find this code

Code: Select all

  --debug_message(sprintf("er: %d, eg: %d, eb: %d", er, eg, eb));
change it to this

Code: Select all

  debug_message(sprintf("er: %d, eg: %d, eb: %d", er, eg, eb));
run it again and tell me what the er eg eb says. most likely its not detecting the RGB color range.

keep in mind always drag your status information bar to the top left corner. I been repeating this too many times. I can help if you give me the er eg eb readings.

these scripts work for all my 4 computers in my house. It works for Xp and vista. Either everyone is setting it up wrong and not following the directions or something wrong with the script. Even my friendsssss had no problem loading the script.

The script leveled my Warrior tune 17 to 21 non stop for 2 days and no banned. Learn how to read & write scripts.

If you guys study the script it will read a color at a certain spot. if the color is off that mean the mob is damaged. ER EG EB is the RGB color it gets. SO it doesn't take much to use common sense. If you move the status information bar around what you think will happen. its gonna detect some other color that it doesn't recognize and says mob is damaged. Or you put another object over the spot where the status information is that will cose it to detect other color in that spot too.

I notice another bug using my Lap top. if you are using a laptop you'll have to put the resolution to 1024x768 colorbit = 16 bit.

Sometime it works on 32 bit.

This new script has a better anti-KS. The old script target a full healthy hp mob, so the bot go after it. If someone else attacks 10 seconds first , the bot will not know who hit it first and KS the other players mob. Now this new script fixed that. It will detect who hit it first. If the bot hit it second it will back off immediatly and target another healthy hp mob.

The only thing left to make the anti-ks to perfection is if a mob is attacking another user then the bot would skip that target or it becomes a KS. Because sometime a tank is pulling a Train and some of the mob he pulled hasn't been damaged yet. So if the bot detect that a mob is full hp , and is in attack mode then it should back away. So, again what i fixed was if the bot is running towards the mob and for any reason an archer/nuker hit it first it will back away.

We already fixed 2 problems now there is one left which i mention above. You guys are free to edit the setting to the old fighter.lua. I did these setting because it worked for me if you set up the pause,pickup, and other timeing right it will keep the bot a live for more than 2 days.
------------------------------------------------
-- FIGHT2
------------------------------------------------
function fight2()
local beginTime = os.time();
local attackLoop = true;
local skillsonetime = 0;
if (target_status == TARGET_FULL) then
keyboardPress(key_attack);
yrest(200);

printf("Attacking Target \n");
end

doing the above change should help more in not ksing as it will check for mobs health before hitting.

but the full code should do something like this:
select target
confirm full health
initiate attack
delay 4-5 sec?(while running to mob)
confirm full health again
if yes continue attack
else break
and select new target

please comment on the above logic

and is there a way to detect mobs that are aggroed by other players?

deaznracer
Posts: 59
Joined: Tue May 20, 2008 5:45 am

Re: Shaiya Fighter Bot

#88 Post by deaznracer » Fri Jul 25, 2008 7:41 pm

MonkeyShinobi wrote:
------------------------------------------------
-- FIGHT2
------------------------------------------------
function fight2()
local beginTime = os.time();
local attackLoop = true;
local skillsonetime = 0;
if (target_status == TARGET_FULL) then
keyboardPress(key_attack);
yrest(200);

printf("Attacking Target \n");
end

doing the above change should help more in not ksing as it will check for mobs health before hitting.

but the full code should do something like this:
select target
confirm full health
initiate attack
delay 4-5 sec?(while running to mob)
confirm full health again
if yes continue attack
else break
and select new target

please comment on the above logic

and is there a way to detect mobs that are aggroed by other players?
yes that is correct on the logic. You'll notice the full code is able to hunt at many different zones. Doing the above code you mention works, but what about when you get stun by mobs and you stop attacking. It won't re attack after the stun effect wears off. So i added extra code to fix it. As i progress my level and test different hunting spot. I constantly added on to the original code. Now it is, i would say, 95% complete on my Shaiya fighter version 2. The delay second is there for a reason, if you are targeting a healthy mob, and the char is running to attack the mob, but there is a big bolder in front of you, then you'll be there all night. So, I gave it a certain amount of time to cancel an attack if the mob Hp has not been drop. Instead of giving it a fixed time, I added an option there for a reason. The reason was not to be user friendly, but because other hunting zone have more obstacle and some zone have mobs spawn further apart from each other, so it would require more delay time before canceling an attack. So I hope that gives a better understanding on how i design fighter version 1.

Yes there is a way to detect if a monster is aggroed by other player. Which simply says who attack first gets the mob. That is what shaiya fighter 2 is for. The only missing part that i can't and have not actually took the time to find out is, what if a player is pulling a train and the mob is attacking the person but the mob's HP is full. In reality if you hit a mob that is being pulled by a guardian/defender he'll cry out "stop KS" and if you are away from your computer while the program keeps constantly repeating its mistake, then he'll probably message a GS. Currently the fighter version 2 detects who hit the mob first between you and the other player. If the other player hits first then logically the mob will run to him, so version 2 stop attacking and reacts like a real player. Also keep in mind,when i created this script, i programed it to react like a real life player and not a bot, because reacting like a bot is old school. It also makes people assume your mexican and you can't speak english, so they'll ignore you. (it's a joke, I'm not racist, seriously :D )

I retested shaiya version 2 and that is the only thing that is left needed. The only way to find out if a mob is aggroed by other player is through memory at the moment if anyone wants to help me out give me a message.

MonkeyShinobi
Posts: 2
Joined: Fri Jul 25, 2008 12:11 pm

Re: Shaiya Fighter Bot

#89 Post by MonkeyShinobi » Fri Jul 25, 2008 8:45 pm

I kindda figured it out

Try using a packet sniffer but normally in such cases u need to use some sort of a filter(e.g server emulator) to detect what the client is sending to the server and what the server is sending back to the client. example would be the cabalrider bot.

hope it helps

Im better at programming robots then utilizing packet sniffers

cronchris
Posts: 12
Joined: Mon Jul 07, 2008 10:46 am

Re: Shaiya Fighter Bot

#90 Post by cronchris » Thu Jul 31, 2008 1:59 am

What does :330: attempt to call global 'sprintf' <a nil value> mean???

If :330: means what line the error is ocurring, then it has to be something with finding the mobs colors, or something close to it. Any feedback would help.

Dnic
Posts: 24
Joined: Sun Jun 01, 2008 4:03 pm

Re: Shaiya Fighter Bot

#91 Post by Dnic » Thu Jul 31, 2008 10:50 am

One thing I have noticed is that it still will get stuck on "dead" mobs. They usually have no health on em. Micro will report it repeatedly as target damaged, but it will not move on.

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

Re: Shaiya Fighter Bot

#92 Post by Administrator » Thu Jul 31, 2008 12:26 pm

What does :330: attempt to call global 'sprintf' <a nil value> mean???
It means the function sprintf was not declared. This was a bug on my part. Just open lib/lib.lua in notepad. Press CTRL + F and type in 'sprintf' (without quotes). It'll bring you to a line with '--' in front of the declaration of sprintf. Remove the '--' and save.

cronchris
Posts: 12
Joined: Mon Jul 07, 2008 10:46 am

Re: Shaiya Fighter Bot

#93 Post by cronchris » Thu Jul 31, 2008 12:37 pm

Hey thanks alot again, I was going crazy trying to fugure that out but.....
Now it's saying :8: attempt to index global 'key' <a nil value> i tried doing same kind of thing with what you just posted but no luck :(

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

Re: Shaiya Fighter Bot

#94 Post by Administrator » Thu Jul 31, 2008 1:08 pm

In older versions, 'key' was simply a table. It has been moved into a module. Ensure that your config.lua (in MicroMacro's main directory) has keyboard = "en_us" and micromacro/lib/mods/keyboard/en_us.lua exists.

Ensure that your keyboard and language setup in lib/lib.lua has not been messed up:

Code: Select all

------------------------------------------------------
-- Keyboard & Language setup
------------------------------------------------------
key = nil;
if( keyboard ~= nil and type(keyboard) == "string" ) then
  key = require("keyboard/" .. keyboard);
end

if( key == true or key == nil ) then
  error("Error loading keyboard module.");
  key = { };
end

If anything seems out of the ordinary on your end, you should probably redownload and install the most recent version (which does contain a few fixes) from the download page.

cronchris
Posts: 12
Joined: Mon Jul 07, 2008 10:46 am

Re: Shaiya Fighter Bot

#95 Post by cronchris » Thu Jul 31, 2008 2:07 pm

------------------------------------------------------
-- Keyboard & Language setup
------------------------------------------------------
key = nil;
if( keyboard ~= nil and type(keyboard) == "string" ) then
key = require("keyboard/" .. keyboard);
end

if( key == true or key == nil ) then
error("Error loading keyboard module.");
key = { };
end

Looks same to me unless I am missing something.

cronchris
Posts: 12
Joined: Mon Jul 07, 2008 10:46 am

Re: Shaiya Fighter Bot

#96 Post by cronchris » Thu Jul 31, 2008 2:23 pm

Ok re-downloaded MicroMacro again fixed the sprintf, and I am still getting the same message.

That message is when I try to use the fighter script, I get same thing with shya script but its a :4: infront instead of :8: , and the shaiya one worked fine untill I changes the sprintf for fighter script. I'm very puzzled?????
Last edited by cronchris on Thu Jul 31, 2008 2:26 pm, edited 1 time in total.

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

Re: Shaiya Fighter Bot

#97 Post by Administrator » Thu Jul 31, 2008 2:24 pm

And you do not receive the error message? What does your log say? Have you updated within the last few days?

Edit:
Ok re-downloaded MicroMacro again fixed the sprintf, and I am still getting the same message.
This should not happen. Did you remember to clear your cache before downloading? I just double-checked to make sure that the latest version did include the sprintf() fix.

Code: Select all

-- Formatted output
-- C sprintf-like function
sprintf = string.format;

cronchris
Posts: 12
Joined: Mon Jul 07, 2008 10:46 am

Re: Shaiya Fighter Bot

#98 Post by cronchris » Thu Jul 31, 2008 3:18 pm

how do you clear cache? on micromacro itself? here is my log

Thu Jul 31 14:24:33 2008 : MicroMacro v0.97
Thu Jul 31 14:24:33 2008 : Processor Type: 586, OS: Windows Vista | Windows Server 2008 Service Pack 1
Thu Jul 31 14:24:33 2008 : Lua initialized successfully.
Thu Jul 31 14:24:33 2008 : Lua libs opened successfully.
Thu Jul 31 14:24:33 2008 : Lua glues exported.
Thu Jul 31 14:24:33 2008 : C:\Users\Walmart\Desktop\micromacro\micromacro\lib\lib.lua:99: '=' expected near 'sprintf'
Thu Jul 31 14:24:33 2008 : Warning: Global 'key' is not a table.
Thu Jul 31 14:24:33 2008 : Configurations run.
Thu Jul 31 14:24:37 2008 : Executing script "shaiya.lua".
==================================================

Thu Jul 31 14:24:37 2008 : ...art\Desktop\micromacro\micromacro\scripts\shaiya.lua:4: attempt to index global 'key' (a nil value)
Thu Jul 31 14:24:37 2008 : Execution of shaiya.lua complete.
Thu Jul 31 14:24:37 2008 : Execution error: Runtime error
Thu Jul 31 14:24:37 2008 : Collecting garbage...
Thu Jul 31 14:24:37 2008 : 32KB freed.



Thu Jul 31 14:24:47 2008 : Executing script "fighterc.lua".
==================================================

Thu Jul 31 14:24:47 2008 : ...t\Desktop\micromacro\micromacro\scripts\fighterc.lua:8: attempt to index global 'key' (a nil value)
Thu Jul 31 14:24:47 2008 : Execution of fighterc.lua complete.
Thu Jul 31 14:24:47 2008 : Execution error: Runtime error
Thu Jul 31 14:24:47 2008 : Collecting garbage...
Thu Jul 31 14:24:47 2008 : 61KB freed.



Thu Jul 31 14:26:39 2008 : Executing script "fighter.lua".
==================================================

Thu Jul 31 14:26:39 2008 : ...rt\Desktop\micromacro\micromacro\scripts\fighter.lua:8: attempt to index global 'key' (a nil value)
Thu Jul 31 14:26:39 2008 : Execution of fighter.lua complete.
Thu Jul 31 14:26:39 2008 : Execution error: Runtime error
Thu Jul 31 14:26:39 2008 : Collecting garbage...
Thu Jul 31 14:26:39 2008 : 62KB freed.



Thu Jul 31 14:26:45 2008 : Executing script "shaiya.lua".
==================================================

Thu Jul 31 14:26:45 2008 : ...art\Desktop\micromacro\micromacro\scripts\shaiya.lua:4: attempt to index global 'key' (a nil value)
Thu Jul 31 14:26:45 2008 : Execution of shaiya.lua complete.
Thu Jul 31 14:26:45 2008 : Execution error: Runtime error
Thu Jul 31 14:26:45 2008 : Collecting garbage...
Thu Jul 31 14:26:45 2008 : 32KB freed.

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

Re: Shaiya Fighter Bot

#99 Post by Administrator » Thu Jul 31, 2008 3:51 pm

C:\Users\Walmart\Desktop\micromacro\micromacro\lib\lib.lua:99: '=' expected near 'sprintf'
I'm betting this is the source of the error. Open up lib/lib.lua again, press CTRL+G. Type in 99 and click OK. it should bring you directly to the sprintf section. Make sure it looks exactly like this:

Code: Select all

-- Formatted output
-- C sprintf-like function
sprintf = string.format;

cronchris
Posts: 12
Joined: Mon Jul 07, 2008 10:46 am

Re: Shaiya Fighter Bot

#100 Post by cronchris » Thu Jul 31, 2008 8:11 pm

ah corecto, thanks bro, said printf instead of sprintf ima test it right now

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests