/** * 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; }
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; }
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; }
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 ); }