Пример #1
0
BOOL KCheckHeroBlowupFunc::operator()(KHero* pHero)
{
    BOOL bResult    = false;
    BOOL bRetCode   = false;
    KLandMine* pLandMine = (KLandMine*)m_pLandMine;
    KVELOCITY vBlowupVelocity = {0};
    KPOSITION Src;
    KPOSITION Dest;
    int nDamage = 0;

    assert(m_pLandMine);

    KGLOG_PROCESS_ERROR(pLandMine->m_nBlowupRange > 0);

    bRetCode = pHero->CanBeAttacked();
    KG_PROCESS_SUCCESS(!bRetCode);

    Src   = pLandMine->GetPosition();
    Dest  = pHero->GetPosition();
    Dest.nZ += pHero->m_nHeight / 2;

    bRetCode = g_InRange(Dest.nX, Dest.nY, Dest.nZ, Src.nX, Src.nY, Src.nZ, pLandMine->m_nBlowupRange);
    KG_PROCESS_SUCCESS(!bRetCode);

    bRetCode = pHero->ApplyGeneralAffect(pLandMine->m_dwAttakerID, pLandMine, pLandMine->m_pTemplate->m_dwAttackAffectID1);
    KGLOG_PROCESS_ERROR(bRetCode);

Exit1:
    bResult = true;
Exit0:
    return bResult;
}
Пример #2
0
void KMathFunctionTest::KMathTest_6725()
{
    int nRetCode = false;
    char szTestCaseDscribe[] = "距离是否在指定范围内 两点间距离等于范围的上限";

    nRetCode = g_InRange(0, 0, 0, 3, 4, 0, 1, 5);  

    KG_CASE_INFO(szTestCaseDscribe, "");
    KG_CPPUNIT_ASSERT(nRetCode == irrInRange);
}
Пример #3
0
void KMathFunctionTest::KMathTest_6722()
{
    int nRetCode = false;
    char szTestCaseDscribe[] = "距离是否在指定范围内 两点间距离小于范围的下限";

    nRetCode = g_InRange(0, 0, 0, 1, 1, 1, 5, 10);

    KG_CASE_INFO(szTestCaseDscribe, "");
    KG_CPPUNIT_ASSERT(nRetCode == irrTooClose);
}
Пример #4
0
void KMathFunctionTest::KMathTest_6721()
{
    int nRetCode = false;
    char szTestCaseDscribe[] = "距离是否在指定数值内 两点间距离超出int上限";

    nRetCode = g_InRange(0, 0, 0, 2147483647, 2147483647, 2147483647, 1000);

    KG_CASE_INFO(szTestCaseDscribe, "");
    KG_CPPUNIT_ASSERT(nRetCode);
}
Пример #5
0
void KMathFunctionTest::KMathTest_6720()
{
    int nRetCode = false;
    char szTestCaseDscribe[] = "距离是否在指定数值内 两点间距离等于指定数值";

    nRetCode = g_InRange(0, 0, 0, 3, 4, 0, 5);

    KG_CASE_INFO(szTestCaseDscribe, "");
    KG_CPPUNIT_ASSERT(nRetCode);
}
Пример #6
0
void KMathFunctionTest::KMathTest_6726()
{
    int nRetCode = false;
    char szTestCaseDscribe[] = "距离是否在指定范围内 两点间距离大于范围的上限";

    nRetCode = g_InRange(0, 0, 0, 5, 5, 5, 1, 4);  

    KG_CASE_INFO(szTestCaseDscribe, "");
    KG_CPPUNIT_ASSERT(nRetCode == irrTooFar);
}
Пример #7
0
void KMathFunctionTest::KMathTest_6719()
{
    int nRetCode = false;
    char szTestCaseDscribe[] = "距离是否在指定数值内 两点间距离大于指定数值";

    nRetCode = g_InRange(1, 1, 1, 2, 2, 2, 1);


    KG_CASE_INFO(szTestCaseDscribe, "");
    KG_CPPUNIT_ASSERT(!nRetCode);
}
Пример #8
0
int KScene::LuaRemoveDoodad(Lua_State* L)
{
    int     nResult         = 0;
    BOOL    bRetCode        = false;
    int     nTopIndex       = 0;
    int     nPosX           = 0;
    int     nPosY           = 0;
    int     nRange          = 0;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 3);

    nPosX       = (int)Lua_ValueToNumber(L, 1);
    nPosY       = (int)Lua_ValueToNumber(L, 2);
    nRange      = (int)Lua_ValueToNumber(L, 3);
    
    for (KObjEnumerator it = m_pSceneObjMgr->GetEnumerator(); it.HasElement(); it.MoveToNext())
    {
        KSceneObject* pObj = it.GetValue();
        if (!g_IsDoodad(pObj))
            continue;

        assert(pObj->m_pTemplate);

        if (pObj->m_pTemplate->m_bImpregnability) // ²»¿ÉÒƳý
            continue;

        if (nRange != -1) // ¼ì²é¾àÀë
        {
            KPOSITION pos = pObj->GetPosition();
            bRetCode = g_InRange(nPosX, nPosY, 0, pos.nX, pos.nY, 0, nRange);
            if (!bRetCode)
                continue;
        }
        RemoveSceneObject(pObj);
    }
    
Exit0:
    return 0;
}
Пример #9
0
void KEscortQuestManager::OnQuestRunning(DWORD dwQuestID, KEscortQuest* pEscortQuest)
{   
    BOOL     bRetCode           = false;
    KPlayer* pPlayer            = NULL;
    KNpc*    pEscortNpc         = NULL;
    BOOL     bAllPlayerFailed   = true;
    int      nQuestPhase        = 0;
    int      nQuestIndex        = -1; 

    assert(pEscortQuest);
    
    for (int i = 0; i < MAX_PARTY_SIZE; ++i)
    {
        if (pEscortQuest->dwPlayerID[i] == ERROR_ID || !pEscortQuest->bValid[i])
        {
            continue;
        }

        assert(g_pSO3World);
        pPlayer = g_pSO3World->m_PlayerSet.GetObj(pEscortQuest->dwPlayerID[i]);
        if (pPlayer == NULL || pPlayer->m_pScene == NULL)
        {
            pEscortQuest->dwPlayerID[i] = ERROR_ID;
            pEscortQuest->bValid[i] = false;
            continue;
        }
        
        nQuestPhase = pPlayer->m_QuestList.GetQuestPhase(dwQuestID);
        if (nQuestPhase == 2 || nQuestPhase == 3)
        {
            pEscortQuest->eQuestState = eqsFinished;
            goto Exit0;
        }
    }

    pEscortNpc = g_pSO3World->m_NpcSet.GetObj(pEscortQuest->dwNpcEscortID);    
    if (pEscortNpc == NULL || pEscortNpc->m_pScene == NULL || g_pSO3World->m_nGameLoop > pEscortQuest->nEndFrames)
    {
        for (int i = 0; i < MAX_PARTY_SIZE; ++i)
        {     
            if (pEscortQuest->dwPlayerID[i] == ERROR_ID || !pEscortQuest->bValid[i])
            {
                continue;
            }

            pPlayer = g_pSO3World->m_PlayerSet.GetObj(pEscortQuest->dwPlayerID[i]);
            if (pPlayer == NULL || pPlayer->m_pScene == NULL)
            {
                pEscortQuest->dwPlayerID[i] = ERROR_ID;
                pEscortQuest->bValid[i] = false;
                continue;
            }

            nQuestIndex = pPlayer->m_QuestList.GetQuestIndex(dwQuestID);
            if (nQuestIndex == -1)
            {
                pEscortQuest->dwPlayerID[i] = ERROR_ID;
                pEscortQuest->bValid[i] = false;
                continue;
            }
            
            pPlayer->m_QuestList.SetQuestFailedFlag(nQuestIndex, true);            
            continue;
        }

        CloseEscortQuest(dwQuestID, 3 * GAME_FPS);

        goto Exit0;
    }
    
    for (int i = 0; i < MAX_PARTY_SIZE; ++i)
    {
        if (pEscortQuest->dwPlayerID[i] == ERROR_ID || !pEscortQuest->bValid[i])
        {
            continue;
        }
        
        pPlayer = g_pSO3World->m_PlayerSet.GetObj(pEscortQuest->dwPlayerID[i]);
        if (pPlayer == NULL || pPlayer->m_pScene == NULL)
        {
            pEscortQuest->dwPlayerID[i] = ERROR_ID;
            pEscortQuest->bValid[i] = false;
            continue;
        }

        bRetCode = g_InRange(pEscortNpc, pPlayer, ESCORT_RANGE);
        if (!bRetCode)
        {
            nQuestIndex = pPlayer->m_QuestList.GetQuestIndex(dwQuestID);
            if (nQuestIndex == -1)
            {
                pEscortQuest->dwPlayerID[i] = ERROR_ID;
                pEscortQuest->bValid[i] = false;
                continue;
            }
            
            pPlayer->m_QuestList.SetQuestFailedFlag(nQuestIndex, true);
            continue;
        }
        
        bAllPlayerFailed = false; // 还有玩家没有失败
    }
        
    if (bAllPlayerFailed) // 所有玩家都失败了
    {
        CloseEscortQuest(dwQuestID, 3 * GAME_FPS);
    }

Exit0:
    return;
}
Пример #10
0
BOOL KEscortQuestManager::InvitePlayerInParty(DWORD dwQuestID, KPlayer* pPlayerAccept)
{
    BOOL                         bResult = false;
    BOOL                         bRetCode = false;
    KQuestInfo*                  pQuestInfo = NULL;
    KTeam*                       pTeam      = NULL;
    KTarget                      Target;

    assert(pPlayerAccept);
    
    KG_PROCESS_SUCCESS(pPlayerAccept->m_dwTeamID == ERROR_ID);
        
    pQuestInfo = g_pSO3World->m_Settings.m_QuestInfoList.GetQuestInfo(dwQuestID);
    KGLOG_PROCESS_ERROR(pQuestInfo);
    
    bRetCode = Target.SetTarget(pPlayerAccept);
    KGLOG_PROCESS_ERROR(bRetCode);

    pTeam = g_pSO3World->m_TeamServer.GetTeam(pPlayerAccept->m_dwTeamID);
    KGLOG_PROCESS_ERROR(pTeam);
    
    for (int i = 0; i < pTeam->nGroupNum; i++)
    {
        for (
            KTEAM_MEMBER_LIST::iterator it = pTeam->MemberGroup[i].MemberList.begin();
            it != pTeam->MemberGroup[i].MemberList.end(); ++it
        )
        {
            QUEST_RESULT_CODE   eRetCode    = qrcFailed;
            KPlayer*            pMember     = NULL;

            if (it->dwMemberID == pPlayerAccept->m_dwID)
            {
                continue;
            }

            pMember = g_pSO3World->m_PlayerSet.GetObj(it->dwMemberID);
            if (pMember == NULL || pMember->m_pScene == NULL)
            {
                continue;
            }

            if (pMember->m_pScene != pPlayerAccept->m_pScene)
            {
                continue;
            }

            bRetCode = g_InRange(pPlayerAccept, pMember, ESCORT_RANGE);
            if (!bRetCode)
            {
                continue;
            }

            eRetCode = pMember->m_QuestList.CanAccept(pQuestInfo, &Target);
            if (eRetCode != qrcSuccess)
            {
                continue;
            }

            g_PlayerServer.DoStartEscortQuest(pMember->m_nConnIndex, pPlayerAccept->m_dwID, dwQuestID);
        }
    }

Exit1:
    bResult = true;
Exit0:
    return bResult;
}