Working on climbable pushables

This commit is contained in:
MontyTRC89 2020-09-07 20:01:28 +02:00
parent 9a5f27b248
commit bc79021dcf
4 changed files with 140 additions and 266 deletions

View file

@ -72,8 +72,8 @@ void InitialisePushableBlock(short itemNum)
ClearMovableBlockSplitters(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber);
//if (item->status != ITEM_INVISIBLE)
// AlterFloorHeight(item, -1024);
if (item->triggerFlags > 64 && item->status != ITEM_INVISIBLE)
AlterFloorHeight(item, -(item->triggerFlags - 64) * 256);
}
void PushableBlockControl(short itemNumber)
@ -97,11 +97,11 @@ void PushableBlockControl(short itemNumber)
{
case LA_PUSHABLE_PUSH:
if ((LaraItem->frameNumber < g_Level.Anims[LaraItem->animNumber].frameBase + 30
|| LaraItem->frameNumber > g_Level.Anims[LaraItem->animNumber].frameBase + 67)
&& (LaraItem->frameNumber < g_Level.Anims[LaraItem->animNumber].frameBase + 78
|| LaraItem->frameNumber > g_Level.Anims[LaraItem->animNumber].frameBase + 125)
&& (LaraItem->frameNumber < g_Level.Anims[LaraItem->animNumber].frameBase + 140
|| LaraItem->frameNumber > g_Level.Anims[LaraItem->animNumber].frameBase + 160))
|| LaraItem->frameNumber > g_Level.Anims[LaraItem->animNumber].frameBase + 67)
&& (LaraItem->frameNumber < g_Level.Anims[LaraItem->animNumber].frameBase + 78
|| LaraItem->frameNumber > g_Level.Anims[LaraItem->animNumber].frameBase + 125)
&& (LaraItem->frameNumber < g_Level.Anims[LaraItem->animNumber].frameBase + 140
|| LaraItem->frameNumber > g_Level.Anims[LaraItem->animNumber].frameBase + 160))
{
if (DoPushPull)
{
@ -121,7 +121,7 @@ void PushableBlockControl(short itemNumber)
{
case 0:
z = pos.z + item->itemFlags[2] - LaraItem->itemFlags[2];
if (abs(item->pos.zPos-z) < 512 && item->pos.zPos < z)
if (abs(item->pos.zPos - z) < 512 && item->pos.zPos < z)
item->pos.zPos = z;
break;
@ -151,7 +151,7 @@ void PushableBlockControl(short itemNumber)
{
if (TrInput & IN_ACTION)
{
if (!TestBlockPush(item,1024,quadrant))
if (!TestBlockPush(item, 1024, quadrant))
LaraItem->goalAnimState = LS_STOP;
}
else
@ -180,28 +180,28 @@ void PushableBlockControl(short itemNumber)
}
GetLaraJointPosition(&pos, LM_LHAND);
switch (quadrant)
{
case 0:
case NORTH:
z = pos.z + item->itemFlags[2] - LaraItem->itemFlags[2];
if (abs(item->pos.zPos - z) < 512 && item->pos.zPos > z)
item->pos.zPos = z;
break;
case 1:
case EAST:
x = pos.x + item->itemFlags[0] - LaraItem->itemFlags[0];
if (abs(item->pos.xPos - x) < 512 && item->pos.xPos > x)
item->pos.xPos = x;
break;
case 2:
case SOUTH:
z = pos.z + item->itemFlags[2] - LaraItem->itemFlags[2];
if (abs(item->pos.zPos - z) < 512 && item->pos.zPos < z)
item->pos.zPos = z;
break;
case 3:
case WEST:
x = pos.x + item->itemFlags[0] - LaraItem->itemFlags[0];
if (abs(item->pos.xPos - x) < 512 && item->pos.xPos < x)
item->pos.xPos = x;
@ -235,6 +235,12 @@ void PushableBlockControl(short itemNumber)
if (LaraItem->frameNumber == g_Level.Anims[LaraItem->animNumber].frameEnd)
{
if (item->triggerFlags > 64)
{
AlterFloorHeight(item, -(item->triggerFlags - 64) * 256);
AdjustStopperFlag(item, item->itemFlags[7] + 0x8000, 0);
}
roomNumber = item->roomNumber;
floor = GetFloor(item->pos.xPos, item->pos.yPos - 256, item->pos.zPos, &roomNumber);
GetFloorHeight(floor, item->pos.xPos, item->pos.yPos - 256, item->pos.zPos);
@ -242,63 +248,40 @@ void PushableBlockControl(short itemNumber)
RemoveActiveItem(itemNumber);
item->status = ITEM_NOT_ACTIVE;
}
/*if (item->status == ITEM_DEACTIVATED)
{
item->status = ITEM_NOT_ACTIVE;
RemoveActiveItem(itemNumber);
if (item->triggerFlags > 64)
{
AlterFloorHeight(item, -1024);
AdjustStopperFlag(item, item->itemFlags[7] + 0x8000, 0);
}
roomNumber = item->roomNumber;
floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
TestTriggers(TriggerIndex, 1, 0);
}*/
break;
}
return;
// TR3 code below, to add in the future
if (item->flags & ONESHOT)
{
AlterFloorHeight(item, 1024);
KillItem(itemNumber);
return;
}
AnimateItem(item);
roomNumber = item->roomNumber;
floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
height = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
if (item->pos.yPos < height)
item->gravityStatus = true;
else if (item->gravityStatus)
{
item->gravityStatus = false;
item->pos.yPos = height;
item->status = ITEM_DEACTIVATED;
floor_shake_effect(item);
SoundEffect(SFX_LARA_THUD, &item->pos, 0);
}
if (item->roomNumber != roomNumber)
ItemNewRoom(itemNumber, roomNumber);
if (item->status == ITEM_DEACTIVATED)
{
item->status = ITEM_NOT_ACTIVE;
RemoveActiveItem(itemNumber);
AlterFloorHeight(item, -1024);
AdjustStopperFlag(item, item->itemFlags[0] + 0x8000, 0);
roomNumber = item->roomNumber;
floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
TestTriggers(TriggerIndex, 1, 0);
}
}
void PushableBlockCollision(short itemNum, ITEM_INFO * l, COLL_INFO * coll)
void PushableBlockCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
{
ITEM_INFO* item = &g_Level.Items[itemNum];
short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos - 256, item->pos.zPos, &roomNumber);
item->pos.yPos = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos - 256, item->pos.zPos);
if (item->roomNumber != roomNumber)
ItemNewRoom(itemNum, roomNumber);
if (item->triggerFlags < 64)
{
item->pos.yPos = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos - 256, item->pos.zPos);
if (item->roomNumber != roomNumber)
ItemNewRoom(itemNum, roomNumber);
}
if ((!(TrInput & IN_ACTION)
|| l->currentAnimState != LS_STOP
@ -309,9 +292,10 @@ void PushableBlockCollision(short itemNum, ITEM_INFO * l, COLL_INFO * coll)
|| item->triggerFlags < 0)
&& (!Lara.isMoving || Lara.generalPtr != item))
{
if (l->currentAnimState != LS_PUSHABLE_GRAB
if (item->triggerFlags < 64 &&
(l->currentAnimState != LS_PUSHABLE_GRAB
|| (l->frameNumber != g_Level.Anims[LA_PUSHABLE_GRAB].frameBase + 19)
|| Lara.cornerX != (int)item)
|| Lara.cornerX != (int)item))
{
ObjectCollision(itemNum, l, coll);
return;
@ -342,7 +326,7 @@ void PushableBlockCollision(short itemNum, ITEM_INFO * l, COLL_INFO * coll)
Lara.headXrot = 0;
Lara.torsoYrot = 0;
Lara.torsoXrot = 0;
PHD_VECTOR pos;
pos.x = 0;
pos.y = 0;
@ -355,6 +339,15 @@ void PushableBlockCollision(short itemNum, ITEM_INFO * l, COLL_INFO * coll)
item->itemFlags[0] = item->pos.xPos;
item->itemFlags[2] = item->pos.zPos;
if (item->triggerFlags > 64
&& (TrInput & IN_ACTION)
&& ((l->animNumber == LA_PUSHABLE_PULL || l->animNumber == LA_PUSHABLE_PUSH)
&& l->frameNumber == g_Level.Anims[l->animNumber].frameBase))
{
AlterFloorHeight(item, 1024);
AdjustStopperFlag(item, item->itemFlags[7], 1);
}
}
else
{
@ -362,155 +355,88 @@ void PushableBlockCollision(short itemNum, ITEM_INFO * l, COLL_INFO * coll)
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos - 256, item->pos.zPos, &roomNumber);
if (roomNumber == item->roomNumber)
{
BOUNDING_BOX* bounds = GetBoundsAccurate(item);
//if (item->triggerFlags < 64)
//{
BOUNDING_BOX* bounds = GetBoundsAccurate(item);
PushableBlockBounds.boundingBox.X1 = (bounds->X1 / 2) - 100;
PushableBlockBounds.boundingBox.X2 = (bounds->X2 / 2) + 100;
PushableBlockBounds.boundingBox.Z1 = bounds->Z1 - 200;
PushableBlockBounds.boundingBox.Z2 = 0;
short rot = item->pos.yRot;
item->pos.yRot = (l->pos.yRot + ANGLE(45)) & 0xC000;
if (TestLaraPosition(&PushableBlockBounds, item, l))
{
if (((item->pos.yRot / 0x4000) + ((rot + 0x2000) / 0x4000)) & 1)
PushableBlockPos.z = bounds->X1 - 35;
else
PushableBlockPos.z = bounds->Z1 - 35;
PushableBlockBounds.boundingBox.X1 = (bounds->X1 / 2) - 100;
PushableBlockBounds.boundingBox.X2 = (bounds->X2 / 2) + 100;
PushableBlockBounds.boundingBox.Z1 = bounds->Z1 - 200;
PushableBlockBounds.boundingBox.Z2 = 0;
if (MoveLaraPosition(&PushableBlockPos, item, l))
short rot = item->pos.yRot;
item->pos.yRot = (l->pos.yRot + ANGLE(45)) & 0xC000;
if (TestLaraPosition(&PushableBlockBounds, item, l))
{
l->animNumber = LA_PUSHABLE_GRAB;
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
l->currentAnimState = LS_PUSHABLE_GRAB;
l->goalAnimState = LS_PUSHABLE_GRAB;
Lara.isMoving = false;
Lara.gunStatus = LG_HANDS_BUSY;
Lara.cornerX = (int)item;
item->pos.yRot = rot;
if (((item->pos.yRot / 0x4000) + ((rot + 0x2000) / 0x4000)) & 1)
PushableBlockPos.z = bounds->X1 - 35;
else
PushableBlockPos.z = bounds->Z1 - 35;
if (MoveLaraPosition(&PushableBlockPos, item, l))
{
l->animNumber = LA_PUSHABLE_GRAB;
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
l->currentAnimState = LS_PUSHABLE_GRAB;
l->goalAnimState = LS_PUSHABLE_GRAB;
Lara.isMoving = false;
Lara.gunStatus = LG_HANDS_BUSY;
Lara.cornerX = (int)item;
item->pos.yRot = rot;
}
else
{
Lara.generalPtr = item;
item->pos.yRot = rot;
}
}
else
{
Lara.generalPtr = item;
if (Lara.isMoving && Lara.generalPtr == item)
{
Lara.isMoving = false;
Lara.gunStatus = LG_NO_ARMS;
}
item->pos.yRot = rot;
}
}
/*}
else
{
if (Lara.isMoving && Lara.generalPtr == item)
short rot = item->pos.yRot;
item->pos.yRot = (l->pos.yRot + ANGLE(45)) & 0xC000;
if (TestLaraPosition(&MovingBlockBounds, item, l))
{
Lara.isMoving = false;
Lara.gunStatus = LG_NO_ARMS;
if (MoveLaraPosition(&PushableBlockPos, item, l))
{
l->animNumber = LA_PUSHABLE_GRAB;
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
l->currentAnimState = LS_PUSHABLE_GRAB;
l->goalAnimState = LS_PUSHABLE_GRAB;
Lara.isMoving = false;
Lara.gunStatus = LG_HANDS_BUSY;
Lara.cornerX = (int)item;
item->pos.yRot = rot;
}
else
{
Lara.generalPtr = item;
item->pos.yRot = rot;
}
}
item->pos.yRot = rot;
}
else
{
if (Lara.isMoving && Lara.generalPtr == item)
{
Lara.isMoving = false;
Lara.gunStatus = LG_NO_ARMS;
}
item->pos.yRot = rot;
}
}*/
}
}
return;
// TR3 code to add in the future
if (!(TrInput & IN_ACTION) ||
item->status == ITEM_ACTIVE ||
l->gravityStatus ||
l->pos.yPos != item->pos.yPos)
return;
short quadrant = GetQuadrant(l->pos.yRot);
if (l->currentAnimState == LS_STOP)
{
if (Lara.gunStatus != LG_NO_ARMS)
return;
switch (quadrant)
{
case NORTH:
item->pos.yRot = 0;
break;
case EAST:
item->pos.yRot = ANGLE(90);
break;
case SOUTH:
item->pos.yRot = -ANGLE(180);
break;
case WEST:
item->pos.yRot = -ANGLE(90);
break;
}
if (!TestLaraPosition(&MovingBlockBounds, item, l))
return;
short roomNumber = l->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
if (roomNumber != item->roomNumber)
return;
switch (quadrant)
{
case NORTH:
l->pos.zPos &= -1024;
l->pos.zPos += 1024 - LARA_RAD;
break;
case SOUTH:
l->pos.zPos &= -1024;
l->pos.zPos += LARA_RAD;
break;
case EAST:
l->pos.xPos &= -1024;
l->pos.xPos += 1024 - LARA_RAD;
break;
case WEST:
l->pos.xPos &= -1024;
l->pos.xPos += LARA_RAD;
break;
}
l->pos.yRot = item->pos.yRot;
l->goalAnimState = LS_PUSHABLE_GRAB;
AnimateLara(l);
if (l->currentAnimState == LS_PUSHABLE_GRAB)
Lara.gunStatus = LG_HANDS_BUSY;
}
else if (l->currentAnimState == LS_PUSHABLE_GRAB)
{
if (l->frameNumber != g_Level.Anims[LA_PUSHABLE_GRAB].frameBase + 19)
return;
if (!TestLaraPosition(&MovingBlockBounds, item, l))
return;
if (TrInput & IN_FORWARD)
{
if (!TestBlockPush(item, 1024, quadrant))
return;
item->goalAnimState = 2;
l->goalAnimState = LS_PUSHABLE_PUSH;
}
else if (TrInput & IN_BACK)
{
if (!TestBlockPull(item, 1024, quadrant))
return;
item->goalAnimState = 3;
l->goalAnimState = LS_PUSHABLE_PULL;
}
else
return;
AddActiveItem(itemNum);
AlterFloorHeight(item, 1024);
AdjustStopperFlag(item, item->itemFlags[0], 1);
item->status = ITEM_ACTIVE;
AnimateItem(item);
AnimateLara(l);
Lara.headXrot = Lara.headYrot = 0;
Lara.torsoXrot = Lara.torsoYrot = 0;
}
}
int TestBlockMovable(ITEM_INFO * item, int blokhite)
@ -580,29 +506,9 @@ int TestBlockPush(ITEM_INFO * item, int blockhite, unsigned short quadrant)
item->pos.xPos = oldX;
item->pos.zPos = oldZ;
item->itemFlags[7] = LaraItem->pos.yRot;
return CollidedItems[0] == NULL;
// TR3 code
/*COLL_INFO scoll;
scoll.quadrant = quadrant;
scoll.radius = 500;
if (CollideStaticObjects(&scoll, x, y, z, roomNum, 1000))
return 0;
if (((int)floor->floor << 8) != y)
return 0;
GetFloorHeight(floor, x, y, z);
if (HeightType != WALL)
return 0;
int cmax = y - (blokhite - 100);
floor = GetFloor(x, cmax, z, &roomNum);
if (GetCeiling(floor, x, cmax, z) > cmax)
return 0;
item->itemFlags[0] = LaraItem->pos.yRot;
return 1;*/
}
int TestBlockPull(ITEM_INFO * item, int blockhite, short quadrant)
@ -689,47 +595,5 @@ int TestBlockPull(ITEM_INFO * item, int blockhite, short quadrant)
LaraItem->pos.zPos = oldZ;
return (CollidedItems[0] == NULL);
/*
COLL_INFO scoll;
scoll.quadrant = quadrant;
scoll.radius = 500;
if (CollideStaticObjects(&scoll, x, y, z, roomNum, 1000))
return 0;
if (((int)floor->floor << 8) != y)
return 0;
int cmax = y - blokhite;
floor = GetFloor(x, cmax, z, &roomNum);
if (((int)floor->ceiling << 8) > cmax)
return 0;
x += xadd;
z += zadd;
roomNum = item->roomNumber;
floor = GetFloor(x, y, z, &roomNum);
if (((int)floor->floor << 8) != y)
return 0;
cmax = y - LARA_HITE;
floor = GetFloor(x, cmax, z, &roomNum);
if (((int)floor->ceiling << 8) > cmax)
return 0;
x = LaraItem->pos.xPos + xadd;
y = LaraItem->pos.yPos;
z = LaraItem->pos.zPos + zadd;
roomNum = LaraItem->roomNumber;
floor = GetFloor(x, y, z, &roomNum);
scoll.quadrant = (quadrant + 2) & 3;
scoll.radius = LARA_RAD;
if (CollideStaticObjects(&scoll, x, y, z, roomNum, LARA_HITE))
return 0;
item->itemFlags[0] = LaraItem->pos.yRot + ANGLE(180);
return 1;*/
}

View file

@ -356,6 +356,16 @@ typedef enum GAME_OBJECT_ID
ID_STATUE_PLINTH, // NEW
ID_CLASSIC_ROLLING_BALL,
ID_BIG_ROLLING_BALL,
ID_PUSHABLE_OBJECT_CLIMBABLE1,
ID_PUSHABLE_OBJECT_CLIMBABLE2,
ID_PUSHABLE_OBJECT_CLIMBABLE3,
ID_PUSHABLE_OBJECT_CLIMBABLE4,
ID_PUSHABLE_OBJECT_CLIMBABLE5,
ID_PUSHABLE_OBJECT_CLIMBABLE6,
ID_PUSHABLE_OBJECT_CLIMBABLE7,
ID_PUSHABLE_OBJECT_CLIMBABLE8,
ID_PUSHABLE_OBJECT_CLIMBABLE9,
ID_PUSHABLE_OBJECT_CLIMBABLE10,
/* Items */
ID_PUZZLE_ITEM1 = 500,

View file

@ -344,7 +344,7 @@ void T5M::Renderer::Renderer11::initialiseScreen(int w, int h, int refreshRate,
void T5M::Renderer::Renderer11::Create()
{
D3D_FEATURE_LEVEL levels[] = {D3D_FEATURE_LEVEL_11_0,D3D_FEATURE_LEVEL_11_1};
D3D_FEATURE_LEVEL levels[] = { D3D_FEATURE_LEVEL_10_1 }; // {D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_11_1};
D3D_FEATURE_LEVEL featureLevel;
HRESULT res;

View file

@ -1671,7 +1671,7 @@
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Objects\TR4\Entity\tr4_von_croy.cpp">
<Filter>File di origine</Filter>
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Objects\TR3\Vehicles\biggun.cpp">
<Filter>File di origine</Filter>