本文整理汇总了C++中CChar::NPC_LoadScript方法的典型用法代码示例。如果您正苦于以下问题:C++ CChar::NPC_LoadScript方法的具体用法?C++ CChar::NPC_LoadScript怎么用?C++ CChar::NPC_LoadScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CChar
的用法示例。
在下文中一共展示了CChar::NPC_LoadScript方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RespawnDeadNPCs
void CSector::RespawnDeadNPCs()
{
ADDTOCALLSTACK("CSector::RespawnDeadNPCs");
// skip sectors in unsupported maps
if ( !g_MapList.m_maps[m_map] ) return;
// Respawn dead NPC's
CChar * pCharNext;
CChar * pChar = STATIC_CAST <CChar *>( m_Chars_Disconnect.GetHead());
for ( ; pChar != NULL; pChar = pCharNext )
{
pCharNext = pChar->GetNext();
if ( ! pChar->m_pNPC )
continue;
if ( ! pChar->m_ptHome.IsValidPoint())
continue;
if ( ! pChar->IsStatFlag( STATF_DEAD ))
continue;
// Restock them with npc stuff.
pChar->NPC_LoadScript(true);
// Res them back to their "home".
int iDist = pChar->m_pNPC->m_Home_Dist_Wander;
pChar->MoveNear( pChar->m_ptHome, ( iDist < SHRT_MAX ) ? iDist : 4 );
pChar->NPC_CreateTrigger(); //Removed from NPC_LoadScript() and triggered after char placement
pChar->Spell_Resurrection();
}
}
示例2: CreateBasic
CChar * CChar::CreateNPC( CREID_TYPE baseID ) // static
{
ADDTOCALLSTACK("CChar::CreateNPC");
CChar * pChar = CreateBasic(baseID);
ASSERT(pChar);
pChar->NPC_LoadScript(true);
pChar->NPC_CreateTrigger();
return pChar;
}
示例3: GenerateChar
void CItemSpawn::GenerateChar(CResourceDef *pDef)
{
ADDTOCALLSTACK("CitemSpawn:GenerateChar");
RESOURCE_ID_BASE rid = pDef->GetResourceID();
if ( rid.GetResType() == RES_SPAWN )
{
const CRandGroupDef *pSpawnGroup = static_cast<const CRandGroupDef *>(pDef);
ASSERT(pSpawnGroup);
size_t i = pSpawnGroup->GetRandMemberIndex();
if ( i != pSpawnGroup->BadMemberIndex() )
rid = pSpawnGroup->GetMemberID(i);
}
if ( (rid.GetResType() != RES_CHARDEF) && (rid.GetResType() != RES_UNKNOWN) )
return;
CPointMap pt = GetTopPoint();
CRegionBase *pRegion = pt.GetRegion(REGION_TYPE_AREA);
if ( !pRegion )
return;
CChar *pChar = CChar::CreateBasic(static_cast<CREID_TYPE>(rid.GetResIndex()));
if ( !pChar )
return;
pChar->NPC_LoadScript(true);
pChar->StatFlag_Set(STATF_Spawned);
// Try placing the char near the spawn
if ( !pChar->MoveNearObj(this, m_itSpawnChar.m_DistMax) || !pChar->CanSeeLOS(pt) )
{
// If this fails, try placing the char over the spawn
if ( !pChar->MoveTo(pt) )
{
DEBUG_ERR(("Spawn UID:0%lx is unable to place a character inside the world.\n", static_cast<DWORD>(GetUID())));
pChar->Delete();
return;
}
}
AddObj(pChar->GetUID());
pChar->NPC_CreateTrigger(); // removed from NPC_LoadScript() and triggered after char placement and attachment to the spawnitem
pChar->Update();
size_t iCount = GetTopSector()->GetCharComplexity();
if ( iCount > g_Cfg.m_iMaxCharComplexity )
g_Log.Event(LOGL_WARN, "%" FMTSIZE_T " chars at %s. Sector too complex!\n", iCount, GetTopSector()->GetBasePoint().WriteUsed());
}
示例4: GenerateChar
void CItemSpawn::GenerateChar(CResourceDef *pDef)
{
ADDTOCALLSTACK("CitemSpawn:GenerateChar");
if ( !IsTopLevel() )
return;
RESOURCE_ID_BASE rid = pDef->GetResourceID();
if ( rid.GetResType() == RES_SPAWN )
{
const CRandGroupDef *pSpawnGroup = static_cast<const CRandGroupDef *>(pDef);
ASSERT(pSpawnGroup);
size_t i = pSpawnGroup->GetRandMemberIndex();
if ( i != pSpawnGroup->BadMemberIndex() )
rid = pSpawnGroup->GetMemberID(i);
}
if ( (rid.GetResType() != RES_CHARDEF) && (rid.GetResType() != RES_UNKNOWN) )
return;
CChar *pChar = CChar::CreateBasic(static_cast<CREID_TYPE>(rid.GetResIndex()));
if ( !pChar )
return;
CPointMap pt = GetTopPoint();
pChar->NPC_LoadScript(true);
pChar->StatFlag_Set(STATF_Spawned);
pChar->MoveTo(pt);
// Check if the NPC can spawn in this region
CRegionBase *pRegion = GetTopPoint().GetRegion(REGION_TYPE_AREA);
if ( !pRegion || (pRegion->IsGuarded() && pChar->Noto_IsEvil()) )
{
pChar->Delete();
return;
}
AddObj(pChar->GetUID());
pChar->NPC_CreateTrigger(); // removed from NPC_LoadScript() and triggered after char placement and attachment to the spawnitem
pChar->Update();
size_t iCount = GetTopSector()->GetCharComplexity();
if ( iCount > g_Cfg.m_iMaxCharComplexity )
g_Log.Event(LOGL_WARN, "%d chars at %s. Sector too complex!\n", iCount, GetTopSector()->GetBasePoint().WriteUsed());
}
示例5: GenerateChar
void CItemSpawn::GenerateChar(CResourceDef * pDef)
{
ADDTOCALLSTACK("CitemSpawn:GenerateChar");
if ( !IsTopLevel() || ( m_itSpawnChar.m_current >= GetAmount() ) || ( GetTopSector()->GetCharComplexity() > g_Cfg.m_iMaxCharComplexity ))
return;
int iDistMax = m_itSpawnChar.m_DistMax;
RESOURCE_ID_BASE rid = pDef->GetResourceID();
if ( rid.GetResType() == RES_SPAWN )
{
const CRandGroupDef * pSpawnGroup = STATIC_CAST <const CRandGroupDef *>(pDef);
ASSERT(pSpawnGroup);
size_t i = pSpawnGroup->GetRandMemberIndex();
if ( i != pSpawnGroup->BadMemberIndex() )
{
rid = pSpawnGroup->GetMemberID(i);
}
}
if (( rid.GetResType() != RES_CHARDEF ) && ( rid.GetResType() != RES_UNKNOWN ))
return;
CREID_TYPE id = static_cast<CREID_TYPE>(rid.GetResIndex());
bool isBadPlaceToSpawn = false;
CChar * pChar = CChar::CreateBasic(id);
if( pChar == NULL )
{
return;
}
pChar->NPC_LoadScript(true);
AddObj(pChar->GetUID());
pChar->m_uidSpawnItem = GetUID(); // SpawnItem for this char
pChar->StatFlag_Set( STATF_Spawned );
pChar->MoveTo(GetTopPoint());
pChar->NPC_CreateTrigger(); //Removed from NPC_LoadScript() and triggered after char placement
if( pChar->GetRegion() == NULL )
{
isBadPlaceToSpawn = true;
}
else if( pChar->GetRegion()->IsGuarded() && pChar->Noto_IsEvil() )
{
isBadPlaceToSpawn = true;
}
// Deny definitely known a bad place to spawn (like red NPCs in guarded areas)
// Usually caused by wide range near the edge of the towns
if( isBadPlaceToSpawn )
{
pChar->Delete();
//m_itSpawnChar.m_current--;
return;
}
ASSERT(pChar->m_pNPC);
if ( iDistMax )
{
pChar->m_ptHome = GetTopPoint();
pChar->m_pNPC->m_Home_Dist_Wander = static_cast<WORD>(iDistMax);
}
pChar->Update();
}