mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-10 23:24:06 +02:00
TR2 add flying helicopter object
This commit is contained in:
12
src/camera.h
12
src/camera.h
@@ -415,11 +415,13 @@ struct Camera : ICamera {
|
||||
if (!owner->viewTarget) {
|
||||
if (viewTarget && !viewTarget->flags.invisible) {
|
||||
vec3 targetVec = (viewTarget->pos - owner->pos).normal();
|
||||
if (targetVec.dot(owner->getDir()) > 0.5f)
|
||||
if (targetVec.dot(owner->getDir()) > 0.1f) {
|
||||
lookAt = viewTarget;
|
||||
}
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
lookAt = owner->viewTarget;
|
||||
}
|
||||
|
||||
owner->lookAt(lookAt);
|
||||
} else {
|
||||
@@ -427,15 +429,17 @@ struct Camera : ICamera {
|
||||
owner->lookAt(NULL);
|
||||
}
|
||||
|
||||
if (!firstPerson && (mode == MODE_FOLLOW || mode == MODE_COMBAT))
|
||||
if (!firstPerson && (mode == MODE_FOLLOW || mode == MODE_COMBAT)) {
|
||||
targetAngle += angle;
|
||||
}
|
||||
|
||||
if (!firstPerson || viewIndex != -1) {
|
||||
|
||||
if (timer > 0.0f) {
|
||||
timer -= Core::deltaTime;
|
||||
if (timer <= 0.0f)
|
||||
if (timer <= 0.0f) {
|
||||
resetTarget();
|
||||
}
|
||||
}
|
||||
|
||||
TR::Location to;
|
||||
|
@@ -984,6 +984,8 @@ namespace TR {
|
||||
SND_TNT = 170,
|
||||
SND_MUTANT_DEATH = 171,
|
||||
SND_SECRET = 173,
|
||||
|
||||
SND_HELICOPTER = 297,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@@ -1147,6 +1147,8 @@ struct Level : IGame {
|
||||
case TR::Entity::WINDOW_1 :
|
||||
case TR::Entity::WINDOW_2 : return new BreakableWindow(this, index);
|
||||
|
||||
case TR::Entity::HELICOPTER_FLYING : return new HelicopterFlying(this, index);
|
||||
|
||||
default : return new Controller(this, index);
|
||||
}
|
||||
}
|
||||
|
@@ -1617,6 +1617,36 @@ struct BreakableWindow : Controller {
|
||||
};
|
||||
|
||||
|
||||
#define HELICOPTER_SPEED 3000
|
||||
#define HELICOPTER_RANGE (1024 * 30)
|
||||
|
||||
struct HelicopterFlying : Controller {
|
||||
|
||||
HelicopterFlying(IGame *game, int entity) : Controller(game, entity) {}
|
||||
|
||||
virtual void update() {
|
||||
pos.z += HELICOPTER_SPEED * Core::deltaTime;
|
||||
updateAnimation(false);
|
||||
updateRoom();
|
||||
|
||||
Controller *lara = game->getLara(pos);
|
||||
|
||||
float dist = pos.z - lara->pos.z;
|
||||
|
||||
Sound::Sample *sample = game->playSound(TR::SND_HELICOPTER, vec3(0.0), 0);
|
||||
if (sample) {
|
||||
sample->volume = (1.0f - dist / HELICOPTER_RANGE) * 0.8f;
|
||||
}
|
||||
|
||||
if (fabsf(dist) > HELICOPTER_RANGE) {
|
||||
Sound::stop(TR::SND_HELICOPTER);
|
||||
flags.invisible = true;
|
||||
deactivate(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#define STONE_ITEM_LIGHT_RADIUS 2048.0f
|
||||
|
||||
struct StoneItem : Controller {
|
||||
|
Reference in New Issue
Block a user