diff --git a/src/animation/AnimManager.h b/src/animation/AnimManager.h index 905cac6c..8658c056 100644 --- a/src/animation/AnimManager.h +++ b/src/animation/AnimManager.h @@ -8,10 +8,10 @@ enum AssocGroupId ASSOCGRP_STD, ASSOCGRP_VAN, ASSOCGRP_COACH, - ASSOCGRP_BIKES, - ASSOCGRP_BIKEV, - ASSOCGRP_BIKEH, - ASSOCGRP_BIKED, + ASSOCGRP_BIKE_STANDARD, + ASSOCGRP_BIKE_VESPA, + ASSOCGRP_BIKE_HARLEY, + ASSOCGRP_BIKE_DIRT, ASSOCGRP_UNARMED, ASSOCGRP_SCREWDRIVER, ASSOCGRP_KNIFE, diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp index fe2c250f..ac80fe83 100644 --- a/src/core/Cam.cpp +++ b/src/core/Cam.cpp @@ -5,6 +5,7 @@ #include "World.h" #include "Vehicle.h" #include "Automobile.h" +#include "Boat.h" #include "Ped.h" #include "PlayerPed.h" #include "CopPed.h" @@ -2718,7 +2719,7 @@ CCam::Process_1stPerson(const CVector &CameraTarget, float TargetOrientation, fl }else{ assert(CamTargetEntity->IsVehicle()); CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(CamTargetEntity->GetModelIndex()); - CVector CamPos = mi->m_vehicleType == VEHICLE_TYPE_BOAT ? mi->m_positions[BOAT_POS_FRONTSEAT] : mi->m_positions[CAR_POS_FRONTSEAT]; + CVector CamPos = mi->GetFrontSeatPosn(); CamPos.x = 0.0f; CamPos.y += -0.08f; CamPos.z += 0.62f; diff --git a/src/core/Radar.h b/src/core/Radar.h index 61d94d05..95b74b84 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -122,7 +122,7 @@ struct sRadarTrace // Values for screen space #define RADAR_LEFT (40.0f) -#define RADAR_BOTTOM (47.0f) +#define RADAR_BOTTOM (40.0f) #define RADAR_WIDTH (94.0f) #define RADAR_HEIGHT (76.0f) diff --git a/src/core/re3.cpp b/src/core/re3.cpp index cb249f53..458ec6d6 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -16,6 +16,7 @@ #include "Boat.h" #include "Heli.h" #include "Automobile.h" +#include "Bike.h" #include "Ped.h" #include "Particle.h" #include "Console.h" @@ -112,6 +113,8 @@ SpawnCar(int id) CVehicle *v; if(CModelInfo::IsBoatModel(id)) v = new CBoat(id, RANDOM_VEHICLE); + if(CModelInfo::IsBikeModel(id)) + v = new CBike(id, RANDOM_VEHICLE); else v = new CAutomobile(id, RANDOM_VEHICLE); @@ -141,10 +144,12 @@ FixCar(void) if(veh == nil) return; veh->m_fHealth = 1000.0f; - if(!veh->IsCar()) - return; - ((CAutomobile*)veh)->Damage.SetEngineStatus(0); - ((CAutomobile*)veh)->Fix(); + if(veh->IsCar()){ + ((CAutomobile*)veh)->Damage.SetEngineStatus(0); + ((CAutomobile*)veh)->Fix(); + }else if(veh->IsBike()){ + ((CBike*)veh)->Fix(); + } } #ifdef MENU_MAP @@ -355,6 +360,7 @@ DebugMenuPopulate(void) DebugMenuAddCmd("Spawn", "Spawn Rhino", [](){ SpawnCar(MI_RHINO); }); DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); }); DebugMenuAddCmd("Spawn", "Spawn Predator", [](){ SpawnCar(MI_PREDATOR); }); + DebugMenuAddCmd("Spawn", "Spawn PCJ 600", [](){ SpawnCar(MI_PCJ600); }); DebugMenuAddVarBool8("Render", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil); DebugMenuAddVarBool8("Render", "Backface Culling", &gBackfaceCulling, nil); diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp index d80fc4cf..d1994c06 100644 --- a/src/modelinfo/VehicleModelInfo.cpp +++ b/src/modelinfo/VehicleModelInfo.cpp @@ -133,11 +133,11 @@ RwObjectNameIdAssocation bikeIds[] = { { "wheel_rear", BIKE_WHEEL_REAR, 0 }, { "mudguard", BIKE_MUDGUARD, 0 }, { "handlebars", BIKE_HANDLEBARS, 0 }, - { "ped_frontseat", BIKE_POS_FRONTSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, - { "ped_backseat", BIKE_POS_BACKSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, - { "headlights", BIKE_POS_HEADLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, - { "taillights", BIKE_POS_TAILLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, - { "exhaust", BIKE_POS_EXHAUST, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "ped_frontseat", CAR_POS_FRONTSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "ped_backseat", CAR_POS_BACKSEAT, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "headlights", CAR_POS_HEADLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "taillights", CAR_POS_TAILLIGHTS, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, + { "exhaust", CAR_POS_EXHAUST, VEHICLE_FLAG_POS | CLUMP_FLAG_NO_HIERID }, { "extra1", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID }, { "extra2", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID }, { "extra3", 0, VEHICLE_FLAG_DRAWLAST | VEHICLE_FLAG_COMP | CLUMP_FLAG_NO_HIERID }, diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h index 5ee6d263..945bdd92 100644 --- a/src/modelinfo/VehicleModelInfo.h +++ b/src/modelinfo/VehicleModelInfo.h @@ -34,6 +34,36 @@ enum eVehicleType { NUM_VEHICLE_TYPES }; +enum eCarPositions +{ + CAR_POS_HEADLIGHTS, + CAR_POS_TAILLIGHTS, + CAR_POS_FRONTSEAT, + CAR_POS_BACKSEAT, + CAR_POS_EXHAUST +}; + +enum eBoatPositions +{ + BOAT_POS_FRONTSEAT +}; + +enum eTrainPositions +{ + TRAIN_POS_LIGHT_FRONT, + TRAIN_POS_LIGHT_REAR, + TRAIN_POS_LEFT_ENTRY, + TRAIN_POS_MID_ENTRY, + TRAIN_POS_RIGHT_ENTRY +}; + +enum ePlanePositions +{ + PLANE_POS_LIGHT_LEFT, + PLANE_POS_LIGHT_RIGHT, + PLANE_POS_LIGHT_TAIL, +}; + enum { NUM_VEHICLE_POSITIONS = 5 }; @@ -107,6 +137,7 @@ public: void SetVehicleComponentFlags(RwFrame *frame, uint32 flags); void PreprocessHierarchy(void); void GetWheelPosn(int32 n, CVector &pos); + CVector GetFrontSeatPosn(void) { return m_positions[m_vehicleType == VEHICLE_TYPE_BOAT ? BOAT_POS_FRONTSEAT : CAR_POS_FRONTSEAT]; }; int32 ChooseComponent(void); int32 ChooseSecondComponent(void); diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index c2c272bf..72f9bfae 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2059,11 +2059,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP switch (component) { case CAR_DOOR_RF: - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - vehDoorPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - vehDoorPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + vehDoorPos = vehModel->GetFrontSeatPosn(); vehDoorPos.x += seatOffset; vehDoorOffset.x = -vehDoorOffset.x; break; @@ -2075,11 +2071,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP break; case CAR_DOOR_LF: - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - vehDoorPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - vehDoorPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + vehDoorPos = vehModel->GetFrontSeatPosn(); vehDoorPos.x = -(vehDoorPos.x + seatOffset); break; @@ -2089,11 +2081,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP break; default: - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - vehDoorPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - vehDoorPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + vehDoorPos = vehModel->GetFrontSeatPosn(); vehDoorOffset = CVector(0.0f, 0.0f, 0.0f); } return vehDoorPos - vehDoorOffset; @@ -15678,11 +15666,7 @@ CPed::SeekBoatPosition(void) CVehicleModelInfo *boatModel = m_carInObjective->GetModelInfo(); CVector enterOffset; - if (boatModel->m_vehicleType == VEHICLE_TYPE_BOAT) - enterOffset = boatModel->m_positions[BOAT_POS_FRONTSEAT]; - else - enterOffset = boatModel->m_positions[CAR_POS_FRONTSEAT]; - + enterOffset = boatModel->GetFrontSeatPosn(); enterOffset.x = 0.0f; CMatrix boatMat(m_carInObjective->GetMatrix()); SetMoveState(PEDMOVE_WALK); @@ -17480,29 +17464,20 @@ CPed::SetPedPositionInCar(void) CMatrix newMat(m_pMyVehicle->GetMatrix()); CVector seatPos; if (m_pMyVehicle->pDriver == this) { - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - seatPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - seatPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; - + seatPos = vehModel->GetFrontSeatPosn(); if (!m_pMyVehicle->IsBoat() && m_pMyVehicle->m_vehType != VEHICLE_TYPE_BIKE) seatPos.x = -seatPos.x; } else if (m_pMyVehicle->pPassengers[0] == this) { - if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) - seatPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; - else - seatPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; + seatPos = vehModel->GetFrontSeatPosn(); } else if (m_pMyVehicle->pPassengers[1] == this) { seatPos = vehModel->m_positions[CAR_POS_BACKSEAT]; seatPos.x = -seatPos.x; } else { if (m_pMyVehicle->pPassengers[2] == this) { seatPos = vehModel->m_positions[CAR_POS_BACKSEAT]; - } else if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT) { - seatPos = vehModel->m_positions[BOAT_POS_FRONTSEAT]; } else { - seatPos = vehModel->m_positions[CAR_POS_FRONTSEAT]; + seatPos = vehModel->GetFrontSeatPosn(); } } newMat.GetPosition() += Multiply3x3(newMat, seatPos); diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index f4444f58..d146ffca 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -175,8 +175,7 @@ CAutomobile::CAutomobile(int32 id, uint8 CreatedBy) for(i = 0; i < 4; i++){ m_aGroundPhysical[i] = nil; m_aGroundOffset[i] = CVector(0.0f, 0.0f, 0.0f); - m_aSuspensionSpringRatio[i] = 1.0f; - m_aSuspensionSpringRatioPrev[i] = m_aSuspensionSpringRatio[i]; + m_aSuspensionSpringRatioPrev[i] = m_aSuspensionSpringRatio[i] = 1.0f; m_aWheelTimer[i] = 0.0f; m_aWheelRotation[i] = 0.0f; m_aWheelSpeed[i] = 0.0f; @@ -4850,8 +4849,8 @@ CAutomobile::BurstTyre(uint8 wheel, bool applyForces) } if(applyForces){ - ApplyMoveForce(GetRight() * CGeneral::GetRandomNumberInRange(-0.3f, 0.3f)); - ApplyTurnForce(GetRight() * CGeneral::GetRandomNumberInRange(-0.3f, 0.3f), GetForward()); + ApplyMoveForce(GetRight() * m_fMass * CGeneral::GetRandomNumberInRange(-0.03f, 0.03f)); + ApplyTurnForce(GetRight() * m_fTurnMass * CGeneral::GetRandomNumberInRange(-0.03f, 0.03f), GetForward()); } } } @@ -4867,10 +4866,10 @@ CAutomobile::IsRoomForPedToLeaveCar(uint32 component, CVector *doorOffset) CVector seatPos; switch(component){ case CAR_DOOR_RF: - seatPos = mi->m_positions[mi->m_vehicleType == VEHICLE_TYPE_BOAT ? BOAT_POS_FRONTSEAT : CAR_POS_FRONTSEAT]; + seatPos = mi->GetFrontSeatPosn(); break; case CAR_DOOR_LF: - seatPos = mi->m_positions[mi->m_vehicleType == VEHICLE_TYPE_BOAT ? BOAT_POS_FRONTSEAT : CAR_POS_FRONTSEAT]; + seatPos = mi->GetFrontSeatPosn(); seatPos.x = -seatPos.x; break; case CAR_DOOR_RR: @@ -4898,7 +4897,7 @@ CAutomobile::IsRoomForPedToLeaveCar(uint32 component, CVector *doorOffset) CVector dist = doorPos - seatPos; - // Removing that makes this func. return false for van doors. + // Removing that makes thiProcessEntityCollisions func. return false for van doors. doorPos.z += 0.5f; float length = dist.Magnitude(); CVector pedPos = seatPos + dist*((length+0.6f)/length); @@ -5519,7 +5518,7 @@ CAutomobile::SetupModelNodes(void) int i; for(i = 0; i < NUM_CAR_NODES; i++) m_aCarNodes[i] = nil; - CClumpModelInfo::FillFrameArray((RpClump*)m_rwObject, m_aCarNodes); + CClumpModelInfo::FillFrameArray(GetClump(), m_aCarNodes); } void diff --git a/src/vehicles/Automobile.h b/src/vehicles/Automobile.h index 9d24d237..186ed646 100644 --- a/src/vehicles/Automobile.h +++ b/src/vehicles/Automobile.h @@ -31,15 +31,6 @@ enum eCarNodes NUM_CAR_NODES, }; -enum eCarPositions -{ - CAR_POS_HEADLIGHTS, - CAR_POS_TAILLIGHTS, - CAR_POS_FRONTSEAT, - CAR_POS_BACKSEAT, - CAR_POS_EXHAUST -}; - // These are used for all the wheel arrays // DON'T confuse with VEHWHEEL, which are vehicle components enum { @@ -49,16 +40,6 @@ enum { CARWHEEL_REAR_RIGHT }; -enum eBombType -{ - CARBOMB_NONE, - CARBOMB_TIMED, - CARBOMB_ONIGNITION, - CARBOMB_REMOTE, - CARBOMB_TIMEDACTIVE, - CARBOMB_ONIGNITIONACTIVE, -}; - enum { CAR_DOOR_FLAG_UNKNOWN = 0x0, CAR_DOOR_FLAG_LF = 0x1, diff --git a/src/vehicles/Bike.h b/src/vehicles/Bike.h index f68a9513..ba93fda0 100644 --- a/src/vehicles/Bike.h +++ b/src/vehicles/Bike.h @@ -1,5 +1,6 @@ #pragma once +#include "Vehicle.h" #include "Skidmarks.h" enum eBikeNodes { @@ -14,20 +15,23 @@ enum eBikeNodes { BIKE_NUM_NODES }; -enum eBikePositions -{ - BIKE_POS_HEADLIGHTS, - BIKE_POS_TAILLIGHTS, - BIKE_POS_FRONTSEAT, - BIKE_POS_BACKSEAT, - BIKE_POS_EXHAUST +enum { + BIKEWHEEL_FRONT, + BIKEWHEEL_REAR, +}; + +enum { + BIKESUSP_FRONT_1, + BIKESUSP_FRONT_2, + BIKESUSP_REAR_1, + BIKESUSP_REAR_2, }; class CBike : public CVehicle { public: RwFrame *m_aBikeNodes[BIKE_NUM_NODES]; - bool m_bLeanMatrixCalculated; + bool bLeanMatrixClean; CMatrix m_leanMatrix; CVector wheelieNormal; CVector wheelieRight; @@ -83,4 +87,43 @@ public: uint8 m_nDriveWheelsOnGroundPrev; float m_fGasPedalAudio; tWheelState m_aWheelState[2]; + + CBike(int32 id, uint8 CreatedBy); + + // from CEntity + void SetModelIndex(uint32 id); + void ProcessControl(void); + void Teleport(CVector v); + void PreRender(void); + void Render(void); + + // from CPhysical + int32 ProcessEntityCollision(CEntity *ent, CColPoint *colpoints); + + // from CVehicle + void ProcessControlInputs(uint8); + void GetComponentWorldPosition(int32 component, CVector &pos); + bool IsComponentPresent(int32 component); + void SetComponentRotation(int32 component, CVector rotation); + bool IsDoorReady(eDoors door); + bool IsDoorFullyOpen(eDoors door); + bool IsDoorClosed(eDoors door); + bool IsDoorMissing(eDoors door); + void RemoveRefsToVehicle(CEntity *ent); + void BlowUpCar(CEntity *ent); + bool SetUpWheelColModel(CColModel *colModel); + void BurstTyre(uint8 tyre, bool applyForces); + bool IsRoomForPedToLeaveCar(uint32 component, CVector *doorOffset); + float GetHeightAboveRoad(void); + void PlayCarHorn(void); + + void PlayHornIfNecessary(void); + void ResetSuspension(void); + void SetupSuspensionLines(void); + void CalculateLeanMatrix(void); + void GetCorrectedWorldDoorPosition(CVector &pos, CVector p1, CVector p2); + + void Fix(void); + void SetupModelNodes(void); + void ReduceHornCounter(void); }; diff --git a/src/vehicles/Plane.h b/src/vehicles/Plane.h index a9afa4bc..e9456bcd 100644 --- a/src/vehicles/Plane.h +++ b/src/vehicles/Plane.h @@ -9,13 +9,6 @@ enum ePlaneNodes NUM_PLANE_NODES }; -enum ePlanePositions -{ - PLANE_POS_LIGHT_LEFT, - PLANE_POS_LIGHT_RIGHT, - PLANE_POS_LIGHT_TAIL, -}; - struct CPlaneNode { CVector p; // position diff --git a/src/vehicles/Train.h b/src/vehicles/Train.h index d8ee949d..57cd28de 100644 --- a/src/vehicles/Train.h +++ b/src/vehicles/Train.h @@ -24,15 +24,6 @@ enum eTrainNodes NUM_TRAIN_NODES }; -enum eTrainPositions -{ - TRAIN_POS_LIGHT_FRONT, - TRAIN_POS_LIGHT_REAR, - TRAIN_POS_LEFT_ENTRY, - TRAIN_POS_MID_ENTRY, - TRAIN_POS_RIGHT_ENTRY -}; - struct CTrainNode { CVector p; // position diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index 3fe99144..319f27c8 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -31,10 +31,14 @@ enum eCarLock { CARLOCK_SKIP_SHUT_DOORS }; - -enum +enum eBombType { - BOAT_POS_FRONTSEAT + CARBOMB_NONE, + CARBOMB_TIMED, + CARBOMB_ONIGNITION, + CARBOMB_REMOTE, + CARBOMB_TIMEDACTIVE, + CARBOMB_ONIGNITIONACTIVE, }; enum eDoors diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index b2ac2ad2..ee786f5f 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -25,7 +25,8 @@ #include "Stats.h" #include "TempColModels.h" #include "Timer.h" -#include "Vehicle.h" +#include "Automobile.h" +#include "Boat.h" #include "WaterLevel.h" #include "WeaponInfo.h" #include "World.h" @@ -2056,31 +2057,29 @@ CWeapon::FireInstantHitFromCar(CVehicle *shooter, bool left) CVehicleModelInfo *modelInfo = shooter->GetModelInfo(); - #define FRONTSEATPOS() (&(shooter->IsBoat() ? modelInfo->m_positions[BOAT_POS_FRONTSEAT] : modelInfo->m_positions[CAR_POS_FRONTSEAT])) - CVector source, target; if ( left ) { source = shooter->GetMatrix() * CVector(-shooter->GetColModel()->boundingBox.max.x + -0.2f, - float(CGeneral::GetRandomNumber() & 255) * 0.001f + FRONTSEATPOS()->y, - FRONTSEATPOS()->z + 0.5f); + float(CGeneral::GetRandomNumber() & 255) * 0.001f + modelInfo->GetFrontSeatPosn().y, + modelInfo->GetFrontSeatPosn().z + 0.5f); source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed; target = shooter->GetMatrix() * CVector(-info->m_fRange, - FRONTSEATPOS()->y, - FRONTSEATPOS()->z + 0.5f); + modelInfo->GetFrontSeatPosn().y, + modelInfo->GetFrontSeatPosn().z + 0.5f); } else { source = shooter->GetMatrix() * CVector(shooter->GetColModel()->boundingBox.max.x + 0.2f, - float(CGeneral::GetRandomNumber() & 255) * 0.001f + FRONTSEATPOS()->y, - FRONTSEATPOS()->z + 0.5f); + float(CGeneral::GetRandomNumber() & 255) * 0.001f + modelInfo->GetFrontSeatPosn().y, + modelInfo->GetFrontSeatPosn().z + 0.5f); source += CTimer::GetTimeStep() * shooter->m_vecMoveSpeed; target = shooter->GetMatrix() * CVector(info->m_fRange, - FRONTSEATPOS()->y, - FRONTSEATPOS()->z + 0.5f); + modelInfo->GetFrontSeatPosn().y, + modelInfo->GetFrontSeatPosn().z + 0.5f); } #undef FRONTSEATPOS