BOOL KHeroPackage::UnApplyEquip(KHero* pHero)
{
    BOOL    bResult     = false;
    BOOL    bRetCode    = false;
    const KItemProperty* pcItemProperty = NULL;

    for (int i = eipEquipBegin; i < eipTotal; ++i)
    {
        IItem* pItem = GetItem(i);
        if (pItem == NULL)
            continue;
        
        pcItemProperty = pItem->GetProperty();
        KGLOG_PROCESS_ERROR(pcItemProperty);

        pHero->UnApplyAttribute(pcItemProperty->pBaseAttr);
        pHero->UnApplyAttribute(pcItemProperty->pExtAttr);
    }    

    bResult = true;
Exit0:
    return bResult;
}
Example #2
0
BOOL KAwardMgr::Award(KPlayer* pPlayer, KAWARD_CARD_TYPE eType, DWORD dwAwardID, unsigned uChooseIndex, BOOL bEndChoose)
{
    BOOL            bResult         = false;
    BOOL            bRetCode        = false;
    IItem*          pItem           = NULL;
    KAwardTable*    pAwardTable     = NULL;
    KAWARD_ITEM*    pAwardItem      = NULL;
    KS2C_Award_Item arrAwardList[cdVipCardCount] = {0};
    IItem*          pLookItem = NULL;
    KSystemMailTxt* pSysMailTxt = NULL;
    KAWARD_ITEM*    pTempItem = NULL;
    KS2C_Award_Item* pAwardItemInfo = NULL;
    KS2C_Award_Item AwardItem;
    DWORD           dwRandSeed = 0;
    int nValuePoint = 0;

    assert(pPlayer);

    KGLOG_PROCESS_ERROR(uChooseIndex < countof(arrAwardList));

    pAwardTable = GetAwardTable(dwAwardID);
    KGLOG_PROCESS_ERROR(pAwardTable);

    pAwardItem = pAwardTable->GetRandomAward();
    if (pAwardItem)
    {
        if (pAwardItem->dwTabType == ittOther || pAwardItem->dwTabType == ittEquip)
        { 
            pSysMailTxt = g_pSO3World->m_Settings.m_SystemMailMgr.GetSystemMailTxt(KMAIL_CHOOSE);
            KGLOG_PROCESS_ERROR(pSysMailTxt);

            bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
            KGLOG_PROCESS_ERROR(bRetCode);
            
            dwRandSeed = KG_GetTickCount();

            bRetCode = pPlayer->SafeAddItem(pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, 
                pSysMailTxt->m_szMailTitl, pSysMailTxt->m_szSendName, pSysMailTxt->m_szMailTxt, dwRandSeed
            );

            pItem = g_pSO3World->m_ItemHouse.CreateItem(pAwardItem->dwTabType, pAwardItem->dwIndex, 0, dwRandSeed, nValuePoint);

            if (bRetCode)
            {
                BroadCastAwardItem(pPlayer, pAwardItem);
 
                if (eType == KAWARD_CARD_TYPE_NORMAL)
                {
                    PLAYER_LOG(
                        pPlayer, "item,additem,%u-%u,%d,%d,%s,%d",
                        pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, 
                        "missionaward", pPlayer->m_dwMapID
                        );
                }
                else if (eType == KAWARD_CARD_TYPE_GOLD)
                {
                    PLAYER_LOG(
                        pPlayer, "item,additem,%u-%u,%d,%d,%s,%d",
                        pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint,
                        "goldaward", pPlayer->m_dwMapID
                        );
                }
                else if (eType == KAWARD_CARD_TYPE_VIP)
                {
                    PLAYER_LOG(
                        pPlayer, "item,additem,%u-%u,%d,%d,%s,%d",
                        pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint,
                        "vipaward", pPlayer->m_dwMapID
                    );
                }
            }
        }
        else if (pAwardItem->dwTabType == ittFashion)
        {
            bRetCode = pPlayer->m_Wardrobe.AddFashion(pAwardItem->dwIndex);
            KGLOG_CHECK_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittCheerleading)
        {
            KGCheerleadingInfo* pCheerleadingInfo = g_pSO3World->m_ItemHouse.GetCheerleadingInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pCheerleadingInfo);

            bRetCode = pPlayer->m_CheerleadingMgr.AddCheerleading(pCheerleadingInfo->dwID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittTeamLogo)
        {
            KTEAM_LOGO_INFO*    pTeamLogoInfo = NULL;

            pTeamLogoInfo = g_pSO3World->m_ItemHouse.GetTeamLogoInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pTeamLogoInfo);

            bRetCode = pPlayer->AddTeamLogo((WORD)pTeamLogoInfo->nID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->nMoney > 0)
        {
            bRetCode = pPlayer->m_MoneyMgr.AddMoney(pAwardItem->eMoneyType, pAwardItem->nMoney);
            KGLOG_PROCESS_ERROR(bRetCode);
            PLAYER_LOG(pPlayer, "money,addmoney,%d,%s,%d-%d,%d,%d", pAwardItem->eMoneyType, "awardtable", 0, 0, 0, pAwardItem->nMoney);


            BroadCastAwardMoney(pPlayer, pAwardItem);
        }

        memset(&AwardItem, 0, sizeof(AwardItem));

        pAwardItemInfo = &AwardItem;

        memset(pAwardItemInfo->RandomAttr, 0, sizeof(pAwardItemInfo->RandomAttr));

        bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
        KGLOG_PROCESS_ERROR(bRetCode);

        pAwardItemInfo->itemType    = (unsigned char)pAwardItem->dwTabType;
        pAwardItemInfo->itemIndex   = pAwardItem->dwIndex;
        pAwardItemInfo->nCount      = (short)pAwardItem->nStackNum;
        pAwardItemInfo->byMoneyType = (BYTE)pAwardItem->eMoneyType;
        pAwardItemInfo->nMoney      = (short)pAwardItem->nMoney;
        pAwardItemInfo->nValuePoint = nValuePoint;

        if (pItem)
        {
            const KItemProperty*    pProperty   = pItem->GetProperty();
            KAttribute*			    pExtAttr    = pProperty->pExtAttr;  

            for (int j = 0; j < countof(pAwardItemInfo->RandomAttr); ++j)
            {
                if (pExtAttr == NULL)
                    break;

                pAwardItemInfo->RandomAttr[j].wKey = (unsigned short)pExtAttr->nKey;
                pAwardItemInfo->RandomAttr[j].wValue = (unsigned short)pExtAttr->nValue1;
                pExtAttr = pExtAttr->pNext;
            }
        }

        g_PlayerServer.DoAwardItemNotify(pPlayer, eType, AwardItem, uChooseIndex);
    }

    KG_PROCESS_SUCCESS(!bEndChoose);

    memset(arrAwardList, 0, sizeof(arrAwardList));
    for (unsigned i = 0; i < countof(arrAwardList); ++i)
    {
        pTempItem = NULL;
        pAwardItemInfo = &arrAwardList[i];

        memset(pAwardItemInfo->RandomAttr, 0, sizeof(pAwardItemInfo->RandomAttr));

        if (i != uChooseIndex)
        {
            const KItemProperty*    pProperty = NULL;
            KAttribute*			    pExtAttr  = NULL;

            pTempItem = pAwardTable->GetOneAwardItemByEqualRate();
            if (pTempItem == NULL)
                continue;

            bRetCode = GetAwardItemValuePoint(pTempItem, nValuePoint);
			KGLOG_PROCESS_ERROR(bRetCode);

            pAwardItemInfo->itemType    = (unsigned char)pTempItem->dwTabType;
            pAwardItemInfo->itemIndex   = pTempItem->dwIndex;
            pAwardItemInfo->nCount      = (short)pTempItem->nStackNum;
            pAwardItemInfo->byMoneyType = (BYTE)pTempItem->eMoneyType;
            pAwardItemInfo->nMoney      = (short)pTempItem->nMoney;
            pAwardItemInfo->nValuePoint = nValuePoint;

            if (pTempItem->dwTabType > 0 && pTempItem->dwIndex > 0)
            {
                pLookItem = g_pSO3World->m_ItemHouse.CreateItem(pTempItem->dwTabType, pTempItem->dwIndex, 0, 0, nValuePoint);
                KGLOG_CHECK_ERROR(pLookItem);
                if (pLookItem)
                {
                    pProperty   = pLookItem->GetProperty();
                    pExtAttr    = pProperty->pExtAttr;  

                    for (int j = 0; j < countof(pAwardItemInfo->RandomAttr); ++j)
                    {
                        if (pExtAttr == NULL)
                            break;

                        pAwardItemInfo->RandomAttr[j].wKey = (unsigned short)pExtAttr->nKey;
                        pAwardItemInfo->RandomAttr[j].wValue = (unsigned short)pExtAttr->nValue1;
                        pExtAttr = pExtAttr->pNext;
                    }

                    g_pSO3World->m_ItemHouse.DestroyItem(pLookItem);
                    pLookItem = NULL;
                }

            }
        }
    }

    g_PlayerServer.DoAwardItemListNotify(pPlayer, eType, arrAwardList, countof(arrAwardList));

Exit1:
    bResult = true;
Exit0:
    if (pLookItem)
    {
        g_pSO3World->m_ItemHouse.DestroyItem(pLookItem);
        pLookItem = NULL;
    }

    if (pItem)
    {
        g_pSO3World->m_ItemHouse.DestroyItem(pItem);
        pItem = NULL;
    }
    return bResult;
}