コード例 #1
0
ファイル: prophet.cpp プロジェクト: jordandavidson/lithtech
void Prophet::MC_Fire_Stand()
{
    CWeapon* pW = m_InventoryMgr.GetCurrentWeapon();

    if(pW == DNULL)
    {
        SetNewState(STATE_Idle);
        return;
    }

    if(pW->GetType() == WEAP_MELEE)
    {
        if (m_bAnimating == DFALSE || m_nCurMetacmd != MC_FIRE_STAND)
        {
            DBOOL bRet = SetAnimation(m_pAnim_Sound->m_nAnim_FIRE_STAND[m_pServerDE->IntRandom(4,6)]);

            //SCHLEGZ 4/22/98 3:27:12 PM: if we can't stand up, crawl out from underneath
            if(!bRet)
            {
                SetNewState(STATE_CrawlUnderObj);
                return;
            }

            m_pServerDE->SetModelLooping(m_hObject, DFALSE);

            m_bAnimating = DTRUE;
            m_nCurMetacmd = MC_FIRE_STAND;
            m_pServerDE->SetNextUpdate(m_hObject, 0.1f);
        }
        else
        {
            if(m_pServerDE->GetModelPlaybackState(m_hObject) & MS_PLAYDONE)
            {
                m_bAnimating = DFALSE;
                Metacmd++;
                return;
            }
        }
    }
    else
    {
        AI_Mgr::MC_Fire_Stand();
    }

    return;
}
コード例 #2
0
//////////////////////////////////////////////////////////////////////////////////////////
//
// CVehicle::BurstTyre
//      (Used for CAutomobile and CBike hooks)
//
// Called when an inflated vehicle tyre is hit by a bullet
//
//////////////////////////////////////////////////////////////////////////////////////////
bool OnMY_CVehicle_BurstTyre( CVehicleSAInterface* pVehicle, uchar ucTyre )
{
    if ( m_pVehicleDamageHandler )
    {
        eWeaponType weaponType = WEAPONTYPE_INVALID;

        // Discover weapon if possible
        CPed* pInitiator = pGameInterface->GetPools()->GetPed ( (DWORD *)pBulletImpactInitiator );
        if ( pInitiator )
        {
            CWeapon* pWeapon = pInitiator->GetWeapon ( pInitiator->GetCurrentWeaponSlot () );
            if ( pWeapon )
                weaponType = pWeapon->GetType ();
        }

        if ( !m_pVehicleDamageHandler( pVehicle, 0, pBulletImpactInitiator, weaponType, vecSavedBulletImpactEndPosition, ucTyre ) )
            return false;
    }

    return true;
}
コード例 #3
0
void SwitchContext ( CPed* thePed )
{
    if ( thePed == NULL ) return;

    pContextSwitchedPed = thePed;
    // Are we not already in another context?
    if ( !bNotInLocalContext )
    {
        // Grab the local ped and the local pad
        CPed* pLocalPlayerPed = pGameInterface->GetPools ()->GetPedFromRef ( (DWORD)1 ); // the player
        CPad* pLocalPad = pGameInterface->GetPad ();
        CPadSAInterface* pLocalPadInterface = ( (CPadSA*) pLocalPad )->GetInterface ();

        // We're not switching to local player
        if ( thePed != pLocalPlayerPed )
        {
            // Store the local pad
            pLocalPad->Store (); // store a copy of the local pad internally

            // Grab the remote data storage for the player we're context switching to
            CPlayerPed* thePlayerPed = dynamic_cast < CPlayerPed* > ( thePed );
            if ( thePlayerPed )
            {
                CRemoteDataStorageSA * data = CRemoteDataSA::GetRemoteDataStorage ( thePlayerPed );
                if ( data )
                {
                    // We want the player to be seen as in targeting mode if they are right clicking and with weapons 
                    eWeaponType currentWeapon = thePed->GetWeapon(thePed->GetCurrentWeaponSlot())->GetType();
                    CControllerState * cs = data->CurrentControllerState();
                    
                    if ( cs->RightShoulder1 != 0 
                        && ( currentWeapon == WEAPONTYPE_SNIPERRIFLE || currentWeapon == WEAPONTYPE_ROCKETLAUNCHER
                        || currentWeapon == WEAPONTYPE_ROCKETLAUNCHER_HS || currentWeapon == WEAPONTYPE_CAMERA ) )
                    {
                        b1stPersonWeaponModeHackInPlace = true;
                        
                        // make the CCamera::Using1stPersonWeaponMode function return true
                        *(BYTE *)0x50BFF0 = 0xB0; // MOV AL, 1
                        *(BYTE *)0x50BFF1 = 0x01;
                        *(BYTE *)0x50BFF2 = 0xC3; // RETN
                    }

                    // Change the local player's pad to the remote player's
                    memcpy ( pLocalPadInterface, &data->m_pad, sizeof ( CPadSAInterface ) );

                    // this is to fix the horn/siren
                    pLocalPad->SetHornHistoryValue ( ( cs->ShockButtonL == 255 ) );
                    // disables the impatient actions on remote players (which cause desync)
                    pLocalPad->SetLastTimeTouched ( pGameInterface->GetSystemTime () );

                    // this is to make movement work correctly
                    fLocalPlayerCameraRotation = *(float *)VAR_CameraRotation;
                    *(float *)VAR_CameraRotation = data->m_fCameraRotation;

                    // Change the gravity to the remote player's
                    pGameInterface->SetGravity ( data->m_fGravity );

                    // Disable mouselook for remote players (so the mouse doesn't affect them)
                    // Only disable mouselook if they're not holding a 1st-person weapon
                    // And if they're not under-water
                    bool bDisableMouseLook = true;
                    CWeapon* pWeapon = thePed->GetWeapon ( thePed->GetCurrentWeaponSlot () );
                    if ( pWeapon )
                    {
                        eWeaponType weaponType = pWeapon->GetType ();
                        switch ( weaponType )
                        {
                            case WEAPONTYPE_SNIPERRIFLE:
                            case WEAPONTYPE_ROCKETLAUNCHER:
                            case WEAPONTYPE_ROCKETLAUNCHER_HS:
                                bDisableMouseLook = false;
                        }
                    }
                    bMouseLookEnabled = *(bool *)0xB6EC2E;
                    if ( bDisableMouseLook ) *(bool *)0xB6EC2E = false;

                    // Disable the goggles
                    bInfraredVisionEnabled = *(bool *)0xC402B9;
                    *(bool *)0xC402B9 = false;
                    bNightVisionEnabled = *(bool *)0xC402B8;
                    *(bool *)0xC402B8 = false;

                    // Remove the code making players cough on fire extinguisher and teargas
                    memset ( (void*) 0x4C03F0, 0x90, 3 );
                    memset ( (void*) 0x4C03F8, 0x90, 7 );

                    // Prevent it calling ClearWeaponTarget for remote players
                    *(BYTE *)0x609C80 = 0xC3;

                    // Prevent rockets firing oddly
                    //*(BYTE *)0x73811C = 0x90;
                    //*(BYTE *)0x73811D = 0xE9;

                    
                    // This is so weapon clicks and similar don't play for us when done remotly
                    *(BYTE *)0x60F273 = 0xEB; 
                    *(BYTE *)0x60F260 = 0x90;
                    *(BYTE *)0x60F261 = 0x90;
                    

                    // Prevent CCamera::SetNewPlayerWeaponMode being called
                    *(BYTE *)0x50BFB0 = 0xC2; // RETN 0xC
                    *(BYTE *)0x50BFB1 = 0x0C; 
                    *(BYTE *)0x50BFB2 = 0x00;

                    // Prevent it calling CCamera::ClearPlayerWeaponMode for remote players
                    *(BYTE *)0x50AB10 = 0xC3;

                    // Prevent it marking targets of remote players
                    *(BYTE *)0x742BF0 = 0xC3;

                    // this is to prevent shooting players following the local camera
                    *(BYTE *)0x687099 = 0xEB;

                    // Prevent the game making remote player's weapons get switched by the local player's
                    *(BYTE *)0x60D850 = 0xC2;
                    *(BYTE *)0x60D851 = 0x04;
                    *(BYTE *)0x60D852 = 0x00;

                    // Change the local player's stats to the remote player's
                    if ( data )
                    {
                        memcpy ( (void *)0xb79380, data->m_stats.StatTypesFloat, sizeof(float) * MAX_FLOAT_STATS );
                        memcpy ( (void *)0xb79000, data->m_stats.StatTypesInt, sizeof(int) * MAX_INT_STATS );
                        memcpy ( (void *)0xb78f10, data->m_stats.StatReactionValue, sizeof(float) * MAX_REACTION_STATS );
                    }                 

                    /*
                    // ChrML: Force as high stats as we can go before screwing up. Players can't have different
                    //        stats or guns don't work. We can't have dual guns either due to some screwups.
                    //        Dual gun screwup: Sync code needs update and the gun pointing up needs to.
                    float* pfStats = (float*) 0xb79380;
                    pfStats [ 69 ] = 500.0f;
                    pfStats [ 70 ] = 999.0f;
                    pfStats [ 71 ] = 999.0f;
                    pfStats [ 72 ] = 999.0f;
                    pfStats [ 73 ] = 500.0f;
                    pfStats [ 74 ] = 999.0f;
                    pfStats [ 75 ] = 500.0f;
                    pfStats [ 76 ] = 999.0f;
                    pfStats [ 77 ] = 999.0f;
                    pfStats [ 78 ] = 999.0f;
                    pfStats [ 79 ] = 999.0f;
                    */

                    CPedSA* thePedSA = dynamic_cast < CPedSA* > ( thePed );
                    if ( thePedSA )
                    {
                        CEntitySAInterface * ped = thePedSA->GetInterface();
                        *(DWORD *)0xB7CD98 = (DWORD)ped;
                    }

                    // Remember that we're not in the local player's context any more (for switching back)
                    bNotInLocalContext = true;

                    // Call the pre-context switch handler we might have
                    if ( m_pPreContextSwitchHandler )
                    {
                        CPlayerPed* pPlayerPed = dynamic_cast < CPlayerPed* > ( thePed );
                        if ( pPlayerPed )
                            m_pPreContextSwitchHandler ( pPlayerPed );
                    }
                }
            }
        }
        else
        {
            // Set the local players gravity
            pGameInterface->SetGravity ( fLocalPlayerGravity );

            if ( bCustomCameraRotation )
                *(float *)VAR_CameraRotation = fLocalPlayerCameraRotation;    
        }
    }
}
コード例 #4
0
ファイル: OpheliaREV.cpp プロジェクト: Arc0re/lithtech
void OpheliaREV::AI_STATE_AttackFar()
{
	DFLOAT fHeight = (DFLOAT)fabs(m_vTargetPos.y - m_MoveObj.GetPos().y);

	//SCHLEGZ 4/22/98 4:51:21 PM: sanity check
	if(m_hTarget == DNULL)
	{
		if(fHeight <= m_vDims.y)
			SetNewState(STATE_SearchVisualTarget);
		else
			ComputeState();

		return;
	}

	m_fStimuli[SIGHT] = VEC_DIST(m_MoveObj.GetPos(),m_vTargetPos);
	DBOOL bAbove = (m_vTargetPos.y - m_MoveObj.GetPos().y) > 0;
	
	CWeapon* pW = m_InventoryMgr.GetCurrentWeapon();

	if(pW == DNULL)
	{
		SetNewState(STATE_Idle);
		return;
	}

	switch(Metacmd)
	{
		case 1:		MC_FaceTarget();	break;
		case 2:		MC_BestWeapon();	break;
		case 3:		if(m_fStimuli[SIGHT] <= (m_fSeeingDist * 0.75) || m_nCurMetacmd == MC_FIRE_STAND
						|| m_nCurMetacmd == MC_FIRE_CROUCH || fHeight > m_vDims.y)
					{
						if((fHeight > m_vDims.y && !bAbove) || m_nCurMetacmd == MC_FIRE_CROUCH
							|| m_fStimuli[HEALTH] < 0.5f || pW->GetType() == WEAP_SNIPERRIFLE)
						{
							MC_Fire_Crouch();
						}
						else
						{
							MC_Fire_Stand();
						}
					}
					else
						Metacmd++;

					break;
		case 4:		if(m_fStimuli[SIGHT] > (m_fSeeingDist * 0.75))
					{
						MC_FaceTarget();
						Metacmd--;

						if(!IsLedge(m_MoveObj.GetForwardVector()) && fHeight <= m_vDims.y
							&& m_nCurMetacmd != MC_FIRE_CROUCH && pW->GetType() != WEAP_SNIPERRIFLE)
						{
							if(m_nInjuredLeg)
								MC_Walk();
							else
								MC_Fire_Run();
						}
						else
						{
							MC_Fire_Crouch();
						}
					}
					else
						Metacmd++;

					break;
		case 5:		ComputeState();		break;
	}

	return;
}
コード例 #5
0
void CWeaponRPCs::GiveWeapon ( NetBitStreamInterface& bitStream )
{
    // Read out weapon id and ammo amount
    ElementID ID;
    SWeaponTypeSync weaponType;

    if ( bitStream.ReadCompressed ( ID ) &&
         bitStream.Read ( &weaponType ) )
    {
        SWeaponAmmoSync ammo ( weaponType.data.ucWeaponType, true, false );
        if ( bitStream.Read ( &ammo ) )
        {
            bool bGiveWeapon = bitStream.ReadBit ();
            unsigned char ucWeaponID = weaponType.data.ucWeaponType;
            unsigned short usAmmo = ammo.data.usTotalAmmo;

            CClientPed * pPed = m_pPedManager->Get ( ID, true );
            if ( pPed )
            {
                // Don't change remote players weapons (affects sync)
                if ( pPed->GetType () == CCLIENTPED || pPed->GetType () == CCLIENTPLAYER )
                {
                    // Valid weapon id?
                    if ( ucWeaponID == 0 || CClientPickupManager::IsValidWeaponID ( ucWeaponID ) )
                    {
                        // Adjust the ammo to 9999 if it's above
                        if ( usAmmo > 9999 ) usAmmo = 9999;

                        // Give the local player the weapon
                        CWeapon* pPlayerWeapon = NULL;
                        if ( ucWeaponID != 0 )
                        {
                            pPlayerWeapon = pPed->GiveWeapon ( static_cast < eWeaponType > ( ucWeaponID ), usAmmo );
                            if ( pPlayerWeapon && bGiveWeapon )
                                pPlayerWeapon->SetAsCurrentWeapon ();
                        }
                        else
                        {
                            // This could be entered into a hack of the year competition. Its about as hacky as it gets.
                            // For some stupid reason, going from brassknuckles to unarmed causes the knuckles to remain 
                            // on display but unusable. So, what we do is switch to a MELEE weapon (creating one if necessary)
                            // then switch back to unarmed from there, which works fine.
                            CWeapon* oldWeapon = pPed->GetWeapon (WEAPONSLOT_TYPE_UNARMED);
                            if ( oldWeapon )
                            {
                                eWeaponType unarmedWeapon = oldWeapon->GetType();
                                pPed->RemoveWeapon ( unarmedWeapon );
                                if ( bGiveWeapon || pPed->GetCurrentWeaponSlot() == WEAPONSLOT_TYPE_UNARMED )
                                {
                                    oldWeapon = NULL;
                                    if ( unarmedWeapon == WEAPONTYPE_BRASSKNUCKLE )
                                    {
                                        oldWeapon = pPed->GetWeapon(WEAPONSLOT_TYPE_MELEE);
                                        if ( oldWeapon && oldWeapon->GetType() == WEAPONTYPE_UNARMED )
                                        {
                                            oldWeapon = pPed->GiveWeapon(WEAPONTYPE_GOLFCLUB, 100);
                                        }
                                        else
                                        {
                                            oldWeapon = NULL;
                                        }
                                        pPed->SetCurrentWeaponSlot ( WEAPONSLOT_TYPE_MELEE );
                                    }

                                    // switch to the unarmed slot
                                    pPed->SetCurrentWeaponSlot ( WEAPONSLOT_TYPE_UNARMED );

                                    // if we created a special MELEE weapon just for this, remove it now
                                    if ( oldWeapon )
                                    {
                                        oldWeapon->Remove();
                                    }
                                }
                            }
                            else
                            {
                                // Probably the ped is streamed out
                                pPed->GiveWeapon ( WEAPONTYPE_UNARMED, 1 );
                                if ( bGiveWeapon )
                                    pPed->SetCurrentWeaponSlot ( WEAPONSLOT_TYPE_UNARMED );
                            }
                        }
                    }
                }
            }
        }
    }
}