7 #include "../../clib/compilerspecifics.h" 8 #include "../../clib/rawtypes.h" 9 #include "../../plib/mapcell.h" 10 #include "../baseobject.h" 11 #include "../item/item.h" 12 #include "../mobile/charactr.h" 13 #include "../uworld.h" 57 for (
const auto& item : cache.
dyn_items )
59 if ( ( item->x == x ) && ( item->y == y ) )
61 if ( item->z <= z && z < item->z + item->height )
63 #if ENABLE_POLTEST_OUTPUT 64 INFO_PRINT <<
"LOS blocked by " << item->description() <<
"\n";
87 for (
const auto& shape : cache.
shapes )
89 short ob_ht = shape.height;
91 #if ENABLE_POLTEST_OUTPUT 92 INFO_PRINT <<
"static type 0x" << fmt::hexu( itr->graphic ) <<
" (flags 0x" 93 << fmt::hexu(
tile_flags( itr->graphic ) ) <<
", ht=" << ob_ht <<
")" 94 <<
" at z-coord " << (int)itr->z <<
"\n";
103 if ( ob_z <= z && z < ob_z + ob_ht )
105 #if ENABLE_POLTEST_OUTPUT 106 INFO_PRINT <<
"LOS blocked by static object\n";
120 unsigned short x,
unsigned short y,
short z,
LosCache& cache )
const 123 if ( att.
x == x && att.
y == y && att.
z <= z &&
128 if ( target.
x == x && target.
y == y && target.
z <= z &&
129 z <= target.
z + target.
height )
138 #define ABS( a ) ( ( ( a ) < 0 ) ? -( a ) : ( a ) ) 141 #define ZSGN( a ) ( ( ( a ) < 0 ) ? -1 : ( a ) > 0 ? 1 : 0 ) 155 if ( ( remote_container !=
nullptr ) && remote )
171 #if ( !defined( _MSC_VER ) || _MSC_VER >= 1900 ) 173 #else // older ms support only primitive types :( 182 std::min( att.
x, tgt.
x ), std::min( att.
y, tgt.
y ), std::max( att.
x, tgt.
x ),
184 u32 flags = Core::tile_flags( item->graphic );
185 if ( flags & Plib::FLAG::BLOCKSIGHT )
187 if ( item->serial != tgt.serial && item->serial != att.serial )
188 cache.dyn_items.push_back( item );
200 const u8 att_look_height( att.look_height() );
201 const u8 tgt_look_height( tgt.look_height() );
203 if ( ( att.y < tgt.y ) || ( att.y == tgt.y && att.z < tgt.z ) )
207 z1 = att.z + att_look_height;
210 z2 = tgt.z + tgt_look_height;
216 z1 = tgt.z + tgt_look_height;
219 z2 = att.z + att_look_height;
226 if ( abs( dx ) > los_range || abs( dy ) >
los_range )
233 if ( att.z <= tgt.z && tgt.z <= att.z + att.height )
237 if ( att.z <= tgt.z + tgt_look_height && tgt.z + tgt_look_height <= att.z + att.height )
255 if ( ax >= ay && ax >= az )
257 yd = ay - ( ax >> 1 );
258 zd = az - ( ax >> 1 );
287 else if ( ay >= ax && ay >= az )
289 xd = ax - ( ay >> 1 );
290 zd = az - ( ay >> 1 );
321 xd = ax - ( az >> 1 );
322 yd = ay - ( az >> 1 );
unsigned int tile_flags(unsigned short tilenum)
bool los_blocked(const Core::ULWObject &att, const Core::ULWObject &target, unsigned short x, unsigned short y, short z, LosCache &cache) const
static bool dynamic_item_blocks_los(unsigned short x, unsigned short y, short z, LosCache &cache)
void getmapshapes(Plib::MapShapeList &shapes, unsigned short x, unsigned short y, unsigned int anyflags) const
#define ZSGN(a)
take sign of a, either -1, 0, or 1
bool has_los(const Core::ULWObject &att, const Core::ULWObject &tgt) const
std::vector< Items::Item * > dyn_items
void readmultis(Plib::MapShapeList &vec, unsigned short x, unsigned short y, unsigned int flags) const
Items::Item * search_remote_containers(u32 find_serial, bool *isRemoteContainer) const
bool isa(UOBJ_CLASS uobj_class) const
bool ignores_line_of_sight() const
#define ABS(a)
absolute value of a
bool static_item_blocks_los(unsigned short x, unsigned short y, short z, LosCache &cache) const
Plib::MapShapeList shapes
static void InBox(u16 x1, u16 y1, u16 x2, u16 y2, const Realms::Realm *realm, F &&f)