[Help] Runes Of Magic

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Message
Author
Mesosmagnet
Posts: 37
Joined: Wed Apr 23, 2008 7:11 am

[Help] Runes Of Magic

#1 Post by Mesosmagnet » Sun Nov 02, 2008 1:11 am

I have kinda given up on Atlantica because i find it kinda boring, and so i have moved on to a new game: Runes of Magic.

It is your typical MMORPG. I need to find the address to know whether I currently have a target. During game-play when u select a target the targets name appears on top center of the screen, and when you attack it there will be a message that says "Enter Battle" and when you kill it or run too far away from it it says "leave battle". Can someone please teach me how to find the address to know when I am in battle and when I am not in battle? Thanks!

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

Re: [Help] Runes Of Magic

#2 Post by 3cmSailorfuku » Sun Nov 02, 2008 5:55 am

Mesosmagnet wrote:I have kinda given up on Atlantica because i find it kinda boring, and so i have moved on to a new game: Runes of Magic.

It is your typical MMORPG. I need to find the address to know whether I currently have a target. During game-play when u select a target the targets name appears on top center of the screen, and when you attack it there will be a message that says "Enter Battle" and when you kill it or run too far away from it it says "leave battle". Can someone please teach me how to find the address to know when I am in battle and when I am not in battle? Thanks!
It's to 99% always a boolean. It depends on what you wanna focus, personally I always pick the adress for the GUI element that has been showing on the top if a monster has been selected or not.
Though there may also be adresses that have the state of the selected monster, like attacking, idling etc.

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

Re: [Help] Runes Of Magic

#3 Post by Administrator » Sun Nov 02, 2008 4:04 pm

I typically use the pointer to the selected target. In most games, the pointer will be 0 (NULL) if none selected, else it will contain a pointer to the target's struct/class.

You can start by having a monster selected, and do an unknown initial value, 4 bytes search. Once this step completes, deselect a monster, and search for an exact value 0. Now select a monster again, and search for a changed value. Now change to a different monster, changed value again. Deselect, search for exact value 0. Etc. Eventually you'll get down to ~10 results or less (hopefully).

Unless the address you find is green in the address menu (I'm assuming you're using Cheat Engine here), you'll need to look up a pointer. Use my tutorial in the memory editing section of the tutorial for this. Typically, it's a double pointer, so you'll need to find a pointer to the pointer you just found. I know, it sounds confusing, but take it step at a time.


This method, although a bit more complicated and time consuming, might eventually allow you to access your target's HP, MP, position, level, and other important data.

Zephyr
Posts: 86
Joined: Fri Apr 18, 2008 8:10 pm

Re: [Help] Runes Of Magic

#4 Post by Zephyr » Sun Nov 02, 2008 7:07 pm

Started looking at this one myself. I get down to four addresses. When I check to see what is accessing one to find the pointer I get a Proction error 103 msg dialog. The odd thing is I receive the same exact dialog with Perfect World. Has anyone come across this one? Been disabling AV and other programs with no luck.

using CE 5.4

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

Re: [Help] Runes Of Magic

#5 Post by Administrator » Sun Nov 02, 2008 7:53 pm

What operating system are you using? It could just be another protection error caused by Vista's UAC. Make sure you run CE with adequate privileges (set it to run as administrator) and try again.

Since I have not gotten into RoM's beta, I cannot be of any more assistance.

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

Re: [Help] Runes Of Magic

#6 Post by Mesosmagnet » Mon Nov 03, 2008 2:40 am

0060c03c this address always pops up when i try to search for any addresses that write to my current HP address(which changes every time i restart the game or use another character). So after getting that...how do i find my HP address?
I'm going to try your monster pointer tip now. Hope it works out! Owh and I will be reading your tutorial so I wont sound so irritating the next time i come for some answers. Thanks


[EDIT] I tried to search for unknown value and it crashed my PC and now even after restarting it everything is just too slow and not responding as it should. The game itself is extremely buggy and I dont want my PC to ever crash like that again I'm going to put a pause to Runes Of Magic for the time being.

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

Re: [Help] Runes Of Magic

#7 Post by Administrator » Mon Nov 03, 2008 3:34 am

I'm sorry to hear that. With so little information, it'd be hard for me to help you anyways. Once the game is in open beta, I'll get around to messing with it.

Zephyr
Posts: 86
Joined: Fri Apr 18, 2008 8:10 pm

Re: [Help] Runes Of Magic

#8 Post by Zephyr » Fri Nov 21, 2008 9:15 pm

OK, with CE working was able to track down pointers and offsets

pointer
014fe124

hp
0x314

energy/mana(primary class bar)
0x320

energy/mana(secondary class bar)
0x328



gonna work on target next.

RedBloodz
Posts: 15
Joined: Wed Mar 12, 2008 5:08 pm

Re: [Help] Runes Of Magic

#9 Post by RedBloodz » Wed Dec 17, 2008 1:31 am

can someone help me out. I made this simple code for a KNIGHT class, but i cant test it out because it cannot read the process from the game. I really dont know anything about reading processes and offset, so this is as far as i can try
i get the following error when trying to run the code

\micromacro\scripts\rom.lua:35: Wrong number of parameters supplied to memoryReadBytePtr().

Code: Select all


proc = 0;
win = 0;
HP_addr = "220CDA1C";
MANA_addr = "220CDA28";
maxHP_addr = "220CDA24";
maxMANA_addr = "220CDA2C";
maxHP = 10000;
maxMANA = 10000;
HP = 10000; -- default, this corrects itself (don't change it!)
MANA = 10000;-- default, this corrects itself (don't change it!)

count=o;
rotatecount=0;
--------------------------------
--------------------------------

----NOTE: These value are in percentage

HP_sit = 75; -- %HP to rest at
MANA_sit = 30; -- %MANA to rest at
HP_emergency = 50; -- %emergency! use a potion!
MANA_emergency = 25;


key_attack = key.VK_1; -- normal melee attack
sit_key = key.VK_X;
-------------------------------
function update_vars()
  HP = memoryReadIntPtr(proc, HP_addr);
  MANA = memoryReadIntPtr(proc, MANA_addr);
  maxHP = memoryReadIntPtr(proc, maxHP_addr);
  maxMANA = memoryReadIntPtr(proc, maxMANA_addr);
end


-- fight as a knight
function knight_fight()
  keyboardHold(key_attack);
  yrest(150);
  keyboardRelease(key_attack);
           if( (HP / maxHP * 100)< HP_sit and HP_sit > 0) then sit(); end
           if( (MANA / maxMANA * 100) < MANA_sit and MANA_sit > 0 ) then sit(); end
    pickup();
    pickup();


end


function pickup()
  keyboardHold(key_attack);
  yrest(200);
  keyboardRelease(key_attack);
end


function target_monster()
  keyboardHold(key.VK_TAB);
  yrest(50);
  keyboardRelease(key.VK_TAB);
end


function have_target()
  r,g,b = getPixel(hdc, 415, 50); 
 --- print("Color R,G,B: ", r, g, b);
  -- check for the red HP bar in the monster's HP window
    if( r ==156 and g == 1 and b == 0) then
       return true;
    else
         return false;
    end
end  ---end for have_target function


function rotate_cam()
  keyboardHold(key.VK_E);
  yrest(1000);
  keyboardRelease(key.VK_E);
    if ( rotatecount==5 ) then
              keyboardHold(key.VK_W);
              yrest(2000);
              keyboardRelease(key.VK_W);
              rotatecount=0;
    end
end


function emergency_heal()
	  keyboardHold(key.VK_DASH);
  	  yrest(100);
	  keyboardRelease(key.VK_DASH);
end

function emergency_mana()
	  keyboardHold(key.VK_EQUAL);
  	  yrest(100);
	  keyboardRelease(key.VK_EQUAL);
end


-- rest untill healed
function sit()
  printf( os.date("Resting... %X\n") );
  keyboardPress(sit_key);
  local last_hp = HP;
  yrest(1000);

  while( true ) do
    -- sit there looking stupid.
    if( HP == maxHP and MANA == maxMANA ) then break; end;

    -- exiting rest disabled for now.
    if( HP < last_hp ) then printf("Exiting! Under attack."); break; end; -- exit rest if under attack

    last_hp = HP;
    yrest(100);
  end

  printf( os.date("Exiting rest. %X\n") );
  keyboardPress(sit_key);
end



function main()
  win = findWindow("Runes of Magic");
  hdc = openDC(win);
  proc = openProcess( findProcessByExe("Client.exe") );
  attach(win);
  registerTimer("update_vars", 100, update_vars);


while( 1 ) do

        target_monster();
        yrest(500);

      if ( have_target() ) then
          while ( have_target() ) do
               knight_fight();
          end
      else
        rotate_cam();
        yrest(500);
        rotatecount=rotatecount+1;
      end
           if( (HP / maxHP * 100)< HP_sit and HP_sit > 0) then sit(); end
           if( (MANA / maxMANA * 100) < MANA_sit and MANA_sit > 0 ) then sit(); end
         if(  (HP / maxHP * 100) < HP_emergency ) then emergency_heal(); end
         if( (MANA / maxMANA * 100) < MANA_emergency ) then emergency_mana(); end


end  ---end for while loop

  detach();
  closeProcess(proc);
end

startMacro(main);


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

Re: [Help] Runes Of Magic

#10 Post by Administrator » Wed Dec 17, 2008 1:53 am

See the online manual for memory reading information. You are doing several things wrong. One of them being specifying addresses as strings, which has long since been deprecated. The error you're getting is due to trying to read a pointer without given an offset (memorRead*Ptr functions require offsets).

I wouldn't worry about it anyways. In a few days the bot that's in the private section of this forum will be released. There's still just a few bugs to work out first.

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

Re: [Help] Runes Of Magic

#11 Post by tcflying » Thu Dec 18, 2008 12:13 pm

Administrator wrote:See the online manual for memory reading information. You are doing several things wrong. One of them being specifying addresses as strings, which has long since been deprecated. The error you're getting is due to trying to read a pointer without given an offset (memorRead*Ptr functions require offsets).

I wouldn't worry about it anyways. In a few days the bot that's in the private section of this forum will be released. There's still just a few bugs to work out first.
i am also interested in this game, and feel bored in the leveling way. may i get the bot atm?

Zephyr
Posts: 86
Joined: Fri Apr 18, 2008 8:10 pm

Re: [Help] Runes Of Magic

#12 Post by Zephyr » Thu Dec 18, 2008 12:24 pm

tcflying

As the boss guy said above. It is still being developed and has some bugs to work out. Though I would think it should be ready by christmas if not sooner seeing as how he is the guru ;)

Zeph

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

Re: [Help] Runes Of Magic

#13 Post by tcflying » Thu Dec 18, 2008 4:41 pm

yes. thx to Zephyr first of all. i just be afraid that admin said in the private section. don't know if i can see the section. but thx for the answer anyway.

Zephyr
Posts: 86
Joined: Fri Apr 18, 2008 8:10 pm

Re: [Help] Runes Of Magic

#14 Post by Zephyr » Thu Dec 18, 2008 5:58 pm

yes it is in the private section and you wont be able to even see the forum. But be assured it is being tested and should be bug free soon.

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

Re: [Help] Runes Of Magic

#15 Post by tcflying » Sat Dec 20, 2008 2:44 pm

thx to Zephyr. i also to join the text and will report the bug. how can i do?

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

Re: [Help] Runes Of Magic

#16 Post by tcflying » Sat Dec 27, 2008 6:20 am

hello, dear admin. is there any news for ROM bot?

RedBloodz
Posts: 15
Joined: Wed Mar 12, 2008 5:08 pm

Re: [Help] Runes Of Magic

#17 Post by RedBloodz » Sat Dec 27, 2008 3:07 pm

hey, can someone help me with my code. It run really fine for Knight and Priest combo. It just m having trouble with my death() function. Especially with any mouse function
I cant seem to make the mouseSet to move where i wanted it and perform mouseLHold() and mouseLRelease().
Basically, I want the mouse to click on revival button but the mouse wont move to that location.
I'm using MicroMacro v0.99.
My other question is about the pointer and the offset. This address and offset below seem to work every time i start my bot on this comp, its XP. But on my vista it has different address but same pointer. what with that.


Code: Select all


--------------------------------
--Edit THESE
--------------------------------
class = CLASS_KNIGHT;  ---INPUT your class: warrior or knight
                         --- this code only work with warrior or knight now
                           --CLASS_KNIGHT, CLASS_WARRIOR, CLASS_CLERIC, CLASS_MAGE, CLASS_ARCHER = 4;

----NOTE: These value are in percentage
HP_sit = 1; -- %HP to rest at
HP_emergency = 45; -- %emergency! use a potion!
HP_regeneration = 85;  ---HP when wants to use regeneration spell
MANA_sit = 40; -- sit when SP go down to 40%
MANA_emergency = 25; --when SP potion when SP go down to 25%
holyshield_HP = 15;  ---percent to use holyshield, this give u few sec of invul
frenzy_HP = 25;  ---when HP go down to 25%, frenzy will be used.

have_buff1 = true;  --if true or false if you have buff spell
have_buff2 = true;
have_buff3 = true;
buff1_duration = 2; -- buff durations in minutes
buff2_duration = 4; -- this will auto buff after duration is up
buff3_duration = 10;


key_hppotion = key.VK_DASH;   ---HP potion key
key_sppotion = key.VK_EQUAL;  ---MP potion key


enraged_key = key.VK_2;  ---enrage skill for class warrior
key_frenzy = key.VK_8;  ---frenzy skill for warrior

key_attack = key.VK_1; -- normal melee attack (default is 1)
key_skill2 = key.VK_2;   ---Skill 2 key
key_skill3 = key.VK_3;  ---Skill 3 key
key_skill4 = key.VK_4;  ---skill 4 key
key_skill5 = key.VK_5;  ---skill 4 key
key_regen = key.VK_6;   ---regeneration skill
key_absorp = key.VK_4;  ---Mana Absorption Skill key
key_resolution = key.VK_7;   --Resolution skill key
key_holyshield = key.VK_8;   ---Knight holy shield skill

key_buff1 = key.VK_9;   ---buff skill #1
key_buff2 = key.VK_0;   ---buff skill #2
key_buff3 = key.VK_NUMPAD9;   ---buff skill #3
sit_key = key.VK_X;      ----Sit/Resting key (default is X)

-------------------------------
--Dont EDIT anything below
--------------------------------
CLASS_KNIGHT = 0;
CLASS_WARRIOR = 1;
CLASS_CLERIC = 2;
CLASS_MAGE = 3;
CLASS_ARCHER = 4;
proc = 0;
win = 0;
success = true;
HP_addr = 0x014ED760;
HP_offset = 796;
maxHP_addr = 0x014ED760;
maxHP_offset = 804;
maxHP = 10000;
MANA_addr = 0x014ED760;
MANA_offset = 808;
maxMANA_addr = 0x014ED760;
maxMANA_offset = 812;
maxHP = 10000;
maxMANA = 10000;
HP = 10000; -- default, this corrects itself (don't change it!)
MANA = 10000;-- default, this corrects itself (don't change it!)

monstercount = 0
regen_duration = 18;
count=o;
rotatecount=0;
buff1_needed = true;
buff2_needed = true;
buff3_needed = true;
regen_needed = true;
-------------------------------------------------

function update_vars()
  HP,success = memoryReadIntPtr(proc, HP_addr,HP_offset);
  maxHP = memoryReadIntPtr(proc, maxHP_addr,maxHP_offset);
        if (class ~= CLASS_WARRIOR) then
   	MANA = memoryReadIntPtr(proc, MANA_addr, MANA_offset );
  	maxMANA = memoryReadIntPtr(proc, maxMANA_addr, maxMANA_offset);
       end
end



function fight()

  -- fight as a knight
	buff();
          if (class == CLASS_KNIGHT ) then
   --print("HP ", HP);
   --print("maxHP ", maxHP);
   --print("MANA ", MANA);
   --print("maxMANA ", maxMANA);
    	     if(  (HP / maxHP * 100) < HP_regeneration ) then regeneration_heal(); end
    	     if(  (HP / maxHP * 100) < HP_emergency ) then emergency_heal(); end
                  if( (MANA / maxMANA * 100) < MANA_emergency ) then emergency_mana(); end
	  keyboardHold(key_attack);
 	 yrest(150);
	  keyboardRelease(key_attack);

	    if( math.random(100) > 85 ) then
    	  if( math.random(100) >= 50 ) then
   	       yrest(100);
   	       keyboardHold(key_skill2);
   	       yrest(50);
	        keyboardRelease(key_skill2);
   	       yrest(150);
	      else
   	       yrest(100);
	        keyboardHold(key_skill3);
	        yrest(50);
	        keyboardRelease(key_skill3);
   	       yrest(150);
	      end
	    end
	     ----holyshield code
	         if(  (HP / maxHP * 100) < holyshield_HP ) then
                            yrest(500);
                            keyboardPress(key_holyshield); 
                           yrest(500);
                        end
	   ----resolution skill code (this give you big burst of HP when it get low, so u wont die)
	         if(  ((HP / maxHP * 100)+10) < holyshield_HP ) then keyboardPress(key_resolution); end
	    ---mana absorption code
		keyboardPress(key_absorp);
  	            rotatecount=0;
                 if( HP == 0 ) then 
                        death();
                  end

	end  --end for if class is knight 


-- fight as a warrior
    if (class == CLASS_WARRIOR) then
	   if(  (HP / maxHP * 100) < HP_emergency ) then emergency_heal(); end
                keyboardPress(enraged_key);
	  yrest(50);
	  keyboardHold(key_attack);
	  yrest(50);
	  keyboardRelease(key_attack);
	    if( math.random(100) > 75 ) then
	      if( math.random(100) >= 50 ) then
	        yrest(50);
	        keyboardHold(key_skill3);
	        yrest(50);
	        keyboardRelease(key_skill3);
	        yrest(1100);
	        keyboardHold(key_skill4);
	        yrest(50);
	        keyboardRelease(key_skill4);
	        yrest(50);
	      else
	        keyboardHold(key_skill5);
	        yrest(50);
	        keyboardRelease(key_skill5);
	        yrest(50);
	      end
	    end
   	  ----Frezy skill code
    	     if(  (HP / maxHP * 100) < frenzy_HP ) then keyboardPress(key_frenzy); end
     	    rotatecount=0;  
    end  --end for the if class is warrior 

end  ---end for the fight fuction

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

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


function regen_timer()
  regen_needed = true;
end


function pickup()
  keyboardHold(key_attack);
  yrest(200);
  keyboardRelease(key_attack);
end


function target_monster()
  keyboardHold(key.VK_TAB);
  yrest(50);
  keyboardRelease(key.VK_TAB);
end


function have_target()
  r,g,b = getPixel(hdc, 415, 50); 
  --print("Color R,G,B: ", r, g, b);
  -- check for the red HP bar in the monster's HP window
    if( r ==156 and g == 1 and b == 0 ) then
       return true;
    else
         return false;
    end
end  ---end for have_target function


function player()
  r2,g2,b2 = getPixel(hdc, 430, 30); 
--  print("Color R,G,B: ", r, g, b);
    if( r2 ==0 and g2 == 120 and b2 == 0  ) then  
       return true;
    else
         return false;
    end
end --- end for the player function

function targetbox()
  rt,gt,bt = getPixel(hdc, 540, 30); 
   --print("Color Rt,Gt,Bt: ", rt, gt, bt);
    if( rt ==227 and gt == 221 and bt == 212  ) then  
       return true;
    else
         return false;
    end

end  --end for targetbox function

function rotate_cam()
  keyboardHold(key.VK_D);
  yrest(550);
  keyboardRelease(key.VK_D);
    if ( rotatecount>=8 ) then
              keyboardHold(key.VK_W);
              yrest(2000);
              keyboardRelease(key.VK_W);
              rotatecount=0;
    end
end


function emergency_heal()
	  keyboardHold(key_hppotion);
  	  yrest(100);
	  keyboardRelease(key_hppotion);
end
function emergency_mana()
	  keyboardHold(key_sppotion);
  	  yrest(100);
	  keyboardRelease(key_sppotion);
end

function regeneration_heal()

        if( regen_needed ) then
          yrest(1000);
          keyboardHold(key_regen);
          yrest(300);
          keyboardRelease(key_regen);
            print("Regen used, wait 20 sec");
          regen_needed  = false;
        end

end

-- rest untill healed
function sit()
  printf( os.date("Resting... %X\n") );
  yrest(500);
  keyboardHold(sit_key);
  yrest(200);
  keyboardRelease(sit_key);
  local last_hp = HP;
  yrest(1000);

  while( true ) do
    -- sit there looking stupid.
    if( class == CLASS_WARRIOR and HP == maxHP ) then break;
    elseif (class ~= CLASS_WARRIOR and HP == maxHP and MANA == maxMANA) then break; end;
    -- exiting rest disabled for now.
    if( HP < last_hp ) then 
            printf("Exiting! Under attack."); 
 	   yrest(2500);
	  keyboardHold(key.VK_E);
 	   yrest(100);
	  keyboardRelease(key.VK_E);
	  keyboardHold(key.VK_S);
 	   yrest(1500);
	  keyboardRelease(key.VK_S);
            break; 
    end; -- exit rest if under attack
          while ( have_target() ) do
               fight();
          end
  	  if ( targetbox() ) then
   	         keyboardHold(key.VK_ESCAPE);
    	        yrest(200);
    	         keyboardRelease(key.VK_ESCAPE);
    	        yrest(200);
	   end
    last_hp = HP;
    yrest(100);
  end

  printf( os.date("Exiting rest. %X\n") );
  keyboardPress(sit_key);
end


function death()
  wx,wy = windowRect(win);

                 yrest(5000);
	  print("dHP ", HP);
	  print("dmaxHP ", maxHP);
	 printf("You're Dead, reviving and keep on botting\n"); 
	 yrest(5000);  --wait 10 secs for the revive box pop up
                --- click on the resurrect box
	  print("wx ", wx);
	  print("wy ", wy);
                      mouseSet(wx+500, wy+190);
 	        yrest(200);
 	        mouseLHold();
	         yrest(100);
	         mouseLRelease();
	          yrest(100);
	 yrest(120000);  --wait 120 secs for the comp to load and rev weakness to be gone
                   ---this mouse click will fix the targeting system bug
	      mouseSet(60, 60);
 	      yrest(200);
 	       mouseLHold();
	       yrest(100);
	       mouseLRelease();
	     yrest(100);
   	  	   if ( player() ) then
      	    	     keyboardHold(key.VK_ESCAPE);
      	     	     yrest(200);
      	     	     keyboardRelease(key.VK_ESCAPE);
      	     	     yrest(200);
     	  	  end

end  --end of the function


function buff()

        if( buff1_needed and have_buff1) then
          yrest(1000);
          keyboardHold(key_buff1);
          yrest(100);
          keyboardRelease(key_buff1);
          buff1_needed = false;
          yrest(1000);
        end

        if( buff2_needed and have_buff2) then
          yrest(1000);
          keyboardHold(key_buff2);
          yrest(100);
          keyboardRelease(key_buff2);
          buff2_needed = false;
          yrest(1000);
        end

        if( buff3_needed and have_buff3) then
          yrest(1000);
          keyboardHold(key_buff3);
          yrest(100);
          keyboardRelease(key_buff3);
          buff3_needed = false;
          yrest(1000);
        end

        if ( player() ) then
            keyboardHold(key.VK_ESCAPE);
            yrest(200);
             keyboardRelease(key.VK_ESCAPE);
            yrest(200);
        end

end --end of function

function changeweapon()
	        yrest(150);
            keyboardHold(key.VK_B);
            yrest(200);
             keyboardRelease(key.VK_B);
	        yrest(150);
                      mouseSet(773, 394);
 	        yrest(200);
 	        mouseRHold();
	        yrest(150);
	       mouseRRelease();
	       yrest(200);

end


function main()
  win = findWindow("Runes of Magic");
  hdc = openDC(win);
  proc = openProcess( findProcessByExe("Client.exe") );
  attach(win);
  registerTimer("update_vars", 100, update_vars);
    registerTimer("buff1_timer", 60000*buff1_duration, buff1_timer);
    registerTimer("buff2_timer", 60000*buff2_duration, buff2_timer);
    registerTimer("buff3_timer", 60000*buff3_duration, buff3_timer);
    registerTimer("regen_timer", 1000*regen_duration, regen_timer);
while( 1 ) do

   --print("HP ", HP);
   --print("maxHP ", maxHP);
   --print("MANA ", MANA);
   --print("maxMANA ", maxMANA);

                 if( HP == 0 ) then death(); end

        target_monster();
        yrest(500);

          for j=0,2 do
             if ( have_target() ) then
                     monstercount = monstercount + 1;
                      print(" monster killed ",  monstercount);
                       while ( have_target() ) do
		fight(); 
                       end
                         for i = 0,3 do
		pickup();
		yrest(500);
	           end
  	         if ( targetbox() or player()) then
   	       	  keyboardHold(key.VK_ESCAPE);
    	      	  yrest(200);
    	       	  keyboardRelease(key.VK_ESCAPE);
    	       	 yrest(200);
	        end
                     yrest(1500);
               ---- following code to get the character oriented correctly
	      keyboardHold(key.VK_D);
 	      yrest(100);
	      keyboardRelease(key.VK_D);
 	      yrest(100);

                -----------------------------
        -- else
     	   --rotate_cam();
       	  --rotatecount=rotatecount+1;
      	   --yrest(400);

        end   ---end for if have_target loop
     end   --- end for the for loop
     	   rotate_cam();
       	  rotatecount=rotatecount+1;

 	     	    yrest(500);
         	                  if( (HP / maxHP * 100)< HP_sit and (HP / maxHP * 100) > HP_emergency) then sit(); end
                                if(  class ~= CLASS_WARRIOR and (MANA / maxMANA * 100) < MANA_sit and (MANA / maxMANA * 100) > MANA_emergency ) then sit(); end
       	                  if(  (HP / maxHP * 100) < HP_emergency ) then emergency_heal(); end
      	                  if( class ~= CLASS_WARRIOR and (MANA / maxMANA * 100) < MANA_emergency ) then emergency_mana(); end

	buff();
          if (monstercount >= 150 and monstercount <= 300) then
             changeweapon();  ---because current weapon durability is zero
             monstercount = 0;
          end

end  ---end for while loop

  detach();
  closeProcess(proc);
  closeDC(hdc);
end

startMacro(main);


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

Re: [Help] Runes Of Magic

#18 Post by Administrator » Sat Dec 27, 2008 4:51 pm

Attached mouse input does not work for RoM. You'd need to use normal mouse input.

Code: Select all

detach(); --deatch temporarily
mouseSet(x, y);
mouseLClick();
attach(win); --re-attach.

Now about your pointer issue... There is nothing to worry about. This is normal. As you open and close the game, it is clearing and re-allocating in the same memory regions. This happens mostly just by chance, as any other programs could potentially allocate memory in that space, causing RoM to have to allocate memory at a different address. As long as you've found a static pointer (one that does not change across systems or when restarting the game), you are done.

RedBloodz
Posts: 15
Joined: Wed Mar 12, 2008 5:08 pm

Re: [Help] Runes Of Magic

#19 Post by RedBloodz » Thu Jan 01, 2009 4:26 pm

thanx, now the mouse works great.
well now m trying to improve my bot. Currently m using pixel base target detection, but m trying to switch to targetID memory address so i can create a MonsterList like in perfect world bot. I just wonder how can you find the targetID address. I'm guesing u search for unknown value, target a monster, search for unknown again, repeat until u have few addresses. I wonder how u go about doing that. like what type of search do i do, what byte, or value, etc.? I was able to find the addresses for HP and MP, but for the target box my hand are tied.


here's the rough version of my bot in case anyone wanna to use it.

Code: Select all


---************************************************************************
--------------------------------
--Edit THESE  ---run in  FULLSCREEN, 1024x768
--------------------------------
class = CLASS_KNIGHT;  ---INPUT your PRIMARY class (got to be exact, CAPs and everything)
                                     --CLASS_KNIGHT, CLASS_WARRIOR, CLASS_PRIEST, CLASS_MAGE, CLASS_SCOUT, CLASS_ROGUE   
sclass = CLASS_PRIEST; ---Input your SECONDARY class (put the same as primary if u dont have one)


----NOTE: These value are in percentage
HP_sit = 5; -- %HP to rest at
HP_emergency = 60; -- %emergency! use a potion!
MANA_sit = 50; -- sit when SP go down to 40%
MANA_emergency = 30; --when SP potion when SP go down to 25%

--- check your class below to see what key to put
key_attack = key.VK_1; -- normal melee attack (default is 1)
key_skill2 = key.VK_2;   ---Skill 2 key
key_skill3 = key.VK_3;  ---Skill 3 key
key_skill4 = key.VK_4;  ---skill 4 key
key_skill5 = key.VK_5;  ---skill 5 key
key_skill6 = key.VK_6;  ---skill 6 key

--buff, work for all classes
have_buff1 = false;  --if true or false if you have buff spell
have_buff2 = false;
have_buff3 = false;
key_buff1 = key.VK_9;   ---buff skill #1
key_buff2 = key.VK_0;   ---buff skill #2
key_buff3 = key.VK_NUMPAD8;   ---buff skill #3
buff1_duration = 3.7; -- buff durations is in minutes
buff2_duration = 1.9; -- this will auto buff after duration is up
buff3_duration = 10;

key_hppotion = key.VK_DASH;   ---HP potion key
key_sppotion = key.VK_EQUAL;  ---MP potion key

--knight 
if (class == CLASS_KNIGHT or sclass == CLASS_KNIGHT) then

holyshield_HP = 15;  ---percent to use holyshield, this give u few sec of invul
key_holyshield = key.VK_NUMPAD1;   ---Knight holy shield skill
resolution_HP = 60;  ---percent to use resolution spell
key_resolution = key.VK_8;   --Resolution skill key
key_absorp = key.VK_4;  ---Mana Absorption Skill key

end

--priest
if (class == CLASS_PRIEST or sclass == CLASS_PRIEST) then                

soulsource_HP = 10;   ---Soul Source spell will be used when HP down to 10%, emergency use only
key_soulsource = key.VK_NUMPAD7;
priestspell1 = key.VK_2;   ---the mage will cast a spell that take 3 second to load, and follow by instant spell. 
priestspell2 = key.VK_2;   ---Then it will continue cast 2nd spell that is 3 second long, and follow by 2nd instant spell
pinstantspell1 = key.VK_4;
pinstantspell2 = key.VK_5;
holyaura_HP = 80;  --percent to use holy aura
key_holyaura = key.VK_NUMPAD0;
HP_regeneration = 95;  ---HP when wants to use regeneration spell
key_regen = key.VK_6;   ---regeneration skill

end

--warrior
if (class == CLASS_WARRIOR or sclass == CLASS_WARRIOR) then  

frenzy_HP = 35;  ---when HP go down to 35%, frenzy will be used.
enraged_key = key.VK_2;  ---enrage skill for class warrior
key_frenzy = key.VK_8;  ---frenzy skill for warrior
sneakattack_key = key.VK_NUMPAD2;

end

-- mage
if (class == CLASS_MAGE or sclass == CLASS_MAGE) then  

castspell1 = key.VK_2;   ---the mage will cast a spell that take 3 second to load, and follow by instant spell. 
castspell2 = key.VK_2;   ---Then it will continue cast 2nd spell that is 3 second long, and follow by 2nd instant spell
instantspell1 = key.VK_4;
instantspell2 = key.VK_5;

end

-- rogue
if (class == CLASS_ROGUE or sclass == CLASS_ROGUE) then  

key_blindstab = key.VK_NUMPAD5;
key_shadowfoce = key.VK_5;

end

sit_key = key.VK_X;      ----Sit/Resting key (default is X)

---switch weapon after few hrs
switchinput = false; ---true/false, true if u want to switch weapons and armors after 100 kills, why? cuz durability.
                             --- see screenshot to see how to set up items for switch. file named switch.jpg
                             --- uhhh, sorry no SS for now, so leave it to false

--*******************************************************************************************
--------------------------------------------------------------------------
--Don't edit anything below unless u know what u doing
---------------------------------------------------------------------------

CLASS_KNIGHT = 0;
CLASS_WARRIOR = 1;
CLASS_CLERIC = 2;
CLASS_MAGE = 3;
CLASS_ARCHER = 4;
proc = 0;
win = 0;
success = true;
HP_addr = 0x014ED760;
HP_offset = 796;
maxHP_addr = 0x014ED760;
maxHP_offset = 804;
maxHP = 10000;
MANA_addr = 0x014ED760;
MANA_offset = 808;
maxMANA_addr = 0x014ED760;
maxMANA_offset = 812;
maxHP = 10000;
maxMANA = 10000;
HP = 10000; -- default, this corrects itself (don't change it!)
MANA = 10000;-- default, this corrects itself (don't change it!)
cx1 = 773;
sx = cx1;
cy = 394;
sy = 560;
btx1 = 761;  --backpack tab1 x-coord
bty1 = 352;  --backpack tab1 y-coord
cii=6;
magespell = 1;
instantspell = 1;
priestspell = 1;
instantspell =1;
monstercount = 0;
monstercount2 = 0;
monsterkilled = 0;
regen_duration = 18;
count=o;
deathcount = 0;
kcount = 0;
rotatecount=0;
buff1_needed = true;
buff2_needed = true;
buff3_needed = true;
regen_needed = true;
-------------------------------------------------

function update_vars()
  HP,success = memoryReadIntPtr(proc, HP_addr,HP_offset);
  maxHP = memoryReadIntPtr(proc, maxHP_addr,maxHP_offset);
        if (class ~= CLASS_WARRIOR) then
   	MANA = memoryReadIntPtr(proc, MANA_addr, MANA_offset );
  	maxMANA = memoryReadIntPtr(proc, maxMANA_addr, maxMANA_offset);
       end
end



function fight()

------------ fight as a knight
          if (class == CLASS_KNIGHT ) then
   --print("HP ", HP);
   --print("maxHP ", maxHP);
   --print("MANA ", MANA);
   --print("maxMANA ", maxMANA);
    	     if(  (HP / maxHP * 100) < HP_regeneration ) then regeneration_heal(); end
    	     if(  (HP / maxHP * 100) < HP_emergency ) then emergency_heal(); end
                  if( (MANA / maxMANA * 100) < MANA_emergency ) then emergency_mana(); end
	  keyboardHold(key_attack);
 	 yrest(150);
	  keyboardRelease(key_attack);
	    if( math.random(100) > 90 ) then
   	       yrest(150);
	        keyboardHold(key_skill3);
	        yrest(100);
	        keyboardRelease(key_skill3);
   	       yrest(150);
                  end
	   if( math.random(100) > 90 ) then
    	   if( math.random(100) >= 50 ) then
   	       yrest(100);
   	       keyboardHold(key_skill2);
   	       yrest(100);
	        keyboardRelease(key_skill2);
   	       yrest(150);
	     else
   	       yrest(100);
	        keyboardHold(key_skill4);
	        yrest(100);
	        keyboardRelease(key_skill4);
   	       yrest(150);
	    end
	    end
	     ----holyshield code
	         if(  (HP / maxHP * 100) < holyshield_HP ) then
                            yrest(200);
                            keyboardPress(key_holyshield); 
                            yrest(200);
                        end
                 ---holy aura code (give 5 second of invul
	         if(  ((HP / maxHP * 100)) < holyaura_HP ) then 
                            yrest(200);
		keyboardPress(key_holyaura); 
                            yrest(200);
	         end

	   ----resolution skill code (this give you big burst of HP when it get low, so u wont die)
                      

	         if(  (HP / maxHP * 100) < resolution_HP ) then
	         if(  MANA  < 100 ) then emergency_mana(); end                            
		yrest(150);
		 keyboardPress(key_resolution); 
		yrest(250);
	        end		
	    ---mana absorption code
		keyboardPress(key_absorp);

	end  --end for if class is knight 


------------------ fight as a warrior
    if (class == CLASS_WARRIOR) then
	   if(  (HP / maxHP * 100) < HP_emergency ) then emergency_heal(); end
                      keyboardPress(enraged_key);
	        yrest(100);
                      keyboardPress(sneakattack_key);
	        yrest(150);
                      keyboardPress(key_attack);
	        yrest(75);
                      keyboardPress(key_blindstab);
	        yrest(150);
                     keyboardPress(key_shadowfoce);
	        yrest(150);
	  if( math.random(100) > 65 ) then
	        yrest(100);
                      keyboardPress(key_skill3);
	        yrest(1100);
                      keyboardPress(key_skill4);
	        yrest(150);
	  else
	        yrest(100);
                      keyboardPress(key_skill6);
	        yrest(150);
	  end
   	  ----Frezy skill code
    	     if(  (HP / maxHP * 100) < frenzy_HP ) then keyboardPress(key_frenzy); end
    end  --end for the if class is warrior 

----------- fight as a mage
    if (class == CLASS_MAGE) then

	   if(  (HP / maxHP * 100) < HP_emergency ) then emergency_heal(); end
                 if(  (MANA / maxMANA * 100) < MANA_emergency ) then emergency_mana(); end

                  if ( magespell == 1) then
	        yrest(100);
                           for mi=1,7 do
                      	    keyboardPress(castspell1);
	        	    yrest(500); 
                           end
                      keyboardPress(instantspell1);
	        yrest(1000);
                      magespell = 2;
                  else
                      yrest(100);
                           for mi=1,7 do
                                keyboardPress(castspell2);
	        	    yrest(500); 
                           end
	        yrest(3500); 
                      keyboardPress(instantspell2);
	        yrest(1000);
                      magespell = 1;
                  end  --- end of the if function magespell
    	     if(  (HP / maxHP * 100) < HP_regeneration ) then regeneration_heal(); end
     	    rotatecount=0;  
    end  --end for the if class is mage


---------- fight as a Priest
    if (class == CLASS_PRIEST) then

	   if(  (HP / maxHP * 100) < HP_emergency ) then emergency_heal(); end
                 if(  (MANA / maxMANA * 100) < MANA_emergency ) then emergency_mana(); end
                      keyboardPress(key.VK_S);
                  if ( priestspell == 1) then
	        yrest(100);
                           for mi=1,7 do
                                 keyboardPress(priestspell1);
	        	    yrest(500); 
                           end
                      keyboardPress(pinstantspell1);
	        yrest(1000);
                      priestspell = 2;
                  else
                      yrest(100);
                           for mi=1,7 do
                                 keyboardPress(priestspell2);
	        	    yrest(500); 
                           end 
                      keyboardPress(pinstantspell2);
	        yrest(1000);
                      priestspell = 1;
                  end
	     ----soul source spell code
	         if(  (HP / maxHP * 100) < soulsource_HP ) then
                            keyboardPress(key_soulsource); 
                            yrest(200);
                        end
                 ---holy aura code (give 5 second of invul
	         if(  ((HP / maxHP * 100)) < holyaura_HP ) then 
                            yrest(200);
		keyboardPress(key_holyaura); 
                            yrest(200);
	         end
    	     if(  (HP / maxHP * 100) < HP_regeneration ) then regeneration_heal(); end

     	    rotatecount=0;  
    end  --end for the if class is mage



      ---- if killing take too long, then move onto the next target

            if (class == CLASS_PRIEST) then
                ki = 10;
            else
               ki = 250;
            end

        if ( kcount >= ki) then 
              keyboardPress(key.VK_ESCAPE); 
             rotate_cam();
             kcount = 0;
        end
                 if( HP == 0 or HP == nil ) then 
                        death();
                  end

end  ---end for the fight fuction

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

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


function regen_timer()
  regen_needed = true;
end


function pickup()
  keyboardHold(key_attack);
  yrest(200);
  keyboardRelease(key_attack);
         if (class == CLASS_MAGE) then
               key_skill3 =  instantspell1;
          end
   	       yrest(100);
	        keyboardHold(key_skill3);
	        yrest(50);
	        keyboardRelease(key_skill3);
   	       yrest(150);
end


function target_monster()
  keyboardHold(key.VK_TAB);
  yrest(50);
  keyboardRelease(key.VK_TAB);
end


function have_target()
  r,g,b = getPixel(hdc, 415, 50); 
 -- print("Color R,G,B: ", r, g, b);
  -- check for the red HP bar in the monster's HP window
    if( r ==156 and g == 1 and b == 0 ) then
       return true;
    else
         return false;
    end
end  ---end for have_target function


function player()
  r2,g2,b2 = getPixel(hdc, 430, 30); 
--  print("Color R,G,B: ", r, g, b);
    if( r2 ==0 and g2 == 120 and b2 == 0  ) then  
       return true;
    else
         return false;
    end
end --- end for the player function

function targetbox()
  rt,gt,bt = getPixel(hdc, 540, 30); 
   --print("Color Rt,Gt,Bt: ", rt, gt, bt);
    if( rt ==227 and gt == 221 and bt == 212  ) then  
       return true;
    else
         return false;
    end

end  --end for targetbox function

function rotate_cam()
  keyboardHold(key.VK_D);
  yrest(650);
  keyboardRelease(key.VK_D);
    if ( rotatecount>=15 ) then
              keyboardHold(key.VK_W);
              yrest(1000);
              keyboardRelease(key.VK_W);
              rotatecount=0;
    end
end


function emergency_heal()
	  keyboardHold(key_hppotion);
  	  yrest(100);
	  keyboardRelease(key_hppotion);
end
function emergency_mana()
	  keyboardHold(key_sppotion);
  	  yrest(100);
	  keyboardRelease(key_sppotion);
end

function regeneration_heal()

        if( regen_needed ) then
          yrest(800);
          keyboardHold(key_regen);
          yrest(200);
          keyboardRelease(key_regen);
          yrest(300);
            print("Regen used, 20 sec reloading");
          regen_needed  = false;
        end

end

-- rest untill healed
function sit()
  printf( os.date("Resting... %X\n") );
  yrest(500);
  keyboardHold(sit_key);
  yrest(200);
  keyboardRelease(sit_key);
  local last_hp = HP;
  yrest(1000);

  while( true ) do
    -- sit there looking stupid.
    if( class == CLASS_WARRIOR and HP == maxHP ) then break;
    elseif (class ~= CLASS_WARRIOR and HP == maxHP and MANA == maxMANA) then break; end;
    -- exiting rest disabled for now.
    if( HP < last_hp ) then 
            printf("Exiting! Under attack."); 
 	   yrest(2500);
	  keyboardHold(key.VK_E);
 	   yrest(100);
	  keyboardRelease(key.VK_E);
 	   yrest(100);
	  keyboardHold(key.VK_S);
 	   yrest(1500);
	  keyboardRelease(key.VK_S);
            break; 
    end; -- exit rest if under attack
          if ( have_target() ) then
            break; 
          end
          while ( have_target() ) do
               fight();
          end
  	  if ( targetbox() ) then
   	         keyboardHold(key.VK_ESCAPE);
    	        yrest(200);
    	         keyboardRelease(key.VK_ESCAPE);
    	        yrest(200);
	   end
    last_hp = HP;
    yrest(100);
  end

  printf( os.date("Exiting rest. %X\n") );
  keyboardPress(sit_key);
end


function death()
 deathcount = deathcount + 1;
  keyboardPress(key.VK_SNAPSHOT);
  print("A screen capture has been taken. Open MS Paint and paste it.");
  wx,wy = windowRect(win);
detach(); --deatch temporarily
                 yrest(5000);
	  print("dHP ", HP);
	  print("dmaxHP ", maxHP);
	 printf("You're Dead, reviving and keep on botting\n"); 
	 yrest(5000);  --wait 10 secs for the revive box pop up
                                ---this mouse click will fix the targeting system bug
	                    mouseSet(60, 60);
 	      	      yrest(200);
		      mouseLClick();
                      	      yrest(1000);
  	                        while ( player()) do
			 yrest(3000);
    			 keyboardHold(key.VK_ESCAPE);
     			 yrest(100);
     			 keyboardRelease(key.VK_ESCAPE);
			 yrest(1000);
	                      end

                --- click on the resurrect box
                        mouseSet(500, 190);
 	          yrest(200);
	          mouseLClick();
	          yrest(20000);  --wait 20 secs for the comp to load 
   	  	   if ( targetbox()) then
                                ---this mouse click will fix the targeting system bug
	                    mouseSet(60, 60);
 	      	      yrest(200);
		      mouseLClick();
                      	      yrest(1000);
  	                        while ( player()) do
			 yrest(3000);
    			 keyboardHold(key.VK_ESCAPE);
     			 yrest(100);
     			 keyboardRelease(key.VK_ESCAPE);
			 yrest(1000);
	                      end
     	  	  end
	          yrest(45000);  --wait 45 secs for the rev weakness to be gone

     if (deathcount >=4 ) then
           exitgame();
     end

attach(win); --re-attach.
end  --end of the function

function exitgame()
detach(); --deatch temporarily
                                yrest(3000);
	                    mouseSet(60, 60);
 	      	      yrest(1000);
		      mouseLClick();
                                 yrest(1000);

  	                while ( player()) do
			 yrest(2000);
    			 keyboardHold(key.VK_ESCAPE);
     			 yrest(100);
     			 keyboardRelease(key.VK_ESCAPE);
			 yrest(500);
	              end


     yrest(1000);
     keyboardHold(key.VK_ESCAPE);
     yrest(200);
     keyboardRelease(key.VK_ESCAPE);
     yrest(1000);
     mouseSet(510, 420);
     yrest(500);
     mouseLClick();
     yrest(1000);
     mouseSet(445, 175);
     yrest(500);
     mouseLClick();
     yrest(1000);
	  print("bot is off");
     running = 0; -- this turns the macro off!

attach(win); --re-attach.
end



function buff()

        if( buff1_needed and have_buff1) then
          yrest(500);
          keyboardHold(key_buff1);
          yrest(100);
          keyboardRelease(key_buff1);
          buff1_needed = false;
          yrest(500);
        end

        if( buff2_needed and have_buff2) then
          yrest(500);
          keyboardHold(key_buff2);
          yrest(150);
          keyboardRelease(key_buff2);
          buff2_needed = false;
          yrest(500);
        end

        if( buff3_needed and have_buff3) then
          yrest(500);
          keyboardHold(key_buff3);
          yrest(150);
          keyboardRelease(key_buff3);
          buff3_needed = false;
          yrest(500);
        end

end --end of function

function change()

     for ci = 1,cii do
                      yrest(300);
                      mouseSet(cx, cy);
 	        yrest(150);
	        mouseRClick();
	       yrest(200);
                      cx = cx + 42;
      end  ---end of the for function
      cx = cx1;
end


function changearmor()
detach(); --deatch temporarily
            yrest(100);
            keyboardHold(key.VK_B);
            yrest(100);
             keyboardRelease(key.VK_B);
             change();
             mouseSet(btx1 + 37, bty1);
             cii = 1;
             mouseLHold();
             yrest(250);
             mouseLRelease();
            change();
             cii = 6;
            keyboardHold(key.VK_B);
            yrest(100);
             keyboardRelease(key.VK_B);
attach(win); --re-attach.
end

function changeweapon()
detach(); --deatch temporarily
            yrest(100);
            keyboardHold(key.VK_B);
            yrest(100);
             keyboardRelease(key.VK_B);
                      yrest(300);
                      mouseSet(sx, sy);
 	        yrest(150);
	        mouseRClick();
	        yrest(200);
            keyboardHold(key.VK_B);
            yrest(100);
             keyboardRelease(key.VK_B);
            yrest(100);
attach(win); --re-attach.
end

function main()
  win = findWindow("Runes of Magic");
  hdc = openDC(win);
  proc = openProcess( findProcessByExe("Client.exe") );
  attach(win);
  registerTimer("update_vars", 100, update_vars);
    registerTimer("buff1_timer", 60000*buff1_duration, buff1_timer);
    registerTimer("buff2_timer", 60000*buff2_duration, buff2_timer);
    registerTimer("buff3_timer", 60000*buff3_duration, buff3_timer);
    registerTimer("regen_timer", 1000*regen_duration, regen_timer);
while( 1 ) do

   --print("HP ", HP);
   --print("maxHP ", maxHP);
   --print("MANA ", MANA);
   --print("maxMANA ", maxMANA);

             if( HP == 0  or HP == nil) then death(); end
	yrest(100);
             if ( have_target() == false ) then
        		target_monster();
		yrest(100);
            end
            yrest(200);
            if ( have_target() ) then
                      magespell = 1;
                      priestspell = 1;
                     monstercount = monstercount + 1;
                     monstercount2 = monstercount2 + 1;
                     monsterkilled = monsterkilled + 1;
                      print(" Monster Killed:\n ",  monsterkilled);
                      print(" Total Death: \n",  deathcount);
                       while ( have_target() ) do
		fight(); 
                            kcount = kcount +1;
		yrest(100);
  	                if ( player()) then
			 yrest(100);
    			 keyboardHold(key.VK_ESCAPE);
     			 yrest(100);
     			 keyboardRelease(key.VK_ESCAPE);
			 yrest(200);
	              end
                       end
                          kcount = 0;
                          for i = 0,3 do
		pickup();
	              keyboardHold(key_skill3);
	              yrest(100);
	              keyboardRelease(key_skill3);
		yrest(400);
	           end
  	           if ( targetbox() or player()) then
			 yrest(100);
    			 keyboardHold(key.VK_ESCAPE);
     			 yrest(100);
     			 keyboardRelease(key.VK_ESCAPE);
			 yrest(200);
	          end
                     yrest(200);
               ---- following code to get the character oriented correctly
	      keyboardPress(key.VK_S);
 	      yrest(50);
	      keyboardPress(key.VK_D);
 	      yrest(50);
                    rotatecount=0;
         else
     	   rotate_cam();
       	   rotatecount=rotatecount+1;
      	   rest(300);

        end   ---end for if have_target loop
	               buff();
  	                if ( player()) then
			 yrest(1000);
    			 keyboardHold(key.VK_ESCAPE);
     			 yrest(150);
     			 keyboardRelease(key.VK_ESCAPE);
			 yrest(1000);
	              end
 	     	    yrest(200);
         	                  if( (HP / maxHP * 100)< HP_sit and (HP / maxHP * 100) > HP_emergency) then sit(); end
                                if(  class ~= CLASS_WARRIOR and (MANA / maxMANA * 100) < MANA_sit and (MANA / maxMANA * 100) > MANA_emergency ) then sit(); 

end
       	                  if(  (HP / maxHP * 100) < HP_emergency ) then emergency_heal(); end
      	                  if( class ~= CLASS_WARRIOR and (MANA / maxMANA * 100) < MANA_emergency ) then emergency_mana(); end
       if (switchinput == true ) then
          if (monstercount >= 150 and monstercount <= 160) then  
             cx = cx1;
             changearmor();  ---because current weapon durability is zero
             monstercount = 0;
             cy = cy + 42;
          end
          if (monstercount2 >= 125 and monstercount2 <= 130) then 
             changeweapon();  ---because current weapon durability is zero
             monstercount2 = 0;
             sx = sx + 42;
          end
        end ---end for the switchinput
end  ---end for while loop

  detach();
  closeProcess(proc);
  closeDC(hdc);
end

startMacro(main);

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

Re: [Help] Runes Of Magic

#20 Post by Administrator » Thu Jan 01, 2009 4:32 pm

The player stores a pointer to it's target. The target has the exact same struct as the player. So if you've found the player's HP offset, your target's HP offset will be the same.

As these are pointers and not GUIDs, you cannot create a list of static monsters to cycle between. It will lead to a crash whenever you write the target address of a target that doesn't exist (which will happen 99% of the time because of dynamic memory).

That being said, you can find the array of nearby monsters (which I started doing, but abandoned for a different solution) and read the addresses out of this. It could still, on rare occasions, crash when a monster disappears after the array is read and before you write to the player's target address.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests