⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usrengn.pas

📁 继续更新AFT源代码 现在解决了无法登陆游戏的问题 用0504的dbserver就可以登陆了 去掉了绿字广告 降低内存占用HOO 去掉了大量的验证问题
💻 PAS
📖 第 1 页 / 共 5 页
字号:

                     case LineNoticeMsg[1] of
                       'R': PlayObject.SysMsg(Copy(LineNoticeMsg,2,length(LineNoticeMsg) - 1),c_Red,t_Notice);
                       'G': PlayObject.SysMsg(Copy(LineNoticeMsg,2,length(LineNoticeMsg) - 1),c_Green,t_Notice);
                       'B': PlayObject.SysMsg(Copy(LineNoticeMsg,2,length(LineNoticeMsg) - 1),c_Blue,t_Notice);
                       else begin
                         PlayObject.SysMsg(LineNoticeMsg,TMsgColor(g_Config.nLineNoticeColor){c_Blue},t_Notice);
                       end;
                     end;
                   end;
                   Inc(PlayObject.m_nShowLineNoticeIdx);
                   if (LineNoticeList.Count <= PlayObject.m_nShowLineNoticeIdx) then
                     PlayObject.m_nShowLineNoticeIdx:=0;
                 end;

                 PlayObject.Run();

                 if not FrontEngine.IsFull and((GetTickCount() - PlayObject.m_dwSaveRcdTick) > g_Config.dwSaveHumanRcdTime) then begin
                   PlayObject.m_dwSaveRcdTick:=GetTickCount();

                   PlayObject.DealCancelA();

                   SaveHumanRcd(PlayObject);

                 end;
               end;//004B119F
             except
               on e: Exception do begin
                 MainOutMessage(format(sExceptionMsg5,[0]));
                 MainOutMessage(E.Message);raise;
               end;
               
             end;
           end;
         end else begin//if not PlayObject.boIsGhost then begin  //CODE:004B11C5
           try
             m_PlayObjectList.Delete(nIdx);
             nCheck30:=2;

             PlayObject.Disappear();

             nCheck30:=3;
           except
             on e: Exception do begin
               MainOutMessage(format(sExceptionMsg6,[nCheck30]));
               MainOutMessage(E.Message);   raise;
             end;
             
           end;//004B1232
           try
             //如果人物死亡
            AddToHumanFreeList(PlayObject);

             nCheck30:=4;
             PlayObject.DealCancelA();

           //  SaveHumanRcd(PlayObject);
         //   if PlayObject.sYsnameMaster='' then  begin//如果是人物的话要下线
             RunSocket.CloseUser(PlayObject.m_nGateIdx,PlayObject.m_nSocket);   //        解决1.9 版本复活功能

          //   MainOutMessage('xjs:if sYsnameMaster=0 then RunSocket.CloseUser');
           
    //         PlayObject.MakeGhost;

           except
             MainOutMessage(format(sExceptionMsg7,[nCheck30]));
           end;//004B12BA

           SendServerGroupMsg(SS_202,nServerIndex,PlayObject.m_sCharName);
           Continue;
         end;
       end;//if (dwTime14 - PlayObject.dw368) > PlayObject.dw36C then begin
       Inc(nIdx);//004B12E6
       if (GetTickCount - dwCheckTime) > g_dwHumLimit then begin
         boCheckTimeLimit:=True;
         m_nProcHumIDx:=nIdx;
         break;
       end;
     end;//while True do begin
     if not boCheckTimeLimit then m_nProcHumIDx:=0;
  except
   // MainOutMessage(sExceptionMsg8);
       on e: Exception do begin
        MainOutMessage(format(sExceptionMsg8,[nCheck30]));
        MainOutMessage(E.Message);    raise;
       end;
       
  end;
  Inc(nProcessHumanLoopTime);
  g_nProcessHumanLoopTime:=nProcessHumanLoopTime;
  if m_nProcHumIDx = 0 then begin
    nProcessHumanLoopTime:=0;
    g_nProcessHumanLoopTime:=nProcessHumanLoopTime;
    dwUsrRotTime:=GetTickCount - g_dwUsrRotCountTick;
    dwUsrRotCountMin:=dwUsrRotTime;
    g_dwUsrRotCountTick:=GetTickCount();
    if dwUsrRotCountMax < dwUsrRotTime then dwUsrRotCountMax:=dwUsrRotTime;
  end;
  g_nHumCountMin:=GetTickCount - dwCheckTime;
  if g_nHumCountMax < g_nHumCountMin then g_nHumCountMax:=g_nHumCountMin;
   asm
      NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP;
   end;  
end;

procedure TUserEngine.ProcessMerchants;//004B1B8C
var
  dwRunTick,dwCurrTick:LongWord;
  i:integer;
  MerchantNPC:TMerchant;
  boProcessLimit:Boolean;
ResourceString
  sExceptionMsg = '[Exception] TUserEngine::ProcessMerchants';
begin
  dwRunTick:=GetTickCount();
  boProcessLimit:=False;
  try
    dwCurrTick:=GetTickCount();
    m_MerchantList.Lock;
    try
      for i:=nMerchantPosition to m_MerchantList.Count -1 do begin
        MerchantNPC:=m_MerchantList.Items[i];
        if not MerchantNPC.m_boGhost then begin
          if Integer(dwCurrTick - MerchantNPC.m_dwRunTick) > MerchantNPC.m_nRunTime then begin
            if (GetTickCount - MerchantNPC.m_dwSearchTick) > MerchantNPC.m_dwSearchTime then begin
              MerchantNPC.m_dwSearchTick:=GetTickCount();
              MerchantNPC.SearchViewRange();
            end;//004B1C3C
            if Integer(dwCurrTick - MerchantNPC.m_dwRunTick) > MerchantNPC.m_nRunTime then begin
              MerchantNPC.m_dwRunTick:=dwCurrTick;
              MerchantNPC.Run;  {FFFFB}
            end;
          end;//004B1C6B
        end else begin//004B1C6B
          if (GetTickCount - MerchantNPC.m_dwGhostTick) > 60 * 1000 then begin
            MerchantNPC.Free;
            m_MerchantList.Delete(i);
            break;
          end;
        end;
        if (GetTickCount - dwRunTick) > g_dwNpcLimit then begin
          nMerchantPosition:=i;
          boProcessLimit:=True;
          Break;
        end;//004B1C8C
      end;//004B1C98
    finally
      m_MerchantList.UnLock;
    end;
    if not boProcessLimit then begin
      nMerchantPosition:=0;
    end;//004B1CA6
  except
    MainOutMessage(sExceptionMsg);
  end;
  dwProcessMerchantTimeMin:=GetTickCount - dwRunTick;
  if dwProcessMerchantTimeMin > dwProcessMerchantTimeMax then dwProcessMerchantTimeMax:=dwProcessMerchantTimeMin;
  if dwProcessNpcTimeMin > dwProcessNpcTimeMax then dwProcessNpcTimeMax:=dwProcessNpcTimeMin;
end;

procedure TUserEngine.ProcessMissions;
 var Startuphum:Tplayobject;
     sMapName:string;
     nSafePoint,nSafeX,nSafeY:integer;
     Envir:TEnvirnoment;
     SafeZoneLight:TSafeZoneLight;
     nx,ny,i:integer;
begin
if g_bostartup then begin

  if g_ManageNPC <> nil then begin
    Startuphum:=Tplayobject.Create;
    if Startuphum<>nil then begin
    Startuphum.m_sCharName:='Startup';
    Startuphum.m_sMapName:='0';
    Startuphum.m_PEnvir:= g_MapManager.FindMap(Startuphum.m_sMapName);
    g_ManageNPC.GotoLable(Startuphum,'@startup',False);
    g_bostartup:=false;
    Startuphum.Free;
    end;
  end;

    if g_Config.boUseSafeZoneLight then begin
    try
    g_StartPointList.Lock;
    for I := 0 to g_StartPointList.Count - 1 do begin
      sMapName:=g_StartPointList.Strings[i];
      nSafePoint:=Integer(g_StartPointList.Objects[i]);
      nSafeX:=LoWord(nSafePoint);
      nSafeY:=HiWord(nSafePoint);
      Envir:=g_MapManager.FindMap(sMapName);
      if Envir=nil then Continue;
    /////////////
      nY:= nSafeY-g_Config.nSafeZoneSize  ;
      nX:= nSafeX-g_Config.nSafeZoneSize ;
      while nX<  nSafeX+g_Config.nSafeZoneSize do begin

         if Envir.GetEvent(nX,nY) = nil then begin
           SafeZoneLight:=TSafeZoneLight.Create(Envir,nX,nY,ET_HOLYCURTAIN,10*24*60*60*1000 ,0);
           g_EventManager.AddEvent(SafeZoneLight);
         end;
         inc(nx,2);
      end;  //while
      nx:= nSafeX+g_Config.nSafeZoneSize;
      if (Envir.GetEvent(nx,ny) = nil) and Envir.CanWalk(nX, nY,false) then begin
       SafeZoneLight:=TSafeZoneLight.Create(Envir,nX,nY,ET_HOLYCURTAIN,10*24*60*60*1000 ,0);
       g_EventManager.AddEvent(SafeZoneLight);
      end;


      nY:= nSafeY+g_Config.nSafeZoneSize  ;
      nX:= nSafeX-g_Config.nSafeZoneSize ;
      while nX<  nSafeX+g_Config.nSafeZoneSize do begin

         if (Envir.GetEvent(nX,nY) = nil) and Envir.CanWalk(nX, nY,false) then begin
           SafeZoneLight:=TSafeZoneLight.Create(Envir,nX,nY,ET_HOLYCURTAIN,10*24*60*60*1000 ,0);
           g_EventManager.AddEvent(SafeZoneLight);
         end;
         inc(nx,2);
      end;  //while
      nx:= nSafeX+g_Config.nSafeZoneSize ;
      if (Envir.GetEvent(nx,ny) = nil) and Envir.CanWalk(nX, nY,false) then begin
       SafeZoneLight:=TSafeZoneLight.Create(Envir,nX,nY,ET_HOLYCURTAIN,10*24*60*60*1000 ,0);
       g_EventManager.AddEvent(SafeZoneLight);
      end;


   // ==============
      nY:= nSafeY-g_Config.nSafeZoneSize  ;
      nX:= nSafeX-g_Config.nSafeZoneSize ;
      while ny<  nSafey+g_Config.nSafeZoneSize do begin

         if (Envir.GetEvent(nx,ny) = nil) and Envir.CanWalk(nX, nY,false) then begin
           SafeZoneLight:=TSafeZoneLight.Create(Envir,nX,nY,ET_HOLYCURTAIN,10*24*60*60*1000 ,0);
           g_EventManager.AddEvent(SafeZoneLight);
         end;
         inc(ny,4);
      end;  //while
      ny:= nSafey+g_Config.nSafeZoneSize ;
      if (Envir.GetEvent(nx,ny) = nil) and Envir.CanWalk(nX, nY,false) then begin
       SafeZoneLight:=TSafeZoneLight.Create(Envir,nX,nY,ET_HOLYCURTAIN,10*24*60*60*1000 ,0);
       g_EventManager.AddEvent(SafeZoneLight);
      end;



      nY:= nSafeY-g_Config.nSafeZoneSize  ;
      nX:= nSafeX+g_Config.nSafeZoneSize ;
      while ny<  nSafey+g_Config.nSafeZoneSize do begin

         if (Envir.GetEvent(nx,ny) = nil) and Envir.CanWalk(nX, nY,false) then begin
           SafeZoneLight:=TSafeZoneLight.Create(Envir,nX,nY,ET_HOLYCURTAIN,10*24*60*60*1000 ,0);
           g_EventManager.AddEvent(SafeZoneLight);
         end;
         inc(ny,4);
      end;  //while

      ny:= nSafey+g_Config.nSafeZoneSize  ;
      if (Envir.GetEvent(nx,ny) = nil) and Envir.CanWalk(nX, nY,false) then begin
       SafeZoneLight:=TSafeZoneLight.Create(Envir,nX,nY,ET_HOLYCURTAIN,10*24*60*60*1000 ,0);
       g_EventManager.AddEvent(SafeZoneLight);
      end;

   end; //for
   finally
    g_StartPointList.UnLock;
   end;
  end;//if  g_Config.boUseSafeZoneLight
end;
end;

procedure TUserEngine.ProcessMonsters;
  function GetZenTime(dwTime:LongWord):LongWord;
  var
    d10:Double;
  begin
    if dwTime < 30 * 60 * 1000 then begin
      d10:= (GetUserCount - g_Config.nUserFull) / g_Config.nZenFastStep;
      if d10 > 0 then begin
        if d10 > 6 then d10:=6;
        Result:= dwTime - Round((dwTime / 10) * d10)
      end else begin//4B1616
        Result:=dwTime;
      end;
    end else begin
      Result:=dwTime;
    end;
      Result:=dwTime;
  end;
//004B1638
var
  dwCurrentTick    :LongWord;
  dwRunTick        :LongWord;
  dwMonProcTick    :LongWord;
  MonGen           :pTMonGenInfo;
  nGenCount        :Integer;
  nGenModCount     :Integer;
  boProcessLimit   :Boolean;
  boRegened        :Boolean;
  I                :Integer;
  nProcessPosition :Integer;
  Monster          :TAnimalObject;
  tCode            :Integer;
  tormoncount      :integer;
ResourceString
  sExceptionMsg = '[Exception] TUserEngine::ProcessMonsters %s %d';
begin
  tCode     := 0;
  dwRunTick := GetTickCount();
  try
    tCode          := 0;
    boProcessLimit := False;
    dwCurrentTick  := GetTickCount();    // dwCurrentTick
    MonGen         := nil;
    //刷新怪物开始

    if ((GetTickCount - dwRegenMonstersTick) > g_Config.dwRegenMonstersTime) then begin
      dwRegenMonstersTick:=GetTickCount();
      if m_nCurrMonGen < m_MonGenList.Count then begin
        MonGen:=m_MonGenList.Items[m_nCurrMonGen];
      end;

      if m_nCurrMonGen < m_MonGenList.Count - 1 then begin
        Inc(m_nCurrMonGen);
      end else begin
        m_nCurrMonGen:=0;
      end;//004B1718

      if (MonGen <> nil) and (MonGen.sMonName <> '') and not g_Config.boVentureServer then begin
        if (MonGen.dwStartTick = 0) or ((GetTickCount - MonGen.dwStartTick) >  MonGen.dwZenTime)  then begin   //  GetZenTime(MonGen.dwZenTime))
          nGenCount:=GetGenMonCount(MonGen);
          boRegened:=True;
          if g_Config.nMonGenRate <= 0 then g_Config.nMonGenRate := 10; //防止除法错误
          nGenModCount:=_MAX(1,ROUND(_MAX(1,MonGen.nCount) / (g_Config.nMonGenRate / 10)));
          if nGenModCount > nGenCount then begin //0806 增加 控制刷怪数量比例
            tormoncount:= nGenModCount - nGenCount;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -