CheckLOS
Checks line of sight (LOS) between two points in the game world.
Returns True if the line of sight is clear, False if blocked.
Pascal: The LOS algorithm and its options are controlled by the global variable LOSOptions. The variable encodes both the check type (Sphere, SphereAdv, RunUO, POL) and option flags (SphereCheckCorners, PolUseNoShoot, PolLosThroughWindow) using bitwise OR.
Python: The check type and options are passed as explicit parameters CheckType and Options instead of using a global variable.
Проверяет прямую видимость (LOS) между двумя точками в игровом мире.
Возвращает True, если линия обзора свободна, False, если заблокирована.
Pascal: Алгоритм LOS и его параметры задаются глобальной переменной LOSOptions. Переменная кодирует тип проверки (Sphere, SphereAdv, RunUO, POL) и флаги опций (SphereCheckCorners, PolUseNoShoot, PolLosThroughWindow) через побитовое ИЛИ.
Python: Тип проверки и опции передаются явными параметрами CheckType и Options вместо глобальной переменной.
function CheckLOS(Xfrom: Word; Yfrom: Word; Zfrom: ShortInt;
Xto: Integer; Yto: Integer; Zto: ShortInt; WorldNum: Byte): Boolean;
Parameters:
- Xfrom, Yfrom, Zfrom — source point coordinates.
- Xto, Yto, Zto — destination point coordinates.
- WorldNum — world/facet number (use WorldNum to get the current one).
LOS check type constants (for LOSOptions):
| Constant | Value | Emulator |
|---|---|---|
losTypeSphere |
1 | Sphere |
losTypeSphereAdv |
2 | Sphere Advanced |
losTypeRunUO |
3 | RunUO |
losTypePOL |
4 | POL |
Option flags (combine with OR):
| Constant | Value | Meaning |
|---|---|---|
losSphereCheckCorners |
256 | Sphere: check corners |
losPolUseNoShoot |
512 | POL: use NoShoot tile flag |
losPolLOSThroughWindow |
1024 | POL: LOS through windows |
def CheckLOS(Xfrom: int, Yfrom: int, Zfrom: int, Xto: int, Yto: int, Zto: int,
WorldNum: int, CheckType: int, Options: int) -> bool: ...
Additional Python parameters:
- CheckType — LOS check type (1 = Sphere, 2 = SphereAdv, 3 = RunUO, 4 = POL).
- Options — option flags (256, 512, 1024, or combined with OR).
begin
// Set POL algorithm with NoShoot flag
LOSOptions := losTypePOL or losPolUseNoShoot;
if CheckLOS(GetX(Self), GetY(Self), GetZ(Self),
GetX(Self) + 10, GetY(Self) + 10, GetZ(Self), WorldNum) then
AddToSystemJournal('Target is visible')
else
AddToSystemJournal('Target is blocked');
end.
# POL algorithm with NoShoot flag
LOS_POL = 4
LOS_USE_NOSHOOT = 512
visible = CheckLOS(
GetX(Self()), GetY(Self()), GetZ(Self()),
GetX(Self()) + 10, GetY(Self()) + 10, GetZ(Self()),
WorldNum(), LOS_POL, LOS_USE_NOSHOOT
)
if visible:
AddToSystemJournal('Target is visible')
else:
AddToSystemJournal('Target is blocked')