本文整理汇总了C++中CItem::GetTopPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::GetTopPoint方法的具体用法?C++ CItem::GetTopPoint怎么用?C++ CItem::GetTopPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::GetTopPoint方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Ship_ListObjs
int CItemMulti::Ship_ListObjs( CObjBase ** ppObjList )
{
// List all the objects in the structure.
// Move the ship and everything on the deck
// If too much stuff. then some will fall overboard. hehe.
if ( ! IsTopLevel())
return 0;
int iMaxDist = Multi_GetMaxDist();
// always list myself first. All other items must see my new region !
int iCount = 0;
ppObjList[iCount++] = this;
CWorldSearch AreaChar( GetTopPoint(), iMaxDist );
while ( iCount < MAX_MULTI_LIST_OBJS )
{
CChar * pChar = AreaChar.GetChar();
if ( pChar == NULL )
break;
if ( pChar->IsClient())
{
pChar->GetClient()->addPause(); // get rid of flicker. for anyone even seeing this.
}
if ( ! m_pRegion->IsInside2d( pChar->GetTopPoint()))
continue;
int zdiff = pChar->GetTopZ() - GetTopZ();
if ( abs( zdiff ) > 3 )
continue;
ppObjList[iCount++] = pChar;
}
CWorldSearch AreaItem( GetTopPoint(), iMaxDist );
while ( iCount < MAX_MULTI_LIST_OBJS )
{
CItem * pItem = AreaItem.GetItem();
if ( pItem == NULL )
break;
if ( pItem == this ) // already listed.
continue;
if ( ! Multi_IsPartOf( pItem ))
{
if ( ! m_pRegion->IsInside2d( pItem->GetTopPoint()))
continue;
if ( ! pItem->IsMovable())
continue;
int zdiff = pItem->GetTopZ() - GetTopZ();
if ( abs( zdiff ) > 3 )
continue;
}
ppObjList[iCount++] = pItem;
}
return( iCount );
}
示例2: r_Verb
//.........这里部分代码省略.........
m_pChar->DeleteKey("ARROWQUEST_X");
m_pChar->DeleteKey("ARROWQUEST_Y");
}
#endif
}
break;
case CV_BADSPAWN:
{
// Loop the world searching for bad spawns
bool fFound = false;
for ( int m = 0; m < 256 && !fFound; m++ )
{
if ( !g_MapList.m_maps[m] ) continue;
for ( int d = 0; d < g_MapList.GetSectorQty(m) && !fFound; d++ )
{
CSector *pSector = g_World.GetSector(m, d);
if ( !pSector ) continue;
CItem *pNext;
CItem *pItem = STATIC_CAST <CItem*>(pSector->m_Items_Inert.GetHead());
for ( ; pItem != NULL && !fFound; pItem = pNext )
{
pNext = pItem->GetNext();
if ( pItem->IsType(IT_SPAWN_ITEM) || pItem->IsType(IT_SPAWN_CHAR) )
{
CItemSpawn *pSpawn = static_cast<CItemSpawn*>(pItem);
CResourceDef *pDef = pSpawn->FixDef();
if ( !pDef )
{
RESOURCE_ID_BASE rid = ( pItem->IsType(IT_SPAWN_ITEM) ? pItem->m_itSpawnItem.m_ItemID : pItem->m_itSpawnChar.m_CharID);
CPointMap pt = pItem->GetTopPoint();
m_pChar->Spell_Teleport(pt, true, false);
m_pChar->m_Act_Targ = pItem->GetUID();
SysMessagef("Bad spawn (0%lx, id=%s). Set as ACT", (DWORD)pItem->GetUID(), g_Cfg.ResourceGetName(rid));
fFound = true;
}
}
}
}
}
if ( ! fFound )
SysMessage(g_Cfg.GetDefaultMsg( DEFMSG_NO_BAD_SPAWNS ));
}
break;
case CV_BANKSELF: // open my own bank
addBankOpen( m_pChar, static_cast<LAYER_TYPE>(s.GetArgVal()));
break;
case CV_CAST:
{
SPELL_TYPE spell = static_cast<SPELL_TYPE>(g_Cfg.ResourceGetIndexType(RES_SPELL, s.GetArgStr()));
const CSpellDef * pSpellDef = g_Cfg.GetSpellDef(spell);
if (pSpellDef == NULL)
return true;
CObjBase * pObjSrc = dynamic_cast<CObjBase *>(pSrc);
if ( IsSetMagicFlags( MAGICF_PRECAST ) && !pSpellDef->IsSpellType( SPELLFLAG_NOPRECAST ) )
{
int skill;
if (!pSpellDef->GetPrimarySkill(&skill, NULL))
return true;
m_tmSkillMagery.m_Spell = spell; // m_atMagery.m_Spell
示例3: GetFixPoint
//.........这里部分代码省略.........
pItemDef = NULL;
pDupeDef = NULL;
pItem = NULL;
wBlockThis = 0;
z = 0;
x2 = y2 = 0;
iQty = 0;
// Any multi items here ?
// Check all of them
CRegionLinks rlinks;
size_t iRegionQty = pt.GetRegions( REGION_TYPE_MULTI, rlinks );
if ( iRegionQty > 0 )
{
// ------------ For variables --------------------
CRegionBase * pRegion = NULL;
const CGrayMulti * pMulti = NULL;
const CUOMultiItemRec2 * pMultiItem = NULL;
x2 = 0;
y2 = 0;
// ------------ For variables --------------------
for ( size_t iRegion = 0; iRegion < iRegionQty; ++iRegion, pRegion = NULL, pItem = NULL, pMulti = NULL, x2 = 0, y2 = 0 )
{
pRegion = rlinks.GetAt(iRegion);
if ( pRegion != NULL )
pItem = pRegion->GetResourceID().ItemFind();
if ( pItem != NULL )
{
pMulti = g_Cfg.GetMultiItemDefs(pItem);
if ( pMulti )
{
x2 = pt.m_x - pItem->GetTopPoint().m_x;
y2 = pt.m_y - pItem->GetTopPoint().m_y;
iQty = pMulti->GetItemCount();
for ( size_t ii = 0; ii < iQty; ++ii, pMultiItem = NULL, z = 0 )
{
pMultiItem = pMulti->GetItem(ii);
if ( !pMultiItem )
break;
if ( ! pMultiItem->m_visible )
continue;
if ( pMultiItem->m_dx != x2 || pMultiItem->m_dy != y2 )
continue;
z = static_cast<signed char>(pItem->GetTopZ() + pMultiItem->m_dz);
pItemDef = CItemBase::FindItemBase( pMultiItem->GetDispID() );
if ( pItemDef != NULL )
{
if ( pItemDef->GetID() == pMultiItem->GetDispID() ) //parent item
{
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK );
z += ((wBlockThis & CAN_I_CLIMB) ? pItemDef->GetHeight()/2 : pItemDef->GetHeight());
}
else //non-parent item
{
pDupeDef = CItemBaseDupe::GetDupeRef(static_cast<ITEMID_TYPE>(pMultiItem->GetDispID()));
if ( pDupeDef == NULL )
{
g_Log.EventDebug("Failed to get non-parent reference (multi) (DispID 0%x) (X: %d Y: %d Z: %d)\n",pMultiItem->GetDispID(),pMultiItem->m_dx+pItem->GetTopPoint().m_x,pMultiItem->m_dy+pItem->GetTopPoint().m_y,pMultiItem->m_dz+pItem->GetTopPoint().m_z);
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK );
示例4: GetHeightPoint
//.........这里部分代码省略.........
wBlockThis = 0;
z = 0;
zHeight = 0;
x2 = y2 = 0;
iQty = 0;
// Any multi items here ?
// Check all of them
if ( fHouseCheck )
{
CRegionLinks rlinks;
size_t iRegionQty = pt.GetRegions( REGION_TYPE_MULTI, rlinks );
if ( iRegionQty > 0 )
{
// ------------ For variables --------------------
CRegionBase * pRegion = NULL;
const CGrayMulti * pMulti = NULL;
const CUOMultiItemRec2 * pMultiItem = NULL;
x2 = 0;
y2 = 0;
// ------------ For variables --------------------
for ( size_t iRegion = 0; iRegion < iRegionQty; ++iRegion, pRegion = NULL, pItem = NULL, pMulti = NULL, x2 = 0, y2 = 0 )
{
pRegion = rlinks.GetAt(iRegion);
if ( pRegion != NULL )
pItem = pRegion->GetResourceID().ItemFind();
if ( pItem != NULL )
{
pMulti = g_Cfg.GetMultiItemDefs(pItem);
if ( pMulti )
{
x2 = pt.m_x - pItem->GetTopPoint().m_x;
y2 = pt.m_y - pItem->GetTopPoint().m_y;
iQty = pMulti->GetItemCount();
for ( size_t ii = 0; ii < iQty; ++ii, pMultiItem = NULL, z = 0, zHeight = 0 )
{
pMultiItem = pMulti->GetItem(ii);
if ( !pMultiItem )
break;
if ( ! pMultiItem->m_visible )
continue;
if ( pMultiItem->m_dx != x2 || pMultiItem->m_dy != y2 )
continue;
z = static_cast<signed char>( pItem->GetTopZ() + pMultiItem->m_dz );
if ( ! block.IsUsableZ(z,block.m_zHeight))
continue;
pItemDef = CItemBase::FindItemBase( pMultiItem->GetDispID() );
if ( pItemDef != NULL )
{
if ( pItemDef->GetID() == pMultiItem->GetDispID() ) //parent item
{
zHeight = pItemDef->GetHeight();
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK ); //Use only Block flags, other remove
}
else //non-parent item
{
pDupeDef = CItemBaseDupe::GetDupeRef(static_cast<ITEMID_TYPE>(pMultiItem->GetDispID()));
if ( pDupeDef == NULL )
示例5: FindTypeNear_Top
CPointMap CWorld::FindTypeNear_Top( const CPointMap & pt, IT_TYPE iType, int iDistance )
{
ADDTOCALLSTACK("CWorld::FindTypeNear_Top");
#define RESOURCE_Z_CHECK 8
CPointMap ptFound;
CItemBase * pItemDef = NULL;
CItem * pItem = NULL;
CItemBaseDupe * pDupeDef = NULL;
height_t Height = 0;
BYTE z = 0;
CPointMap ptTest;
unsigned int iRetElem = 4;
CPointMap ptElem[5];
memset(ptElem, 0, sizeof(ptElem));
//for ( iQty = 0; iQty < 4; ++iQty )
// ptElem[iQty].m_z = UO_SIZE_MIN_Z;
ptElem[0].m_z = ptElem[1].m_z = ptElem[2].m_z = ptElem[3].m_z = UO_SIZE_MIN_Z;
ptElem[4] = CPointMap(USHRT_MAX, USHRT_MAX, UO_SIZE_MIN_Z);
bool fElem[4] = { false, false, false, false };
// Check dynamics
CWorldSearch Area( pt, iDistance );
Area.SetAllShow( true );
for (;;)
{
z = 0;
Height = 0;
pItem = Area.GetItem();
if ( pItem == NULL )
break;
if ( pt.GetDist( pItem->GetTopPoint() ) > iDistance )
continue;
pItemDef = CItemBase::FindItemBase( pItem->GetDispID() );
if ( pItemDef == NULL )
continue;
Height = pItemDef->GetHeight();
if ( pItemDef->GetID() != pItem->GetDispID() ) //not a parent item
{
pDupeDef = CItemBaseDupe::GetDupeRef(static_cast<ITEMID_TYPE>(pItem->GetDispID()));
if ( ! pDupeDef )
{
g_Log.EventDebug("Failed to get non-parent reference (dynamic) (DispID 0%x) (X: %d Y: %d Z: %d)\n",pItem->GetDispID(),ptTest.m_x,ptTest.m_y,ptTest.m_z);
Height = pItemDef->GetHeight();
}
else
Height = pDupeDef->GetHeight();
}
z = minimum( Height + pItem->GetTopPoint().m_z, UO_SIZE_Z ); //height + current position = the top point
if ( ptElem[0].m_z > z ) //if ( ptElem[0].m_z > pItem->GetTopPoint().m_z )
continue;
if ( ((( z - pt.m_z ) > 0) && ( z - pt.m_z ) > RESOURCE_Z_CHECK ) || ((( pt.m_z - z ) < 0) && (( pt.m_z - z ) < - RESOURCE_Z_CHECK ))) //if ( ((( pItem->GetTopPoint().m_z - pt.m_z ) > 0) && ( pItem->GetTopPoint().m_z - pt.m_z ) > RESOURCE_Z_CHECK ) || ((( pt.m_z - pItem->GetTopPoint().m_z ) < 0) && (( pt.m_z - pItem->GetTopPoint().m_z ) < - RESOURCE_Z_CHECK )))
continue;
if (( z < ptElem[0].m_z ) || (( z == ptElem[0].m_z ) && ( fElem[0] )))
continue;
ptElem[0] = pItem->GetTopPoint();
ptElem[0].m_z = z;
fElem[0] = false;
//DEBUG_ERR(("dynamic pItem->IsType( iType %d) %d\n",iType,pItem->IsType( iType )));
if ( pItem->IsType( iType ) ) //( pItem->Item_GetDef()->IsType(iType) ) )
{
fElem[0] = true;
iRetElem = 0;
}
}
// Parts of multis ?
const CGrayMulti * pMulti = NULL; // Multi Def (multi check)
const CUOMultiItemRec2 * pMultiItem = NULL; // Multi item iterator
CRegionBase * pRegion = NULL;
CRegionLinks rlinks;
size_t iRegionQty = pt.GetRegions( REGION_TYPE_MULTI, rlinks );
if ( iRegionQty > 0 )
{
for ( size_t iRegion = 0; iRegion < iRegionQty; pMulti = NULL, ++iRegion)
{
pRegion = rlinks.GetAt(iRegion);
pItem = pRegion->GetResourceID().ItemFind();
if ( !pItem )
continue;
pMulti = g_Cfg.GetMultiItemDefs(pItem);
if ( !pMulti )
continue;
size_t iMultiQty = pMulti->GetItemCount();
for ( size_t iMulti = 0; iMulti < iMultiQty; pItemDef = NULL, pMultiItem = NULL, Height = 0, ++iMulti )
{
pMultiItem = pMulti->GetItem(iMulti);
if ( !pMultiItem )
break;
//.........这里部分代码省略.........
示例6: FindItemTypeNearby
CPointMap CWorld::FindItemTypeNearby(const CPointMap & pt, IT_TYPE iType, int iDistance, bool bCheckMulti, bool bLimitZ)
{
ADDTOCALLSTACK("CWorld::FindItemTypeNearby");
// Find the closest item of this type.
// This does not mean that i can touch it.
// ARGS:
// iDistance = 2d distance to search.
CPointMap ptFound;
int iTestDistance;
// Check dynamics first since they are the easiest.
CWorldSearch Area( pt, iDistance );
for (;;)
{
CItem * pItem = Area.GetItem();
if ( pItem == NULL )
break;
if ( ! pItem->IsType( iType ) && ! pItem->Item_GetDef()->IsType(iType) )
continue;
if ( bLimitZ && ( pItem->GetTopPoint().m_z != pt.m_z ))
continue;
iTestDistance = pt.GetDist(pItem->GetTopPoint());
if ( iTestDistance > iDistance )
continue;
ptFound = pItem->GetTopPoint();
iDistance = iTestDistance; // tighten up the search.
if ( ! iDistance )
return( ptFound );
}
// Check for appropriate terrain type
CRectMap rect;
rect.SetRect( pt.m_x - iDistance, pt.m_y - iDistance,
pt.m_x + iDistance + 1, pt.m_y + iDistance + 1,
pt.m_map);
const CUOMapMeter * pMeter = NULL;
for (int x = rect.m_left; x < rect.m_right; x++, pMeter = NULL )
{
for ( int y = rect.m_top; y < rect.m_bottom; y++, pMeter = NULL )
{
CPointMap ptTest(static_cast<WORD>(x), static_cast<WORD>(y), pt.m_z, pt.m_map);
pMeter = GetMapMeter(ptTest);
if ( !pMeter )
continue;
if ( bLimitZ && ( pMeter->m_z != pt.m_z ) )
continue;
ptTest.m_z = pMeter->m_z;
if ( iType != g_World.GetTerrainItemType( pMeter->m_wTerrainIndex ) )
continue;
iTestDistance = pt.GetDist(ptTest);
if ( iTestDistance > iDistance )
break;
ptFound = ptTest;
iDistance = iTestDistance; // tighten up the search.
if ( ! iDistance )
return( ptFound );
rect.SetRect( pt.m_x - iDistance, pt.m_y - iDistance,
pt.m_x + iDistance + 1, pt.m_y + iDistance + 1,
pt.m_map);
}
}
// Check for statics
rect.SetRect( pt.m_x - iDistance, pt.m_y - iDistance,
pt.m_x + iDistance + 1, pt.m_y + iDistance + 1,
pt.m_map);
const CGrayMapBlock * pMapBlock = NULL;
const CUOStaticItemRec * pStatic = NULL;
const CItemBase * pItemDef = NULL;
for (int x = rect.m_left; x < rect.m_right; x += UO_BLOCK_SIZE, pMapBlock = NULL )
{
for ( int y = rect.m_top; y < rect.m_bottom; y += UO_BLOCK_SIZE, pMapBlock = NULL )
{
CPointMap ptTest(static_cast<WORD>(x), static_cast<WORD>(y), pt.m_z, pt.m_map);
pMapBlock = GetMapBlock( ptTest );
if ( !pMapBlock )
continue;
size_t iQty = pMapBlock->m_Statics.GetStaticQty();
if ( iQty <= 0 )
continue;
pStatic = NULL;
pItemDef = NULL;
//.........这里部分代码省略.........
示例7: Area
void CWorld::GetHeightPoint2( const CPointMap & pt, CGrayMapBlockState & block, bool fHouseCheck )
{
ADDTOCALLSTACK("CWorld::GetHeightPoint2");
// Height of statics at/above given coordinates
// do gravity here for the z.
DWORD wBlockThis = 0;
const CGrayMapBlock * pMapBlock = GetMapBlock( pt );
if ( !pMapBlock )
{
g_Log.EventWarn("GetMapBlock failed at %s.\n", pt.WriteUsed());
return;
}
{
size_t iStaticQty = pMapBlock->m_Statics.GetStaticQty();
if ( iStaticQty > 0 ) // no static items here.
{
int x2 = pMapBlock->GetOffsetX(pt.m_x);
int y2 = pMapBlock->GetOffsetY(pt.m_y);
for ( size_t i = 0; i < iStaticQty; i++ )
{
if ( ! pMapBlock->m_Statics.IsStaticPoint( i, x2, y2 ))
continue;
const CUOStaticItemRec * pStatic = pMapBlock->m_Statics.GetStatic( i );
signed char z = pStatic->m_z;
if ( ! block.IsUsableZ(z,PLAYER_HEIGHT))
continue;
// This static is at the coordinates in question.
// enough room for me to stand here ?
wBlockThis = 0;
height_t zHeight = CItemBase::GetItemHeight( pStatic->GetDispID(), wBlockThis );
block.CheckTile( wBlockThis, z, zHeight, pStatic->GetDispID() + TERRAIN_QTY );
}
}
}
// Any multi items here ?
if ( fHouseCheck )
{
CRegionLinks rlinks;
size_t iRegionQty = pt.GetRegions( REGION_TYPE_MULTI, rlinks );
if ( iRegionQty > 0 )
{
for ( size_t i = 0; i < iRegionQty; i++)
{
CRegionBase * pRegion = rlinks.GetAt(i);
CItem * pItem = pRegion->GetResourceID().ItemFind();
if ( pItem != NULL )
{
const CGrayMulti * pMulti = g_Cfg.GetMultiItemDefs(pItem);
if ( pMulti )
{
int x2 = pt.m_x - pItem->GetTopPoint().m_x;
int y2 = pt.m_y - pItem->GetTopPoint().m_y;
size_t iMultiQty = pMulti->GetItemCount();
for ( size_t j = 0; j < iMultiQty; j++ )
{
const CUOMultiItemRec2 * pMultiItem = pMulti->GetItem(j);
ASSERT(pMultiItem);
if ( ! pMultiItem->m_visible )
continue;
if ( pMultiItem->m_dx != x2 || pMultiItem->m_dy != y2 )
continue;
signed char zitem = static_cast<signed char>( pItem->GetTopZ() + pMultiItem->m_dz );
if ( ! block.IsUsableZ(zitem,PLAYER_HEIGHT))
continue;
wBlockThis = 0;
height_t zHeight = CItemBase::GetItemHeight( pMultiItem->GetDispID(), wBlockThis );
block.CheckTile( wBlockThis, zitem, zHeight, pMultiItem->GetDispID() + TERRAIN_QTY );
}
}
}
}
}
}
{
// Any dynamic items here ?
// NOTE: This could just be an item that an NPC could just move ?
CWorldSearch Area( pt );
for (;;)
{
CItem * pItem = Area.GetItem();
if ( pItem == NULL )
break;
signed char zitem = pItem->GetTopZ();
if ( ! block.IsUsableZ(zitem,PLAYER_HEIGHT))
continue;
// Invis items should not block ???
CItemBase * pItemDef = pItem->Item_GetDef();
ASSERT(pItemDef);
//.........这里部分代码省略.........
示例8: 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)
//.........这里部分代码省略.........
示例9: r_Verb
//.........这里部分代码省略.........
case CV_ARROWQUEST:
{
INT64 piVal[3];
Str_ParseCmds(s.GetArgRaw(), piVal, COUNTOF(piVal));
addArrowQuest(static_cast<WORD>(piVal[0]), static_cast<WORD>(piVal[1]), static_cast<DWORD>(piVal[2]));
break;
}
case CV_BADSPAWN:
{
// Loop the world searching for bad spawns
bool fFound = false;
CItem *pItem = NULL;
CSector *pSector = NULL;
CResourceDef *pSpawnDef = NULL;
for ( int m = 0; (m < 256) && !fFound; ++m )
{
if ( !g_MapList.m_maps[m] )
continue;
for ( int s = 0; (s < g_MapList.GetSectorQty(m)) && !fFound; ++s )
{
pSector = g_World.GetSector(m, s);
if ( !pSector )
continue;
for ( pItem = static_cast<CItem *>(pSector->m_Items_Timer.GetHead()); (pItem != NULL) && !fFound; pItem = pItem->GetNext() )
{
if ( pItem->IsType(IT_SPAWN_ITEM) || pItem->IsType(IT_SPAWN_CHAR) )
{
pSpawnDef = static_cast<CItemSpawn *>(pItem)->FixDef();
if ( !pSpawnDef )
{
RESOURCE_ID_BASE rid = pItem->IsType(IT_SPAWN_ITEM) ? pItem->m_itSpawnItem.m_ItemID : pItem->m_itSpawnChar.m_CharID;
CPointMap pt = pItem->GetTopPoint();
m_pChar->Spell_Teleport(pt, true, false);
m_pChar->m_Act_Targ = pItem->GetUID();
SysMessagef("Bad spawn (0%lx, id=%s). Set as ACT", static_cast<DWORD>(pItem->GetUID()), g_Cfg.ResourceGetName(rid));
fFound = true;
}
}
}
}
}
if ( !fFound )
SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_NO_BAD_SPAWNS));
break;
}
case CV_BANKSELF:
{
addBankOpen(m_pChar, LAYER_BANKBOX);
break;
}
case CV_CAST:
{
SPELL_TYPE spell = static_cast<SPELL_TYPE>(g_Cfg.ResourceGetIndexType(RES_SPELL, s.GetArgStr()));
const CSpellDef *pSpellDef = g_Cfg.GetSpellDef(spell);
if ( !pSpellDef )
return true;
CObjBase *pObjSrc = dynamic_cast<CObjBase *>(pSrc);
if ( IsSetMagicFlags(MAGICF_PRECAST) && !pSpellDef->IsSpellType(SPELLFLAG_NOPRECAST) )
{
int iSkill;
if ( !pSpellDef->GetPrimarySkill(&iSkill, NULL) )
return true;
示例10: r_WriteVal
//.........这里部分代码省略.........
CItemBase * pItemDef = CItemBase::FindItemBase( idTile );
if ( pItemDef == NULL )
{
DEBUG_ERR(("Must have ITEMDEF section for item ID 0%x\n", idTile ));
return false;
}
return pItemDef->r_WriteVal( pszKey, sVal, &g_Serv );
}
else if ( !strnicmp( pszKey, "COMPONENTS", 10) )
{
pszKey += 10;
CRegionLinks rlinks;
const CRegionBase* pRegion = NULL;
CItem* pItem = NULL;
const CGrayMulti* pMulti = NULL;
const CUOMultiItemRec2* pMultiItem = NULL;
size_t iMultiQty = GetRegions(REGION_TYPE_MULTI, rlinks);
if ( *pszKey == '\0' )
{
int iComponentQty = 0;
for (size_t i = 0; i < iMultiQty; i++)
{
pRegion = rlinks.GetAt(i);
if (pRegion == NULL)
continue;
pItem = pRegion->GetResourceID().ItemFind();
if (pItem == NULL)
continue;
const CPointMap ptMulti = pItem->GetTopPoint();
pMulti = g_Cfg.GetMultiItemDefs(pItem);
if (pMulti == NULL)
continue;
size_t iQty = pMulti->GetItemCount();
for (size_t ii = 0; ii < iQty; ii++)
{
pMultiItem = pMulti->GetItem(ii);
if (pMultiItem == NULL)
break;
if (pMultiItem->m_visible == 0)
continue;
CPointMap ptTest(static_cast<WORD>(ptMulti.m_x + pMultiItem->m_dx), static_cast<WORD>(ptMulti.m_y + pMultiItem->m_dy), static_cast<signed char>(ptMulti.m_z + pMultiItem->m_dz), this->m_map);
if (GetDist(ptTest) > 0)
continue;
iComponentQty++;
}
}
sVal.FormatVal( iComponentQty );
return true;
}
SKIP_SEPARATORS( pszKey );
int iComponent = 0;
int type = 0;
if ( strnicmp( pszKey, "FINDID", 6 ) == 0 )
{
示例11: ImportWSC
//.........这里部分代码省略.........
if ( s.IsKey("ID" ))
{
if ( m_pCurObj != NULL )
return( false );
pItem = CItem::CreateTemplate(static_cast<ITEMID_TYPE>(ATOI(pArg)));
pItem->SetName( sName );
m_pCurObj = pItem;
m_pCurSer->m_pObj = pItem;
continue;
}
if ( m_pCurObj == NULL )
{
DEBUG_ERR(( "Import:Bad Item Key '%s'\n", s.GetKey()));
break;
}
else if ( s.IsKey("CONT" ))
{
m_pCurSer->m_dwContSer = ATOI(pArg);
}
else if ( s.IsKey("LAYER" ))
{
m_pCurSer->m_layer = static_cast<LAYER_TYPE>(ATOI(pArg));
continue;
}
else if (pItem == NULL)
{
DEBUG_ERR(( "Import:Found '%s' before ID.\n", s.GetKey()));
continue;
}
if ( s.IsKey("X" ))
{
CPointMap pt = pItem->GetTopPoint();
pt.m_x = static_cast<short>( ATOI(pArg) );
pItem->SetUnkPoint(pt);
continue;
}
else if ( s.IsKey("Y" ))
{
CPointMap pt = pItem->GetTopPoint();
pt.m_y = static_cast<short>( ATOI(pArg) );
pItem->SetUnkPoint(pt);
continue;
}
else if ( s.IsKey("Z" ))
{
CPointMap pt = pItem->GetTopPoint();
pt.m_z = static_cast<signed char>( ATOI(pArg) );
pItem->SetUnkPoint(pt);
continue;
}
else if ( s.IsKey("COLOR" ))
{
pItem->SetHue( static_cast<HUE_TYPE>( ATOI(pArg) ) );
continue;
}
else if ( s.IsKey("AMOUNT" ))
{
pItem->SetAmount( ATOI(pArg));
continue;
}
else if ( s.IsKey("MOREX" ))
{
pItem->m_itNormal.m_morep.m_x = static_cast<short>(ATOI(pArg));
continue;