Fixed ID_LOCUST_EMITTER (missing only rendering)

This commit is contained in:
MontyTRC89 2021-08-18 11:17:42 +02:00
parent 1ad81f4a63
commit 11f8e533e9
2 changed files with 25 additions and 19 deletions

View file

@ -51,7 +51,7 @@ void SpawnLocust(ITEM_INFO* item)
{ {
locust = &Locusts[locustNumber]; locust = &Locusts[locustNumber];
// emitter // emitter
if (item->objectNumber == ID_LOCUSTS_EMITTER) if (item->objectNumber == ID_LOCUST_EMITTER)
{ {
end.x = item->pos.xPos; end.x = item->pos.xPos;
end.y = item->pos.yPos; end.y = item->pos.yPos;
@ -73,10 +73,11 @@ void SpawnLocust(ITEM_INFO* item)
phd_GetVectorAngles(end.x - start.x, end.y - start.y, end.z - start.z, angles); phd_GetVectorAngles(end.x - start.x, end.y - start.y, end.z - start.z, angles);
} }
target = GetCreatureInfo(item)->enemy; // NOTE: this is not present in original TR4 code
//target = GetCreatureInfo(item)->enemy;
locust->on = true; locust->on = true;
locust->target = target != nullptr ? target : nullptr; //locust->target = target != nullptr ? target : nullptr;
locust->pos.xPos = end.x; locust->pos.xPos = end.x;
locust->pos.yPos = end.y; locust->pos.yPos = end.y;
locust->pos.zPos = end.z; locust->pos.zPos = end.z;
@ -96,14 +97,14 @@ void InitialiseLocust(short itemNumber)
if (item->pos.yRot > 0) if (item->pos.yRot > 0)
{ {
if (item->pos.yRot == 0x4000) if (item->pos.yRot == ANGLE(90))
item->pos.xPos += CLICK(2); item->pos.xPos += CLICK(2);
} }
else if (item->pos.yRot < 0) else if (item->pos.yRot < 0)
{ {
if (item->pos.yRot == -0x8000) if (item->pos.yRot == -ANGLE(180))
item->pos.zPos -= CLICK(2); item->pos.zPos -= CLICK(2);
else if (item->pos.yRot == -0x4000) else if (item->pos.yRot == -ANGLE(90))
item->pos.xPos -= CLICK(2); item->pos.xPos -= CLICK(2);
} }
else else
@ -144,9 +145,13 @@ void UpdateLocusts(void)
locust = &Locusts[i]; locust = &Locusts[i];
if (locust->on) if (locust->on)
{ {
if (locust->target == nullptr) // NOTE: not present in original TR4 code
locust->target = LaraItem; //if (LaraItem == nullptr)
if (locust->target->hitPoints <= 0 && locust->counter >= 90 && !(GetRandomControl() & 7)) // LaraItem = LaraItem;
if ((Lara.keepDucked || LaraItem->hitPoints <= 0)
&& locust->counter >= 90
&& !(GetRandomControl() & 7))
locust->counter = 90; locust->counter = 90;
locust->counter--; locust->counter--;
@ -164,12 +169,12 @@ void UpdateLocusts(void)
} }
phd_GetVectorAngles( phd_GetVectorAngles(
locust->target->pos.xPos + 8 * locust->escapeXrot - locust->pos.xPos, LaraItem->pos.xPos + 8 * locust->escapeXrot - locust->pos.xPos,
locust->target->pos.yPos - locust->escapeYrot - locust->pos.yPos, LaraItem->pos.yPos - locust->escapeYrot - locust->pos.yPos,
locust->target->pos.zPos + 8 * locust->escapeZrot - locust->pos.zPos, LaraItem->pos.zPos + 8 * locust->escapeZrot - locust->pos.zPos,
angles); angles);
distance = SQUARE(locust->target->pos.zPos - locust->pos.zPos) + SQUARE(locust->target->pos.xPos - locust->pos.xPos); distance = SQUARE(LaraItem->pos.zPos - locust->pos.zPos) + SQUARE(LaraItem->pos.xPos - locust->pos.xPos);
square = int(sqrt(distance)) / 8; square = int(sqrt(distance)) / 8;
if (square <= 128) if (square <= 128)
{ {
@ -210,13 +215,14 @@ void UpdateLocusts(void)
locust->pos.xPos += locust->randomRotation * phd_cos(locust->pos.xRot) * phd_sin(locust->pos.yRot); locust->pos.xPos += locust->randomRotation * phd_cos(locust->pos.xRot) * phd_sin(locust->pos.yRot);
locust->pos.yPos += locust->randomRotation * phd_sin(-locust->pos.xRot); locust->pos.yPos += locust->randomRotation * phd_sin(-locust->pos.xRot);
locust->pos.zPos += locust->randomRotation * phd_cos(locust->pos.xRot) * phd_cos(locust->pos.yRot); locust->pos.zPos += locust->randomRotation * phd_cos(locust->pos.xRot) * phd_cos(locust->pos.yRot);
if (ItemNearTarget(&locust->pos, locust->target, CLICK(1) / 2)) if (ItemNearTarget(&locust->pos, LaraItem, CLICK(1) / 2))
{ {
TriggerBlood(locust->pos.xPos, locust->pos.yPos, locust->pos.zPos, 2 * GetRandomControl(), 2); TriggerBlood(locust->pos.xPos, locust->pos.yPos, locust->pos.zPos, 2 * GetRandomControl(), 2);
if (locust->target == LaraItem) if (LaraItem->hitPoints > 0)
locust->target->hitPoints -= LOCUST_LARA_DAMAGE; LaraItem->hitPoints -= LOCUST_LARA_DAMAGE;
else // NOTE: not present in original TR4 code
locust->target->hitPoints -= LOCUST_ENTITY_DAMAGE; //else
// LaraItem->hitPoints -= LOCUST_ENTITY_DAMAGE;
} }
if (locust->counter > 0) if (locust->counter > 0)

View file

@ -683,7 +683,7 @@ static void StartBaddy(OBJECT_INFO* obj)
g_Level.Bones[obj->boneIndex + 7 * 4] |= ROT_Y | ROT_X; g_Level.Bones[obj->boneIndex + 7 * 4] |= ROT_Y | ROT_X;
} }
obj = &Objects[ID_LOCUSTS_EMITTER]; obj = &Objects[ID_LOCUST_EMITTER];
if (obj->loaded) if (obj->loaded)
{ {
obj->initialise = InitialiseLocust; obj->initialise = InitialiseLocust;