Pol  Revision:dd8d5e0
3D LOS CHECKING

Functions

static bool Pol::Realms::Realm::dynamic_item_blocks_los (unsigned short x, unsigned short y, short z, LosCache &cache)
 
bool Pol::Realms::Realm::has_los (const Core::ULWObject &att, const Core::ULWObject &tgt) const
 
bool Pol::Realms::Realm::los_blocked (const Core::ULWObject &att, const Core::ULWObject &target, unsigned short x, unsigned short y, short z, LosCache &cache) const
 
bool Pol::Realms::Realm::static_item_blocks_los (unsigned short x, unsigned short y, short z, LosCache &cache) const
 

Detailed Description

To determine LOS, a 3D line is drawn from the top of the attacker to the top of the target.

An 3D extension of Bresenham's algorithm is used to draw the line.

Each point along the way is checked for items and statics of any kind. Only integer addition and subtraction is required.

The line always starts at the point with the lowest Y-coordinate, or if the Y coordinates are the same, the point with the lowest Z-coordinate. This way, if A -> B has LOS, then B -> A has LOS, always. (Bresenham lines can occupy different points, given the same endpoints, depending on which point is used as the start)

Zero-height items (floor tiles, mostly) are treated as 1-height items, sitting at 1 lower Z coordinate. This makes floors solid. (A weirdness: On a floor at height 72, characters walk around at Z=73, but items are placed at Z=72. This is somewhat unfortunate.)

Note
All obstacles found to obstruct the LOS are checked to make sure they are neither the attacker nor the target, since both endpoints are checked. This is actually unnecessary when both attacker and defender are characters, which ends up being all the time when it matters.

Function Documentation

bool Pol::Realms::Realm::dynamic_item_blocks_los ( unsigned short  x,
unsigned short  y,
short  z,
LosCache cache 
)
staticprotected

Definition at line 55 of file realmlos.cpp.

References Pol::Realms::Realm::LosCache::dyn_items, and INFO_PRINT.

Referenced by Pol::Realms::Realm::los_blocked().

bool Pol::Realms::Realm::los_blocked ( const Core::ULWObject att,
const Core::ULWObject target,
unsigned short  x,
unsigned short  y,
short  z,
LosCache cache 
) const
protected
bool Pol::Realms::Realm::static_item_blocks_los ( unsigned short  x,
unsigned short  y,
short  z,
LosCache cache 
) const
protected