📄 envir.pas
字号:
//boFlag 如果为TRUE 则忽略座标上是否有角色
//返回值 True 为可以移动,False 为不可以移动
//======================================================================
function TEnvirnoment.CanWalk(nX, nY: Integer; boFlag: Boolean = False): 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): Boolean; //004B5ED0
var
MapCellInfo: pTMapCellinfo;
OSObject: pTOSObject;
BaseObject: TBaseObject;
i: Integer;
Castle: TUserCastle;
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
{//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 Flag.boRUNHUMAN then Continue;
end else
begin
if BaseObject.m_btRaceServer = RC_NPC then
begin
if g_Config.boRunNpc then Continue;
end else
begin
if BaseObject.m_btRaceServer in [RC_GUARD, RC_ARCHERGUARD] then
begin
if g_Config.boRunGuard then Continue;
end else
begin
if g_Config.boRUNMON or Flag.boRUNMON 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;
end;
end; //004B5FB5
end; //004B5FB5
end;
end;
end; //004B5FBD
end;
constructor TMapManager.Create;
begin
inherited Create;
end;
destructor TMapManager.Destroy;
var
i: Integer;
begin
for i := 0 to Count - 1 do
begin
TEnvirnoment(Items[i]).Free;
end;
inherited;
end;
//Envir:TEnvirnoment
function TMapManager.FindMap(sMapName: string): TEnvirnoment; //4B7350
var
Map: TEnvirnoment;
i: Integer;
begin
Result := nil;
Lock;
try
for i := 0 to Count - 1 do
begin
Map := TEnvirnoment(Items[i]);
if CompareText(Map.sMapName, sMapName) = 0 then
begin
Result := Map;
Break;
end;
end;
finally
UnLock;
end;
end;
function TMapManager.GetMapInfo(nServerIdx: Integer; sMapName: string): TEnvirnoment; //004B7424
var
i: Integer;
Envir: TEnvirnoment;
begin
Result := nil;
Lock;
try
for i := 0 to Count - 1 do
begin
Envir := Items[i];
if (Envir.nServerIndex = nServerIdx) and (CompareText(Envir.sMapName, sMapName) = 0) then
begin
Result := Envir;
Break;
end;
end; //004B74C8
finally
UnLock;
end;
end;
function TEnvirnoment.DeleteFromMap(nX, nY: Integer; btType: Byte;
pRemoveObject: TObject): Integer; //004B6710
var
MapCellInfo: pTMapCellinfo;
OSObject: pTOSObject;
n18: Integer;
btRaceServer: Byte;
resourcestring
sExceptionMsg1 = '[Exception] TEnvirnoment::DeleteFromMap -> Except 1 ** %d';
sExceptionMsg2 = '[Exception] TEnvirnoment::DeleteFromMap -> Except 2 ** %d';
begin
Result := -1;
try
if GetMapCellInfo(nX, nY, MapCellInfo) then
begin
if MapCellInfo <> nil then
begin
try
if MapCellInfo.ObjList <> nil then
begin
n18 := 0;
while (True) do
begin
if MapCellInfo.ObjList.Count <= n18 then Break;
OSObject := MapCellInfo.ObjList.Items[n18];
if OSObject <> nil then
begin
if (OSObject.btType = btType) and (OSObject.CellObj = pRemoveObject) then
begin
MapCellInfo.ObjList.Delete(n18);
Dispose(OSObject);
Result := 1;
//减地图人物怪物计数
if (btType = OS_MOVINGOBJECT) and (not TBaseObject(pRemoveObject).m_boDelFormMaped) then
begin
TBaseObject(pRemoveObject).m_boDelFormMaped := True;
TBaseObject(pRemoveObject).m_boAddToMaped := False;
DelObjectCount(pRemoveObject);
end;
if MapCellInfo.ObjList.Count > 0 then Continue;
MapCellInfo.ObjList.Free;
MapCellInfo.ObjList := nil;
Break;
{//Jacky 处理防止内存泄露 有待换上
if MapCellInfo.ObjList.Count <= 0 then begin
MapCellInfo.ObjList.Free;
MapCellInfo.ObjList:=nil;
end;
break;
}
end
end else
begin
MapCellInfo.ObjList.Delete(n18);
if MapCellInfo.ObjList.Count > 0 then Continue;
MapCellInfo.ObjList.Free;
MapCellInfo.ObjList := nil;
Break;
end;
Inc(n18);
end;
end else
begin
Result := -2;
end;
except
OSObject := nil;
MainOutMessage(Format(sExceptionMsg1, [btType]));
end;
end else Result := -3;
end else Result := 0;
except
MainOutMessage(Format(sExceptionMsg2, [btType]));
end;
end;
function TEnvirnoment.GetItem(nX, nY: Integer): pTMapItem; //004B5B0C
var
i: Integer;
MapCellInfo: pTMapCellinfo;
OSObject: pTOSObject;
BaseObject: TBaseObject;
begin
Result := nil;
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.btType = OS_ITEMOBJECT then
begin
Result := pTMapItem(OSObject.CellObj);
Exit;
end;
if OSObject.btType = OS_GATEOBJECT then
bo2C := False;
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 TMapManager.GetMapOfServerIndex(sMapName: string): Integer; //004B7510
var
i: Integer;
Envir: TEnvirnoment;
begin
Result := 0;
Lock;
try
for i := 0 to Count - 1 do
begin
Envir := Items[i];
if (CompareText(Envir.sMapName, sMapName) = 0) then
begin
Result := Envir.nServerIndex;
Break;
end;
end;
finally
UnLock;
end;
end;
procedure TMapManager.LoadMapDoor; //004B6FFC
var
i: Integer;
begin
for i := 0 to Count - 1 do
begin
TEnvirnoment(Items[i]).AddDoorToMap;
end;
end;
procedure TMapManager.ProcessMapDoor;
begin
end;
procedure TMapManager.ReSetMinMap;
var
i, ii: Integer;
Envirnoment: TEnvirnoment;
begin
for i := 0 to Count - 1 do
begin
Envirnoment := TEnvirnoment(Items[i]);
for ii := 0 to MiniMapList.Count - 1 do
begin
if CompareText(MiniMapList.Strings[ii], Envirnoment.sMapName) = 0 then
begin
Envirnoment.nMinMap := Integer(MiniMapList.Objects[ii]);
Break;
end;
end;
end;
end;
function TEnvirnoment.IsCheapStuff: Boolean; //004B6E24
begin
if m_QuestList.Count > 0 then Result := True
else Result := False;
end;
function TEnvirnoment.AddToMapMineEvent(nX, nY: Integer; nType: Integer; Event: TObject): TObject; //004B6600
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -