📄 usrengn.pas
字号:
boRegened := True;
//if MonGen.nCount > tGenCount then begin
//if (MonGen.nCount <= g_nMonGenRate) or (MonGen.nCount div g_nMonGenRate > tGenCount) then begin //0806 增加 控制刷怪数量比例
nGenModCount := _MAX(1, Round(_MAX(1, MonGen.nCount) / (g_Config.nMonGenRate / 10)));
if nGenModCount > nGenCount then
begin //0806 增加 控制刷怪数量比例
boRegened := RegenMonsters(MonGen, nGenModCount - nGenCount);
end; //004B1798
if boRegened then
begin
MonGen.dwStartTick := GetTickCount();
end;
end; //004B17A9
g_sMonGenInfo1 := MonGen.sMonName + ',' + IntToStr(m_nCurrMonGen) + '/' + IntToStr(m_MonGenList.Count);
end; //004B1851
end; //004B1851
g_nMonGenTime := GetTickCount - dwCurrentTick;
if g_nMonGenTime > g_nMonGenTimeMin then g_nMonGenTimeMin := g_nMonGenTime;
if g_nMonGenTime > g_nMonGenTimeMax then g_nMonGenTimeMax := g_nMonGenTime;
//刷新怪物结束
dwMonProcTick := GetTickCount();
nMonsterProcessCount := 0;
tCode := 1;
//004B187B
for i := m_nMonGenListPosition to m_MonGenList.Count - 1 do
begin
MonGen := m_MonGenList.Items[i];
tCode := 11;
if m_nMonGenCertListPosition < MonGen.CertList.Count then
begin
nProcessPosition := m_nMonGenCertListPosition;
end else
begin //4B18A8
nProcessPosition := 0;
end;
m_nMonGenCertListPosition := 0;
//4B18B5
while (True) do
begin
if nProcessPosition >= MonGen.CertList.Count then Break;
Monster := MonGen.CertList.Items[nProcessPosition];
tCode := 12;
if not Monster.m_boGhost then
begin
if Integer(dwCurrentTick - Monster.m_dwRunTick) > Monster.m_nRunTime then
begin
Monster.m_dwRunTick := dwRunTick;
if (dwCurrentTick - Monster.m_dwSearchTick) > Monster.m_dwSearchTime then
begin
Monster.m_dwSearchTick := GetTickCount();
tCode := 13;
Monster.SearchViewRange();
end;
tCode := 14;
{$IF PROCESSMONSTMODE = OLDMONSTERMODE}
Monster.Run;
{$ELSE}
if not Monster.m_boIsVisibleActive and (Monster.m_nProcessRunCount < g_Config.nProcessMonsterInterval) then
begin
Inc(Monster.m_nProcessRunCount);
end else
begin
Monster.m_nProcessRunCount := 0;
Monster.Run;
end;
{$IFEND}
Inc(nMonsterProcessCount);
end;
Inc(nMonsterProcessPostion);
end else
begin
if (GetTickCount - Monster.m_dwGhostTick) > 5 * 60 * 1000 then
begin
MonGen.CertList.Delete(nProcessPosition);
Monster.Free;
Continue;
end;
end;
Inc(nProcessPosition);
if (GetTickCount - dwMonProcTick) > g_dwMonLimit then
begin
g_sMonGenInfo2 := Monster.m_sCharName + '/' + IntToStr(i) + '/' + IntToStr(nProcessPosition);
boProcessLimit := True;
m_nMonGenCertListPosition := nProcessPosition;
Break;
end;
end; //while (True) do begin
if boProcessLimit then Break;
end; //for I:= m_nMonGenListPosition to MonGenList.Count -1 do begin
//004B1A5D
tCode := 2;
if m_MonGenList.Count <= i then
begin
m_nMonGenListPosition := 0;
nMonsterCount := nMonsterProcessPostion;
nMonsterProcessPostion := 0;
n84 := (n84 + nMonsterProcessCount) div 2;
end; //4B1AAF
if not boProcessLimit then
begin
m_nMonGenListPosition := 0;
end else
begin
m_nMonGenListPosition := i;
end;
g_nMonProcTime := GetTickCount - dwMonProcTick;
if g_nMonProcTime > g_nMonProcTimeMin then g_nMonProcTimeMin := g_nMonProcTime;
if g_nMonProcTime > g_nMonProcTimeMax then g_nMonProcTimeMax := g_nMonProcTime;
except
on E: Exception do
begin
MainOutMessage(Format(sExceptionMsg, [tCode]));
MainOutMessage(E.Message);
end;
end;
g_nMonTimeMin := GetTickCount - dwRunTick;
if g_nMonTimeMax < g_nMonTimeMin then g_nMonTimeMax := g_nMonTimeMin;
end;
function TUserEngine.GetGenMonCount(MonGen: pTMonGenInfo): Integer; //4AE19C
var
i: Integer;
nCount: Integer;
BaseObject: TBaseObject;
begin
nCount := 0;
for i := 0 to MonGen.CertList.Count - 1 do
begin
BaseObject := TBaseObject(MonGen.CertList.Items[i]);
if not BaseObject.m_boDeath and not BaseObject.m_boGhost then Inc(nCount);
end;
Result := nCount;
end;
procedure TUserEngine.ProcessNpcs;
var
dwRunTick, dwCurrTick: LongWord;
i: Integer;
NPC: TNormNpc;
boProcessLimit: Boolean;
begin
dwRunTick := GetTickCount();
boProcessLimit := False;
try
dwCurrTick := GetTickCount();
for i := nNpcPosition to QuestNPCList.Count - 1 do
begin
NPC := QuestNPCList.Items[i];
if not NPC.m_boGhost then
begin
if Integer(dwCurrTick - NPC.m_dwRunTick) > NPC.m_nRunTime then
begin
if (GetTickCount - NPC.m_dwSearchTick) > NPC.m_dwSearchTime then
begin
NPC.m_dwSearchTick := GetTickCount();
NPC.SearchViewRange();
end;
if Integer(dwCurrTick - NPC.m_dwRunTick) > NPC.m_nRunTime then
begin
NPC.m_dwRunTick := dwCurrTick;
NPC.Run; {FFFFB}
end;
end;
end else
begin
if (GetTickCount - NPC.m_dwGhostTick) > 60 * 1000 then
begin
NPC.Free;
QuestNPCList.Delete(i);
Break;
end;
end;
if (GetTickCount - dwRunTick) > g_dwNpcLimit then
begin
nNpcPosition := i;
boProcessLimit := True;
Break;
end;
end;
if not boProcessLimit then
begin
nNpcPosition := 0;
end;
except
MainOutMessage('[Exceptioin] TUserEngine.ProcessNpcs');
end;
dwProcessNpcTimeMin := GetTickCount - dwRunTick;
if dwProcessNpcTimeMin > dwProcessNpcTimeMax then dwProcessNpcTimeMax := dwProcessNpcTimeMin;
end;
//004ADE3C
function TUserEngine.RegenMonsterByName(sMap: string; nX, nY: Integer;
sMonName: string): TBaseObject;
var
nRace: Integer;
BaseObject: TBaseObject;
n18: Integer;
MonGen: pTMonGenInfo;
begin
nRace := GetMonRace(sMonName);
BaseObject := AddBaseObject(sMap, nX, nY, nRace, sMonName);
if BaseObject <> nil then
begin
n18 := m_MonGenList.Count - 1;
if n18 < 0 then n18 := 0;
MonGen := m_MonGenList.Items[n18];
MonGen.CertList.Add(BaseObject);
BaseObject.m_PEnvir.AddObject(BaseObject);
BaseObject.m_boAddToMaped := True;
// MainOutMessage(format('MonGet Count:%d',[MonGen.CertList.Count]));
end;
Result := BaseObject;
end;
procedure TUserEngine.Run; //004B20B8
//var
// i:integer;
// dwProcessTick:LongWord;
resourcestring
sExceptionMsg = '[Exception] TUserEngine::Run';
begin
CalceTime := GetTickCount;
try
{
ProcessHumans();
if (GetTickCount() - dwProcessMonstersTick) > g_dwProcessMonstersTime then begin
dwProcessMonstersTick:=GetTickCount();
ProcessMonsters();
end;
dwProcessTick:=GetTickCount();
ProcessMerchants();
dwProcessMerchantTimeMin:=GetTickCount - dwProcessTick;
dwProcessTick:=GetTickCount();
ProcessNpcs();
dwProcessNpcTimeMin:=GetTickCount - dwProcessTick;
if (GetTickCount() - dwProcessMissionsTime) > 1000 then begin
dwProcessMissionsTime:=GetTickCount();
ProcessMissions();
Process4AECFC();
ProcessEvents();
end;
if (GetTickCount() - dwProcessMapDoorTick) > 500 then begin
dwProcessMapDoorTick:=GetTickCount();
ProcessMapDoor();
end;
}
if (GetTickCount() - dwShowOnlineTick) > g_Config.dwConsoleShowUserCountTime then
begin
// if (GetTickCount() - dwShowOnlineTime) > 5000 then begin
dwShowOnlineTick := GetTickCount();
NoticeManager.LoadingNotice;
// MainOutMessage(TimeToStr(Now) + ' 在线数: ' + IntToStr(GetUserCount));
MainOutMessage('在线人数: ' + IntToStr(GetUserCount));
// UserCastle.Save;
g_CastleManager.Save;
end;
if (GetTickCount() - dwSendOnlineHumTime) > 10000 then
begin
dwSendOnlineHumTime := GetTickCount();
FrmIDSoc.SendOnlineHumCountMsg(GetOnlineHumCount);
// GuildManager.Run;
// UserCastle.Run;
// for i:=0 to DenySayMsgList.Count - 1 do begin
// //
// end;
end;
except
on E: Exception do
begin
MainOutMessage(sExceptionMsg);
MainOutMessage(E.Message);
end;
end;
// dwUsrTimeMin:=GetTickCount() - CalceTime;
// if dwUsrTimeMax < dwUsrTimeMin then dwUsrTimeMax:=dwUsrTimeMin;
end;
function TUserEngine.GetStdItem(nItemIdx: Integer): TItem; //004AC2F8
begin
Result := nil;
Dec(nItemIdx);
if (nItemIdx >= 0) and (StdItemList.Count > nItemIdx) then
begin
Result := StdItemList.Items[nItemIdx];
if Result.Name = '' then Result := nil;
end;
end;
function TUserEngine.GetStdItem(sItemName: string): TItem; //004AC348
var
i: Integer;
StdItem: TItem;
begin
Result := nil;
if sItemName = '' then Exit;
for i := 0 to StdItemList.Count - 1 do
begin
StdItem := StdItemList.Items[i];
if CompareText(StdItem.Name, sItemName) = 0 then
begin
Result := StdItem;
Break;
end;
end;
end;
function TUserEngine.GetStdItemWeight(nItemIdx: Integer): Integer; //004AC2B0
var
StdItem: TItem;
begin
Dec(nItemIdx);
if (nItemIdx >= 0) and (StdItemList.Count > nItemIdx) then
begin
StdItem := StdItemList.Items[nItemIdx];
Result := StdItem.Weight;
end else
begin
Result := 0;
end;
end;
function TUserEngine.GetStdItemName(nItemIdx: Integer): string; //004AC1AC
begin
Result := '';
Dec(nItemIdx);
if (nItemIdx >= 0) and (StdItemList.Count > nItemIdx) then
begin
Result := TItem(StdItemList.Items[nItemIdx]).Name;
end else Result := '';
end;
function TUserEngine.FindOtherServerUser(sName: string;
var nServerIndex): Boolean;
begin
Result := False;
end;
//004AEA00
procedure TUserEngine.CryCry(wIdent: Word; pMap: TEnvirnoment; nX, nY,
nWide: Integer; btFColor, btBColor: Byte; sMsg: string);
var
i: Integer;
PlayObject: TPlayObject;
begin
for i := 0 to m_PlayObjectList.Count - 1 do
begin
PlayObject := TPlayObject(m_PlayObjectList.Objects[i]);
if not PlayObject.m_boGhost and
(PlayObject.m_PEnvir = pMap) and
(PlayObject.m_boBanShout) and
(abs(PlayObject.m_nCurrX - nX) < nWide) and
(abs(PlayObject.m_nCurrY - nY) < nWide) then
begin
//PlayObject.SendMsg(nil,wIdent,0,0,$FFFF,0,sMsg);
PlayObject.SendMsg(nil, wIdent, 0, btFColor, btBColor, 0, sMsg);
end;
end;
end;
procedure TUserEngine.DemoRun;
begin
Run();
end;
function TUserEngine.MonGetRandomItems(mon: TBaseObject): Integer; //004AD2E8
var
i: Integer;
ItemList: TList;
iname: string;
MonItem: pTMonItem;
UserItem: pTUserItem;
StdItem: TItem;
Monster: pTMonInfo;
begin
ItemList := nil;
for i := 0 to MonsterList.Count - 1 do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -