Sie sind auf Seite 1von 6

var MobX, MobY, i, j, R, RMin: integer; tmpStr, tmpstrmob, _7C, _OAOO, _0C, _00ODOA, curr, codid, buildstr: string;

Move, _Move, _SFWI2, _SFWI3, _StartZone: string; Mycorp, MyXstr, MyYstr, xgostr, ygostr, SpeedStr, company, MobXStr, MobYStr, RSt r: string; LStr, xcurr, ycurr, xgo, ygo, dx, dy, myx, myy, Speed:integer; SpisokMob, SpisokIgr: TStringList; Fi: Extended; steag,dumpin: boolean; function OnTimer(var ntimer, count: integer): boolean; begin if ntimer=1 then begin gSys.SetTimer(1, 0); if SpisokMob.count>0 then begin Rstr := SpisokMob.ValueFromIndex(0); LStr := Length(RStr); MobXStr := copy(RSTR, 1, pos(' ', RStr)-1); MobX := StrToInt(MobXStr); MobYStr := copy(RSTR, pos(' ', RStr)+1, LStr); MobY := StrToInt(MobYStr); dx := MobX-myx; dy := MobY-myY; Rmin := trunc(SQRT(dx*dx+dy*dy)); j := 0; for i:=0 to SpisokMob.count-1 do begin Rstr := SpisokMob.ValueFromIndex(i); LStr := Length(RStr); MobXStr := copy(RSTR, 1, pos(' ', RStr)-1); MobX := StrToInt(MobXStr); MobYStr := copy(RSTR, pos(' ', RStr)+1, LStr); MobY := StrToInt(MobYStr); dx := MobX-myx; dy := MobY-myY; R := trunc(SQRT(dx*dx+dy*dy)); if R<Rmin then begin j := i; RMin := R; end; end; gSys.SendS(HStr('53454C7C')+SpisokMob.Names[j]+_OAOO); end else gSys.SendC('0 A STD ..MOB.not.found..'+HStr('000D0A')); end; if ntimer=2 then begin gSys.SetTimer(2, 0); if SpisokIgr.count>0 then begin Rstr := SpisokIgr.ValueFromIndex(0); LStr := Length(RStr); MobXStr := copy(RSTR, 1, pos(' ', RStr)-1);

MobX := StrToInt(MobXStr); MobYStr := copy(RSTR, pos(' ', RStr)+1, LStr); MobY := StrToInt(MobYStr); dx := MobX-myx; dy := MobY-myY; Rmin := trunc(SQRT(dx*dx+dy*dy)); j := 0; for i:=0 to SpisokIgr.count-1 do begin Rstr := SpisokIgr.ValueFromIndex(i); LStr := Length(RStr); MobXStr := copy(RSTR, 1, pos(' ', RStr)-1); MobX := StrToInt(MobXStr); MobYStr := copy(RSTR, pos(' ', RStr)+1, LStr); MobY := StrToInt(MobYStr); dx := MobX-myx; dy := MobY-myY; R := trunc(SQRT(dx*dx+dy*dy)); if R<Rmin then begin j := i; RMin := R; end; end; gSys.SendS(HStr('53454C7C')+SpisokIgr.Names[j]+_OAOO); end else gSys.SendC('0 A STD ..Player.(enemy).not.found..'+HStr('000D0A')); end; if ntimer=3 then begin xcurr := strToInt(MyXstr); ycurr := strToInt(MyYstr); xgo := strToInt(xgostr); ygo := strToInt(ygostr); dx := xgo-xcurr; dy := ygo-ycurr; if (dx=0)and(dy>0) then Fi := 90.0; if (dx=0)and(dy<0) then Fi := -90.0; if dx>0 then Fi := 180*ArcTan(dy/dx)/3.1415926; if dx<0 then Fi := 180*ArcTan(dy/dx)/3.1415926-180; if Fi<180 then Fi := Fi+360; if Fi>180 then Fi := Fi-360; dy := Trunc(0.5*Speed*Sin(Fi*3.1415926/180.0)); dx := Trunc(0.5*Speed*Cos(Fi*3.1415926/180.0)); MyXstr := IntToStr(xcurr+dx); MyYstr := IntToStr(ycurr+dy); myx := xcurr+dx; myy := ycurr+dy; gSys.SetTimer(3, 500); end; end; procedure OnCreate;

begin _OAOO := HSTR('0A00'); _7C := HSTR('7C'); _00ODOA := HStr('000D0A'); Move := HSTR('307C317C'); _Move := HSTR('317C'); _SFWI2 := HStr('537C4657587C320A00'); _SFWI3 := HStr('537C4657587C330A00'); _StartZone := HSTR('307C497C'); _0C := HStr('307C437C'); SpisokMob := TStringList.Create; SpisokIgr := TStringList.Create; end; procedure OnDestroy; begin SpisokMob.Free; SpisokIgr.Free; end; begin if (not _gFromServ)and(_gBuff=_SFWI2) then begin gSys.SetTimer(1, 150+Round(200*Random)); gSys.SendC('0 A STD ..Loking..MOB..'+HStr('000D0A')); gBlockPacket; end; if (not _gFromServ)and(_gBuff=_SFWI3) then begin gSys.SetTimer(2, 150+Round(200*Random)); gSys.SendC('0 A STD ..Loking..Player..'+HStr('000D0A')); gBlockPacket; end; if (_gFromServ)and(Pos(Move, _gBuff)=1) then begin LStr := length(_gBuff); tmpstr := Copy(_gBuff, Pos(Move, _gBuff)+4, LStr); tmpstrmob := Copy(tmpstr, 1, Pos(_7C, tmpstr)-1); end; tmpstr := _gBuff; if (_gFromServ)and(pos(_StartZone, tmpstr)>0) then begin LStr := Length(tmpstr); tmpstr := copy(tmpstr, pos(_StartZone, tmpstr), LStr); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); MyXstr := copy(tmpstr, 1, pos(' ', tmpstr)-1); xgostr := MyXstr; tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); MyYstr := copy(tmpstr, 1, pos(' ', tmpstr)-1);

ygostr := MyYstr; tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LSTR); Mycorp := copy(tmpstr, 1, pos(' ', tmpstr)); end; if (_gFromServ)and(Pos('0 A v ', _gBuff)>0) then begin LStr := length(_gBuff); tmpstr := _gBuff; tmpstr := copy(_gBuff, pos('0 A v ', tmpstr)+4, LStr); tmpstr := copy(tmpstr, pos(' ', tmpstr)+1, LStr); SpeedStr := copy(tmpstr, 1, pos(HStr('000D0A'), tmpstr)-1); Speed := StrToInt(SpeedStr); end; if (not _gFromServ)and(Pos(_Move, _gBuff)=1) then begin LStr := length(_gBuff); tmpstr := Copy(_gBuff, Pos(_Move, _gBuff), LStr-2); tmpstr := Copy(tmpstr, Pos(_7C, tmpstr)+1, LStr); xgostr := Copy(tmpstr, 1, Pos(_7C, tmpstr)-1); tmpstr := Copy(tmpstr, Pos(_7C, tmpstr)+1, LStr); ygostr := Copy(tmpstr, 1, Pos(_7C, tmpstr)-1); tmpstr := Copy(tmpstr, Pos(_7C, tmpstr)+1, LStr); MyXstr := Copy(tmpstr, 1, Pos(_7C, tmpstr)-1); MyYstr := Copy(tmpstr, Pos(_7C, tmpstr)+1, LStr); myx := StrToInt(MyXstr); myy := StrToInt(MyYstr); end; if (_gFromServ)and(Pos(_0C, _gBuff)>0) then begin tmpstr := _gBuff; steag := false; repeat if Pos(_00ODOA, tmpstr)<0 then steag:= true; LStr := Length(tmpstr); if LStr=0 then steag:= true; if (not steag) then begin curr := copy(tmpstr, 1, pos(_00ODOA, tmpstr)+2); if (Pos(_0C, curr)=1) then begin curr := Copy(curr, Pos(_7C, curr)+1, LStr); curr := Copy(curr, Pos(_7C, curr)+1, LStr); CodId := Copy(curr, 1, Pos(_7C, curr)-1); curr := Copy(curr, Pos(_7C, curr)+1, LStr); curr := Copy(curr, Pos(_7C, curr)+1, LStr); curr := Copy(curr, Pos(_7C, curr)+1, LStr); curr := Copy(curr, Pos(_7C, curr)+1, LStr); curr := Copy(curr, Pos(_7C, curr)+1, LStr); MobXStr := Copy(curr, 1, Pos(_7C, curr)-1); curr := Copy(curr, Pos(_7C, curr)+1, LStr); MobYStr := Copy(curr, 1, Pos(_7C, curr)-1); curr := Copy(curr, Pos(_7C, curr)+1, LStr); company := copy(curr, 1, 2); if company='0 ' then begin BuildStr := CodId+'='+MobXStr+' '+MobYStr; SpisokMob.add(BuildStr);

end else if company<>Mycorp then begin BuildStr := CodId+'='+MobXStr+' '+MobYStr; SpisokIgr.add(BuildStr); end; end; end; tmpstr := copy(tmpstr, pos(_00ODOA, tmpstr)+3, LStr); until steag; end; if (_gFromServ)and(Pos(Move, _gBuff)>0) then begin tmpstr := _gBuff; steag := false; repeat if Pos(_00ODOA, tmpstr)<0 then steag := true; LStr := Length(tmpstr); if LStr=0 then steag := true; if (not steag) then begin curr := copy(tmpstr, 1, pos(_00ODOA, tmpstr)+2); if (Pos(Move, curr)=1) then begin curr := Copy(curr, Pos(_7C, curr)+1, LStr); curr := Copy(curr, Pos(_7C, curr)+1, LStr); CodId := Copy(curr, 1, Pos(_7C, curr)-1); curr := Copy(curr, Pos(_7C, curr)+1, LStr); MobXStr := Copy(curr, 1, Pos(_7C, curr)-1); curr := Copy(curr, Pos(_7C, curr)+1, LStr); MobYStr := Copy(curr, 1, Pos(_7C, curr)-1); j := SpisokMob.IndexOfName(CodId); if j<>-1 then begin BuildStr := CodId+'='+MobXStr+' '+MobYStr; SpisokMob.delete(j); SpisokMob.add(BuildStr); end; j := SpisokIgr.IndexOfName(CodId); if j<>-1 then begin BuildStr := CodId+'='+MobXStr+' '+MobYStr; SpisokIgr.delete(j); SpisokIgr.add(BuildStr); end; end; end; tmpstr := copy(tmpstr, pos(_00ODOA, tmpstr)+3, LStr); until steag; end; if (_gFromServ)and(Pos('0 R ', _gBuff)>0) then begin tmpstr := _gBuff; steag := false; repeat if Pos(_00ODOA, tmpstr)<0 then steag := true;

LStr := Length(tmpstr); if LStr=0 then steag := true; if (not steag) then begin curr := copy(tmpstr, 1, pos(_00ODOA, tmpstr)+2); if (Pos('0 R ', curr)=1) then begin curr := Copy(curr, Pos(_7C, curr)+1, LStr); curr := Copy(curr, Pos(_7C, curr)+1, LStr); CodId := Copy(curr, 1, Pos(_00ODOA, curr)-1); j := SpisokMob.IndexOfName(CodId); if j<>-1 then begin SpisokMob.delete(j); end; j := SpisokIgr.IndexOfName(CodId); if j<>-1 then begin SpisokIgr.delete(j); end; end; end; tmpstr := copy(tmpstr, pos(_00ODOA, tmpstr)+3, LStr); until steag; end; end.

Das könnte Ihnen auch gefallen