2018-08-19 09:46:58 +02:00
|
|
|
#include "control.h"
|
|
|
|
|
|
|
|
#include "..\Global\global.h"
|
2018-10-30 12:40:30 +01:00
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
#include "pickup.h"
|
|
|
|
#include "spotcam.h"
|
2019-11-21 07:43:34 +01:00
|
|
|
#include "Camera.h"
|
|
|
|
#include "Lara.h"
|
2018-08-19 09:46:58 +02:00
|
|
|
#include "hair.h"
|
|
|
|
#include "items.h"
|
|
|
|
#include "effect2.h"
|
|
|
|
#include "draw.h"
|
|
|
|
#include "inventory.h"
|
|
|
|
#include "gameflow.h"
|
|
|
|
#include "lot.h"
|
|
|
|
#include "pickup.h"
|
|
|
|
#include "draw.h"
|
|
|
|
#include "healt.h"
|
2018-09-03 21:08:40 +02:00
|
|
|
#include "savegame.h"
|
|
|
|
#include "sound.h"
|
2018-09-22 23:54:36 +02:00
|
|
|
#include "spotcam.h"
|
2019-11-20 11:24:36 +01:00
|
|
|
#include "box.h"
|
2019-11-01 08:35:01 +01:00
|
|
|
#include "objects.h"
|
2019-11-09 09:55:56 +01:00
|
|
|
#include "switch.h"
|
2019-12-01 08:13:19 +01:00
|
|
|
#include "laramisc.h"
|
2019-12-07 08:36:13 +01:00
|
|
|
#include "rope.h"
|
2019-12-22 00:20:10 +01:00
|
|
|
#include "tomb4fx.h"
|
|
|
|
#include "traps.h"
|
|
|
|
#include "effects.h"
|
2020-01-01 11:45:09 +01:00
|
|
|
#include "sphere.h"
|
2020-01-07 17:33:13 -03:00
|
|
|
#include "debris.h"
|
|
|
|
#include "larafire.h"
|
2020-01-30 11:24:12 +01:00
|
|
|
#include "..\Objects\oldobjects.h"
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2020-01-05 18:48:16 +01:00
|
|
|
#include "footprint.h"
|
2018-08-19 09:46:58 +02:00
|
|
|
#include "..\Specific\roomload.h"
|
|
|
|
#include "..\Specific\input.h"
|
|
|
|
#include "..\Specific\init.h"
|
|
|
|
#include "..\Specific\winmain.h"
|
|
|
|
|
|
|
|
#include <process.h>
|
|
|
|
#include <stdio.h>
|
2020-03-29 10:38:29 +02:00
|
|
|
#include "..\Renderer\Renderer11.h"
|
2020-04-01 13:09:14 +02:00
|
|
|
#include "../Specific/setup.h"
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
int KeyTriggerActive;
|
2019-12-27 23:54:40 -03:00
|
|
|
int number_los_rooms;
|
|
|
|
short los_rooms[20];
|
2020-01-07 17:33:13 -03:00
|
|
|
int ClosestItem;
|
|
|
|
int ClosestDist;
|
|
|
|
PHD_VECTOR ClosestCoord;
|
|
|
|
int rand_1 = -747505337;
|
|
|
|
int rand_2 = -747505337;
|
2020-01-08 17:13:44 +01:00
|
|
|
int RumbleTimer = 0;
|
|
|
|
int InGameCnt = 0;
|
2020-01-16 19:14:35 +01:00
|
|
|
byte IsAtmospherePlaying = 0;
|
|
|
|
byte FlipStatus = 0;
|
|
|
|
int FlipStats[255];
|
|
|
|
int FlipMap[255];
|
2020-01-19 08:12:51 +01:00
|
|
|
bool InItemControlLoop;
|
|
|
|
short ItemNewRoomNo;
|
|
|
|
short ItemNewRooms[512];
|
|
|
|
short NextFxActive;
|
|
|
|
short NextFxFree;
|
|
|
|
short NextItemActive;
|
|
|
|
short NextItemFree;
|
2020-04-01 13:09:14 +02:00
|
|
|
short* TriggerIndex;
|
2020-04-28 12:24:10 -03:00
|
|
|
string LuaMessage;
|
2019-11-15 07:40:22 +01:00
|
|
|
|
2018-09-22 23:54:36 +02:00
|
|
|
extern GameFlow* g_GameFlow;
|
2018-09-23 12:01:07 +02:00
|
|
|
extern GameScript* g_GameScript;
|
2019-11-18 07:48:35 +01:00
|
|
|
extern Inventory* g_Inventory;
|
2019-12-22 00:20:10 +01:00
|
|
|
extern int SplashCount;
|
2020-01-08 13:25:42 +01:00
|
|
|
extern void(*effect_routines[59])(ITEM_INFO* item);
|
|
|
|
extern short FXType;
|
2020-01-08 17:13:44 +01:00
|
|
|
extern vector<AudioTrack> g_AudioTracks;
|
|
|
|
extern std::deque<FOOTPRINT_STRUCT> footprints;
|
2018-09-04 13:24:50 +02:00
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
GAME_STATUS ControlPhase(int numFrames, int demoMode)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
2018-09-22 23:54:36 +02:00
|
|
|
GameScriptLevel* level = g_GameFlow->GetLevel(CurrentLevel);
|
2018-09-05 23:56:39 +02:00
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
RegeneratePickups();
|
|
|
|
|
|
|
|
if (numFrames > 10)
|
|
|
|
numFrames = 10;
|
|
|
|
|
|
|
|
if (TrackCameraInit)
|
2019-04-30 12:56:27 +02:00
|
|
|
UseSpotCam = false;
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2019-04-30 12:56:27 +02:00
|
|
|
SetDebounce = true;
|
2018-08-19 09:46:58 +02:00
|
|
|
|
|
|
|
for (FramesCount += numFrames; FramesCount > 0; FramesCount -= 2)
|
|
|
|
{
|
|
|
|
GlobalCounter++;
|
|
|
|
|
2018-08-20 21:32:19 +02:00
|
|
|
UpdateSky();
|
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
// Poll the keyboard and update input variables
|
2019-05-31 21:45:13 +02:00
|
|
|
if (CurrentLevel != 0)
|
|
|
|
{
|
|
|
|
if (S_UpdateInput() == -1)
|
|
|
|
return GAME_STATUS_NONE;
|
|
|
|
}
|
|
|
|
|
2020-04-28 12:24:10 -03:00
|
|
|
if ((TrInput & IN_SPRINT) == IN_SPRINT)
|
|
|
|
{
|
|
|
|
g_GameScript->ExecuteScript("script.lua", &LuaMessage);
|
|
|
|
}
|
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
// Has Lara control been disabled?
|
2019-05-31 21:45:13 +02:00
|
|
|
if (DisableLaraControl || CurrentLevel == 0)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
|
|
|
if (CurrentLevel != 0)
|
|
|
|
DbInput = 0;
|
|
|
|
TrInput &= 0x200;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If cutscene has been triggered then clear input
|
|
|
|
if (CutSeqTriggered)
|
|
|
|
TrInput = 0;
|
|
|
|
|
|
|
|
// Does the player want to enter inventory?
|
2019-04-30 12:56:27 +02:00
|
|
|
SetDebounce = false;
|
2018-11-01 22:45:59 +01:00
|
|
|
if (CurrentLevel != 0 && !g_Renderer->IsFading())
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
2019-11-18 07:48:35 +01:00
|
|
|
if ((DbInput & IN_DESELECT || g_Inventory->GetEnterObject() != NO_ITEM) && !CutSeqTriggered && LaraItem->hitPoints > 0)
|
2018-09-08 21:30:48 +02:00
|
|
|
{
|
2018-09-07 18:34:18 +02:00
|
|
|
// Stop all sounds
|
2020-01-13 20:01:28 +01:00
|
|
|
SOUND_Stop();
|
2019-11-27 15:12:35 +01:00
|
|
|
int inventoryResult = g_Inventory->DoInventory();
|
2018-09-03 21:08:40 +02:00
|
|
|
switch (inventoryResult)
|
|
|
|
{
|
2019-04-26 15:10:32 +02:00
|
|
|
case INV_RESULT_LOAD_GAME:
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_LOAD_GAME;
|
2019-04-26 15:10:32 +02:00
|
|
|
case INV_RESULT_EXIT_TO_TILE:
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_EXIT_TO_TITLE;
|
2018-09-03 21:08:40 +02:00
|
|
|
}
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Has level been completed?
|
2019-05-31 21:45:13 +02:00
|
|
|
if (CurrentLevel != 0 && LevelComplete)
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_LEVEL_COMPLETED;
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
int oldInput = TrInput;
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Is Lara dead?
|
2019-05-31 21:45:13 +02:00
|
|
|
if (CurrentLevel != 0 && (Lara.deathCount > 300 || Lara.deathCount > 60 && TrInput))
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
int inventoryResult = g_Inventory->DoInventory();
|
2018-09-08 21:30:48 +02:00
|
|
|
switch (inventoryResult)
|
|
|
|
{
|
2019-04-26 15:10:32 +02:00
|
|
|
case INV_RESULT_NEW_GAME:
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_NEW_GAME;
|
2019-04-26 15:10:32 +02:00
|
|
|
case INV_RESULT_LOAD_GAME:
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_LOAD_GAME;
|
2019-04-26 15:10:32 +02:00
|
|
|
case INV_RESULT_EXIT_TO_TILE:
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_EXIT_TO_TITLE;
|
2018-09-08 21:30:48 +02:00
|
|
|
}
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (demoMode && TrInput == -1)
|
|
|
|
{
|
|
|
|
oldInput = 0;
|
|
|
|
TrInput = 0;
|
|
|
|
}
|
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
if (CurrentLevel == 0)
|
|
|
|
TrInput = 0;
|
|
|
|
|
2018-11-11 23:42:30 +01:00
|
|
|
// Handle lasersight and binocular
|
2019-05-31 21:45:13 +02:00
|
|
|
if (CurrentLevel != 0)
|
2018-11-11 11:16:37 +01:00
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
if (!(TrInput & IN_LOOK) || SniperCameraActive || UseSpotCam || TrackCameraInit ||
|
|
|
|
((LaraItem->currentAnimState != STATE_LARA_STOP || LaraItem->animNumber != ANIMATION_LARA_STAY_IDLE)
|
|
|
|
&& (!Lara.isDucked
|
|
|
|
|| TrInput & IN_DUCK
|
|
|
|
|| LaraItem->animNumber != ANIMATION_LARA_CROUCH_IDLE
|
|
|
|
|| LaraItem->goalAnimState != STATE_LARA_CROUCH_IDLE)))
|
2018-11-11 11:16:37 +01:00
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
if (BinocularRange == 0)
|
2018-11-11 11:16:37 +01:00
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
if (SniperCameraActive || UseSpotCam || TrackCameraInit)
|
|
|
|
TrInput &= ~IN_LOOK;
|
2018-11-11 11:16:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
if (LaserSight)
|
|
|
|
{
|
|
|
|
BinocularRange = 0;
|
|
|
|
LaserSight = false;
|
|
|
|
AlterFOV(ANGLE(80));
|
|
|
|
LaraItem->meshBits = 0xFFFFFFFF;
|
2020-01-06 08:11:15 +01:00
|
|
|
Lara.busy = false;
|
2019-05-31 21:45:13 +02:00
|
|
|
Camera.type = BinocularOldCamera;
|
2018-11-11 11:16:37 +01:00
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
Lara.headYrot = 0;
|
|
|
|
Lara.headXrot = 0;
|
2018-11-11 11:16:37 +01:00
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
Lara.torsoYrot = 0;
|
|
|
|
Lara.torsoXrot = 0;
|
|
|
|
|
|
|
|
Camera.bounce = 0;
|
|
|
|
BinocularOn = -8;
|
|
|
|
|
|
|
|
TrInput &= ~IN_LOOK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TrInput |= IN_LOOK;
|
|
|
|
}
|
|
|
|
}
|
2018-11-11 11:16:37 +01:00
|
|
|
|
|
|
|
Infrared = false;
|
2019-05-31 21:45:13 +02:00
|
|
|
}
|
|
|
|
else if (BinocularRange == 0)
|
2018-11-11 11:16:37 +01:00
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
if (Lara.gunStatus == LG_READY
|
|
|
|
&& ((Lara.gunType == WEAPON_REVOLVER && g_LaraExtra.Weapons[WEAPON_REVOLVER].HasLasersight)
|
|
|
|
|| (Lara.gunType == WEAPON_HK)
|
|
|
|
|| (Lara.gunType == WEAPON_CROSSBOW && g_LaraExtra.Weapons[WEAPON_CROSSBOW].HasLasersight)))
|
|
|
|
{
|
|
|
|
BinocularRange = 128;
|
|
|
|
BinocularOldCamera = Camera.oldType;
|
|
|
|
|
|
|
|
Lara.busy = true;
|
|
|
|
LaserSight = true;
|
|
|
|
|
|
|
|
/*if (!(gfLevelFlags & GF_LVOP_TRAIN))
|
|
|
|
InfraRed = TRUE;
|
|
|
|
else*
|
2019-11-21 07:43:34 +01:00
|
|
|
InfraRed = false;*/
|
2019-05-31 21:45:13 +02:00
|
|
|
Infrared = true;
|
|
|
|
}
|
2018-11-11 11:16:37 +01:00
|
|
|
else
|
2019-05-31 21:45:13 +02:00
|
|
|
Infrared = false;
|
2018-11-11 11:16:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
if (LaserSight)
|
|
|
|
{
|
|
|
|
/*if (!(gfLevelFlags & GF_LVOP_TRAIN))
|
|
|
|
InfraRed = TRUE;
|
|
|
|
else
|
2019-11-21 07:43:34 +01:00
|
|
|
InfraRed = false;*/
|
2019-05-31 21:45:13 +02:00
|
|
|
Infrared = true;
|
|
|
|
}
|
2018-11-11 11:16:37 +01:00
|
|
|
else
|
2019-05-31 21:45:13 +02:00
|
|
|
{
|
|
|
|
/*if ((gfLevelFlags & GF_LVOP_TRAIN) && (inputBusy & IN_ACTION))
|
|
|
|
InfraRed = TRUE;
|
|
|
|
else
|
2019-11-21 07:43:34 +01:00
|
|
|
InfraRed = false;*/
|
2019-05-31 21:45:13 +02:00
|
|
|
Infrared = false;
|
|
|
|
}
|
2018-11-11 11:16:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear dynamic lights
|
2019-12-22 00:20:10 +01:00
|
|
|
ClearDynamicLights();
|
2018-08-19 09:46:58 +02:00
|
|
|
ClearFires();
|
|
|
|
g_Renderer->ClearDynamicLights();
|
|
|
|
|
|
|
|
GotLaraSpheres = false;
|
2018-08-24 23:36:49 +02:00
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Update all items
|
2018-08-24 23:36:49 +02:00
|
|
|
InItemControlLoop = true;
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
short itemNum = NextItemActive;
|
2018-08-19 09:46:58 +02:00
|
|
|
while (itemNum != NO_ITEM)
|
|
|
|
{
|
2018-08-24 23:36:49 +02:00
|
|
|
ITEM_INFO* item = &Items[itemNum];
|
2019-11-27 15:12:35 +01:00
|
|
|
short nextItem = item->nextActive;
|
2018-08-24 23:36:49 +02:00
|
|
|
|
2018-11-18 22:53:38 +01:00
|
|
|
if (item->afterDeath <= 128)
|
2018-09-04 20:54:15 +02:00
|
|
|
{
|
|
|
|
if (Objects[item->objectNumber].control)
|
|
|
|
Objects[item->objectNumber].control(itemNum);
|
2020-01-18 21:55:04 +01:00
|
|
|
|
|
|
|
if (item->afterDeath < 128 && item->afterDeath > 0 && !(Wibble & 3))
|
|
|
|
item->afterDeath++;
|
|
|
|
if (item->afterDeath == 128)
|
|
|
|
KillItem(itemNum);
|
2018-09-04 20:54:15 +02:00
|
|
|
}
|
2018-08-24 23:36:49 +02:00
|
|
|
else
|
|
|
|
{
|
2018-09-04 20:54:15 +02:00
|
|
|
KillItem(itemNum);
|
2018-08-24 23:36:49 +02:00
|
|
|
}
|
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
itemNum = nextItem;
|
|
|
|
}
|
2018-08-24 23:36:49 +02:00
|
|
|
|
|
|
|
InItemControlLoop = false;
|
|
|
|
KillMoveItems();
|
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Update all effects
|
2018-08-24 23:36:49 +02:00
|
|
|
InItemControlLoop = true;
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
short fxNum = NextFxActive;
|
2018-08-24 23:36:49 +02:00
|
|
|
while (fxNum != NO_ITEM)
|
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
short nextFx = Effects[fxNum].nextActive;
|
2020-01-19 08:12:51 +01:00
|
|
|
FX_INFO* fx = &Effects[fxNum];
|
|
|
|
if (Objects[fx->objectNumber].control)
|
|
|
|
Objects[fx->objectNumber].control(fxNum);
|
2018-08-24 23:36:49 +02:00
|
|
|
fxNum = nextFx;
|
|
|
|
}
|
|
|
|
|
|
|
|
InItemControlLoop = false;
|
2019-12-16 10:26:00 -03:00
|
|
|
KillMoveEffects();
|
2018-08-24 23:36:49 +02:00
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Update some effect timers
|
2018-08-24 23:36:49 +02:00
|
|
|
if (SmokeCountL)
|
|
|
|
SmokeCountL--;
|
|
|
|
if (SmokeCountR)
|
|
|
|
SmokeCountR--;
|
|
|
|
if (SplashCount)
|
|
|
|
SplashCount--;
|
|
|
|
if (WeaponDelay)
|
|
|
|
WeaponDelay--;
|
2018-09-12 20:37:37 +02:00
|
|
|
if (WeaponEnemyTimer)
|
|
|
|
WeaponEnemyTimer--;
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
if (CurrentLevel != 0)
|
2018-11-08 23:05:25 +01:00
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
if (Lara.hasFired)
|
2018-11-08 23:05:25 +01:00
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
AlertNearbyGuards(LaraItem);
|
|
|
|
Lara.hasFired = false;
|
2018-11-08 23:05:25 +01:00
|
|
|
}
|
2019-05-31 21:45:13 +02:00
|
|
|
|
|
|
|
// Is Lara poisoned?
|
|
|
|
if (Lara.poisoned)
|
2018-11-08 23:05:25 +01:00
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
if (Lara.poisoned <= 4096)
|
2018-11-08 23:05:25 +01:00
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
if (Lara.dpoisoned)
|
|
|
|
++Lara.dpoisoned;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Lara.poisoned = 4096;
|
|
|
|
}
|
|
|
|
if ((gfLevelFlags & 0x80u) != 0 && !Lara.gassed)
|
|
|
|
{
|
|
|
|
if (Lara.dpoisoned)
|
|
|
|
{
|
|
|
|
Lara.dpoisoned -= 8;
|
|
|
|
if (Lara.dpoisoned < 0)
|
|
|
|
Lara.dpoisoned = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Lara.dpoisoned >= 256 && !(Wibble & 0xFF))
|
|
|
|
{
|
|
|
|
LaraItem->hitPoints -= Lara.poisoned >> (8 - Lara.gassed);
|
|
|
|
PoisonFlags = 16;
|
2018-11-08 23:05:25 +01:00
|
|
|
}
|
|
|
|
}
|
2018-09-09 15:39:18 +02:00
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
// Control Lara
|
|
|
|
InItemControlLoop = true;
|
|
|
|
Lara.skelebob = NULL;
|
2019-12-01 08:13:19 +01:00
|
|
|
LaraControl(Lara.itemNumber);
|
2019-05-31 21:45:13 +02:00
|
|
|
InItemControlLoop = false;
|
|
|
|
KillMoveItems();
|
|
|
|
|
|
|
|
// Update Lara's ponytails
|
|
|
|
HairControl(0, 0, 0);
|
|
|
|
if (level->LaraType == LARA_YOUNG)
|
|
|
|
HairControl(0, 1, 0);
|
|
|
|
}
|
2018-08-19 09:46:58 +02:00
|
|
|
|
|
|
|
if (UseSpotCam)
|
2018-09-07 18:34:18 +02:00
|
|
|
{
|
2018-09-08 20:54:13 +02:00
|
|
|
// Draw flyby cameras
|
2019-12-29 08:05:58 +01:00
|
|
|
//if (CurrentLevel != 0)
|
|
|
|
// g_Renderer->EnableCinematicBars(true);
|
2018-08-19 09:46:58 +02:00
|
|
|
CalculateSpotCameras();
|
2018-09-07 18:34:18 +02:00
|
|
|
}
|
2018-08-19 09:46:58 +02:00
|
|
|
else
|
2018-09-07 18:34:18 +02:00
|
|
|
{
|
2018-09-08 20:54:13 +02:00
|
|
|
// Do the standard camera
|
2019-12-29 08:05:58 +01:00
|
|
|
//g_Renderer->EnableCinematicBars(false);
|
2019-05-31 21:45:13 +02:00
|
|
|
TrackCameraInit = false;
|
2018-08-19 09:46:58 +02:00
|
|
|
CalculateCamera();
|
2018-09-07 18:34:18 +02:00
|
|
|
}
|
2018-08-28 20:39:00 +02:00
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
//WTF: what is this? It's used everywhere so it has to stay
|
2018-08-19 09:46:58 +02:00
|
|
|
Wibble = (Wibble + 4) & 0xFC;
|
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Update special effects
|
2018-11-08 23:05:25 +01:00
|
|
|
TriggerLaraDrips();
|
|
|
|
|
|
|
|
if (SmashedMeshCount)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
SmashedMeshCount--;
|
|
|
|
|
|
|
|
FLOOR_INFO* floor = GetFloor(
|
|
|
|
SmashedMesh[SmashedMeshCount]->x,
|
|
|
|
SmashedMesh[SmashedMeshCount]->y,
|
|
|
|
SmashedMesh[SmashedMeshCount]->z,
|
|
|
|
&SmashedMeshRoom[SmashedMeshCount]);
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
int height = GetFloorHeight(
|
2018-11-08 23:05:25 +01:00
|
|
|
floor,
|
|
|
|
SmashedMesh[SmashedMeshCount]->x,
|
|
|
|
SmashedMesh[SmashedMeshCount]->y,
|
|
|
|
SmashedMesh[SmashedMeshCount]->z);
|
|
|
|
|
|
|
|
TestTriggers(TriggerIndex, 1, 0);
|
|
|
|
|
|
|
|
floor->stopper = false;
|
|
|
|
SmashedMesh[SmashedMeshCount] = 0;
|
|
|
|
} while (SmashedMeshCount != 0);
|
|
|
|
}
|
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
UpdateSparks();
|
|
|
|
UpdateFireSparks();
|
2018-08-19 21:49:42 +02:00
|
|
|
UpdateSmoke();
|
|
|
|
UpdateBlood();
|
2018-08-20 19:01:35 +02:00
|
|
|
UpdateBubbles();
|
2020-04-01 07:24:15 +02:00
|
|
|
UpdateDebris();
|
2018-08-20 19:01:35 +02:00
|
|
|
UpdateGunShells();
|
2020-01-05 18:48:16 +01:00
|
|
|
updateFootprints();
|
2018-08-20 19:01:35 +02:00
|
|
|
UpdateSplashes();
|
2020-03-16 12:36:29 +01:00
|
|
|
UpdateEnergyArcs();
|
2018-08-24 23:36:49 +02:00
|
|
|
UpdateDrips();
|
|
|
|
UpdateRats();
|
|
|
|
UpdateBats();
|
|
|
|
UpdateSpiders();
|
|
|
|
UpdateShockwaves();
|
2020-04-14 06:11:10 +02:00
|
|
|
Legacy_UpdateLightning();
|
2019-02-09 09:35:20 +01:00
|
|
|
AnimateWaterfalls();
|
2018-11-08 23:05:25 +01:00
|
|
|
|
|
|
|
if (level->Rumble)
|
|
|
|
RumbleScreen();
|
|
|
|
|
|
|
|
SoundEffects();
|
2018-08-24 23:36:49 +02:00
|
|
|
|
|
|
|
HealtBarTimer--;
|
2019-05-06 23:48:35 +02:00
|
|
|
|
|
|
|
GameTimer++;
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
2018-09-03 21:08:40 +02:00
|
|
|
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_NONE;
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned __stdcall GameMain(void*)
|
|
|
|
{
|
|
|
|
DB_Log(2, "GameMain - DLL");
|
|
|
|
printf("GameMain\n");
|
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// We still need legacy matrices because control routines use them
|
2018-08-19 09:46:58 +02:00
|
|
|
MatrixPtr = MatrixStack;
|
|
|
|
DxMatrixPtr = (byte*)malloc(48 * 40);
|
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Initialise legacy memory buffer and game timer
|
2018-08-19 09:46:58 +02:00
|
|
|
InitGameMalloc();
|
|
|
|
TIME_Init();
|
2018-09-04 13:24:50 +02:00
|
|
|
|
2019-05-09 13:50:55 +02:00
|
|
|
// Do a fixed time title image
|
|
|
|
g_Renderer->DoTitleImage();
|
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Execute the LUA gameflow and play the game
|
2018-09-22 23:54:36 +02:00
|
|
|
g_GameFlow->DoGameflow();
|
2018-09-04 13:24:50 +02:00
|
|
|
|
2019-06-10 21:42:42 +02:00
|
|
|
DoTheGame = false;
|
2018-09-04 13:24:50 +02:00
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Finish the thread
|
2018-08-19 09:46:58 +02:00
|
|
|
PostMessageA((HWND)WindowsHandle, 0x10u, 0, 0);
|
|
|
|
_endthreadex(1);
|
2019-06-10 21:42:42 +02:00
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
return 1;
|
2018-09-01 15:46:37 +02:00
|
|
|
}
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
GAME_STATUS DoTitle(int index)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
|
|
|
DB_Log(2, "DoTitle - DLL");
|
|
|
|
printf("DoTitle\n");
|
2018-09-03 21:08:40 +02:00
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
CreditsDone = false;
|
|
|
|
CanLoad = false;
|
|
|
|
|
|
|
|
// Load the level
|
|
|
|
S_LoadLevelFile(index);
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
int inventoryResult;
|
2019-05-31 21:45:13 +02:00
|
|
|
|
|
|
|
if (g_GameFlow->TitleType == TITLE_FLYBY)
|
|
|
|
{
|
|
|
|
// Initialise items, effects, lots, camera
|
|
|
|
InitialiseFXArray(true);
|
2019-11-15 07:40:22 +01:00
|
|
|
InitialisePickupDisplay();
|
2019-05-31 21:45:13 +02:00
|
|
|
InitialiseCamera();
|
|
|
|
SOUND_Stop();
|
|
|
|
|
|
|
|
RequiredStartPos = false;
|
|
|
|
if (InitialiseGame)
|
|
|
|
{
|
|
|
|
GameTimer = 0;
|
|
|
|
RequiredStartPos = false;
|
|
|
|
InitialiseGame = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Savegame.Level.Timer = 0;
|
|
|
|
if (CurrentLevel == 1)
|
|
|
|
Savegame.TLCount = 0;
|
|
|
|
|
|
|
|
LastInventoryItem = -1;
|
|
|
|
DelCutSeqPlayer = 0;
|
|
|
|
TitleControlsLockedOut = false;
|
|
|
|
GameMode = 1;
|
|
|
|
|
|
|
|
// Initialise flyby cameras
|
|
|
|
InitSpotCamSequences();
|
|
|
|
|
|
|
|
InitialiseSpotCam(2);
|
|
|
|
CurrentAtmosphere = 83;
|
|
|
|
UseSpotCam = true;
|
2019-05-10 20:38:48 +02:00
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
// Play background music
|
|
|
|
//CurrentAtmosphere = ambient;
|
|
|
|
S_CDPlay(CurrentAtmosphere, 1);
|
|
|
|
IsAtmospherePlaying = true;
|
|
|
|
|
|
|
|
// Initialise ponytails
|
|
|
|
InitialiseHair();
|
|
|
|
|
|
|
|
ControlPhase(2, 0);
|
|
|
|
inventoryResult = g_Inventory->DoTitleInventory();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inventoryResult = g_Inventory->DoTitleInventory();
|
|
|
|
}
|
|
|
|
|
|
|
|
UseSpotCam = false;
|
2019-05-10 20:38:48 +02:00
|
|
|
S_CDStop();
|
|
|
|
|
2018-09-03 21:08:40 +02:00
|
|
|
switch (inventoryResult)
|
|
|
|
{
|
2019-04-26 15:10:32 +02:00
|
|
|
case INV_RESULT_NEW_GAME:
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_NEW_GAME;
|
2019-04-26 15:10:32 +02:00
|
|
|
case INV_RESULT_LOAD_GAME:
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_LOAD_GAME;
|
2019-04-26 15:10:32 +02:00
|
|
|
case INV_RESULT_EXIT_GAME:
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_EXIT_GAME;
|
2018-09-03 21:08:40 +02:00
|
|
|
}
|
|
|
|
|
2019-04-29 13:10:58 +02:00
|
|
|
return GAME_STATUS_NEW_GAME;
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
GAME_STATUS DoLevel(int index, int ambient, bool loadFromSavegame)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
|
|
|
CreditsDone = false;
|
|
|
|
CanLoad = false;
|
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// If not loading a savegame, then clear all the infos
|
2018-09-03 21:08:40 +02:00
|
|
|
if (!loadFromSavegame)
|
|
|
|
{
|
|
|
|
Savegame.Level.Timer = 0;
|
|
|
|
Savegame.Level.Distance = 0;
|
|
|
|
Savegame.Level.AmmoUsed = 0;
|
|
|
|
Savegame.Level.AmmoHits = 0;
|
|
|
|
Savegame.Level.Kills = 0;
|
|
|
|
}
|
|
|
|
|
2018-10-24 23:32:22 +02:00
|
|
|
// Load the level
|
|
|
|
S_LoadLevelFile(index);
|
|
|
|
|
2018-10-28 11:34:29 +01:00
|
|
|
// Initialise items, effects, lots, camera
|
|
|
|
InitialiseFXArray(true);
|
2019-11-15 07:40:22 +01:00
|
|
|
InitialisePickupDisplay();
|
2018-10-28 11:34:29 +01:00
|
|
|
InitialiseCamera();
|
|
|
|
SOUND_Stop();
|
|
|
|
|
2018-10-24 23:32:22 +02:00
|
|
|
// Restore the game?
|
2018-09-03 21:08:40 +02:00
|
|
|
if (loadFromSavegame)
|
|
|
|
{
|
2018-10-24 23:32:22 +02:00
|
|
|
char fileName[255];
|
|
|
|
ZeroMemory(fileName, 255);
|
|
|
|
sprintf(fileName, "savegame.%d", g_GameFlow->SelectedSaveGame);
|
|
|
|
SaveGame::Load(fileName);
|
|
|
|
|
2019-12-14 07:28:48 +01:00
|
|
|
Camera.pos.x = LaraItem->pos.xPos + 256;
|
|
|
|
Camera.pos.y = LaraItem->pos.yPos + 256;
|
|
|
|
Camera.pos.z = LaraItem->pos.zPos + 256;
|
|
|
|
|
|
|
|
Camera.target.x = LaraItem->pos.xPos;
|
|
|
|
Camera.target.y = LaraItem->pos.yPos;
|
|
|
|
Camera.target.z = LaraItem->pos.zPos;
|
|
|
|
|
2020-01-12 08:02:48 +01:00
|
|
|
int x = Lara.weaponItem;
|
|
|
|
|
2019-05-06 23:48:35 +02:00
|
|
|
RequiredStartPos = false;
|
|
|
|
InitialiseGame = false;
|
2018-10-24 23:32:22 +02:00
|
|
|
g_GameFlow->SelectedSaveGame = 0;
|
2018-09-03 21:08:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-06 23:48:35 +02:00
|
|
|
RequiredStartPos = false;
|
|
|
|
if (InitialiseGame)
|
2018-09-03 21:08:40 +02:00
|
|
|
{
|
|
|
|
GameTimer = 0;
|
2019-05-06 23:48:35 +02:00
|
|
|
RequiredStartPos = false;
|
|
|
|
InitialiseGame = false;
|
2018-09-03 21:08:40 +02:00
|
|
|
}
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2018-09-03 21:08:40 +02:00
|
|
|
Savegame.Level.Timer = 0;
|
|
|
|
if (CurrentLevel == 1)
|
|
|
|
Savegame.TLCount = 0;
|
|
|
|
}
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2019-05-06 23:48:35 +02:00
|
|
|
LastInventoryItem = -1;
|
2018-08-19 09:46:58 +02:00
|
|
|
DelCutSeqPlayer = 0;
|
|
|
|
TitleControlsLockedOut = false;
|
2019-11-18 07:48:35 +01:00
|
|
|
g_Inventory->SetEnterObject(NO_ITEM);
|
|
|
|
g_Inventory->SetSelectedObject(NO_ITEM);
|
2018-08-22 08:53:34 +02:00
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Initialise flyby cameras
|
|
|
|
InitSpotCamSequences();
|
2019-05-31 21:45:13 +02:00
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Play background music
|
2018-08-22 08:53:34 +02:00
|
|
|
CurrentAtmosphere = ambient;
|
|
|
|
S_CDPlay(CurrentAtmosphere, 1);
|
|
|
|
IsAtmospherePlaying = true;
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// Initialise ponytails
|
2018-08-19 09:46:58 +02:00
|
|
|
InitialiseHair();
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
int nframes = 2;
|
2018-09-03 21:08:40 +02:00
|
|
|
GAME_STATUS result = ControlPhase(nframes, 0);
|
2018-09-07 18:34:18 +02:00
|
|
|
g_Renderer->FadeIn();
|
|
|
|
|
2018-09-08 20:54:13 +02:00
|
|
|
// The game loop, finally!
|
2018-09-03 21:08:40 +02:00
|
|
|
while (true)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
|
|
|
nframes = DrawPhaseGame();
|
2020-04-05 08:15:56 +02:00
|
|
|
result = ControlPhase(nframes, 0);
|
2018-09-08 20:54:13 +02:00
|
|
|
|
2019-04-29 13:10:58 +02:00
|
|
|
if (result == GAME_STATUS_EXIT_TO_TITLE ||
|
|
|
|
result == GAME_STATUS_LOAD_GAME ||
|
|
|
|
result == GAME_STATUS_LEVEL_COMPLETED)
|
2018-09-08 20:54:13 +02:00
|
|
|
{
|
|
|
|
// Here is the only way for exiting from the loop
|
|
|
|
SOUND_Stop();
|
|
|
|
S_CDStop();
|
|
|
|
|
2018-09-03 21:08:40 +02:00
|
|
|
return result;
|
2018-09-08 20:54:13 +02:00
|
|
|
}
|
2018-09-03 21:08:40 +02:00
|
|
|
|
2018-08-21 21:32:56 +03:00
|
|
|
Sound_UpdateScene();
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void TestTriggers(short* data, int heavy, int HeavyFlags)
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
int flip = -1;
|
|
|
|
int flipAvailable = 0;
|
|
|
|
int newEffect = -1;
|
|
|
|
int switchOff = 0;
|
|
|
|
int switchFlag = 0;
|
|
|
|
short objectNumber = 0;
|
|
|
|
int keyResult = 0;
|
|
|
|
short cameraFlags = 0;
|
|
|
|
short cameraTimer = 0;
|
|
|
|
int spotCamIndex = 0;
|
2018-09-22 23:54:36 +02:00
|
|
|
|
|
|
|
HeavyTriggered = false;
|
|
|
|
|
|
|
|
if (!heavy)
|
|
|
|
{
|
|
|
|
Lara.canMonkeySwing = false;
|
2018-10-28 13:55:02 +01:00
|
|
|
Lara.climbStatus = false;
|
2018-09-22 23:54:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Burn Lara
|
|
|
|
if ((*data & 0x1F) == LAVA_TYPE)
|
|
|
|
{
|
|
|
|
if (!heavy && (LaraItem->pos.yPos == LaraItem->floor || Lara.waterStatus))
|
|
|
|
LavaBurn(LaraItem);
|
|
|
|
|
2018-09-23 09:38:24 +02:00
|
|
|
if (*data & 0x8000)
|
2018-09-22 23:54:36 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
data++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lara can climb
|
|
|
|
if ((*data & 0x1F) == CLIMB_TYPE)
|
|
|
|
{
|
|
|
|
if (!heavy)
|
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
short quad = (unsigned short)(LaraItem->pos.yRot + ANGLE(45)) / ANGLE(90);
|
2018-09-22 23:54:36 +02:00
|
|
|
if ((1 << (quad + 8)) & *data)
|
|
|
|
Lara.climbStatus = true;
|
|
|
|
}
|
|
|
|
|
2018-09-23 09:38:24 +02:00
|
|
|
if (*data & 0x8000)
|
2018-09-22 23:54:36 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
data++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lara can monkey
|
|
|
|
if ((*data & 0x1F) == MONKEY_TYPE)
|
|
|
|
{
|
|
|
|
if (!heavy)
|
|
|
|
Lara.canMonkeySwing = true;
|
|
|
|
|
2018-09-23 09:38:24 +02:00
|
|
|
if (*data & 0x8000)
|
2018-09-22 23:54:36 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
data++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trigger triggerer
|
|
|
|
if ((*data & 0x1F) == TRIGTRIGGER_TYPE)
|
|
|
|
{
|
|
|
|
if (!(*data & 0x20) || *data & 0x8000)
|
|
|
|
return;
|
|
|
|
|
|
|
|
data++;
|
|
|
|
}
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
short triggerType = (*(data++) >> 8) & 0x3F;
|
|
|
|
short flags = *(data++);
|
|
|
|
short timer = flags & 0xFF;
|
2018-09-22 23:54:36 +02:00
|
|
|
|
|
|
|
if (Camera.type != HEAVY_CAMERA)
|
|
|
|
RefreshCamera(triggerType, data);
|
|
|
|
|
|
|
|
if (heavy)
|
|
|
|
{
|
|
|
|
switch (triggerType)
|
|
|
|
{
|
|
|
|
case HEAVY:
|
|
|
|
case HEAVYANTITRIGGER:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HEAVYSWITCH:
|
|
|
|
if (!HeavyFlags)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (HeavyFlags >= 0)
|
|
|
|
{
|
2020-04-07 19:20:32 +02:00
|
|
|
flags &= CODE_BITS;
|
2018-09-22 23:54:36 +02:00
|
|
|
if (flags != HeavyFlags)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-07 19:20:32 +02:00
|
|
|
flags |= CODE_BITS;
|
2018-09-22 23:54:36 +02:00
|
|
|
flags += HeavyFlags;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Enemies can only activate heavy triggers
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
short value = 0;
|
2018-09-22 23:54:36 +02:00
|
|
|
|
|
|
|
switch (triggerType)
|
|
|
|
{
|
|
|
|
case TRIGGER_TYPES::SWITCH:
|
|
|
|
value = *(data++) & 0x3FF;
|
|
|
|
|
2018-09-23 09:38:24 +02:00
|
|
|
if (flags & 0x100)
|
2018-09-22 23:54:36 +02:00
|
|
|
Items[value].itemFlags[0] = 1;
|
|
|
|
|
|
|
|
if (!SwitchTrigger(value, timer))
|
|
|
|
return;
|
|
|
|
|
|
|
|
objectNumber = Items[value].objectNumber;
|
|
|
|
if (objectNumber >= ID_SWITCH_TYPE1 && objectNumber <= ID_SWITCH_TYPE6 && Items[value].triggerFlags == 5)
|
|
|
|
switchFlag = 1;
|
|
|
|
|
|
|
|
switchOff = (Items[value].currentAnimState == 1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::MONKEY:
|
|
|
|
if (LaraItem->currentAnimState >= 75 &&
|
|
|
|
(LaraItem->currentAnimState <= 79 ||
|
|
|
|
LaraItem->currentAnimState == 82 ||
|
|
|
|
LaraItem->currentAnimState == 83))
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::TIGHTROPE_T:
|
|
|
|
if (LaraItem->currentAnimState >= 119 &&
|
|
|
|
LaraItem->currentAnimState <= 127 &&
|
|
|
|
LaraItem->currentAnimState != 126)
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::CRAWLDUCK_T:
|
|
|
|
if (LaraItem->currentAnimState == 80 ||
|
|
|
|
LaraItem->currentAnimState == 81 ||
|
|
|
|
LaraItem->currentAnimState == 84 ||
|
|
|
|
LaraItem->currentAnimState == 85 ||
|
|
|
|
LaraItem->currentAnimState == 86 ||
|
|
|
|
LaraItem->currentAnimState == 71 ||
|
|
|
|
LaraItem->currentAnimState == 72 ||
|
|
|
|
LaraItem->currentAnimState == 105 ||
|
|
|
|
LaraItem->currentAnimState == 106)
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::CLIMB_T:
|
|
|
|
if (LaraItem->currentAnimState == 10 ||
|
|
|
|
LaraItem->currentAnimState == 56 ||
|
|
|
|
LaraItem->currentAnimState == 57 ||
|
|
|
|
LaraItem->currentAnimState == 58 ||
|
|
|
|
LaraItem->currentAnimState == 59 ||
|
|
|
|
LaraItem->currentAnimState == 60 ||
|
|
|
|
LaraItem->currentAnimState == 61 ||
|
|
|
|
LaraItem->currentAnimState == 75)
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::PAD:
|
|
|
|
case TRIGGER_TYPES::ANTIPAD:
|
|
|
|
if (LaraItem->pos.yPos == LaraItem->floor)
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::KEY:
|
|
|
|
value = *(data++) & 0x3FF;
|
|
|
|
keyResult = KeyTrigger(value);
|
|
|
|
if (keyResult != -1)
|
2018-09-23 09:38:24 +02:00
|
|
|
break;
|
|
|
|
return;
|
2018-09-22 23:54:36 +02:00
|
|
|
|
|
|
|
case TRIGGER_TYPES::PICKUP:
|
|
|
|
value = *(data++) & 0x3FF;
|
|
|
|
if (!PickupTrigger(value))
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::COMBAT:
|
|
|
|
if (Lara.gunStatus == LG_READY)
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::SKELETON_T:
|
|
|
|
Lara.skelebob = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::HEAVY:
|
|
|
|
case TRIGGER_TYPES::DUMMY:
|
|
|
|
case TRIGGER_TYPES::HEAVYSWITCH:
|
|
|
|
case TRIGGER_TYPES::HEAVYANTITRIGGER:
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
short targetType = 0;
|
|
|
|
short trigger = 0;
|
2018-09-22 23:54:36 +02:00
|
|
|
|
|
|
|
ITEM_INFO* item = NULL;
|
|
|
|
ITEM_INFO* cameraItem = NULL;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
trigger = *(data++);
|
2020-04-07 19:20:32 +02:00
|
|
|
value = trigger & VALUE_BITS;
|
2018-09-22 23:54:36 +02:00
|
|
|
targetType = (trigger >> 10) & 0xF;
|
|
|
|
|
|
|
|
switch (targetType)
|
|
|
|
{
|
|
|
|
case TO_OBJECT:
|
|
|
|
item = &Items[value];
|
|
|
|
|
|
|
|
if (keyResult >= 2 ||
|
|
|
|
(triggerType == TRIGGER_TYPES::ANTIPAD ||
|
|
|
|
triggerType == TRIGGER_TYPES::ANTITRIGGER ||
|
|
|
|
triggerType == TRIGGER_TYPES::HEAVYANTITRIGGER) &&
|
2020-04-07 19:20:32 +02:00
|
|
|
item->flags & ATONESHOT)
|
2018-09-22 23:54:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::SWITCH)
|
|
|
|
{
|
2020-04-07 19:20:32 +02:00
|
|
|
if (item->flags & SWONESHOT)
|
2018-09-22 23:54:36 +02:00
|
|
|
break;
|
|
|
|
if (item->objectNumber == ID_DART_EMITTER && item->active)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->timer = timer;
|
|
|
|
if (timer != 1)
|
|
|
|
item->timer = 30 * timer;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::SWITCH ||
|
|
|
|
triggerType == TRIGGER_TYPES::HEAVYSWITCH)
|
|
|
|
{
|
|
|
|
if (HeavyFlags >= 0)
|
|
|
|
{
|
|
|
|
if (switchFlag)
|
2020-04-07 19:20:32 +02:00
|
|
|
item->flags |= (flags & CODE_BITS);
|
2018-09-22 23:54:36 +02:00
|
|
|
else
|
2020-04-07 19:20:32 +02:00
|
|
|
item->flags ^= (flags & CODE_BITS);
|
2018-09-22 23:54:36 +02:00
|
|
|
|
2020-04-07 19:20:32 +02:00
|
|
|
if (flags & ONESHOT)
|
|
|
|
item->flags |= SWONESHOT;
|
2018-09-22 23:54:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-07 19:20:32 +02:00
|
|
|
if (((flags ^ item->flags) & CODE_BITS) == CODE_BITS)
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
2020-04-07 19:20:32 +02:00
|
|
|
item->flags ^= (flags & CODE_BITS);
|
|
|
|
if (flags & ONESHOT)
|
|
|
|
item->flags |= SWONESHOT;
|
2018-09-22 23:54:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (triggerType == TRIGGER_TYPES::ANTIPAD ||
|
|
|
|
triggerType == TRIGGER_TYPES::ANTITRIGGER ||
|
|
|
|
triggerType == TRIGGER_TYPES::HEAVYANTITRIGGER)
|
|
|
|
{
|
|
|
|
if (item->objectNumber == ID_EARTHQUAKE)
|
|
|
|
{
|
|
|
|
item->itemFlags[0] = 0;
|
|
|
|
item->itemFlags[1] = 100;
|
|
|
|
}
|
|
|
|
|
2020-04-07 19:20:32 +02:00
|
|
|
item->flags &= ~(CODE_BITS | REVERSE);
|
2018-09-22 23:54:36 +02:00
|
|
|
|
2020-04-07 19:20:32 +02:00
|
|
|
if (flags & ONESHOT)
|
|
|
|
item->flags |= ATONESHOT;
|
2018-09-22 23:54:36 +02:00
|
|
|
|
|
|
|
if (item->active && Objects[item->objectNumber].intelligent)
|
|
|
|
{
|
|
|
|
item->hitPoints = -16384;
|
2018-09-23 09:38:24 +02:00
|
|
|
DisableBaddieAI(value);
|
|
|
|
KillItem(value);
|
2018-09-22 23:54:36 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-07 19:20:32 +02:00
|
|
|
else if (flags & CODE_BITS)
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
2020-04-07 19:20:32 +02:00
|
|
|
item->flags |= flags & CODE_BITS;
|
2018-09-22 23:54:36 +02:00
|
|
|
}
|
|
|
|
|
2020-04-07 19:20:32 +02:00
|
|
|
if ((item->flags & CODE_BITS) == CODE_BITS)
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
|
|
|
item->flags |= 0x20;
|
|
|
|
|
2020-04-07 19:20:32 +02:00
|
|
|
if (flags & ONESHOT)
|
|
|
|
item->flags |= ONESHOT;
|
2018-09-22 23:54:36 +02:00
|
|
|
|
2020-01-18 21:55:04 +01:00
|
|
|
if (!(item->active) && !(item->flags & IFLAG_KILLED))
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
|
|
|
if (Objects[item->objectNumber].intelligent)
|
|
|
|
{
|
2020-03-25 07:06:04 +01:00
|
|
|
if (item->status != ITEM_INACTIVE)
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
|
|
|
if (item->status == ITEM_INVISIBLE)
|
|
|
|
{
|
|
|
|
item->touchBits = 0;
|
2018-09-23 09:38:24 +02:00
|
|
|
if (EnableBaddieAI(value, 0))
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
|
|
|
item->status = ITEM_ACTIVE;
|
2018-09-23 09:38:24 +02:00
|
|
|
AddActiveItem(value);
|
2018-09-22 23:54:36 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->status == ITEM_INVISIBLE;
|
2018-09-23 09:38:24 +02:00
|
|
|
AddActiveItem(value);
|
2018-09-22 23:54:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->touchBits = 0;
|
|
|
|
item->status = ITEM_ACTIVE;
|
2018-09-23 09:38:24 +02:00
|
|
|
AddActiveItem(value);
|
|
|
|
EnableBaddieAI(value, 1);
|
2018-09-22 23:54:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->touchBits = 0;
|
2018-09-23 09:38:24 +02:00
|
|
|
AddActiveItem(value);
|
2018-09-22 23:54:36 +02:00
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
HeavyTriggered = heavy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_CAMERA:
|
|
|
|
trigger = *(data++);
|
|
|
|
|
|
|
|
if (keyResult == 1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (Camera.fixed[value].flags & 0x100)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Camera.number = value;
|
|
|
|
|
|
|
|
if (Camera.type == LOOK_CAMERA || Camera.type == COMBAT_CAMERA && !(Camera.fixed[value].flags & 3))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::COMBAT)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::SWITCH && timer && switchOff)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (Camera.number != Camera.last || triggerType == TRIGGER_TYPES::SWITCH)
|
|
|
|
{
|
|
|
|
Camera.timer = (trigger & 0xFF) * 30;
|
|
|
|
|
|
|
|
if (trigger & 0x100)
|
|
|
|
Camera.fixed[Camera.number].flags |= 0x100;
|
|
|
|
|
2020-04-07 19:20:32 +02:00
|
|
|
Camera.speed = ((trigger & CODE_BITS) >> 6) + 1;
|
2018-09-22 23:54:36 +02:00
|
|
|
Camera.type = heavy ? HEAVY_CAMERA : FIXED_CAMERA;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLYBY:
|
|
|
|
trigger = *(data++);
|
|
|
|
|
|
|
|
if (keyResult == 1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::ANTIPAD ||
|
|
|
|
triggerType == TRIGGER_TYPES::ANTITRIGGER ||
|
|
|
|
triggerType == TRIGGER_TYPES::HEAVYANTITRIGGER)
|
|
|
|
UseSpotCam = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spotCamIndex = 0;
|
2019-05-31 21:45:13 +02:00
|
|
|
if (SpotCamRemap[value] != 0)
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
for (int i = 0; i < SpotCamRemap[value]; i++)
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
|
|
|
spotCamIndex += CameraCnt[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
if (!(SpotCam[spotCamIndex].flags & SCF_CAMERA_ONE_SHOT))
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
|
|
|
if (trigger & 0x100)
|
2019-05-31 21:45:13 +02:00
|
|
|
SpotCam[spotCamIndex].flags |= SCF_CAMERA_ONE_SHOT;
|
2018-09-22 23:54:36 +02:00
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
if (!UseSpotCam || CurrentLevel == 0)
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
|
|
|
UseSpotCam = true;
|
|
|
|
if (LastSpotCam != value)
|
|
|
|
TrackCameraInit = false;
|
2019-05-31 21:45:13 +02:00
|
|
|
InitialiseSpotCam(value);
|
2018-09-22 23:54:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_TARGET:
|
|
|
|
cameraItem = &Items[value];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_SINK:
|
|
|
|
Lara.currentActive = value + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLIPMAP:
|
|
|
|
flipAvailable = true;
|
|
|
|
|
|
|
|
if (FlipMap[value] & 0x100)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::SWITCH)
|
2020-04-07 19:20:32 +02:00
|
|
|
FlipMap[value] ^= (flags & CODE_BITS);
|
|
|
|
else if (flags & CODE_BITS)
|
|
|
|
FlipMap[value] |= (flags & CODE_BITS);
|
2018-09-22 23:54:36 +02:00
|
|
|
|
2020-04-07 19:20:32 +02:00
|
|
|
if ((FlipMap[value] & CODE_BITS) == CODE_BITS)
|
2018-09-22 23:54:36 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
if (flags & 0x100)
|
|
|
|
FlipMap[value] |= 0x100;
|
2020-01-14 00:26:44 -03:00
|
|
|
if (!FlipStats[value])
|
2018-09-22 23:54:36 +02:00
|
|
|
flip = value;
|
|
|
|
}
|
2020-01-14 00:26:44 -03:00
|
|
|
else if (FlipStats[value])
|
2018-09-22 23:54:36 +02:00
|
|
|
flip = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLIPON:
|
2018-09-23 09:38:24 +02:00
|
|
|
flipAvailable = true;
|
2020-04-07 19:20:32 +02:00
|
|
|
FlipMap[value] |= CODE_BITS;
|
2020-01-14 00:26:44 -03:00
|
|
|
if (!FlipStats[value])
|
2018-09-22 23:54:36 +02:00
|
|
|
flip = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLIPOFF:
|
2018-09-23 09:38:24 +02:00
|
|
|
flipAvailable = true;
|
2020-04-07 19:20:32 +02:00
|
|
|
FlipMap[value] &= ~CODE_BITS;
|
2020-01-14 00:26:44 -03:00
|
|
|
if (FlipStats[value])
|
2018-09-22 23:54:36 +02:00
|
|
|
flip = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLIPEFFECT:
|
|
|
|
TriggerTimer = timer;
|
|
|
|
newEffect = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FINISH:
|
2019-05-06 23:48:35 +02:00
|
|
|
RequiredStartPos = false;
|
2018-09-22 23:54:36 +02:00
|
|
|
LevelComplete = CurrentLevel + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_CD:
|
|
|
|
PlaySoundTrack(value, flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_CUTSCENE:
|
|
|
|
// TODO: not used for now
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_LUA_SCRIPT:
|
2018-09-23 09:38:24 +02:00
|
|
|
trigger = *(data++);
|
2018-09-23 12:01:07 +02:00
|
|
|
g_GameScript->ExecuteTrigger(trigger & 0x7FFF);
|
2018-09-23 09:38:24 +02:00
|
|
|
|
2018-09-22 23:54:36 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (!(trigger & 0x8000));
|
|
|
|
|
|
|
|
if (cameraItem && (Camera.type == FIXED_CAMERA || Camera.type == HEAVY_CAMERA))
|
|
|
|
Camera.item = cameraItem;
|
|
|
|
|
|
|
|
if (flip != -1)
|
|
|
|
DoFlipMap(flip);
|
|
|
|
|
|
|
|
if (newEffect != -1 && (flip || !flipAvailable))
|
|
|
|
{
|
|
|
|
FlipEffect = newEffect;
|
|
|
|
FlipTimer = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void UpdateSky()
|
2018-12-28 12:12:58 +01:00
|
|
|
{
|
|
|
|
GameScriptLevel* level = g_GameFlow->GetLevel(CurrentLevel);
|
|
|
|
|
|
|
|
if (level->Layer1.Enabled)
|
|
|
|
{
|
|
|
|
SkyPos1 += level->Layer1.CloudSpeed;
|
|
|
|
if (SkyPos1 <= 9728)
|
|
|
|
{
|
|
|
|
if (SkyPos1 < 0)
|
|
|
|
SkyPos1 += 9728;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SkyPos1 -= 9728;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level->Layer1.Enabled)
|
|
|
|
{
|
|
|
|
SkyPos2 += level->Layer2.CloudSpeed;
|
|
|
|
if (SkyPos2 <= 9728)
|
|
|
|
{
|
|
|
|
if (SkyPos2 < 0)
|
|
|
|
SkyPos2 += 9728;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SkyPos2 -= 9728;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void ActivateKey()
|
2019-11-15 07:40:22 +01:00
|
|
|
{
|
|
|
|
KeyTriggerActive = 1;
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
short GetDoor(FLOOR_INFO* floor)
|
2019-12-01 08:13:19 +01:00
|
|
|
{
|
|
|
|
if (!floor->index)
|
|
|
|
return NO_ROOM;
|
|
|
|
|
2019-12-02 09:11:21 +01:00
|
|
|
short* data = &FloorData[floor->index];
|
|
|
|
short type = *(data++);
|
2019-12-01 08:13:19 +01:00
|
|
|
|
|
|
|
if (((type & DATA_TYPE) == TILT_TYPE)
|
|
|
|
|| ((type & DATA_TYPE) == SPLIT1)
|
|
|
|
|| ((type & DATA_TYPE) == SPLIT2)
|
|
|
|
|| ((type & DATA_TYPE) == NOCOLF1B)
|
|
|
|
|| ((type & DATA_TYPE) == NOCOLF1T)
|
|
|
|
|| ((type & DATA_TYPE) == NOCOLF2B)
|
|
|
|
|| ((type & DATA_TYPE) == NOCOLF2T))
|
|
|
|
{
|
|
|
|
if (type & END_BIT)
|
|
|
|
return NO_ROOM;
|
|
|
|
|
|
|
|
data++;
|
|
|
|
type = *(data++);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((type & DATA_TYPE) == ROOF_TYPE)
|
|
|
|
|| ((type & DATA_TYPE) == SPLIT3)
|
|
|
|
|| ((type & DATA_TYPE) == SPLIT4)
|
|
|
|
|| ((type & DATA_TYPE) == NOCOLC1B)
|
|
|
|
|| ((type & DATA_TYPE) == NOCOLC1T)
|
|
|
|
|| ((type & DATA_TYPE) == NOCOLC2B)
|
|
|
|
|| ((type & DATA_TYPE) == NOCOLC2T))
|
|
|
|
{
|
|
|
|
if (type & END_BIT)
|
|
|
|
return NO_ROOM;
|
|
|
|
|
|
|
|
data++;
|
|
|
|
type = *(data++);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((type & DATA_TYPE) == DOOR_TYPE)
|
|
|
|
return (*data);
|
|
|
|
|
|
|
|
return NO_ROOM;
|
|
|
|
}
|
|
|
|
|
2019-12-04 18:51:23 +01:00
|
|
|
void TranslateItem(ITEM_INFO* item, int x, int y, int z)
|
|
|
|
{
|
|
|
|
int c = COS(item->pos.yRot);
|
|
|
|
int s = SIN(item->pos.yRot);
|
|
|
|
|
|
|
|
item->pos.xPos += (c * x + s * z) >> W2V_SHIFT;
|
|
|
|
item->pos.yPos += y;
|
|
|
|
item->pos.zPos += (-s * x + c * z) >> W2V_SHIFT;
|
|
|
|
}
|
|
|
|
|
2019-12-05 17:35:57 +01:00
|
|
|
int GetWaterSurface(int x, int y, int z, short roomNumber)
|
|
|
|
{
|
|
|
|
ROOM_INFO* room = &Rooms[roomNumber];
|
2020-01-14 14:25:37 +01:00
|
|
|
FLOOR_INFO* floor = &XZ_GET_SECTOR(room, x - room->x, z - room->z);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
if (room->flags & ENV_FLAG_WATER)
|
|
|
|
{
|
|
|
|
while (floor->skyRoom != NO_ROOM)
|
|
|
|
{
|
|
|
|
room = &Rooms[floor->skyRoom];
|
|
|
|
if (!(room->flags & ENV_FLAG_WATER))
|
|
|
|
return (floor->ceiling << 8);
|
2020-01-14 14:25:37 +01:00
|
|
|
floor = &XZ_GET_SECTOR(room, x - room->x, z - room->z);
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
return NO_HEIGHT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (floor->pitRoom != NO_ROOM)
|
|
|
|
{
|
|
|
|
room = &Rooms[floor->pitRoom];
|
|
|
|
if (room->flags & ENV_FLAG_WATER)
|
|
|
|
return (floor->floor << 8);
|
2020-01-14 14:25:37 +01:00
|
|
|
floor = &XZ_GET_SECTOR(room, x - room->x, z - room->z);
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
2019-12-07 08:55:56 +01:00
|
|
|
|
2019-12-05 17:35:57 +01:00
|
|
|
return NO_HEIGHT;
|
|
|
|
}
|
|
|
|
|
2019-12-08 19:01:57 +01:00
|
|
|
void KillMoveItems()
|
|
|
|
{
|
|
|
|
if (ItemNewRoomNo > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < ItemNewRoomNo; i++)
|
|
|
|
{
|
|
|
|
short itemNumber = ItemNewRooms[2 * i];
|
|
|
|
if (itemNumber >= 0)
|
|
|
|
ItemNewRoom(itemNumber, ItemNewRooms[2 * i + 1]);
|
|
|
|
else
|
|
|
|
KillItem(itemNumber & 0x7FFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemNewRoomNo = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KillMoveEffects()
|
|
|
|
{
|
|
|
|
if (ItemNewRoomNo > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < ItemNewRoomNo; i++)
|
|
|
|
{
|
|
|
|
short itemNumber = ItemNewRooms[2 * i];
|
|
|
|
if (itemNumber >= 0)
|
|
|
|
EffectNewRoom(itemNumber, ItemNewRooms[2 * i + 1]);
|
|
|
|
else
|
|
|
|
KillEffect(itemNumber & 0x7FFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemNewRoomNo = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetChange(ITEM_INFO* item, ANIM_STRUCT* anim)
|
|
|
|
{
|
|
|
|
if (item->currentAnimState == item->goalAnimState)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (anim->numberChanges <= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < anim->numberChanges; i++)
|
|
|
|
{
|
2019-12-10 18:25:48 +01:00
|
|
|
CHANGE_STRUCT* change = &Changes[anim->changeIndex + i];
|
2019-12-08 19:01:57 +01:00
|
|
|
if (change->goalAnimState == item->goalAnimState)
|
|
|
|
{
|
|
|
|
for (int j = 0; j < change->numberRanges; j++)
|
|
|
|
{
|
2019-12-10 18:25:48 +01:00
|
|
|
RANGE_STRUCT* range = &Ranges[change->rangeIndex + j];
|
2019-12-08 19:01:57 +01:00
|
|
|
if (item->frameNumber >= range->startFrame && item->frameNumber <= range->endFrame)
|
|
|
|
{
|
|
|
|
item->animNumber = range->linkAnimNum;
|
|
|
|
item->frameNumber = range->linkFrameNum;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AlterFloorHeight(ITEM_INFO* item, int height)
|
|
|
|
{
|
2019-12-14 22:41:38 +01:00
|
|
|
FLOOR_INFO* floor;
|
|
|
|
FLOOR_INFO* ceiling;
|
|
|
|
BOX_INFO* box;
|
|
|
|
short roomNumber;
|
2019-12-08 19:01:57 +01:00
|
|
|
int flag = 0;
|
2019-12-14 22:41:38 +01:00
|
|
|
|
2019-12-08 19:01:57 +01:00
|
|
|
if (abs(height))
|
|
|
|
{
|
|
|
|
flag = 1;
|
|
|
|
if (height >= 0)
|
|
|
|
height++;
|
|
|
|
else
|
|
|
|
height--;
|
|
|
|
}
|
|
|
|
|
2019-12-14 22:41:38 +01:00
|
|
|
roomNumber = item->roomNumber;
|
|
|
|
floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
|
|
|
|
ceiling = GetFloor(item->pos.xPos, height + item->pos.yPos - WALL_SIZE, item->pos.zPos, &roomNumber);
|
2019-12-23 23:10:24 +01:00
|
|
|
|
|
|
|
if (floor->floor == NO_HEIGHT / STEP_SIZE)
|
2019-12-08 19:01:57 +01:00
|
|
|
{
|
2019-12-23 23:10:24 +01:00
|
|
|
floor->floor = ceiling->ceiling + height / STEP_SIZE;
|
2019-12-08 19:01:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-23 23:10:24 +01:00
|
|
|
floor->floor += height / STEP_SIZE;
|
2019-12-08 19:01:57 +01:00
|
|
|
if (floor->floor == ceiling->ceiling && !flag)
|
2019-12-23 23:10:24 +01:00
|
|
|
floor->floor = NO_HEIGHT / STEP_SIZE;
|
2019-12-08 19:01:57 +01:00
|
|
|
}
|
|
|
|
|
2019-12-14 22:41:38 +01:00
|
|
|
box = &Boxes[floor->box];
|
|
|
|
if (box->overlapIndex & BLOCKABLE)
|
2019-12-08 19:01:57 +01:00
|
|
|
{
|
|
|
|
if (height >= 0)
|
2019-12-14 22:41:38 +01:00
|
|
|
box->overlapIndex &= ~BLOCKED;
|
2019-12-08 19:01:57 +01:00
|
|
|
else
|
2019-12-14 22:41:38 +01:00
|
|
|
box->overlapIndex |= BLOCKED;
|
2019-12-08 19:01:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-14 18:24:06 +01:00
|
|
|
FLOOR_INFO* GetFloor(int x, int y, int z, short* roomNumber)
|
2019-12-08 19:01:57 +01:00
|
|
|
{
|
2019-12-14 22:41:38 +01:00
|
|
|
ROOM_INFO* r;
|
2019-12-08 19:01:57 +01:00
|
|
|
FLOOR_INFO* floor;
|
2019-12-14 22:41:38 +01:00
|
|
|
short data;
|
2019-12-08 19:01:57 +01:00
|
|
|
int xFloor = 0;
|
|
|
|
int yFloor = 0;
|
|
|
|
short roomDoor = 0;
|
2019-12-14 18:24:06 +01:00
|
|
|
int retval;
|
2019-12-08 19:01:57 +01:00
|
|
|
|
2019-12-14 22:41:38 +01:00
|
|
|
r = &Rooms[*roomNumber];
|
2019-12-10 18:25:48 +01:00
|
|
|
do
|
2019-12-08 19:01:57 +01:00
|
|
|
{
|
|
|
|
xFloor = (z - r->z) >> WALL_SHIFT;
|
|
|
|
yFloor = (x - r->x) >> WALL_SHIFT;
|
|
|
|
|
|
|
|
if (xFloor <= 0)
|
|
|
|
{
|
|
|
|
xFloor = 0;
|
|
|
|
if (yFloor < 1)
|
|
|
|
yFloor = 1;
|
2019-12-10 18:25:48 +01:00
|
|
|
else if (yFloor > r->ySize - 2)
|
2019-12-08 19:01:57 +01:00
|
|
|
yFloor = r->ySize - 2;
|
|
|
|
}
|
|
|
|
else if (xFloor >= r->xSize - 1)
|
|
|
|
{
|
|
|
|
xFloor = r->xSize - 1;
|
|
|
|
if (yFloor < 1)
|
|
|
|
yFloor = 1;
|
2019-12-10 18:25:48 +01:00
|
|
|
else if (yFloor > r->ySize - 2)
|
2019-12-08 19:01:57 +01:00
|
|
|
yFloor = r->ySize - 2;
|
|
|
|
}
|
|
|
|
else if (yFloor >= 0)
|
|
|
|
{
|
|
|
|
if (yFloor >= r->ySize)
|
|
|
|
yFloor = r->ySize - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
yFloor = 0;
|
|
|
|
}
|
|
|
|
|
2019-12-14 18:24:06 +01:00
|
|
|
floor = &r->floor[xFloor + (yFloor * r->xSize)];
|
2019-12-10 18:25:48 +01:00
|
|
|
data = GetDoor(floor);
|
|
|
|
if (data != NO_ROOM)
|
|
|
|
{
|
|
|
|
*roomNumber = data;
|
2019-12-14 18:24:06 +01:00
|
|
|
r = &Rooms[data];
|
2019-12-10 18:25:48 +01:00
|
|
|
}
|
|
|
|
} while (data != NO_ROOM);
|
2019-12-08 19:01:57 +01:00
|
|
|
|
|
|
|
if (y < floor->floor * 256)
|
|
|
|
{
|
|
|
|
if (y < floor->ceiling * 256 && floor->skyRoom != NO_ROOM)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int noCollision = CheckNoColCeilingTriangle(floor, x, z);
|
|
|
|
if (noCollision == 1 || noCollision == -1 && y >= r->maxceiling)
|
|
|
|
break;
|
|
|
|
|
|
|
|
*roomNumber = floor->skyRoom;
|
|
|
|
r = &Rooms[floor->skyRoom];
|
|
|
|
floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z);
|
|
|
|
if (y >= floor->ceiling * 256)
|
|
|
|
break;
|
|
|
|
} while (floor->skyRoom != NO_ROOM);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (floor->pitRoom != NO_ROOM)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int noCollision = CheckNoColFloorTriangle(floor, x, z);
|
|
|
|
if (noCollision == 1 || noCollision == -1 && y < r->minfloor)
|
|
|
|
break;
|
|
|
|
|
|
|
|
*roomNumber = floor->pitRoom;
|
|
|
|
r = &Rooms[floor->pitRoom];
|
2019-12-14 22:41:38 +01:00
|
|
|
floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z);
|
2019-12-08 19:01:57 +01:00
|
|
|
if (y < floor->floor * 256)
|
|
|
|
break;
|
|
|
|
} while (floor->pitRoom != NO_ROOM);
|
|
|
|
}
|
2019-12-14 22:41:38 +01:00
|
|
|
|
2019-12-08 19:01:57 +01:00
|
|
|
return floor;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CheckNoColFloorTriangle(FLOOR_INFO* floor, int x, int z)
|
|
|
|
{
|
|
|
|
if (!floor->index)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
short* data = &FloorData[floor->index];
|
|
|
|
short type = *(data) & DATA_TYPE;
|
|
|
|
|
|
|
|
if (type == NOCOLF1T || type == NOCOLF1B || type == NOCOLF2T || type == NOCOLF2B)
|
|
|
|
{
|
|
|
|
int dx = x & 1023;
|
|
|
|
int dz = z & 1023;
|
|
|
|
|
2019-12-14 18:24:06 +01:00
|
|
|
if (type == NOCOLF1T && dx <= (SECTOR(1) - dz))
|
2019-12-08 19:01:57 +01:00
|
|
|
return -1;
|
2019-12-14 18:24:06 +01:00
|
|
|
else if (type == NOCOLF1B && dx > (SECTOR(1) - dz))
|
2019-12-08 19:01:57 +01:00
|
|
|
return -1;
|
|
|
|
else if (type == NOCOLF2T && dx <= dz)
|
|
|
|
return -1;
|
|
|
|
else if (type == NOCOLF2B && dx > dz)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CheckNoColCeilingTriangle(FLOOR_INFO * floor, int x, int z)
|
|
|
|
{
|
|
|
|
if (!floor->index)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
short* data = &FloorData[floor->index];
|
|
|
|
short type = *(data) & DATA_TYPE;
|
|
|
|
|
|
|
|
if (type == TILT_TYPE || type == SPLIT1 || type == SPLIT2 || type == NOCOLF1T || type == NOCOLF1B || type == NOCOLF2T || type == NOCOLF2B) // gibby
|
|
|
|
{
|
|
|
|
if (*(data) & END_BIT)
|
|
|
|
return 0;
|
|
|
|
type = *(data + 2) & DATA_TYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == NOCOLC1T || type == NOCOLC1B || type == NOCOLC2T || type == NOCOLC2B)
|
|
|
|
{
|
|
|
|
int dx = x & 1023;
|
|
|
|
int dz = z & 1023;
|
|
|
|
|
2019-12-14 18:24:06 +01:00
|
|
|
if (type == NOCOLC1T && dx <= (SECTOR(1) - dz))
|
2019-12-08 19:01:57 +01:00
|
|
|
return -1;
|
2019-12-14 18:24:06 +01:00
|
|
|
else if (type == NOCOLC1B && dx > (SECTOR(1) - dz))
|
2019-12-08 19:01:57 +01:00
|
|
|
return -1;
|
|
|
|
else if (type == NOCOLC2T && dx <= dz)
|
|
|
|
return -1;
|
|
|
|
else if (type == NOCOLC2B && dx > dz)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-14 08:43:34 +01:00
|
|
|
int GetFloorHeight(FLOOR_INFO* floor, int x, int y, int z)
|
2019-12-10 18:25:48 +01:00
|
|
|
{
|
|
|
|
TiltYOffset = 0;
|
|
|
|
TiltXOffset = 0;
|
|
|
|
OnObject = 0;
|
2019-12-14 18:24:06 +01:00
|
|
|
HeightType = WALL;
|
2019-12-10 18:25:48 +01:00
|
|
|
|
|
|
|
ROOM_INFO* r;
|
|
|
|
while (floor->pitRoom != NO_ROOM)
|
|
|
|
{
|
|
|
|
if (CheckNoColFloorTriangle(floor, x, z) == 1)
|
|
|
|
break;
|
|
|
|
r = &Rooms[floor->pitRoom];
|
|
|
|
floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z);
|
|
|
|
}
|
|
|
|
|
|
|
|
int height = floor->floor * 256;
|
|
|
|
if (height == NO_HEIGHT)
|
|
|
|
return height;
|
|
|
|
|
|
|
|
TriggerIndex = NULL;
|
|
|
|
|
|
|
|
if (floor->index == 0)
|
|
|
|
return height;
|
|
|
|
|
|
|
|
short* data = &FloorData[floor->index];
|
2019-12-21 18:32:48 -03:00
|
|
|
short type, hadj;
|
2019-12-10 18:25:48 +01:00
|
|
|
|
|
|
|
int xOff, yOff, trigger;
|
|
|
|
ITEM_INFO* item;
|
|
|
|
OBJECT_INFO* obj;
|
2019-12-21 18:32:48 -03:00
|
|
|
int tilts, t0, t1, t2, t3, t4, dx, dz, h1, h2;
|
2019-12-10 18:25:48 +01:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
type = *(data++);
|
|
|
|
|
|
|
|
switch (type & DATA_TYPE)
|
|
|
|
{
|
|
|
|
case DOOR_TYPE:
|
|
|
|
case ROOF_TYPE:
|
|
|
|
case SPLIT3:
|
|
|
|
case SPLIT4:
|
|
|
|
case NOCOLC1T:
|
|
|
|
case NOCOLC1B:
|
|
|
|
case NOCOLC2T:
|
|
|
|
case NOCOLC2B:
|
|
|
|
data++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TILT_TYPE:
|
2019-12-15 00:14:02 -03:00
|
|
|
TiltXOffset = xOff = (*data >> 8);
|
|
|
|
TiltYOffset = yOff = *(char *) data;
|
2019-12-10 18:25:48 +01:00
|
|
|
|
|
|
|
if ((abs(xOff)) > 2 || (abs(yOff)) > 2)
|
|
|
|
HeightType = BIG_SLOPE;
|
|
|
|
else
|
|
|
|
HeightType = SMALL_SLOPE;
|
|
|
|
|
|
|
|
if (xOff >= 0)
|
2019-12-14 08:43:34 +01:00
|
|
|
height += (xOff * ((-1 - z) & 1023) >> 2);
|
2019-12-10 18:25:48 +01:00
|
|
|
else
|
2019-12-14 08:43:34 +01:00
|
|
|
height -= (xOff * (z & 1023) >> 2);
|
2019-12-10 18:25:48 +01:00
|
|
|
|
|
|
|
if (yOff >= 0)
|
2019-12-14 08:43:34 +01:00
|
|
|
height += yOff * ((-1 - x) & 1023) >> 2;
|
2019-12-10 18:25:48 +01:00
|
|
|
else
|
2019-12-14 08:43:34 +01:00
|
|
|
height -= yOff * (x & 1023) >> 2;
|
2019-12-10 18:25:48 +01:00
|
|
|
|
|
|
|
data++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRIGGER_TYPE:
|
|
|
|
if (!TriggerIndex)
|
|
|
|
TriggerIndex = data - 1;
|
|
|
|
|
|
|
|
data++;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
trigger = *(data++);
|
|
|
|
|
|
|
|
if (TRIG_BITS(trigger) != TO_OBJECT)
|
|
|
|
{
|
|
|
|
if (TRIG_BITS(trigger) == TO_CAMERA ||
|
|
|
|
TRIG_BITS(trigger) == TO_FLYBY)
|
|
|
|
{
|
|
|
|
trigger = *(data++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item = &Items[trigger & VALUE_BITS];
|
|
|
|
obj = &Objects[item->objectNumber];
|
|
|
|
|
|
|
|
if (obj->floor && !(item->flags & 0x8000))
|
|
|
|
{
|
|
|
|
(obj->floor)(item, x, y, z, &height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (!(trigger& END_BIT));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAVA_TYPE:
|
|
|
|
TriggerIndex = data - 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLIMB_TYPE:
|
|
|
|
case MONKEY_TYPE:
|
|
|
|
case TRIGTRIGGER_TYPE:
|
|
|
|
if (!TriggerIndex)
|
|
|
|
TriggerIndex = data - 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SPLIT1:
|
|
|
|
case SPLIT2:
|
|
|
|
case NOCOLF1T:
|
|
|
|
case NOCOLF1B:
|
|
|
|
case NOCOLF2T:
|
|
|
|
case NOCOLF2B:
|
|
|
|
tilts = *data;
|
|
|
|
t0 = tilts & 15;
|
|
|
|
t1 = (tilts >> 4) & 15;
|
|
|
|
t2 = (tilts >> 8) & 15;
|
|
|
|
t3 = (tilts >> 12) & 15;
|
|
|
|
|
|
|
|
dx = x & 1023;
|
|
|
|
dz = z & 1023;
|
|
|
|
|
|
|
|
xOff = yOff = 0;
|
|
|
|
|
|
|
|
HeightType = SPLIT_TRI;
|
|
|
|
|
|
|
|
if ((type & DATA_TYPE) == SPLIT1 ||
|
|
|
|
(type & DATA_TYPE) == NOCOLF1T ||
|
|
|
|
(type & DATA_TYPE) == NOCOLF1B)
|
|
|
|
{
|
|
|
|
if (dx <= (1024 - dz))
|
|
|
|
{
|
2019-12-14 08:43:34 +01:00
|
|
|
hadj = (type >> 10) & 0x1F;
|
2019-12-10 18:25:48 +01:00
|
|
|
if (hadj & 0x10)
|
|
|
|
hadj |= 0xfff0;
|
2019-12-14 08:43:34 +01:00
|
|
|
height += 256 * hadj;
|
2019-12-10 18:25:48 +01:00
|
|
|
xOff = t2 - t1;
|
|
|
|
yOff = t0 - t1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-14 08:43:34 +01:00
|
|
|
hadj = (type >> 5) & 0x1F;
|
2019-12-10 18:25:48 +01:00
|
|
|
if (hadj & 0x10)
|
2019-12-14 08:43:34 +01:00
|
|
|
hadj |= 0xFFF0;
|
|
|
|
height += 256 * hadj;
|
2019-12-10 18:25:48 +01:00
|
|
|
xOff = t3 - t0;
|
|
|
|
yOff = t3 - t2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (dx <= dz)
|
|
|
|
{
|
|
|
|
hadj = (type >> 10) & 0x1f;
|
|
|
|
if (hadj & 0x10)
|
|
|
|
hadj |= 0xfff0;
|
2019-12-14 08:43:34 +01:00
|
|
|
height += 256 * hadj;
|
2019-12-10 18:25:48 +01:00
|
|
|
xOff = t2 - t1;
|
|
|
|
yOff = t3 - t2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hadj = (type >> 5) & 0x1f;
|
|
|
|
if (hadj & 0x10)
|
|
|
|
hadj |= 0xfff0;
|
2019-12-14 08:43:34 +01:00
|
|
|
height += 256 * hadj;
|
2019-12-10 18:25:48 +01:00
|
|
|
xOff = t3 - t0;
|
|
|
|
yOff = t0 - t1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TiltXOffset = xOff;
|
|
|
|
TiltYOffset = yOff;
|
|
|
|
|
|
|
|
if ((abs(xOff)) > 2 || (abs(yOff)) > 2)
|
|
|
|
HeightType = DIAGONAL;
|
|
|
|
else if (HeightType != SPLIT_TRI)
|
|
|
|
HeightType = SMALL_SLOPE;
|
|
|
|
|
|
|
|
if (xOff >= 0)
|
2019-12-14 08:43:34 +01:00
|
|
|
height += xOff * ((-1 - z) & 1023) >> 2;
|
2019-12-10 18:25:48 +01:00
|
|
|
else
|
2019-12-14 08:43:34 +01:00
|
|
|
height -= xOff * (z & 1023) >> 2;
|
2019-12-10 18:25:48 +01:00
|
|
|
|
|
|
|
if (yOff >= 0)
|
2019-12-14 08:43:34 +01:00
|
|
|
height += yOff * ((-1 - x) & 1023) >> 2;
|
2019-12-10 18:25:48 +01:00
|
|
|
else
|
2019-12-14 08:43:34 +01:00
|
|
|
height -= yOff * (x & 1023) >> 2;
|
2019-12-10 18:25:48 +01:00
|
|
|
|
|
|
|
data++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (!(type & END_BIT));
|
|
|
|
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
int LOS(GAME_VECTOR* start, GAME_VECTOR* end) // (F) (D)
|
2019-12-27 23:54:40 -03:00
|
|
|
{
|
|
|
|
int result1, result2;
|
|
|
|
|
|
|
|
end->roomNumber = start->roomNumber;
|
|
|
|
if (abs(end->z - start->z) > abs(end->x - start->x))
|
|
|
|
{
|
|
|
|
result1 = xLOS(start, end);
|
|
|
|
result2 = zLOS(start, end);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result1 = zLOS(start, end);
|
|
|
|
result2 = xLOS(start, end);
|
|
|
|
}
|
|
|
|
if (result2)
|
|
|
|
{
|
|
|
|
GetFloor(end->x, end->y, end->z, &end->roomNumber);
|
|
|
|
if (ClipTarget(start, end) && result1 == 1 && result2 == 1)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
int xLOS(GAME_VECTOR* start, GAME_VECTOR* end) // (F) (D)
|
2019-12-27 23:54:40 -03:00
|
|
|
{
|
|
|
|
int dx, dy, dz, x, y, z, flag;
|
|
|
|
short room, room2;
|
|
|
|
FLOOR_INFO* floor;
|
|
|
|
|
|
|
|
dx = end->x - start->x;
|
|
|
|
if (!dx)
|
|
|
|
return 1;
|
|
|
|
dy = (end->y - start->y << 10) / dx;
|
|
|
|
dz = (end->z - start->z << 10) / dx;
|
|
|
|
number_los_rooms = 1;
|
|
|
|
los_rooms[0] = start->roomNumber;
|
|
|
|
room = start->roomNumber;
|
|
|
|
room2 = start->roomNumber;
|
|
|
|
flag = 1;
|
|
|
|
if (dx < 0)
|
|
|
|
{
|
|
|
|
x = start->x & 0xFFFFFC00;
|
|
|
|
y = ((x - start->x) * dy >> 10) + start->y;
|
|
|
|
z = ((x - start->x) * dz >> 10) + start->z;
|
|
|
|
while (x > end->x)
|
|
|
|
{
|
|
|
|
floor = GetFloor(x, y, z, &room);
|
|
|
|
if (room != room2)
|
|
|
|
{
|
|
|
|
room2 = room;
|
|
|
|
los_rooms[number_los_rooms] = room;
|
|
|
|
++number_los_rooms;
|
|
|
|
}
|
|
|
|
if (y > GetFloorHeight(floor, x, y, z) || y < GetCeiling(floor, x, y, z))
|
|
|
|
{
|
|
|
|
flag = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
floor = GetFloor(x - 1, y, z, &room);
|
|
|
|
if (room != room2)
|
|
|
|
{
|
|
|
|
room2 = room;
|
|
|
|
los_rooms[number_los_rooms] = room;
|
|
|
|
++number_los_rooms;
|
|
|
|
}
|
|
|
|
if (y > GetFloorHeight(floor, x - 1, y, z) || y < GetCeiling(floor, x - 1, y, z))
|
|
|
|
{
|
|
|
|
flag = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
x -= 1024;
|
|
|
|
y -= dy;
|
|
|
|
z -= dz;
|
|
|
|
}
|
|
|
|
if (flag != 1)
|
|
|
|
{
|
|
|
|
end->x = x;
|
|
|
|
end->y = y;
|
|
|
|
end->z = z;
|
|
|
|
}
|
|
|
|
end->roomNumber = flag ? room : room2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = start->x | 0x3FF;
|
|
|
|
y = ((x - start->x) * dy >> 10) + start->y;
|
|
|
|
z = ((x - start->x) * dz >> 10) + start->z;
|
|
|
|
while (x < end->x)
|
|
|
|
{
|
|
|
|
floor = GetFloor(x, y, z, &room);
|
|
|
|
if (room != room2)
|
|
|
|
{
|
|
|
|
room2 = room;
|
|
|
|
los_rooms[number_los_rooms] = room;
|
|
|
|
++number_los_rooms;
|
|
|
|
}
|
|
|
|
if (y > GetFloorHeight(floor, x, y, z) || y < GetCeiling(floor, x, y, z))
|
|
|
|
{
|
|
|
|
flag = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
floor = GetFloor(x + 1, y, z, &room);
|
|
|
|
if (room != room2)
|
|
|
|
{
|
|
|
|
room2 = room;
|
|
|
|
los_rooms[number_los_rooms] = room;
|
|
|
|
++number_los_rooms;
|
|
|
|
}
|
|
|
|
if (y > GetFloorHeight(floor, x + 1, y, z) || y < GetCeiling(floor, x + 1, y, z))
|
|
|
|
{
|
|
|
|
flag = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
x += 1024;
|
|
|
|
y += dy;
|
|
|
|
z += dz;
|
|
|
|
}
|
|
|
|
if (flag != 1)
|
|
|
|
{
|
|
|
|
end->x = x;
|
|
|
|
end->y = y;
|
|
|
|
end->z = z;
|
|
|
|
}
|
|
|
|
end->roomNumber = flag ? room : room2;
|
|
|
|
}
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
int zLOS(GAME_VECTOR* start, GAME_VECTOR* end) // (F) (D)
|
2019-12-27 23:54:40 -03:00
|
|
|
{
|
|
|
|
int dx, dy, dz, x, y, z, flag;
|
|
|
|
short room, room2;
|
|
|
|
FLOOR_INFO* floor;
|
|
|
|
|
|
|
|
dz = end->z - start->z;
|
|
|
|
if (!dz)
|
|
|
|
return 1;
|
|
|
|
dx = (end->x - start->x << 10) / dz;
|
|
|
|
dy = (end->y - start->y << 10) / dz;
|
|
|
|
number_los_rooms = 1;
|
|
|
|
los_rooms[0] = start->roomNumber;
|
|
|
|
room = start->roomNumber;
|
|
|
|
room2 = start->roomNumber;
|
|
|
|
flag = 1;
|
|
|
|
if (dz < 0)
|
|
|
|
{
|
|
|
|
z = start->z & 0xFFFFFC00;
|
|
|
|
x = ((z - start->z) * dx >> 10) + start->x;
|
|
|
|
y = ((z - start->z) * dy >> 10) + start->y;
|
|
|
|
while (z > end->z)
|
|
|
|
{
|
|
|
|
floor = GetFloor(x, y, z, &room);
|
|
|
|
if (room != room2)
|
|
|
|
{
|
|
|
|
room2 = room;
|
|
|
|
los_rooms[number_los_rooms] = room;
|
|
|
|
++number_los_rooms;
|
|
|
|
}
|
|
|
|
if (y > GetFloorHeight(floor, x, y, z) || y < GetCeiling(floor, x, y, z))
|
|
|
|
{
|
|
|
|
flag = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
floor = GetFloor(x, y, z - 1, &room);
|
|
|
|
if (room != room2)
|
|
|
|
{
|
|
|
|
room2 = room;
|
|
|
|
los_rooms[number_los_rooms] = room;
|
|
|
|
++number_los_rooms;
|
|
|
|
}
|
|
|
|
if (y > GetFloorHeight(floor, x, y, z - 1) || y < GetCeiling(floor, x, y, z - 1))
|
|
|
|
{
|
|
|
|
flag = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
z -= 1024;
|
|
|
|
x -= dx;
|
|
|
|
y -= dy;
|
|
|
|
}
|
|
|
|
if (flag != 1)
|
|
|
|
{
|
|
|
|
end->x = x;
|
|
|
|
end->y = y;
|
|
|
|
end->z = z;
|
|
|
|
}
|
|
|
|
end->roomNumber = flag ? room : room2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
z = start->z | 0x3FF;
|
|
|
|
x = ((z - start->z) * dx >> 10) + start->x;
|
|
|
|
y = ((z - start->z) * dy >> 10) + start->y;
|
|
|
|
while (z < end->z)
|
|
|
|
{
|
|
|
|
floor = GetFloor(x, y, z, &room);
|
|
|
|
if (room != room2)
|
|
|
|
{
|
|
|
|
room2 = room;
|
|
|
|
los_rooms[number_los_rooms] = room;
|
|
|
|
++number_los_rooms;
|
|
|
|
}
|
|
|
|
if (y > GetFloorHeight(floor, x, y, z) || y < GetCeiling(floor, x, y, z))
|
|
|
|
{
|
|
|
|
flag = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
floor = GetFloor(x, y, z + 1, &room);
|
|
|
|
if (room != room2)
|
|
|
|
{
|
|
|
|
room2 = room;
|
|
|
|
los_rooms[number_los_rooms] = room;
|
|
|
|
++number_los_rooms;
|
|
|
|
}
|
|
|
|
if (y > GetFloorHeight(floor, x, y, z + 1) || y < GetCeiling(floor, x, y, z + 1))
|
|
|
|
{
|
|
|
|
flag = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
z += 1024;
|
|
|
|
x += dx;
|
|
|
|
y += dy;
|
|
|
|
}
|
|
|
|
if (flag != 1)
|
|
|
|
{
|
|
|
|
end->x = x;
|
|
|
|
end->y = y;
|
|
|
|
end->z = z;
|
|
|
|
}
|
|
|
|
end->roomNumber = flag ? room : room2;
|
|
|
|
}
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
int ClipTarget(GAME_VECTOR* start, GAME_VECTOR* target) // (F) (D)
|
2019-12-27 23:54:40 -03:00
|
|
|
{
|
|
|
|
short room;
|
|
|
|
int x, y, z, wx, wy, wz;
|
|
|
|
|
|
|
|
room = target->roomNumber;
|
|
|
|
if (target->y > GetFloorHeight(GetFloor(target->x, target->y, target->z, &room), target->x, target->y, target->z))
|
|
|
|
{
|
|
|
|
x = (7 * (target->x - start->x) >> 3) + start->x;
|
|
|
|
y = (7 * (target->y - start->y) >> 3) + start->y;
|
|
|
|
z = (7 * (target->z - start->z) >> 3) + start->z;
|
|
|
|
for (int i = 3; i > 0; --i)
|
|
|
|
{
|
|
|
|
wx = ((target->x - x) * i >> 2) + x;
|
|
|
|
wy = ((target->y - y) * i >> 2) + y;
|
|
|
|
wz = ((target->z - z) * i >> 2) + z;
|
|
|
|
if (wy < GetFloorHeight(GetFloor(wx, wy, wz, &room), wx, wy, wz))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
target->x = wx;
|
|
|
|
target->y = wy;
|
|
|
|
target->z = wz;
|
|
|
|
target->roomNumber = room;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
room = target->roomNumber;
|
|
|
|
if (target->y < GetCeiling(GetFloor(target->x, target->y, target->z, &room), target->x, target->y, target->z))
|
|
|
|
{
|
|
|
|
x = (7 * (target->x - start->x) >> 3) + start->x;
|
|
|
|
y = (7 * (target->y - start->y) >> 3) + start->y;
|
|
|
|
z = (7 * (target->z - start->z) >> 3) + start->z;
|
|
|
|
for (int i = 3; i > 0; --i)
|
|
|
|
{
|
|
|
|
wx = ((target->x - x) * i >> 2) + x;
|
|
|
|
wy = ((target->y - y) * i >> 2) + y;
|
|
|
|
wz = ((target->z - z) * i >> 2) + z;
|
|
|
|
if (wy > GetCeiling(GetFloor(wx, wy, wz, &room), wx, wy, wz))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
target->x = wx;
|
|
|
|
target->y = wy;
|
|
|
|
target->z = wz;
|
|
|
|
target->roomNumber = room;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2019-12-22 00:20:10 +01:00
|
|
|
|
2020-03-28 11:25:49 -03:00
|
|
|
int GetTargetOnLOS(GAME_VECTOR* src, GAME_VECTOR* dest, int DrawTarget, int firing) // (AF) (D)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
GAME_VECTOR target;
|
|
|
|
int result, flag, itemNumber, count;
|
|
|
|
MESH_INFO* mesh;
|
|
|
|
PHD_VECTOR vector;
|
|
|
|
ITEM_INFO* item;
|
|
|
|
short angle, room, triggerItems[8];
|
2020-03-29 10:38:29 +02:00
|
|
|
VECTOR dir;
|
|
|
|
Vector3 direction = Vector3(dest->x, dest->y, dest->z) - Vector3(src->x, src->y, src->z);
|
|
|
|
direction.Normalize();
|
2020-01-07 17:33:13 -03:00
|
|
|
target.x = dest->x;
|
|
|
|
target.y = dest->y;
|
|
|
|
target.z = dest->z;
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
result = LOS(src, &target);
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
GetFloor(target.x, target.y, target.z, &target.roomNumber);
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
if (firing && LaserSight)
|
|
|
|
{
|
|
|
|
Lara.hasFired = true;
|
|
|
|
Lara.fired = true;
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
if (Lara.gunType == WEAPON_REVOLVER)
|
|
|
|
{
|
|
|
|
SoundEffect(SFX_REVOLVER, NULL, 0);
|
|
|
|
}
|
|
|
|
}
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
flag = 0;
|
|
|
|
itemNumber = ObjectOnLOS2(src, dest, &vector, &mesh);
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
if (itemNumber != 999)
|
|
|
|
{
|
|
|
|
target.x = vector.x - (vector.x - src->x >> 5);
|
|
|
|
target.y = vector.y - (vector.y - src->y >> 5);
|
|
|
|
target.z = vector.z - (vector.z - src->z >> 5);
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
GetFloor(target.x, target.y, target.z, &target.roomNumber);
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
if (itemNumber >= 0)
|
|
|
|
Lara.target = &Items[itemNumber];
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
if (firing)
|
|
|
|
{
|
|
|
|
if (Lara.gunType != WEAPON_CROSSBOW)
|
|
|
|
{
|
|
|
|
if (itemNumber < 0)
|
|
|
|
{
|
|
|
|
if (mesh->staticNumber >= 50 && mesh->staticNumber < 58)
|
|
|
|
{
|
2020-04-01 07:24:15 +02:00
|
|
|
ShatterImpactData.impactDirection = direction;
|
2020-04-05 17:36:24 +02:00
|
|
|
ShatterImpactData.impactLocation = Vector3(mesh->x, mesh->y, mesh->z);
|
2020-04-01 07:24:15 +02:00
|
|
|
ShatterObject(NULL, mesh, 128, target.roomNumber, 0);
|
|
|
|
//ShatterObject(NULL, mesh, 128, target.roomNumber, 0);
|
2020-01-07 17:33:13 -03:00
|
|
|
SmashedMeshRoom[SmashedMeshCount] = target.roomNumber;
|
|
|
|
SmashedMesh[SmashedMeshCount] = mesh;
|
|
|
|
++SmashedMeshCount;
|
|
|
|
mesh->Flags &= ~0x1;
|
|
|
|
SoundEffect(ShatterSounds[CurrentLevel - 5][mesh->staticNumber], (PHD_3DPOS *) mesh, 0);
|
|
|
|
}
|
|
|
|
TriggerRicochetSpark(&target, LaraItem->pos.yRot, 3, 0);
|
|
|
|
TriggerRicochetSpark(&target, LaraItem->pos.yRot, 3, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item = &Items[itemNumber];
|
|
|
|
if (item->objectNumber != ID_SHOOT_SWITCH1 && item->objectNumber != ID_SHOOT_SWITCH2)
|
|
|
|
{
|
2020-04-05 08:15:56 +02:00
|
|
|
if (Objects[item->objectNumber].explodableMeshbits & ShatterItem.bit && LaserSight)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
if (!Objects[item->objectNumber].intelligent)
|
|
|
|
{
|
2020-04-05 08:15:56 +02:00
|
|
|
item->meshBits &= ~ShatterItem.bit;
|
2020-04-01 07:24:15 +02:00
|
|
|
ShatterImpactData.impactDirection = direction;
|
2020-04-05 17:36:24 +02:00
|
|
|
ShatterImpactData.impactLocation = Vector3(ShatterItem.sphere.x, ShatterItem.sphere.y,ShatterItem.sphere.z);
|
2020-04-01 07:24:15 +02:00
|
|
|
ShatterObject(&ShatterItem, 0, 128, target.roomNumber, 0);
|
2020-01-07 17:33:13 -03:00
|
|
|
TriggerRicochetSpark(&target, LaraItem->pos.yRot, 3, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-03-14 07:48:35 +01:00
|
|
|
if (item->objectNumber != ID_GUARD_LASER)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
item->hitPoints -= 30;
|
|
|
|
if (item->hitPoints < 0)
|
|
|
|
item->hitPoints = 0;
|
|
|
|
HitTarget(item, &target, WeaponsArray[Lara.gunType].damage, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
angle = ATAN(LaraItem->pos.zPos - item->pos.zPos, LaraItem->pos.xPos - item->pos.xPos) - item->pos.yRot;
|
|
|
|
if (angle > -ANGLE(90) && angle < ANGLE(90))
|
|
|
|
{
|
|
|
|
item->hitPoints = 0;
|
|
|
|
HitTarget(item, &target, WeaponsArray[Lara.gunType].damage, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (DrawTarget && (Lara.gunType == WEAPON_REVOLVER || Lara.gunType == WEAPON_HK))
|
|
|
|
{
|
|
|
|
if (Objects[item->objectNumber].intelligent)
|
|
|
|
{
|
|
|
|
HitTarget(item, &target, WeaponsArray[Lara.gunType].damage, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Objects[item->objectNumber].hitEffect == 3)
|
|
|
|
TriggerRicochetSpark(&target, LaraItem->pos.yRot, 3, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (item->objectNumber >= ID_SMASH_OBJECT1 && item->objectNumber <= ID_SMASH_OBJECT8)
|
|
|
|
{
|
|
|
|
SmashObject(itemNumber);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Objects[item->objectNumber].hitEffect == 1)
|
|
|
|
{
|
|
|
|
DoBloodSplat(target.x, target.y, target.z, (GetRandomControl() & 3) + 3, item->pos.yRot, item->roomNumber);
|
|
|
|
}
|
|
|
|
else if (Objects[item->objectNumber].hitEffect == 2)
|
|
|
|
{
|
|
|
|
TriggerRicochetSpark(&target, LaraItem->pos.yRot, 3, -5);
|
|
|
|
}
|
|
|
|
else if (Objects[item->objectNumber].hitEffect == 3)
|
|
|
|
{
|
|
|
|
TriggerRicochetSpark(&target, LaraItem->pos.yRot, 3, 0);
|
|
|
|
}
|
|
|
|
item->hitStatus = true;
|
|
|
|
if (!Objects[item->objectNumber].undead)
|
|
|
|
{
|
|
|
|
item->hitPoints -= WeaponsArray[Lara.gunType].damage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-05 08:15:56 +02:00
|
|
|
if (ShatterItem.bit == 1 << Objects[item->objectNumber].nmeshes - 1)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
if (!(item->flags & 0x40))
|
|
|
|
{
|
|
|
|
if (item->objectNumber == ID_SHOOT_SWITCH1)
|
|
|
|
ExplodeItemNode(item, Objects[item->objectNumber].nmeshes - 1, 0, 64);
|
|
|
|
if (item->triggerFlags == 444 && item->objectNumber == ID_SHOOT_SWITCH2)
|
|
|
|
{
|
|
|
|
ProcessExplodingSwitchType8(item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (item->flags & IFLAG_ACTIVATION_MASK && (item->flags & IFLAG_ACTIVATION_MASK) != IFLAG_ACTIVATION_MASK)
|
|
|
|
{
|
|
|
|
room = item->roomNumber;
|
|
|
|
GetFloorHeight(GetFloor(item->pos.xPos, item->pos.yPos - 256, item->pos.zPos, &room), item->pos.xPos, item->pos.yPos - 256, item->pos.zPos);
|
|
|
|
TestTriggers(TriggerIndex, 1, item->flags & IFLAG_ACTIVATION_MASK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (count = GetSwitchTrigger(item, triggerItems, 1); count > 0; --count)
|
|
|
|
{
|
2020-01-08 16:01:57 -03:00
|
|
|
AddActiveItem(triggerItems[count - 1]);
|
|
|
|
Items[triggerItems[count - 1]].status = ITEM_ACTIVE;
|
|
|
|
Items[triggerItems[count - 1]].flags |= IFLAG_ACTIVATION_MASK;
|
2020-01-07 17:33:13 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (item->status != ITEM_DEACTIVATED)
|
|
|
|
{
|
|
|
|
AddActiveItem(itemNumber);
|
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
item->flags |= IFLAG_ACTIVATION_MASK | 0x40;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TriggerRicochetSpark(&target, LaraItem->pos.yRot, 3, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (LaserSight && itemNumber >= 0)
|
|
|
|
{
|
|
|
|
item = &Items[itemNumber];
|
|
|
|
if (item->objectNumber == ID_ENEMY_JEEP && item->meshBits & 1)
|
|
|
|
{
|
|
|
|
/* @FIXME This turns the LaserSight sprite of the Grappling Gun green and calls FireGrapplingBoltFromLasersight() */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (itemNumber >= 0)
|
|
|
|
{
|
|
|
|
item = &Items[itemNumber];
|
|
|
|
if (item->objectNumber == ID_ENEMY_JEEP && Lara.gunType == WEAPON_CROSSBOW && item->meshBits & 1)
|
|
|
|
{
|
|
|
|
/* @FIXME This turns the LaserSight sprite of the Grappling Gun green */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Lara.gunType != WEAPON_CROSSBOW)
|
|
|
|
{
|
|
|
|
target.x -= target.x - src->x >> 5;
|
|
|
|
target.y -= target.y - src->y >> 5;
|
|
|
|
target.z -= target.z - src->z >> 5;
|
|
|
|
if (firing && !result)
|
|
|
|
TriggerRicochetSpark(&target, LaraItem->pos.yRot, 8, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (firing && LaserSight)
|
|
|
|
{
|
|
|
|
/* @FIXME This calls FireGrapplingBoltFromLasersight() */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
if (DrawTarget && (flag || !result))
|
|
|
|
{
|
|
|
|
TriggerDynamicLight(target.x, target.y, target.z, 64, 255, 0, 0);
|
|
|
|
LaserSightActive = 1;
|
|
|
|
LaserSightX = target.x;
|
|
|
|
LaserSightY = target.y;
|
|
|
|
LaserSightZ = target.z;
|
|
|
|
}
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
int ObjectOnLOS2(GAME_VECTOR* start, GAME_VECTOR* end, PHD_VECTOR* vec, MESH_INFO** mesh) // (F) (D)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
int r, m;
|
|
|
|
ROOM_INFO* room;
|
|
|
|
short linknum, *box;
|
|
|
|
ITEM_INFO* item;
|
|
|
|
PHD_3DPOS pos;
|
|
|
|
MESH_INFO* meshp;
|
|
|
|
|
|
|
|
ClosestItem = 999;
|
2020-01-08 08:06:33 +01:00
|
|
|
ClosestDist = SQUARE(end->x - start->x)
|
|
|
|
+ SQUARE(end->y - start->y)
|
|
|
|
+ SQUARE(end->z - start->z);
|
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
for (r = 0; r < number_los_rooms; ++r)
|
|
|
|
{
|
|
|
|
room = &Rooms[los_rooms[r]];
|
2020-01-08 08:06:33 +01:00
|
|
|
|
|
|
|
for (m = 0; m < room->numMeshes; m++)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
meshp = &room->mesh[m];
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
if (meshp->Flags & 1)
|
|
|
|
{
|
|
|
|
pos.xPos = meshp->x;
|
|
|
|
pos.yPos = meshp->y;
|
|
|
|
pos.zPos = meshp->z;
|
|
|
|
pos.yRot = meshp->yRot;
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
if (DoRayBox(start, end, &StaticObjects[meshp->staticNumber].xMinc, &pos, vec, -1 - meshp->staticNumber))
|
|
|
|
{
|
|
|
|
*mesh = meshp;
|
|
|
|
end->roomNumber = los_rooms[r];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-08 08:06:33 +01:00
|
|
|
|
|
|
|
for (linknum = room->itemNumber; linknum != NO_ITEM; linknum = Items[linknum].nextItem)
|
|
|
|
{
|
|
|
|
item = &Items[linknum];
|
|
|
|
|
|
|
|
if (item->status != ITEM_DEACTIVATED
|
|
|
|
&& item->status != ITEM_INVISIBLE
|
2020-01-08 16:01:57 -03:00
|
|
|
&& (item->objectNumber != ID_LARA && Objects[item->objectNumber].collision != NULL
|
|
|
|
|| item->objectNumber == ID_LARA && GetLaraOnLOS))
|
2020-01-08 08:06:33 +01:00
|
|
|
{
|
|
|
|
box = GetBoundsAccurate(item);
|
|
|
|
|
|
|
|
pos.xPos = item->pos.xPos;
|
|
|
|
pos.yPos = item->pos.yPos;
|
|
|
|
pos.zPos = item->pos.zPos;
|
|
|
|
pos.yRot = item->pos.yRot;
|
|
|
|
|
|
|
|
if (DoRayBox(start, end, box, &pos, vec, linknum))
|
|
|
|
{
|
|
|
|
end->roomNumber = los_rooms[r];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-07 17:33:13 -03:00
|
|
|
}
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
vec->x = ClosestCoord.x;
|
|
|
|
vec->y = ClosestCoord.y;
|
|
|
|
vec->z = ClosestCoord.z;
|
2020-01-08 08:06:33 +01:00
|
|
|
|
2020-01-07 17:33:13 -03:00
|
|
|
return ClosestItem;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
int GetRandomControl() // (F) (D)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
rand_1 = 1103515245 * rand_1 + 12345;
|
|
|
|
return rand_1 >> 10 & 0x7FFF;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
void SeedRandomControl(int seed) // (F) (D)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
rand_1 = seed;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
int GetRandomDraw() // (F) (D)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
rand_2 = 1103515245 * rand_2 + 12345;
|
|
|
|
return rand_2 >> 10 & 0x7FFF;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
void SeedRandomDraw(int seed) // (F) (D)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
rand_2 = seed;
|
|
|
|
}
|
|
|
|
|
2020-03-21 14:48:37 -03:00
|
|
|
int GetCeiling(FLOOR_INFO* floor, int x, int y, int z) // (F) (D)
|
2020-01-07 17:33:13 -03:00
|
|
|
{
|
|
|
|
ROOM_INFO* room;
|
|
|
|
FLOOR_INFO* floor2;
|
|
|
|
int ceiling, t0, t1, t2, t3, dx, dz, xOff, yOff;
|
|
|
|
short type, type2, function, cadj, trigger, *data;
|
|
|
|
bool end;
|
|
|
|
ITEM_INFO* item;
|
|
|
|
|
|
|
|
floor2 = floor;
|
|
|
|
while (floor2->skyRoom != NO_ROOM)
|
|
|
|
{
|
2020-03-28 11:25:49 -03:00
|
|
|
if (CheckNoColCeilingTriangle(floor, x, z) == 1) /* @ORIGINAL_BUG: the call is made with floor (which is constant in the while loop) instead of floor2 */
|
2020-01-07 17:33:13 -03:00
|
|
|
break;
|
|
|
|
room = &Rooms[floor2->skyRoom];
|
|
|
|
floor2 = &XZ_GET_SECTOR(room, x - room->x, z - room->z);
|
|
|
|
}
|
|
|
|
ceiling = 256 * floor2->ceiling;
|
|
|
|
if (ceiling != NO_HEIGHT)
|
|
|
|
{
|
|
|
|
if (floor2->index)
|
|
|
|
{
|
|
|
|
data = &FloorData[floor2->index];
|
|
|
|
type = *data;
|
|
|
|
function = type & DATA_TYPE;
|
|
|
|
++data;
|
|
|
|
end = false;
|
|
|
|
if (function == TILT_TYPE || function == SPLIT1 || function == SPLIT2 || function == NOCOLF1T || function == NOCOLF1B || function == NOCOLF2T || function == NOCOLF2B)
|
|
|
|
{
|
|
|
|
++data;
|
|
|
|
if (type & END_BIT)
|
|
|
|
end = true;
|
|
|
|
type = *data;
|
|
|
|
function = type & DATA_TYPE;
|
|
|
|
++data;
|
|
|
|
}
|
|
|
|
if (!end)
|
|
|
|
{
|
|
|
|
xOff = 0;
|
|
|
|
yOff = 0;
|
|
|
|
if (function != ROOF_TYPE)
|
|
|
|
{
|
|
|
|
if (function == SPLIT3 || function == SPLIT4 || function == NOCOLC1T || function == NOCOLC1B || function == NOCOLC2T || function == NOCOLC2B)
|
|
|
|
{
|
|
|
|
dx = x & 0x3FF;
|
|
|
|
dz = z & 0x3FF;
|
|
|
|
t0 = -(*data & DATA_TILT);
|
|
|
|
t1 = -(*data >> 4 & DATA_TILT);
|
|
|
|
t2 = -(*data >> 8 & DATA_TILT);
|
|
|
|
t3 = -(*data >> 12 & DATA_TILT);
|
|
|
|
if (function == SPLIT3 || function == NOCOLC1T || function == NOCOLC1B)
|
|
|
|
{
|
|
|
|
if (dx <= 1024 - dz)
|
|
|
|
{
|
|
|
|
cadj = type >> 10 & DATA_TYPE;
|
|
|
|
if (cadj & 0x10)
|
|
|
|
cadj |= 0xFFF0;
|
|
|
|
ceiling += 256 * cadj;
|
|
|
|
xOff = t2 - t1;
|
|
|
|
yOff = t3 - t2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cadj = type >> 5 & DATA_TYPE;
|
|
|
|
if (cadj & 0x10)
|
|
|
|
cadj |= 0xFFF0;
|
|
|
|
ceiling += 256 * cadj;
|
|
|
|
xOff = t3 - t0;
|
|
|
|
yOff = t0 - t1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (dx <= dz)
|
|
|
|
{
|
|
|
|
cadj = type >> 10 & DATA_TYPE;
|
|
|
|
if (cadj & 0x10)
|
|
|
|
cadj |= 0xFFF0;
|
|
|
|
ceiling += 256 * cadj;
|
|
|
|
xOff = t2 - t1;
|
|
|
|
yOff = t0 - t1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cadj = type >> 5 & DATA_TYPE;
|
|
|
|
if (cadj & 0x10)
|
|
|
|
cadj |= 0xFFF0;
|
|
|
|
ceiling += 256 * cadj;
|
|
|
|
xOff = t3 - t0;
|
|
|
|
yOff = t3 - t2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xOff = *data >> 8;
|
|
|
|
yOff = *(char *)data;
|
|
|
|
}
|
|
|
|
if (xOff < 0)
|
|
|
|
{
|
|
|
|
ceiling += (z & 0x3FF) * xOff >> 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ceiling -= (-1 - z & 0x3FF) * xOff >> 2;
|
|
|
|
}
|
|
|
|
if (yOff < 0)
|
|
|
|
{
|
|
|
|
ceiling += (-1 - x & 0x3FF) * yOff >> 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ceiling -= (x & 0x3FF) * yOff >> 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (floor->pitRoom != NO_ROOM)
|
|
|
|
{
|
|
|
|
if (CheckNoColFloorTriangle(floor, x, z) == 1)
|
|
|
|
break;
|
|
|
|
room = &Rooms[floor->pitRoom];
|
|
|
|
floor = &XZ_GET_SECTOR(room, x - room->x, z - room->z);
|
|
|
|
}
|
|
|
|
if (floor->index)
|
|
|
|
{
|
|
|
|
data = &FloorData[floor->index];
|
|
|
|
do
|
|
|
|
{
|
|
|
|
type = *data;
|
|
|
|
function = type & DATA_TYPE;
|
|
|
|
++data;
|
|
|
|
switch (function)
|
|
|
|
{
|
|
|
|
case DOOR_TYPE:
|
|
|
|
case TILT_TYPE:
|
|
|
|
case ROOF_TYPE:
|
|
|
|
case SPLIT1:
|
|
|
|
case SPLIT2:
|
|
|
|
case SPLIT3:
|
|
|
|
case SPLIT4:
|
|
|
|
case NOCOLF1T:
|
|
|
|
case NOCOLF1B:
|
|
|
|
case NOCOLF2T:
|
|
|
|
case NOCOLF2B:
|
|
|
|
case NOCOLC1T:
|
|
|
|
case NOCOLC1B:
|
|
|
|
case NOCOLC2T:
|
|
|
|
case NOCOLC2B:
|
|
|
|
++data;
|
|
|
|
break;
|
|
|
|
case TRIGGER_TYPE:
|
|
|
|
++data;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
type2 = *data;
|
|
|
|
trigger = TRIG_BITS(type2);
|
|
|
|
++data;
|
|
|
|
if (trigger != TO_OBJECT)
|
|
|
|
{
|
|
|
|
if (trigger == TO_CAMERA || trigger == TO_FLYBY)
|
|
|
|
{
|
|
|
|
type2 = *data;
|
|
|
|
++data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item = &Items[type2 & VALUE_BITS];
|
|
|
|
if (Objects[item->objectNumber].ceiling && !(item->flags & 0x8000))
|
|
|
|
{
|
|
|
|
Objects[item->objectNumber].ceiling(item, x, y, z, &ceiling);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!(type2 & END_BIT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!(type & END_BIT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ceiling;
|
|
|
|
}
|
|
|
|
|
2020-01-07 11:06:26 +01:00
|
|
|
int DoRayBox(GAME_VECTOR* start, GAME_VECTOR* end, short* box, PHD_3DPOS* itemOrStaticPos, PHD_VECTOR* hitPos, short closesItemNumber)
|
|
|
|
{
|
|
|
|
PHD_VECTOR p1, p2;
|
|
|
|
|
|
|
|
p1.x = box[0] << 16;
|
|
|
|
p2.x = box[1] << 16;
|
|
|
|
p1.y = box[2] << 16;
|
|
|
|
p2.y = box[3] << 16;
|
|
|
|
p1.z = box[4] << 16;
|
|
|
|
p2.z = box[5] << 16;
|
|
|
|
|
|
|
|
int dx2 = end->x - itemOrStaticPos->xPos;
|
|
|
|
int dy2 = end->y - itemOrStaticPos->yPos;
|
|
|
|
int dz2 = end->z - itemOrStaticPos->zPos;
|
|
|
|
|
|
|
|
phd_PushUnitMatrix();
|
|
|
|
|
|
|
|
phd_RotY(-itemOrStaticPos->yRot);
|
|
|
|
|
|
|
|
int a1 = MatrixPtr[M00] * dx2 +
|
|
|
|
MatrixPtr[M01] * dy2 +
|
|
|
|
MatrixPtr[M02] * dz2;
|
|
|
|
|
|
|
|
int a2 = MatrixPtr[M10] * dx2 +
|
|
|
|
MatrixPtr[M11] * dy2 +
|
|
|
|
MatrixPtr[M12] * dz2;
|
|
|
|
|
|
|
|
int a3 = MatrixPtr[M20] * dx2 +
|
|
|
|
MatrixPtr[M21] * dy2 +
|
|
|
|
MatrixPtr[M22] * dz2;
|
|
|
|
|
|
|
|
int dx1 = start->x - itemOrStaticPos->xPos;
|
|
|
|
int dy1 = start->y - itemOrStaticPos->yPos;
|
|
|
|
int dz1 = start->z - itemOrStaticPos->zPos;
|
|
|
|
|
|
|
|
int b1 = MatrixPtr[M00] * dx1 +
|
|
|
|
MatrixPtr[M01] * dy1 +
|
|
|
|
MatrixPtr[M02] * dz1;
|
|
|
|
|
|
|
|
int b2 = MatrixPtr[M10] * dx1 +
|
|
|
|
MatrixPtr[M11] * dy1 +
|
|
|
|
MatrixPtr[M12] * dz1;
|
|
|
|
|
|
|
|
int b3 = MatrixPtr[M20] * dx1 +
|
|
|
|
MatrixPtr[M21] * dy1 +
|
|
|
|
MatrixPtr[M22] * dz1;
|
|
|
|
|
|
|
|
phd_PopMatrix();
|
|
|
|
|
|
|
|
PHD_VECTOR vec;
|
|
|
|
|
|
|
|
vec.x = ((a1 >> W2V_SHIFT) - (b1 >> W2V_SHIFT)) << 16;
|
|
|
|
vec.y = ((a2 >> W2V_SHIFT) - (b2 >> W2V_SHIFT)) << 16;
|
|
|
|
vec.z = ((a3 >> W2V_SHIFT) - (b3 >> W2V_SHIFT)) << 16;
|
|
|
|
|
2020-01-25 23:31:26 -03:00
|
|
|
NormaliseRopeVector(&vec);
|
2020-01-07 11:06:26 +01:00
|
|
|
|
|
|
|
PHD_VECTOR pb;
|
|
|
|
pb.x = b1 >> W2V_SHIFT << 16;
|
|
|
|
pb.y = b2 >> W2V_SHIFT << 16;
|
|
|
|
pb.z = b3 >> W2V_SHIFT << 16;
|
|
|
|
|
|
|
|
vec.x <<= 8;
|
|
|
|
vec.y <<= 8;
|
|
|
|
vec.z <<= 8;
|
|
|
|
|
|
|
|
if (!DoRayBox_sub_401523(&p1, &p2, &pb, &vec, hitPos))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (hitPos->x < box[0]
|
|
|
|
|| hitPos->y < box[2]
|
|
|
|
|| hitPos->z < box[4]
|
|
|
|
|| hitPos->x > box[1]
|
|
|
|
|| hitPos->y > box[3]
|
|
|
|
|| hitPos->z > box[5])
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
phd_PushUnitMatrix();
|
|
|
|
|
|
|
|
phd_RotY(itemOrStaticPos->yRot);
|
|
|
|
|
|
|
|
int c1 = MatrixPtr[M00] * hitPos->x +
|
|
|
|
MatrixPtr[M01] * hitPos->y +
|
|
|
|
MatrixPtr[M02] * hitPos->z;
|
|
|
|
|
|
|
|
int c2 = MatrixPtr[M10] * hitPos->x +
|
|
|
|
MatrixPtr[M11] * hitPos->y +
|
|
|
|
MatrixPtr[M12] * hitPos->z;
|
|
|
|
|
|
|
|
int c3 = MatrixPtr[M20] * hitPos->x +
|
|
|
|
MatrixPtr[M21] * hitPos->y +
|
|
|
|
MatrixPtr[M22] * hitPos->z;
|
|
|
|
|
|
|
|
hitPos->x = (c1 >> W2V_SHIFT);
|
|
|
|
hitPos->y = (c2 >> W2V_SHIFT);
|
|
|
|
hitPos->z = (c3 >> W2V_SHIFT);
|
|
|
|
|
|
|
|
phd_PopMatrix();
|
|
|
|
|
|
|
|
short* meshPtr = NULL;
|
2020-04-05 08:15:56 +02:00
|
|
|
int bit = 0;
|
2020-01-07 11:06:26 +01:00
|
|
|
int sp = -2;
|
|
|
|
int minDistance = 0x7FFFFFFF;
|
|
|
|
|
2020-04-05 08:15:56 +02:00
|
|
|
int action = TrInput & IN_ACTION;
|
|
|
|
|
2020-01-07 11:06:26 +01:00
|
|
|
if (closesItemNumber < 0)
|
|
|
|
{
|
|
|
|
sp = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &Items[closesItemNumber];
|
|
|
|
OBJECT_INFO* obj = &Objects[item->objectNumber];
|
|
|
|
|
|
|
|
GetSpheres(item, SphereList, 1);
|
|
|
|
|
2020-04-05 08:15:56 +02:00
|
|
|
SPHERE spheres[34];
|
|
|
|
memcpy(spheres, SphereList, sizeof(SPHERE) * 34);
|
2020-01-07 11:06:26 +01:00
|
|
|
if (obj->nmeshes <= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
meshPtr = Meshes[obj->meshIndex];
|
|
|
|
|
|
|
|
for (int i = 0; i < obj->nmeshes; i++)
|
|
|
|
{
|
|
|
|
if (item->meshBits & (1 << i))
|
|
|
|
{
|
|
|
|
SPHERE* sphere = &SphereList[i];
|
|
|
|
|
|
|
|
if (item->meshBits & (1 << i))
|
|
|
|
{
|
|
|
|
SPHERE* sphere = &SphereList[i];
|
|
|
|
|
|
|
|
int dx = end->x - start->x;
|
|
|
|
int dy = end->y - start->y;
|
|
|
|
int dz = end->z - start->z;
|
|
|
|
|
|
|
|
int d1 = dx * (sphere->x - start->x) + dy * (sphere->y - start->y) + dz * (sphere->z - start->z);
|
|
|
|
int d2 = SQUARE(dx) + SQUARE(dy) + SQUARE(dz);
|
|
|
|
|
|
|
|
if ((d1 < 0 && d2 < 0) || (d1 > 0 && d2 > 0) || abs(d1) <= abs(d2))
|
|
|
|
{
|
|
|
|
int l;
|
|
|
|
if (d2 >> 16)
|
|
|
|
l = d1 / (d2 >> 16);
|
|
|
|
else
|
|
|
|
l = 0;
|
|
|
|
|
|
|
|
int x = start->x + (l * dx >> 16);
|
|
|
|
int y = start->y + (l * dy >> 16);
|
|
|
|
int z = start->z + (l * dz >> 16);
|
|
|
|
|
|
|
|
int d = SQUARE(x - sphere->x) + SQUARE(y - sphere->y) + SQUARE(z - sphere->z);
|
|
|
|
|
|
|
|
if (d <= SQUARE(sphere->r))
|
|
|
|
{
|
|
|
|
int newDist = SQUARE(sphere->x - start->x) + SQUARE(sphere->y - start->y) + SQUARE(sphere->z - start->z);
|
|
|
|
|
|
|
|
if (newDist < minDistance)
|
|
|
|
{
|
|
|
|
minDistance = newDist;
|
2020-03-16 22:27:50 +01:00
|
|
|
meshPtr = Meshes[obj->meshIndex + i];
|
2020-01-07 11:06:26 +01:00
|
|
|
bit = 1 << i;
|
|
|
|
sp = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sp < -1)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-05 08:15:56 +02:00
|
|
|
printf("Bit: %d \n", bit);
|
|
|
|
|
2020-01-07 11:06:26 +01:00
|
|
|
int distance = SQUARE(hitPos->x + itemOrStaticPos->xPos - start->x)
|
|
|
|
+ SQUARE(hitPos->y + itemOrStaticPos->yPos - start->y)
|
|
|
|
+ SQUARE(hitPos->z + itemOrStaticPos->zPos - start->z);
|
|
|
|
|
|
|
|
if (distance >= ClosestDist)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ClosestCoord.x = hitPos->x + itemOrStaticPos->xPos;
|
|
|
|
ClosestCoord.y = hitPos->y + itemOrStaticPos->yPos;
|
|
|
|
ClosestCoord.z = hitPos->z + itemOrStaticPos->zPos;
|
|
|
|
ClosestDist = distance;
|
|
|
|
ClosestItem = closesItemNumber;
|
|
|
|
|
|
|
|
if (sp >= 0)
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &Items[closesItemNumber];
|
|
|
|
|
|
|
|
GetSpheres(item, SphereList, 3);
|
|
|
|
|
|
|
|
ShatterItem.yRot = item->pos.yRot;
|
|
|
|
ShatterItem.meshp = meshPtr;
|
|
|
|
ShatterItem.sphere.x = SphereList[sp].x;
|
|
|
|
ShatterItem.sphere.y = SphereList[sp].y;
|
|
|
|
ShatterItem.sphere.z = SphereList[sp].z;
|
|
|
|
ShatterItem.bit = bit;
|
|
|
|
ShatterItem.flags = 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-01-08 13:25:42 +01:00
|
|
|
void AnimateItem(ITEM_INFO* item)
|
|
|
|
{
|
|
|
|
item->touchBits = 0;
|
|
|
|
item->hitStatus = false;
|
|
|
|
|
|
|
|
item->frameNumber++;
|
|
|
|
|
|
|
|
ANIM_STRUCT* anim = &Anims[item->animNumber];
|
|
|
|
if (anim->numberChanges > 0 && GetChange(item, anim))
|
|
|
|
{
|
|
|
|
anim = &Anims[item->animNumber];
|
|
|
|
|
|
|
|
item->currentAnimState = anim->currentAnimState;
|
|
|
|
|
|
|
|
if (item->requiredAnimState == item->currentAnimState)
|
|
|
|
item->requiredAnimState = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item->frameNumber > anim->frameEnd)
|
|
|
|
{
|
|
|
|
if (anim->numberCommands > 0)
|
|
|
|
{
|
|
|
|
short* cmd = &Commands[anim->commandIndex];
|
|
|
|
for (int i = anim->numberCommands; i > 0; i--)
|
|
|
|
{
|
|
|
|
switch (*(cmd++))
|
|
|
|
{
|
|
|
|
case COMMAND_MOVE_ORIGIN:
|
|
|
|
TranslateItem(item, cmd[0], cmd[1], cmd[2]);
|
|
|
|
cmd += 3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMMAND_JUMP_VELOCITY:
|
|
|
|
item->fallspeed = *(cmd++);
|
|
|
|
item->speed = *(cmd++);
|
|
|
|
item->gravityStatus = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMMAND_DEACTIVATE:
|
|
|
|
if (Objects[item->objectNumber].intelligent && !item->afterDeath)
|
|
|
|
item->afterDeath = 1;
|
|
|
|
item->status = ITEM_DEACTIVATED;
|
|
|
|
break;
|
|
|
|
case COMMAND_SOUND_FX:
|
|
|
|
case COMMAND_EFFECT:
|
|
|
|
cmd += 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
item->animNumber = anim->jumpAnimNum;
|
|
|
|
item->frameNumber = anim->jumpFrameNum;
|
|
|
|
|
|
|
|
anim = &Anims[item->animNumber];
|
|
|
|
|
|
|
|
if (item->currentAnimState != anim->currentAnimState)
|
|
|
|
{
|
|
|
|
item->currentAnimState = anim->currentAnimState;
|
|
|
|
item->goalAnimState = anim->currentAnimState;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item->requiredAnimState == item->currentAnimState)
|
|
|
|
item->requiredAnimState = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anim->numberCommands > 0)
|
|
|
|
{
|
|
|
|
short* cmd = &Commands[anim->commandIndex];
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
for (int i = anim->numberCommands; i > 0; i--)
|
|
|
|
{
|
|
|
|
switch (*(cmd++))
|
|
|
|
{
|
|
|
|
case COMMAND_MOVE_ORIGIN:
|
|
|
|
cmd += 3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMMAND_JUMP_VELOCITY:
|
|
|
|
cmd += 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMMAND_SOUND_FX:
|
|
|
|
if (item->frameNumber != *cmd)
|
|
|
|
{
|
|
|
|
cmd += 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags = cmd[1] & 0xC000;
|
|
|
|
|
|
|
|
if (!Objects[item->objectNumber].waterCreature)
|
|
|
|
{
|
|
|
|
if (item->roomNumber == NO_ROOM)
|
|
|
|
{
|
|
|
|
item->pos.xPos = LaraItem->pos.xPos;
|
|
|
|
item->pos.yPos = LaraItem->pos.yPos - 762;
|
|
|
|
item->pos.zPos = LaraItem->pos.zPos;
|
|
|
|
|
|
|
|
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 2);
|
|
|
|
}
|
|
|
|
else if (Rooms[item->roomNumber].flags & ENV_FLAG_WATER)
|
|
|
|
{
|
|
|
|
if (!flags
|
|
|
|
|| flags == SFX_WATERONLY
|
|
|
|
&& (Rooms[Camera.pos.roomNumber].flags & ENV_FLAG_WATER
|
|
|
|
|| Objects[item->objectNumber].intelligent))
|
|
|
|
{
|
|
|
|
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!flags || flags == SFX_LANDONLY && !(Rooms[Camera.pos.roomNumber].flags & ENV_FLAG_WATER))
|
|
|
|
{
|
|
|
|
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Rooms[Camera.pos.roomNumber].flags & ENV_FLAG_WATER)
|
|
|
|
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 1);
|
|
|
|
else
|
|
|
|
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMMAND_EFFECT:
|
|
|
|
if (item->frameNumber != *cmd)
|
|
|
|
{
|
|
|
|
cmd += 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
FXType = cmd[1] & 0xC000;
|
|
|
|
(*effect_routines[(int)(cmd[1] & 0x3fff)])(item);
|
|
|
|
|
|
|
|
cmd += 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int lateral = 0;
|
|
|
|
|
|
|
|
if (item->gravityStatus)
|
|
|
|
{
|
|
|
|
item->fallspeed += (item->fallspeed >= 128 ? 1 : 6);
|
|
|
|
item->pos.yPos += item->fallspeed;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int velocity = anim->velocity;
|
|
|
|
if (anim->acceleration)
|
|
|
|
velocity += anim->acceleration * (item->frameNumber - anim->frameBase);
|
|
|
|
item->speed = velocity >> 16;
|
|
|
|
|
|
|
|
lateral = anim->Xvelocity;
|
|
|
|
if (anim->Xacceleration)
|
|
|
|
lateral += anim->Xacceleration * (item->frameNumber - anim->frameBase);
|
|
|
|
|
|
|
|
lateral >>= 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->pos.xPos += item->speed * SIN(item->pos.yRot) >> W2V_SHIFT;
|
|
|
|
item->pos.zPos += item->speed * COS(item->pos.yRot) >> W2V_SHIFT;
|
|
|
|
|
|
|
|
item->pos.xPos += lateral * SIN(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT;
|
|
|
|
item->pos.zPos += lateral * COS(item->pos.yRot + ANGLE(90)) >> W2V_SHIFT;
|
|
|
|
}
|
|
|
|
|
2020-01-08 17:13:44 +01:00
|
|
|
void DoFlipMap(short group)
|
|
|
|
{
|
|
|
|
ROOM_INFO temp ;
|
|
|
|
|
|
|
|
for (int i = 0; i < NumberRooms; i++)
|
|
|
|
{
|
|
|
|
ROOM_INFO* r = &Rooms[i];
|
|
|
|
|
|
|
|
if (r->flippedRoom >= 0 && r->flipNumber == group)
|
|
|
|
{
|
|
|
|
RemoveRoomFlipItems(r);
|
|
|
|
|
|
|
|
ROOM_INFO* flipped = &Rooms[r->flippedRoom];
|
|
|
|
|
|
|
|
memcpy(&temp, r, sizeof(temp));
|
|
|
|
memcpy(r, flipped, sizeof(ROOM_INFO));
|
|
|
|
memcpy(flipped, &temp, sizeof(ROOM_INFO));
|
|
|
|
|
|
|
|
r->flippedRoom = flipped->flippedRoom;
|
|
|
|
flipped->flippedRoom = -1;
|
|
|
|
|
|
|
|
r->itemNumber = flipped->itemNumber;
|
|
|
|
r->fxNumber = flipped->fxNumber;
|
|
|
|
|
|
|
|
AddRoomFlipItems(r);
|
2020-01-14 14:39:24 -03:00
|
|
|
|
|
|
|
g_Renderer->FlipRooms(i, r->flippedRoom);
|
2020-01-08 17:13:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-09 12:30:39 -03:00
|
|
|
int status = FlipStats[group] == 0;
|
|
|
|
FlipStats[group] = status;
|
|
|
|
FlipStatus = status;
|
2020-01-08 17:13:44 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < NUM_SLOTS; i++)
|
|
|
|
{
|
|
|
|
BaddieSlots[i].LOT.targetBox = NO_BOX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddRoomFlipItems(ROOM_INFO* r)
|
|
|
|
{
|
|
|
|
for (short linkNum = r->itemNumber; linkNum != NO_ITEM; linkNum = Items[linkNum].nextItem)
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &Items[linkNum];
|
|
|
|
|
|
|
|
if (item->objectNumber == ID_RAISING_BLOCK1 && item->itemFlags[1])
|
|
|
|
AlterFloorHeight(item, -1024);
|
|
|
|
|
|
|
|
if (item->objectNumber == ID_RAISING_BLOCK2)
|
|
|
|
{
|
|
|
|
if (item->itemFlags[1])
|
|
|
|
AlterFloorHeight(item, -2048);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveRoomFlipItems(ROOM_INFO* r)
|
|
|
|
{
|
|
|
|
for (short linkNum = r->itemNumber; linkNum != NO_ITEM; linkNum = Items[linkNum].nextItem)
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &Items[linkNum];
|
|
|
|
|
|
|
|
if (item->flags & 0x100
|
|
|
|
&& Objects[item->objectNumber].intelligent
|
|
|
|
&& item->hitPoints <= 0
|
|
|
|
&& item->hitPoints != -16384)
|
|
|
|
{
|
|
|
|
KillItem(linkNum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlaySoundTrack(short track, short flags)
|
|
|
|
{
|
|
|
|
S_CDPlayEx(track, flags, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RumbleScreen()
|
|
|
|
{
|
|
|
|
if (!(GlobalCounter & 0x1FF))
|
|
|
|
SoundEffect(SFX_KLAXON, 0, 4104);
|
|
|
|
|
|
|
|
if (RumbleTimer >= 0)
|
|
|
|
RumbleTimer++;
|
|
|
|
|
|
|
|
if (RumbleTimer > 450)
|
|
|
|
{
|
|
|
|
if (!(GetRandomControl() & 0x1FF))
|
|
|
|
{
|
|
|
|
InGameCnt = 0;
|
|
|
|
RumbleTimer = -32 - (GetRandomControl() & 0x1F);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RumbleTimer < 0)
|
|
|
|
{
|
|
|
|
if (InGameCnt >= abs(RumbleTimer))
|
|
|
|
{
|
|
|
|
Camera.bounce = -(GetRandomControl() % abs(RumbleTimer));
|
|
|
|
RumbleTimer++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InGameCnt++;
|
|
|
|
Camera.bounce = -(GetRandomControl() % InGameCnt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 17:28:10 +01:00
|
|
|
void RefreshCamera(short type, short* data)
|
|
|
|
{
|
|
|
|
short trigger, value, targetOk;
|
|
|
|
|
|
|
|
targetOk = 2;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
trigger = *(data++);
|
|
|
|
value = trigger & VALUE_BITS;
|
|
|
|
|
|
|
|
switch (TRIG_BITS(trigger))
|
|
|
|
{
|
|
|
|
case TO_CAMERA:
|
|
|
|
data++;
|
|
|
|
|
|
|
|
if (value == Camera.last)
|
|
|
|
{
|
|
|
|
Camera.number = value;
|
|
|
|
|
|
|
|
if ((Camera.timer < 0)
|
|
|
|
|| (Camera.type == LOOK_CAMERA)
|
|
|
|
|| (Camera.type == COMBAT_CAMERA))
|
|
|
|
{
|
|
|
|
Camera.timer = -1;
|
|
|
|
targetOk = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Camera.type = FIXED_CAMERA;
|
|
|
|
targetOk = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
targetOk = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_TARGET:
|
|
|
|
if (Camera.type == LOOK_CAMERA || Camera.type == COMBAT_CAMERA)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Camera.item = &Items[value];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (!(trigger & END_BIT));
|
|
|
|
|
|
|
|
if (Camera.item)
|
|
|
|
if (!targetOk || (targetOk == 2 && Camera.item->lookedAt && Camera.item != Camera.lastItem))
|
|
|
|
Camera.item = NULL;
|
|
|
|
|
|
|
|
if (Camera.number == -1 && Camera.timer > 0)
|
|
|
|
Camera.timer = -1;
|
|
|
|
}
|
|
|
|
|
2020-01-10 17:06:49 -03:00
|
|
|
int ExplodeItemNode(ITEM_INFO* item, int Node, int NoXZVel, int bits)
|
|
|
|
{
|
|
|
|
short Num;
|
|
|
|
|
|
|
|
if (1 << Node & item->meshBits)
|
|
|
|
{
|
|
|
|
Num = bits;
|
|
|
|
if (item->objectNumber == ID_SHOOT_SWITCH1 && (CurrentLevel == 4 || CurrentLevel == 7))
|
|
|
|
{
|
|
|
|
SoundEffect(SFX_SMASH_METAL, &item->pos, 0);
|
|
|
|
}
|
|
|
|
else if (Num == 256)
|
|
|
|
{
|
|
|
|
Num = -64;
|
|
|
|
}
|
2020-03-27 19:27:21 -03:00
|
|
|
GetSpheres(item, SphereList, 3);
|
2020-01-10 17:06:49 -03:00
|
|
|
ShatterItem.yRot = item->pos.yRot;
|
|
|
|
ShatterItem.bit = 1 << Node;
|
2020-03-16 22:27:50 +01:00
|
|
|
ShatterItem.meshp = Meshes[Objects[item->objectNumber].meshIndex + Node];
|
2020-01-10 17:06:49 -03:00
|
|
|
ShatterItem.sphere.x = SphereList[Node].x;
|
|
|
|
ShatterItem.sphere.y = SphereList[Node].y;
|
|
|
|
ShatterItem.sphere.z = SphereList[Node].z;
|
|
|
|
ShatterItem.il = (ITEM_LIGHT *) &item->legacyLightData;
|
|
|
|
ShatterItem.flags = item->objectNumber == ID_CROSSBOW_BOLT ? 0x400 : 0;
|
2020-04-05 17:36:24 +02:00
|
|
|
ShatterImpactData.impactDirection = Vector3(0, -1, 0);
|
|
|
|
ShatterImpactData.impactLocation = { (float)ShatterItem.sphere.x,(float)ShatterItem.sphere.y,(float)ShatterItem.sphere.z };
|
2020-04-02 12:57:51 +02:00
|
|
|
ShatterObject(&ShatterItem, NULL, Num, item->roomNumber, NoXZVel);
|
2020-03-27 19:27:21 -03:00
|
|
|
item->meshBits &= ~ShatterItem.bit;
|
2020-01-10 17:06:49 -03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TriggerActive(ITEM_INFO* item)
|
|
|
|
{
|
|
|
|
int flag;
|
|
|
|
|
2020-01-22 21:22:35 +01:00
|
|
|
flag = (~item->flags & IFLAG_REVERSE) >> 14;
|
2020-01-10 17:06:49 -03:00
|
|
|
if ((item->flags & IFLAG_ACTIVATION_MASK) != IFLAG_ACTIVATION_MASK)
|
|
|
|
{
|
|
|
|
flag = !flag;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (item->timer)
|
|
|
|
{
|
|
|
|
if (item->timer > 0)
|
|
|
|
{
|
|
|
|
--item->timer;
|
|
|
|
if (!item->timer)
|
|
|
|
item->timer = -1;
|
|
|
|
}
|
|
|
|
else if (item->timer < -1)
|
|
|
|
{
|
|
|
|
++item->timer;
|
|
|
|
if (item->timer == -1)
|
|
|
|
item->timer = 0;
|
|
|
|
}
|
|
|
|
if (item->timer <= -1)
|
|
|
|
flag = !flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2020-01-14 13:14:52 +01:00
|
|
|
int GetWaterHeight(int x, int y, int z, short roomNumber)
|
|
|
|
{
|
|
|
|
ROOM_INFO* r = &Rooms[roomNumber];
|
|
|
|
FLOOR_INFO* floor;
|
|
|
|
short adjoiningRoom = NO_ROOM;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
int xBlock = (x - r->x) >> WALL_SHIFT;
|
|
|
|
int zBlock = (z - r->z) >> WALL_SHIFT;
|
|
|
|
|
|
|
|
if (zBlock <= 0)
|
|
|
|
{
|
|
|
|
zBlock = 0;
|
|
|
|
if (xBlock < 1)
|
|
|
|
xBlock = 1;
|
|
|
|
else if (xBlock > r->ySize - 2)
|
|
|
|
xBlock = r->ySize - 2;
|
|
|
|
}
|
|
|
|
else if (zBlock >= r->xSize - 1)
|
|
|
|
{
|
|
|
|
zBlock = r->xSize - 1;
|
|
|
|
if (xBlock < 1)
|
|
|
|
xBlock = 1;
|
|
|
|
else if (xBlock > r->ySize - 2)
|
|
|
|
xBlock = r->ySize - 2;
|
|
|
|
}
|
|
|
|
else if (xBlock < 0)
|
|
|
|
xBlock = 0;
|
|
|
|
else if (xBlock >= r->ySize)
|
|
|
|
xBlock = r->ySize - 1;
|
|
|
|
|
|
|
|
floor = &r->floor[zBlock + xBlock * r->xSize];
|
|
|
|
adjoiningRoom = GetDoor(floor);
|
|
|
|
|
|
|
|
if (adjoiningRoom != NO_ROOM)
|
|
|
|
{
|
|
|
|
roomNumber = adjoiningRoom;
|
|
|
|
r = &Rooms[adjoiningRoom];
|
|
|
|
}
|
|
|
|
} while (adjoiningRoom != NO_ROOM);
|
|
|
|
|
|
|
|
if (r->flags & (ENV_FLAG_WATER | ENV_FLAG_SWAMP))
|
|
|
|
{
|
2020-01-14 14:25:37 +01:00
|
|
|
while (floor->skyRoom != NO_ROOM)
|
2020-01-14 13:14:52 +01:00
|
|
|
{
|
2020-01-14 14:25:37 +01:00
|
|
|
if (CheckNoColCeilingTriangle(floor, x, z) == 1)
|
|
|
|
break;
|
|
|
|
r = &Rooms[floor->skyRoom];
|
|
|
|
if (!(r->flags & (ENV_FLAG_WATER | ENV_FLAG_SWAMP)))
|
|
|
|
return r->minfloor;
|
|
|
|
floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z);
|
|
|
|
if (floor->skyRoom == NO_ROOM)
|
|
|
|
break;
|
2020-01-14 13:14:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return r->maxceiling;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-14 14:25:37 +01:00
|
|
|
while (floor->pitRoom != NO_ROOM)
|
2020-01-14 13:14:52 +01:00
|
|
|
{
|
2020-01-14 14:25:37 +01:00
|
|
|
if (CheckNoColFloorTriangle(floor, x, z) == 1)
|
|
|
|
break;
|
|
|
|
r = &Rooms[floor->pitRoom];
|
|
|
|
if (r->flags & (ENV_FLAG_WATER | ENV_FLAG_SWAMP))
|
|
|
|
return r->maxceiling;
|
|
|
|
floor = &XZ_GET_SECTOR(r, x - r->x, z - r->z);
|
|
|
|
if (floor->pitRoom == NO_ROOM)
|
|
|
|
break;
|
2020-01-14 13:14:52 +01:00
|
|
|
}
|
|
|
|
}
|
2020-01-14 14:25:37 +01:00
|
|
|
|
|
|
|
return NO_HEIGHT;
|
2020-01-14 13:14:52 +01:00
|
|
|
}
|
|
|
|
|
2020-02-10 10:38:00 +01:00
|
|
|
int is_object_in_room(short roomNumber, short objectNumber)
|
|
|
|
{
|
|
|
|
short itemNumber = Rooms[roomNumber].itemNumber;
|
|
|
|
|
|
|
|
if (itemNumber == NO_ITEM)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &Items[itemNumber];
|
|
|
|
|
|
|
|
if (item->objectNumber == objectNumber)
|
|
|
|
break;
|
|
|
|
|
|
|
|
itemNumber = item->nextItem;
|
|
|
|
|
|
|
|
if (itemNumber == NO_ITEM)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterpolateAngle(short angle, short* rotation, short* outAngle, int shift)
|
|
|
|
{
|
|
|
|
short deltaAngle = angle - *rotation;
|
|
|
|
|
|
|
|
if (deltaAngle < -32768)
|
|
|
|
deltaAngle += 65536;
|
|
|
|
else if (deltaAngle > 32768)
|
|
|
|
deltaAngle -= 65536;
|
|
|
|
|
|
|
|
if (outAngle)
|
|
|
|
* outAngle = deltaAngle;
|
|
|
|
|
|
|
|
*rotation += deltaAngle >> shift;
|
|
|
|
}
|
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
void Inject_Control()
|
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
INJECT(0x00416760, TestTriggers);
|
|
|
|
INJECT(0x004167B0, TestTriggers);
|
2019-12-04 18:51:23 +01:00
|
|
|
INJECT(0x00415960, TranslateItem);
|
2019-12-10 18:25:48 +01:00
|
|
|
INJECT(0x00415B20, GetFloor);
|
2020-01-07 17:33:13 -03:00
|
|
|
INJECT(0x00417640, GetCeiling);
|
2020-01-08 13:25:42 +01:00
|
|
|
INJECT(0x004A7C10, GetRandomControl);
|
|
|
|
INJECT(0x004A7C40, GetRandomDraw);
|
|
|
|
INJECT(0x004A7C70, SeedRandomControl);
|
|
|
|
INJECT(0x004A7C90, SeedRandomDraw);
|
|
|
|
INJECT(0x00415300, AnimateItem);
|
2020-01-08 16:01:57 -03:00
|
|
|
INJECT(0x0041A170, GetTargetOnLOS);
|
2020-01-16 19:14:35 +01:00
|
|
|
INJECT(0x00415DA0, GetWaterHeight);
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|