예제 #1
0
파일: CCameraSA.cpp 프로젝트: Alambos/eXe
CEntity * CCameraSA::GetTargetEntity ( void )
{
    CEntitySAInterface * pInterface = this->GetInterface()->pTargetEntity;
    CPoolsSA * pPools = ((CPoolsSA *)pGame->GetPools());
	CEntity * pReturn = NULL;

	if ( pPools && pInterface )
	{
		switch ( pInterface->nType )
		{
            case ENTITY_TYPE_PED:
                pReturn = (CEntity*)(pPools->GetPed((DWORD *)pInterface));
                break;
			case ENTITY_TYPE_VEHICLE:
				pReturn = (CEntity*)(pPools->GetVehicle((DWORD *)pInterface));
				break;
            case ENTITY_TYPE_OBJECT:
                pReturn = (CEntity*)(pPools->GetObject ((DWORD *)pInterface));
                break;
			default:
				break;
		}
	}
	return pReturn;
}
예제 #2
0
/**
 * This adds the local player to the ped pool, nothing else
 * @return BOOL TRUE if success, FALSE otherwise
 */
BOOL CGameSA::InitLocalPlayer(  )
{
    DEBUG_TRACE("BOOL CGameSA::InitLocalPlayer(  )");

    // Added by ChrML - Looks like it isn't safe to call this more than once but mod code might do
    static bool bAlreadyInited = false;
    if ( bAlreadyInited )
    {
        return TRUE;
    }
    bAlreadyInited = true;

    CPoolsSA * pools = (CPoolsSA *)this->GetPools ();
    if ( pools )
    {
        //* HACKED IN HERE FOR NOW *//
        CPedSAInterface* pInterface = pools->GetPedInterface ( (DWORD)1 );

        if ( pInterface )
        {
            pools->AddPed ( (DWORD*)pInterface );
            return TRUE;
        }

        return FALSE;
    }
    return FALSE;
}
예제 #3
0
/**
 * Constructor for CCivilianPedSA
 */
CCivilianPedSA::CCivilianPedSA( ePedModel pedType )
{
    DEBUG_TRACE("CCivilianPedSA::CCivilianPedSA( ePedModel pedType )");
    // based on CCivilianPed::SetupPlayerPed (R*)
    DWORD CPedOperatorNew = FUNC_CPedOperatorNew;
    DWORD CCivilianPedConstructor = FUNC_CCivilianPedConstructor;

    DWORD dwPedPointer = 0;
    _asm
    {
        push    SIZEOF_CCIVILIANPED
        call    CPedOperatorNew
        add     esp, 4

        mov     dwPedPointer, eax

        mov     ecx, eax
        push    0 // set to 0 and they'll behave like AI peds
        push    1 // ped type
        call    CCivilianPedConstructor
    }
    this->SetInterface((CEntitySAInterface *)dwPedPointer);
    this->Init(); // init our interfaces 
    CPoolsSA * pools = (CPoolsSA *)pGame->GetPools();
    this->internalID =  pools->GetPedRef ( (DWORD *)this->GetInterface () );
    CWorldSA * world = (CWorldSA *)pGame->GetWorld();
    world->Add(this->GetInterface(), CCivPed_Constructor);
    this->SetModelIndex(pedType);
    this->BeingDeleted = FALSE;
    this->DoNotRemoveFromGame = FALSE;
    this->SetType ( CIVILIAN_PED );

    this->m_pInterface->bStreamingDontDelete = true;
    this->m_pInterface->bDontStream = true;
}
예제 #4
0
CPlayerPedSA::CPlayerPedSA ( CPlayerPedSAInterface * pPlayer )
{
    DEBUG_TRACE("CPlayerPedSA::CPlayerPedSA( CPedSAInterface * ped )");
    // based on CPlayerPed::SetupPlayerPed (R*)
    this->SetInterface((CEntitySAInterface *)pPlayer);

    this->Init();
    CPoolsSA * pools = (CPoolsSA *)pGame->GetPools();
    this->internalID =  pools->GetPedRef ( (DWORD *)this->GetInterface () );
    this->SetType ( PLAYER_PED );
    this->BeingDeleted = FALSE;

    m_bIsLocal = true;
    DoNotRemoveFromGame = true;
    m_pData = GetPlayerPedInterface ()->pPlayerData;
    m_pWanted = NULL;

    GetPlayerPedInterface ()->pedFlags.bCanBeShotInVehicle = true;
    GetPlayerPedInterface ()->pedFlags.bTestForShotInVehicle = true;    
    GetPlayerPedInterface ()->pedFlags.bIsLanding = false;
    GetPlayerPedInterface ()->fRotationSpeed = 7.5;


    pLocalClothes = m_pData->m_pClothes;
    pLocalWanted = m_pData->m_Wanted;

    GetPlayerPedInterface ()->pedFlags.bCanBeShotInVehicle = true;
    // Something resets this, constantly
    GetPlayerPedInterface ()->pedFlags.bTestForShotInVehicle = true;
    // Stop remote players targeting the local (need to stop them targeting eachother too)
    GetPlayerPedInterface ()->pedFlags.bNeverEverTargetThisPed = true;
}
예제 #5
0
파일: CEventSA.cpp 프로젝트: Alambos/eXe
CEntity	* CEventSA::GetEntity (  )
{
	DEBUG_TRACE("CEntity * CEventSA::GetEntity (  )");
	if(this->GetEntityType() == EVENT_NULL)
		return NULL;

	CPoolsSA * pPools = (CPoolsSA *)pGame->GetPools();
	CEntity * entity;		

	switch(m_pInterface->m_eEventEntity)
	{
	case ENTITY_EVENT_PED:
		entity = (CEntity *)pPools->GetPedFromRef((DWORD)m_pInterface->m_nEventEntityRef);
		break;
	case ENTITY_EVENT_VEHICLE:
		entity = (CEntity *)pPools->GetVehicleFromRef((DWORD)m_pInterface->m_nEventEntityRef);
		break;
	case ENTITY_EVENT_OBJECT:
		entity = (CEntity *)pPools->GetObjectFromRef((DWORD)m_pInterface->m_nEventEntityRef);
		break;
	default:
		return NULL;
	}
	return entity;
}
예제 #6
0
VOID CMarkerSA::SetEntity(CObject* object)
{
    DEBUG_TRACE("VOID CMarkerSA::SetEntity ( CObject * object )");
    CPoolsSA* pPools = (CPoolsSA*)pGame->GetPools();
    DWORD     dwID = pPools->GetObjectRef((CObject*)object);
    internalInterface->PoolIndex = dwID;
    internalInterface->BlipType = (eMarkerType)MARKER_TYPE_OBJECT;
}
예제 #7
0
VOID CMarkerSA::SetEntity(CPed* ped)
{
    DEBUG_TRACE("VOID CMarkerSA::SetEntity ( CPed * ped )");
    CPoolsSA* pPools = (CPoolsSA*)pGame->GetPools();
    DWORD     dwID = pPools->GetPedRef((CPed*)ped);
    internalInterface->PoolIndex = dwID;
    internalInterface->BlipType = (BYTE)MARKER_TYPE_CHAR;
}
예제 #8
0
VOID CMarkerSA::SetEntity(CVehicle* vehicle)
{
    DEBUG_TRACE("VOID CMarkerSA::SetEntity ( CVehicle * vehicle )");
    CPoolsSA* pPools = (CPoolsSA*)pGame->GetPools();
    DWORD     dwID = pPools->GetVehicleRef((CVehicle*)vehicle);
    internalInterface->PoolIndex = dwID;
    internalInterface->BlipType = (BYTE)MARKER_TYPE_CAR;
}
예제 #9
0
void SwitchContext ( CVehicleSAInterface* pVehicleInterface )
{   
    // Grab the CVehicle for the given vehicle interface
    CPoolsSA* pool = (CPoolsSA*) pGameInterface->GetPools ();
    CVehicle* pVehicle = pool->GetVehicle ( (DWORD *)pVehicleInterface );
    if ( pVehicle )
    {
        SwitchContext ( pVehicle );
    }
}
예제 #10
0
CEntity* CMarkerSA::GetEntity()
{
    DEBUG_TRACE("CEntity * CMarkerSA::GetEntity (  )");
    CPoolsSA* pPools = (CPoolsSA*)pGame->GetPools();

    switch (internalInterface->BlipType)
    {
        case MARKER_TYPE_CAR:
            return (CEntity*)pPools->GetVehicleFromRef((DWORD)internalInterface->PoolIndex);
        case MARKER_TYPE_CHAR:
            return (CEntity*)pPools->GetPedFromRef((DWORD)internalInterface->PoolIndex);
        case MARKER_TYPE_OBJECT:
            return (CEntity*)pPools->GetObjectFromRef((DWORD)internalInterface->PoolIndex);
        default:
            return NULL;
    }
}
예제 #11
0
CEntity * CEventDamageSA::GetInflictingEntity ( void )
{
    CEntity * pReturn = NULL;
    CEntitySAInterface * pInterface = m_pInterface->pInflictor;
    if ( pInterface )
    {
        CPoolsSA * pPools = ((CPoolsSA *)pGame->GetPools());
        switch( pInterface->nType )
        {
        case ENTITY_TYPE_PED:
            pReturn = pPools->GetPed((DWORD *)pInterface);
            break;
        case ENTITY_TYPE_VEHICLE:
            pReturn = pPools->GetVehicle ( (DWORD *)pInterface );
            break;
        }
    }
    return pReturn;
}
예제 #12
0
bool CWorldSA::ProcessLineOfSight(const CVector * vecStart, const CVector * vecEnd, CColPoint ** colCollision, 
                                  CEntity ** CollisionEntity,
                                  const SLineOfSightFlags flags,
                                  SLineOfSightBuildingResult* pBuildingResult )
{
    DEBUG_TRACE("VOID CWorldSA::ProcessLineOfSight(CVector * vecStart, CVector * vecEnd, CColPoint * colCollision, CEntity * CollisionEntity)");
    DWORD dwPadding[100]; // stops the function missbehaving and overwriting the return address
    dwPadding [0] = 0;  // prevent the warning and eventual compiler optimizations from removing it

    CColPointSA * pColPointSA = new CColPointSA();
    CColPointSAInterface * pColPointSAInterface = pColPointSA->GetInterface();  

    //DWORD targetEntity;
    CEntitySAInterface * targetEntity = NULL;
    bool bReturn = false;

    DWORD dwFunc = FUNC_ProcessLineOfSight;
    // bool bCheckBuildings = true,                 bool bCheckVehicles = true,     bool bCheckPeds = true, 
    // bool bCheckObjects = true,                   bool bCheckDummies = true,      bool bSeeThroughStuff = false, 
    // bool bIgnoreSomeObjectsForCamera = false,    bool bShootThroughStuff = false
    MemPutFast < BYTE > ( VAR_CWorld_bIncludeCarTires, flags.bCheckCarTires );

    _asm
    {
        push    flags.bShootThroughStuff
        push    flags.bIgnoreSomeObjectsForCamera
        push    flags.bSeeThroughStuff
        push    flags.bCheckDummies
        push    flags.bCheckObjects
        push    flags.bCheckPeds
        push    flags.bCheckVehicles
        push    flags.bCheckBuildings
        lea     eax, targetEntity
        push    eax
        push    pColPointSAInterface    
        push    vecEnd
        push    vecStart    
        call    dwFunc
        mov     bReturn, al
        add     esp, 0x30
    }

    MemPutFast < BYTE > ( VAR_CWorld_bIncludeCarTires, 0 );

    // Building info needed?
    if ( pBuildingResult )
    {
        CPoolsSA * pPools = ((CPoolsSA *)pGame->GetPools());
        if ( pPools )
        {
            if ( targetEntity && targetEntity->nType == ENTITY_TYPE_BUILDING )
            {
                pBuildingResult->bValid = true;
                pBuildingResult->usModelID = targetEntity->m_nModelIndex;
                if ( targetEntity->m_pLod )
                    pBuildingResult->usLODModelID = targetEntity->m_pLod->m_nModelIndex;
                else
                    pBuildingResult->usLODModelID = 0;

                pBuildingResult->pInterface = targetEntity;
                pBuildingResult->vecPosition = targetEntity->Placeable.m_transform.m_translate;
                if ( targetEntity->Placeable.matrix )
                {
                    CVector& vecRotation = pBuildingResult->vecRotation;
                    ConvertMatrixToEulerAngles ( *targetEntity->Placeable.matrix, vecRotation.fX, vecRotation.fY, vecRotation.fZ );
                    vecRotation = -vecRotation;
                }
            }
            if ( targetEntity && targetEntity->nType == ENTITY_TYPE_OBJECT )
            {
                pBuildingResult->bValid = true;
                pBuildingResult->usModelID = targetEntity->m_nModelIndex;
                if ( targetEntity->m_pLod )
                    pBuildingResult->usLODModelID = targetEntity->m_pLod->m_nModelIndex;
                else
                    pBuildingResult->usLODModelID = 0;

                pBuildingResult->pInterface = targetEntity;
            }
        }
    }


    if ( CollisionEntity )
    {
        CPoolsSA * pPools = ((CPoolsSA *)pGame->GetPools());
        if(pPools)
        {
            if(targetEntity)
            {
                switch (targetEntity->nType)
                {
                    case ENTITY_TYPE_PED:
                        *CollisionEntity = pPools->GetPed((DWORD *)targetEntity);
                        break;
                    case ENTITY_TYPE_OBJECT:
                        *CollisionEntity = pPools->GetObject((DWORD *)targetEntity);
                        break;
                    case ENTITY_TYPE_VEHICLE:
                        *CollisionEntity = pPools->GetVehicle((DWORD *)targetEntity);
                        break;
                }

                /*CEntitySA * entity = new CEntitySA();
                entity->SetInterface((CEntitySAInterface *)targetEntity);
                eEntityType EntityType = entity->GetEntityType();
                delete entity;
                switch(EntityType)
                {
                case ENTITY_TYPE_PED:
                case ENTITY_TYPE_OBJECT:
                    *CollisionEntity = pPools->GetPed((DWORD *)targetEntity);
                    if ( *CollisionEntity )
                        break;
                    *CollisionEntity = pPools->GetObject((CObjectSAInterface *)targetEntity);
                    break;
                case ENTITY_TYPE_VEHICLE:
                    *CollisionEntity = pPools->GetVehicle((CVehicleSAInterface *)targetEntity);
                    break;

                }*/
            }
        }
    }
    if ( colCollision ) *colCollision = pColPointSA;
    else pColPointSA->Destroy ();

    return bReturn;
}
예제 #13
0
CPlayerPedSA::CPlayerPedSA( ePedModel pedType )
{
    DEBUG_TRACE("CPlayerPedSA::CPlayerPedSA( ePedModel pedType )");
    // based on CPlayerPed::SetupPlayerPed (R*)
    DWORD CPedOperatorNew = FUNC_CPedOperatorNew;
    DWORD CPlayerPedConstructor = FUNC_CPlayerPedConstructor;

    DWORD dwPedPointer = 0;
    _asm
    {
        push    SIZEOF_CPLAYERPED
        call    CPedOperatorNew
        add     esp, 4

        mov     dwPedPointer, eax

        mov     ecx, eax
        push    0 // set to 0 and they'll behave like AI peds
        push    1
        call    CPlayerPedConstructor
    }

    this->SetInterface((CEntitySAInterface *)dwPedPointer);

    this->Init(); // init our interfaces 
    CPoolsSA * pools = (CPoolsSA *)pGame->GetPools ( );
    this->internalID =  pools->GetPedRef ( (DWORD *)this->GetInterface () );
    CWorldSA * world = (CWorldSA *)pGame->GetWorld();
    
    this->SetModelIndex(pedType);
    this->BeingDeleted = FALSE;
    this->DoNotRemoveFromGame = FALSE;
    this->SetType ( PLAYER_PED );

    // Allocate a player data struct and set it as the players
    m_bIsLocal = false;
    m_pData = new CPlayerPedDataSAInterface;

    // Copy the local player data so we're defaulted to something good
    CPlayerPedSA* pLocalPlayerSA = dynamic_cast < CPlayerPedSA* > ( pools->GetPedFromRef ( (DWORD)1 ) );
    if ( pLocalPlayerSA )
        MemCpyFast ( m_pData, ((CPlayerPedSAInterface*)pLocalPlayerSA->GetInterface ())->pPlayerData, sizeof ( CPlayerPedDataSAInterface ) );

    // Replace the player ped data in our ped interface with the one we just created
    GetPlayerPedInterface ()->pPlayerData = m_pData;

    // Set default stuff
    m_pData->m_bRenderWeapon = true;
    m_pData->m_Wanted = pLocalWanted;
    m_pData->m_fSprintEnergy = 1000.0f;

    // Clothes pointers or we'll crash later (TODO: Wrap up with some cloth classes and make it unique per player)
    m_pData->m_pClothes = pLocalClothes;

    // Not sure why was this here (svn blame reports that this line came from the old SVN),
    // but it's causing a bug in what the just streamed-in players that are in the air are
    // processed as if they would be standing on some surface, screwing velocity calculations
    // for players floating in air (using superman script, for example) because GTA:SA will
    // try to apply the floor friction to their velocity.
    //SetIsStanding ( true );

    GetPlayerPedInterface ()->pedFlags.bCanBeShotInVehicle = true;
    GetPlayerPedInterface ()->pedFlags.bTestForShotInVehicle = true;
    // Stop remote players targeting eachother, this also stops the local player targeting them (needs to be fixed)
    GetPlayerPedInterface ()->pedFlags.bNeverEverTargetThisPed = true;
    GetPlayerPedInterface ()->pedFlags.bIsLanding = false;
    GetPlayerPedInterface ()->fRotationSpeed = 7.5;
    m_pInterface->bStreamingDontDelete = true;
    m_pInterface->bDontStream = true;
    world->Add ( m_pInterface, CPlayerPed_Constructor );
}