From 319449970c076f49302035bcf497a14038120cc6 Mon Sep 17 00:00:00 2001 From: XProger Date: Wed, 29 May 2019 03:56:43 +0300 Subject: [PATCH] #183 fix "Swimming Rats" --- src/enemy.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/enemy.h b/src/enemy.h index 628174d..09cc7f4 100644 --- a/src/enemy.h +++ b/src/enemy.h @@ -1050,9 +1050,11 @@ struct Rat : Enemy { modelLand = level->getModelIndex(TR::Entity::ENEMY_RAT_LAND) - 1; modelWater = level->getModelIndex(TR::Entity::ENEMY_RAT_WATER) - 1; } - + const virtual TR::Model* getModel() { - bool water = getRoom().flags.water; + bool water = getRoom().flags.water || modelWater == -1; + stand = water ? STAND_ONWATER : STAND_GROUND; + int modelIndex = water ? modelWater : modelLand; if (modelIndex == -1) { @@ -1065,7 +1067,6 @@ struct Rat : Enemy { if (animation.model != model) { targetBox = TR::NO_BOX; animation.setModel(model); - stand = water ? STAND_ONWATER : STAND_GROUND; int16 rIndex = getRoomIndex(); if (water) { @@ -1075,7 +1076,6 @@ struct Rat : Enemy { roomIndex = rIndex; } } else { - int16 rIndex = getRoomIndex(); TR::Room::Sector *sector = level->getSector(rIndex, pos); if (sector) { pos.y = float(sector->floor * 256); @@ -1229,13 +1229,15 @@ struct Crocodile : Enemy { modelLand = level->getModelIndex(TR::Entity::ENEMY_CROCODILE_LAND) - 1; modelWater = level->getModelIndex(TR::Entity::ENEMY_CROCODILE_WATER) - 1; - bool water = getRoom().flags.water; + bool water = getRoom().flags.water || modelWater == -1; flying = water; stand = water ? STAND_UNDERWATER : STAND_GROUND; } const virtual TR::Model* getModel() { - bool water = getRoom().flags.water; + bool water = getRoom().flags.water || modelWater == -1; + stand = water ? STAND_UNDERWATER : STAND_GROUND; + int modelIndex = water ? modelWater : modelLand; if (modelIndex == -1) { @@ -1248,7 +1250,6 @@ struct Crocodile : Enemy { if (animation.model != model) { targetBox = TR::NO_BOX; animation.setModel(model); - stand = water ? STAND_UNDERWATER : STAND_GROUND; flying = water; int16 rIndex = getRoomIndex(); @@ -1259,7 +1260,6 @@ struct Crocodile : Enemy { roomIndex = rIndex; } } else { - int16 rIndex = getRoomIndex(); TR::Room::Sector *sector = level->getSector(rIndex, pos); if (sector) { pos.y = float(sector->floor * 256);