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

📄 envir.pas

📁 继续更新AFT源代码 现在解决了无法登陆游戏的问题 用0504的dbserver就可以登陆了 去掉了绿字广告 降低内存占用HOO 去掉了大量的验证问题
💻 PAS
📖 第 1 页 / 共 4 页
字号:
//004B2A6C
function TEnvirnoment.GetNextPosition(sx, sy, ndir,nFlag:Integer;var snx:Integer;var sny:Integer):Boolean;
begin
   snx := sx;
   sny := sy;
   case nDir of
     DR_UP: if sny > nFlag - 1 then Dec(sny,nFlag);
     DR_DOWN: if sny < (m_nHeight - nFlag) then Inc(sny,nFlag);
     DR_LEFT: if snx > nFlag - 1 then Dec(snx,nFlag);
     DR_RIGHT: if snx < (m_nWidth - nFlag) then Inc(snx,nFlag);
     DR_UPLEFT: begin
       if (snx > nFlag - 1) and (sny > nFlag - 1) then begin
         Dec(snx,nFlag);
         Dec(sny,nFlag);
       end;
     end;
     DR_UPRIGHT: begin //004B2B77
       if (snx > nFlag - 1) and (sny < (m_nHeight - nFlag)) then begin
         Inc(snx,nFlag);
         Dec(sny,nFlag);
       end;
     end;
     DR_DOWNLEFT: begin //004B2BAC
       if (snx < (m_nWidth - nFlag)) and (sny > nFlag - 1) then begin
         Dec(snx,nFlag);
         Inc(sny,nFlag);
       end;
     end;
     DR_DOWNRIGHT: begin
       if (snx < (m_nWidth - nFlag)) and (sny < (m_nHeight - nFlag)) then begin
         Inc(snx,nFlag);
         Inc(sny,nFlag);
       end;
     end;
   end;
   if (snx = sx) and (sny = sy) then Result:=False
   else Result:=True;
     
end;

function TEnvirnoment.CanSafeWalk(nX, nY: Integer): Boolean; //004B609C
var
  I: Integer;
  MapCellInfo:pTMapCellinfo;
  OSObject:pTOSObject;
begin
  Result:=True;
  if GetMapCellInfo(nX,nY,MapCellInfo) and (MapCellInfo.ObjList <> nil)then begin
    for I := MapCellInfo.ObjList.Count -1 downto 0 do begin
      OSObject:=MapCellInfo.ObjList.Items[i];
      if OSObject.btType = OS_EVENTOBJECT then begin
        if TEvent(OSObject.CellObj).m_nDamage > 0 then Result:=False;
      end;
    end;
  end;
end;

function TEnvirnoment.ArroundDoorOpened(nX, nY: Integer): Boolean; //004B6B48
var
  I: Integer;
  Door:pTDoorInfo;
ResourceString
  sExceptionMsg = '[Exception] TEnvirnoment::ArroundDoorOpened ';
begin
  Result:=True;
  try
    for I := 0 to m_DoorList.Count - 1 do begin
      Door:=m_DoorList.Items[i];
      if (abs(Door.nX - nX) <= 1) and ((abs(Door.nY - nY) <= 1)) then begin
        if not Door.Status.boOpened then begin
          Result:=False;
          break;
        end;
      end;
    end;
  except
    MainOutMessage(sExceptionMsg);
  end;
end;

function TEnvirnoment.GetMovingObject(nX,nY:Integer;boFlag:Boolean): Pointer; //004B5838
var
  I: Integer;
  MapCellInfo:pTMapCellinfo;
  OSObject:pTOSObject;
  BaseObject:TBaseObject;
begin
  Result:=nil;
  if GetMapCellInfo(nX,nY,MapCellInfo) and (MapCellInfo.ObjList <> nil)  then begin
    for I := 0 to MapCellInfo.ObjList.Count - 1 do begin
      OSObject:=MapCellInfo.ObjList.Items[i];
      if OSObject=nil then continue;
      if OSObject.btType = OS_MOVINGOBJECT then begin
        BaseObject:=TBaseObject(OSObject.CellObj);
        if ((BaseObject <> nil) and
           (not BaseObject.m_boGhost) and
           (BaseObject.bo2B9)) and
           ((not boFlag) or (not BaseObject.m_boDeath)) then begin

          Result:=BaseObject;
          break;
        end;
      end;
    end;
  end;
end;

function TEnvirnoment.GetQuestNPC(BaseObject: TObject;sCharName,sStr: String;boFlag:Boolean): TObject; //004B6E4C
var
  I: Integer;
  MapQuestFlag:pTMapQuestInfo;
  nFlagValue:Integer;
  bo1D:Boolean;
begin
  Result:=nil;
  for I := 0 to m_QuestList.Count - 1 do begin
    MapQuestFlag:=m_QuestList.Items[i];
    nFlagValue:=TBaseObject(BaseObject).GetQuestFalgStatus(MapQuestFlag.nFlag);
    if nFlagValue = MapQuestFlag.nValue then begin
      if (boFlag = MapQuestFlag.bo10) or (not boFlag) then begin
        bo1D:=False;
        if (MapQuestFlag.s08 <> '') and (MapQuestFlag.s0C <> '') then begin
          if (MapQuestFlag.s08 = sCharName) and (MapQuestFlag.s0C = sStr) then
            bo1D:=True;
        end;
        if (MapQuestFlag.s08 <> '') and (MapQuestFlag.s0C = '') then begin
          if (MapQuestFlag.s08 = sCharName) and (sStr = '') then
            bo1D:=True;
        end;
        if (MapQuestFlag.s08 = '') and (MapQuestFlag.s0C <> '') then begin
          if (MapQuestFlag.s0C = sStr) then
            bo1D:=True;
        end;
        if bo1D then begin
          Result:=MapQuestFlag.NPC;
          break;
        end;
      end;
    end;
  end;
end;

function TEnvirnoment.GetItemEx(nX, nY: Integer;
  var nCount: Integer): Pointer; //004B5C10
var
  I: Integer;
  MapCellInfo:pTMapCellinfo;
  OSObject:pTOSObject;
  BaseObject:TBaseObject;
begin
  Result:=nil;
  nCount:=0;
  bo2C:=False;
  if GetMapCellInfo(nX,nY,MapCellInfo) and (MapCellInfo.chFlag = 0) then begin
    bo2C:=True;
    if MapCellInfo.ObjList <> nil then begin
      for I := 0 to MapCellInfo.ObjList.Count - 1 do begin
        OSObject:=MapCellInfo.ObjList.Items[i];
        if OSObject=nil then continue;
        if OSObject.btType = OS_ITEMOBJECT then begin
          Result:=Pointer(OSObject.CellObj);
          Inc(nCount);
        end;
        if OSObject.btType = OS_GATEOBJECT then begin
          bo2C:=False;
        end;
        if OSObject.btType = OS_MOVINGOBJECT then begin
          BaseObject:=TBaseObject(OSObject.CellObj);
          if not BaseObject.m_boDeath then
            bo2C:=False;
        end;
      end;
    end;
  end;

end;

function TEnvirnoment.GetDoor(nX, nY: Integer): pTDoorInfo; //004B6ACC
var
  I: Integer;
  Door:pTDoorInfo;
begin
  Result:=nil;
  for I := 0 to m_DoorList.Count - 1 do begin
    Door:=m_DoorList.Items[i];
    if (Door.nX = nX) and (Door.nY =nY) then begin
      Result:=Door;
      exit;
    end;
  end;
end;

function TEnvirnoment.IsValidObject(nX, nY, nRage: Integer; BaseObject: TObject): Boolean; //004B5A3C
var
  nXX,nYY,I:Integer;
  MapCellInfo:pTMapCellinfo;
  OSObject:pTOSObject;
begin
  Result:=False;
  for nXX:= nX - nRage to nX + nRage do begin
    for nYY:= nY - nRage to nY + nRage do begin
      if GetMapCellInfo(nX,nY,MapCellInfo) and (MapCellInfo.ObjList <> nil) then begin
        for I := 0 to MapCellInfo.ObjList.Count - 1 do begin
          OSObject:=MapCellInfo.ObjList.Items[i];
          if OSObject.CellObj = BaseObject then begin
            Result:=True;
            exit;
          end;
        end;
      end;
    end;
  end;
end;

function TEnvirnoment.GetRangeBaseObject(nX, nY, nRage: Integer; boFlag: Boolean;
  BaseObjectList: TList): Integer; //004B59C0
var
  nXX,nYY:Integer;
begin
  for nXX:= nX - nRage to nX + nRage do begin
    for nYY:= nY - nRage to nY + nRage do begin
      GetBaseObjects(nXX,nYY,boFlag,BaseObjectList);
    end;
  end;
  Result:=BaseObjectList.Count;
end;
//boFlag 是否包括死亡对象
//FALSE 包括死亡对象
//TRUE  不包括死亡对象
function TEnvirnoment.GetBaseObjects(nX, nY: Integer; boFlag: Boolean;
  BaseObjectList: TList): Integer; //004B58F8
var
  I: Integer;
  MapCellInfo:pTMapCellinfo;
  OSObject:pTOSObject;
  BaseObject:TBaseObject;
begin
  if GetMapCellInfo(nX,nY,MapCellInfo) and (MapCellInfo.ObjList <> nil) then begin
    for I := 0 to MapCellInfo.ObjList.Count - 1 do begin
      OSObject:=MapCellInfo.ObjList.Items[i];
      if OSObject=nil then continue;
      if OSObject.btType = OS_MOVINGOBJECT then begin
        BaseObject:=TBaseObject(OSObject.CellObj);
        if BaseObject <> nil then begin
          if not BaseObject.m_boGhost and BaseObject.bo2B9 then begin
            if not boFlag or not BaseObject.m_boDeath then
              BaseObjectList.Add(BaseObject);
          end;
        end;
      end;
    end;
  end;
  Result:=BaseObjectList.Count;
end;

function TEnvirnoment.GetEvent(nX,nY:Integer): TObject; //004B5D24
var
  I: Integer;
  MapCellInfo:pTMapCellinfo;
  OSObject:pTOSObject;
begin
  Result:=nil;
  bo2C:=False;
  if GetMapCellInfo(nX,nY,MapCellInfo) and (MapCellInfo.ObjList <> nil) then begin
    for I := 0 to MapCellInfo.ObjList.Count - 1 do begin
      OSObject:=MapCellInfo.ObjList.Items[i];
      if OSObject.btType = OS_EVENTOBJECT then begin
        Result:=OSObject.CellObj;
      end;
    end;
  end;
end;

procedure TEnvirnoment.SetMapXYFlag(nX, nY: Integer; boFlag: Boolean);//004B5E8C
var
  MapCellInfo:pTMapCellinfo;
begin
  if GetMapCellInfo(nX,nY,MapCellInfo) then begin
    if boFlag then MapCellInfo.chFlag:=0
    else MapCellInfo.chFlag:=2;
  end;
end;

procedure TEnvirnoment.SetMapXYFlagx(nX, nY,nFlag: Integer);//004B5E8C
var
  MapCellInfo:pTMapCellinfo;
begin
  if GetMapCellInfo(nX,nY,MapCellInfo) then begin
   MapCellInfo.chFlag:=nFlag;
  end;
end;


function TEnvirnoment.CanFly(nsX, nsY, ndX, ndY: integer): Boolean; //004B600C
var
  r28,r30:Real;
  n14,n18,n1C:Integer;
begin
  Result:=True;
  r28:=(ndX - nsX) / 1.0e1;
  r30:=(ndY - ndY) / 1.0e1;
  n14:=0;
  while (True) do begin
    n18:=ROUND(nsX + r28);
    n1C:=ROUND(nsY + r30);
    if not CanWalk(n18,n1C,True) then begin
      Result:=False;
      break;
    end;
    Inc(n14);
    if n14 >= 10 then break;      
  end;
end;



function TEnvirnoment.GetXYHuman(nMapX, nMapY: Integer): Boolean;
var
  I: Integer;
  MapCellInfo:pTMapCellinfo;
  OSObject:pTOSObject;
  BaseObject:TBaseObject;
begin
  Result:=False;
  if GetMapCellInfo(nMapX,nMapY,MapCellInfo) and (MapCellInfo.ObjList <> nil) then begin
    for I := 0 to MapCellInfo.ObjList.Count - 1 do begin
      OSObject:=MapCellInfo.ObjList.Items[i];
      if OSObject=nil then continue;
      if OSObject.btType = OS_MOVINGOBJECT then begin
        BaseObject:=TBaseObject(OSObject.CellObj);
        if BaseObject.m_btRaceServer = RC_PLAYOBJECT then begin
          Result:=True;
          break;
        end;          
      end;
    end;
  end;
end;

function TEnvirnoment.sub_4B5FC8(nX, nY: Integer): Boolean;//0x004B5FC8
var
  MapCellInfo:pTMapCellinfo;
begin
  Result:=True;
  if GetMapCellInfo(nX,nY,MapCellInfo) and (MapCellInfo.chFlag = 2) then
    Result:=False;
end;

function TEnvirnoment.GetEnvirInfo: String;
var
  sMsg:string;
begin
  sMsg:='地图名:%s(%s) DAY:%s DARK:%s SAFE:%s FIGHT:%s FIGHT3:%s QUIZ:%s NORECONNECT:%s(%s) MUSIC:%s(%d) EXPRATE:%s(%f) PKWINLEVEL:%s(%d) PKLOSTLEVEL:%s(%d) PKWINEXP:%s(%d) PKLOSTEXP:%s(%d) DECHP:%s(%d/%d) INCHP:%s(%d/%d)';
  sMsg:=sMsg +' DECGAMEGOLD:%s(%d/%d) INCGAMEGOLD:%s(%d/%d) INCGAMEPOINT:%s(%d/%d) RUNHUMAN:%s RUNMON:%s NEEDHOLE:%s NORECALL:%s NOGUILDRECALL:%s NODEARRECALL:%s NOMASTERRECALL:%s NODRUG:%s MINE:%s NOPOSITIONMOVE:%s';
  Result:=format(sMsg,[sMapName,
                       sMapDesc,
                       BoolToCStr(m_boDAY),
                       BoolToCStr(m_boDARK),
                       BoolToCStr(m_boSAFE),
                       BoolToCStr(m_boFightZone),
                       BoolToCStr(m_boFight3Zone),
                       BoolToCStr(m_boQUIZ),
                       BoolToCStr(m_boNORECONNECT),sNoReconnectMap,
                       BoolToCStr(m_boMUSIC),m_nMUSICID,
                       BoolToCStr(m_boEXPRATE),m_nEXPRATE / 100,
                       BoolToCStr(m_boPKWINLEVEL),m_nPKWINLEVEL,
                       BoolToCStr(m_boPKLOSTLEVEL),m_nPKLOSTLEVEL,
                       BoolToCStr(m_boPKWINEXP),m_nPKWINEXP,
                       BoolToCStr(m_boPKLOSTEXP),m_nPKLOSTEXP,
                       BoolToCStr(m_boDECHP),m_nDECHPTIME,m_nDECHPPOINT,
                       BoolToCStr(m_boINCHP),m_nINCHPTIME,m_nINCHPPOINT,
                       BoolToCStr(m_boDECGAMEGOLD),m_nDECGAMEGOLDTIME,m_nDECGAMEGOLD,
                       BoolToCStr(m_boINCGAMEGOLD),m_nINCGAMEGOLDTIME,m_nINCGAMEGOLD,
                       BoolToCStr(m_boINCGAMEPOINT),m_nINCGAMEPOINTTIME,m_nINCGAMEPOINT,
                       BoolToCStr(m_boRUNHUMAN),
                       BoolToCStr(m_boRUNMON),
                       BoolToCStr(m_boNEEDHOLE),
                       BoolToCStr(m_boNORECALL),
                       BoolToCStr(m_boNOGUILDRECALL),
                       BoolToCStr(m_boNODEARRECALL),
                       BoolToCStr(m_boNOMASTERRECALL),
                       BoolToCStr(m_boNODRUG),
                       BoolToCStr(m_boMINE),
                       BoolToCStr(m_boNOPOSITIONMOVE)
                       ]);
end;

procedure TEnvirnoment.AddObject(nType: Integer);
begin
  case nType of
    0: Inc(m_nHumCount);
    1: Inc(m_nMonCount);
  end;
end;

procedure TEnvirnoment.DelObjectCount(BaseObject:TObject);
var
  btRaceServer:Byte;
begin
  btRaceServer:=TBaseObject(BaseObject).m_btRaceServer;
  if btRaceServer = RC_PLAYOBJECT then dec(m_nHumCount);
  if btRaceServer >= RC_ANIMAL then dec(m_nMonCount);
end;

procedure TMapManager.Run;
begin

end;

end.

⌨️ 快捷键说明

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