本文整理汇总了C++中CItem::GetTopZ方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::GetTopZ方法的具体用法?C++ CItem::GetTopZ怎么用?C++ CItem::GetTopZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::GetTopZ方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: NPC_CheckWalkHere
bool CChar::NPC_CheckWalkHere( const CPointBase & pt, const CRegionBase * pArea, WORD wBlockFlags ) const
{
ADDTOCALLSTACK("CChar::NPC_CheckWalkHere");
UNREFERENCED_PARAMETER(wBlockFlags);
// Does the NPC want to walk here ? step on this item ?
if ( !m_pNPC )
return false;
if ( !pt.IsValidXY() )
return true;
if ( m_pArea != NULL )
{
if ( m_pNPC->m_Brain == NPCBRAIN_GUARD && !IsStatFlag(STATF_War) ) // guards will want to stay in guard range
{
if ( m_pArea->IsGuarded() && !pArea->IsGuarded() )
return false;
}
if ( Noto_IsCriminal() )
{
if ( !m_pArea->IsGuarded() && pArea->IsGuarded() )
return false;
}
}
// Is there a nasty object here that will hurt us ?
CWorldSearch AreaItems(pt);
for (;;)
{
CItem * pItem = AreaItems.GetItem();
if ( pItem == NULL )
break;
if ( abs(pItem->GetTopZ() - pt.m_z) > 5 )
continue;
switch ( pItem->GetType() )
{
case IT_WEB:
return (GetDispID() == CREID_GIANT_SPIDER) ? true : false;
case IT_FIRE:
return Can(CAN_C_FIRE_IMMUNE);
case IT_TRAP:
case IT_TRAP_ACTIVE:
case IT_MOONGATE:
case IT_TELEPAD:
return false;
default:
break;
}
}
return true;
}
示例3: GetHeightPoint
//.........这里部分代码省略.........
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 )
{
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);
zHeight = pItemDef->GetHeight();
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK );
}
else
{
zHeight = pDupeDef->GetHeight();
wBlockThis = ( pDupeDef->m_Can & CAN_I_MOVEMASK ); //Use only Block flags, other remove - CAN flags cannot be inherited from the parent item due to bad script pack...
}
}
}
else if ( pMultiItem->GetDispID() )
CItemBase::GetItemTiledataFlags(wBlockThis,pMultiItem->GetDispID());
block.CheckTile_Item( wBlockThis, z, zHeight, pMultiItem->GetDispID() + TERRAIN_QTY );
}
示例4: GetFixPoint
//.........这里部分代码省略.........
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 );
z += ((wBlockThis & CAN_I_CLIMB) ? pItemDef->GetHeight()/2 : pItemDef->GetHeight());
}
else
{
wBlockThis = ( pDupeDef->m_Can & CAN_I_MOVEMASK );
z += ((wBlockThis & CAN_I_CLIMB) ? pDupeDef->GetHeight()/2 : pDupeDef->GetHeight());
}
}
}
else if ( pMultiItem->GetDispID() )
CItemBase::GetItemTiledataFlags(wBlockThis,pMultiItem->GetDispID());
if (block.m_Bottom.m_z < z)
{
if ((z < pt.m_z+PLAYER_HEIGHT) && (wBlockThis & (CAN_I_PLATFORM|CAN_I_CLIMB|CAN_I_WATER)))
{
示例5: 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);
//.........这里部分代码省略.........
示例6: ImportFix
void CImportFile::ImportFix()
{
ADDTOCALLSTACK("CImportFile::ImportFix");
// adjust all the containered items and eliminate duplicates.
CheckLast();
int iRemoved = 0;
CImportSer * pSerNext;
m_pCurSer = static_cast <CImportSer*> ( m_ListSer.GetHead());
for ( ; m_pCurSer != NULL; m_pCurSer = pSerNext )
{
pSerNext = static_cast <CImportSer*> ( m_pCurSer->GetNext());
if ( m_pCurSer->m_pObj == NULL ) // NEver created correctly
{
delete m_pCurSer;
continue;
}
// Make sure this item is not a dupe ?
CItem * pItemTest;
if ( m_pCurSer->IsTopLevel()) // top level only
{
if ( m_pCurSer->m_pObj->IsItem())
{
CItem * pItemCheck = dynamic_cast <CItem*>( m_pCurSer->m_pObj );
ASSERT(pItemCheck);
pItemCheck->SetAttr(ATTR_MOVE_NEVER);
CWorldSearch AreaItems( m_pCurSer->m_pObj->GetTopPoint());
for (;;)
{
CItem * pItem = AreaItems.GetItem();
if ( pItem == NULL )
break;
if ( ! pItem->IsSameType( m_pCurSer->m_pObj ))
continue;
pItem->SetName( m_pCurSer->m_pObj->GetName());
if ( ! ( m_pCurSer->m_pObj->GetTopZ() == pItem->GetTopZ()))
continue;
goto item_delete;
}
}
else
{
// dupe char ?
}
// Make sure the top level object is placed correctly.
m_pCurSer->m_pObj->MoveTo( m_pCurSer->m_pObj->GetTopPoint());
m_pCurSer->m_pObj->Update();
if ( ! m_pCurSer->m_pObj->IsContainer())
delete m_pCurSer;
continue;
}
pItemTest = dynamic_cast <CItem*> (m_pCurSer->m_pObj);
if ( pItemTest == NULL )
{
item_delete:
delete m_pCurSer->m_pObj;
delete m_pCurSer;
iRemoved ++;
continue;
}
// Find it's container.
CImportSer* pSerCont = static_cast <CImportSer*> ( m_ListSer.GetHead());
CObjBase * pObjCont = NULL;
for ( ; pSerCont != NULL; pSerCont = static_cast <CImportSer*> ( pSerCont->GetNext()))
{
if ( pSerCont->m_pObj == NULL )
continue;
if ( pSerCont->m_dwSer == m_pCurSer->m_dwContSer )
{
pObjCont = pSerCont->m_pObj;
if ( ! pItemTest->LoadSetContainer( pObjCont->GetUID(), m_pCurSer->m_layer ))
{
goto item_delete; // not in a cont ?
}
m_pCurSer->m_dwContSer = UID_UNUSED; // found it.
break;
}
}
if ( ! m_pCurSer->IsTopLevel() || pObjCont == NULL)
{
goto item_delete;
}
// Is it a dupe in the container or equipped ?
for ( CItem *pItem = dynamic_cast<CContainer*>(pObjCont)->GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
{
if ( pItemTest == pItem )
continue;
if ( pItemTest->IsItemEquipped())
{
if ( pItemTest->GetEquipLayer() != pItem->GetEquipLayer())
continue;
//.........这里部分代码省略.........
示例7: r_WriteVal
//.........这里部分代码省略.........
}
if ( pMultiItem == NULL )
{
sVal.FormatHex(0);
return true;
}
SKIP_SEPARATORS( pszKey );
if ( !*pszKey )
pszKey = "ID";
ITEMID_TYPE idTile = pMultiItem->GetDispID();
if ( strnicmp( pszKey, "ID", 2 ) == 0 )
{
sVal.FormatHex( idTile );
return true;
}
else if ( strnicmp( pszKey, "MULTI", 5 ) == 0 )
{
pszKey += 5;
if (*pszKey != '\0')
{
SKIP_SEPARATORS(pszKey);
return pItem->r_WriteVal( pszKey, sVal, &g_Serv );
}
sVal.FormatHex( pItem->GetUID() );
return true;
}
else if ( strnicmp( pszKey, "Z", 1 ) == 0 )
{
sVal.FormatVal( pItem->GetTopZ() + pMultiItem->m_dz );
return true;
}
// Check the script def for the item.
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 );
}
int index = FindTableHeadSorted( pszKey, sm_szLoadKeys, COUNTOF(sm_szLoadKeys)-1 );
if ( index < 0 )
return false;
switch ( index )
{
case PT_M:
case PT_MAP:
sVal.FormatVal(m_map);
break;
case PT_X:
sVal.FormatVal(m_x);
break;
case PT_Y:
sVal.FormatVal(m_y);
break;
case PT_Z:
sVal.FormatVal(m_z);
示例8: MergeDupes
void CImportFile::MergeDupes()
{
ADDTOCALLSTACK("CImportFile::MergeDupes");
// place all items and eliminate duplicates.
CheckLast();
int iRemoved = 0;
CImportSer *pSerNext;
m_pCurSer = static_cast<CImportSer *>(m_ListSer.GetHead());
for ( ; m_pCurSer != NULL; m_pCurSer = pSerNext )
{
pSerNext = static_cast<CImportSer *>(m_pCurSer->GetNext());
if ( m_pCurSer->m_pObj == NULL ) // never created correctly
{
delete m_pCurSer;
continue;
}
// Make sure this item is not a dupe ?
CItem *pItemTest;
if ( m_pCurSer->IsTopLevel() ) // top level only
{
if ( m_pCurSer->m_pObj->IsItem() )
{
CItem *pItemCheck = dynamic_cast<CItem *>(m_pCurSer->m_pObj);
ASSERT(pItemCheck);
pItemCheck->SetAttr(ATTR_MOVE_NEVER);
CWorldSearch AreaItems(m_pCurSer->m_pObj->GetTopPoint());
for (;;)
{
CItem *pItem = AreaItems.GetItem();
if ( pItem == NULL )
break;
if ( !pItem->IsIdentical(m_pCurSer->m_pObj ))
continue;
pItem->SetName(m_pCurSer->m_pObj->GetName());
if ( !(m_pCurSer->m_pObj->GetTopZ() == pItem->GetTopZ()) )
continue;
goto item_delete;
}
}
// Make sure the top level object is placed correctly.
m_pCurSer->m_pObj->MoveTo(m_pCurSer->m_pObj->GetTopPoint());
m_pCurSer->m_pObj->Update();
if ( !m_pCurSer->m_pObj->IsContainer() )
delete m_pCurSer;
continue;
}
pItemTest = dynamic_cast <CItem*> (m_pCurSer->m_pObj);
if ( pItemTest == NULL )
{
item_delete:
delete m_pCurSer->m_pObj;
delete m_pCurSer;
iRemoved ++;
continue;
}
delete m_pCurSer;
}
if ( iRemoved )
{
DEBUG_ERR(( "Import: removed %d bad items\n", iRemoved ));
}
m_ListSer.DeleteAll(); // done with the list now.
}