Exemplo n.º 1
0
void CWorldRPCs::SetWeaponProperty(NetBitStreamInterface& bitStream)
{
    unsigned char ucWeapon = 0;
    unsigned char ucProperty = 0;
    unsigned char ucWeaponSkill = 0;
    float         fData = 0.0f;
    short         sData = 0;
    if (bitStream.Read(ucWeapon) && bitStream.Read(ucProperty) && bitStream.Read(ucWeaponSkill))
    {
        CWeaponStat* pWeaponInfo =
            g_pGame->GetWeaponStatManager()->GetWeaponStats(static_cast<eWeaponType>(ucWeapon), static_cast<eWeaponSkill>(ucWeaponSkill));
        switch (ucProperty)
        {
            case WEAPON_WEAPON_RANGE:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponRange(fData);
                break;
            }
            case WEAPON_TARGET_RANGE:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetTargetRange(fData);
                break;
            }
            case WEAPON_ACCURACY:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetAccuracy(fData);
                break;
            }
            case WEAPON_LIFE_SPAN:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetLifeSpan(fData);
                break;
            }
            case WEAPON_FIRING_SPEED:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetFiringSpeed(fData);
                break;
            }
            case WEAPON_MOVE_SPEED:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetMoveSpeed(fData);
                break;
            }
            case WEAPON_ANIM_LOOP_START:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnimLoopStart(fData);
                break;
            }
            case WEAPON_ANIM_LOOP_STOP:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnimLoopStop(fData);
                break;
            }
            case WEAPON_ANIM_LOOP_RELEASE_BULLET_TIME:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnimLoopFireTime(fData);
                break;
            }

            case WEAPON_ANIM2_LOOP_START:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnim2LoopStart(fData);
                break;
            }
            case WEAPON_ANIM2_LOOP_STOP:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnim2LoopStop(fData);
                break;
            }
            case WEAPON_ANIM2_LOOP_RELEASE_BULLET_TIME:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnim2LoopFireTime(fData);
                break;
            }

            case WEAPON_ANIM_BREAKOUT_TIME:
            {
                bitStream.Read(fData);
                pWeaponInfo->SetWeaponAnimBreakoutTime(fData);
                break;
            }
            case WEAPON_DAMAGE:
            {
                bitStream.Read(sData);
                pWeaponInfo->SetDamagePerHit(sData);
                break;
            }
            case WEAPON_MAX_CLIP_AMMO:
            {
                bitStream.Read(sData);
                pWeaponInfo->SetMaximumClipAmmo(sData);
                break;
            }
            case WEAPON_FLAGS:
            {
                int iData = 0;
                if (bitStream.Version() < 0x57)
                {
                    bitStream.Read(sData);
                    iData = sData;
                }
                else
                    bitStream.Read(iData);

                pWeaponInfo->ToggleFlagBits(iData);
                break;
            }
            case WEAPON_ANIM_GROUP:
            {
                bitStream.Read(sData);
                pWeaponInfo->SetAnimGroup(sData);
                break;
            }
            case WEAPON_FLAG_AIM_NO_AUTO:
            case WEAPON_FLAG_AIM_ARM:
            case WEAPON_FLAG_AIM_1ST_PERSON:
            case WEAPON_FLAG_AIM_FREE:
            case WEAPON_FLAG_MOVE_AND_AIM:
            case WEAPON_FLAG_MOVE_AND_SHOOT:
            case WEAPON_FLAG_TYPE_THROW:
            case WEAPON_FLAG_TYPE_HEAVY:
            case WEAPON_FLAG_TYPE_CONSTANT:
            case WEAPON_FLAG_TYPE_DUAL:
            case WEAPON_FLAG_ANIM_RELOAD:
            case WEAPON_FLAG_ANIM_CROUCH:
            case WEAPON_FLAG_ANIM_RELOAD_LOOP:
            case WEAPON_FLAG_ANIM_RELOAD_LONG:
            case WEAPON_FLAG_SHOT_SLOWS:
            case WEAPON_FLAG_SHOT_RAND_SPEED:
            case WEAPON_FLAG_SHOT_ANIM_ABRUPT:
            case WEAPON_FLAG_SHOT_EXPANDS:
            {
                bool bEnable;
                bitStream.ReadBit(bEnable);
                uint uiFlagBit = GetWeaponPropertyFlagBit((eWeaponProperty)ucProperty);
                if (bEnable)
                    pWeaponInfo->SetFlagBits(uiFlagBit);
                else
                    pWeaponInfo->ClearFlagBits(uiFlagBit);
                break;
            }
        }
    }
}
Exemplo n.º 2
0
void CWorldRPCs::SetWeaponProperty ( NetBitStreamInterface& bitStream )
{
    unsigned char ucWeapon = 0;
    unsigned char ucProperty = 0;
    unsigned char ucWeaponSkill = 0;
    float fData = 0.0f;
    short sData = 0;
    if ( bitStream.Read ( ucWeapon ) && bitStream.Read ( ucProperty ) && bitStream.Read ( ucWeaponSkill ) )
    {
        CWeaponStat* pWeaponInfo = g_pGame->GetWeaponStatManager()->GetWeaponStats( static_cast < eWeaponType > ( ucWeapon ), static_cast < eWeaponSkill > ( ucWeaponSkill ) );
        CWeaponStat* pOriginalWeaponInfo = g_pGame->GetWeaponStatManager()->GetOriginalWeaponStats( static_cast < eWeaponType > ( ucWeapon ), static_cast < eWeaponSkill > ( ucWeaponSkill ) );
        switch ( ucProperty )
        {
        case WEAPON_WEAPON_RANGE:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetWeaponRange ( fData );
            break;
        }
        case WEAPON_TARGET_RANGE:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetTargetRange ( fData );
            break;
        }
        case WEAPON_ACCURACY:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetAccuracy ( fData );
            break;
        }
        case WEAPON_LIFE_SPAN:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetLifeSpan ( fData );
            break;
        }
        case WEAPON_FIRING_SPEED:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetFiringSpeed ( fData );
            break;
        }
        case WEAPON_MOVE_SPEED:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetMoveSpeed ( fData );
            break;
        }
        case WEAPON_ANIM_LOOP_START:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetWeaponAnimLoopStart ( fData );
            break;
        }
        case WEAPON_ANIM_LOOP_STOP:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetWeaponAnimLoopStop ( fData );
            break;
        }
        case WEAPON_ANIM_LOOP_RELEASE_BULLET_TIME:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetWeaponAnimLoopFireTime ( fData );
            break;
        }

        case WEAPON_ANIM2_LOOP_START:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetWeaponAnim2LoopStart ( fData );
            break;
        }
        case WEAPON_ANIM2_LOOP_STOP:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetWeaponAnim2LoopStop ( fData );
            break;
        }
        case WEAPON_ANIM2_LOOP_RELEASE_BULLET_TIME:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetWeaponAnim2LoopFireTime ( fData );
            break;
        }

        case WEAPON_ANIM_BREAKOUT_TIME:
        {
            bitStream.Read ( fData );
            pWeaponInfo->SetWeaponAnimBreakoutTime ( fData );
            break;
        }
        case WEAPON_DAMAGE:
        {
            bitStream.Read ( sData );
            pWeaponInfo->SetDamagePerHit ( sData );
            break;
        }
        case WEAPON_MAX_CLIP_AMMO:
        {
            bitStream.Read ( sData );
            pWeaponInfo->SetMaximumClipAmmo ( sData );
            break;
        }
        case WEAPON_FLAGS:
        {
            bitStream.Read ( sData );
            if ( pWeaponInfo->IsFlagSet ( sData ) )
            {
                if ( sData == 0x800 )
                {
                    // if it can support this anim group
                    if ( ( ucWeapon >= WEAPONTYPE_PISTOL && ucWeapon <= WEAPONTYPE_SNIPERRIFLE ) || ucWeapon == WEAPONTYPE_MINIGUN )
                    {
                        // Revert anim group to default
                        pWeaponInfo->SetAnimGroup ( pOriginalWeaponInfo->GetAnimGroup ( ) );
                    }
                }
                pWeaponInfo->ClearFlag ( sData );
            }
            else
            {
                if ( sData == 0x800 )
                {
                    // if it can support this anim group
                    if ( ( ucWeapon >= WEAPONTYPE_PISTOL && ucWeapon <= WEAPONTYPE_SNIPERRIFLE ) || ucWeapon == WEAPONTYPE_MINIGUN )
                    {
                        // sawn off shotgun anim group
                        pWeaponInfo->SetAnimGroup ( 17 );
                    }
                }
                pWeaponInfo->SetFlag ( sData );
            }

            break;
        }
        case WEAPON_ANIM_GROUP:
        {
            bitStream.Read ( sData );
            pWeaponInfo->SetAnimGroup ( sData );
            break;
        }
        }
    }
}