📄 uuser.pas
字号:
GetNextPosition (SenderInfo.dir, xx, yy);
if (BasicData.x = xx) and (BasicData.y = yy) then begin
ret := CommandHited (SenderInfo.id, aSubData.HitData);
if (ret <> 0) and (AttribClass.CurLife = 0) then CommandChangeCharState (wfs_die, FALSE);
if ret <> 0 then aSubData.HitData.boHited := TRUE;
end;
}
end;
FM_BOW :
begin
if BasicData.Feature.rfeaturestate = wfs_die then begin Result := PROC_TRUE; exit; end;
if aSubData.TargetId = Basicdata.id then begin
if (TUser (Self).SysopScope = 101) or (BasicData.Feature.rHideState = hs_0) then begin
end else begin
ret := CommandHited (SenderInfo.id, aSubData.HitData, 100);
if (ret <> 0) and (AttribClass.CurLife = 0) then CommandChangeCharState (wfs_die, FALSE);
end;
end;
end;
FM_CHANGEFEATURE :
begin
if SenderInfo.id = BasicData.id then begin
if State <> wfs_care then SetTargetId (0);
if State <> wfs_sitdown then HaveMagicClass.SetBreathngMagic (nil);
if (State <> wfs_running) and (state <> wfs_running2) then HaveMagicClass.SetRunningMagic (nil);
end;
if Senderinfo.Feature.rfeaturestate = wfs_die then begin
if Senderinfo.id = TargetId then SetTargetId (0);
end;
end;
end;
end;
procedure TUserObject.Update (CurTick: integer);
var
ret : integer;
key : word;
Bo : TBasicObject;
GotoXyRData : TGotoXyRData; // ract, rdir, rlen : word;
x1, y1, x2, y2: word;
nX, nY : Integer;
SubData : TSubData;
begin
inherited UpDate (CurTick);
AttribClass.Update (Curtick);
ret := HaveMagicClass.Update (CurTick);
case ret of
RET_CLOSE_NONE:;
RET_CLOSE_RUNNING:
begin
CommandChangeCharState (wfs_normal, FALSE);
HaveMagicClass.SetRunningMagic(nil);
end;
RET_CLOSE_BREATHNG:
begin
CommandChangeCharState (wfs_normal, FALSE);
HaveMagicClass.SetBreathngMagic(nil);
end;
RET_CLOSE_ATTACK :
begin
end;
RET_CLOSE_PROTECTING :
begin
HaveMagicClass.SetProtectingMagic(nil);
end;
end;
HaveItemClass.Update (CurTick);
WearItemClass.Update (CurTick);
if (BasicData.Feature.rFeatureState = wfs_die) and (CurTick > DiedTick + 3000) then begin
if Manager.boPosDie = true then begin
CommandChangeCharState (wfs_normal, FALSE);
TUser(Self).boNewServer := true;
x1 := BasicData.x;
y1 := BasicData.y;
PosByDieClass.GetPosByDieData (Manager.ServerID, ServerID, x1, y1);
TUser(Self).SetPosition (x1, y1);
exit;
end;
nX := BasicData.x;
nY := BasicData.y;
if Maper.isMoveable (nX, nY) = false then begin
if Maper.GetNearXy (nX, nY) = false then begin
frmMain.WriteLogInfo (format ('TUserObject.Update() GetMoveableXY Error (%s, %d, %d, %d)', [Name, ServerID, nX, nY]));
exit;
end;
CommandChangeCharState (wfs_normal, FALSE);
TUser(Self).SetPosition (nX, nY);
end else begin
BasicData.X := nX;
BasicData.Y := nY;
CommandChangeCharState (wfs_normal, FALSE);
Maper.MapProc (BasicData.Id, MM_SHOW, BasicData.x, BasicData.y, BasicData.x, BasicData.y, BasicData);
end;
exit;
{
if Maper.isMoveable (nX, nY) then begin
Maper.MapProc (BasicData.Id, MM_SHOW, BasicData.x, BasicData.y, BasicData.x, BasicData.y);
CommandChangeCharState (wfs_normal, FALSE);
end else begin
if Maper.GetNearXy (nX, nY) then begin
CommandChangeCharState (wfs_normal, FALSE);
Phone.SendMessage (NOTARGETPHONE, FM_DESTROY, BasicData, SubData);
Phone.UnRegisterUser (BasicData.id, BasicData.x, BasicData.y);
BasicData.x := nX; BasicData.y := nY;
SendClass.SendMap (BasicData, Manager.MapName, Manager.ObjName, Manager.RofName, Manager.TilName, Manager.SoundBase);
Phone.RegisterUser (BasicData.id, FieldProc, BasicData.X, BasicData.Y);
Phone.SendMessage (NOTARGETPHONE, FM_CREATE, BasicData, SubData);
end;
end;
}
end;
if (BasicData.Feature.rFeatureState = wfs_die) and (CurTick < DiedTick + 3000) then begin
if (RopeTarget <> 0) and (RopeTick + 500 > CurTick) then begin
bo := TBasicObject (GetViewObjectById (RopeTarget));
if bo = nil then exit;
x1 := BasicData.x;
y1 := BasicData.y;
x2 := bo.Posx;
y2 := bo.Posy;
if AI0GotoXy (GotoXyRData, BasicData.dir, x1, y1, x2, y2, RopeOldX, RopeOldY, Maper.isMoveable) then begin
case GotoXyRData.ract of
AI_CLEAROLDPOS : begin RopeOldX := 0; RopeOldY := 0; end;
AI_TURN :
begin
BasicData.dir := GotoXyRData.rdir;
SendLocalMessage (NOTARGETPHONE, FM_TURN, BasicData, SubData);
SendClass.SendTurn (BasicData);
end;
AI_MOVE :
begin
x1 := BasicData.x; y1 := BasicData.y;
GetNextPosition (GotoXyRData.rdir, x1, y1);
if Maper.isMoveable ( x1, y1) then begin
RopeOldX := BasicData.x;
RopeOldy := BasicData.y;
BasicData.dir := GotoXyRData.rdir;
BasicData.nx := x1;
BasicData.ny := y1;
Phone.SendMessage ( NOTARGETPHONE, FM_MOVE, BasicData, SubData);
SendClass.SendMove (BasicData); // 郴啊 杭荐 乐澜.
Maper.MapProc (BasicData.Id, MM_MOVE, BasicData.x, BasicData.y, x1, y1, BasicData);
BasicData.x := x1; BasicData.y := y1;
end;
end;
end;
end;
end;
end;
Case LifeObjectState of
los_none:
begin
if boShiftAttack = FALSE then begin boShiftAttack := TRUE; SendClass.SendShiftAttack (boShiftAttack); end;
end;
los_die :
begin
if boShiftAttack = FALSE then begin boShiftAttack := TRUE; SendClass.SendShiftAttack (boShiftAttack); end;
end;
los_attack:
begin
bo := TBasicObject (GetViewObjectById (TargetId));
if bo = nil then LifeObjectState := los_none
else begin
if HaveMagicClass.pCurAttackMagic = nil then exit;
case HaveMagicClass.pCurAttackMagic^.rMagicType of
MAGICTYPE_BOWING, MAGICTYPE_THROWING :
begin
if boShiftAttack = FALSE then begin boShiftAttack := TRUE; SendClass.SendShiftAttack (boShiftAttack); end;
CommandBowing (CurTick, TargetId, bo.Posx, bo.Posy, TRUE);
end;
else begin
if GetLargeLength (BasicData.X, BasicData.Y, bo.PosX, bo.PosY) = 1 then begin
key := GetNextDirection (BasicData.X, BasicData.Y, bo.PosX, bo.PosY);
if key = DR_DONTMOVE then exit; // 困率捞 0 老锭狼 版快牢单 困率捞 1烙..
if key <> BasicData.dir then CommandTurn (key, TRUE);
if CommandHit (CurTick, TRUE) then begin
if boShiftAttack = TRUE then begin boShiftAttack := FALSE; SendClass.SendShiftAttack (boShiftAttack); end;
end;
end else begin
if boShiftAttack = FALSE then begin boShiftAttack := TRUE; SendClass.SendShiftAttack (boShiftAttack); end;
end;
end;
end;
end;
end;
end;
if AttribClass.ReQuestPlaySoundNumber <> 0 then begin
SetWordString (SubData.SayString, IntToStr (AttribClass.RequestPlaySoundNumber) + '.wav');
SendLocalMessage (NOTARGETPHONE, FM_SOUND, BasicData, SubData);
AttribClass.ReQuestPlaySoundNumber := 0;
end;
if HaveMagicClass.ReQuestPlaySoundNumber <> 0 then begin
SetWordString (SubData.SayString, IntToStr (HaveMagicClass.RequestPlaySoundNumber) + '.wav');
SendLocalMessage (NOTARGETPHONE, FM_SOUND, BasicData, SubData);
HaveMagicClass.ReQuestPlaySoundNumber := 0;
end;
if HaveItemClass.ReQuestPlaySoundNumber <> 0 then begin
SetWordString (SubData.SayString, IntToStr (HaveItemClass.RequestPlaySoundNumber) + '.wav');
SendLocalMessage (NOTARGETPHONE, FM_SOUND, BasicData, SubData);
HaveItemClass.ReQuestPlaySoundNumber := 0;
end;
if WearItemClass.ReQuestPlaySoundNumber <> 0 then begin
SetWordString (SubData.SayString, IntToStr (WearItemClass.RequestPlaySoundNumber) + '.wav');
SendLocalMessage (NOTARGETPHONE, FM_SOUND, BasicData, SubData);
WearItemClass.ReQuestPlaySoundNumber := 0;
end;
end;
procedure TUserObject.Initial (aName: String);
begin
inherited Initial (aName, aName);
Name := aName;
IP := Connector.IpAddr;
SendClass.SetName (Name);
SendClass.SetConnector (Connector);
AttribClass.LoadFromSdb (@Connector.CharData);
HaveMagicClass.LoadFromSdb (@Connector.CharData);
HaveItemClass.LoadFromSdb (@Connector.CharData);
WearItemClass.LoadFromSdb (@Connector.CharData);
end;
function TUserObject.FindHaveMagicByName (aMagicName : String) : Integer;
begin
Result := HaveMagicClass.FindHaveMagicByName (aMagicName);
end;
function TUserObject.DeleteItem (aItemData: PTItemData): Boolean;
begin
Result := HaveItemClass.DeleteItem (aItemData);
end;
function TUserObject.FindItem (aItemData : PTItemData): Boolean;
begin
Result := HaveItemClass.FindItem (aItemData);
end;
function TUserObject.AddMagic (aMagicData: PTMagicData): Boolean;
begin
Result := HaveMagicClass.AddMagic (aMagicData);
end;
////////////////////////////////////////////////////
//
// === User ===
//
////////////////////////////////////////////////////
constructor TUser.Create;
begin
inherited Create;
MailBox := TList.Create;
RefuseReceiver := TStringList.Create;
MailSender := TStringList.Create;
MacroChecker := TMacroChecker.Create (6);
boException := false;
SysopObj := nil;
UserObj := nil;
boCanSay := true;
boCanMove := true;
boCanAttack := true;
end;
destructor TUser.Destroy;
var
i : Integer;
pd : PTLetterData;
begin
for i := 0 to MailBox.Count - 1 do begin
pd := MailBox.Items[i];
if pd <> nil then Dispose (pd);
end;
MailBox.Free;
RefuseReceiver.Free;
MailSender.Free;
MacroChecker.Free;
inherited destroy;
end;
procedure TUser.LoadUserData (aName: string);
var
flag : Boolean;
i, xx, yy: integer;
begin
StrPCopy (@Basicdata.Name, aName);
ServerID := Connector.CharData.ServerId;
xx := Connector.CharData.X;
yy := Connector.CharData.Y;
Maper.GetMoveableXy (xx, yy, 10);
if Maper.IsMoveable (xx, yy) = false then begin
xx := Maper.Width div 2;
yy := Maper.Height div 2;
Maper.GetMoveableXy (xx, yy, 10);
end;
BasicData.x := xx;
BasicData.y := yy;
BasicData.dir := DR_4;
GuildName := StrPas (@Connector.CharData.Guild);
GuildGrade := '';
StrPCopy (@Connector.CharData.LastDate, DateToStr (Date));
boNewServer := FALSE;
end;
procedure TUser.SaveUserData (aName: string);
begin
Connector.CharData.ServerID := ServerID;
StrPCopy (@Connector.CharData.Guild, GuildName);
if (not boNewServer) and (Connector.BattleState = bcs_none) then begin
Connector.CharData.X := BasicData.x;
Connector.CharData.Y := BasicData.Y;
end else begin
Connector.CharData.X := PosMoveX;
Connector.CharData.Y := PosMoveY;
end;
end;
function TUser.InitialLayer (aCharName: string): Boolean;
begin
Result := false;
PrisonTick := mmAnsTick;
SaveTick := mmAnsTick;
FalseTick := 0;
MailTick := mmAnsTick - 10 * 100;
Name := aCharName;
Result := true;
end;
procedure TUser.Initial (aName: string);
begin
inherited Initial (aName);
FillChar (ExchangeData, SizeOf (TExchangeData), 0);
InputStringState := InputStringState_None;
boTV := false;
boException := false;
boLetterCheck := true;
boCanSay := true;
boCanMove := true;
boCanAttack := true;
UseSkillKind := -1;
SkillUsedTick := 0;
SkillUsedMaxTick := 0;
LoadUserData (aName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -