dimanche 10 janvier 2016

C++ Condition not read

Hello i have a problem with a C++ fonction

I've coded this :

#ifdef __TRAIL_SYSTEM

    if( IsPlayer() && m_pActMover->IsMove() && IsMode( TRANSPARENT_MODE ) == 0 && HasBuffByIk3( IK3_TRAIL ) && !m_pRide)
    {
            int nType = 0;
            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL1))  //Trail etoile Bleu
                nType = 2;

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL2))  //Trail etoile Rouge
                nType = 3;

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL3))  //Trail etoile Multicolore
                nType = 4;

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL4))  //Trail Nuageux
                nType = 5;  

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL5))  //Trail tetes de mort
                nType = 6;  

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL6))  //Trail etoile Vert
                nType = 7;

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL7))  //Trail arc en ciel
                nType = 8;  

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL8))  //Trail ligne verte
                nType = 9;

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL9))  //Trail ligne Orange
                nType = 10; 

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL10)) // Trail ligne Violette
                nType = 11; 

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL11)) //Trail VIP 
                nType = 12; 

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL12)) //Trail du Souverain
                nType = 13; 

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL13)) //Trail Bulles
                nType = 14; 

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL14)) //Trail Toque
                nType = 15; 

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL15)) //Trail Chat
                nType = 16; 

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL16)) //Trail Simpsons
                nType = 17;

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL17)) //Trail Fusees
                nType = 18; 

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL18)) //Trail SpaceCakes
                nType = 19; 

            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL19)) //Trail Cookie
                nType = 20;             


            if(HasBuff( BUFF_ITEM, II_SYS_SYS_TRAIL20)) //Trail Agneau
                nType = 21;     

        CreateFlyParticle( this, GetAngleX(), nType );
        Error( "Type : %d", nType );
    }

#endif

who means : If my player have a buff with the item ID "II_SYS_SYS_TRAIL1" then the nType = 2.

If the nType = 2 then i got this :

void CreateFlyParticle( CMover *pMover, float fAngX, int nType )
{
    FLOAT fAngXZ, fAngH, fDist, fSpeed;
    D3DXVECTOR3 vVel;
    D3DXVECTOR3 vPos = pMover->GetPos();
    vPos.y += 0.8f;

    fAngXZ = pMover->GetAngle();
    fAngXZ += 180.0f; 
    fAngXZ = D3DXToRadian( fAngXZ );

    vPos.x += (xRandom(100) / 100.0f) - 0.50f;
    vPos.y += (xRandom(100) / 100.0f) - 0.50f;
    vPos.z += (xRandom(100) / 100.0f) - 0.50f;

    for( int i = 0; i < 2; i ++ )
    {
        fAngXZ = (float)(-45.0f + xRandomF(90));
        fAngXZ += pMover->GetAngle();
        fAngXZ += 180.0f;

        fAngXZ = D3DXToRadian( fAngXZ );
        fAngH = (float)(fAngX + xRandomF(10));
        fAngH = D3DXToRadian( fAngH );
        fSpeed = xRandomF(0.02f);

        fDist = cosf(-fAngH) * fSpeed;
        vVel.x = sinf(fAngXZ) * fDist;
        vVel.z = -cosf(fAngXZ) * fDist;
        vVel.y = -sinf(-fAngH) * fSpeed;
    /*  if( nType == 1 ) // 근두운용.
            g_ParticleMng.CreateParticle( 10 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.5f );*/
    #ifdef __TRAIL_SYSTEM
        if(nType == 2)
            g_ParticleMng.CreateParticle( 30 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 5.0f );   
        if(nType == 3)
            g_ParticleMng.CreateParticle( 31 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 5.0f );   
        if(nType == 4)
            g_ParticleMng.CreateParticle( 32 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 5.0f );   
        if(nType == 5)
            g_ParticleMng.CreateParticle( 33 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 6)
            g_ParticleMng.CreateParticle( 34 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 7)
            g_ParticleMng.CreateParticle( 35 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 8)
            g_ParticleMng.CreateParticle( 36 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 9)
            g_ParticleMng.CreateParticle( 37 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 10)
            g_ParticleMng.CreateParticle( 38 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 11)
            g_ParticleMng.CreateParticle( 39 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 12)
            g_ParticleMng.CreateParticle( 40 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 13)
            g_ParticleMng.CreateParticle( 41 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 14)
            g_ParticleMng.CreateParticle( 42 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 15)
            g_ParticleMng.CreateParticle( 43 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 16)
            g_ParticleMng.CreateParticle( 44 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 17)
        {
            g_ParticleMng.CreateParticle( 45 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
            g_ParticleMng.CreateParticle( 50 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
            g_ParticleMng.CreateParticle( 51 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
            g_ParticleMng.CreateParticle( 52 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
            g_ParticleMng.CreateParticle( 53 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        }
        if(nType == 18)
            g_ParticleMng.CreateParticle( 46 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 19)
            g_ParticleMng.CreateParticle( 47 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 20)
            g_ParticleMng.CreateParticle( 48 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );   
        if(nType == 21)
            g_ParticleMng.CreateParticle( 49 + xRandom(3), vPos, vVel, CMover::GetActiveMover()->GetPos().y + 0.8f );

#endif      

Then it create the particle 30 who is this one :

    #ifdef __TRAIL_SYSTEM
        case 30:    pParticles->m_fSize = 0.5f; strcpy( szFileName, "etc_Particle11.bmp" ); break;
        case 31:    pParticles->m_fSize = 0.5f; strcpy( szFileName, "etc_Particle12.bmp" ); break;
        case 32:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "multicolortrail.bmp" );    break;
        case 33:    pParticles->m_fSize = 0.5f;     strcpy( szFileName, "etc_ParticleCloud01.bmp" );    break;
        case 34:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "skulltrail.bmp" ); break;
        case 35:    pParticles->m_fSize = 0.5f; strcpy( szFileName, "etc_Particle14.bmp" ); break;
        case 36:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "rainbowtrail.bmp" );   break;
        case 37:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "greenlinetrail.bmp" ); break;
        case 38:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "orangelinetrail.bmp" );    break;
        case 39:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "purplelinetrail.bmp" );    break;
        case 40:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "VIPISLIFETRAIL.bmp" ); break;
        case 41:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "lordtrail.bmp" );  break;
        case 42:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "bubblestrail.bmp" );   break;
        case 43:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "pikachutrail.bmp" );   break;
        case 44:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "cattrail.bmp" );   break;
        case 45:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "homerheadtrail.bmp" ); break;
        case 46:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "spacerockettrail.bmp" );   break;
        case 47:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "onepiecetrail.bmp" );  break;
        case 48:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "cookietrails.bmp" );   break;
        case 49:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "lambtrail.bmp" );  break;
        case 50:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "margeheadtrail.bmp" ); break;
        case 51:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "lisaheadtrail.bmp" );  break;
        case 52:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "bartheadtrail.bmp" );  break;
        case 53:    pParticles->m_fSize = 0.15f;    strcpy( szFileName, "maggieheadtrail.bmp" );    break;
#endif

But ! The problem is :

If i use TRAIL1 my nType is 2 but it also use the nType 3 and it play the 2 particles in the same time.. Maybe you someone know what is the problem for it ?

I made the good "if" condition so it shoulnd act like i use TRAIL1 and TRAIL2 in the same time ! Also if i use trail 2 it only show the TRAIL2 particles which is what i really want. So why did the first one don't work correctly ? :/..

Thanks alot for all your answer..

Aucun commentaire:

Enregistrer un commentaire