📄 charcls.pas
字号:
Rmsg.rx := ax;
RMsg.ry := ay;
RMsg.rfeature := aFeature;
Rmsg.rmotion := amotion;
AddMessage (RMsg);
exit;
end;
}
case amsg of
SM_STRUCTED :
begin
StructedTick := CurTick;
StructedPercent := amotion;
end;
SM_SAY :;
SM_CHANGEFEATURE:
begin
for i := 0 to CharImageBufferCount -1 do begin
if CharImageBuffer[i].aCharImage <> nil then CharImageBuffer[i].aCharImage.Free;
CharImageBuffer[i].aCharImage := nil;
CharImageBuffer[i].aImageNumber := -1;
end;
CharImageBuffer[0].aCharImage := TA2Image.Create (CharMaxSiez, CharMaxSiez, 0, 0);
CharImageBufferIndex := 0;
if Feature.raninumber <> afeature.raninumber then AniList := Animater.GetAnimationList(afeature.raninumber);
dir := adir; x := ax; y := ay;
if (Feature.rfeaturestate <> wfs_sitdown) and (aFeature.rFeatureState = wfs_sitdown) then begin
CurActionInfo := FindAnimation ( AM_SEATDOWN, dir);
SetCurrentFrame (CurActionInfo,0, CurTick);
CurAction := SM_MOTION;
end;
if (Feature.rfeaturestate = wfs_sitdown) and (aFeature.rFeatureState <> wfs_sitdown) then begin
CurActionInfo := FindAnimation ( AM_STANDUP, dir);
SetCurrentFrame (CurActionInfo,0, CurTick);
CurAction := SM_MOTION;
end;
if (Feature.rfeaturestate <> wfs_die) and (aFeature.rFeatureState = wfs_die) then begin
CurActionInfo := FindAnimation ( AM_DIE, dir);
SetCurrentFrame (CurActionInfo,0, CurTick);
CurAction := SM_MOTION;
end;
Feature := aFeature;
if Feature.rEffectNumber > 0 then begin
AddBgEffect (ax, ay, Feature.rEffectNumber-1, Feature.rEffectKind);
end;
end;
SM_SETPOSITION :
begin
dir := adir; x := ax; y := ay;
Feature := aFeature;
CurActionInfo := FindAnimation ( AM_TURN, dir);
SetCurrentFrame (CurActionInfo,0, CurTick);
CurAction := SM_TURN;
end;
SM_TURN :
begin
dir := adir; x := ax; y := ay;
Feature := aFeature;
CurActionInfo := FindAnimation ( AM_TURN, dir);
SetCurrentFrame (CurActionInfo,0, CurTick);
CurAction := SM_TURN;
end;
SM_MOTION :
begin
dir := adir; x := ax; y := ay;
CurActionInfo := FindAnimation ( amotion, dir);
SetCurrentFrame (CurActionInfo,0, CurTick);
CurAction := SM_MOTION;
end;
SM_MOVE :
begin
xx := ax; yy := ay;
GetNextPosition (adir, xx, yy);
x := xx;
y := yy;
dir := adir;
CurActionInfo := FindAnimation ( AM_MOVE, dir);
SetCurrentFrame (CurActionInfo, 0, CurTick);
CurAction := SM_MOVE;
end;
end;
end;
function TCharClass.FindAnimation ( aact, adir : Integer) : PTAniInfo;
var
i : Integer;
ainfo: PTAniInfo;
begin
Result := nil;
case Feature.rFeaturestate of
wfs_normal : if aact = AM_TURN then aact := AM_TURN;
wfs_care : if aact = AM_TURN then aact := AM_TURN1;
wfs_sitdown : if aact = AM_TURN then aact := AM_TURN2;
wfs_die : if aact = AM_TURN then aact := AM_TURN3;
wfs_running : if aact = AM_TURN then aact := AM_TURN4;
wfs_running2 : if aact = AM_TURN then aact := AM_TURN5;
end;
case Feature.rFeaturestate of
wfs_normal : if aact = AM_TURNNING then aact := AM_TURNNING;
wfs_care : if aact = AM_TURNNING then aact := AM_TURNNING1;
wfs_sitdown : if aact = AM_TURNNING then aact := AM_TURNNING2;
wfs_die : if aact = AM_TURNNING then aact := AM_TURNNING3;
wfs_running : if aact = AM_TURNNING then aact := AM_TURNNING4;
wfs_running2 : if aact = AM_TURNNING then aact := AM_TURNNING5;
end;
case Feature.rFeaturestate of
wfs_normal : if aact = AM_MOVE then aact := AM_MOVE;
wfs_care : if aact = AM_MOVE then aact := AM_MOVE1;
wfs_sitdown : if aact = AM_MOVE then aact := AM_MOVE2;
wfs_die : if aact = AM_MOVE then aact := AM_MOVE3;
wfs_running : if aact = AM_MOVE then aact := AM_MOVE4;
wfs_running2 : if aact = AM_MOVE then aact := AM_MOVE5;
end;
for i := 0 to AniList.Count -1 do begin
ainfo := AniList[i];
if (ainfo.Action = aact) and (ainfo.direction = adir) then begin
Result := ainfo;
break;
end;
end;
end;
procedure TCharClass.SetCurrentFrame (aAniInfo : PTAniInfo; aFrame, CurTime: integer);
begin
if aAniInfo = nil then begin Error := 10; exit; end;
FrameStartTime := CurTime;
Curframe := aFrame;
ImageNumber := aAniInfo^.Frames[CurFrame];
RealX := x*UNITX + aAniInfo^.Pxs[curframe]+UNITXS;
RealY := y*UNITY + aAniInfo^.Pys[curframe]-UNITYS;
end;
function TCharClass.AllowAddAction: Boolean;
begin
Result := FALSE;
if CurActionInfo = nil then begin Result := TRUE; exit; end;
if (CurAction = SM_TURN) then Result := TRUE;
if (CurActionInfo^.Frame-2 = curframe) then Result := TRUE;
if Feature.rfeaturestate = wfs_die then Result := FALSE;
if Feature.rfeaturestate = wfs_sitdown then Result := FALSE;
end;
procedure TCharClass.MakeFrame (aindex, CurTick: integer);
var
i, block, bidx : integer;
addx, addy : integer;
gc, ga : integer;
boflag : Boolean;
ImageLib : TA2ImageLib;
begin
if (Feature.rTeamColor > 0) and (Feature.rTeamColor < 32) then begin
addx := CHarMaxSiezHalf;
addy := CHarMaxSiezHalf - Feature.rTeamColor - Random (2);
end else begin
addx := CHarMaxSiezHalf;
addy := CHarMaxSiezHalf;
end;
if aindex = OldMakeFrame then exit;
OldMakeFrame := aindex;
block := aindex div 500;
bidx := aindex mod 500;
OverImage.Free;
OverImage := TA2Image.Create (CharMaxSiez, CharMaxSiez, 0, 0);
for i := 0 to CharImageBufferCount -1 do begin
if CharImageBuffer[i].aImageNumber = aindex then begin
if CharImageBuffer[i].aCharImage <> nil then begin
CharImageBufferIndex := i;
exit;
end;
end;
end;
CharImageBufferIndex := -1;
for i := 0 to CharImageBufferCount -1 do begin
if CharImageBuffer[i].aImageNumber = -1 then begin
if CharImageBuffer[i].aCharImage <> nil then begin
CharImageBufferIndex := i;
break;
end;
end;
end;
if CharImageBufferIndex = -1 then begin
CharImageBufferIndex := Random(CharImageBufferCount - 1);
if CharImageBufferIndex > CharImageBufferCount then CharImageBufferIndex := 0;
if CharImageBuffer[CharImageBufferIndex].aCharImage <> nil then begin
CharImageBuffer[CharImageBufferIndex].aCharImage.Free;
CharImageBuffer[CharImageBufferIndex].aCharImage := TA2Image.Create (CharMaxSiez, CharMaxSiez, 0, 0);
end else begin
CharImageBuffer[CharImageBufferIndex].aCharImage := TA2Image.Create (CharMaxSiez, CharMaxSiez, 0, 0);
end;
end else begin
if CharImageBuffer[CharImageBufferIndex].aCharImage <> nil then begin
CharImageBuffer[CharImageBufferIndex].aCharImage.Free;
CharImageBuffer[CharImageBufferIndex].aCharImage := TA2Image.Create (CharMaxSiez, CharMaxSiez, 0, 0);
end else begin
CharImageBuffer[CharImageBufferIndex].aCharImage := TA2Image.Create (CharMaxSiez, CharMaxSiez, 0, 0);
end;
end;
CharImageBuffer[CharImageBufferIndex].aImageNumber := aIndex;
if Feature.rrace = RACE_MONSTER then begin
with Feature do begin
ImageLib := FAtzClass.GetImageLib (format ('z%d.atz', [rImageNumber]), CurTick);
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then
CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImage (ImageLib.Images[bidx], ImageLib.Images[bidx].px+CHarMaxSiezHalf, ImageLib.Images[bidx].py+CHarMaxSiezHalf, FALSE);
ImageLib := FAtzClass.GetImageLib (format ('z%dm.atz', [rImageNumber]), CurTick);
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then begin
OverImage.DrawImage (ImageLib.Images[bidx], ImageLib.Images[bidx].px+CHarMaxSiezHalf, ImageLib.Images[bidx].py+CHarMaxSiezHalf, FALSE);
end;
end;
CharImageBuffer[CharImageBufferIndex].aCharImage.Optimize;
OverImage.Optimize;
exit;
end;
with Feature do begin
if not rboMan then ImageLib := FAtzClass.GetImageLib (format ('0%d%d.atz', [rArr[0],block]), CurTick)
else ImageLib := FAtzClass.GetImageLib (format ('1%d%d.atz', [rArr[0],block]), CurTick);
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImage (ImageLib.Images[bidx], ImageLib.Images[bidx].px+CHarMaxSiezHalf, ImageLib.Images[bidx].py+CHarMaxSiezHalf, FALSE);
for i := 0 to 5 do begin
if not Feature.rboMan then ImageLib := FAtzClass.GetImageLib (char(word('a')+i) + format ('%d%d.atz', [Feature.rArr[i*2],block]), CurTick)
else ImageLib := FAtzClass.GetImageLib (char(word('n')+i) + format ('%d%d.atz', [Feature.rArr[i*2],block]), CurTick);
if ImageLib = nil then continue;
if ImageLib.Count <= bidx then continue;
if Feature.rArr[i*2+1] = 0 then begin
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImage (ImageLib.Images[bidx], ImageLib.Images[bidx].px+addx, ImageLib.Images[bidx].py+addy, TRUE)
end else begin
GetGreenColorAndAdd (Feature.rArr[i*2+1], gc, ga);
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImageGreenConvert (ImageLib.Images[bidx], ImageLib.Images[bidx].px+addx, ImageLib.Images[bidx].py+addy, gc, ga);
end;
end;
end;
boflag := TRUE;
case block of
0 : if CharTable0[bidx] = 1 then boflag := FALSE;
1 : if CharTable1[bidx] = 1 then boflag := FALSE;
2 : if CharTable2[bidx] = 1 then boflag := FALSE;
3 : if CharTable3[bidx] = 1 then boflag := FALSE;
4 : if CharTable4[bidx] = 1 then boflag := FALSE;
end;
if boflag then begin
for i := 6 to 9 do begin
if not Feature.rboMan then ImageLib := FAtzClass.GetImageLib (char(word('a')+i) + format ('%d%d.atz', [Feature.rArr[i*2],block]), CurTick)
else ImageLib := FAtzClass.GetImageLib (char(word('n')+i) + format ('%d%d.atz', [Feature.rArr[i*2],block]), CurTick);
if ImageLib = nil then continue;
if ImageLib.Count <= bidx then continue;
if Feature.rArr[i*2+1] = 0 then begin
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImage (ImageLib.Images[bidx], ImageLib.Images[bidx].px+addx, ImageLib.Images[bidx].py+addy, TRUE)
end else begin
GetGreenColorAndAdd (Feature.rArr[i*2+1], gc, ga);
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImageGreenConvert (ImageLib.Images[bidx], ImageLib.Images[bidx].px+addx, ImageLib.Images[bidx].py+addy, gc, ga);
end;
end;
exit;
end;
if not Feature.rboMan then ImageLib := FAtzClass.GetImageLib (char(word('a')+9) + format ('%d%d.atz', [Feature.rArr[9*2],block]), CurTick)
else ImageLib := FAtzClass.GetImageLib (char(word('n')+9) + format ('%d%d.atz', [Feature.rArr[9*2],block]), CurTick);
if (ImageLib <> nil) and (ImageLib.Count > bidx) then begin
if Feature.rArr[9*2+1] = 0 then begin
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImage (ImageLib.Images[bidx], ImageLib.Images[bidx].px+addx, ImageLib.Images[bidx].py+addy, TRUE)
end else begin
GetGreenColorAndAdd (Feature.rArr[9*2+1], gc, ga);
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImageGreenConvert (ImageLib.Images[bidx], ImageLib.Images[bidx].px+addx, ImageLib.Images[bidx].py+addy, gc, ga);
end;
end;
for i := 6 to 8 do begin
if not Feature.rboMan then ImageLib := FAtzClass.GetImageLib (char(word('a')+i) + format ('%d%d.atz', [Feature.rArr[i*2],block]), CurTick)
else ImageLib := FAtzClass.GetImageLib (char(word('n')+i) + format ('%d%d.atz', [Feature.rArr[i*2],block]), CurTick);
if ImageLib = nil then continue;
if ImageLib.Count <= bidx then continue;
if Feature.rArr[i*2+1] = 0 then begin
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImage (ImageLib.Images[bidx], ImageLib.Images[bidx].px+addx, ImageLib.Images[bidx].py+addy, TRUE)
end else begin
GetGreenColorAndAdd (Feature.rArr[i*2+1], gc, ga);
if (ImageLib <> nil) and (ImageLib.Images[bidx] <> nil) then CharImageBuffer[CharImageBufferIndex].aCharImage.DrawImageGreenConvert (ImageLib.Images[bidx], ImageLib.Images[bidx].px+addx, ImageLib.Images[bidx].py+addy, gc, ga);
end;
end;
CharImageBuffer[CharImageBufferIndex].aCharImage.Optimize;
OverImage.Optimize;
end;
procedure TCharClass.Paint(CurTick: integer);
begin
MakeFrame (ImageNumber, CurTick);
// if CharImageBuffer[CharImageBufferIndex].aCharImage = nil then exit;
case Feature.rHideState of
hs_100 : // 老馆利牢 葛嚼
begin
BackScreen.DrawImageKeyColor (CharImageBuffer[CharImageBufferIndex].aCharImage, RealX-CHarMaxSiezHalf, RealY-CHarMaxSiezHalf);
BackScreen.DrawImageOveray (OverImage, RealX-CHarMaxSiezHalf, RealY-CHarMaxSiezHalf, 20);
end;
hs_0 : // 肯傈洒 焊捞瘤 救阑版快 弊府瘤 臼澜
if id = CharCenterID then BackScreen.DrawRefractive (CharImageBuffer[CharImageBufferIndex].aCharImage, RealX-CHarMaxSiezHalf, RealY-CHarMaxSiezHalf, 4, 3);
hs_1 : // 篮脚吝烙 CharCenterID 老版快 荤侩磊祈狼肺 距埃颇鄂祸捞 啊固等 版快 Refracrange : 4 overValue : 3
BackScreen.DrawRefractive (CharImageBuffer[CharImageBufferIndex].aCharImage, RealX-CHarMaxSiezHalf, RealY-CHarMaxSiezHalf, 4, 3);
hs_99 : // 篮脚吝 荤侩磊啊 篮脚焊绰 付过殿阑 荤侩矫 距埃 焊捞绰版快 Refracrange : 4 overValue : 0
BackScreen.DrawRefractive (CharImageBuffer[CharImageBufferIndex].aCharImage, RealX-CHarMaxSiezHalf, RealY-CHarMaxSiezHalf, 4, 0);
end;
if StructedTick <> 0 then BackScreen.DrawStructed (RealX, RealY, 36, StructedPercent); // Char 赣府困狼 俊呈瘤官
end;
function TCharClass.Update ( CurTick: integer) : Integer;
procedure NextMessage;
var
RMsg : TRecordMessage;
begin
CurActionInfo := nil;
ViewMessage (RMsg);
if RMsg.rMsg <> 0 then begin
GetMessage (RMsg);
with RMsg do
ProcessMessage (rMsg, rdir, rx, ry, rfeature, rmotion);
end else begin
if CurTick > TurningTick + 200 then begin
TurningTick := CurTick;
CurActionInfo := FindAnimation ( AM_TURNNING, dir);
SetCurrentFrame (CurActionInfo,0, CurTick);
CurAction := SM_TURN;
end else begin
CurActionInfo := FindAnimation ( AM_TURN, dir);
SetCurrentFrame (CurActionInfo, 0, CurTick);
CurAction := SM_TURN;
end;
end;
end;
var
PassTick : integer;
begin
Result := 0;
if (BubbleList.Count <> 0) and (BubbleTick + 300 < CurTick) then BubbleList.Clear;
if StructedTick + 200 < CurTick then StructedTick := 0;
if CurActionInfo <> nil then begin
PassTick := CurTick - FrameStartTime; // 青悼捞 场车栏搁
if PassTick > (CurActionInfo^.Frametime) then begin
Result := 1;
curframe := curframe + 1;
if CurActionInfo^.Frame <= curframe then NextMessage
else SetCurrentFrame (CurActionInfo, curframe, CurTick);
end;
end else begin
NextMessage;
end;
if CharCenterId = id then begin
CharPosX := x; CharPosY := y;
BackScreen.SetCenter (RealX, RealY);
Map.SetCenter (x, y);
end;
end;
///////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -