📄 envir.pas
字号:
PTMapItem(pTOSObject(MapCellInfo.ObjList.Items[i]).CellObj);
if MapItem.Name = sSTRING_GOLDNAME then
begin
nGoldCount := MapItem.Count + PTMapItem(pRemoveObject).Count;
if nGoldCount <= 2000 then
begin
MapItem.Count := nGoldCount;
MapItem.Looks := GetGoldShape(nGoldCount);
MapItem.AniCount := 0;
MapItem.Reserved := 0;
OSObject.dwAddTime := GetTickCount();
Result := MapItem;
bo1E := True;
end;
end;
end;
end; //004B653D
end; //004B653D
if not bo1E and (MapCellInfo.ObjList.Count >= 5) then
begin
Result := nil;
bo1E := True;
end; //004B6558
end; //004B6558
if btType = OS_EVENTOBJECT then
begin
end;
end; //004B655C
if not bo1E then
begin
New(OSObject);
if OSObject<>nil then
Begin
OSObject.btType := btType;
OSObject.CellObj := pRemoveObject;
OSObject.dwAddTime := GetTickCount();
MapCellInfo.ObjList.Add(OSObject);
Result := Pointer(pRemoveObject);
if (btType = OS_MOVINGOBJECT) and (not
TBaseObject(pRemoveObject).m_boAddToMaped) then
begin
TBaseObject(pRemoveObject).m_boDelFormMaped := False;
TBaseObject(pRemoveObject).m_boAddToMaped := True;
btRaceServer := TBaseObject(pRemoveObject).m_btRaceServer;
if btRaceServer = RC_PLAYOBJECT then
Inc(m_nHumCount);
if btRaceServer >= RC_ANIMAL then
Inc(m_nMonCount);
end;
End;
end; //004B659F
end; //004B659F
except
MainOutMessage(sExceptionMsg);
end;
end;
procedure TEnvirnoment.AddDoorToMap(); //004B6A74
var
i : Integer;
Door : pTDoorInfo;
begin
for i := 0 to m_DoorList.Count - 1 do
begin
Door := m_DoorList.Items[i];
AddToMap(Door.nX, Door.nY, OS_DOOR, TObject(Door));
end;
end;
function TEnvirnoment.GetMapCellInfo(nX, nY: Integer; var MapCellInfo:
pTMapCellinfo): Boolean; //004B57D8
begin
MapCellInfo := nil;
Result:=False;
if (nX >= 0) and (nX < m_nWidth) and (nY >= 0) and (nY < m_nHeight) then
begin
MapCellInfo := @MapCellArray[nX * m_nHeight + nY];
if MapCellInfo<>nil then
Result := True;
end
else
begin //004B5829
Result := False;
end;
end;
function TEnvirnoment.MoveToMovingObject(nCX, nCY: Integer; Cert: TObject; nX,
nY: Integer; boFlag: Boolean): Integer; //004B612C
var
MapCellInfo : pTMapCellinfo;
BaseObject : TBaseObject;
OSObject : pTOSObject;
i : Integer;
bo1A : Boolean;
resourcestring
sExceptionMsg =
'[Exception] TEnvirnoment::MoveToMovingObject';
label
Loop, Over;
begin
Result := 0;
try
bo1A := True;
if not boFlag and GetMapCellInfo(nX, nY, MapCellInfo) then
begin
if MapCellInfo.chFlag = 0 then
begin
if MapCellInfo.ObjList <> nil then
begin
for i := 0 to MapCellInfo.ObjList.Count - 1 do
begin //004B61AD
if pTOSObject(MapCellInfo.ObjList.Items[i]).btType = OS_MOVINGOBJECT
then
begin
BaseObject :=
TBaseObject(pTOSObject(MapCellInfo.ObjList.Items[i]).CellObj);
if BaseObject <> nil then
begin //004B61DB
if not BaseObject.m_boGhost
and BaseObject.bo2B9
and not BaseObject.m_boDeath
and not BaseObject.m_boFixedHideMode
and not BaseObject.m_boObMode then
begin
bo1A := False;
break;
end;
end; //004B6223
end; //004B6223
end; //004B622D
end; //004B6238
end
else
begin //004B622D if MapCellInfo.chFlag = 0 then begin
Result := -1;
bo1A := False;
end; //004B6238
end; //004B6238
if bo1A then
begin //004B6238
if GetMapCellInfo(nX, nY, MapCellInfo) and (MapCellInfo.chFlag <> 0) then
begin
Result := -1;
end
else
begin //004B6265
if GetMapCellInfo(nCX, nCY, MapCellInfo) and (MapCellInfo.ObjList <> nil)
then
begin
i := 0;
while (True) do
begin
if MapCellInfo.ObjList.Count <= i then
break;
OSObject := MapCellInfo.ObjList.Items[i];
if OSObject.btType = OS_MOVINGOBJECT then
begin
if TBaseObject(OSObject.CellObj) = TBaseObject(Cert) then
begin
MapCellInfo.ObjList.Delete(i);
DisPose(OSObject);
if MapCellInfo.ObjList.Count > 0 then
Continue;
MapCellInfo.ObjList.Free;
MapCellInfo.ObjList := nil;
break;
end;
end;
Inc(i);
end;
end; //4B6311
if GetMapCellInfo(nX, nY, MapCellInfo) then
begin
if (MapCellInfo.ObjList = nil) then
begin
MapCellInfo.ObjList := TMyList.create;
end;
New(OSObject);
if OSObject<>nil then
Begin
OSObject.btType := OS_MOVINGOBJECT;
OSObject.CellObj := Cert;
OSObject.dwAddTime := GetTickCount;
MapCellInfo.ObjList.Add(OSObject);
Result := 1;
End;
end; //004B6383
end; //004B6383
end; //004B6383
except
on E: Exception do
begin
MainOutMessage(sExceptionMsg);
{$IF SHowErr = 1}
MainOutMessage(E.Message);
{$IFEND}
end;
end;
// pMapCellInfo = GetMapCellInfo(nX, nY);
end;
//======================================================================
//检查地图指定座标是否可以移动
//boFlag 如果为TRUE 则忽略座标上是否有角色
//返回值 True 为可以移动,False 为不可以移动
//======================================================================
function TEnvirnoment.CanWalk(nX, nY: Integer; boFlag: Boolean): Boolean;
//004B5ED0
var
MapCellInfo : pTMapCellinfo;
OSObject : pTOSObject;
BaseObject : TBaseObject;
i : Integer;
begin
Result := False;
if GetMapCellInfo(nX, nY, MapCellInfo) and (MapCellInfo.chFlag = 0) then
begin
Result := True;
if not boFlag 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_MOVINGOBJECT then
begin
BaseObject := TBaseObject(OSObject.CellObj);
if BaseObject <> nil then
begin
if not BaseObject.m_boGhost
and BaseObject.bo2B9
and not BaseObject.m_boDeath
and not BaseObject.m_boFixedHideMode
and not BaseObject.m_boObMode then
begin
Result := False;
break;
end;
end; //004B5FB5
end; //004B5FB5
end;
end;
end; //004B5FBD
end;
//======================================================================
//检查地图指定座标是否可以移动
//boFlag 如果为TRUE 则忽略座标上是否有角色
//返回值 True 为可以移动,False 为不可以移动
//======================================================================
function TEnvirnoment.CanWalkOfItem(nX, nY: Integer; boFlag, boItem: Boolean):
Boolean; //004B5ED0
var
MapCellInfo : pTMapCellinfo;
OSObject : pTOSObject;
BaseObject : TBaseObject;
i : Integer;
begin
Result := True;
if GetMapCellInfo(nX, nY, MapCellInfo) and (MapCellInfo.chFlag = 0) then
begin
// Result:=True;
if (MapCellInfo.ObjList <> nil) then
begin
for i := 0 to MapCellInfo.ObjList.Count - 1 do
begin
OSObject := MapCellInfo.ObjList.Items[i];
if not boFlag and (OSObject.btType = OS_MOVINGOBJECT) then
begin
BaseObject := TBaseObject(OSObject.CellObj);
if BaseObject <> nil then
begin
if not BaseObject.m_boGhost
and BaseObject.bo2B9
and not BaseObject.m_boDeath
and not BaseObject.m_boFixedHideMode
and not BaseObject.m_boObMode then
begin
Result := False;
break;
end;
end; //004B5FB5
end; //004B5FB5
if not boItem and (OSObject.btType = OS_ITEMOBJECT) then
begin
Result := False;
break;
end;
end;
end;
end; //004B5FBD
end;
function TEnvirnoment.CanWalkEx(nX, nY: Integer; boFlag: Boolean;PlayObject:TObject=nil): Boolean;
//004B5ED0
var
MapCellInfo : pTMapCellinfo;
OSObject : pTOSObject;
BaseObject : TBaseObject;
i : Integer;
Castle : TUserCastle;
canRun : Integer;
begin
Result := False;
canrun:=-1;
if PlayObject<>nil then
CanRun:=TPlayObject(PlayObject).CanRun;
if GetMapCellInfo(nX, nY, MapCellInfo) and (MapCellInfo.chFlag = 0) then
begin
Result := True;
if not boFlag 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_MOVINGOBJECT then
begin
BaseObject := TBaseObject(OSObject.CellObj);
if BaseObject <> nil then
begin
{//01/25 多城堡 控制
if g_Config.boWarDisHumRun and UserCastle.m_boUnderWar and
UserCastle.InCastleWarArea(BaseObject.m_PEnvir,BaseObject.m_nCurrX,BaseObject.m_nCurrY) then begin
}
Castle := g_CastleManager.InCastleWarArea(BaseObject);
if g_Config.boWarDisHumRun and (Castle <> nil) and
(Castle.m_boUnderWar) then
begin
end
else
begin
if BaseObject.m_btRaceServer = RC_PLAYOBJECT then
begin
if g_Config.boRUNHUMAN or m_boRUNHUMAN or (canrun=0)or (Canrun=2)then
Continue;
end
else
begin
if BaseObject.m_btRaceServer = RC_NPC then
begin
if g_Config.boRunNpc or (canrun=0)then
Continue;
end
else
begin
if BaseObject.m_btRaceServer in [RC_GUARD, RC_ARCHERGUARD]
then
begin
if g_Config.boRunGuard or (canrun=0) then
Continue;
end
else
begin
if g_Config.boRUNMON or m_boRUNMON or (canrun=0)or (Canrun=1) then
Continue;
end;
end;
end;
end;
if not BaseObject.m_boGhost
and BaseObject.bo2B9
and not BaseObject.m_boDeath
and not BaseObject.m_boFixedHideMode
and not BaseObject.m_boObMode then
begin
Result := False;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -