Scripting Problem

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Post Reply
Message
Author
gwencilicious
Posts: 9
Joined: Sat Mar 31, 2012 12:12 am

Scripting Problem

#1 Post by gwencilicious » Sat Mar 31, 2012 12:20 am

hi. i made a script for a game called Eden Eternal the script was executed successfully but i wonder why it terminates right after i start it. when i check the log files it says that the execution was successful. i cant see or determine the problem of the script. here is the script that im using. it is not yet full but i just want to check whether or not my idea is correct or wrong.

ps. thank you runner01 for the mems

setStartKey(key.VK_DELETE);
setStopKey(key.VK_END);

--ADDRESSES+OFFSETS
memptrs ={
destX = {address = 0xDEFF30; offset = 0};
destY = {address = 0xDEFF34; offset = 0};
charX = {address = 0xD18D98; offset = 0};
charY = {address = 0xD18D94; offset = 0};
curHP = {address = 0xDEFF10; offset = 0};
maxHP = {address = 0xDEFF14; offset = 0};
curMP = {address = 0xDEFF18; offset = 0};
maxMP = {address = 0xDEFF1C; offset = 0};
mapID = {address = 0xD1766C; offset = 0x6};
camZoom = {address = 0xD17868; offset = 0x7C};
camX = {address = 0xD17868; offset = 0x2C};
camY = {address = 0xD17868; offset = 0x30};
camZ = {address = 0xD17868; offset = 0x34};
};

--CODECAVES
function prepareCC()
-- HP/MP
memWriteInt(0x00DEFE0F, -1996203893);
memWriteInt(0x00DEFE13, -553709539);
memWriteInt(0x00DEFE17, 1280871168);
memWriteInt(0x00DEFE1B, -15458935);
memWriteInt(0x00DEFE1F, 1485504734);
memWriteInt(0x00DEFE23, 404588808);
memWriteInt(0x00DEFE27, -1962877185);
memWriteInt(0x00DEFE2B, 495538264);
memWriteInt(0x00DEFE2F, 14614300);
memWriteInt(0x00DEFE33, 292995);
memWriteInt(0x00DEFE37, -1072525553);
memWriteInt(0x00DEFE3B, -739639407);
memWriteInt(0x00DEFE3F, 16748991);
memWriteInt(0x0070BE0F, 1849687017);
memWriteInt(0x0070BE13, -1098674176);
-- Des X
memWriteInt(0x00DEFE52, -13623925);
memWriteInt(0x00DEFE56, -880082722);
memWriteInt(0x00DEFE5A, 14454409);
memWriteInt(0x00DEFE5E, 736690176);
memWriteInt(0x00DEFE62, 16742964);
-- Des Y
memWriteInt(0x00DEFE74, 873827072);
memWriteInt(0x00DEFE78, -1996431617);
memWriteInt(0x00DEFE7C, 1451955286);
memWriteInt(0x00DEFE80, -385848812);
memWriteInt(0x00DEFE84, -8624627);
-- redirect, always at the end
memWriteInt(0x0059328A, -2050243607);
memWriteInt(0x0059328E, 1284149248);
memWriteInt(0x005B6490, -2087067415);
end


function update_vars()
HP = memoryReadIntPtr(_Launcher, 0xDEFF10, 0);
MaxHP = memoryReadIntPtr(_Launcher, 0xDEFF14, 0);
end

function use_hp_potion()
keyboardPress( key.VK_9)
end

--Variables
HP = 11566;
MaxHP = HP;
hp_potion_use = 80;

function main()
attach( findWindow("Eden Eternal") );
attach( foregroundWindow() );
win = findWindow("Eden Eternal");
proc = openProcess(findProcessByExe("_Launcher.exe"));
setPriority(PRIORITY_HIGH);
if( (HP/MaxHP*100) < hp_potion_use ) then use_hp_potion(); end
--detach();
end

startMacro(main);

gwencilicious
Posts: 9
Joined: Sat Mar 31, 2012 12:12 am

Re: Scripting Problem

#2 Post by gwencilicious » Sat Mar 31, 2012 12:23 am

here is the log file


Sat Mar 31 13:22:55 2012 : Processor Type: 2X AMD or Intel x64 @2938MHz, OS: Windows 7
Sat Mar 31 13:22:55 2012 : User privilege level: Administrator
Sat Mar 31 13:22:55 2012 : Lua glues exported
Sat Mar 31 13:22:55 2012 : MicroMacro v1.02 beta 1
Sat Mar 31 13:22:55 2012 : LuaCoco is available
Sat Mar 31 13:22:55 2012 : Keyboard layout: US English
Sat Mar 31 13:22:58 2012 : Executing script 'test.lua'
-------------------------------------------------------------------------------


Sat Mar 31 13:23:03 2012 : Execution success

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Scripting Problem

#3 Post by botje » Sat Mar 31, 2012 5:08 am

simple, it doesnt have a loop, so it executes just 1 time :P

use

Code: Select all

while true
     --your code
end
botje

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Scripting Problem

#4 Post by runner01 » Sat Mar 31, 2012 9:02 am

gwencilicious wrote: function main()
attach( findWindow("Eden Eternal") );
attach( foregroundWindow() );
win = findWindow("Eden Eternal");
proc = openProcess(findProcessByExe("_Launcher.exe"));
setPriority(PRIORITY_HIGH);
prepareCC(); -- This starts your Code Caves. Otherwise the HP/MP will not read correctly
while (1) do
if( (HP/MaxHP*100) < hp_potion_use ) then use_hp_potion();
end
--detach();
end

startMacro(main);
That will fix your looping problem.

Code: Select all

function update_vars()
HP = memoryReadInt(_Launcher, 0xDEFF10)-- You can take out the Ptr at the end, because there is no offset.
MaxHP = memoryReadInt(_Launcher, 0xDEFF14);
end	

gwencilicious
Posts: 9
Joined: Sat Mar 31, 2012 12:12 am

Re: Scripting Problem

#5 Post by gwencilicious » Sat Mar 31, 2012 2:20 pm

thanks guys! esp runner01 for helping me thru this new program :))

gwencilicious
Posts: 9
Joined: Sat Mar 31, 2012 12:12 am

Re: Scripting Problem

#6 Post by gwencilicious » Sat Mar 31, 2012 3:09 pm

its me again. @runner macro says it return a nil value in one of the mems so it terminates. i tried to re edit the script into something like this:

memWriteInt(_Launcher, 0x00DEFE0F, -1996203893);
memWriteInt(_Launcher, 0x00DEFE13, -553709539);
memWriteInt(_Launcher, 0x00DEFE17, 1280871168);

(just an example) still it says attempt to call global 'memWriteInt' (a nil value) i supposed one of the mems is wrong? i read nil = false

im assuming im having problems because im running in win7 64bit and the mems are for 32bit. just an assumption,

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

Re: Scripting Problem

#7 Post by Administrator » Sat Mar 31, 2012 7:45 pm

That error is telling you that memWriteInt is nil (does not exist). That function is not valid; you are looking for memoryWriteInt().

gwencilicious
Posts: 9
Joined: Sat Mar 31, 2012 12:12 am

Re: Scripting Problem

#8 Post by gwencilicious » Mon Apr 02, 2012 5:25 am

thanks! now i got it with no errors but uhmm, it looks like whenever i run micromacro in EE with no errors, my EE lags...

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Scripting Problem

#9 Post by runner01 » Mon Apr 02, 2012 11:01 am

tried taking this out?
I don't think you need high priority for potting

Code: Select all

setPriority(PRIORITY_HIGH);

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Scripting Problem

#10 Post by runner01 » Mon Apr 02, 2012 11:04 am

gwencilicious wrote:its me again. @runner macro says it return a nil value in one of the mems so it terminates. i tried to re edit the script into something like this:

memWriteInt(_Launcher, 0x00DEFE0F, -1996203893);
memWriteInt(_Launcher, 0x00DEFE13, -553709539);
memWriteInt(_Launcher, 0x00DEFE17, 1280871168);

(just an example) still it says attempt to call global 'memWriteInt' (a nil value) i supposed one of the mems is wrong? i read nil = false

im assuming im having problems because im running in win7 64bit and the mems are for 32bit. just an assumption,
You still have to define the 'memWriteInt' with a function... That is just a variable with no instruction.
http://www.solarstrike.net/wiki/index.p ... ryWriteInt

gwencilicious
Posts: 9
Joined: Sat Mar 31, 2012 12:12 am

Re: Scripting Problem

#11 Post by gwencilicious » Mon Apr 02, 2012 9:11 pm

finally.. i got my macro to do what i ask him to do :D

potting = complete

next would be moving. i have a very big dillema. after intensive reading, i have learned that MM dont accept "map coordinates", instead, they only accept mouse inputs or keyboard keys. thanks to runner01 i got my potting complete the next problem would be the moving :( whenever i click on EE it only points to one spot in the map so therefore it will go there whatever you do. even if for example i obtained disable mouse function, that wouldnt suffice the fact that MM doesnt accept map coords. am i right? and if so, what can you guys advice me to solve my problem thanks in advance im learning to use MM and thanks for the hand guys lets keep it up :)

gwencilicious
Posts: 9
Joined: Sat Mar 31, 2012 12:12 am

Re: Scripting Problem

#12 Post by gwencilicious » Mon Apr 02, 2012 9:12 pm

setStartKey(key.VK_DELETE);
setStopKey(key.VK_END);

--ADDRESSES+OFFSETS

memoryptrs ={
destX = {address = 0xDEFF30; offset = 0};
destY = {address = 0xDEFF34; offset = 0};
charX = {address = 0xD18D98; offset = 0};
charY = {address = 0xD18D94; offset = 0};
curHP = {address = 0xDEFF10; offset = 0};
MaxHP = {address = 0xDEFF14; offset = 0};
MP = {address = 0xDEFF18; offset = 0};
MaxMP = {address = 0xDEFF1C; offset = 0};
mapID = {address = 0xD1766C; offset = 0x6};
camZoom = {address = 0xD17868; offset = 0x7C};
camX = {address = 0xD17868; offset = 0x2C};
camY = {address = 0xD17868; offset = 0x30};
camZ = {address = 0xD17868; offset = 0x34};
};


--CODECAVES
function prepareCC()
-- HP/MP
memoryWriteInt(proc, 0x00DEFE0F, -1996203893);
memoryWriteInt(proc, 0x00DEFE13, -553709539);
memoryWriteInt(proc, 0x00DEFE17, 1280871168);
memoryWriteInt(proc, 0x00DEFE1B, -15458935);
memoryWriteInt(proc, 0x00DEFE1F, 1485504734);
memoryWriteInt(proc, 0x00DEFE23, 404588808);
memoryWriteInt(proc, 0x00DEFE27, -1962877185);
memoryWriteInt(proc, 0x00DEFE2B, 495538264);
memoryWriteInt(proc, 0x00DEFE2F, 14614300);
memoryWriteInt(proc, 0x00DEFE33, 292995);
memoryWriteInt(proc, 0x00DEFE37, -1072525553);
memoryWriteInt(proc, 0x00DEFE3B, -739639407);
memoryWriteInt(proc, 0x00DEFE3F, 16748991);
memoryWriteInt(proc, 0x0070BE0F, 1849687017);
memoryWriteInt(proc, 0x0070BE13, -1098674176);
-- Des X
memoryWriteInt(proc, 0x00DEFE52, -13623925);
memoryWriteInt(proc, 0x00DEFE56, -880082722);
memoryWriteInt(proc, 0x00DEFE5A, 14454409);
memoryWriteInt(proc, 0x00DEFE5E, 736690176);
memoryWriteInt(proc, 0x00DEFE62, 16742964);
-- Des Y
memoryWriteInt(proc, 0x00DEFE74, 873827072);
memoryWriteInt(proc, 0x00DEFE78, -1996431617);
memoryWriteInt(proc, 0x00DEFE7C, 1451955286);
memoryWriteInt(proc, 0x00DEFE80, -385848812);
memoryWriteInt(proc, 0x00DEFE84, -8624627);
-- redirect, always at the end
memoryWriteInt(proc, 0x0059328A, -2050243607);
memoryWriteInt(proc, 0x0059328E, 1284149248);
memoryWriteInt(proc, 0x005B6490, -2087067415);
end

function use_hp_potion()
keyboardPress( key.VK_9 );
yrest(50);
keyboardRelease( key.VK_9)
yrest(50);
end

--Variables
HP_potion_use = 9000;

function main()

win = findWindow("Eden Eternal");
proc = openProcess(findProcessByWindow(win));
keyboardSetDelay(1000)


prepareCC();

HP = memoryReadInt(proc, 0xDEFF10);
MaxHP = memoryReadInt(proc, 0xDEFF14);

while ( 1 ) do
HP = memoryReadInt(proc, 0xDEFF10);
MaxHP = memoryReadInt(proc, 0xDEFF14);

if( HP < HP_potion_use )
then use_hp_potion();
end

end

end

startMacro(main);


this is my working script. although i only integrated potting, it is because i got a problem on how to make my character move on a map coordinate using my script;

User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: Scripting Problem

#13 Post by botje » Tue Apr 03, 2012 1:57 am

well, its a hard part to do so.

i cant get my head around a waypoint system either >.<

gwencilicious
Posts: 9
Joined: Sat Mar 31, 2012 12:12 am

Re: Scripting Problem

#14 Post by gwencilicious » Tue Apr 03, 2012 5:53 am

@botje if only there's a command like moveTo even if you make a function out of that it is difficult to make characters move just like that especially in 3D environment where mouse input in your screen is not equal to map coordinates :(

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Scripting Problem

#15 Post by runner01 » Tue Apr 03, 2012 10:02 am

Well you still have to translate our "RunTo" From BEM to MM:

Code: Select all


Original RunTo by Vans in his delphi bot:

function("RunTo")
     begin
          // Set destination coordinates
          Memory.Set value("_Launcher", "{DestXAdd}", "float", "{XVal}")
          Memory.Set value("_Launcher", "{DestYAdd}", "float", "{YVal}")
          begin loop("-1")
               // Check if player died while running
               Function.Execute("VerifyDeath")
               if  Variable.Is equal to("Dead", "True")
                    begin
                         Function.Abort()
                    end
               // Check if map changed
               if  Memory.Value is not("_Launcher", "{CurrentMapAdd}", "2", "{CurrentMap}")
                    begin
                         Macro.Pause("3000")
                         Function.Abort()
                    end
               // Click on the map to move
               Mouse.Click at coordinate("{ClickX}", "{ClickY}", "left")
               Macro.Pause("{ClickTime}")
               // Attack if it has to
               if  Variable.Is equal to("Attack", "True")
                    begin
                         Function.Execute("Attack")
                    end
               // Calculate actual coordinates within a threshold
               Memory.Get value("_Launcher", "{CharXAdd}", "float", "CharX")
               Memory.Get value("_Launcher", "{CharYAdd}", "float", "CharY")
               Variable.Evaluate (Math)("{XVal}+{Threshold}", "MaxX")
               Variable.Evaluate (Math)("{XVal}-{Threshold}", "MinX")
               Variable.Evaluate (Math)("{YVal}+{Threshold}", "MaxY")
               Variable.Evaluate (Math)("{YVal}-{Threshold}", "MinY")
               // Check if arrived to destiny using a threshold
               if  Variable.Is between (Math)("CharX", "{MinX}", "{MaxX}")
                    and
                    Variable.Is between (Math)("CharY", "{MinY}", "{MaxY}")
                    begin
                         Macro.Break from loop("yes")
                    end
          end
     end
function
This:

Code: Select all

function("RunTo")
will translate to:

Code: Select all

function runTo()
But we need the variables Destination X and Y and rather if we should attack or not.
so we'll change it to:

Code: Select all

function runTo(destinationX, destinationY, commandAttack)
next is the setting the memory of your destination X, Y into memory so when you click, it will move to that destination:

Code: Select all

          
          Memory.Set value("_Launcher", "{DestXAdd}", "float", "{XVal}")
          Memory.Set value("_Launcher", "{DestYAdd}", "float", "{YVal}")
which will translate to this:

Code: Select all

memorySetFloat(proc, memoryptrs.destX, destinationX, "destination_X")
memorySetFloat(proc, memoryptrs.destY, destinationY, "destination_Y")
so your code will look something like this:

Code: Select all

-- Setting predefined VARIABLES: DO NOT MODIFY --
destinationX = 0;
destinationY = 0;
charX = 0;
charY = 0;

-- [our version of the runto's on B.E.M. ] --
function runTo(destinationX, destinationY, commandAttack)
	memorySetFloat(proc, memoryptrs.destX, destinationX, "destination_X")
	memorySetFloat(proc, memoryptrs.destY, destinationY, "destination_Y")
        --fill in the rest--
end
When you're done translating the B.E.M. code to MM, your runTo should look like this

Code: Select all

runTo(001, 002, true);
runTo(003, 004, false);

runner01
Posts: 11
Joined: Wed Mar 21, 2012 10:43 pm

Re: Scripting Problem

#16 Post by runner01 » Tue Apr 03, 2012 10:19 am

This is as far as I will guide you. Some of us would like to keep this "undetected" and I've already said too much. The rest is up to you to finish. Most of the scripts in BEM is public knowledge. You'll just have to translate it to MM. You'll have to re-write all the Functions:

RunTo
VerifyDeath
Prepare
Attack
Heal
CheckBag
Sell
SetCamera

After you're done, you'll have a fully functional MM bot for any of the dungeons for EE.
Cheers,
-Runner

gwencilicious
Posts: 9
Joined: Sat Mar 31, 2012 12:12 am

Re: Scripting Problem

#17 Post by gwencilicious » Tue Apr 03, 2012 2:04 pm

runner all i have to say is THANKS! :D this will be a long night for me although i dont have the skills you got i want to pull out something from your help thanks again! :) ill update you on my progress

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests