diff --git a/TR5Main/Objects/TR4/Entity/tr4_big_beetle.cpp b/TR5Main/Objects/TR4/Entity/tr4_big_beetle.cpp new file mode 100644 index 000000000..b8e38d304 --- /dev/null +++ b/TR5Main/Objects/TR4/Entity/tr4_big_beetle.cpp @@ -0,0 +1,205 @@ +#include "framework.h" +#include "tr4_big_beetle.h" +#include "items.h" +#include "effect2.h" +#include "setup.h" +#include "level.h" +#include "control.h" +#include "trmath.h" +#include +#include +#include +#include + +BITE_INFO BitBeetleBite = { 0,0,0,12 }; + +void InitialiseBigBeetle(short itemNumber) +{ + ITEM_INFO* item = &g_Level.Items[itemNumber]; + + ClearItem(itemNumber); + + item->animNumber = Objects[item->objectNumber].animIndex + 3; + item->frameNumber = g_Level.Anims[item->animNumber].frameBase; + item->goalAnimState = 1; + item->currentAnimState = 1; +} + +void BigBeetleControl(short itemNumber) +{ + if (!CreatureActive(itemNumber)) + return; + + ITEM_INFO* item = &g_Level.Items[itemNumber]; + CREATURE_INFO* creature = (CREATURE_INFO*)item->data; + + short angle = 0; + + if (item->hitPoints <= 0) + { + if (item->currentAnimState != 6) + { + if (item->currentAnimState != 7) + { + if (item->currentAnimState == 8) + { + item->pos.xRot = 0; + item->pos.yPos = item->floor; + } + else + { + item->animNumber = Objects[item->objectNumber].animIndex + 5; + item->frameNumber = g_Level.Anims[item->animNumber].frameBase; + item->gravityStatus = true; + item->currentAnimState = 6; + item->speed = 0; + item->pos.xRot = 0; + } + } + else if (item->pos.yPos >= item->floor) + { + item->pos.yPos = item->floor; + item->gravityStatus = false; + item->fallspeed = 0; + item->goalAnimState = 8; + } + } + item->pos.xRot = 0; + } + else + { + AI_INFO info; + CreatureAIInfo(item, &info); + + GetCreatureMood(item, &info, VIOLENT); + if (creature->flags) + creature->mood = ESCAPE_MOOD; + CreatureMood(item, &info, VIOLENT); + + angle = CreatureTurn(item, creature->maximumTurn); + + if (info.distance > SQUARE(3072) + || !(GetRandomControl() & 0x7F) + || item->hitStatus) + { + creature->flags = 0; + } + + switch (item->currentAnimState) + { + case 1: + item->pos.yPos = item->floor; + creature->maximumTurn = ANGLE(1); + + if (item->hitStatus + || info.distance < SQUARE(3072) + || creature->hurtByLara + || item->aiBits == MODIFY) + { + item->goalAnimState = 2; + } + + break; + + case 3: + creature->maximumTurn = ANGLE(7); + + if (item->requiredAnimState) + { + item->goalAnimState = item->requiredAnimState; + } + else if (info.ahead) + { + if (info.distance < SQUARE(256)) + { + item->goalAnimState = 9; + } + } + + break; + + case 4u: + creature->maximumTurn = ANGLE(7); + + if (info.ahead) + { + if (info.distance < SQUARE(256)) + { + item->goalAnimState = 4; + } + } + else if (info.distance < SQUARE(256)) + { + item->goalAnimState = 9; + } + else + { + item->requiredAnimState = 3; + item->goalAnimState = 9; + } + + if (!creature->flags) + { + if (item->touchBits & 0x60) + { + LaraItem->hitPoints -= 50; + LaraItem->hitStatus = true; + CreatureEffect2( + item, + &BitBeetleBite, + 5, + -1, + DoBloodSplat); + creature->flags = 1; + } + } + + break; + + case 5: + creature->flags = 0; + + item->pos.yPos += 51; + if (item->pos.yPos > item->floor) + item->pos.yPos = item->floor; + + break; + + case 9u: + creature->maximumTurn = ANGLE(7); + + if (item->requiredAnimState) + { + item->goalAnimState = item->requiredAnimState; + } + else if (!item->hitStatus + && GetRandomControl() >= 384 + && item->aiBits != MODIFY + && (creature->mood && GetRandomControl() >= 128 + || creature->hurtByLara + || item->aiBits == MODIFY)) + { + if (info.ahead) + { + if (info.distance < SQUARE(256) && !creature->flags) + { + item->goalAnimState = 4; + } + } + } + else + { + item->goalAnimState = 3; + } + + break; + + default: + break; + + } + } + + CreatureTilt(item, 2 * angle); + CreatureAnimation(itemNumber, angle, angle); +} \ No newline at end of file diff --git a/TR5Main/Objects/TR4/Entity/tr4_big_beetle.h b/TR5Main/Objects/TR4/Entity/tr4_big_beetle.h new file mode 100644 index 000000000..980930c3f --- /dev/null +++ b/TR5Main/Objects/TR4/Entity/tr4_big_beetle.h @@ -0,0 +1,4 @@ +#pragma once + +void InitialiseBigBeetle(short itemNumber); +void BigBeetleControl(short itemNumber); \ No newline at end of file diff --git a/TR5Main/Objects/TR4/Entity/tr4_setha.cpp b/TR5Main/Objects/TR4/Entity/tr4_setha.cpp index 87570ecdf..a40b16f7e 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_setha.cpp +++ b/TR5Main/Objects/TR4/Entity/tr4_setha.cpp @@ -1,5 +1,5 @@ #include "framework.h" -#include "tr4_horseman.h" +#include "tr4_setha.h" #include "items.h" #include "effect2.h" #include "setup.h" @@ -9,7 +9,7 @@ #include #include #include -#include +#include BITE_INFO SethaBite1 = { 0,220,50,17 }; BITE_INFO SethaBite2 = { 0,220,50,13 }; @@ -484,7 +484,7 @@ void TriggerSethaSparks1(int x, int y, int z, short xv, short yv, short zv) } } -void TriggerSethaSparks2(short itemNumber, byte node, int size) +void TriggerSethaSparks2(short itemNumber, char node, int size) { int dx = LaraItem->pos.xPos - g_Level.Items[itemNumber].pos.xPos; int dz = LaraItem->pos.zPos - g_Level.Items[itemNumber].pos.zPos; diff --git a/TR5Main/Objects/TR4/Entity/tr4_setha.h b/TR5Main/Objects/TR4/Entity/tr4_setha.h index e56c679bf..b97f1e8ac 100644 --- a/TR5Main/Objects/TR4/Entity/tr4_setha.h +++ b/TR5Main/Objects/TR4/Entity/tr4_setha.h @@ -7,3 +7,4 @@ void SethaControl(short itemNumber); void TriggerSethaSparks1(int x, int y, int z, short xv, short yv, short zv); void TriggerSethaSparks2(short itemNumber, char node, int size); void SethaThrowAttack(PHD_3DPOS* pos, short roomNumber, short mesh); +void SethaAttack(int itemNumber); diff --git a/TR5Main/Objects/TR4/tr4_objects.cpp b/TR5Main/Objects/TR4/tr4_objects.cpp index 5bb063828..3634e5530 100644 --- a/TR5Main/Objects/TR4/tr4_objects.cpp +++ b/TR5Main/Objects/TR4/tr4_objects.cpp @@ -25,6 +25,7 @@ #include "tr4_baboon.h" // OK #include "tr4_mutant.h" // OK #include "tr4_locusts.h" // OK +#include "tr4_big_beetle.h" // OFF /// objects #include "tr4_sarcophagus.h" /// puzzle @@ -291,6 +292,26 @@ static void StartBaddy(OBJECT_INFO* obj) g_Level.Bones[obj->boneIndex + 7 * 4] |= ROT_Y; } + obj = &Objects[ID_BIG_BEETLE]; + if (obj->loaded) + { + obj->initialise = InitialiseBigBeetle; + obj->control = BigBeetleControl; + obj->collision = CreatureCollision; + obj->shadowSize = 128; + obj->hitPoints = 30; + obj->pivotLength = 50; + obj->radius = 204; + obj->intelligent = true; + obj->saveHitpoints = true; + obj->saveFlags = true; + obj->saveAnim = true; + obj->savePosition = true; + obj->hitEffect = HIT_BLOOD; + obj->undead = true; + obj->zoneType = ZONE_FLYER; + } + obj = &Objects[ID_SETHA]; if (obj->loaded) { diff --git a/TR5Main/TR5Main.vcxproj b/TR5Main/TR5Main.vcxproj index 2e07446c0..324868d27 100644 --- a/TR5Main/TR5Main.vcxproj +++ b/TR5Main/TR5Main.vcxproj @@ -147,6 +147,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" + @@ -424,6 +425,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" + diff --git a/TR5Main/TR5Main.vcxproj.filters b/TR5Main/TR5Main.vcxproj.filters index 6c1e088aa..1bdfbce0d 100644 --- a/TR5Main/TR5Main.vcxproj.filters +++ b/TR5Main/TR5Main.vcxproj.filters @@ -864,6 +864,9 @@ File di intestazione + + File di intestazione + @@ -1574,6 +1577,9 @@ File di origine + + File di origine +