diff --git a/TR5Main/Game/lara.cpp b/TR5Main/Game/lara.cpp index f5ef20d4d..d06c4dc70 100644 --- a/TR5Main/Game/lara.cpp +++ b/TR5Main/Game/lara.cpp @@ -23,7 +23,7 @@ #include "setup.h" #include "motorbike.h" -#include "cannon.h" +#include "biggun.h" #include "quad.h" #include "snowmobile.h" #include "jeep.h" @@ -446,6 +446,11 @@ void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll) // return; // break; + case ID_BIGGUN: + if (BigGunControl(coll)) + return; + break; + default: break; } diff --git a/TR5Main/Objects/TR3/Vehicles/biggun.cpp b/TR5Main/Objects/TR3/Vehicles/biggun.cpp new file mode 100644 index 000000000..bddca5893 --- /dev/null +++ b/TR5Main/Objects/TR3/Vehicles/biggun.cpp @@ -0,0 +1,291 @@ +#include "framework.h" +#include "biggun.h" +#include "items.h" +#include "level.h" +#include "collide.h" +#include "input.h" +#include "lara.h" +#include "laraflar.h" +#include "sound.h" +#include "sphere.h" +#include "effect2.h" +#include "lara_struct.h" +#include "tomb4fx.h" +#include "draw.h" + +static long GunRotYAdd = 0; +int fireCount = 0; + +void FireBigGun(ITEM_INFO *obj) +{ + Lara.hasFired = true; + + short itemNumber = CreateItem(); + if (itemNumber != NO_ITEM) + { + ITEM_INFO* item = &g_Level.Items[itemNumber]; + item->objectNumber = ID_ROCKET; + item->roomNumber = LaraItem->roomNumber; + + + PHD_VECTOR jointPos; + jointPos.x = Lara.torsoXrot; + jointPos.y = Lara.torsoYrot + 1300; + jointPos.z = Lara.torsoZrot; + + GetLaraJointPosition(&jointPos, LM_RHAND); + + int x, y, z; + item->pos.xPos = x = jointPos.x; + item->pos.yPos = y = jointPos.y; + item->pos.zPos = z = jointPos.z; + + jointPos.x = 0; + jointPos.y = 180 + 1024; + jointPos.z = 0; + + SmokeCountL = 32; + SmokeWeapon = WEAPON_ROCKET_LAUNCHER; + + for (int i = 0; i < 5; i++) + TriggerGunSmoke(x, y, z, jointPos.x - x, jointPos.y - y, jointPos.z - z, 1, WEAPON_ROCKET_LAUNCHER, 32); + + InitialiseItem(itemNumber); + + item->pos.xRot = LaraItem->pos.xRot + Lara.leftArm.xRot; + item->pos.yRot = LaraItem->pos.yRot + Lara.leftArm.yRot; + item->pos.zRot = 0; + + if (!Lara.leftArm.lock) + { + item->pos.xRot += Lara.torsoXrot; + item->pos.yRot += Lara.torsoYrot; + } + + item->speed = 512 >> 5; + item->itemFlags[0] = 0; + + AddActiveItem(itemNumber); + + SoundEffect(SFX_EXPLOSION1, 0, 0); + } + +} + +static int CanUseGun(ITEM_INFO *obj, ITEM_INFO *lara) +{ + int dist; + long x, z; + + if ((!(TrInput & IN_ACTION)) + || (Lara.gunStatus != LG_NO_ARMS) + || (lara->gravityStatus)) + return 0; + + x = lara->pos.xPos - obj->pos.xPos; + z = lara->pos.zPos - obj->pos.zPos; + + dist = SQUARE(x) + SQUARE(z); + + if (dist > 30000) + return 0; + else + return 1; +} + +void BigGunInitialise(short itemNum) +{ + ITEM_INFO *obj; + BIGGUNINFO *gun; + + obj = &g_Level.Items[itemNum]; + + gun = (BIGGUNINFO*)malloc(sizeof(BIGGUNINFO)); + obj->data = malloc(sizeof(BIGGUNINFO)); + + gun->flags = 0; + fireCount = 0; + gun->yRot = 30; + gun->yRot = 0; + gun->startYRot = obj->pos.yRot; +} + +void BigGunCollision(short itemNum, ITEM_INFO* lara, COLL_INFO* coll) +{ + ITEM_INFO* obj; + BIGGUNINFO *gun; + + if (lara->hitPoints <= 0 || Lara.Vehicle != NO_ITEM) + return; + + obj = &g_Level.Items[itemNum]; + + if (CanUseGun(obj, lara)) + { + Lara.Vehicle = itemNum; + + if (Lara.gunType == WEAPON_FLARE) + { + CreateFlare(ID_FLARE_ITEM, 0); + undraw_flare_meshes(); + Lara.flareControlLeft = false; + Lara.requestGunType = WEAPON_NONE; + Lara.gunType = WEAPON_NONE; + } + + Lara.gunStatus = LG_HANDS_BUSY; + + lara->pos.xPos = obj->pos.xPos; + lara->pos.xRot = obj->pos.xRot; + lara->pos.yPos = obj->pos.yPos; + lara->pos.yRot = obj->pos.yRot; + lara->pos.zPos = obj->pos.zPos; + lara->pos.zRot = obj->pos.zRot; + + lara->animNumber = Objects[ID_BIGGUN_ANIMS].animIndex + 0; + lara->frameNumber = g_Level.Anims[Objects[ID_BIGGUN_ANIMS].animIndex].frameBase; + lara->currentAnimState = 0; + lara->goalAnimState = 0; + + gun = (BIGGUNINFO*)obj->data; + gun->flags = 0; + gun->xRot = 30; + + } + else + ObjectCollision(itemNum, lara, coll); +} + +int BigGunControl(COLL_INFO *coll) +{ + BIGGUNINFO *gun; + ITEM_INFO *obj; + ITEM_INFO *lara; + + lara = LaraItem; + obj = &g_Level.Items[Lara.Vehicle]; + gun = (BIGGUNINFO *)obj->data; + + if (gun->flags & 1) + { + if ((lara->hitPoints <= 0) || (TrInput & IN_ROLL)) + { + gun->flags = 2; + } + else if ((TrInput & IN_ACTION) && fireCount == 0) + { + FireBigGun(obj); + fireCount = 26; + } + else + { + if (TrInput & IN_LEFT) + { + if (GunRotYAdd > 0) + GunRotYAdd--;// >>= 1; + + GunRotYAdd -= 16; + + if (GunRotYAdd < -64) + GunRotYAdd = -64; + + if (((Wibble & 7) == 0) && (abs(gun->yRot) < 544)) + SoundEffect(SFX_TR3_LARA_UZI_STOP, &obj->pos, NULL); + } + else if (TrInput & IN_RIGHT) + { + if (GunRotYAdd < 0) + GunRotYAdd++;// >>= 1; + + GunRotYAdd += 16; + + if (GunRotYAdd < 64) + GunRotYAdd = 64; + + if (((Wibble & 7) == 0) && (abs(gun->yRot) < (136 << 2))) + SoundEffect(SFX_TR3_LARA_UZI_STOP, &obj->pos, NULL); + } + else + { +// GunRotYAdd -= GunRotYAdd >> 2; + if (abs(GunRotYAdd) < 16) + GunRotYAdd = 0; + } + + gun->yRot = GunRotYAdd >> 2; + + if (gun->yRot < -(136 << 2)) + { + gun->yRot = -(136 << 2); + GunRotYAdd = 0; + } + else if (gun->yRot > (136 << 2)) + { + gun->yRot = (136 << 2); + GunRotYAdd = 0; + } + + if ((TrInput & IN_FORWARD) && (gun->xRot < 59)) + gun->xRot++; + else if ((TrInput & IN_BACK) && (gun->xRot)) + gun->xRot--; + } + } + if (gun->flags & 2) + { + if (gun->xRot < 30) + gun->xRot++; + else if (gun->xRot > 30) + gun->xRot--; + else + { + lara->animNumber = Objects[ID_BIGGUN_ANIMS].animIndex + 1; + lara->frameNumber = g_Level.Anims[Objects[ID_BIGGUN_ANIMS].animIndex].frameBase; + lara->currentAnimState = 1; + lara->goalAnimState = 1; + gun->flags = 4; + } + } + + switch (lara->currentAnimState) + { + case 0: + case 1: + AnimateItem(lara); + obj->animNumber = Objects[ID_BIGGUN].animIndex + (lara->animNumber - Objects[ID_BIGGUN_ANIMS].animIndex); + obj->frameNumber = g_Level.Anims[obj->animNumber].frameBase + (lara->frameNumber - g_Level.Anims[lara->animNumber].frameBase); + + if ((gun->flags & 4) && lara->frameNumber == g_Level.Anims[lara->animNumber].frameEnd) + { + lara->animNumber = LA_STAND_SOLID; + lara->frameNumber = g_Level.Anims[lara->animNumber].frameBase; + lara->currentAnimState = LS_STOP; + lara->goalAnimState = LS_STOP; + Lara.Vehicle = NO_ITEM; + Lara.gunStatus = LG_NO_ARMS; + } + break; + case 2: + lara->animNumber = Objects[ID_BIGGUN_ANIMS].animIndex + 2; + lara->frameNumber = g_Level.Anims[Objects[ID_BIGGUN].animIndex + 2].frameBase + gun->xRot; + + obj->animNumber = Objects[ID_BIGGUN].animIndex + (lara->animNumber - Objects[ID_BIGGUN_ANIMS].animIndex); + obj->frameNumber = g_Level.Anims[obj->animNumber].frameBase + (lara->frameNumber - g_Level.Anims[lara->animNumber].frameBase); + + if (fireCount) + fireCount--; + + gun->flags = 1; + break; + } + + lara->pos.yRot = gun->startYRot + (gun->yRot * (ANGLE(1) >> 2)); + obj->pos.yRot = gun->startYRot + (gun->yRot * (ANGLE(1) >> 2)); + + coll->enableSpaz = false; + coll->enableBaddiePush = false; + LaraBaddieCollision(lara, coll); + + Camera.targetElevation = -ANGLE(15); + return 1; +} diff --git a/TR5Main/Objects/TR3/Vehicles/biggun.h b/TR5Main/Objects/TR3/Vehicles/biggun.h new file mode 100644 index 000000000..063960671 --- /dev/null +++ b/TR5Main/Objects/TR3/Vehicles/biggun.h @@ -0,0 +1,15 @@ +#pragma once +#include "lara_struct.h" + +typedef struct { + short xRot; + short yRot; + short startYRot; + char flags; +}BIGGUNINFO; +void FireBigGun(ITEM_INFO *obj); +void BigGunInitialise(short itemNum); +static int CanUseGun(ITEM_INFO *obj, ITEM_INFO *lara); +void BigGunInitialise(short itemNum); +void BigGunCollision(short itemNum, ITEM_INFO* lara, COLL_INFO* coll); +int BigGunControl(COLL_INFO *coll); diff --git a/TR5Main/Objects/TR3/Vehicles/cannon.cpp b/TR5Main/Objects/TR3/Vehicles/cannon.cpp deleted file mode 100644 index 474d5f8d5..000000000 --- a/TR5Main/Objects/TR3/Vehicles/cannon.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "framework.h" -#include "cannon.h" diff --git a/TR5Main/Objects/TR3/Vehicles/cannon.h b/TR5Main/Objects/TR3/Vehicles/cannon.h deleted file mode 100644 index 3f59c932d..000000000 --- a/TR5Main/Objects/TR3/Vehicles/cannon.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once - diff --git a/TR5Main/Objects/TR3/tr3_objects.cpp b/TR5Main/Objects/TR3/tr3_objects.cpp index be17c23f8..35410b9f0 100644 --- a/TR5Main/Objects/TR3/tr3_objects.cpp +++ b/TR5Main/Objects/TR3/tr3_objects.cpp @@ -23,7 +23,7 @@ /// switch /// vehicles -#include "cannon.h" +#include "biggun.h" #include "kayak.h" #include "minecart.h" #include "quad.h" @@ -392,6 +392,18 @@ static void StartVehicles(OBJECT_INFO* obj) obj->saveFlags = true; obj->savePosition = true; } + + obj = &Objects[ID_BIGGUN]; + if (obj->loaded) + { + obj->initialise = BigGunInitialise; + obj->collision = BigGunCollision; +// obj->draw_routine = BigGunDraw; + obj->savePosition = 1; + obj->saveFlags = 1; + obj->saveAnim = 1; + } + } static void StartProjectiles(OBJECT_INFO* obj) diff --git a/TR5Main/Objects/objectslist.h b/TR5Main/Objects/objectslist.h index 9b6b7b13f..ba06d0414 100644 --- a/TR5Main/Objects/objectslist.h +++ b/TR5Main/Objects/objectslist.h @@ -61,6 +61,9 @@ typedef enum GAME_OBJECT_ID ID_MOTORBIKE, ID_RUBBER_BOAT_LARA_ANIMS, ID_RUBBER_BOAT_BOAT, // TR3 / (TR4 TRNG) + ID_BIGGUN_ANIMS, + ID_BIGGUN, // TR3 + ID_VEHICLE_SMASHABLE_FLOOR = 90, // NEW ID_VEHICLE_SMASHABLE_WALL, // NEW diff --git a/TR5Main/TR5Main.vcxproj b/TR5Main/TR5Main.vcxproj index e80549833..23adb6378 100644 --- a/TR5Main/TR5Main.vcxproj +++ b/TR5Main/TR5Main.vcxproj @@ -15,7 +15,7 @@ {15AB0220-541C-4DA1-94EB-ED3C47E4582E} Win32Proj TR5Main - 10.0.19041.0 + 10.0.17134.0 @@ -314,7 +314,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" - + @@ -534,7 +534,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" - + diff --git a/TR5Main/TR5Main.vcxproj.filters b/TR5Main/TR5Main.vcxproj.filters index d40244e97..9aeca5f47 100644 --- a/TR5Main/TR5Main.vcxproj.filters +++ b/TR5Main/TR5Main.vcxproj.filters @@ -414,9 +414,6 @@ File di intestazione - - File di intestazione - File di intestazione @@ -879,6 +876,9 @@ File di intestazione + + File di intestazione + @@ -1376,9 +1376,6 @@ File di origine - - File di origine - File di origine @@ -1604,6 +1601,9 @@ File di origine + + File di origine +