From ff8a656040b63f4c1066b52481d75e53579a1cea Mon Sep 17 00:00:00 2001 From: Flugente Date: Wed, 30 Aug 2017 19:33:23 +0000 Subject: [PATCH] Smoothen ballistic shield 'movement' by taking soldier position offsets into account git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8467 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TileEngine/renderworld.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/TileEngine/renderworld.cpp b/TileEngine/renderworld.cpp index 0802cb49..fb6433b2 100644 --- a/TileEngine/renderworld.cpp +++ b/TileEngine/renderworld.cpp @@ -634,7 +634,7 @@ void ShowRiotShield( SOLDIERTYPE* pSoldier ) // but don*t do so while scrolling, because that looks weird if ( !gfScrollPending && !gfScrollInertia) { - INT32 iBack = RegisterBackgroundRect(BGND_FLAG_SINGLE, NULL, sScreenX - 50, sScreenY - 60, sScreenX + 50, sScreenY + 35); + INT32 iBack = RegisterBackgroundRect(BGND_FLAG_SINGLE, NULL, sScreenX - 50, sScreenY - 60, sScreenX + 50, sScreenY + 35 ); if (iBack != -1) { @@ -648,7 +648,18 @@ void ShowRiotShield( SOLDIERTYPE* pSoldier ) if (pObj) offset = Item[pObj->usItem].usRiotShieldGraphic; - BltVideoObjectFromIndex( FRAME_BUFFER, guiShieldGraphic, offset * 8 + pSoldier->ubDirection, sScreenX - 20, sScreenY - 60, VO_BLT_TRANSSHADOW, NULL ); + // try to keep the shield 'moving' alongside the soldier. This won't work perfectly, but it's better than nothing + INT16 base_x = 0; + INT16 base_y = 0; + ConvertMapPosToWorldTileCenter( pSoldier->sGridNo, &base_x, &base_y ); + + INT16 dx = pSoldier->sX - base_x; + INT16 dy = pSoldier->sY - base_y; + + INT16 offset_x = (dx - dy); + INT16 offset_y = (dx + dy); + + BltVideoObjectFromIndex( FRAME_BUFFER, guiShieldGraphic, offset * 8 + pSoldier->ubDirection, sScreenX - 20 + offset_x, sScreenY - 60 + offset_y, VO_BLT_TRANSSHADOW, NULL ); } }