📄 usrengn.pas
字号:
//Application.ProcessMessages;
end;
end;
finally
m_MerchantList.UnLock;
end;
end;
procedure TUserEngine.NPCinitialize;
var
I: Integer;
NormNpc: TNormNpc;
begin
for I := QuestNPCList.Count - 1 downto 0 do begin
NormNpc := TNormNpc(QuestNPCList.Items[I]);
if NormNpc <> nil then begin
NormNpc.m_PEnvir := g_MapManager.FindMap(NormNpc.m_sMapName);
if NormNpc.m_PEnvir <> nil then begin
NormNpc.Initialize;
if NormNpc.m_boAddtoMapSuccess and (not NormNpc.m_boIsHide) then begin
MainOutMessage(NormNpc.m_sCharName + ' Npc Initalize fail... ');
QuestNPCList.Delete(I);
NormNpc.Free;
end else begin
NormNpc.LoadNpcScript();
end;
end else begin
MainOutMessage(NormNpc.m_sCharName + ' Npc Initalize fail... (npc.PEnvir=nil) ');
QuestNPCList.Delete(I);
NormNpc.Free;
end;
end;
end;
end;
function TUserEngine.GetLoadPlayCount: Integer;
begin
Result := m_LoadPlayList.Count;
end;
function TUserEngine.GetOnlineHumCount: Integer;
begin
Result := m_PlayObjectList.Count;
end;
function TUserEngine.GetUserCount: Integer;
begin
Result := m_PlayObjectList.Count + m_StringList_0C.Count;
end;
function TUserEngine.GetAutoAddExpPlayCount: Integer;
var
I: Integer;
begin
Result := 0;
EnterCriticalSection(ProcessHumanCriticalSection);
try
for I := 0 to m_PlayObjectList.Count - 1 do begin
if TPlayObject(m_PlayObjectList.Objects[I]).m_boNotOnlineAddExp then Inc(Result);
end;
finally
LeaveCriticalSection(ProcessHumanCriticalSection);
end;
end;
procedure TUserEngine.ProcessHumans;
function IsLogined(sAccount, sChrName: string): Boolean;
var
I: Integer;
begin
Result := False;
if FrontEngine.InSaveRcdList(sAccount, sChrName) then begin
Result := True;
end else begin
for I := 0 to m_PlayObjectList.Count - 1 do begin
if (CompareText(TPlayObject(m_PlayObjectList.Objects[I]).m_sUserID, sAccount) = 0) and
(CompareText(m_PlayObjectList.Strings[I], sChrName) = 0) then begin
Result := True;
Break;
end;
end;
end;
end;
function MakeNewHuman(UserOpenInfo: pTUserOpenInfo): TPlayObject;
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;
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_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 := 10;
Abil.MaxExp := 100;
Abil.Weight := 100;
Abil.MaxWeight := 100;
PlayObject.m_boNewHuman := True;
end;
end;
Envir := g_MapManager.GetMapInfo(nServerIndex, PlayObject.m_sMapName);
if Envir <> nil then begin
if Envir.m_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;
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
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;
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;
FreeAndNil(PlayObject);
Exit;
end;
nC := 0;
while (True) do begin
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]));
{ 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
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;
PlayObject.m_sUserID := UserOpenInfo.LoadUser.sAccount;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -