diff --git a/TR5Main/Game/lara2gun.cpp b/TR5Main/Game/lara2gun.cpp index 6c323526e..727c7a08e 100644 --- a/TR5Main/Game/lara2gun.cpp +++ b/TR5Main/Game/lara2gun.cpp @@ -7,13 +7,13 @@ PISTOL_DEF PistolsTable[4] = { { ID_LARA, 0, 0, 0, 0 }, - { ID_PISTOLS_ANIM, 4, 5, 0xD, 0x18 }, - { ID_REVOLVER_ANIM , 7, 8, 0xF, 0x1D }, - { ID_UZI_ANIM, 4, 5, 0xD, 0x18 } + { ID_PISTOLS_ANIM, 4, 5, 13, 24 }, + { ID_REVOLVER_ANIM , 7, 8, 15, 29 }, + { ID_UZI_ANIM, 4, 5, 13, 24 } }; -int UziLeft; -int UziRight; +bool UziLeft; +bool UziRight; void AnimatePistols(int weaponType) { @@ -302,7 +302,7 @@ void PistolHandler(int weaponType) void undraw_pistol_mesh_right(int weaponType) { - Lara.meshPtrs[HAND_R] = Meshes[Objects[ID_LARA].meshIndex + HAND_R * 2]; + LARA_MESHES(ID_LARA, HAND_R); switch (weaponType) { @@ -323,7 +323,7 @@ void undraw_pistol_mesh_left(int weaponType) { if (weaponType != WEAPON_REVOLVER) { - Lara.meshPtrs[HAND_L] = Meshes[Objects[ID_LARA].meshIndex + HAND_L * 2]; + LARA_MESHES(ID_LARA, HAND_L); switch (weaponType) { @@ -340,14 +340,12 @@ void undraw_pistol_mesh_left(int weaponType) void draw_pistol_meshes(int weaponType) { Lara.holster = ID_LARA_HOLSTERS; - - Lara.meshPtrs[HAND_R] = Meshes[Objects[WeaponObjectMesh(weaponType)].meshIndex + HAND_R * 2]; - //Lara.meshPtrs[THIGH_R] = Meshes[Objects[ID_LARA].meshIndex + THIGH_R * 2]; + + LARA_MESHES(WeaponObjectMesh(weaponType), HAND_R); if (weaponType != WEAPON_REVOLVER) { - Lara.meshPtrs[HAND_L] = Meshes[Objects[WeaponObjectMesh(weaponType)].meshIndex + HAND_L * 2]; - //Lara.meshPtrs[THIGH_L] = Meshes[Objects[ID_LARA].meshIndex + THIGH_L * 2]; + LARA_MESHES(WeaponObjectMesh(weaponType), HAND_L); } } diff --git a/TR5Main/Game/larafire.cpp b/TR5Main/Game/larafire.cpp index 85bd6dd43..add5bc791 100644 --- a/TR5Main/Game/larafire.cpp +++ b/TR5Main/Game/larafire.cpp @@ -289,16 +289,11 @@ void AimWeapon(WEAPON_INFO* winfo, LARA_ARM* arm) void SmashItem(short itemNum) { ITEM_INFO* item = &Items[itemNum]; - short objectNumber = item->objectNumber; - if (objectNumber >= ID_SMASH_OBJECT1 && objectNumber <= ID_SMASH_OBJECT8) + if (item->objectNumber >= ID_SMASH_OBJECT1 && item->objectNumber <= ID_SMASH_OBJECT8) + { SmashObject(itemNum); - - /*ITEM_INFO* item = &Items[itemNum]; - short objectNumber = item->objectNumber; - printf("SmashItem\n"); - if (objectNumber >= ID_SMASH_OBJECT1 && objectNumber <= ID_SMASH_OBJECT8) - SmashObject(itemNum); - else if (objectNumber == ID_BELL_SWITCH) + } + /*else if (item->objectNumber == ID_BELL_SWITCH) { if (item->status != ITEM_ACTIVE) { @@ -310,8 +305,6 @@ void SmashItem(short itemNum) void LaraGun() { - int meshIndex; - if (Lara.leftArm.flash_gun > 0) --Lara.leftArm.flash_gun; if (Lara.rightArm.flash_gun > 0) @@ -323,11 +316,8 @@ void LaraGun() return; } - int gunStatus = Lara.gunStatus; - if (LaraItem->hitPoints <= 0) { - gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS; } else if (!Lara.gunStatus) @@ -447,7 +437,7 @@ void LaraGun() break; case LG_UNDRAW_GUNS: - Lara.meshPtrs[HEAD] = Meshes[Objects[ID_LARA].meshIndex + 14 * 2]; + LARA_MESHES(ID_LARA, HEAD); switch (Lara.gunType) { @@ -477,20 +467,18 @@ void LaraGun() case LG_READY: if (!(TrInput & IN_ACTION)) - meshIndex = Objects[ID_LARA].meshIndex; + LARA_MESHES(ID_LARA, HEAD); else - meshIndex = Objects[ID_LARA_SCREAM].meshIndex; - Lara.meshPtrs[HEAD] = Meshes[meshIndex + HEAD * 2]; + LARA_MESHES(ID_LARA_SCREAM, HEAD); - if (Camera.type != CAMERA_TYPE::CINEMATIC_CAMERA && Camera.type != CAMERA_TYPE::LOOK_CAMERA && - Camera.type != CAMERA_TYPE::HEAVY_CAMERA) + if (Camera.type != CAMERA_TYPE::CINEMATIC_CAMERA && Camera.type != CAMERA_TYPE::LOOK_CAMERA && Camera.type != CAMERA_TYPE::HEAVY_CAMERA) Camera.type = CAMERA_TYPE::COMBAT_CAMERA; if (TrInput & IN_ACTION) { - if (!GetAmmo(Lara.gunType)) + if (!*GetAmmo(Lara.gunType)) { - Lara.requestGunType = Objects[ID_PISTOLS_ITEM].loaded; + Lara.requestGunType = (Objects[ID_PISTOLS_ITEM].loaded == true) ? WEAPON_PISTOLS : WEAPON_NONE; return; } } @@ -549,7 +537,7 @@ void LaraGun() case LG_HANDS_BUSY: if (Lara.gunType == WEAPON_FLARE) { - if (Lara.meshPtrs[HAND_L] == Meshes[Objects[ID_FLARE_ANIM].meshIndex + HAND_L * 2]) + if (CHECK_LARA_MESHES(ID_FLARE_ANIM, HAND_L)) { Lara.flareControlLeft = (g_LaraExtra.Vehicle != NO_ITEM || CheckForHoldingState(LaraItem->currentAnimState)); DoFlareInHand(Lara.flareAge); @@ -623,7 +611,7 @@ int WeaponObjectMesh(int weaponType) switch (weaponType) { case WEAPON_REVOLVER: - return ((g_LaraExtra.Weapons[WEAPON_REVOLVER].HasLasersight) != 0 ? ID_LARA_REVOLVER_LASER : ID_REVOLVER_ANIM); + return (g_LaraExtra.Weapons[WEAPON_REVOLVER].HasLasersight == true ? ID_LARA_REVOLVER_LASER : ID_REVOLVER_ANIM); case WEAPON_UZI: return ID_UZI_ANIM; @@ -635,7 +623,7 @@ int WeaponObjectMesh(int weaponType) return ID_HK_ANIM; case WEAPON_CROSSBOW: - return ((g_LaraExtra.Weapons[WEAPON_CROSSBOW].HasLasersight) != 0 ? ID_LARA_CROSSBOW_LASER : ID_CROSSBOW_ANIM); + return (g_LaraExtra.Weapons[WEAPON_CROSSBOW].HasLasersight == true ? ID_LARA_CROSSBOW_LASER : ID_CROSSBOW_ANIM); case WEAPON_GRENADE_LAUNCHER: return ID_GRENADE_ANIM; @@ -696,7 +684,7 @@ int FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles) pos.yPos = 0; pos.zPos = 0; - GetLaraJointPosition((PHD_VECTOR*)&pos, 11); + GetLaraJointPosition((PHD_VECTOR*)&pos, LJ_RHAND); short* ammo = GetAmmo(weaponType); if (!*ammo) return 0; @@ -708,9 +696,9 @@ int FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles) pos.xPos = src->pos.xPos; pos.yPos = src->pos.yPos - weapon->gunHeight; pos.zPos = src->pos.zPos; - int r = (int)((GetRandomControl() - 16384) * weapon->shotAccuracy) / 65536; + int r = (int)((GetRandomControl() - 0x4000) * weapon->shotAccuracy) / 0x10000; pos.xRot = angles[1] + (short)r; - r = (int)((GetRandomControl() - 16384) * weapon->shotAccuracy) / 65536; + r = (int)((GetRandomControl() - 0x4000) * weapon->shotAccuracy) / 0x10000; pos.yRot = angles[0] + (short)r; pos.zRot = 0; @@ -751,9 +739,9 @@ int FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles) { GAME_VECTOR vDest; - vDest.x = vSrc.x + ((*(MatrixPtr + M20) * weapon->targetDist) >> W2V_SHIFT); - vDest.y = vSrc.y + ((*(MatrixPtr + M21) * weapon->targetDist) >> W2V_SHIFT); - vDest.z = vSrc.z + ((*(MatrixPtr + M22) * weapon->targetDist) >> W2V_SHIFT); + vDest.x = vSrc.x + ((MatrixPtr[M20] * weapon->targetDist) >> W2V_SHIFT); + vDest.y = vSrc.y + ((MatrixPtr[M21] * weapon->targetDist) >> W2V_SHIFT); + vDest.z = vSrc.z + ((MatrixPtr[M22] * weapon->targetDist) >> W2V_SHIFT); GetTargetOnLOS(&vSrc, &vDest, 0, 1); @@ -765,16 +753,13 @@ int FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles) GAME_VECTOR vDest; - vDest.x = vSrc.x + ((*(MatrixPtr + M20) * bestDistance) >> W2V_SHIFT); - vDest.y = vSrc.y + ((*(MatrixPtr + M21) * bestDistance) >> W2V_SHIFT); - vDest.z = vSrc.z + ((*(MatrixPtr + M22) * bestDistance) >> W2V_SHIFT); + vDest.x = vSrc.x + ((MatrixPtr[M20] * bestDistance) >> W2V_SHIFT); + vDest.y = vSrc.y + ((MatrixPtr[M21] * bestDistance) >> W2V_SHIFT); + vDest.z = vSrc.z + ((MatrixPtr[M22] * bestDistance) >> W2V_SHIFT); // TODO: enable it when the slot is created ! - /*if (target->objectNumber != ID_SHIVA && target->objectNumber != ID_ARMY_WINSTON && target->objectNumber != ID_LONDONBOSS && (target->objectNumber != ID_TRIBEBOSS || TribeBossShieldOn == false)) // Hit TRIBEBOSS's shield if on. - { - HitTarget(target, &vDest, weapon->damage, 0); - } - else if (target->objectNumber == ID_TRIBEBOSS) + /* + if (target->objectNumber == ID_TRIBEBOSS) { long dx, dy, dz; @@ -816,15 +801,17 @@ int FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles) return 1; } + + return 0; } void find_target_point(ITEM_INFO* item, GAME_VECTOR* target) { short* bounds = GetBestFrame(item); - int x = (int)((*(bounds + 0) + *(bounds + 1)) / 2); - int y = (int)(*(bounds + 2) + (*(bounds + 3) - *(bounds + 2)) / 3); - int z = (int)((*(bounds + 4) + *(bounds + 5)) / 2); + int x = (int)((bounds[0] + bounds[1]) / 2); + int y = (int)(bounds[2] + (bounds[3] - bounds[2]) / 3); + int z = (int)((bounds[4] + bounds[5]) / 2); int c = COS(item->pos.yRot); int s = SIN(item->pos.yRot); @@ -871,33 +858,33 @@ void LaraTargetInfo(WEAPON_INFO* weapon) if (LOS(&pos, &targetPoint)) { if (angles[0] >= weapon->lockAngles[0] - && angles[0] <= weapon->lockAngles[1] - && angles[1] >= weapon->lockAngles[2] - && angles[1] <= weapon->lockAngles[3]) + && angles[0] <= weapon->lockAngles[1] + && angles[1] >= weapon->lockAngles[2] + && angles[1] <= weapon->lockAngles[3]) { - Lara.rightArm.lock = 1; - Lara.leftArm.lock = 1; + Lara.rightArm.lock = true; + Lara.leftArm.lock = true; Lara.targetAngles[0] = angles[0]; Lara.targetAngles[1] = angles[1]; return; } if (Lara.leftArm.lock - && (angles[0] < weapon->leftAngles[0] - || angles[0] > weapon->leftAngles[1] - || angles[1] < weapon->leftAngles[2] - || angles[1] > weapon->leftAngles[3])) + && (angles[0] < weapon->leftAngles[0] + || angles[0] > weapon->leftAngles[1] + || angles[1] < weapon->leftAngles[2] + || angles[1] > weapon->leftAngles[3])) { - Lara.leftArm.lock = 0; + Lara.leftArm.lock = false; } if (Lara.rightArm.lock - && (angles[0] < weapon->rightAngles[0] - || angles[0] > weapon->rightAngles[1] - || angles[1] < weapon->rightAngles[2] - || angles[1] > weapon->rightAngles[3])) + && (angles[0] < weapon->rightAngles[0] + || angles[0] > weapon->rightAngles[1] + || angles[1] < weapon->rightAngles[2] + || angles[1] > weapon->rightAngles[3])) { - Lara.rightArm.lock = 0; + Lara.rightArm.lock = false; Lara.targetAngles[0] = angles[0]; Lara.targetAngles[1] = angles[1]; return; @@ -905,8 +892,8 @@ void LaraTargetInfo(WEAPON_INFO* weapon) } else { - Lara.rightArm.lock = 0; - Lara.leftArm.lock = 0; + Lara.rightArm.lock = false; + Lara.leftArm.lock = false; } Lara.targetAngles[0] = angles[0]; diff --git a/TR5Main/Game/laraflar.cpp b/TR5Main/Game/laraflar.cpp index da789c5f6..1ed2884d6 100644 --- a/TR5Main/Game/laraflar.cpp +++ b/TR5Main/Game/laraflar.cpp @@ -91,11 +91,11 @@ void ready_flare()//4A3E4(<), 4A848(<) (F) void undraw_flare_meshes() { - Lara.meshPtrs[LM_LHAND] = Meshes[Objects[ID_LARA].meshIndex + 104]; + LARA_MESHES(ID_LARA, HAND_L); } void draw_flare_meshes()//4A394(<), 4A7F8(<) (F) { - Lara.meshPtrs[LM_LHAND] = Meshes[Objects[ID_FLARE_ANIM].meshIndex + 104]; + LARA_MESHES(ID_FLARE_ANIM, HAND_L); } void undraw_flare()//4A108, 4A56C diff --git a/TR5Main/Game/laramisc.cpp b/TR5Main/Game/laramisc.cpp index 3e0a43c13..1321885f6 100644 --- a/TR5Main/Game/laramisc.cpp +++ b/TR5Main/Game/laramisc.cpp @@ -561,7 +561,7 @@ void LaraInitialiseMeshes()//4A684, 4AAE8 (F) { for (int i = 0; i < 15; i++) { - Lara.meshPtrs[i] = Meshes[Objects[ID_LARA].meshIndex + 2 * i] = Meshes[Objects[ID_LARA_SKIN].meshIndex + 2 * i]; + INIT_LARA_MESHES(i, ID_LARA, ID_LARA_SKIN); } /*if (gfCurrentLevel >= LVL5_GALLOWS_TREE && gfCurrentLevel <= LVL5_OLD_MILL) diff --git a/TR5Main/Global/constants.h b/TR5Main/Global/constants.h index e36c485b8..05007f100 100644 --- a/TR5Main/Global/constants.h +++ b/TR5Main/Global/constants.h @@ -1,5 +1,8 @@ #pragma once +#define HAIR_SEGMENTS 7 // only classic lara (young lara have more segments !) +#define DOUBLE_HAIR_SEGMENTS 14 + #define TEXTURE_PAGE (256 * 256) #define W2V_SHIFT 14 // Shift scale of View.Frame to World.Frame @@ -42,6 +45,22 @@ #define MAX_DRAW_STATICS 16384 #define MAX_BONES 32 #define MAX_SPRITES 16384 +#define MAX_SPARKS 1024 // 128 normally +#define MAX_SPARKS_FIRE 20 +#define MAX_FIRE_LIST 32 // FIRE_SPARKS list +#define MAX_SPARKS_SMOKE 64 +#define MAX_SPARKS_BLOOD 64 +#define MAX_GUNSHELL 24 +#define MAX_GUNFLASH 6 +#define MAX_DRIPS 32 +#define MAX_BUBBLES 40 +#define MAX_DYNAMICS 64 +#define MAX_SPLASH 4 +#define MAX_RIPPLES 32 +#define MAX_CAMERA 18 +#define MAX_SHOCKWAVE 16 +#define MAX_EFFECTS 100 +#define MAX_DEBRIS 256 #define NO_ROOM 0xFF #define NO_HEIGHT (-0x7F00) #define NUM_PICKUPS 64 diff --git a/TR5Main/Global/macros.h b/TR5Main/Global/macros.h index 3cf59a817..f83450c9e 100644 --- a/TR5Main/Global/macros.h +++ b/TR5Main/Global/macros.h @@ -11,4 +11,9 @@ #define ADD_PTR(p, t, n) p = (t*)((char*)(p) + (ptrdiff_t)(n)); -#define ZONE(A) (((A) >> (WALL_SIZE - 2)) - 1) \ No newline at end of file +#define ZONE(A) (((A) >> (WALL_SIZE - 2)) - 1) + +#define MESHES(slot, mesh) Meshes[Objects[slot].meshIndex + mesh * 2] +#define LARA_MESHES(slot, mesh) Lara.meshPtrs[mesh] = MESHES(slot, mesh) +#define CHECK_LARA_MESHES(slot, mesh) Lara.meshPtrs[mesh] == MESHES(slot, mesh) +#define INIT_LARA_MESHES(mesh, to, from) Lara.meshPtrs[mesh] = LARA_MESHES(to, mesh) = LARA_MESHES(from, mesh) \ No newline at end of file diff --git a/TR5Main/Global/types.h b/TR5Main/Global/types.h index ba0aee05c..400f9ad77 100644 --- a/TR5Main/Global/types.h +++ b/TR5Main/Global/types.h @@ -122,6 +122,7 @@ typedef struct item_light_t typedef struct hair_struct { PHD_3DPOS pos; + //PHD_VECTOR hvel; byte unknown[24]; } HAIR_STRUCT; @@ -156,10 +157,10 @@ typedef struct ai_info_t } AI_INFO; typedef struct bite_info_t { // Offset into given Mesh - int x; // where Baddie kicks off Bite Effect - int y; - int z; - int meshNum; + int x; // where Baddie kicks off Bite Effect + int y; + int z; + int meshNum; } BITE_INFO; typedef struct lot_info_t diff --git a/TR5Main/Global/vars.h b/TR5Main/Global/vars.h index c29e40a75..781bc22ca 100644 --- a/TR5Main/Global/vars.h +++ b/TR5Main/Global/vars.h @@ -2,6 +2,8 @@ #include "..\Game\sound.h" + + #define Camera VAR_U_(0x00EEF940, CAMERA_INFO) #define ForcedFixedCamera VAR_U_(0x00EEFA20, GAME_VECTOR) #define UseForcedFixedCamera VAR_U_(0x00EEFA50, char) @@ -53,7 +55,7 @@ #define LaraItem VAR_U_(0x00E5BF08, ITEM_INFO*) #define Lara VAR_U_(0x00E5BD60, LARA_INFO) #define LaraDrawType VAR_U_(0x00EEEAD0, char) -#define Hairs ARRAY_(0x00E5C000, HAIR_STRUCT, [14]) +#define Hairs ARRAY_(0x00E5C000, HAIR_STRUCT, [DOUBLE_HAIR_SEGMENTS]) #define gfNumMips VAR_U_(0x0051CE37, char) #define Frames VAR_U_(0x00875174, short*) #define gfMips ARRAY_(0x00E5C2C0, char, [8]) @@ -109,14 +111,10 @@ #define nFrames VAR_U_(0x005082C4, int) #define GameStatus VAR_U_(0x00E5C2B0, int) #define GotLaraSpheres VAR_U_(0x00E51F2E, byte) -#define EffectRoutines ARRAY_(0x00507964, EFFECT_ROUTINE, [100]) +#define EffectRoutines ARRAY_(0x00507964, EFFECT_ROUTINE, [MAX_EFFECTS]) #define DashTimer VAR_U_(0x00E5BF04, short) #define LaraCollisionRoutines ARRAY_(0x005089A8, LARA_COLLISION_ROUTINE, [500]) #define LaraControlRoutines ARRAY_(0x0050877C, LARA_CONTROL_ROUTINE, [500]) -#define ShockWaves ARRAY_(0x00E4C1A0, SHOCKWAVE_STRUCT, [16]) -#define Bubbles ARRAY_(0x00E4D160, BUBBLE_STRUCT, [40]) -#define Ripples ARRAY_(0x00E5C600, RIPPLE_STRUCT, [32]) -#define Blood ARRAY_(0x00E4C9C0, BLOOD_STRUCT, [32]) #define CurrentFOV VAR_U_(0x00E4F504, short) #define SpotCam ARRAY_(0x00E4F6C0, SPOTCAM, [64]) #define CurrentSplineCamera VAR_U_(0x00E4F500, short) @@ -147,20 +145,30 @@ #define Unknown_00E6CAE8 VAR_U_(0x00E6CAE8, int) #define PhdWindowXmax VAR_U_(0x0055D218, short) #define PhdWindowYmax VAR_U_(0x0055D240, short) -#define Fires ARRAY_(0x00E4C7A0, FIRE_LIST, [32]) -#define Dynamics ARRAY_(0x00E6C3E0, DYNAMIC, [64]) +#define Fires ARRAY_(0x00E4C7A0, FIRE_LIST, [MAX_FIRE_LIST]) +#define Dynamics ARRAY_(0x00E6C3E0, DYNAMIC, [MAX_DYNAMICS]) #define NumDynamics VAR_U_(0x00E6D82C, int) #define Sprites VAR_U_(0x008751B4, SPRITE*) -#define FireSparks ARRAY_(0x00E4CE40, FIRE_SPARKS, [20]) +#define FireSparks ARRAY_(0x00E4CE40, FIRE_SPARKS, [MAX_SPARKS_FIRE]) #define NextFreeFireSpark VAR_U_(0x0050A17C, short) -#define SmokeSparks ARRAY_(0x00E4B940, SMOKE_SPARKS, [32]) -#define Blood ARRAY_(0x00E4C9C0, BLOOD_STRUCT, [32]) -#define GunShells ARRAY_(0x00E4BEC0, GUNSHELL_STRUCT, [24]) -#define Sparks ARRAY_(0x00E5F380, SPARKS, [128]) -#define Drips ARRAY_(0x00E4D740, DRIP_STRUCT, [32]) -#define Bubbles ARRAY_(0x00E4D160, BUBBLE_STRUCT, [40]) -#define Splashes ARRAY_(0x00E6CA00, SPLASH_STRUCT, [4]) -#define Ripples ARRAY_(0x00E5C600, RIPPLE_STRUCT, [32]) +#define SmokeSparks ARRAY_(0x00E4B940, SMOKE_SPARKS, [MAX_SPARKS_SMOKE]) +#define Blood ARRAY_(0x00E4C9C0, BLOOD_STRUCT, [MAX_SPARKS_BLOOD]) +#define GunShells ARRAY_(0x00E4BEC0, GUNSHELL_STRUCT, [MAX_GUNSHELL]) +#define GunFlashes ARRAY_(0x00E4D660, GUNFLASH_STRUCT, [MAX_GUNFLASH]) +#define Sparks ARRAY_(0x00E5F380, SPARKS, [MAX_SPARKS]) +#define Drips ARRAY_(0x00E4D740, DRIP_STRUCT, [MAX_DRIPS]) +#define Bubbles ARRAY_(0x00E4D160, BUBBLE_STRUCT, [MAX_BUBBLES]) +#define Splashes ARRAY_(0x00E6CA00, SPLASH_STRUCT, [MAX_SPLASH]) +#define Ripples ARRAY_(0x00E5C600, RIPPLE_STRUCT, [MAX_RIPPLES]) +#define ShockWaves ARRAY_(0x00E4C1A0, SHOCKWAVE_STRUCT, [MAX_SHOCKWAVE]) +#define NextFireSpark VAR_U_(0x0050A17C, int) +#define NextSmokeSpark VAR_U_(0x0051D084, int) +#define NextGunShell VAR_U_(0x0051D08C, int) +#define NextBubble VAR_U_(0x0051D090, int) +#define NextDrip VAR_U_(0x0051D094, int) +#define NextDebris VAR_U_(0x0051CA8C, int) +#define NextBlood VAR_U_(0x0051D088, int) +#define NextItem VAR_U_(0x00EEF044, short) #define SkyPos1 VAR_U_(0x00E6E4B0, short) #define SkyPos2 VAR_U_(0x00E6D73E, short) #define SkyVelocity1 VAR_U_(0x00E5C276, signed char) @@ -213,7 +221,7 @@ #define SmashedMeshCount VAR_U_(0x0051CA5C, short) #define SmashedMesh ARRAY_(0x00EEF8C0, MESH_INFO*, [16]) #define SmashedMeshRoom ARRAY_(0x00EEF480, short, [16]) -#define Debris ARRAY_(0x00E8CAC0, DEBRIS_STRUCT, [256]) +#define Debris ARRAY_(0x00E8CAC0, DEBRIS_STRUCT, [MAX_DEBRIS]) #define SniperCameraActive VAR_U_(0x0051CA1D, byte) #define BinocularRange VAR_U_(0x0051CA30, int) #define BinocularOn VAR_U_(0x0051CA34, int) @@ -262,15 +270,15 @@ #define FirstCamera VAR_U_(0x00E51F24, short) #define LastCamera VAR_U_(0x00E4F6AC, short) #define CurrentCameraCnt VAR_U_(0x00E4EAA0, int) -#define CameraXposition ARRAY_(0x00E4F440, int, [18]) -#define CameraYposition ARRAY_(0x00E4F600, int, [18]) -#define CameraZposition ARRAY_(0x00E4F540, int, [18]) -#define CameraXtarget ARRAY_(0x00E4F3E0, int, [18]) -#define CameraYtarget ARRAY_(0x00E51EC0, int, [18]) -#define CameraZtarget ARRAY_(0x00E4F5A0, int, [18]) -#define CameraRoll ARRAY_(0x00E4F4A0, int, [18]) -#define CameraFOV ARRAY_(0x00E4F380, int, [18]) -#define CameraSpeed ARRAY_(0x00E4F660, int, [18]) +#define CameraXposition ARRAY_(0x00E4F440, int, [MAX_CAMERA]) +#define CameraYposition ARRAY_(0x00E4F600, int, [MAX_CAMERA]) +#define CameraZposition ARRAY_(0x00E4F540, int, [MAX_CAMERA]) +#define CameraXtarget ARRAY_(0x00E4F3E0, int, [MAX_CAMERA]) +#define CameraYtarget ARRAY_(0x00E51EC0, int, [MAX_CAMERA]) +#define CameraZtarget ARRAY_(0x00E4F5A0, int, [MAX_CAMERA]) +#define CameraRoll ARRAY_(0x00E4F4A0, int, [MAX_CAMERA]) +#define CameraFOV ARRAY_(0x00E4F380, int, [MAX_CAMERA]) +#define CameraSpeed ARRAY_(0x00E4F660, int, [MAX_CAMERA]) #define SpotcamDontDrawLara VAR_U_(0x0051D021, byte) #define QuakeCam VAR_U_(0x00E4F520, QUAKE_CAMERA) #define SplineFromCamera VAR_U_(0x00E4F3DC, int) @@ -278,6 +286,7 @@ #define PoisonFlag VAR_U_(0x00E5BF3E, byte) #define SplashSetup VAR_U_(0x00E6CAC0, SPLASH_SETUP) #define NullRotations ARRAY_(0x0051CD68, short, [12]) +#define FirstHair VAR_U_(0x00E5BF60, int) // JeepBaddieCollision #define Unk_0080DE1A VAR_U_(0x0080DE1A, short) diff --git a/TR5Main/Objects/dragon.cpp b/TR5Main/Objects/dragon.cpp index 31b614508..17de601cd 100644 --- a/TR5Main/Objects/dragon.cpp +++ b/TR5Main/Objects/dragon.cpp @@ -248,7 +248,7 @@ void DragonCollision(short itemNum, ITEM_INFO* laraitem, COLL_INFO* coll) Lara.gunStatus = LG_HANDS_BUSY; Lara.hitDirection = -1; - Lara.meshPtrs[HAND_R] = Meshes[Objects[ID_LARA_EXTRA_ANIMS].meshIndex + HAND_R]; + LARA_MESHES(ID_LARA_EXTRA_ANIMS, HAND_R); /* Do cinematic camera */ Camera.type = CINEMATIC_CAMERA; diff --git a/TR5Main/Objects/kayak.cpp b/TR5Main/Objects/kayak.cpp index ebc987c96..626e0e0ac 100644 --- a/TR5Main/Objects/kayak.cpp +++ b/TR5Main/Objects/kayak.cpp @@ -955,7 +955,7 @@ void KayakUserInput(ITEM_INFO* kayak, ITEM_INFO* lara, KAYAK_INFO* kinfo) short* tmp; tmp = Lara.meshPtrs[HAND_R]; - Lara.meshPtrs[HAND_R] = Meshes[Objects[ID_KAYAK_LARA_ANIMS].meshIndex + HAND_R]; + LARA_MESHES(ID_KAYAK_LARA_ANIMS, HAND_R); Meshes[Objects[ID_KAYAK_LARA_ANIMS].meshIndex + HAND_R] = tmp; lara->meshBits &= ~LARA_LEG_BITS; diff --git a/TR5Main/Objects/minecart.cpp b/TR5Main/Objects/minecart.cpp index 5a949aae5..93ad112a1 100644 --- a/TR5Main/Objects/minecart.cpp +++ b/TR5Main/Objects/minecart.cpp @@ -623,8 +623,8 @@ static void DoUserInput(ITEM_INFO* v, ITEM_INFO* l, CART_INFO* cart) short* tmp; tmp = Lara.meshPtrs[HAND_R]; - - Lara.meshPtrs[HAND_R] = Meshes[Objects[ID_MINECART_ANIMS].meshIndex + HAND_R]; + + LARA_MESHES(ID_MINECART_ANIMS, HAND_R); Meshes[Objects[ID_MINECART_ANIMS].meshIndex + HAND_R] = tmp; cart->Flags &= ~CF_MESH; diff --git a/TR5Main/Specific/setup.cpp b/TR5Main/Specific/setup.cpp index d467afd77..2c2b6ecb9 100644 --- a/TR5Main/Specific/setup.cpp +++ b/TR5Main/Specific/setup.cpp @@ -72,10 +72,10 @@ void NewObjects() obj->saveAnim = true; obj->saveFlags = true; - Bones[obj->boneIndex + 192] |= ROT_Z; - Bones[obj->boneIndex + 192] |= ROT_Y; - Bones[obj->boneIndex + 208] |= ROT_Z; - Bones[obj->boneIndex + 208] |= ROT_Y; + Bones[obj->boneIndex + 48 * 4] |= ROT_Z; + Bones[obj->boneIndex + 48 * 4] |= ROT_Y; + Bones[obj->boneIndex + 52 * 4] |= ROT_Z; + Bones[obj->boneIndex + 52 * 4] |= ROT_Y; } obj = &Objects[ID_BAT]; @@ -165,14 +165,14 @@ void NewObjects() obj->saveAnim = true; obj->saveFlags = true; - Bones[obj->boneIndex + 112] |= ROT_Y; - Bones[obj->boneIndex + 112] |= ROT_X; - Bones[obj->boneIndex + 352] |= ROT_Y; - Bones[obj->boneIndex + 352] |= ROT_X; + Bones[obj->boneIndex + 28 * 4] |= ROT_Y; + Bones[obj->boneIndex + 28 * 4] |= ROT_X; + Bones[obj->boneIndex + 88 * 4] |= ROT_Y; + Bones[obj->boneIndex + 88 * 4] |= ROT_X; - Meshes[obj->meshIndex + 36] = Meshes[Objects[ID_MESHSWAP1].meshIndex + 32]; - Meshes[obj->meshIndex + 60] = Meshes[Objects[ID_MESHSWAP1].meshIndex + 56]; - Meshes[obj->meshIndex + 36] = Meshes[Objects[ID_MESHSWAP1].meshIndex + 22]; + Meshes[obj->meshIndex + 18 * 2] = Meshes[Objects[ID_MESHSWAP1].meshIndex + 16 * 2]; + Meshes[obj->meshIndex + 30 * 2] = Meshes[Objects[ID_MESHSWAP1].meshIndex + 28 * 2]; + Meshes[obj->meshIndex + 18 * 2] = Meshes[Objects[ID_MESHSWAP1].meshIndex + 11 * 2]; } obj = &Objects[ID_BADDY2]; @@ -191,10 +191,10 @@ void NewObjects() obj->saveAnim = true; obj->saveFlags = true; - Bones[obj->boneIndex + 112] |= ROT_Y; - Bones[obj->boneIndex + 112] |= ROT_X; - Bones[obj->boneIndex + 352] |= ROT_Y; - Bones[obj->boneIndex + 352] |= ROT_X; + Bones[obj->boneIndex + 28 * 4] |= ROT_Y; + Bones[obj->boneIndex + 28 * 4] |= ROT_X; + Bones[obj->boneIndex + 88 * 4] |= ROT_Y; + Bones[obj->boneIndex + 88 * 4] |= ROT_X; } obj = &Objects[ID_SAS_CAIRO]; @@ -215,8 +215,8 @@ void NewObjects() Bones[obj->boneIndex] |= ROT_Y; Bones[obj->boneIndex] |= ROT_X; - Bones[obj->boneIndex + 112] |= ROT_Y; - Bones[obj->boneIndex + 112] |= ROT_X; + Bones[obj->boneIndex + 28 * 4] |= ROT_Y; + Bones[obj->boneIndex + 28 * 4] |= ROT_X; } obj = &Objects[ID_MUMMY]; @@ -234,9 +234,9 @@ void NewObjects() obj->saveAnim = true; obj->saveFlags = true; - Bones[obj->boneIndex + 112] |= ROT_Y; - Bones[obj->boneIndex + 112] |= ROT_X; - Bones[obj->boneIndex + 288] |= ROT_Y; + Bones[obj->boneIndex + 28 * 4] |= ROT_Y; + Bones[obj->boneIndex + 28 * 4] |= ROT_X; + Bones[obj->boneIndex + 72 * 4] |= ROT_Y; } obj = &Objects[ID_QUAD]; @@ -913,9 +913,9 @@ void NewObjects() Bones[obj->boneIndex + 20 * 4] |= ROT_X | ROT_Y; // TODO: check if constants are byte, short or int - Meshes[obj->meshIndex + 124] = Meshes[Objects[ID_MESHSWAP2].meshIndex + 120]; - Meshes[obj->meshIndex + 148] = Meshes[Objects[ID_MESHSWAP2].meshIndex + 144]; - Meshes[obj->meshIndex + 172] = Meshes[Objects[ID_MESHSWAP2].meshIndex + 168]; + Meshes[obj->meshIndex + 60 * 2] = Meshes[Objects[ID_MESHSWAP2].meshIndex + 60 * 2]; + Meshes[obj->meshIndex + 72 * 2] = Meshes[Objects[ID_MESHSWAP2].meshIndex + 72 * 2]; + Meshes[obj->meshIndex + 84 * 2] = Meshes[Objects[ID_MESHSWAP2].meshIndex + 84 * 2]; } obj = &Objects[ID_CROCODILE]; @@ -2939,6 +2939,67 @@ void TrapObjects() } } +void InitialiseHair() +{ + int* bone; + + FirstHair = 1; + bone = &Bones[Objects[ID_HAIR].boneIndex]; + + Hairs[0].pos.yRot = 0; + Hairs[0].pos.xRot = -0x4000; + + // normal hair + for (int i = 1; i < HAIR_SEGMENTS; i++, bone += 4) + { + Hairs[i].pos.xPos = *(bone + 1); + Hairs[i].pos.yPos = *(bone + 2); + Hairs[i].pos.zPos = *(bone + 3); + Hairs[i].pos.xRot = -0x4000; + Hairs[i].pos.yRot = 0; + Hairs[i].pos.zRot = 0; + //Hairs[i].hvel.x = 0; + //Hairs[i].hvel.y = 0; + //Hairs[i].hvel.z = 0; + } +} + +void InitialiseSpecialEffects() +{ + int i; + SPARKS* sptr; + + memset(&Sparks, 0, MAX_SPARKS * sizeof(SPARKS)); + memset(&FireSparks, 0, MAX_SPARKS_FIRE * sizeof(FIRE_SPARKS)); + memset(&SmokeSparks, 0, MAX_SPARKS_SMOKE * sizeof(SMOKE_SPARKS)); + memset(&GunShells, 0, MAX_GUNSHELL * sizeof(GUNSHELL_STRUCT)); + memset(&GunFlashes, 0, (MAX_GUNFLASH * sizeof(GUNFLASH_STRUCT)) - sizeof(int)); // the size is 200 on IDA (without -4 it's 204 ??) + memset(&Debris, 0, MAX_DEBRIS * sizeof(DEBRIS_STRUCT)); + memset(&Blood, 0, MAX_SPARKS_BLOOD * sizeof(BLOOD_STRUCT)); + memset(&Splashes, 0, MAX_SPLASH * sizeof(SPLASH_STRUCT)); + memset(&Ripples, 0, MAX_RIPPLES * sizeof(RIPPLE_STRUCT)); + memset(&Bubbles, 0, MAX_BUBBLES * sizeof(BUBBLE_STRUCT)); + memset(&Drips, 0, MAX_DRIPS * sizeof(DRIP_STRUCT)); + memset(&ShockWaves, 0, MAX_SHOCKWAVE * sizeof(SHOCKWAVE_STRUCT)); + + sptr = &Sparks[0]; + for (i = 0; i < MAX_SPARKS; i++) + { + sptr->on = false; + sptr->dynamic = -1; + sptr++; + } + + NextFireSpark = 1; + NextSmokeSpark = 0; + NextGunShell = 0; + NextBubble = 0; + NextDrip = 0; + NextDebris = 0; + NextBlood = 0; + NextItem = NO_ITEM; +} + void PickupObjects() { OBJECT_INFO* obj; @@ -3569,14 +3630,14 @@ void InitialiseObjects() // Reset MIP flag so we can reuse slots //for (short i = 0; i < ID_NUMBER_OBJECTS; i++) // Objects[i].objectMip = NULL; - + // New objects imported from old TRs NewObjects(); // User defined objects CustomObjects(); - InitialiseHairs(); + InitialiseHair(); InitialiseSpecialEffects(); NumRPickups = 0; diff --git a/TR5Main/Specific/setup.h b/TR5Main/Specific/setup.h index 12adecbbf..b6e18f3b4 100644 --- a/TR5Main/Specific/setup.h +++ b/TR5Main/Specific/setup.h @@ -2,11 +2,11 @@ #include "..\Global\global.h" -void BaddyObjects(); //#define BaddyObjects ((void (__cdecl*)()) 0x004737C0) -void ObjectObjects(); //#define ObjectObjects ((void (__cdecl*)()) 0x00476360) -void TrapObjects(); //#define TrapObjects ((void (__cdecl*)()) 0x00475D40) -#define InitialiseHairs ((void (__cdecl*)()) 0x00438BE0) -#define InitialiseSpecialEffects ((void (__cdecl*)()) 0x0043D8B0) +void BaddyObjects(); +void ObjectObjects(); +void TrapObjects(); +void InitialiseHair(); +void InitialiseSpecialEffects(); void CustomObjects(); void InitialiseObjects();