Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit c;
- interface
- const
- FinalCharSet= ['a'..'z']+['A'..'Z']+['а'..'я']+['А'..'Я']+['0'..'9']+['-'..'-'];
- MonLength = $36c0;
- CharSelected= $00604530;
- MaxZoom = $0060B758;//$00604698;
- MinZoom = $005EB83C;//$005e483c;
- Address_Exp = $011093D0; //Столько опыта на лвл
- Over_Exp_Tek = $34FEC; //Текущий опыт игрока
- TStrOff = $90; //offset to structure of target
- //difference is always $74.
- MStrOff = $104;
- CellOff1 = $000023d8-4;
- CellOff2 = $000003B8-4;
- CellOff3 = $000001A4;
- BAutoAttackOff = $14E12C;
- AAutoAttackOff = $4FC50; // $4FBC8;
- AutoRunOff = $4FC58; //Автобег
- BNameOff = $34F4C; // offset to character name from basedata
- BHPOff = $34F74;
- BMHPOff = $34F70;
- BMPOff = $34F7C;
- BMMPOff = $34F78;
- CameraOff = $412F8;
- BDurOff = $350E2;
- ActOff = $1A9;
- LActOff = $1AA;
- NameOff = $16B0; // offset to name in structure of monsters
- HPOff = $414; // hp }
- MHPOff = $418; // max hp }
- XOff = $14C;
- YOff = $150;
- ZOff = $154;
- DistOff = $404;
- PvpSOff = $3F7;
- pvpfOff = $40D;
- LegOff = $1CCD;
- LvlOff = $1B4;
- LvlOffChar = $34FF0;
- KeyOff = $49C;
- MailOff = $328E0E1;
- // Button_R = $52;
- // Button_W = 38;
- //Shift-state related.
- Const
- Shift = 16;
- Ctrl = 17;
- Alt = 18;
- implementation
- uses windows, functions2, math, VarConstType;
- //Неиспользуемый код.
- /// ///////////////////////////
- //
- // Adaptation from II
- //
- // Block of routines begins here
- //
- /// ///////////////////////////////
- /// //////////////////////////////////////////////////////////////
- /// /// His infernal majesty, Procedure UpdateTarget
- /// ///
- /// /// Note: Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn
- /// //////////////////////////////////////////////////////////////
- Procedure UpdateTarget(Address: dword;Var Target: pAnyCharacter); overload;
- var
- BytesRead: dword;
- Const
- OffsetName = NameOff;
- OffsetLevel = LvlOff;
- OffsetPvpSign = PvpSOff;
- OffsetPvpFlag = pvpFOff;
- OffsetTarHp = HPOff;
- OffsetAction = ActOff;
- OffsetCoord = XOff;
- OffsetDist = DistOff;
- begin
- (*
- //Some exception handling;
- if Address=0 then begin
- ClearEntry(Target);
- Exit;
- end;
- *)
- Target.name := GetString(Aika.ProcHandle, Address + OffsetName, 16);
- ReadProcessMemory(Aika.ProcHandle, ptr(Address + 4), @Target.uid, 4,
- BytesRead);
- ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetLevel), @Target.lvl, 2,
- BytesRead);
- // Read pvp flags
- ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetPvpSign),
- @Target.pvpsign, 1, BytesRead);
- ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetPvpFlag),
- @Target.pvpflag, 1, BytesRead);
- // Read HP,MaxHp,Mp,MaxMp
- ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetTarHp), @Target.hp,
- 4 * 4, BytesRead);
- // read both actions
- ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetAction), @Target.act,
- 2, BytesRead);
- // read all coordinates;
- ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetCoord), @Target.x,
- 4 * 3, BytesRead);
- ReadProcessMemory(Aika.ProcHandle, ptr(Address + OffsetDist), @Target.Dist, 4,
- BytesRead);
- (*
- if byte(Target.PvpSign)=1 then Target.PvpSign:=true else Target.PvpSign:=false;
- if byte(Target.PvpFlag)=1 then Target.Pvpflag:=true else Target.Pvpflag:=false;
- *)
- end;
- Function Valid(Monster: pAnyCharacter;
- CheckAttackState: boolean = false): boolean;
- begin
- Result := true;
- if (Monster.uid = $FFFFFFFF) Or (Monster.uid = 0) OR
- (Monster.hp > Monster.maxhp) OR (Monster.maxmp <> 0) OR (IsNan(Monster.x))
- OR (IsNan(Monster.y)) OR (IsNan(Monster.z)) OR (Monster.x = 0) OR
- (Monster.y = 0) Then
- Result := false;
- // We are there? Hence result=true and CheckAttackState=True either
- // Note that CheckAttackState is optional parameter, in most cases - false;
- if Result And CheckAttackState then
- // Do not try this at home
- Result := (Monster.act in [5 .. 7]) or (Monster.act in [21 .. 22]) Or
- (Monster.lastact in [5 .. 7]) or (Monster.lastact in [21 .. 22]);
- end;
- { ///////////////////////////////////////////////////////////
- GetNearestDirect Proc:
- Perform search of nearest to character mob;
- Note: if custom parameter not specified, he sets to false
- Algorithm:
- 1)Create example of tMonster
- 2) In cycle //For OhNo:=1 to 256
- Read New monster
- Check whether monster valid
- If yes then inc MobArray(Vincitore) count, add Mob to array
- 3)Find mob with least distance, In Cycle (for Ohno := 0 to Vincitore - 1)
- 4)Set this mob as char current target
- 5)Destroy example of tMonster;
- ////////////////////////////////////////////////////////// }
- Procedure GetNearestDirect(SearchAggr: boolean = false);
- var
- OhNo: word;
- vincitore: word;
- MobArr: array of tAnyCharacter;
- BytesRead: dword;
- //
- StartAddress: dword;
- Nea: pAnyCharacter;
- Const
- OffsetChar = $DC;
- OffsetTarget = $68;
- MonsterSize = MonLength;
- begin
- Nea := New(pAnyCharacter);
- // Get start address;
- ReadProcessMemory(Aika.ProcHandle, ptr(Aika.ActionPtr + OffsetChar),
- @StartAddress, 4, BytesRead);
- vincitore := 0;
- // Cycle that infiltrates valid mobs into MobArr;
- for OhNo := 1 to 256 do
- begin
- UpdateTarget(StartAddress + OhNo * MonsterSize, Nea);
- if Valid(Nea, SearchAggr) then
- begin
- Nea.id := OhNo;
- inc(vincitore);
- SetLength(MobArr, vincitore);
- MobArr[vincitore - 1] := Nea^;
- end;
- end; // for end;
- // some exception handling;
- if vincitore = 0 then
- begin
- Dispose(Nea);
- exit;
- end;
- // get last element
- Nea^ := MobArr[vincitore - 1];
- // get nearest mob
- for OhNo := 0 to vincitore - 1 do
- if Nea.Dist > MobArr[OhNo].Dist then
- Nea^ := MobArr[OhNo];
- SetLength(MobArr, 0);
- // compute address of nearest mob.
- StartAddress := StartAddress + Nea.id * MonsterSize;
- WriteProcessMemory(Aika.ProcHandle, ptr(Aika.ActionPtr + OffsetTarget),
- @StartAddress, 4, BytesRead);
- Dispose(@Nea^);
- end;
- end.
- Const
- BasePtr = $025B1D00; //Основной указатель
- ActionPtr = BasePtr-$4; //Указатель действий персонажа
- PanelPtr = BasePtr+$EC0; //Указатель на панели
Add Comment
Please, Sign In to add comment