Reverted flyby changes; Fixed TR5 pushables; Decompiling dog;

This commit is contained in:
Montagna Marco 2019-12-27 08:25:27 +01:00
parent 38dc36e281
commit d70c84eddf
6 changed files with 699 additions and 44 deletions

Binary file not shown.

View file

@ -627,7 +627,7 @@ void InitialiseLara(int restore)
memset(&Lara, 0, sizeof(LARA_INFO));
g_LaraExtra.ExtraAnim = -1;
g_LaraExtra.Vehicle = NO_ITEM;
g_LaraExtra.Weapons[WEAPON_PISTOLS].Present = true;
g_LaraExtra.Weapons[WEAPON_PISTOLS].Present = Objects[ID_PISTOLS_ITEM].loaded;
}
Lara.look = TRUE;

View file

@ -1209,6 +1209,6 @@ void CalculateSpotCameras()
void Inject_Spotcam()
{
INJECT(0x0047A800, InitSpotCamSequences);
//INJECT(0x0047A9D0, InitialiseSpotCam);
INJECT(0x0047A9D0, InitialiseSpotCam);
//INJECT(0x0047B280, CalculateSpotCameras);
}

View file

@ -1,4 +1,7 @@
#include "../newobjects.h"
#include "../../Game/Box.h"
byte dogAnims[] = { 0x14, 0x15, 0x16, 0x14 };
void InitialiseDog(short itemNum)
{
@ -13,4 +16,285 @@ void InitialiseDog(short itemNum)
// TODO: item->flags2 ^= (item->flags2 ^ ((item->flags2 & 0xFE) + 2)) & 6;
}
item->frameNumber = Anims[item->animNumber].frameBase;
}
void DogControl(short itemNumber)
{
if (!CreatureActive(itemNumber))
return;
short angle = 0;
short joint2 = 0;
short joint1 = 0;
short joint0 = 0;
ITEM_INFO* item = &Items[itemNumber];
CREATURE_INFO* creature = (CREATURE_INFO*)item->data;
OBJECT_INFO* obj = &Objects[item->objectNumber];
if (item->hitPoints <= 0)
{
if (item->animNumber == obj->animIndex + 1)
{
item->hitPoints = obj->hitPoints;
}
else if (item->currentAnimState != 11)
{
item->animNumber = obj->animIndex+ dogAnims[GetRandomControl() & 3];
item->currentAnimState = 11;
item->frameNumber = Anims[item->animNumber].frameBase;
}
}
else
{
if (item->aiBits)
GetAITarget(creature);
else
creature->enemy = LaraItem;
AI_INFO info;
CreatureAIInfo(item, &info);
int distance;
if (creature->enemy == LaraItem)
{
distance = info.distance;
}
else
{
int dx = LaraItem->pos.xPos - item->pos.xPos;
int dz = LaraItem->pos.zPos - item->pos.zPos;
ATAN(dz, dx);
distance = SQUARE(dx) + SQUARE(dz);
}
if (info.ahead)
{
joint2 = info.xAngle; // Maybe swapped
joint1 = info.angle;
}
GetCreatureMood(item, &info, VIOLENT);
CreatureMood(item, &info, VIOLENT);
if (!creature->mood)
creature->maximumTurn >>= 1;
angle = CreatureTurn(item, creature->maximumTurn);
joint0 = 4 * angle;
if (creature->hurtByLara || distance < 0x900000 && !(item->aiBits & MODIFY))
{
AlertAllGuards(itemNumber);
item->aiBits &= ~MODIFY;
}
#if OLD_CODE
v14 = GetRandomControl();
v15 = item->frameNumber - anims[item->animNumber].frame_base;
switch (item->currentAnimState)
{
case 0:
case 8:
joint1 = 0;
joint2 = 0;
if (creature->mood && (item->_bf15ea & 0x3E00) != 4096)
{
item->goal_anim_state = 1;
}
else
{
v18 = __OFSUB__(++creature->flags, 300);
v16 = creature->flags == 300;
v17 = (creature->flags - 300) < 0;
creature->maximumTurn = 0;
if (!((v17 ^ v18) | v16) && v14 < 128)
item->goal_anim_state = 1;
}
goto LABEL_100;
case 1:
goto LABEL_30;
case 2:
creature->maximumTurn = 546;
v24 = item->_bf15ea;
if (v24 & 0x800)
{
item->goal_anim_state = 2;
goto LABEL_100;
}
if (!creature->mood && v14 < 256)
goto LABEL_63;
item->goal_anim_state = 5;
goto LABEL_100;
case 3:
creature->maximumTurn = 1092;
v25 = creature->mood;
if (v25 == 2)
{
if (lara.target != item && v33)
item->goal_anim_state = 9;
}
else if (v25)
{
if (v34 && v32 < 0x100000)
{
item->goal_anim_state = 6;
}
else if (v32 < 2359296)
{
item->required_anim_state = 5;
item->goal_anim_state = 9;
}
}
else
{
item->goal_anim_state = 9;
}
goto LABEL_100;
case 5:
creature->maximumTurn = 546;
v26 = creature->mood;
if (v26)
{
if (v26 == 2)
{
item->goal_anim_state = 3;
}
else if (v34 && v32 < 116281)
{
item->goal_anim_state = 12;
item->required_anim_state = 5;
}
else if (v32 > 2359296 || item->_bf15ea & 0x10)
{
item->goal_anim_state = 3;
}
}
else
{
item->goal_anim_state = 9;
}
goto LABEL_100;
case 6:
if (v34 && item->touch_bits & 0x6648 && v15 >= 4 && v15 <= 14)
{
CreatureEffectOld(item, &unk_508518, 2, -1, DoBloodSplat);
LaraItem->hitPoints -= 20;
LaraItem->_bf15ea |= 0x10u;
}
item->goal_anim_state = 3;
goto LABEL_100;
case 7:
joint1 = 0;
joint2 = 0;
goto LABEL_100;
case 9:
v19 = item->required_anim_state;
if (v19)
{
item->goal_anim_state = v19;
goto LABEL_100;
}
LABEL_30:
creature->maximumTurn = 0;
v20 = item->_bf15ea;
if (v20 & 0x200)
{
joint1 = AIGuard(creature);
if (GetRandomControl())
goto LABEL_100;
if (item->currentAnimState == 1)
{
item->goal_anim_state = 9;
goto LABEL_100;
}
}
else
{
v21 = item->currentAnimState;
if (v21 == 9 && v14 < 128)
{
item->goal_anim_state = 1;
goto LABEL_100;
}
if (v20 & 0x800)
{
if (v21 == 1)
item->goal_anim_state = 2;
else
LABEL_63:
item->goal_anim_state = 1;
goto LABEL_100;
}
v22 = creature->mood;
if (v22 == 2)
{
if (lara.target == item || !v33 || v20 & 0x10)
{
item->required_anim_state = 3;
item->goal_anim_state = 9;
}
else
{
item->goal_anim_state = 1;
}
goto LABEL_100;
}
if (v22)
{
item->required_anim_state = 3;
if (v21 == 1)
item->goal_anim_state = 9;
goto LABEL_100;
}
creature->flags = 0;
creature->maximumTurn = 182;
if (v14 < 256)
{
v23 = item->_bf15ea;
if (v23 & 0x1000)
{
if (item->currentAnimState == 1)
{
item->goal_anim_state = 8;
creature->flags = 0;
goto LABEL_100;
}
}
}
if (v14 >= 4096)
{
if (!(v14 & 0x1F))
item->goal_anim_state = 7;
goto LABEL_100;
}
if (item->currentAnimState == 1)
{
item->goal_anim_state = 2;
goto LABEL_100;
}
}
item->goal_anim_state = 1;
goto LABEL_100;
case 12:
if (v34 && item->touch_bits & 0x48 && (v15 >= 9 && v15 <= 12 || v15 >= 22 && v15 <= 25))
{
CreatureEffectOld(item, &unk_508518, 2, -1, DoBloodSplat);
LaraItem->hitPoints -= 10;
LaraItem->_bf15ea |= 0x10u;
}
goto LABEL_100;
default:
goto LABEL_100;
}
#endif
}
CreatureTilt(item, 0);
CreatureJoint(item, 0, joint0);
CreatureJoint(item, 1, joint1);
CreatureJoint(item, 2, joint2);
CreatureAnimation(itemNumber, angle, 0);
}

View file

@ -1,5 +1,7 @@
#include "../newobjects.h"
#include "../oldobjects.h"
#include "../../Game/lara.h"
#include "../../Game/draw.h"
#include "../../Global/global.h"
#include "../../Game/items.h"
#include "../../Game/collide.h"
@ -14,14 +16,24 @@ short MovingBlockBounds[12] = {
-10 * ONE_DEGREE, 10 * ONE_DEGREE
};
short PushableBlockBounds[12] = {
0x0000, 0x0000, 0xFF00, 0x0000,
0x0000, 0x0000, 0xF8E4, 0x071C,
0xEAAC, 0x1554, 0xF8E4, 0x071C
};
PHD_VECTOR PushableBlockPos = { 0, 0, 0 };
int DoPushPull = 0;
void InitialisePushableBlock(short itemNum)
{
ITEM_INFO* item = &Items[itemNum];
ClearMovableBlockSplitters(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber);
if (item->status != ITEM_INVISIBLE)
AlterFloorHeight(item, -1024);
//if (item->status != ITEM_INVISIBLE)
// AlterFloorHeight(item, -1024);
}
void ClearMovableBlockSplitters(int x, int y, int z, short roomNumber)
@ -67,6 +79,174 @@ void PushableBlockControl(short itemNumber)
{
ITEM_INFO* item = &Items[itemNumber];
PHD_VECTOR pos;
pos.x = 0;
pos.y = 0;
pos.z = 0;
unsigned short quadrant = (unsigned short)((LaraItem->pos.yRot + 0x2000) / 0x4000);
int x, z;
FLOOR_INFO* floor;
ROOM_INFO* r;
int height;
short roomNumber;
switch (LaraItem->animNumber)
{
case ANIMATION_LARA_OBJECT_PUSH:
if ((LaraItem->frameNumber < Anims[LaraItem->animNumber].frameBase + 30
|| LaraItem->frameNumber > Anims[LaraItem->animNumber].frameBase + 67)
&& (LaraItem->frameNumber < Anims[LaraItem->animNumber].frameBase + 78
|| LaraItem->frameNumber > Anims[LaraItem->animNumber].frameBase + 125)
&& (LaraItem->frameNumber < Anims[LaraItem->animNumber].frameBase + 140
|| LaraItem->frameNumber > Anims[LaraItem->animNumber].frameBase + 160))
{
if (DoPushPull)
{
SoundEffect(SFX_PUSH_BLOCK_END, &item->pos, 2);
DoPushPull = 0;
}
}
else
{
SoundEffect(SFX_PUSHABLE_SOUND, &item->pos, 2);
DoPushPull = 1;
}
GetLaraJointPosition(&pos, LJ_LHAND);
switch (quadrant)
{
case 0:
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:
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:
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:
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;
default:
break;
}
if (LaraItem->frameNumber == Anims[LaraItem->animNumber].frameEnd - 1)
{
if (TrInput & IN_ACTION)
{
if (!TestBlockPush(item,1024,quadrant))
LaraItem->goalAnimState = STATE_LARA_STOP;
}
else
{
LaraItem->goalAnimState = STATE_LARA_STOP;
}
}
break;
case ANIMATION_LARA_OBJECT_PULL:
if ((LaraItem->frameNumber < Anims[LaraItem->animNumber].frameBase + 40
|| LaraItem->frameNumber > Anims[LaraItem->animNumber].frameBase + 122)
&& (LaraItem->frameNumber < Anims[LaraItem->animNumber].frameBase + 130
|| LaraItem->frameNumber > Anims[LaraItem->animNumber].frameBase + 170))
{
if (DoPushPull)
{
SoundEffect(SFX_PUSH_BLOCK_END, &item->pos, 2);
DoPushPull = 0;
}
}
else
{
SoundEffect(SFX_PUSHABLE_SOUND, &item->pos, 2);
DoPushPull = 1;
}
GetLaraJointPosition(&pos, LJ_LHAND);
switch (quadrant)
{
case 0:
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:
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:
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:
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;
default:
break;
}
if (LaraItem->frameNumber == Anims[LaraItem->animNumber].frameEnd - 1)
{
if (TrInput & IN_ACTION)
{
if (!TestBlockPull(item, 1024, quadrant))
LaraItem->goalAnimState = STATE_LARA_STOP;
}
else
{
LaraItem->goalAnimState = STATE_LARA_STOP;
}
}
break;
case ANIMATION_LARA_PUSHABLE_PUSH_TO_STAND:
case ANIMATION_LARA_PUSHABLE_PULL_TO_STAND:
if (LaraItem->frameNumber == Anims[ANIMATION_LARA_PUSHABLE_PUSH_TO_STAND].frameBase
|| LaraItem->frameNumber == Anims[ANIMATION_LARA_PUSHABLE_PULL_TO_STAND].frameBase)
{
item->pos.xPos = item->pos.xPos & 0xFFFFFE00 | 0x200;
item->pos.zPos = item->pos.zPos & 0xFFFFFE00 | 0x200;
}
if (LaraItem->frameNumber == Anims[LaraItem->animNumber].frameEnd)
{
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);
TestTriggers(TriggerIndex, 1, item->flags & 0x3E00);
RemoveActiveItem(itemNumber);
item->status = ITEM_INACTIVE;
}
break;
}
return;
// TR3 code below, to add in the future
if (item->flags & ONESHOT)
{
AlterFloorHeight(item, 1024);
@ -76,9 +256,9 @@ void PushableBlockControl(short itemNumber)
AnimateItem(item);
short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
int height = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
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;
@ -109,18 +289,135 @@ void PushableBlockControl(short itemNumber)
}
}
void PushableBlockCollision(short itemNum, ITEM_INFO * laraitem, COLL_INFO * coll)
void PushableBlockCollision(short itemNum, ITEM_INFO * l, COLL_INFO * coll)
{
ITEM_INFO* item = &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 ((!(TrInput & IN_ACTION)
|| l->currentAnimState != STATE_LARA_STOP
|| l->animNumber != ANIMATION_LARA_STAY_IDLE
|| l->gravityStatus
|| Lara.gunStatus
|| item->status == ITEM_INVISIBLE
|| item->triggerFlags < 0)
&& (!Lara.isMoving || Lara.generalPtr != item))
{
if (l->currentAnimState != STATE_LARA_PUSHABLE_GRAB
|| (l->frameNumber != Anims[ANIMATION_LARA_START_OBJECT_MOVING].frameBase + 19)
|| Lara.cornerX != (int)item)
{
ObjectCollision(itemNum, l, coll);
return;
}
unsigned short quadrant = (unsigned short)((l->pos.yRot + 0x2000) / 0x4000);
if (TrInput & IN_FORWARD)
{
if (!TestBlockPush(item, 1024, quadrant))
return;
l->goalAnimState = STATE_LARA_PUSHABLE_PUSH;
}
else if (TrInput & IN_BACK)
{
if (!TestBlockPull(item, 1024, quadrant))
return;
l->goalAnimState = STATE_LARA_PUSHABLE_PULL;
}
else
{
return;
}
item->status = ITEM_ACTIVE;
AddActiveItem(itemNum);
Lara.headYrot = 0;
Lara.headXrot = 0;
Lara.torsoYrot = 0;
Lara.torsoXrot = 0;
PHD_VECTOR pos;
pos.x = 0;
pos.y = 0;
pos.z = 0;
GetLaraJointPosition(&pos, LJ_LHAND);
l->itemFlags[0] = pos.x;
l->itemFlags[2] = pos.z;
item->itemFlags[0] = item->pos.xPos;
item->itemFlags[2] = item->pos.zPos;
}
else
{
short roomNumber = l->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos - 256, item->pos.zPos, &roomNumber);
if (roomNumber == item->roomNumber)
{
short* bounds = GetBoundsAccurate(item);
PushableBlockBounds[0] = (bounds[0] >> 1) - 100;
PushableBlockBounds[1] = (bounds[1] >> 1) + 100;
PushableBlockBounds[4] = bounds[4] - 200;
PushableBlockBounds[5] = 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[0] - 35;
else
PushableBlockPos.z = bounds[4] - 35;
if (MoveLaraPosition(&PushableBlockPos, item, l))
{
l->animNumber = ANIMATION_LARA_START_OBJECT_MOVING;
l->frameNumber = Anims[l->animNumber].frameBase;
l->currentAnimState = STATE_LARA_PUSHABLE_GRAB;
l->goalAnimState = STATE_LARA_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
{
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 ||
laraitem->gravityStatus ||
laraitem->pos.yPos != item->pos.yPos)
l->gravityStatus ||
l->pos.yPos != item->pos.yPos)
return;
unsigned short quadrant = (unsigned short)(laraitem->pos.yRot + 0x2000) / 0x4000;
if (laraitem->currentAnimState == STATE_LARA_STOP)
unsigned short quadrant = (unsigned short)(l->pos.yRot + 0x2000) / 0x4000;
if (l->currentAnimState == STATE_LARA_STOP)
{
if (Lara.gunStatus != LG_NO_ARMS)
return;
@ -143,10 +440,10 @@ void PushableBlockCollision(short itemNum, ITEM_INFO * laraitem, COLL_INFO * col
item->pos.yRot = -ANGLE(90);
break;
}
if (!TestLaraPosition(MovingBlockBounds, item, laraitem))
if (!TestLaraPosition(MovingBlockBounds, item, l))
return;
short roomNumber = laraitem->roomNumber;
short roomNumber = l->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
if (roomNumber != item->roomNumber)
return;
@ -154,50 +451,50 @@ void PushableBlockCollision(short itemNum, ITEM_INFO * laraitem, COLL_INFO * col
switch (quadrant)
{
case NORTH:
laraitem->pos.zPos &= -1024;
laraitem->pos.zPos += 1024 - LARA_RAD;
l->pos.zPos &= -1024;
l->pos.zPos += 1024 - LARA_RAD;
break;
case SOUTH:
laraitem->pos.zPos &= -1024;
laraitem->pos.zPos += LARA_RAD;
l->pos.zPos &= -1024;
l->pos.zPos += LARA_RAD;
break;
case EAST:
laraitem->pos.xPos &= -1024;
laraitem->pos.xPos += 1024 - LARA_RAD;
l->pos.xPos &= -1024;
l->pos.xPos += 1024 - LARA_RAD;
break;
case WEST:
laraitem->pos.xPos &= -1024;
laraitem->pos.xPos += LARA_RAD;
l->pos.xPos &= -1024;
l->pos.xPos += LARA_RAD;
break;
}
laraitem->pos.yRot = item->pos.yRot;
laraitem->goalAnimState = STATE_LARA_PUSHABLE_GRAB;
AnimateLara(laraitem);
if (laraitem->currentAnimState == STATE_LARA_PUSHABLE_GRAB)
l->pos.yRot = item->pos.yRot;
l->goalAnimState = STATE_LARA_PUSHABLE_GRAB;
AnimateLara(l);
if (l->currentAnimState == STATE_LARA_PUSHABLE_GRAB)
Lara.gunStatus = LG_HANDS_BUSY;
}
else if (laraitem->currentAnimState == STATE_LARA_PUSHABLE_GRAB)
else if (l->currentAnimState == STATE_LARA_PUSHABLE_GRAB)
{
if (laraitem->frameNumber != Anims[ANIMATION_LARA_START_OBJECT_MOVING].frameBase + 19)
if (l->frameNumber != Anims[ANIMATION_LARA_START_OBJECT_MOVING].frameBase + 19)
return;
if (!TestLaraPosition(MovingBlockBounds, item, laraitem))
if (!TestLaraPosition(MovingBlockBounds, item, l))
return;
if (TrInput & IN_FORWARD)
{
if (!TestBlockPush(item, 1024, quadrant))
return;
item->goalAnimState = 2;
laraitem->goalAnimState = STATE_LARA_PUSHABLE_PUSH;
l->goalAnimState = STATE_LARA_PUSHABLE_PUSH;
}
else if (TrInput & IN_BACK)
{
if (!TestBlockPull(item, 1024, quadrant))
return;
item->goalAnimState = 3;
laraitem->goalAnimState = STATE_LARA_PUSHABLE_PULL;
l->goalAnimState = STATE_LARA_PUSHABLE_PULL;
}
else
return;
@ -208,7 +505,7 @@ void PushableBlockCollision(short itemNum, ITEM_INFO * laraitem, COLL_INFO * col
item->status = ITEM_ACTIVE;
AnimateItem(item);
AnimateLara(laraitem);
AnimateLara(l);
Lara.headXrot = Lara.headYrot = 0;
Lara.torsoXrot = Lara.torsoYrot = 0;
@ -228,10 +525,10 @@ int TestBlockMovable(ITEM_INFO * item, int blokhite)
return 1;
}
int TestBlockPush(ITEM_INFO * item, int blokhite, unsigned short quadrant)
int TestBlockPush(ITEM_INFO * item, int blockhite, unsigned short quadrant)
{
if (!TestBlockMovable(item, blokhite))
return 0;
//if (!TestBlockMovable(item, blokhite))
// return 0;
int x = item->pos.xPos;
int y = item->pos.yPos;
@ -259,10 +556,33 @@ int TestBlockPush(ITEM_INFO * item, int blokhite, unsigned short quadrant)
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNum);
ROOM_INFO* r = &Rooms[roomNum];
if (XZ_GET_SECTOR(r,x-r->x,z-r->z).stopper )
if (XZ_GET_SECTOR(r, x - r->x, z - r->z).stopper)
return 0;
COLL_INFO scoll;
if (GetFloorHeight(floor, x, y - 256, z) != y)
return 0;
GetFloorHeight(floor, x, y, z);
if (HeightType)
return 0;
int ceiling = y - blockhite + 100;
floor = GetFloor(x, ceiling, z, &roomNum);
if (GetCeiling(floor, x, ceiling, z) > ceiling)
return 0;
int oldX = item->pos.xPos;
int oldZ = item->pos.zPos;
item->pos.xPos = x;
item->pos.zPos = z;
GetCollidedObjects(item, 256, 1, &CollidedItems[0], 0, 0);
item->pos.xPos = oldX;
item->pos.zPos = oldZ;
return CollidedItems[0] == NULL;
// TR3 code
/*COLL_INFO scoll;
scoll.quadrant = quadrant;
scoll.radius = 500;
if (CollideStaticObjects(&scoll, x, y, z, roomNum, 1000))
@ -281,13 +601,13 @@ int TestBlockPush(ITEM_INFO * item, int blokhite, unsigned short quadrant)
return 0;
item->itemFlags[0] = LaraItem->pos.yRot;
return 1;
return 1;*/
}
int TestBlockPull(ITEM_INFO * item, int blokhite, short quadrant)
int TestBlockPull(ITEM_INFO * item, int blockhite, short quadrant)
{
if (!TestBlockMovable(item, blokhite))
return (0);
//if (!TestBlockMovable(item, blokhite))
// return (0);
int xadd = 0;
int zadd = 0;
@ -315,12 +635,61 @@ int TestBlockPull(ITEM_INFO * item, int blokhite, short quadrant)
int y = item->pos.yPos;
int z = item->pos.zPos + zadd;
short roomNum = item->roomNumber;
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNum);
FLOOR_INFO* floor = GetFloor(x, y - 256, z, &roomNum);
ROOM_INFO* r = &Rooms[roomNum];
if (XZ_GET_SECTOR(r,x-r->x,z-r->z).stopper)
if (XZ_GET_SECTOR(r, x - r->x, z - r->z).stopper)
return 0;
if (GetFloorHeight(floor, x, y - 256, z) != y)
return 0;
if (GetFloor(x, y - blockhite, z, &quadrant)->ceiling * 256 > y - blockhite)
return 0;
int oldX = item->pos.xPos;
int oldZ = item->pos.zPos;
item->pos.xPos = x;
item->pos.zPos = z;
GetCollidedObjects(item, 256, 1, &CollidedItems[0], 0, 0);
item->pos.xPos = oldX;
item->pos.zPos = oldZ;
if (CollidedItems[0] != NULL)
return 0;
x += xadd;
z += zadd;
roomNum = item->roomNumber;
floor = GetFloor(x, y - 256, z, &roomNum);
if (GetFloorHeight(floor, x, y - 256, z) != y)
return 0;
if (GetFloor(x, y - 762, z, &roomNum)->ceiling * 256 > y - 762)
return 0;
x = LaraItem->pos.xPos + xadd;
z = LaraItem->pos.zPos + zadd;
roomNum = LaraItem->roomNumber;
GetFloor(x, y, z, &roomNum);
r = &Rooms[roomNum];
if (XZ_GET_SECTOR(r, x - r->x, z - r->z).stopper)
return 0;
oldX = LaraItem->pos.xPos;
oldZ = LaraItem->pos.zPos;
LaraItem->pos.xPos = x;
LaraItem->pos.zPos = z;
GetCollidedObjects(LaraItem, 256, 1, &CollidedItems[0], 0, 0);
LaraItem->pos.xPos = oldX;
LaraItem->pos.zPos = oldZ;
return (CollidedItems[0] == NULL);
/*
COLL_INFO scoll;
scoll.quadrant = quadrant;
scoll.radius = 500;
@ -360,6 +729,6 @@ int TestBlockPull(ITEM_INFO * item, int blokhite, short quadrant)
item->itemFlags[0] = LaraItem->pos.yRot + ANGLE(180);
return 1;
return 1;*/
}

View file

@ -5907,6 +5907,8 @@ int Renderer11::drawInventoryScene()
OBJECT_INFO* obj = &Objects[objectNumber];
RendererObject* moveableObj = m_moveableObjects[objectNumber];
if (moveableObj == NULL)
continue;
// Build the object animation matrices
if (ring->focusState == INV_FOCUS_STATE_FOCUSED && obj->animIndex != -1 &&