This Tutorial, is for "Improve" Sounds on Car, Like that video:
https://www.youtube.com/watch?v=mthsVHd9Y9c
ONLY WORK ON AllRight Source
Okay, lets go to Tutorial!
In obj_Vehicle.cpp Search for this...
PHP Code:
void obj_Vehicle::UpdateEngineSound()
And Change for this
PHP Code:
void obj_Vehicle::UpdateEngineSound()
{
// ONLY SAME CAR!!!!!!!!!!!!!!!!
//if (!EngineSnd) return;
if (!gClientLogic().localPlayer_) return;
if (gClientLogic().localPlayer_->curcar == NULL) return;
if (gClientLogic().localPlayer_->curcar != this) return;
//if (!status) return;
if (!SoundSys.IsHandleValid(EngineSnd))
{
if (EngineSnd)
SoundSys.Release(EngineSnd);
EngineSnd = NULL;
//EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngineLoop"), GetPosition());
{
if(FileName == "data/objectsdepot/vehicles/drivable_stryker.sco") //Fdr Novos sons para o carro...
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngineLoop"), GetPosition());
else if (FileName == "data/objectsdepot/vehicles/drivable_buggy_02.sco")
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngineLoop"), GetPosition());
else if (FileName == "data/objectsdepot/vehicles/zombie_killer_car.sco")
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngineLoop"), GetPosition());
else
EngineSnd = NULL;
}
SoundSys.Stop(EngineSnd);
if (!SoundSys.IsHandleValid(EngineSnd))
return;
}
//else if(!SoundSys.isPlaying(EngineSnd))
if (fuel < 2)
SoundSys.Stop(EngineSnd);
else
if(!SoundSys.isPlaying(EngineSnd))
SoundSys.Start(EngineSnd);
float rpm;
if (gClientLogic().localPlayer_->isDriving() && gClientLogic().localPlayer_->curcar == this)
rpm = R3D_MIN(getVehicleDescriptor()->vehicle->mDriveDynData.getEngineRotationSpeed()*5.33f, 8000.0f);
else
rpm = R3D_MIN(getVehicleDescriptor()->vehicle->mDriveDynData.getEngineRotationSpeed()*7.33f, 8000.0f);
SoundSys.SetParamValue(EngineSnd,"rpm",rpm);
SoundSys.SetSoundPos(EngineSnd,GetPosition());
}
Like That
PHP Code:
// Engine
void obj_Vehicle::UpdateEngineSound
()
{
// ONLY SAME CAR!!!!!!!!!!!!!!!!
//if (!EngineSnd) return;
if (!gClientLogic().localPlayer_) return;
if (gClientLogic().localPlayer_->curcar == NULL) return;
if (gClientLogic().localPlayer_->curcar != this) return;
//if (!status) return;
if (!SoundSys.IsHandleValid(EngineSnd))
{
if (EngineSnd)
SoundSys.Release(EngineSnd);
EngineSnd = NULL;
//EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngineLoop"), GetPosition());
{
if(FileName == "data/objectsdepot/vehicles/drivable_stryker.sco") //Fdr Novos sons para o carro...
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngineLoop"), GetPosition());
else if (FileName == "data/objectsdepot/vehicles/drivable_buggy_02.sco")
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngineLoop"), GetPosition());
else if (FileName == "data/objectsdepot/vehicles/zombie_killer_car.sco")
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngineLoop"), GetPosition());
else
EngineSnd = NULL;
}
SoundSys.Stop(EngineSnd);
if (!SoundSys.IsHandleValid(EngineSnd))
return;
}
//else if(!SoundSys.isPlaying(EngineSnd))
if (fuel < 2)
SoundSys.Stop(EngineSnd);
else
if(!SoundSys.isPlaying(EngineSnd))
SoundSys.Start(EngineSnd);
float rpm;
if (gClientLogic().localPlayer_->isDriving() && gClientLogic().localPlayer_->curcar == this)
rpm = R3D_MIN(getVehicleDescriptor()->vehicle->mDriveDynData.getEngineRotationSpeed()*5.33f, 8000.0f);
else
rpm = R3D_MIN(getVehicleDescriptor()->vehicle->mDriveDynData.getEngineRotationSpeed()*7.33f, 8000.0f);
SoundSys.SetParamValue(EngineSnd,"rpm",rpm);
SoundSys.SetSoundPos(EngineSnd,GetPosition());
}
void obj_Vehicle::UpdateTraction()
Now Search for this
PHP Code:
BOOL obj_Vehicle::OnCreate()
And Change for this.
PHP Code:
BOOL obj_Vehicle::OnCreate()
{
m_ActionUI_Title = gLangMngr.getString("Vehicle");
m_ActionUI_Msg = gLangMngr.getString("Hold E To Enter Vehicle");
if (!parent::OnCreate())
return FALSE;
r3dMesh *m = MeshLOD[0];
if (!m)
return FALSE;
vd = g_pPhysicsWorld->m_VehicleManager->CreateVehicle(m);
if (vd)
{
// Set position and orientation for car
SwitchToDrivable(d_drive_vehicles->GetBool());
SyncPhysicsPoseWithObjectPose();
r3dBoundBox bb = GetBBoxLocal();
std::swap(bb.Size.x, bb.Size.z);
std::swap(bb.Org.x, bb.Org.z);
SetBBoxLocal(bb);
vd->owner = this;
}
if (FileName == "data/objectsdepot/vehicles/drivable_stryker.sco") //Fdr - Novos sons para o carro...
{
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngineLoop"), GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/drivable_buggy_02.sco")
{
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngineLoop"), GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/zombie_killer_car.sco")
{
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngineLoop"), GetPosition());
}
netMover.Teleport(GetPosition());
dura = 100.0f;
RemoteSpeed = 0.0f;
//extime = 0.0f;
//(obj_ParticleSystem*)srv_CreateGameObject("obj_ParticleSystem", "Fire_Large_01", GetPosition() );
Light = (obj_LightHelper*)srv_CreateGameObject("obj_LightHelper", "Spot", GetPosition ());
Light->SetRotationVector(GetRotationVector());
//Light->m_pPreset = m_pPreset;
Light->SetPosition(GetBBoxWorld().Center());
Light->Color = r3dColor::white;;
/*Light->LT.bDiffuseOnly = 0;
Light->LT.bCastShadows = 0;
Light->LT.bDiffuseOnly = 0;
Light->LT.bDiffuseOnly = 0;*/
/* Light->LT.Intensity = 4.0f;
Light->bOn = true;
Light->innerRadius = 30.0f;
Light->outerRadius = 40.0f;*/
Light->LT.Intensity = 0.0f;
Light->bOn = true;
Light->innerRadius = 0.0f;
Light->outerRadius = 0.0f;
Light->bKilled = false;
//Light->bSerialized = true;
//bOn = false;
m_ParticleTracer = NULL;
//fuel = 100;
// Sound
//EngineSnd = NULL;
//EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngineLoop"), GetPosition());
SoundSys.Stop(EngineSnd);
r3d_assert(EngineSnd);
return vd != 0;
}
Like That
PHP Code:
BOOL obj_Vehicle::OnCreate()
{
m_ActionUI_Title = gLangMngr.getString("Vehicle");
m_ActionUI_Msg = gLangMngr.getString("Hold E To Enter Vehicle");
if (!parent::OnCreate())
return FALSE;
r3dMesh *m = MeshLOD[0];
if (!m)
return FALSE;
vd = g_pPhysicsWorld->m_VehicleManager->CreateVehicle(m);
if (vd)
{
// Set position and orientation for car
SwitchToDrivable(d_drive_vehicles->GetBool());
SyncPhysicsPoseWithObjectPose();
r3dBoundBox bb = GetBBoxLocal();
std::swap(bb.Size.x, bb.Size.z);
std::swap(bb.Org.x, bb.Org.z);
SetBBoxLocal(bb);
vd->owner = this;
}
if (FileName == "data/objectsdepot/vehicles/drivable_stryker.sco") //Fdr - Novos sons para o carro...
{
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngineLoop"), GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/drivable_buggy_02.sco")
{
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngineLoop"), GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/zombie_killer_car.sco")
{
EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngineLoop"), GetPosition());
}
netMover.Teleport(GetPosition());
dura = 100.0f;
RemoteSpeed = 0.0f;
//extime = 0.0f;
//(obj_ParticleSystem*)srv_CreateGameObject("obj_ParticleSystem", "Fire_Large_01", GetPosition() );
Light = (obj_LightHelper*)srv_CreateGameObject("obj_LightHelper", "Spot", GetPosition ());
Light->SetRotationVector(GetRotationVector());
//Light->m_pPreset = m_pPreset;
Light->SetPosition(GetBBoxWorld().Center());
Light->Color = r3dColor::white;;
/*Light->LT.bDiffuseOnly = 0;
Light->LT.bCastShadows = 0;
Light->LT.bDiffuseOnly = 0;
Light->LT.bDiffuseOnly = 0;*/
/* Light->LT.Intensity = 4.0f;
Light->bOn = true;
Light->innerRadius = 30.0f;
Light->outerRadius = 40.0f;*/
Light->LT.Intensity = 0.0f;
Light->bOn = true;
Light->innerRadius = 0.0f;
Light->outerRadius = 0.0f;
Light->bKilled = false;
//Light->bSerialized = true;
//bOn = false;
m_ParticleTracer = NULL;
//fuel = 100;
// Sound
//EngineSnd = NULL;
//EngineSnd = SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngineLoop"), GetPosition());
SoundSys.Stop(EngineSnd);
r3d_assert(EngineSnd);
return vd != 0;
}
//////////////////////////////////////////////////////////////////////////
Now in Al_Player.cpp Search for this
PHP Code:
if(dropObj->Class->Name == "obj_Vehicle")
And Change for this
PHP Code:
if(dropObj->Class->Name == "obj_Vehicle")
{
obj_Vehicle* target_Vehicle = (obj_Vehicle*)dropObj;
if ( target_Vehicle ) // now we're going to try to use vehicles (otherwise UAV characters can't use vehicles).
{
if ( target_Vehicle->status )
{
//hudMain->showMessage(L"Cannot enter vehicle");
curcar = target_Vehicle;
vehicleViewActive_ = VehicleView_Passenger;
hudActionUI->Deactivate();
TogglePhysicsSimulation(false);
PKT_C2C_CarPass_s n;
n.NetID = toP2pNetId(target_Vehicle->GetNetworkID());
p2pSendToHost(gClientLogic().localPlayer_, &n, sizeof(n));
return;
}
hudActionUI->showEBlock(false,false);
hudActionUI->Deactivate();
d_drive_vehiclescon->SetBool(true);
enterVehicle( target_Vehicle );
curcar = target_Vehicle;
//g_pPhysicsWorld->m_VehicleManager->DriveCar(target_Vehicle->vd);
if (FileName == "data/objectsdepot/vehicles/drivable_stryker.sco") //Fdr Novos sons para o carro...
{
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngine_Start"), GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/drivable_buggy_02.sco")
{
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngine_Start"),GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/zombie_killer_car.sco")
{
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngine_Start"),GetPosition());
}
}
return;
}
Like That
PHP Code:
if(dropObj->Class->Name == "obj_Vehicle")
{
obj_Vehicle* target_Vehicle = (obj_Vehicle*)dropObj;
if ( target_Vehicle ) // now we're going to try to use vehicles (otherwise UAV characters can't use vehicles).
{
if ( target_Vehicle->status )
{
//hudMain->showMessage(L"Cannot enter vehicle");
curcar = target_Vehicle;
vehicleViewActive_ = VehicleView_Passenger;
hudActionUI->Deactivate();
TogglePhysicsSimulation(false);
PKT_C2C_CarPass_s n;
n.NetID = toP2pNetId(target_Vehicle->GetNetworkID());
p2pSendToHost(gClientLogic().localPlayer_, &n, sizeof(n));
return;
}
hudActionUI->showEBlock(false,false);
hudActionUI->Deactivate();
d_drive_vehiclescon->SetBool(true);
enterVehicle( target_Vehicle );
curcar = target_Vehicle;
//g_pPhysicsWorld->m_VehicleManager->DriveCar(target_Vehicle->vd);
}
// SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngine_Start"),GetPosition());
{
if (FileName == "data/objectsdepot/vehicles/drivable_stryker.sco") //Fdr Novos sons para o carro...
{
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngine_Start"), GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/drivable_buggy_02.sco")
{
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngine_Start"),GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/zombie_killer_car.sco")
{
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngine_Start"),GetPosition());
}
}
return;
}
if(dropObj->Class->Name == "obj_SafeLock")
Now Search for This
PHP Code:
void obj_Player::exitVehicle()
And Change to this
PHP Code:
void obj_Player::exitVehicle()
{
hudMain->setCarInfo(0,0,0,0,0,false);
//SoundSys.Stop(m_sndVehicleDrive);
//SoundSys.Play(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngine_Stop"), curcar->GetPosition(), true);
r3dVector targetPosition = curcar->GetPosition() + r3dPoint3D( 4, 3, 0 );
// Server Vehicles TeleportPlayer( targetPosition, "Exiting vehicle");
curcar->SwitchToDrivable( false );
vehicleViewActive_ = VehicleView_None;
d_drive_vehiclescon->SetBool(false);
d_drive_vehicles->SetBool( false );
curcar->SwitchToDrivable( false );
PKT_C2C_CarStatus_s n;
n.status = false;
n.fuel = curcar->fuel;
p2pSendToHost(curcar,&n,sizeof(n));
// g_pPhysicsWorld->m_VehicleManager->getRealDrivenVehicle()->owner = NULL;
curcar->NetworkLocal = false;
//g_pPhysicsWorld->m_VehicleManager->getRealDrivenVehicle()->vd->owner=0;
TogglePhysicsSimulation(true);
if (FileName == "data/objectsdepot/vehicles/drivable_stryker.sco") //Fdr Novos sons para o carro...
{
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngine_Stop"), GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/drivable_buggy_02.sco")
{
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/DuneBuggyEngine_Stop"), GetPosition());
}
if (FileName == "data/objectsdepot/vehicles/zombie_killer_car.sco")
{
SoundSys.PlayAndForget(SoundSys.GetEventIDByPath("Sounds/Vehicles/StrykerEngine_Stop"), GetPosition());
}
}
Credits: Aomosin - Source
me for Codes .. 