- disable CarBuildingCollision smashable correction (fixes the mission 23 cutscene)

This commit is contained in:
Ilya Shurumov 2022-04-02 23:48:54 +06:00
parent 554974da50
commit 4f2be527c7

View File

@ -547,29 +547,19 @@ void DamageCar(CAR_DATA *cp, CDATA2D *cd, CRET2D *collisionResult, int strikeVel
// [D] [T]
int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop, int flags)
{
int temp;
int strikeVel;
int boxDiffY;
int boxDiffY, buildingHeightY;
int collided;
short scale;
int chan;
int player_id;
SMASHABLE_OBJECT* match;
SMASHABLE_OBJECT* sip;
CAR_COSMETICS* car_cos;
MODEL *model;
VECTOR tempwhere;
VECTOR tempwhere, velocity;
SVECTOR boxDisp;
VECTOR velocity;
LONGVECTOR4 pointVel;
LONGVECTOR4 reaction;
LONGVECTOR4 lever;
VECTOR LeafPosition;
VECTOR lamp_velocity;
LONGVECTOR4 pointVel, reaction, lever;
int debris_colour;
int displacement;
int denom;
int buildingHeightY;
int displacement, denom;
#if 0 //def PSX
CDATA2D* cd = (CDATA2D*)(u_char*)getScratchAddr(0);
@ -583,6 +573,26 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
#endif
model = modelpointers[cop->type];
boxDiffY = cp->hd.oBox.location.vy + building->pos.vy;
boxDiffY = ABS(boxDiffY);
// [A] Boat Jump: make player's life easier getting out
if (cop->type == 1246 && gCurrentMissionNumber == 35)
buildingHeightY = building->height / 5;
else
buildingHeightY = building->height >> 1;
if (boxDiffY > buildingHeightY + (cp->hd.oBox.length[1] >> 1) ||
(cop->pos.vx == OBJECT_SMASHED_MARK) ||
(model->shape_flags & SHAPE_FLAG_NOCOLLIDE))
{
return 0;
}
collided = 0;
car_cos = cp->ap.carCos;
player_id = GetPlayerId(cp);
cd[0].isCameraOrTanner = (cp->controlType == CONTROL_TYPE_TANNERCOLLIDER || cp->controlType == CONTROL_TYPE_CAMERACOLLIDER);
@ -592,28 +602,6 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
cd[1].isCameraOrTanner = (flags & CollisionCheckFlag_MightBeABarrier) == 0;
boxDiffY = cp->hd.oBox.location.vy + building->pos.vy;
boxDiffY = ABS(boxDiffY);
collided = 0;
car_cos = cp->ap.carCos;
// [A] Boat Jump: make player's life easier getting out
if (cop->type == 1246 && gCurrentMissionNumber == 35)
buildingHeightY = building->height / 5;
else
buildingHeightY = building->height >> 1;
if (boxDiffY <= buildingHeightY + (cp->hd.oBox.length[1] >> 1) && (cop->pos.vx != OBJECT_SMASHED_MARK) && (model->shape_flags & SHAPE_FLAG_NOCOLLIDE) == 0)
{
tempwhere.vx = cp->hd.where.t[0];
tempwhere.vz = cp->hd.where.t[2];
debris_colour = GetDebrisColour(cp);
cd[0].theta = cp->hd.direction;
if (cp->controlType == CONTROL_TYPE_TANNERCOLLIDER)
{
cd[0].x.vx = cp->hd.where.t[0];
@ -623,9 +611,6 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
cd[0].vel.vx = FIXEDH(cp->st.n.linearVelocity[0]);
cd[0].vel.vz = FIXEDH(cp->st.n.linearVelocity[2]);
cp->hd.where.t[0] += cd[0].vel.vx;
cp->hd.where.t[2] += cd[0].vel.vz;
cd[0].length[0] = 90;
cd[0].length[1] = 90;
}
@ -650,17 +635,12 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
boxDisp.vz = -car_cos->cog.vz;
gte_ldv0(&boxDisp);
gte_rtv0tr();
gte_stlvnl(&cd[0].x);
cd[0].vel.vx = FIXEDH(cp->st.n.linearVelocity[0]);
cd[0].vel.vz = FIXEDH(cp->st.n.linearVelocity[2]);
cp->hd.where.t[0] += cd[0].vel.vx;
cp->hd.where.t[2] += cd[0].vel.vz;
cd[0].length[0] = car_cos->colBox.vz + 15;
cd[0].length[1] = car_cos->colBox.vx + 15;
@ -668,10 +648,17 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
cd[0].length[1] = (cd[0].length[1] * 13) / 16;
}
cd[0].theta = cp->hd.direction;
cd[0].avel = FIXEDH(cp->st.n.angularVelocity[1]) * 5 >> 5;
cd[1].x.vx = cp->hd.where.t[0] + (((building->pos.vx - cp->hd.where.t[0]) << 0x10) >> 0x10);
cd[1].x.vz = cp->hd.where.t[2] + (((building->pos.vz - cp->hd.where.t[2]) << 0x10) >> 0x10);
tempwhere.vx = cp->hd.where.t[0];
tempwhere.vz = cp->hd.where.t[2];
cp->hd.where.t[0] += cd[0].vel.vx;
cp->hd.where.t[2] += cd[0].vel.vz;
cd[1].x.vx = cp->hd.where.t[0] + (short)(building->pos.vx - cp->hd.where.t[0]);
cd[1].x.vz = cp->hd.where.t[2] + (short)(building->pos.vz - cp->hd.where.t[2]);
cd[1].theta = building->theta;
cd[1].length[0] = building->xsize;
@ -810,8 +797,11 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
collisionResult.hit.vy = cp->hd.where.t[1] + 41;
// perform error correction
if ((model->flags2 & MODEL_FLAG_SMASHABLE) == 0)
{
cp->hd.where.t[0] += FIXEDH(collisionResult.penetration * collisionResult.surfNormal.vx);
cp->hd.where.t[2] += FIXEDH(collisionResult.penetration * collisionResult.surfNormal.vz);
}
lever[0] = collisionResult.hit.vx - cp->hd.where.t[0];
lever[1] = collisionResult.hit.vy - cp->hd.where.t[1];
@ -834,6 +824,8 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
{
if (cp->controlType == CONTROL_TYPE_PLAYER)
{
short scale;
if (strikeVel < 32)
scale = ((strikeVel << 23) >> 16);
else
@ -851,6 +843,8 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
velocity.vy = -17;
velocity.vz = cp->st.n.linearVelocity[2] / ONE;
debris_colour = GetDebrisColour(cp);
if (model->flags2 & MODEL_FLAG_SMASHABLE)
{
// smash object
@ -859,6 +853,8 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
// smash object
if ((model->shape_flags & SHAPE_FLAG_TRANS) == 0)
{
int chan;
sip = smashable;
match = sip;
@ -902,6 +898,7 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
{
if (model->flags2 & MODEL_FLAG_TREE)
{
VECTOR LeafPosition;
LeafPosition.vx = collisionResult.hit.vx;
LeafPosition.vy = -((rand() & 0xfe) + 600) - collisionResult.hit.vy;
LeafPosition.vz = collisionResult.hit.vz;
@ -914,10 +911,13 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
{
if (damage_lamp(cop))
{
ClearMem((char*)&lamp_velocity, sizeof(lamp_velocity));
VECTOR lamp_velocity;
lamp_velocity.vx = 0;
lamp_velocity.vy = 16;
lamp_velocity.vz = 0;
collisionResult.hit.vy -= 730;
Setup_Sparks(&collisionResult.hit, &lamp_velocity, 0x14, 0);
Setup_Sparks(&collisionResult.hit, &lamp_velocity, 20, 0);
collisionResult.hit.vy += 730;
}
}
@ -961,6 +961,7 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
// angular impulse calculation and modifiers
if (cp->controlType != CONTROL_TYPE_LEAD_AI)
{
int temp;
temp = FIXEDH(lever[1] * reaction[2]);
if (cp->controlType == CONTROL_TYPE_PURSUER_AI)
@ -1000,7 +1001,6 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
cp->hd.where.t[0] -= FIXEDH(cp->st.n.linearVelocity[0]);
cp->hd.where.t[2] -= FIXEDH(cp->st.n.linearVelocity[2]);
}
}
return collided;
}