当前位置: 首页>>代码示例>>C++>>正文


C++ CNpc::Load方法代码示例

本文整理汇总了C++中CNpc::Load方法的典型用法代码示例。如果您正苦于以下问题:C++ CNpc::Load方法的具体用法?C++ CNpc::Load怎么用?C++ CNpc::Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CNpc的用法示例。


在下文中一共展示了CNpc::Load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateNpcThread

//	Npc Thread 를 만든다.
BOOL CServerDlg::CreateNpcThread()
{
    BOOL	bMoveNext	= TRUE;
    int		nSerial		= m_sMapEventNpc;
    int		nPathSerial = 1;
    int		nNpcCount	= 0;
    int		i=0, j=0;
    int nRandom = 0, nServerNum = 0;
    double  dbSpeed = 0;

    m_TotalNPC = 0;			// DB에 있는 수
    m_CurrentNPC = 0;
    m_CurrentNPCError = 0;

    CNpcTable*	pNpcTable = NULL;
    CRoomEvent* pRoom = NULL;

    CNpcPosSet NpcPosSet;

    char szPath[500];
    char szX[5];
    char szZ[5];

    float fRandom_X = 0.0f;
    float fRandom_Z = 0.0f;

    int nMonsterNumber = 0;

    try
    {
        if(NpcPosSet.IsOpen()) NpcPosSet.Close();
        if(!NpcPosSet.Open())	{
            AfxMessageBox(_T("MONSTER_POS DB Open Fail!"));
            return FALSE;
        }
        if(NpcPosSet.IsBOF())	{
            AfxMessageBox(_T("MONSTER_POS DB Empty!"));
            return FALSE;
        }

        NpcPosSet.MoveFirst();

        while(!NpcPosSet.IsEOF())	{
            nMonsterNumber = NpcPosSet.m_NumNPC;
            //if( NpcPosSet.m_ZoneID == 101 )	{	// 테스트를 위해서,,
            //	nMonsterNumber = 1;
            //if(nMonsterNumber > 4)	{
            //	nMonsterNumber = nMonsterNumber / 4;
            //}
            //}
            nServerNum = 0;
            nServerNum = GetServerNumber( NpcPosSet.m_ZoneID );

            if( m_byZone == nServerNum || m_byZone == UNIFY_ZONE)	{
                for(j=0; j<nMonsterNumber; j++)		{
                    CNpc*		pNpc		= new CNpc();

                    pNpc->m_byMoveType = NpcPosSet.m_ActType;
                    pNpc->m_byInitMoveType = NpcPosSet.m_ActType;

                    bool bMonster = (NpcPosSet.m_ActType < 100);
                    if (bMonster)
                        pNpcTable = m_arMonTable.GetData(NpcPosSet.m_NpcID);
                    else
                    {
                        pNpc->m_byMoveType = NpcPosSet.m_ActType - 100;
                        //pNpc->m_byInitMoveType = NpcPosSet.m_ActType - 100;
                        pNpcTable = m_arNpcTable.GetData(NpcPosSet.m_NpcID);
                    }

                    if (pNpcTable == NULL)
                    {
                        char buff[128] = {0};
                        sprintf(buff, "NPC %d not found in %s table.", pNpc->m_sNid, bMonster ? "K_MONSTER" : "K_NPC");
                        AfxMessageBox(buff);
                        delete pNpc;
                        return FALSE;
                    }

                    pNpc->Load(nSerial++, pNpcTable);
                    pNpc->m_byBattlePos = 0;

                    if(pNpc->m_byMoveType >= 2)	{
                        pNpc->m_byBattlePos = myrand( 1, 3 );
                        pNpc->m_byPathCount = nPathSerial++;
                    }

                    pNpc->InitPos();

                    if( bMoveNext )	{
                        bMoveNext = FALSE;
                        nNpcCount = NpcPosSet.m_NumNPC;
                    }

                    //////// MONSTER POS ////////////////////////////////////////
                    pNpc->m_bCurZone = NpcPosSet.m_ZoneID;

                    // map에 몬스터의 위치를 랜덤하게 위치시킨다.. (테스트 용 : 수정-DB에서 읽어오는데로 몬 위치 결정)
                    nRandom = abs(NpcPosSet.m_LeftX - NpcPosSet.m_RightX);
//.........这里部分代码省略.........
开发者ID:jakenewby,项目名称:snoxd-koserver-1,代码行数:101,代码来源:ServerDlg.cpp

示例2: LoadSpawnCallback

bool CServerDlg::LoadSpawnCallback(OdbcCommand *dbCommand)
{
    // Avoid allocating stack space for these.
    // This method will only ever run in the same thread.
    static int nRandom = 0;
    static double dbSpeed = 0;
    static CNpcTable * pNpcTable = NULL;
    static CRoomEvent* pRoom = NULL;
    static char szPath[500];
    static float fRandom_X = 0.0f, fRandom_Z = 0.0f;

    // Unfortunately we cannot simply read what we need directly
    // into the CNpc instance. We have to resort to creating
    // copies of the data to allow for the way they handle multiple spawns...
    // Best we can do, I think, is to avoid allocating it on the stack.
    static uint8	bNumNpc, bZoneID, bActType, bRegenType, bDungeonFamily, bSpecialType,
              bTrapNumber, bDirection, bDotCnt;
    static uint16	sSid, sRegTime;
    static uint32	nServerNum;
    static int32	iLeftX, iTopZ, iRightX, iBottomZ,
              iLimitMinX, iLimitMinZ, iLimitMaxX, iLimitMaxZ;

    dbCommand->FetchByte(1, bZoneID);
    dbCommand->FetchUInt16(2, sSid);
    dbCommand->FetchByte(3, bActType);
    dbCommand->FetchByte(4, bRegenType);
    dbCommand->FetchByte(5, bDungeonFamily);
    dbCommand->FetchByte(6, bSpecialType);
    dbCommand->FetchByte(7, bTrapNumber);
    dbCommand->FetchInt32(8, iLeftX);
    dbCommand->FetchInt32(9, iTopZ);
    dbCommand->FetchInt32(10, iRightX);
    dbCommand->FetchInt32(11, iBottomZ);
    dbCommand->FetchInt32(12, iLimitMinZ);
    dbCommand->FetchInt32(13, iLimitMinX);
    dbCommand->FetchInt32(14, iLimitMaxX);
    dbCommand->FetchInt32(15, iLimitMaxZ);
    dbCommand->FetchByte(16, bNumNpc);
    dbCommand->FetchUInt16(17, sRegTime);
    dbCommand->FetchByte(18, bDirection);
    dbCommand->FetchByte(19, bDotCnt);
    dbCommand->FetchString(20, szPath, sizeof(szPath));

    nServerNum = GetServerNumber(bZoneID);

    if (m_byZone == nServerNum || m_byZone == UNIFY_ZONE)
    {
        uint8 bPathSerial = 1;
        for (uint8 j = 0; j < bNumNpc; j++)
        {
            CNpc * pNpc = new CNpc();

            pNpc->m_byMoveType = bActType;
            pNpc->m_byInitMoveType = bActType;

            bool bMonster = (bActType < 100);
            if (bMonster)
            {
                pNpcTable = m_arMonTable.GetData(sSid);
            }
            else
            {
                pNpc->m_byMoveType = bActType - 100;
                pNpcTable = m_arNpcTable.GetData(sSid);
            }

            if (pNpcTable == NULL)
            {
                printf("NPC %d not found in %s table.\n", pNpc->m_sNid, bMonster ? "K_MONSTER" : "K_NPC");
                delete pNpc;
                return false;
            }

            pNpc->Load(m_TotalNPC++, pNpcTable);
            pNpc->m_byBattlePos = 0;

            if (pNpc->m_byMoveType >= 2)
            {
                pNpc->m_byBattlePos = myrand(1, 3);
                pNpc->m_byPathCount = bPathSerial++;
            }

            pNpc->InitPos();

            pNpc->m_bCurZone = bZoneID;

            nRandom = abs(iLeftX - iRightX);
            if (nRandom <= 1)
                fRandom_X = (float)iLeftX;
            else
            {
                if (iLeftX < iRightX)
                    fRandom_X = (float)myrand(iLeftX, iRightX);
                else
                    fRandom_X = (float)myrand(iRightX, iLeftX);
            }

            nRandom = abs(iTopZ - iBottomZ);
            if (nRandom <= 1)
                fRandom_Z = (float)iTopZ;
//.........这里部分代码省略.........
开发者ID:heaheart,项目名称:snoxd-koserver,代码行数:101,代码来源:ServerDlg.cpp


注:本文中的CNpc::Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。