From fa4479913858af2b8b5bad4c67d9b13d75ebfb42 Mon Sep 17 00:00:00 2001 From: XProger Date: Sun, 30 Sep 2018 03:07:07 +0300 Subject: [PATCH] #3 fix death in the air, fix enemies target after removing the second player, fix flame emitters --- src/character.h | 9 +++++++-- src/lara.h | 6 ++++-- src/level.h | 16 ++++++++++++++-- src/trigger.h | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/character.h b/src/character.h index 858270c..e3e504f 100644 --- a/src/character.h +++ b/src/character.h @@ -167,8 +167,13 @@ struct Character : Controller { virtual bool useHeadAnimation() { return false; } int getNextState() { - if (input & DEATH) - return getStateDeath(); + if (input & DEATH) { + int deathState = getStateDeath(); + if (animation.canSetState(deathState)) { + velocity = vec3(0.0f); + return deathState; + } + } switch (stand) { case STAND_AIR : return getStateAir(); diff --git a/src/lara.h b/src/lara.h index 64c1e9a..2cd2cac 100644 --- a/src/lara.h +++ b/src/lara.h @@ -1497,8 +1497,8 @@ struct Lara : Character { arms[0].tracking = arms[1].tracking = NULL; arms[0].target = arms[1].target = NULL; viewTarget = NULL; - velocity = vec3(0.0f); animation.overrideMask = 0; + int oldState = state; switch (hitType) { case TR::HIT_FALL : { @@ -1574,6 +1574,9 @@ struct Lara : Character { for (int i = 0; i < 10; i++) Flame::add(game, this, int(randf() * 24.0f)); } + + if (state != oldState) + velocity = vec3(0.0f); }; bool useItem(TR::Entity::Type item) { @@ -2513,7 +2516,6 @@ struct Lara : Character { } virtual int getStateDeath() { - velocity = vec3(0.0f); return (stand == STAND_UNDERWATER || stand == STAND_ONWATER) ? STATE_UNDERWATER_DEATH : (state == STATE_MIDAS_DEATH ? STATE_MIDAS_DEATH : STATE_DEATH); } diff --git a/src/level.h b/src/level.h index 7eeaa01..11c43bb 100644 --- a/src/level.h +++ b/src/level.h @@ -797,8 +797,7 @@ struct Level : IGame { players[index]->camera->cameraIndex = index; Sound::listenersCount = 2; } else if (index == 1) { - removeEntity(players[index]); - players[index] = NULL; + removePlayer(index); Sound::listenersCount = 1; return; } @@ -817,6 +816,19 @@ struct Level : IGame { players[index]->reset(lead->getRoomIndex(), lead->pos, lead->angle.y, lead->stand); } + void removePlayer(int index) { + for (int i = 0; i < level.entitiesCount; i++) { + if (level.entities[i].controller && level.entities[i].isEnemy()) { + Enemy *e = (Enemy*)level.entities[i].controller; + if (e->target == players[index]) { + e->target = NULL; + } + } + } + removeEntity(players[index]); + players[index] = NULL; + } + Controller* initController(int index) { if (level.entities[index].type == TR::Entity::CUT_1 && (level.version & TR::VER_TR1)) return new Lara(this, index); diff --git a/src/trigger.h b/src/trigger.h index 20057a1..a61395e 100644 --- a/src/trigger.h +++ b/src/trigger.h @@ -167,7 +167,7 @@ struct Flame : Sprite { Sprite::update(); game->playSound(TR::SND_FLAME, pos, Sound::PAN); - Character *lara = (Character*)(owner ? owner : game->getLara(pos)); + Character *lara = (Character*)((owner && owner->getEntity().isLara()) ? owner : game->getLara(pos)); if (jointIndex > -1) { if (lara->stand == Character::STAND_UNDERWATER) {