📄 envir.pas
字号:
if nValue > 1 then nValue:=1;
MapQuest.nValue:=nValue;
if sMonName = '*' then sMonName:='';
MapQuest.sMonName:=sMonName;
if sItem = '*' then sItem:='';
MapQuest.sItemName:=sItem;
if sQuest = '*' then sQuest:='';
MapQuest.boGrouped := boGrouped;
MapMerchant := TMerchant.Create;
MapMerchant.m_sMapName := '0';
MapMerchant.m_nCurrX := 0;
MapMerchant.m_nCurrY := 0;
MapMerchant.m_sCharName := sQuest;
MapMerchant.m_nFlag := 0;
MapMerchant.m_wAppr := 0;
MapMerchant.m_sFilePath := 'MapQuest_def\';
MapMerchant.m_boIsHide := True;
MapMerchant.m_boIsQuest := False;
UserEngine.QuestNPCList.Add(MapMerchant);
MapQuest.NPC:=MapMerchant;
m_QuestList.Add(MapQuest);
Result:=True;
end;
function TEnvirnoment.GetXYObjCount(nX, nY: Integer): Integer; //004B5DB0
var
I: Integer;
MapCellInfo:pTMapCellinfo;
OSObject:pTOSObject;
BaseObject:TBaseObject;
begin
Result:=0;
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_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
Inc(Result);
end;
end;
end;
end;
end;
end;
//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 < (Header.wWidth - nFlag) then Inc(sny,nFlag);
DR_LEFT: if snx > nFlag - 1 then Dec(snx,nFlag);
DR_RIGHT: if snx < (Header.wWidth - 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 < (Header.wHeight - nFlag)) then begin
Inc(snx,nFlag);
Dec(sny,nFlag);
end;
end;
DR_DOWNLEFT: begin //004B2BAC
if (snx < (Header.wWidth - nFlag)) and (sny > nFlag - 1) then begin
Dec(snx,nFlag);
Inc(sny,nFlag);
end;
end;
DR_DOWNRIGHT: begin
if (snx < (Header.wWidth - nFlag)) and (sny < (Header.wHeight - 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.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,sItem: 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.boGrouped) or (not boFlag) then begin
bo1D:=False;
if (MapQuestFlag.sMonName <> '') and (MapQuestFlag.sItemName <> '') then begin
if (MapQuestFlag.sMonName = sCharName) and (MapQuestFlag.sItemName = sItem) then
bo1D:=True;
end;
if (MapQuestFlag.sMonName <> '') and (MapQuestFlag.sItemName = '') then begin
if (MapQuestFlag.sMonName = sCharName) and (sItem = '') then
bo1D:=True;
end;
if (MapQuestFlag.sMonName = '') and (MapQuestFlag.sItemName <> '') then begin
if (MapQuestFlag.sItemName = sItem) 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.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.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;
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 - ndX) / 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.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.IsValidCell(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:='Map:%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 MINE2:%s NODROPITEM:%s';
sMsg:=sMsg +' NOTHROWITEM:%s NOPOSITIONMOVE:%s NOHORSE:%s NOCHAT:%s';
Result:=format(sMsg,[sMapName,
sMapDesc,
BoolToStr(Flag.boDayLight),
BoolToStr(Flag.boDarkness),
BoolToStr(Flag.boSAFE),
BoolToStr(Flag.boFightZone),
BoolToStr(Flag.boFight3Zone),
BoolToStr(Flag.boQUIZ),
BoolToStr(Flag.boNORECONNECT),Flag.sNoReconnectMap,
BoolToStr(Flag.boMUSIC),Flag.nMUSICID,
BoolToStr(Flag.boEXPRATE),Flag.nEXPRATE / 100,
BoolToStr(Flag.boPKWINLEVEL),Flag.nPKWINLEVEL,
BoolToStr(Flag.boPKLOSTLEVEL),Flag.nPKLOSTLEVEL,
BoolToStr(Flag.boPKWINEXP),Flag.nPKWINEXP,
BoolToStr(Flag.boPKLOSTEXP),Flag.nPKLOSTEXP,
BoolToStr(Flag.boDECHP),Flag.nDECHPTIME,Flag.nDECHPPOINT,
BoolToStr(Flag.boINCHP),Flag.nINCHPTIME,Flag.nINCHPPOINT,
BoolToStr(Flag.boDECGAMEGOLD),Flag.nDECGAMEGOLDTIME,Flag.nDECGAMEGOLD,
BoolToStr(Flag.boINCGAMEGOLD),Flag.nINCGAMEGOLDTIME,Flag.nINCGAMEGOLD,
BoolToStr(Flag.boINCGAMEPOINT),Flag.nINCGAMEPOINTTIME,Flag.nINCGAMEPOINT,
BoolToStr(Flag.boRUNHUMAN),
BoolToStr(Flag.boRUNMON),
BoolToStr(Flag.boNEEDHOLE),
BoolToStr(Flag.boNORECALL),
BoolToStr(Flag.boNOGUILDRECALL),
BoolToStr(Flag.boNODEARRECALL),
BoolToStr(Flag.boNOMASTERRECALL),
BoolToStr(Flag.boNODRUG),
BoolToStr(Flag.boMINE),
BoolToStr(Flag.boMINE2),
BoolToStr(Flag.boNODROPITEM),
BoolToStr(Flag.boNOTHROWITEM),
BoolToStr(Flag.boNOPOSITIONMOVE),
BoolToStr(Flag.boNOHORSE),
BoolToStr(Flag.boNOCHAT)
]);
end;
procedure TEnvirnoment.AddObject(BaseObject:TObject);
var
btRaceServer:Byte;
begin
btRaceServer:=TBaseObject(BaseObject).m_btRaceServer;
if btRaceServer = RC_PLAYOBJECT then Inc(m_nHumCount);
if btRaceServer >= RC_ANIMAL then Inc(m_nMonCount);
end;
procedure TEnvirnoment.DelObjectCount(BaseObject:TObject);
var
btRaceServer:Byte;
begin
btRaceServer:=TBaseObject(BaseObject).m_btRaceServer;
if btRaceServer = RC_PLAYOBJECT then Inc(m_nHumCount);
if btRaceServer >= RC_ANIMAL then Inc(m_nMonCount);
end;
procedure TMapManager.Run;
begin
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -