📄 usrengn.pas
字号:
end;
FrmMain.Caption := sCaption + '[正在初始化 NPC(' + IntToStr(m_MerchantList.Count) + '/' + IntToStr(m_MerchantList.Count - i) + ')]';
//Application.ProcessMessages;
end;
finally
m_MerchantList.UnLock;
end;
end;
procedure TUserEngine.NPCinitialize; //004ACC24
var
i: Integer;
NormNpc: TNormNpc;
begin
for i := QuestNPCList.Count - 1 downto 0 do
begin
NormNpc := TNormNpc(QuestNPCList.Items[i]);
NormNpc.m_PEnvir := g_MapManager.FindMap(NormNpc.m_sMapName);
if NormNpc.m_PEnvir <> nil then
begin
NormNpc.Initialize; //FFFE
if NormNpc.m_boAddtoMapSuccess and (not NormNpc.m_boIsHide) then
begin
MainOutMessage(NormNpc.m_sCharName + ' Npc 初始化失败... ');
QuestNPCList.Delete(i);
NormNpc.Free;
end else
begin
NormNpc.LoadNpcScript();
end;
end else
begin
MainOutMessage(NormNpc.m_sCharName + ' Npc 初始化失败... (npc.PEnvir=nil) ');
QuestNPCList.Delete(i);
NormNpc.Free;
end;
end;
end;
function TUserEngine.GetLoadPlayCount: Integer; //004AE7F0
begin
Result := m_LoadPlayList.Count;
end;
function TUserEngine.GetOnlineHumCount: Integer; //004AE7F0
begin
Result := m_PlayObjectList.Count;
end;
function TUserEngine.GetUserCount: Integer; //004AE7C0
begin
Result := m_PlayObjectList.Count;
end;
procedure TUserEngine.ProcessHumans;
function IsLogined(sChrName: string): Boolean; //004AFC68
var
i: Integer;
begin
Result := False;
if FrontEngine.InSaveRcdList(sChrName) then
begin
Result := True;
end else
begin
for i := 0 to m_PlayObjectList.Count - 1 do
begin
if CompareText(m_PlayObjectList.Strings[i], sChrName) = 0 then
begin
Result := True;
Break;
end;
end;
end;
end;
function MakeNewHuman(UserOpenInfo: pTUserOpenInfo): TPlayObject; //004AFD28
var
PlayObject: TPlayObject;
Abil: pTAbility;
Envir: TEnvirnoment;
nC: Integer;
SwitchDataInfo: pTSwitchDataInfo;
Castle: TUserCastle;
resourcestring
sExceptionMsg = '[Exception] TUserEngine::MakeNewHuman';
sChangeServerFail1 = 'chg-server-fail-1 [%d] -> [%d] [%s]';
sChangeServerFail2 = 'chg-server-fail-2 [%d] -> [%d] [%s]';
sChangeServerFail3 = 'chg-server-fail-3 [%d] -> [%d] [%s]';
sChangeServerFail4 = 'chg-server-fail-4 [%d] -> [%d] [%s]';
sErrorEnvirIsNil = '[Error] PlayObject.PEnvir = nil';
label
ReGetMap;
begin
Result := nil;
try
PlayObject := TPlayObject.Create;
if not g_Config.boVentureServer then
begin
UserOpenInfo.sChrName := '';
UserOpenInfo.LoadUser.nSessionID := 0;
SwitchDataInfo := GetSwitchData(UserOpenInfo.sChrName, UserOpenInfo.LoadUser.nSessionID);
end else SwitchDataInfo := nil; //004AFD95
SwitchDataInfo := nil;
if SwitchDataInfo = nil then
begin
GetHumData(PlayObject, UserOpenInfo.HumanRcd);
PlayObject.m_btRaceServer := RC_PLAYOBJECT;
if PlayObject.m_sHomeMap = '' then
begin
ReGetMap:
PlayObject.m_sHomeMap := GetHomeInfo(PlayObject.m_btJob, PlayObject.m_nHomeX, PlayObject.m_nHomeY);
PlayObject.m_sMapName := PlayObject.m_sHomeMap;
PlayObject.m_nCurrX := GetRandHomeX(PlayObject);
PlayObject.m_nCurrY := GetRandHomeY(PlayObject);
if PlayObject.m_Abil.Level = 0 then
begin
Abil := @PlayObject.m_Abil;
Abil.Level := 1;
Abil.AC := 0;
Abil.MAC := 0;
Abil.DC := MakeLong(1, 2);
Abil.MC := MakeLong(1, 2);
Abil.SC := MakeLong(1, 2);
Abil.MP := 15;
Abil.HP := 15;
Abil.MaxHP := 15;
Abil.MaxMP := 15;
Abil.Exp := 0;
Abil.MaxExp := 100;
Abil.Weight := 0;
Abil.MaxWeight := 30;
PlayObject.m_boNewHuman := True;
end;
end;
Envir := g_MapManager.GetMapInfo(nServerIndex, PlayObject.m_sMapName);
if Envir <> nil then
begin
if Envir.Flag.boFIGHT3Zone then
begin //是否在行会战争地图死亡
if (PlayObject.m_Abil.HP <= 0) and (PlayObject.m_nFightZoneDieCount < 3) then
begin
PlayObject.m_Abil.HP := PlayObject.m_Abil.MaxHP;
PlayObject.m_Abil.MP := PlayObject.m_Abil.MaxMP;
PlayObject.m_boDieInFight3Zone := True;
end else PlayObject.m_nFightZoneDieCount := 0;
end;
end;
PlayObject.m_MyGuild := g_GuildManager.MemberOfGuild(PlayObject.m_sCharName);
Castle := g_CastleManager.InCastleWarArea(Envir, PlayObject.m_nCurrX, PlayObject.m_nCurrY);
{
if (Envir <> nil) and ((UserCastle.m_MapPalace = Envir) or
(UserCastle.m_boUnderWar and UserCastle.InCastleWarArea(PlayObject.m_PEnvir,PlayObject.m_nCurrX,PlayObject.m_nCurrY))) then begin
}
if (Envir <> nil) and (Castle <> nil) and ((Castle.m_MapPalace = Envir) or Castle.m_boUnderWar) then
begin
Castle := g_CastleManager.IsCastleMember(PlayObject);
//if not UserCastle.IsMember(PlayObject) then begin
if Castle = nil then
begin
PlayObject.m_sMapName := PlayObject.m_sHomeMap;
PlayObject.m_nCurrX := PlayObject.m_nHomeX - 2 + Random(5);
PlayObject.m_nCurrY := PlayObject.m_nHomeY - 2 + Random(5);
end else
begin
{
if UserCastle.m_MapPalace = Envir then begin
PlayObject.m_sMapName:=UserCastle.GetMapName();
PlayObject.m_nCurrX:=UserCastle.GetHomeX;
PlayObject.m_nCurrY:=UserCastle.GetHomeY;
end;
}
if Castle.m_MapPalace = Envir then
begin
PlayObject.m_sMapName := Castle.GetMapName();
PlayObject.m_nCurrX := Castle.GetHomeX;
PlayObject.m_nCurrY := Castle.GetHomeY;
end;
end;
end; //004B00C0
if (PlayObject.nC4 <= 1) and (PlayObject.m_Abil.Level >= 1) then
PlayObject.nC4 := 2;
if g_MapManager.FindMap(PlayObject.m_sMapName) = nil then
PlayObject.m_Abil.HP := 0;
if PlayObject.m_Abil.HP <= 0 then
begin
PlayObject.ClearStatusTime();
if PlayObject.PKLevel < 2 then
begin
Castle := g_CastleManager.IsCastleMember(PlayObject);
// if UserCastle.m_boUnderWar and (UserCastle.IsMember(PlayObject)) then begin
if (Castle <> nil) and Castle.m_boUnderWar then
begin
PlayObject.m_sMapName := Castle.m_sHomeMap;
PlayObject.m_nCurrX := Castle.GetHomeX;
PlayObject.m_nCurrY := Castle.GetHomeY;
end else
begin
PlayObject.m_sMapName := PlayObject.m_sHomeMap;
PlayObject.m_nCurrX := PlayObject.m_nHomeX - 2 + Random(5);
PlayObject.m_nCurrY := PlayObject.m_nHomeY - 2 + Random(5);
end;
end else
begin //004B0201
PlayObject.m_sMapName := g_Config.sRedDieHomeMap {'3'};
PlayObject.m_nCurrX := Random(13) + g_Config.nRedDieHomeX {839};
PlayObject.m_nCurrY := Random(13) + g_Config.nRedDieHomeY {668};
end;
PlayObject.m_Abil.HP := 14;
end; //004B023D
PlayObject.AbilCopyToWAbil();
Envir := g_MapManager.GetMapInfo(nServerIndex, PlayObject.m_sMapName);
if Envir = nil then
begin
PlayObject.m_nSessionID := UserOpenInfo.LoadUser.nSessionID;
PlayObject.m_nSocket := UserOpenInfo.LoadUser.nSocket;
PlayObject.m_nGateIdx := UserOpenInfo.LoadUser.nGateIdx;
PlayObject.m_nGSocketIdx := UserOpenInfo.LoadUser.nGSocketIdx;
PlayObject.m_WAbil := PlayObject.m_Abil;
PlayObject.m_nServerIndex := g_MapManager.GetMapOfServerIndex(PlayObject.m_sMapName);
if PlayObject.m_Abil.HP <> 14 then
begin
MainOutMessage(Format(sChangeServerFail1, [nServerIndex, PlayObject.m_nServerIndex, PlayObject.m_sMapName]));
{MainOutMessage('chg-server-fail-1 [' +
IntToStr(nServerIndex) +
'] -> [' +
IntToStr(PlayObject.m_nServerIndex) +
'] [' +
PlayObject.m_sMapName +
']');}
end;
SendSwitchData(PlayObject, PlayObject.m_nServerIndex);
SendChangeServer(PlayObject, PlayObject.m_nServerIndex);
PlayObject.Free;
Exit;
end;
nC := 0;
while (True) do
begin //004B03CC
if Envir.CanWalk(PlayObject.m_nCurrX, PlayObject.m_nCurrY, True) then Break;
PlayObject.m_nCurrX := PlayObject.m_nCurrX - 3 + Random(6);
PlayObject.m_nCurrY := PlayObject.m_nCurrY - 3 + Random(6);
Inc(nC);
if nC >= 5 then Break;
end;
if not Envir.CanWalk(PlayObject.m_nCurrX, PlayObject.m_nCurrY, True) then
begin
// MainOutMessage(format(sChangeServerFail2,[nServerIndex,PlayObject.m_nServerIndex,PlayObject.m_sMapName]));
// 问题2 屏蔽上面那句
{ MainOutMessage('chg-server-fail-2 [' +
IntToStr(nServerIndex) +
'] -> [' +
IntToStr(PlayObject.m_nServerIndex) +
'] [' +
PlayObject.m_sMapName +
']');}
PlayObject.m_sMapName := g_Config.sHomeMap;
Envir := g_MapManager.FindMap(g_Config.sHomeMap);
PlayObject.m_nCurrX := g_Config.nHomeX;
PlayObject.m_nCurrY := g_Config.nHomeY;
end;
PlayObject.m_PEnvir := Envir;
if PlayObject.m_PEnvir = nil then
begin
MainOutMessage(sErrorEnvirIsNil);
goto ReGetMap;
end else
begin
PlayObject.m_boReadyRun := False;
end;
end else
begin //004B0561
GetHumData(PlayObject, UserOpenInfo.HumanRcd);
PlayObject.m_sMapName := SwitchDataInfo.sMap;
PlayObject.m_nCurrX := SwitchDataInfo.wX;
PlayObject.m_nCurrY := SwitchDataInfo.wY;
PlayObject.m_Abil := SwitchDataInfo.Abil;
PlayObject.m_WAbil := SwitchDataInfo.Abil;
LoadSwitchData(SwitchDataInfo, PlayObject);
DelSwitchData(SwitchDataInfo);
Envir := g_MapManager.GetMapInfo(nServerIndex, PlayObject.m_sMapName);
if Envir <> nil then
begin
MainOutMessage(Format(sChangeServerFail3, [nServerIndex, PlayObject.m_nServerIndex, PlayObject.m_sMapName]));
{MainOutMessage('chg-server-fail-3 [' +
IntToStr(nServerIndex) +
'] -> [' +
IntToStr(PlayObject.m_nServerIndex) +
'] [' +
PlayObject.m_sMapName +
']');}
PlayObject.m_sMapName := g_Config.sHomeMap;
Envir := g_MapManager.FindMap(g_Config.sHomeMap);
PlayObject.m_nCurrX := g_Config.nHomeX;
PlayObject.m_nCurrY := g_Config.nHomeY;
end else
begin
if not Envir.CanWalk(PlayObject.m_nCurrX, PlayObject.m_nCurrY, True) then
begin
MainOutMessage(Format(sChangeServerFail4, [nServerIndex, PlayObject.m_nServerIndex, PlayObject.m_sMapName]));
{MainOutMessage('chg-server-fail-4 [' +
IntToStr(nServerIndex) +
'] -> [' +
IntToStr(PlayObject.m_nServerIndex) +
'] [' +
PlayObject.m_sMapName +
']');}
PlayObject.m_sMapName := g_Config.sHomeMap;
Envir := g_MapManager.FindMap(g_Config.sHomeMap);
PlayObject.m_nCurrX := g_Config.nHomeX;
PlayObject.m_nCurrY := g_Config.nHomeY;
end;
PlayObject.AbilCopyToWAbil();
PlayObject.m_PEnvir := Envir;
if PlayObject.m_PEnvir = nil then
begin
MainOutMessage(sErrorEnvirIsNil);
goto ReGetMap;
end else
begin
PlayObject.m_boReadyRun := False;
PlayObject.m_boLoginNoticeOK := True;
PlayObject.bo6AB := True;
end;
end;
end; //004B085C
PlayObject.m_sUserID := UserOpenInfo.LoadUser.sAccount;
PlayObject.m_sIPaddr := UserOpenInfo.LoadUser.sIPaddr;
PlayObject.m_sIPLocal := GetIPLocal(PlayObject.m_sIPaddr);
PlayObject.m_nSocket := UserOpenInfo.LoadUser.nSocket;
PlayObject.m_nGSocketIdx := UserOpenInfo.LoadUser.nGSocketIdx;
PlayObject.m_nGateIdx := UserOpenInfo.LoadUser.nGateIdx;
PlayObject.m_nSessionID := UserOpenInfo.LoadUser.nSessionID;
PlayObject.m_nPayMent := UserOpenInfo.LoadUser.nPayMent;
PlayObject.m_nPayMode := UserOpenInfo.LoadUser.nPayMode;
PlayObject.m_dwLoadTick := UserOpenInfo.LoadUser.dwNewUserTick;
// PlayObject.m_nSoftVersionDate:=UserOpenInfo.HumInfo.nSoftVersionDate;
PlayObject.m_nSoftVersionDateEx := GetExVersionNO(UserOpenInfo.LoadUser.nSoftVersionDate, PlayObject.m_nSoftVersionDate);
Result := PlayObject;
except
MainOutMessage(sExceptionMsg);
end;
end;
var
dwUsrRotTime: LongWord;
dwCheckTime: LongWord; //0x10
dwCurTick: LongWord;
nCheck30: Integer; //0x30
boCheckTimeLimit: Boolean; //0x31
nIdx: Integer;
PlayObject: TPlayObject;
i: Integer;
UserOpenInfo: pTUserOpenInfo;
GoldChangeInfo: pTGoldChangeInfo;
LineNoticeMsg: string;
resourcestring
sExceptionMsg1 = '[Exception] TUserEngine::ProcessHumans -> Ready, Save, Load... Code:=%d';
sExceptionMsg2 = '[Exception] TUserEngine::ProcessHumans ClosePlayer.Delete - Free';
sExceptionMsg3 = '[Exception] TUserEngine::ProcessHumans ClosePlayer.Delete';
sExceptionMsg4 = '[Exception] TUserEngine::ProcessHumans RunNotice';
sExceptionMsg5 = '[Exception] TUserEngine::ProcessHumans Human.Operate Code: %d';
sExceptionMsg6 = '[Exception] TUserEngine::ProcessHumans Human.Finalize Code: %d';
sExceptionMsg7 = '[Exception] TUserEngine::ProcessHumans RunSocket.CloseUser Code: %d';
sExceptionMsg8 = '[Exception] TUserEngine::ProcessHumans';
begin
nCheck30 := 0;
dwCheckTime := GetTickCount();
if (GetTickCount - m_dwProcessLoadPlayTick) > 200 then
begin
m_dwProcessLoadPlayTick := GetTickCount();
try
EnterCriticalSection(m_LoadPlaySection);
try
for i := 0 to m_LoadPlayList.Count - 1 do
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -