mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-06 13:16:52 +02:00
11
src/enemy.h
11
src/enemy.h
@@ -1847,7 +1847,7 @@ struct Mutant : Enemy {
|
|||||||
bool exploded = explodeMask != 0;
|
bool exploded = explodeMask != 0;
|
||||||
|
|
||||||
if (health <= 0.0f && !exploded) {
|
if (health <= 0.0f && !exploded) {
|
||||||
game->playSound(TR::SND_MUTANT_DEATH, pos, 0);
|
game->playSound(TR::SND_MUTANT_DEATH, pos, Sound::PAN);
|
||||||
explode(0xffffffff);
|
explode(0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1976,6 +1976,7 @@ struct Mutant : Enemy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define GIANT_MUTANT_TURN_SLOW (DEG2RAD * 90)
|
#define GIANT_MUTANT_TURN_SLOW (DEG2RAD * 90)
|
||||||
|
#define GIANT_MUTANT_MIN_ANGLE (DEG2RAD * 10)
|
||||||
#define GIANT_MUTANT_MAX_ANGLE (DEG2RAD * 45)
|
#define GIANT_MUTANT_MAX_ANGLE (DEG2RAD * 45)
|
||||||
#define GIANT_MUTANT_DAMAGE 500
|
#define GIANT_MUTANT_DAMAGE 500
|
||||||
#define GIANT_MUTANT_DAMAGE_WALK 5
|
#define GIANT_MUTANT_DAMAGE_WALK 5
|
||||||
@@ -2009,11 +2010,11 @@ struct GiantMutant : Enemy {
|
|||||||
STATE_FATAL,
|
STATE_FATAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
GiantMutant(IGame *game, int entity) : Enemy(game, entity, 1/*500*/, 341, 375.0f, 1.0f) {
|
GiantMutant(IGame *game, int entity) : Enemy(game, entity, 500, 341, 375.0f, 1.0f) {
|
||||||
hitSound = TR::SND_HIT_MUTANT;
|
hitSound = TR::SND_HIT_MUTANT;
|
||||||
stand = STAND_AIR;
|
stand = STAND_AIR;
|
||||||
jointChest = -1;
|
jointChest = -1;
|
||||||
jointHead = 3;
|
jointHead = -1; // 3; TODO: fix head orientation
|
||||||
rangeHead = vec4(-0.5f, 0.5f, -0.5f, 0.5f) * PI;
|
rangeHead = vec4(-0.5f, 0.5f, -0.5f, 0.5f) * PI;
|
||||||
invertAim = true;
|
invertAim = true;
|
||||||
}
|
}
|
||||||
@@ -2025,7 +2026,7 @@ struct GiantMutant : Enemy {
|
|||||||
|
|
||||||
if (health <= 0.0f && !exploded && animation.index == ANIM_DEATH && flags.state == TR::Entity::asInactive) {
|
if (health <= 0.0f && !exploded && animation.index == ANIM_DEATH && flags.state == TR::Entity::asInactive) {
|
||||||
flags.state = TR::Entity::asActive;
|
flags.state = TR::Entity::asActive;
|
||||||
game->playSound(TR::SND_MUTANT_DEATH, pos, 0);
|
game->playSound(TR::SND_MUTANT_DEATH, pos, Sound::PAN);
|
||||||
explode(0xffffffff);
|
explode(0xffffffff);
|
||||||
game->checkTrigger(this, true);
|
game->checkTrigger(this, true);
|
||||||
}
|
}
|
||||||
@@ -2115,7 +2116,7 @@ struct GiantMutant : Enemy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void updatePosition() {
|
virtual void updatePosition() {
|
||||||
if (target && target->health > 0.0f)
|
if (target && target->health > 0.0f && fabsf(targetAngle) > GIANT_MUTANT_MIN_ANGLE)
|
||||||
if (state == STATE_TURN_LEFT || state == STATE_TURN_RIGHT || state == STATE_WALK || state == STATE_STOP)
|
if (state == STATE_TURN_LEFT || state == STATE_TURN_RIGHT || state == STATE_WALK || state == STATE_STOP)
|
||||||
turn(targetAngle, GIANT_MUTANT_TURN_SLOW);
|
turn(targetAngle, GIANT_MUTANT_TURN_SLOW);
|
||||||
|
|
||||||
|
@@ -1490,7 +1490,6 @@ struct Lara : Character {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TR::HIT_BOULDER : {
|
case TR::HIT_BOULDER : {
|
||||||
camera->setAngle(-25, 170);
|
|
||||||
animation.setAnim(ANIM_DEATH_BOULDER);
|
animation.setAnim(ANIM_DEATH_BOULDER);
|
||||||
|
|
||||||
vec3 v(0.0f);
|
vec3 v(0.0f);
|
||||||
@@ -1518,7 +1517,6 @@ struct Lara : Character {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TR::HIT_REX : {
|
case TR::HIT_REX : {
|
||||||
camera->setAngle(-25, 170);
|
|
||||||
pos = enemy->pos;
|
pos = enemy->pos;
|
||||||
angle = enemy->angle;
|
angle = enemy->angle;
|
||||||
|
|
||||||
@@ -1538,7 +1536,6 @@ struct Lara : Character {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TR::HIT_GIANT_MUTANT : {
|
case TR::HIT_GIANT_MUTANT : {
|
||||||
// camera->setAngle(-25, 170);
|
|
||||||
pos = enemy->pos;
|
pos = enemy->pos;
|
||||||
angle = enemy->angle;
|
angle = enemy->angle;
|
||||||
|
|
||||||
|
13
src/level.h
13
src/level.h
@@ -464,16 +464,16 @@ struct Level : IGame {
|
|||||||
players[i]->camera->shake = 0.5f * max(0.0f, 1.0f - (controller->pos - players[i]->camera->eye.pos).length2() / (15 * 1024 * 15 * 1024));
|
players[i]->camera->shake = 0.5f * max(0.0f, 1.0f - (controller->pos - players[i]->camera->eye.pos).length2() / (15 * 1024 * 15 * 1024));
|
||||||
return;
|
return;
|
||||||
case TR::Effect::FLOOD : {
|
case TR::Effect::FLOOD : {
|
||||||
Sound::Sample *sample = playSound(TR::SND_FLOOD, vec3(), 0);
|
Sound::Sample *sample = playSound(TR::SND_FLOOD);
|
||||||
if (sample)
|
if (sample)
|
||||||
sample->setVolume(0.0f, 4.0f);
|
sample->setVolume(0.0f, 4.0f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TR::Effect::STAIRS2SLOPE :
|
case TR::Effect::STAIRS2SLOPE :
|
||||||
playSound(TR::SND_STAIRS2SLOPE, vec3(), 0);
|
playSound(TR::SND_STAIRS2SLOPE);
|
||||||
break;
|
break;
|
||||||
case TR::Effect::EXPLOSION :
|
case TR::Effect::EXPLOSION :
|
||||||
playSound(TR::SND_TNT, vec3(0), 0);
|
playSound(TR::SND_TNT);
|
||||||
shakeCamera(1.0f);
|
shakeCamera(1.0f);
|
||||||
break;
|
break;
|
||||||
default : ;
|
default : ;
|
||||||
@@ -572,7 +572,6 @@ struct Level : IGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual Sound::Sample* playSound(int id, const vec3 &pos = vec3(0.0f), int flags = 0) const {
|
virtual Sound::Sample* playSound(int id, const vec3 &pos = vec3(0.0f), int flags = 0) const {
|
||||||
//return NULL;
|
|
||||||
if (level.version == TR::VER_TR1_PSX && id == TR::SND_SECRET)
|
if (level.version == TR::VER_TR1_PSX && id == TR::SND_SECRET)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -590,7 +589,7 @@ struct Level : IGame {
|
|||||||
|
|
||||||
if (!(flags & Sound::MUSIC)) {
|
if (!(flags & Sound::MUSIC)) {
|
||||||
switch (b.flags.mode) {
|
switch (b.flags.mode) {
|
||||||
case 0 : if (level.version & TR::VER_TR1) flags |= Sound::UNIQUE; break; // TODO check this
|
case 0 : flags |= Sound::UNIQUE; break;
|
||||||
case 1 : flags |= Sound::REPLAY; break;
|
case 1 : flags |= Sound::REPLAY; break;
|
||||||
case 2 : if (level.version & TR::VER_TR1) flags |= Sound::LOOP; break;
|
case 2 : if (level.version & TR::VER_TR1) flags |= Sound::LOOP; break;
|
||||||
case 3 : if (!(level.version & TR::VER_TR1)) flags |= Sound::LOOP | Sound::UNIQUE; break;
|
case 3 : if (!(level.version & TR::VER_TR1)) flags |= Sound::LOOP | Sound::UNIQUE; break;
|
||||||
@@ -598,7 +597,7 @@ struct Level : IGame {
|
|||||||
}
|
}
|
||||||
if (b.flags.gain) volume = max(0.0f, volume - randf() * 0.25f);
|
if (b.flags.gain) volume = max(0.0f, volume - randf() * 0.25f);
|
||||||
//if (b.flags.camera) flags &= ~Sound::PAN;
|
//if (b.flags.camera) flags &= ~Sound::PAN;
|
||||||
return Sound::play(level.getSampleStream(index), pos, volume, pitch, flags, id);
|
return Sound::play(level.getSampleStream(index), &pos, volume, pitch, flags, id);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -623,7 +622,7 @@ struct Level : IGame {
|
|||||||
Level *level = req->level;
|
Level *level = req->level;
|
||||||
level->waitTrack = false;
|
level->waitTrack = false;
|
||||||
if (stream) {
|
if (stream) {
|
||||||
level->sndTrack = Sound::play(stream, vec3(0.0f), 0.01f, 1.0f, req->flags);
|
level->sndTrack = Sound::play(stream, NULL, 0.01f, 1.0f, req->flags);
|
||||||
if (level->sndTrack) {
|
if (level->sndTrack) {
|
||||||
if (level->level.isCutsceneLevel()) {
|
if (level->level.isCutsceneLevel()) {
|
||||||
Core::resetTime();
|
Core::resetTime();
|
||||||
|
36
src/sound.h
36
src/sound.h
@@ -469,6 +469,7 @@ namespace Sound {
|
|||||||
bool flipped;
|
bool flipped;
|
||||||
|
|
||||||
struct Sample {
|
struct Sample {
|
||||||
|
const vec3 *uniquePtr;
|
||||||
Decoder *decoder;
|
Decoder *decoder;
|
||||||
vec3 pos;
|
vec3 pos;
|
||||||
float volume;
|
float volume;
|
||||||
@@ -480,7 +481,9 @@ namespace Sound {
|
|||||||
bool isPlaying;
|
bool isPlaying;
|
||||||
bool stopAfterFade;
|
bool stopAfterFade;
|
||||||
|
|
||||||
Sample(Stream *stream, const vec3 &pos, float volume, float pitch, int flags, int id) : decoder(NULL), pos(pos), volume(volume), volumeTarget(volume), volumeDelta(0.0f), pitch(pitch), flags(flags), id(id) {
|
Sample(Stream *stream, const vec3 *pos, float volume, float pitch, int flags, int id) : uniquePtr(pos), decoder(NULL), volume(volume), volumeTarget(volume), volumeDelta(0.0f), pitch(pitch), flags(flags), id(id) {
|
||||||
|
this->pos = pos ? *pos : vec3(0.0f);
|
||||||
|
|
||||||
uint32 fourcc;
|
uint32 fourcc;
|
||||||
stream->read(fourcc);
|
stream->read(fourcc);
|
||||||
if (fourcc == FOURCC("RIFF")) { // wav
|
if (fourcc == FOURCC("RIFF")) { // wav
|
||||||
@@ -760,16 +763,23 @@ namespace Sound {
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sample* play(Stream *stream, const vec3 &pos, float volume = 1.0f, float pitch = 0.0f, int flags = 0, int id = - 1) {
|
Sample* getChannel(int id, const vec3 *pos) {
|
||||||
|
for (int i = 0; i < channelsCount; i++)
|
||||||
|
if (channels[i]->id == id && channels[i]->uniquePtr == pos)
|
||||||
|
return channels[i];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sample* play(Stream *stream, const vec3 *pos = NULL, float volume = 1.0f, float pitch = 0.0f, int flags = 0, int id = - 1) {
|
||||||
OS_LOCK(lock);
|
OS_LOCK(lock);
|
||||||
|
|
||||||
ASSERT(pitch >= 0.0f);
|
ASSERT(pitch >= 0.0f);
|
||||||
if (!stream) return NULL;
|
if (!stream) return NULL;
|
||||||
if (volume > 0.001f) {
|
if (volume > 0.001f) {
|
||||||
vec3 listenerPos = getListener(pos).matrix.getPos();
|
if (pos && !(flags & (FLIPPED | UNFLIPPED | MUSIC)) && (flags & PAN)) {
|
||||||
|
vec3 listenerPos = getListener(*pos).matrix.getPos();
|
||||||
|
vec3 d = *pos - listenerPos;
|
||||||
|
|
||||||
if (!(flags & (FLIPPED | UNFLIPPED | MUSIC)) && (flags & PAN)) {
|
|
||||||
vec3 d = pos - listenerPos;
|
|
||||||
if (fabsf(d.x) > SND_FADEOFF_DIST || fabsf(d.y) > SND_FADEOFF_DIST || fabsf(d.z) > SND_FADEOFF_DIST) {
|
if (fabsf(d.x) > SND_FADEOFF_DIST || fabsf(d.y) > SND_FADEOFF_DIST || fabsf(d.z) > SND_FADEOFF_DIST) {
|
||||||
delete stream;
|
delete stream;
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -777,20 +787,18 @@ namespace Sound {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & (UNIQUE | REPLAY)) {
|
if (flags & (UNIQUE | REPLAY)) {
|
||||||
for (int i = 0; i < channelsCount; i++)
|
Sample *ch = getChannel(id, pos);
|
||||||
if (channels[i]->id == id) {
|
|
||||||
vec3 p = listenerPos;
|
|
||||||
|
|
||||||
if ((p - channels[i]->pos).length2() > (p - pos).length2()) {
|
if (ch) {
|
||||||
channels[i]->pos = pos;
|
if (pos)
|
||||||
channels[i]->pitch = pitch;
|
ch->pos = *pos;
|
||||||
}
|
ch->pitch = pitch;
|
||||||
|
|
||||||
if (flags & REPLAY)
|
if (flags & REPLAY)
|
||||||
channels[i]->replay();
|
ch->replay();
|
||||||
|
|
||||||
delete stream;
|
delete stream;
|
||||||
return channels[i];
|
return ch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1513,7 +1513,7 @@ struct Bubble : Sprite {
|
|||||||
struct Explosion : Sprite {
|
struct Explosion : Sprite {
|
||||||
|
|
||||||
Explosion(IGame *game, int entity) : Sprite(game, entity, true, Sprite::FRAME_ANIMATED) {
|
Explosion(IGame *game, int entity) : Sprite(game, entity, true, Sprite::FRAME_ANIMATED) {
|
||||||
game->playSound(TR::SND_EXPLOSION, pos, 0);
|
game->playSound(TR::SND_EXPLOSION, pos, Sound::PAN);
|
||||||
game->getMesh()->sequences[-(getEntity().modelIndex + 1)].transp = 2; // fix blending mode to additive
|
game->getMesh()->sequences[-(getEntity().modelIndex + 1)].transp = 2; // fix blending mode to additive
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user