2019-07-17 07:19:20 -04:00
|
|
|
#include "common.h"
|
2020-04-17 09:31:11 -04:00
|
|
|
|
2020-01-31 05:23:15 -05:00
|
|
|
#include "Automobile.h"
|
|
|
|
#include "CarCtrl.h"
|
|
|
|
#include "Camera.h"
|
2019-07-17 07:19:20 -04:00
|
|
|
#include "Remote.h"
|
2020-01-31 05:23:15 -05:00
|
|
|
#include "Timer.h"
|
|
|
|
#include "World.h"
|
|
|
|
#include "PlayerInfo.h"
|
|
|
|
#include "Vehicle.h"
|
2019-07-17 07:19:20 -04:00
|
|
|
|
2020-01-31 05:23:15 -05:00
|
|
|
void
|
|
|
|
CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uint16 model)
|
|
|
|
{
|
|
|
|
CAutomobile *car = new CAutomobile(model, MISSION_VEHICLE);
|
|
|
|
bool found;
|
|
|
|
|
|
|
|
z = car->GetDistanceFromCentreOfMassToBaseOfModel() + CWorld::FindGroundZFor3DCoord(x, y, z + 2.0f, &found);
|
|
|
|
|
|
|
|
car->GetMatrix().SetRotateZOnly(rot);
|
2020-04-30 06:48:01 -04:00
|
|
|
car->SetPosition(x, y, z);
|
2020-04-30 09:45:45 -04:00
|
|
|
car->SetStatus(STATUS_PLAYER_REMOTE);
|
2020-01-31 05:23:15 -05:00
|
|
|
car->bIsLocked = true;
|
|
|
|
|
|
|
|
CCarCtrl::JoinCarWithRoadSystem(car);
|
|
|
|
car->AutoPilot.m_nCarMission = MISSION_NONE;
|
|
|
|
car->AutoPilot.m_nTempAction = TEMPACT_NONE;
|
|
|
|
car->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
|
|
|
|
car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f;
|
|
|
|
car->AutoPilot.m_nNextLane = car->AutoPilot.m_nCurrentLane = 0;
|
|
|
|
car->bEngineOn = true;
|
|
|
|
CWorld::Add(car);
|
|
|
|
if (FindPlayerVehicle() != nil)
|
2020-04-30 09:45:45 -04:00
|
|
|
FindPlayerVehicle()->SetStatus(STATUS_PLAYER_DISABLED);
|
2020-01-31 05:23:15 -05:00
|
|
|
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = car;
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->RegisterReference((CEntity**)&CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle);
|
2020-04-02 06:48:01 -04:00
|
|
|
TheCamera.TakeControl(car, CCam::MODE_BEHINDCAR, INTERPOLATION, CAMCONTROL_SCRIPT);
|
2020-01-31 05:23:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CRemote::TakeRemoteControlledCarFromPlayer(void)
|
|
|
|
{
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->VehicleCreatedBy = RANDOM_VEHICLE;
|
|
|
|
CCarCtrl::NumMissionCars--;
|
|
|
|
CCarCtrl::NumRandomCars++;
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->bIsLocked = false;
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_nTimeLostRemoteCar = CTimer::GetTimeInMilliseconds();
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_bInRemoteMode = true;
|
|
|
|
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->bRemoveFromWorld = true;
|
|
|
|
}
|