Hi !
Here's my 2nd game macro ...
Today it's Perfect World a nice MMORPG!
I didn't even realize Gigus made a really perfect bot for this game but I post mine anyway, maybe someone will use the new memory adresses to update Gigus' bot
Code:
// fullscreen mode | resolution : 1280x800
// attack action on 1
// 1st skill on 2
// 2nd skill on 3
// MP potions on 7
// HP potions on 8
// looting action on 9
begin
Window.Bring to front("Perfect World", "No")
Window.Set location("Perfect World", "No", "0", "0")
Color.Flush screen dump cache()
// just reminders for the memory base pointers for HP and MP
Memory.Get value("elementclient", "elementclient.exe+729184,34,4D0", "4", "totalHP")
Memory.Get value("elementclient", "elementclient.exe+729184,34,490", "4", "currentHP")
Memory.Get value("elementclient", "elementclient.exe+729184,34,4D4", "4", "totalMP")
Memory.Get value("elementclient", "elementclient.exe+729184,34,494", "4", "currentMP")
Function.Execute("quit")
// stopwatch for skill 1
Macro.Start stopwatch("SWskill1")
// stopwatch for skill 2
Macro.Start stopwatch("SWskill2")
// stopwatch for fight timeout (eg: if the mob is behind a wall or can't be reached, the macro changes the target after a certain amount of time)
Macro.Start stopwatch("FTO")
begin loop()
// main : aim,kill,loot (and heal while killing mobs and after looting)
Color.Flush screen dump cache()
Function.Execute("Aim")
Function.Execute("Hit")
Function.Execute("Loot")
Function.Execute("Heal")
Function.Execute("quit")
end
end
function("Heal")
begin
// HP potions on 8
Memory.Get value("elementclient", "elementclient.exe+729184,34,4D0", "4", "totalHP")
Memory.Get value("elementclient", "elementclient.exe+729184,34,490", "4", "currentHP")
Variable.Evaluate (Math)("{currentHP}/{totalHP}", "ratioHP")
if Variable.Is less than (Math)("ratioHP", "0,5")
begin
Keyboard.Press key("8")
Macro.Pause("300")
end
Memory.Get value("elementclient", "elementclient.exe+729184,34,4D4", "4", "totalMP")
Memory.Get value("elementclient", "elementclient.exe+729184,34,494", "4", "currentMP")
Variable.Evaluate (Math)("{currentMP}/{totalMP}", "ratioMP")
if Variable.Is less than (Math)("ratioMP", "0,5")
begin
Keyboard.Press key("7")
Macro.Pause("300")
end
end
function
function("Aim")
begin
Color.Flush screen dump cache()
while Color.At coordinate is not within (RGB range)("0", "255", "25", "5", "568", "27")
begin
Keyboard.Press key("1")
Keyboard.Press key("{<TAB>}")
Macro.Pause("400")
Color.Flush screen dump cache()
Function.Execute("Heal")
Function.Execute("quit")
end
end
function
function("Loot")
begin
if Color.At coordinate is not within (RGB range)("0", "255", "25", "5", "568", "27")
begin
Macro.Pause("500")
begin loop("10")
Keyboard.Press key("9")
Macro.Pause("450")
end
end
end
function
function("Hit")
begin
// this stopwatch avoid
Macro.Reset stopwatch("FTO")
while Color.At coordinate is within (RGB range)("0", "255", "25", "5", "568", "27")
begin
Macro.Read stopwatch("FTO", "Vfight")
if Variable.Is greater than (Math)("Vfight", "40000")
begin
Macro.Reset stopwatch("FTO")
// dunno why, If I don't read the stopwatch here, TAB key is pressed infinitely ...
Macro.Read stopwatch("FTO", "Vfight")
Keyboard.Press key("{<TAB>}")
Macro.Pause("500")
end
Function.Execute("Aim")
Keyboard.Press key("1")
Macro.Pause("200")
Function.Execute("Heal")
Function.Execute("skill1")
Function.Execute("skill2")
Function.Execute("quit")
end
end
function
function("skill1")
begin
Macro.Read stopwatch("SWskill1", "Vskill1")
if Variable.Is greater than (Math)("Vskill1", "8050")
begin
// maddly press "2" key :)
Keyboard.Press key("2")
Macro.Pause("200")
Keyboard.Press key("2")
Macro.Pause("200")
Keyboard.Press key("2")
Macro.Pause("200")
Macro.Reset stopwatch("SWskill1")
Macro.Read stopwatch("SWskill1", "Vskill1")
Function.Execute("Heal")
Keyboard.Press key("1")
Macro.Pause("300")
end
end
function
function("skill2")
begin
Macro.Read stopwatch("SWskill2", "Vskill2")
if Variable.Is greater than (Math)("Vskill2", "3050")
begin
// maddly press "3" key :)
Keyboard.Press key("3")
Macro.Pause("200")
Keyboard.Press key("3")
Macro.Pause("200")
Keyboard.Press key("3")
Macro.Pause("200")
Macro.Reset stopwatch("SWskill2")
Macro.Read stopwatch("SWskill2", "Vskill2")
Function.Execute("Heal")
Keyboard.Press key("1")
Macro.Pause("300")
end
end
function
function("quit")
begin
if Keyboard.Keys has been pressed within (ms)("Q", "10000")
begin
Macro.Break from loop("no")
end
end
function
Later I plan to search the memory pointer adress for the "targeted monster" and send directly keys to the game so the bot will be able to run even with minimized game !