?? clfunc.pas
字號:
begin
for i:=0 to 20-1 do begin
if (DealRemoteItems[i].S.Name = ci.S.Name) and (DealRemoteItems[i].MakeIndex = ci.MakeIndex) then begin
FillChar (DealRemoteItems[i], sizeof(TClientItem), #0);
break;
end;
end;
end;
{----------------------------------------------------------}
//計算兩點間的距離(X或Y方向)
function GetDistance (sx, sy, dx, dy: integer): integer;
begin
Result := _MAX(abs(sx-dx), abs(sy-dy));
end;
//根據方向和當前位置確定下一個位置坐標(位移量=1)
procedure GetNextPosXY (dir: byte; var x, y:Integer);
begin
case dir of
DR_UP: begin x := x; y := y-1; end;
DR_UPRIGHT: begin x := x+1; y := y-1; end;
DR_RIGHT: begin x := x+1; y := y; end;
DR_DOWNRIGHT: begin x := x+1; y := y+1; end;
DR_DOWN: begin x := x; y := y+1; end;
DR_DOWNLEFT: begin x := x-1; y := y+1; end;
DR_LEFT: begin x := x-1; y := y; end;
DR_UPLEFT: begin x := x-1; y := y-1; end;
end;
end;
//根據方向和當前位置確定下一個位置坐標(位移量=2)
procedure GetNextRunXY (dir: byte; var x, y:Integer);
begin
case dir of
DR_UP: begin x := x; y := y-2; end;
DR_UPRIGHT: begin x := x+2; y := y-2; end;
DR_RIGHT: begin x := x+2; y := y; end;
DR_DOWNRIGHT: begin x := x+2; y := y+2; end;
DR_DOWN: begin x := x; y := y+2; end;
DR_DOWNLEFT: begin x := x-2; y := y+2; end;
DR_LEFT: begin x := x-2; y := y; end;
DR_UPLEFT: begin x := x-2; y := y-2; end;
end;
end;
//根據兩點計算移動的方向
function GetNextDirection (sx, sy, dx, dy: Integer): byte;
var
flagx, flagy: integer;
begin
Result := DR_DOWN;
if sx < dx then flagx := 1
else if sx = dx then flagx := 0
else flagx := -1;
if abs(sy-dy) > 2
then if (sx >= dx-1) and (sx <= dx+1) then flagx := 0;
if sy < dy then flagy := 1
else if sy = dy then flagy := 0
else flagy := -1;
if abs(sx-dx) > 2 then if (sy > dy-1) and (sy <= dy+1) then flagy := 0;
if (flagx = 0) and (flagy = -1) then Result := DR_UP;
if (flagx = 1) and (flagy = -1) then Result := DR_UPRIGHT;
if (flagx = 1) and (flagy = 0) then Result := DR_RIGHT;
if (flagx = 1) and (flagy = 1) then Result := DR_DOWNRIGHT;
if (flagx = 0) and (flagy = 1) then Result := DR_DOWN;
if (flagx = -1) and (flagy = 1) then Result := DR_DOWNLEFT;
if (flagx = -1) and (flagy = 0) then Result := DR_LEFT;
if (flagx = -1) and (flagy = -1) then Result := DR_UPLEFT;
end;
//根據當前方向獲得轉身后的方向
function GetBack (dir: integer): integer;
begin
Result := DR_UP;
case dir of
DR_UP: Result := DR_DOWN;
DR_DOWN: Result := DR_UP;
DR_LEFT: Result := DR_RIGHT;
DR_RIGHT: Result := DR_LEFT;
DR_UPLEFT: Result := DR_DOWNRIGHT;
DR_UPRIGHT: Result := DR_DOWNLEFT;
DR_DOWNLEFT: Result := DR_UPRIGHT;
DR_DOWNRIGHT: Result := DR_UPLEFT;
end;
end;
//根據當前坐標和方向獲得后退的坐標
procedure GetBackPosition (sx, sy, dir: integer; var newx, newy: integer);
begin
newx := sx;
newy := sy;
case dir of
DR_UP: newy := newy+1;
DR_DOWN: newy := newy-1;
DR_LEFT: newx := newx+1;
DR_RIGHT: newx := newx-1;
DR_UPLEFT:
begin
newx := newx + 1;
newy := newy + 1;
end;
DR_UPRIGHT:
begin
newx := newx - 1;
newy := newy + 1;
end;
DR_DOWNLEFT:
begin
newx := newx + 1;
newy := newy - 1;
end;
DR_DOWNRIGHT:
begin
newx := newx - 1;
newy := newy - 1;
end;
end;
end;
//根據當前位置和方向獲得前進一步的坐標
procedure GetFrontPosition (sx, sy, dir: integer; var newx, newy: integer);
begin
newx := sx;
newy := sy;
case dir of
DR_UP: newy := newy-1;
DR_DOWN: newy := newy+1;
DR_LEFT: newx := newx-1;
DR_RIGHT: newx := newx+1;
DR_UPLEFT:
begin
newx := newx - 1;
newy := newy - 1;
end;
DR_UPRIGHT:
begin
newx := newx + 1;
newy := newy - 1;
end;
DR_DOWNLEFT:
begin
newx := newx - 1;
newy := newy + 1;
end;
DR_DOWNRIGHT:
begin
newx := newx + 1;
newy := newy + 1;
end;
end;
end;
//根據兩點位置獲得飛行方向(8個方向)
function GetFlyDirection (sx, sy, ttx, tty: integer): Integer;
var
fx, fy: Real;
begin
fx := ttx - sx;
fy := tty - sy;
sx := 0;
sy := 0;
Result := DR_DOWN;
if fx=0 then begin //兩點的X坐標相等
if fy < 0 then Result := DR_UP
else Result := DR_DOWN;
exit;
end;
if fy=0 then begin //兩點的Y坐標相等
if fx < 0 then Result := DR_LEFT
else Result := DR_RIGHT;
exit;
end;
if (fx > 0) and (fy < 0) then begin
if -fy > fx*2.5 then Result := DR_UP
else if -fy < fx/3 then Result := DR_RIGHT
else Result := DR_UPRIGHT;
end;
if (fx > 0) and (fy > 0) then begin
if fy < fx/3 then Result := DR_RIGHT
else if fy > fx*2.5 then Result := DR_DOWN
else Result := DR_DOWNRIGHT;
end;
if (fx < 0) and (fy > 0) then begin
if fy < -fx/3 then Result := DR_LEFT
else if fy > -fx*2.5 then Result := DR_DOWN
else Result := DR_DOWNLEFT;
end;
if (fx < 0) and (fy < 0) then begin
if -fy > -fx*2.5 then Result := DR_UP
else if -fy < -fx/3 then Result := DR_LEFT
else Result := DR_UPLEFT;
end;
end;
//根據兩點位置獲得飛行方向(16個方向)
function GetFlyDirection16 (sx, sy, ttx, tty: integer): Integer;
var
fx, fy: Real;
begin
fx := ttx - sx;
fy := tty - sy;
sx := 0;
sy := 0;
Result := 0;
if fx=0 then begin
if fy < 0 then Result := 0
else Result := 8;
exit;
end;
if fy=0 then begin
if fx < 0 then Result := 12
else Result := 4;
exit;
end;
if (fx > 0) and (fy < 0) then begin
Result := 4;
if -fy > fx/4 then Result := 3;
if -fy > fx/1.9 then Result := 2;
if -fy > fx*1.4 then Result := 1;
if -fy > fx*4 then Result := 0;
end;
if (fx > 0) and (fy > 0) then begin
Result := 4;
if fy > fx/4 then Result := 5;
if fy > fx/1.9 then Result := 6;
if fy > fx*1.4 then Result := 7;
if fy > fx*4 then Result := 8;
end;
if (fx < 0) and (fy > 0) then begin
Result := 12;
if fy > -fx/4 then Result := 11;
if fy > -fx/1.9 then Result := 10;
if fy > -fx*1.4 then Result := 9;
if fy > -fx*4 then Result := 8;
end;
if (fx < 0) and (fy < 0) then begin
Result := 12;
if -fy > -fx/4 then Result := 13;
if -fy > -fx/1.9 then Result := 14;
if -fy > -fx*1.4 then Result := 15;
if -fy > -fx*4 then Result := 0;
end;
end;
//按逆時針轉動一個方向后的方向
function PrivDir (ndir: integer): integer;
begin
if ndir - 1 < 0 then Result := 7
else Result := ndir-1;
end;
//按順時針轉動一個方向后的方向
function NextDir (ndir: integer): integer;
begin
if ndir + 1 > 7 then Result := 0
else Result := ndir+1;
end;
//著重顯示文字(以bcolor色加文字邊框),效果如鏤空
procedure BoldTextOut (surface: TDirectDrawSurface; x, y, fcolor, bcolor: integer; str: string);
begin
with surface do begin
Canvas.Font.Name:='宋體';
Canvas.Font.Charset:=GB2312_CHARSET;
Canvas.Font.Color := bcolor;
Canvas.TextOut (x-1, y, str);
Canvas.TextOut (x+1, y, str);
Canvas.TextOut (x, y-1, str);
Canvas.TextOut (x, y+1, str);
Canvas.Font.Color := fcolor;
Canvas.TextOut (x, y, str);
end;
end;
function GetTakeOnPosition (smode: integer): integer;
begin
Result := -1;
case smode of //StdMode
5, 6:
Result := U_WEAPON; //武器
10, 11:
Result := U_DRESS; //衣服
15,16:
Result := U_HELMET; //頭盔
19,20,21:
Result := U_NECKLACE; //項鏈
22,23:
Result := U_RINGL; //左戒指
24,26:
Result := U_ARMRINGR; //右手戒指
25:
Result := U_ARMRINGL; //右手戒指
30:
Result := U_RIGHTHAND; //右手
end;
end;
//判斷某個鍵是否按下
function IsKeyPressed (key: byte): Boolean;
var
keyvalue: TKeyBoardState;
begin
Result := FALSE;
FillChar(keyvalue, sizeof(TKeyboardState), #0);
if GetKeyboardState (keyvalue) then
if (keyvalue[key] and $80) <> 0 then
Result := TRUE;
end;
procedure AddChangeFace (recogid: integer);
begin
ChangeFaceReadyList.Add (pointer(recogid));
end;
procedure DelChangeFace (recogid: integer);
var
i: integer;
begin
for i:=0 to ChangeFaceReadyList.Count-1 do begin
if integer(ChangeFaceReadyList[i]) = recogid then begin
ChangeFaceReadyList.Delete (i);
break;
end;
end;
end;
function IsChangingFace (recogid: integer): Boolean;
var
i: integer;
begin
Result := FALSE;
for i:=0 to ChangeFaceReadyList.Count-1 do begin
if integer(ChangeFaceReadyList[i]) = recogid then begin
Result := TRUE;
break;
end;
end;
end;
Initialization
DropItems := TList.Create;
Finalization
DropItems.Free;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -