mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-28 03:54:15 +01:00
some changes
This commit is contained in:
parent
7919b92d28
commit
2f979a8cde
@ -2593,6 +2593,54 @@ float CCarCtrl::FindMaxSteerAngle(CVehicle* pVehicle)
|
|||||||
return pVehicle->GetModelIndex() == MI_ENFORCER ? 0.7f : DEFAULT_MAX_STEER_ANGLE;
|
return pVehicle->GetModelIndex() == MI_ENFORCER ? 0.7f : DEFAULT_MAX_STEER_ANGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCarCtrl::SteerAIHeliTowardsTargetCoors(CAutomobile* pHeli)
|
||||||
|
{
|
||||||
|
if (pHeli->m_aWheelSpeed[1] < 0.22f)
|
||||||
|
pHeli->m_aWheelSpeed[1] += 0.001f;
|
||||||
|
if (pHeli->m_aWheelSpeed[1] < 0.22f)
|
||||||
|
return;
|
||||||
|
CVector2D vecToTarget = pHeli->AutoPilot.m_vecDestinationCoors - pHeli->GetPosition();
|
||||||
|
float distanceToTarget = vecToTarget.Magnitude();
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
float speed = pHeli->AutoPilot.GetCruiseSpeed() * 0.01f;
|
||||||
|
#else
|
||||||
|
float speed = pHeli->AutoPilot.m_nCruiseSpeed * 0.01f;
|
||||||
|
#endif
|
||||||
|
if (distanceToTarget >= 100.0f)
|
||||||
|
{
|
||||||
|
if (distanceToTarget > 75.0f)
|
||||||
|
speed *= 0.7f;
|
||||||
|
else if (distanceToTarget > 10.0f)
|
||||||
|
speed *= 0.4f;
|
||||||
|
else
|
||||||
|
speed *= 0.2f;
|
||||||
|
}
|
||||||
|
CVector2D vecAdvanceThisFrame = vecToTarget;
|
||||||
|
vecAdvanceThisFrame.Normalise();
|
||||||
|
vecAdvanceThisFrame *= speed;
|
||||||
|
float resistance = Pow(0.997f, CTimer::GetTimeStep());
|
||||||
|
pHeli->m_vecMoveSpeed.x *= resistance;
|
||||||
|
pHeli->m_vecMoveSpeed.y *= resistance;
|
||||||
|
vecAdvanceThisFrame -= pHeli->m_vecMoveSpeed;
|
||||||
|
CVector2D vecSpeedChange = vecAdvanceThisFrame - pHeli->m_vecMoveSpeed;
|
||||||
|
float vecSpeedChangeLength = vecSpeedChange.Magnitude();
|
||||||
|
vecSpeedChange.Normalise();
|
||||||
|
float changeMultiplier = 0.002f * CTimer::GetTimeStep();
|
||||||
|
if (distanceToTarget < 5.0f)
|
||||||
|
changeMultiplier /= 5.0f;
|
||||||
|
if (vecSpeedChangeLength < changeMultiplier) {
|
||||||
|
pHeli->m_vecMoveSpeed.x = vecAdvanceThisFrame.x;
|
||||||
|
pHeli->m_vecMoveSpeed.y = vecAdvanceThisFrame.y;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pHeli->m_vecMoveSpeed.x += vecSpeedChange.x * changeMultiplier;
|
||||||
|
pHeli->m_vecMoveSpeed.y += vecSpeedChange.y * changeMultiplier;
|
||||||
|
}
|
||||||
|
pHeli->SetPosition(pHeli->GetPosition() + CVector(CTimer::GetTimeStep() * pHeli->m_vecMoveSpeed.x, CTimer::GetTimeStep() * pHeli->m_vecMoveSpeed.y, 0.0f));
|
||||||
|
assert(0);
|
||||||
|
// This is not finished yet. Heli fields in CAutomobile required
|
||||||
|
}
|
||||||
|
|
||||||
void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerve, float* pAccel, float* pBrake, bool* pHandbrake)
|
void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerve, float* pAccel, float* pBrake, bool* pHandbrake)
|
||||||
{
|
{
|
||||||
CVector2D forward = pVehicle->GetForward();
|
CVector2D forward = pVehicle->GetForward();
|
||||||
@ -2620,18 +2668,12 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
|
|||||||
if (PickNextNodeAccordingStrategy(pVehicle)) {
|
if (PickNextNodeAccordingStrategy(pVehicle)) {
|
||||||
switch (pVehicle->AutoPilot.m_nCarMission){
|
switch (pVehicle->AutoPilot.m_nCarMission){
|
||||||
case MISSION_GOTOCOORDS:
|
case MISSION_GOTOCOORDS:
|
||||||
pVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT;
|
SteerAICarWithPhysicsHeadingForTarget(pVehicle, nil, pVehicle->AutoPilot.m_vecDestinationCoors.x,
|
||||||
*pSwerve = 0.0f;
|
pVehicle->AutoPilot.m_vecDestinationCoors.y, pSwerve, pAccel, pBrake, pHandbrake);
|
||||||
*pAccel = 0.0f;
|
|
||||||
*pBrake = 0.0f;
|
|
||||||
*pHandbrake = false;
|
|
||||||
return;
|
return;
|
||||||
case MISSION_GOTOCOORDS_ACCURATE:
|
case MISSION_GOTOCOORDS_ACCURATE:
|
||||||
pVehicle->AutoPilot.m_nCarMission = MISSION_GOTO_COORDS_STRAIGHT_ACCURATE;
|
SteerAICarWithPhysicsHeadingForTarget(pVehicle, nil, pVehicle->AutoPilot.m_vecDestinationCoors.x,
|
||||||
*pSwerve = 0.0f;
|
pVehicle->AutoPilot.m_vecDestinationCoors.y, pSwerve, pAccel, pBrake, pHandbrake);
|
||||||
*pAccel = 0.0f;
|
|
||||||
*pBrake = 0.0f;
|
|
||||||
*pHandbrake = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2667,6 +2709,7 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
|
|||||||
switch (pVehicle->AutoPilot.m_nDrivingStyle) {
|
switch (pVehicle->AutoPilot.m_nDrivingStyle) {
|
||||||
case DRIVINGSTYLE_STOP_FOR_CARS:
|
case DRIVINGSTYLE_STOP_FOR_CARS:
|
||||||
case DRIVINGSTYLE_SLOW_DOWN_FOR_CARS:
|
case DRIVINGSTYLE_SLOW_DOWN_FOR_CARS:
|
||||||
|
case DRIVINGSTYLE_STOP_FOR_CARS_IGNORE_LIGHTS:
|
||||||
speedStyleMultiplier = FindMaximumSpeedForThisCarInTraffic(pVehicle) / pVehicle->AutoPilot.m_nCruiseSpeed;
|
speedStyleMultiplier = FindMaximumSpeedForThisCarInTraffic(pVehicle) / pVehicle->AutoPilot.m_nCruiseSpeed;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2933,8 +2976,6 @@ bool CCarCtrl::JoinCarWithRoadSystemGotoCoors(CVehicle* pVehicle, CVector vecTar
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
|
void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
|
||||||
{
|
{
|
||||||
if (pVehicle->m_nRouteSeed)
|
if (pVehicle->m_nRouteSeed)
|
||||||
@ -2952,12 +2993,22 @@ void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle)
|
|||||||
curLink = 0;
|
curLink = 0;
|
||||||
curConnection = ThePaths.m_carPathConnections[pCurNode->firstLink];
|
curConnection = ThePaths.m_carPathConnections[pCurNode->firstLink];
|
||||||
}else{
|
}else{
|
||||||
curConnection = pVehicle->AutoPilot.m_nNextPathNodeInfo;
|
int closestLink = -1;
|
||||||
while (curConnection == pVehicle->AutoPilot.m_nNextPathNodeInfo){
|
float md = 999999.9f;
|
||||||
curLink = CGeneral::GetRandomNumber() % pCurNode->numLinks;
|
|
||||||
curConnection = ThePaths.m_carPathConnections[curLink + pCurNode->firstLink];
|
for (curLink = 0; curLink < pCurNode->numLinks; curLink++) {
|
||||||
|
int node = ThePaths.ConnectedNode(curLink + pCurNode->firstLink);
|
||||||
|
CPathNode* pNode = &ThePaths.m_pathNodes[node];
|
||||||
|
if (node == pVehicle->AutoPilot.m_nNextRouteNode)
|
||||||
|
continue;
|
||||||
|
float dist = CCollision::DistToLine(&pCurNode->GetPosition(), &pNode->GetPosition(), &pVehicle->GetPosition());
|
||||||
|
if (dist < md) {
|
||||||
|
md = dist;
|
||||||
|
closestLink = curLink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
curConnection = ThePaths.m_carPathConnections[closestLink + pCurNode->firstLink];
|
||||||
|
}
|
||||||
pVehicle->AutoPilot.m_nCurrentPathNodeInfo = curConnection;
|
pVehicle->AutoPilot.m_nCurrentPathNodeInfo = curConnection;
|
||||||
pVehicle->AutoPilot.m_nCurrentDirection = (ThePaths.ConnectedNode(curLink + pCurNode->firstLink) >= pVehicle->AutoPilot.m_nCurrentRouteNode) ? 1 : -1;
|
pVehicle->AutoPilot.m_nCurrentDirection = (ThePaths.ConnectedNode(curLink + pCurNode->firstLink) >= pVehicle->AutoPilot.m_nCurrentRouteNode) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
@ -205,12 +205,19 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X
|
|||||||
}
|
}
|
||||||
CGarage* pGarage = &aGarages[NumGarages];
|
CGarage* pGarage = &aGarages[NumGarages];
|
||||||
// TODO(MIAMI): proper!
|
// TODO(MIAMI): proper!
|
||||||
pGarage->m_fX1 = Min(Min(X1, X2), X3);
|
pGarage->m_fInfX = Min(Min(X1, X2), X3, X2 + X3 - X1);
|
||||||
pGarage->m_fX2 = Max(Max(X1, X2), X3);
|
pGarage->m_fSupX = Max(Max(X1, X2), X3);
|
||||||
pGarage->m_fY1 = Min(Min(Y1, Y2), Y3);
|
pGarage->m_fInfY = Min(Min(Y1, Y2), Y3, Y2 + Y3 - Y1);
|
||||||
pGarage->m_fY2 = Max(Max(Y1, Y2), Y3);
|
pGarage->m_fSupY = Max(Max(Y1, Y2), Y3);
|
||||||
pGarage->m_fZ1 = Min(Z1, Z2);
|
pGarage->m_vecCorner1 = CVector(X1, Y1, Z1);
|
||||||
pGarage->m_fZ2 = Max(Z1, Z2);
|
pGarage->m_vDir1 = CVector2D(X2 - X1, Y2 - Y1);
|
||||||
|
pGarage->m_vDir1 = CVector2D(X3 - X1, Y3 - Y1);
|
||||||
|
pGarage->m_fSupZ = Z2;
|
||||||
|
pGarage->m_nMaxStoredCars = 4;
|
||||||
|
pGarage->m_fDir1Len = pGarage->m_vDir1.Magnitude();
|
||||||
|
pGarage->m_fDir2Len = pGarage->m_vDir1.Magnitude();
|
||||||
|
pGarage->m_vDir1 /= pGarage->m_fDir1Len;
|
||||||
|
pGarage->m_vDir2 /= pGarage->m_fDir2Len;
|
||||||
pGarage->m_pDoor1 = nil;
|
pGarage->m_pDoor1 = nil;
|
||||||
pGarage->m_pDoor2 = nil;
|
pGarage->m_pDoor2 = nil;
|
||||||
pGarage->m_fDoor1Z = Z1;
|
pGarage->m_fDoor1Z = Z1;
|
||||||
@ -257,6 +264,17 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X
|
|||||||
case GARAGE_FOR_SCRIPT_TO_OPEN_AND_CLOSE:
|
case GARAGE_FOR_SCRIPT_TO_OPEN_AND_CLOSE:
|
||||||
case GARAGE_KEEPS_OPENING_FOR_SPECIFIC_CAR:
|
case GARAGE_KEEPS_OPENING_FOR_SPECIFIC_CAR:
|
||||||
case GARAGE_MISSION_KEEPCAR_REMAINCLOSED:
|
case GARAGE_MISSION_KEEPCAR_REMAINCLOSED:
|
||||||
|
case GARAGE_COLLECTCARS_4:
|
||||||
|
case GARAGE_FOR_SCRIPT_TO_OPEN_FOR_CAR:
|
||||||
|
case GARAGE_HIDEOUT_FOUR:
|
||||||
|
case GARAGE_HIDEOUT_FIVE:
|
||||||
|
case GARAGE_HIDEOUT_SIX:
|
||||||
|
case GARAGE_HIDEOUT_SEVEN:
|
||||||
|
case GARAGE_HIDEOUT_EIGHT:
|
||||||
|
case GARAGE_HIDEOUT_NINE:
|
||||||
|
case GARAGE_HIDEOUT_TEN:
|
||||||
|
case GARAGE_HIDEOUT_ELEVEN:
|
||||||
|
case GARAGE_HIDEOUT_TWELVE:
|
||||||
pGarage->m_eGarageState = GS_FULLYCLOSED;
|
pGarage->m_eGarageState = GS_FULLYCLOSED;
|
||||||
pGarage->m_fDoorPos = 0.0f;
|
pGarage->m_fDoorPos = 0.0f;
|
||||||
break;
|
break;
|
||||||
|
@ -94,6 +94,7 @@ class CGarage
|
|||||||
{
|
{
|
||||||
eGarageType m_eGarageType;
|
eGarageType m_eGarageType;
|
||||||
eGarageState m_eGarageState;
|
eGarageState m_eGarageState;
|
||||||
|
uint8 m_nMaxStoredCars;
|
||||||
bool field_2; // unused
|
bool field_2; // unused
|
||||||
bool m_bClosingWithoutTargetCar;
|
bool m_bClosingWithoutTargetCar;
|
||||||
bool m_bDeactivated;
|
bool m_bDeactivated;
|
||||||
@ -108,12 +109,16 @@ class CGarage
|
|||||||
bool m_bRecreateDoorOnNextRefresh;
|
bool m_bRecreateDoorOnNextRefresh;
|
||||||
bool m_bRotatedDoor;
|
bool m_bRotatedDoor;
|
||||||
bool m_bCameraFollowsPlayer;
|
bool m_bCameraFollowsPlayer;
|
||||||
float m_fX1;
|
CVector m_vecCorner1;
|
||||||
float m_fX2;
|
CVector2D m_vDir1;
|
||||||
float m_fY1;
|
CVector2D m_vDir2;
|
||||||
float m_fY2;
|
float m_fSupZ;
|
||||||
float m_fZ1;
|
float m_fDir1Len;
|
||||||
float m_fZ2;
|
float m_fDir2Len;
|
||||||
|
float m_fInfX;
|
||||||
|
float m_fSupX;
|
||||||
|
float m_fInfY;
|
||||||
|
float m_fSupY;
|
||||||
float m_fDoorPos;
|
float m_fDoorPos;
|
||||||
float m_fDoorHeight;
|
float m_fDoorHeight;
|
||||||
float m_fDoor1X;
|
float m_fDoor1X;
|
||||||
@ -183,8 +188,6 @@ class CGarage
|
|||||||
friend class CCamera;
|
friend class CCamera;
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(CGarage) == 140, "CGarage");
|
|
||||||
|
|
||||||
class CGarages
|
class CGarages
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
|
Loading…
Reference in New Issue
Block a user