void CItem::Spawn_GenerateChar( CResourceDef * pDef ) { if ( ! IsTopLevel()) return; // creatures can only be top level. if ( m_itSpawnChar.m_current >= GetAmount()) return; int iComplexity = GetTopSector()->GetCharComplexity(); if ( iComplexity > g_Cfg.m_iMaxCharComplexity ) { DEBUG_MSG(( "Spawn uid=0%lx too complex (%d>%d)\n", GetUID(), iComplexity, 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); int i = pSpawnGroup->GetRandMemberIndex(); if ( i >= 0 ) { rid = pSpawnGroup->GetMemberID(i); } } CREID_TYPE id; if ( rid.GetResType() == RES_CHARDEF || rid.GetResType() == RES_UNKNOWN ) { id = (CREID_TYPE) rid.GetResIndex(); } else { return; } CChar * pChar = CChar::CreateNPC( id ); if ( pChar == NULL ) return; ASSERT(pChar->m_pNPC); m_itSpawnChar.m_current ++; pChar->Memory_AddObjTypes( this, MEMORY_ISPAWNED ); // Move to spot "near" the spawn item. pChar->MoveNearObj( this, iDistMax ); if ( iDistMax ) { pChar->m_ptHome = GetTopPoint(); pChar->m_pNPC->m_Home_Dist_Wander = iDistMax; } pChar->Update(); }
CStoneMember::CStoneMember( CItemStone * pStone, CGrayUID uid, STONEPRIV_TYPE iType, LPCTSTR pTitle, CGrayUID loyaluid, bool fVal1, bool fVal2, int nAccountGold) { m_uidLinkTo = uid; m_sTitle = pTitle; m_iPriv = iType; m_uidLoyalTo = loyaluid; // union. if ( iType == STONEPRIV_ENEMY ) { m_Enemy.m_fTheyDeclared = fVal1; m_Enemy.m_fWeDeclared = fVal2; } else { m_Member.m_fAbbrev = fVal1; m_Member.m_iVoteTally = fVal2; // Temporary space to calculate votes. } m_Member.m_iAccountGold = nAccountGold; if ( ! g_Serv.IsLoading() && pStone->GetMemoryType()) { CChar * pChar = uid.CharFind(); if ( pChar != NULL ) { pChar->Memory_AddObjTypes(pStone, static_cast<WORD>(pStone->GetMemoryType())); if ( pStone->IsTopLevel()) { pChar->m_ptHome = pStone->GetTopPoint(); // Our new home. } } } pStone->InsertTail( this ); }