📄 clmain.pas
字号:
if key = '/' then begin
if WhisperName = '' then PlayScene.EdChat.Text := key
else if Length(WhisperName) > 2 then PlayScene.EdChat.Text := '/' + WhisperName + ' '
else PlayScene.EdChat.Text := key;
PlayScene.EdChat.SelStart := Length(PlayScene.EdChat.Text);
PlayScene.EdChat.SelLength := 0;
end else begin
PlayScene.EdChat.Text := key;
PlayScene.EdChat.SelStart := 1;
PlayScene.EdChat.SelLength := 0;
end;
end;
end;
key := #0;
end;
end;
function TFrmMain.GetMagicByKey (Key: char): PTClientMagic;
var
i: integer;
pm: PTClientMagic;
begin
Result := nil;
for i:=0 to MagicList.Count-1 do begin
pm := PTClientMagic (MagicList[i]);
if pm.Key = Key then begin
Result := pm;
break;
end;
end;
end;
procedure TFrmMain.UseMagic (tx, ty: integer; pcm: PTClientMagic); //tx, ty: 胶农赴 谅钎烙.
var
tdir, targx, targy, targid: integer;
pmag: PTUseMagicInfo;
begin
if pcm = nil then exit;
//是否可以使用魔法:需要的点数<当前点数,或者是魔法EffectType = 0
if (pcm.Def.Spell + pcm.Def.DefSpell <= Myself.Abil.MP) or (pcm.Def.EffectType = 0) then begin
if pcm.Def.EffectType = 0 then begin //八过,瓤苞绝澜
//八过 虐绰 青悼阑 蝶肺 窍瘤 臼绰促.
//辑滚俊 流立 傈崔茄促.
//if CanNextAction and ServerAcceptNextAction then begin
//堪拳搬篮 茄锅 荤侩饶 9檬鳖瘤绰 促矫 喘妨瘤瘤 臼霸 茄促.
if pcm.Def.MagicId = 26 then begin //堪拳搬
if GetTickCount - LatestFireHitTime < 10 * 1000 then begin //10秒用一次
exit;
end;
end;
//公怕焊绰 茄锅 荤侩饶 3檬鳖瘤绰 促矫 喘妨瘤瘤 臼绰促.
if pcm.Def.MagicId = 27 then begin //公怕焊
if GetTickCount - LatestRushRushTime < 3 * 1000 then begin //3秒用一次
exit;
end;
end;
//八过篮 掉饭捞(500ms) 绝捞 喘妨柳促.
if GetTickCount - LatestSpellTime > 500 then begin
LatestSpellTime := GetTickCount;
MagicDelayTime := 0; //pcm.Def.DelayTime;
SendSpellMsg (CM_SPELL, Myself.Dir{x}, 0, pcm.Def.MagicId, 0);
end;
end else begin
tdir := GetFlyDirection (390, 175, tx, ty);
MagicTarget := FocusCret;
if not PlayScene.IsValidActor (MagicTarget) then
MagicTarget := nil;
if MagicTarget = nil then begin
PlayScene.CXYfromMouseXY (tx, ty, targx, targy);
targid := 0;
end else begin
targx := MagicTarget.XX;
targy := MagicTarget.YY;
targid := MagicTarget.RecogId;
end;
if CanNextAction and ServerAcceptNextAction then begin
LatestSpellTime := GetTickCount; //付过 荤侩
new (pmag);
FillChar (pmag^, sizeof(TUseMagicInfo), #0);
pmag.EffectNumber := pcm.Def.Effect;
pmag.MagicSerial := pcm.Def.MagicId;
pmag.ServerMagicCode := 0;
MagicDelayTime := 200 + pcm.Def.DelayTime; //促澜 付过阑 荤侩且锭鳖瘤 浆绰 矫埃
case pmag.MagicSerial of
//0, 2, 11, 12, 15, 16, 17, 13, 23, 24, 26, 27, 28, 29: ;
2, 14, 15, 16, 17, 18, 19, 21, //厚傍拜 付过 力寇
12, 25, 26, 28, 29, 30, 31: ;
else LatestMagicTime := GetTickCount;
end;
//荤恩阑 傍拜窍绰 版快狼 掉饭捞
MagicPKDelayTime := 0;
if MagicTarget <> nil then
if MagicTarget.Race = 0 then
MagicPKDelayTime := 300 + Random(1100); //(600+200 + MagicDelayTime div 5);
Myself.SendMsg (CM_SPELL, targx, targy, tdir, Integer(pmag), targid, '', 0);
end;// else
//Dscreen.AddSysMsg ('泪矫饶俊 荤侩且 荐 乐嚼聪促.');
//Inc (SpellCount);
end;
end else
Dscreen.AddSysMsg ('点数不够,无法使用.');
// Dscreen.AddSysMsg ('付过荤侩');
end;
procedure TFrmMain.UseMagicSpell (who, effnum, targetx, targety, magic_id: integer);
var
actor: TActor;
adir: integer;
pmag: PTUseMagicInfo;
begin
actor := PlayScene.FindActor (who);
if actor <> nil then begin
adir := GetFlyDirection (actor.XX, actor.YY, targetx, targety);
new (pmag);
FillChar (pmag^, sizeof(TUseMagicInfo), #0);
pmag.EffectNumber := effnum; //magnum;
pmag.ServerMagicCode := 0; //烙矫
pmag.MagicSerial := magic_id;
actor.SendMsg (SM_SPELL, 0, 0, adir, Integer(pmag), 0, '', 0);
Inc (SpellCount);
end else
Inc (SpellFailCount);
end;
procedure TFrmMain.UseMagicFire (who, efftype, effnum, targetx, targety, target: integer);
var
actor: TActor;
adir, sound: integer;
pmag: PTUseMagicInfo;
begin
actor := PlayScene.FindActor (who);
if actor <> nil then begin
actor.SendMsg (SM_MAGICFIRE, target{111magid}, efftype, effnum, targetx, targety, '', sound);
//if actor = Myself then Dec (SpellCount);
if FireCount < SpellCount then
Inc (FireCount);
end;
MagicTarget := nil;
end;
procedure TFrmMain.UseMagicFireFail (who: integer);
var
actor: TActor;
begin
actor := PlayScene.FindActor (who);
if actor <> nil then begin
actor.SendMsg (SM_MAGICFIRE_FAIL, 0, 0, 0, 0, 0, '', 0);
end;
MagicTarget := nil;
end;
//吃药
procedure TFrmMain.EatItem (idx: integer);
begin
if idx in [0..MAXBAGITEMCL-1] then begin
if (EatingItem.S.Name <> '') and (GetTickCount - EatTime > 5 * 1000) then begin //5秒之内只能吃一次药
EatingItem.S.Name := '';
end; /////!///////
if (EatingItem.S.Name = '') and (ItemArr[idx].S.Name <> '') and (ItemArr[idx].S.StdMode <= 4) then begin
EatingItem := ItemArr[idx];
ItemArr[idx].S.Name := '';
//氓阑 佬绰 巴... 劳鳃 巴牢 瘤 拱绢夯促.
if (ItemArr[idx].S.StdMode = 4) and (ItemArr[idx].S.Shape < 100) then begin
//shape > 100捞搁 弓澜 酒捞袍 烙..
if ItemArr[idx].S.Shape < 50 then begin
if mrYes <> FrmDlg.DMessageDlg (ItemArr[idx].S.Name + '是否使用该物品?', [mbYes, mbNo]) then begin
ItemArr[idx] := EatingItem;
exit;
end;
end else begin
//shape > 50捞搁 林巩 辑 辆幅...
if mrYes <> FrmDlg.DMessageDlg (ItemArr[idx].S.Name + '是否使用该物品?', [mbYes, mbNo]) then begin
ItemArr[idx] := EatingItem;
exit;
end;
end;
end;
EatTime := GetTickCount;
SendEat(ItemArr[idx].MakeIndex, ItemArr[idx].S.Name );
ItemUseSound (ItemArr[idx].S.StdMode);
end;
end else begin
if (idx = -1) and ItemMoving then begin
ItemMoving := FALSE;
EatingItem := MovingItem.Item;
MovingItem.Item.S.Name := '';
//氓阑 佬绰 巴... 劳鳃 巴牢 瘤 拱绢夯促.
if (EatingItem.S.StdMode = 4) and (EatingItem.S.Shape < 100) then begin
//shape > 100捞搁 弓澜 酒捞袍 烙..
if EatingItem.S.Shape < 50 then begin
if mrYes <> FrmDlg.DMessageDlg ('"' + EatingItem.S.Name + '"物品是否使用?', [mbYes, mbNo]) then begin
AddItemBag (EatingItem);
exit;
end;
end else begin
//shape > 50捞搁 林巩 辑 辆幅...
if mrYes <> FrmDlg.DMessageDlg ('"' + EatingItem.S.Name + '"物品是否使用?', [mbYes, mbNo]) then begin
AddItemBag (EatingItem);
exit;
end;
end;
end;
EatTime := GetTickCount;
SendEat (EatingItem.MakeIndex, EatingItem.S.Name );
ItemUseSound (EatingItem.S.StdMode);
end;
end;
end;
function TFrmMain.TargetInSwordLongAttackRange (ndir: integer): Boolean;
var
nx, ny: integer;
actor: TActor;
begin
Result := FALSE;
GetFrontPosition (Myself.XX, Myself.YY, ndir, nx, ny);
GetFrontPosition (nx, ny, ndir, nx, ny);
if (abs(Myself.XX-nx) = 2) or (abs(Myself.YY-ny) = 2) then begin
actor := PlayScene.FindActorXY (nx, ny);
if actor <> nil then
if not actor.Death then
Result := TRUE;
end;
end;
function TFrmMain.TargetInSwordWideAttackRange (ndir: integer): Boolean;
var
nx, ny, rx, ry, mdir: integer;
actor, ractor: TActor;
begin
Result := FALSE;
GetFrontPosition (Myself.XX, Myself.YY, ndir, nx, ny);
actor := PlayScene.FindActorXY (nx, ny);
mdir := (ndir + 1) mod 8;
GetFrontPosition (Myself.XX, Myself.YY, mdir, rx, ry);
ractor := PlayScene.FindActorXY (rx, ry);
if ractor = nil then begin
mdir := (ndir + 2) mod 8;
GetFrontPosition (Myself.XX, Myself.YY, mdir, rx, ry);
ractor := PlayScene.FindActorXY (rx, ry);
end;
if ractor = nil then begin
mdir := (ndir + 7) mod 8;
GetFrontPosition (Myself.XX, Myself.YY, mdir, rx, ry);
ractor := PlayScene.FindActorXY (rx, ry);
end;
if (actor <> nil) and (ractor <> nil) then
if not actor.Death and not ractor.Death then
Result := TRUE;
end;
{--------------------- Mouse Interface ----------------------}
procedure TFrmMain.DXDraw1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
i, mx, my, msx, msy, sel: integer;
target: TActor;
itemnames: string;
begin
if DWinMan.MouseMove (Shift, X, Y) then exit;
if (Myself = nil) or (DScreen.CurrentScene <> PlayScene) then exit;
BoSelectMyself := PlayScene.IsSelectMyself (X, Y);
target := PlayScene.GetAttackFocusCharacter (X, Y, DupSelection, sel, FALSE);
if DupSelection <> sel then DupSelection := 0;
if target <> nil then begin
if (target.UserName = '') and (GetTickCount - target.SendQueryUserNameTime > 10*1000) then begin
target.SendQueryUserNameTime := GetTickCount;
SendQueryUserName (target.RecogId, target.XX, target.YY);
end;
FocusCret := target;
end else
FocusCret := nil;
FocusItem := PlayScene.GetDropItems (X, Y, itemnames);
if FocusItem <> nil then begin
PlayScene.ScreenXYfromMCXY (FocusItem.X, FocusItem.Y, mx, my);
DScreen.ShowHint (mx-20,
my-10,
itemnames, //PTDropItem(ilist[i]).Name,
clWhite,
TRUE);
end else
DScreen.ClearHint;
PlayScene.CXYfromMouseXY (X, Y, MCX, MCY);
MouseX := X;
MouseY := Y;
MouseItem.S.Name := '';
MouseStateItem.S.Name := '';
MouseUserStateItem.S.Name := '';
if ((ssLeft in Shift) or (ssRight in Shift)) and (GetTickCount - mousedowntime > 300) then
_DXDrawMouseDown(self, mbLeft, Shift, X, Y);
end;
procedure TFrmMain.DXDraw1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
mousedowntime := GetTickCount;
RunReadyCount := 0; //档框摧扁 秒家(顿扁 牢版快)
_DXDrawMouseDown (Sender, Button, Shift, X, Y);
end;
procedure TFrmMain.AttackTarget (target: TActor);
var
tdir, dx, dy, hitmsg: integer;
begin
hitmsg := CM_HIT;
if UseItems[U_WEAPON].S.StdMode = 6 then hitmsg := CM_HEAVYHIT;
tdir := GetNextDirection (Myself.XX, Myself.YY, target.XX, target.YY);
if (abs(Myself.XX-target.XX) <= 1) and (abs(Myself.YY-target.YY) <= 1) and (not target.Death) then begin
if CanNextAction and ServerAcceptNextAction and CanNextHit then begin
if BoNextTimeFireHit and (Myself.Abil.MP >= 7) then begin
BoNextTimeFireHit := FALSE;
hitmsg := CM_FIREHIT;
end else
if BoNextTimePowerHit then begin //颇况 酒咆牢 版快, 抗档八过
BoNextTimePowerHit := FALSE;
hitmsg := CM_POWERHIT;
end else
if BoCanWideHit and (Myself.Abil.MP >= 3) then begin //and (TargetInSwordWideAttackRange (tdir)) then begin //氛 酒咆牢 版快, 馆岿八过
hitmsg := CM_WIDEHIT;
end else
if BoCanLongHit and (TargetInSwordLongAttackRange (tdir)) then begin //氛 酒咆牢 版快, 绢八贱
hitmsg := CM_LONGHIT;
end;
//if ((target.Race <> 0) and (target.Race <> RCC_GUARD)) or (ssShift in Shift) then //荤恩阑 角荐肺 傍拜窍绰 巴阑 阜澜
Myself.SendMsg (hitmsg, Myself.XX, Myself.YY, tdir, 0, 0, '', 0);
LatestHitTime := GetTickCount;
end;
LastAttackTime := GetTickCount;
end else begin
//厚档甫 甸绊 乐栏搁
//if (UseItems[U_WEAPON].S.Shape = 6) and (target <> nil) then begin
// Myself.SendMsg (CM_THROW, Myself.XX, Myself.YY, tdir, integer(target), 0, '', 0);
// TargetCret := nil; //茄锅父 傍拜
//end else begin
ChrAction := caWalk;
GetBackPosition (target.XX, target.YY, tdir, dx, dy);
TargetX := dx;
TargetY := dy;
//end;
end;
end;
procedure TFrmMain._DXDrawMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
tdir, nx, ny, hitmsg, sel: integer;
target: TActor;
begin
ActionKey := 0;
MouseX := X;
MouseY := Y;
BoAutoDig := FALSE;
if (Button = mbRight) and ItemMoving then begin
FrmDlg.CancelItemMoving;
exit;
end;
if DWinMan.Mouse
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -