CynicRus
2012-08-03 14:47:50
Assistant in the battles for Blood and Soul game. Written as an example to use my plugin:spongebob:
program BSAutoHealer;
{$loadlib rwmem.dll}
{$i SRL\SRL.simba}
Type TBSChar = record
DynHp,Hp,DynMp,Mp,CurrExp: integer;
end;
const
BaseCharAddr = $00AA2F38;//in that address located dinamicaly addres to Character struct(i think);
BaseStatAddr = $00AA7A80;
var
BSChar: TBSChar;
BSPid: integer;
X,Y: integer;
OldExp,GainedExp,GainedLvl,KillsCounter,RestoredHp,RestoredMP: integer;
HealPot,ManaPot: integer;
NKFlag: integer; //No Kill flag
function GetDynHP(pid: integer): integer;
var
i: integer;
begin
//read dynamicaly character address
i:=ReadFromMemoryFromPID(pid,BaseCharAddr,4);
//read hp value and return this
result:=ReadFromMemoryFromPID(pid,i+(9*4)+$188,4);
end;
function GetHP(pid: integer): integer;
var
i: integer;
begin
//read dynamicaly character address
i:=ReadFromMemoryFromPID(pid,BaseCharAddr,4);
//read hp value and return this
result:=ReadFromMemoryFromPID(pid,i+(8*4)+$188,4);
end;
function GetDynMP(pid: integer): integer;
var
i: integer;
begin
//read dynamicaly character address
i:=ReadFromMemoryFromPID(pid,BaseCharAddr,4);
//read mp value and return this
result:=ReadFromMemoryFromPID(pid,i+($b*4)+$188,4);
end;
function GetMP(pid: integer): integer;
var
i: integer;
begin
//read dynamicaly character address
i:=ReadFromMemoryFromPID(pid,BaseCharAddr,4);
//read mp value and return this
result:=ReadFromMemoryFromPID(pid,i+($a*4)+$188,4);
end;
function GetCurrExp(pid: integer): integer;
var
i: integer;
begin
//read dynamicaly character address
i:=ReadFromMemoryFromPID(pid,BaseCharAddr,4);
//read exp value and return this
result:=ReadFromMemoryFromPID(pid,i+$598,4);
end;
Procedure UpdateStats;
var
xp: integer;
begin
OldExp:=BSChar.CurrExp;
BSChar.DynHp:=GetDynHp(BSPid);
BSChar.DynMp:=GetDynMp(BSPid);
BSChar.Hp:=GetHp(BSPid);
BSChar.Mp:=GetMp(BSPid);
BSChar.CurrExp:=GetCurrExp(BSPid);
if OldExp<BSChar.CurrExp then
KillsCounter:=KillsCounter+1;//Kill mob counter
if OldExp = BSChar.CurrExp then
begin
if NKFlag = 0 then NKFlag:=1 else NKFlag:=NKFlag+1;
end;
if not NKFlag>0 then
begin
if BSChar.CurrExp>0 then
xp:=BSChar.CurrExp-OldExp
else begin
xp:=0;
GainedLvl:=GainedLvl+1;
end;
GainedExp:=GainedExp+xp;
end;
end;
Procedure SetupBS;
begin
BSPid:=GetProcessIdByName('Client.exe');
if BSPid <> 0 then
begin
//Fill unchanged fields
BSChar.Hp:=GetHp(BSPid);
BSChar.Mp:=GetMp(BSPid);
//Fill dynamicaly fields
BSChar.DynHp:=GetDynHp(BSPid);
BSChar.DynMp:=GetDynMp(BSPid);
BSChar.CurrExp:=GetCurrExp(BSPid);
//fill dtms
HealPot:= DTMFromString('mfgEAAHicE2JgYPjCxMDwFYg/QTGI/R2IPwPxOyB+DcRvgfgjVO4nEP9BUvMeSs9jZmBYCMSLgHgpFK8G4rVAvB6KNwPxFijeBMQbgXgnEO+C0nuBeHm+HBhzWjsyfL/TwPD5ajHD1RRPhv0G8gxTZgYynJ4qx3B9vQvDxaVWDE9PpDDEsjIztPZ5M2yt5mVIB7oDREcAaWoBRiphTAAAKmg1cg==');
ManaPot:= DTMFromString('mVAEAAHicE2BgYFBkZmBQhmJVIJZHwtLMEHk1INYEYi0gloOKSwKxEhDPBeLFQLwciNcA8RIk9log3gzE24B4OxBvgNJbgXgTEO8E4r8vpzIINE9m4LR2ZGCtPsrw/8cqBt7EHDCbMbyXgTF2BsOVde4MjMZBDIyGAQyMXhUMjAqmDPf3hDEwajgyUAoYKcToAAAwNh+8');
end else
begin
WriteLn('Blood and Soul client not finded!');
TerminateScript;
end;
end;
Procedure Heal;
var
DiffHp,Hp: integer;
begin
Hp:=BSChar.DynHp;
DiffHp:=BSChar.Hp-BSChar.DynHp;
if FindDTM(HealPot, X, Y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 4, 4, False);//FindDTM gives (x, y) as the coordinates of the DTM we made it look for.
Wait(1000);
UpdateStats();
if Hp>=BSChar.DynHp then begin
WriteLn('Something wrong-(')
TerminateScript;
end
else
begin
restoredHp:=restoredHp+DiffHp;
end;
end;
end;
Procedure Mana;
var
DiffMp,Mp: integer;
begin
Mp:=BSChar.DynMp;
DiffMp:=BSChar.Mp-BSChar.DynMp;
if FindDTM(ManaPot, X, Y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 4, 4, False);//FindDTM gives (x, y) as the coordinates of the DTM we made it look for.
Wait(1000);
UpdateStats();
if Mp>=BSChar.DynMp then begin
WriteLn('Something wrong-(')
TerminateScript;
end
else
begin
restoredMp:=restoredMp+DiffMp;
end;
end;
end;
Procedure CheckStats;
begin
UpdateStats;
if BSChar.DynHp<BSChar.Hp then
NKFlag:=0;
if BSChar.DynMp<BSChar.Mp then
NKFlag:=0;
if BSChar.DynHp<(BSChar.Hp/2) then
Heal;
if BSChar.DynMp<(BSChar.Mp/2) then
Mana;
end;
Procedure PrintVars;
begin
WriteLn('My Hits:'+#32+toStr(BSChar.DynHp)+'/'+toStr(BSChar.Hp));
WriteLn('My Mana:'+#32+toStr(BSChar.DynMp)+'/'+toStr(BSChar.Mp));
WriteLn('I gained:'+toStr(GainedExp)+#32+'exp');
WriteLn('I kill'+toStr(KillsCounter)+#32 + 'mobs');
WriteLn('I healed'+toStr(restoredHp));
WriteLn('I restore'+toStr(restoredMp)+#32+'mana');
WriteLn('I gained:'+toStr(GainedLvl)+#32+'lvls');
end;
begin
SetupBS;
repeat
CheckStats;
PrintVars;
until false;
end.