@@ -78,7 +78,7 @@ namespace OpenXcom
7878 * @param y Y position in pixels.
7979 * @param visibleMapHeight Current visible map height.
8080 */
81- Map::Map (Game *game, int width, int height, int x, int y, int visibleMapHeight) : InteractiveSurface(width, height, x, y), _game(game), _arrow(0 ), _selectorX(0 ), _selectorY(0 ), _mouseX(0 ), _mouseY(0 ), _cursorType(CT_NORMAL ), _cursorSize(1 ), _animFrame(0 ), _projectile(0 ), _projectileInFOV(false ), _explosionInFOV(false ), _visibleMapHeight(visibleMapHeight), _unitDying(false ), _smoothingEngaged(false )
81+ Map::Map (Game *game, int width, int height, int x, int y, int visibleMapHeight) : InteractiveSurface(width, height, x, y), _game(game), _arrow(0 ), _selectorX(0 ), _selectorY(0 ), _mouseX(0 ), _mouseY(0 ), _cursorType(CT_NORMAL ), _cursorSize(1 ), _animFrame(0 ), _projectile(0 ), _projectileInFOV(false ), _explosionInFOV(false ), _launch( false ), _visibleMapHeight(visibleMapHeight), _unitDying(false ), _smoothingEngaged(false )
8282{
8383 _previewSetting = Options::battleNewPreviewPath;
8484 _smoothCamera = Options::battleSmoothCamera;
@@ -289,15 +289,20 @@ void Map::drawTerrain(Surface *surface)
289289 }
290290 if (_smoothCamera)
291291 {
292+ if (_launch)
293+ {
294+ _launch = false ;
295+ if ((bulletPositionScreen.x < 1 || bulletPositionScreen.x > surface->getWidth () - 1 ||
296+ bulletPositionScreen.y < 1 || bulletPositionScreen.y > _visibleMapHeight - 1 ))
297+ {
298+ _camera->centerOnPosition (Position (bulletLowX, bulletLowY, bulletHighZ), false );
299+ _camera->convertVoxelToScreen (_projectile->getPosition (), &bulletPositionScreen);
300+ }
301+ }
292302 if (!_smoothingEngaged)
293303 {
294- Position origin = _projectile->getOrigin ();
295- Position target = _projectile->getTarget ();
296- if (std::abs (origin.x - target.x ) > 1 ||
297- std::abs (origin.y - target.y ) > 1 ||
298- std::abs (origin.z - target.z ) > 1 ||
299- bulletPositionScreen.x < 0 || bulletPositionScreen.x > surface->getWidth () ||
300- bulletPositionScreen.y < 0 || bulletPositionScreen.y > _visibleMapHeight)
304+ if (bulletPositionScreen.x < 1 || bulletPositionScreen.x > surface->getWidth () - 1 ||
305+ bulletPositionScreen.y < 1 || bulletPositionScreen.y > _visibleMapHeight - 1 )
301306 {
302307 _smoothingEngaged = true ;
303308 }
@@ -1205,6 +1210,10 @@ void Map::cacheUnit(BattleUnit *unit)
12051210void Map::setProjectile (Projectile *projectile)
12061211{
12071212 _projectile = projectile;
1213+ if (projectile && Options::battleSmoothCamera)
1214+ {
1215+ _launch = true ;
1216+ }
12081217}
12091218
12101219/* *
0 commit comments