本文整理汇总了C++中CItemBase::Can方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemBase::Can方法的具体用法?C++ CItemBase::Can怎么用?C++ CItemBase::Can使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItemBase
的用法示例。
在下文中一共展示了CItemBase::Can方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CanSeeLOS_New
bool CChar::CanSeeLOS_New( const CPointMap &ptDst, CPointMap *pptBlock, int iMaxDist, word flags, bool bCombatCheck ) const
{
ADDTOCALLSTACK("CChar::CanSeeLOS_New");
// WARNING: CanSeeLOS is an expensive function (lot of calculations but most importantly it has to read the UO files, and file I/O is slow).
if ( !bCombatCheck && IsPriv(PRIV_GM) ) // If i'm checking the LOS during a combat, i don't want to shoot through the walls even if i'm a GM
{
WARNLOS(("GM Pass\n"));
return true;
}
CPointMap ptSrc = GetTopPoint();
CPointMap ptNow(ptSrc);
if ( ptSrc.m_map != ptDst.m_map ) // Different map
return this->CanSeeLOS_New_Failed(pptBlock, ptNow);
if ( ptSrc == ptDst ) // Same point ^^
return true;
short iTotalZ = ptSrc.m_z + GetHeightMount(true);
ptSrc.m_z = (char)minimum(iTotalZ, UO_SIZE_Z); //true - substract one from the height because of eyes height
WARNLOS(("Total Z: %d\n", ptSrc.m_z));
int dx, dy, dz;
dx = ptDst.m_x - ptSrc.m_x;
dy = ptDst.m_y - ptSrc.m_y;
dz = ptDst.m_z - ptSrc.m_z;
float dist2d, dist3d;
dist2d = sqrt((float)(dx*dx + dy*dy));
if ( dz )
dist3d = sqrt((float)(dist2d*dist2d + dz*dz));
else
dist3d = dist2d;
if ( APPROX(dist2d) > (float)iMaxDist )
{
WARNLOS(("( APPROX(dist2d)(%f) > ((double)iMaxDist)(%f) ) --> NOLOS\n", APPROX(dist2d), (float)iMaxDist));
return CanSeeLOS_New_Failed(pptBlock, ptNow);
}
float dFactorX, dFactorY, dFactorZ;
dFactorX = dx / dist3d;
dFactorY = dy / dist3d;
dFactorZ = dz / dist3d;
float nPx, nPy, nPz;
nPx = ptSrc.m_x;
nPy = ptSrc.m_y;
nPz = ptSrc.m_z;
std::vector<CPointMap> path;
for (;;)
{
if ( BETWEENPOINT(nPx, ptDst.m_x, ptSrc.m_x) && BETWEENPOINT(nPy, ptDst.m_y, ptSrc.m_y) && BETWEENPOINT(nPz, ptDst.m_z, ptSrc.m_z) )
{
dx = (int)APPROX(nPx);
dy = (int)APPROX(nPy);
dz = (int)APPROX(nPz);
// Add point to vector
if ( !path.empty() )
{
CPointMap ptEnd = path[path.size() - 1];
if ( ptEnd.m_x != dx || ptEnd.m_y != dy || ptEnd.m_z != dz )
path.emplace_back((word)dx, (word)dy, (char)dz, ptSrc.m_map);
}
else
{
path.emplace_back((word)dx, (word)dy, (char)dz, ptSrc.m_map);
}
WARNLOS(("PATH X:%d Y:%d Z:%d\n", dx, dy, dz));
nPx += dFactorX;
nPy += dFactorY;
nPz += dFactorZ;
}
else
break;
}
if ( !path.empty() )
{
if ( path[path.size() - 1] != ptDst )
path.emplace_back(ptDst.m_x, ptDst.m_y, ptDst.m_z, ptDst.m_map);
}
else
{
path.clear();
return CanSeeLOS_New_Failed(pptBlock, ptNow);
}
WARNLOS(("Path calculated %" PRIuSIZE_T "\n", path.size()));
// Ok now we should loop through all the points and checking for maptile, staticx, items, multis.
// If something is in the way and it has the wrong flags LOS return false
const CServerMapBlock *pBlock = nullptr; // Block of the map (for statics)
const CUOStaticItemRec *pStatic = nullptr; // Statics iterator (based on SphereMapBlock)
const CSphereMulti *pMulti = nullptr; // Multi Def (multi check)
//.........这里部分代码省略.........