From ec8a9c8e614b684695461764f8fe3cb0a491087a Mon Sep 17 00:00:00 2001 From: KPhoenix Date: Fri, 15 Sep 2023 11:52:22 -0400 Subject: [PATCH] Lava --- Source/automap.cpp | 279 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 271 insertions(+), 8 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index adea30fda..53136fafe 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -41,6 +41,12 @@ enum MapColors : uint8_t { MapColorsDim = (PAL16_YELLOW + 8), /** color for items on automap */ MapColorsItem = (PAL8_BLUE + 1), + /** color for cave lava on automap */ + MapColorsLava = (PAL8_ORANGE + 2), + /** color for cave water on automap */ + MapColorsWater = (PAL8_BLUE + 2), + /** color for hive acid on automap */ + MapColorsAcid = (PAL8_YELLOW + 4), }; struct AutomapTile { @@ -81,6 +87,27 @@ struct AutomapTile { CaveWoodCross, CaveRightWoodCross, CaveLeftWoodCross, + HorizontalLavaThin, + VerticalLavaThin, + BendSouthLavaThin, + BendWestLavaThin, + BendEastLavaThin, + BendNorthLavaThin, + VerticalWallLava, + HorizontalWallLava, + SELava, + SWLava, + NELava, + NWLava, + SLava, + WLava, + ELava, + NLava, + Lava, + CaveHorizontalWallLava, + CaveVerticalWallLava, + HorizontalBridgeLava, + VerticalBridgeLava, VerticalDiamond, HorizontalDiamond, }; @@ -436,6 +463,99 @@ void DrawRiverForkOut(const Surface &out, Point center, uint8_t color) out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileRight, AmHeightOffset::ThreeQuartersTileDown), color); } +template +void DrawLavaRiver(const Surface &out, Point center, uint8_t color, bool hasBridge) +{ + // First row (y = 0) + if constexpr (IsAnyOf(TDir1, Direction::NorthWest) || IsAnyOf(TDir2, Direction::NorthWest)) { + if (!(hasBridge && IsAnyOf(TDir1, Direction::NorthWest))) { + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileLeft, AmHeightOffset::QuarterTileUp), color); + out.SetPixel(center + AmOffset(AmWidthOffset::HalfTileLeft, AmHeightOffset::None), color); + } + } + + // Second row (y = 1) + if constexpr (IsAnyOf(TDir1, Direction::NorthEast) || IsAnyOf(TDir2, Direction::NorthEast)) { + if (!(hasBridge && (IsAnyOf(TDir1, Direction::NorthEast) || IsAnyOf(TDir2, Direction::NorthEast)))) + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileRight, AmHeightOffset::QuarterTileUp), color); + } + if constexpr (IsAnyOf(TDir1, Direction::NorthWest, Direction::NorthEast) || IsAnyOf(TDir2, Direction::NorthWest, Direction::NorthEast)) { + out.SetPixel(center + AmOffset(AmWidthOffset::None, AmHeightOffset::None), color); + } + if constexpr (IsAnyOf(TDir1, Direction::SouthWest, Direction::NorthWest) || IsAnyOf(TDir2, Direction::SouthWest, Direction::NorthWest)) { + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileLeft, AmHeightOffset::QuarterTileDown), color); + } + if constexpr (IsAnyOf(TDir1, Direction::SouthWest) || IsAnyOf(TDir2, Direction::SouthWest)) { + out.SetPixel(center + AmOffset(AmWidthOffset::HalfTileLeft, AmHeightOffset::HalfTileDown), color); + } + + // Third row (y = 2) + if constexpr (IsAnyOf(TDir1, Direction::NorthEast) || IsAnyOf(TDir2, Direction::NorthEast)) { + if (!(hasBridge && (IsAnyOf(TDir1, Direction::NorthEast) || IsAnyOf(TDir2, Direction::NorthEast)))) + out.SetPixel(center + AmOffset(AmWidthOffset::HalfTileRight, AmHeightOffset::None), color); + } + if constexpr (IsAnyOf(TDir1, Direction::NorthEast, Direction::SouthEast) || IsAnyOf(TDir2, Direction::NorthEast, Direction::SouthEast)) { + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileRight, AmHeightOffset::QuarterTileDown), color); + } + if constexpr (IsAnyOf(TDir1, Direction::SouthWest, Direction::SouthEast) || IsAnyOf(TDir2, Direction::SouthWest, Direction::SouthEast)) { + out.SetPixel(center + AmOffset(AmWidthOffset::None, AmHeightOffset::HalfTileDown), color); + } + if constexpr (IsAnyOf(TDir1, Direction::SouthWest) || IsAnyOf(TDir2, Direction::SouthWest)) { + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileLeft, AmHeightOffset::ThreeQuartersTileDown), color); + } + + // Fourth row (y = 3) + if constexpr (IsAnyOf(TDir1, Direction::SouthEast) || IsAnyOf(TDir2, Direction::SouthEast)) { + out.SetPixel(center + AmOffset(AmWidthOffset::HalfTileRight, AmHeightOffset::HalfTileDown), color); + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileRight, AmHeightOffset::ThreeQuartersTileDown), color); + } +} + +template +void DrawLava(const Surface &out, Point center, uint8_t color) +{ + if constexpr (IsAnyOf(TDir, Direction::NorthWest, Direction::North, Direction::NorthEast, Direction::NoDirection)) { + out.SetPixel(center + AmOffset(AmWidthOffset::None, AmHeightOffset::HalfTileUp), color); // north corner + } + if constexpr (IsAnyOf(TDir, Direction::SouthWest, Direction::West, Direction::NorthWest, Direction::North, Direction::NorthEast, Direction::NoDirection)) { + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileLeft, AmHeightOffset::QuarterTileUp), color); // northwest edge + out.SetPixel(center + AmOffset(AmWidthOffset::HalfTileLeft, AmHeightOffset::None), color); // northwest edge + } + if constexpr (IsAnyOf(TDir, Direction::SouthWest, Direction::West, Direction::NorthWest, Direction::NoDirection)) { + out.SetPixel(center + AmOffset(AmWidthOffset::ThreeQuartersTileLeft, AmHeightOffset::QuarterTileDown), color); // west corner + } + if constexpr (IsAnyOf(TDir, Direction::South, Direction::SouthWest, Direction::West, Direction::NorthWest, Direction::SouthEast, Direction::NoDirection)) { + out.SetPixel(center + AmOffset(AmWidthOffset::HalfTileLeft, AmHeightOffset::HalfTileDown), color); // southwest edge + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileLeft, AmHeightOffset::ThreeQuartersTileDown), color); // southwest edge + } + if constexpr (IsAnyOf(TDir, Direction::South, Direction::SouthWest, Direction::SouthEast, Direction::NoDirection)) { + out.SetPixel(center + AmOffset(AmWidthOffset::None, AmHeightOffset::FullTileDown), color); // south corner + } + if constexpr (IsAnyOf(TDir, Direction::South, Direction::SouthWest, Direction::NorthEast, Direction::East, Direction::SouthEast, Direction::NoDirection)) { + out.SetPixel(center + AmOffset(AmWidthOffset::HalfTileRight, AmHeightOffset::HalfTileDown), color); // southeast edge + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileRight, AmHeightOffset::ThreeQuartersTileDown), color); // southeast edge + } + if constexpr (IsAnyOf(TDir, Direction::NorthEast, Direction::East, Direction::SouthEast, Direction::NoDirection)) { + out.SetPixel(center + AmOffset(AmWidthOffset::ThreeQuartersTileRight, AmHeightOffset::QuarterTileDown), color); // east corner + } + if constexpr (IsAnyOf(TDir, Direction::NorthWest, Direction::North, Direction::NorthEast, Direction::East, Direction::SouthEast, Direction::NoDirection)) { + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileRight, AmHeightOffset::QuarterTileUp), color); // northeast edge + out.SetPixel(center + AmOffset(AmWidthOffset::HalfTileRight, AmHeightOffset::None), color); // northeast edge + } + if constexpr (IsNoneOf(TDir, Direction::South)) { + out.SetPixel(center + AmOffset(AmWidthOffset::None, AmHeightOffset::None), color); // north center + } + if constexpr (IsNoneOf(TDir, Direction::East)) { + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileLeft, AmHeightOffset::QuarterTileDown), color); // west center + } + if constexpr (IsNoneOf(TDir, Direction::West)) { + out.SetPixel(center + AmOffset(AmWidthOffset::QuarterTileRight, AmHeightOffset::QuarterTileDown), color); // east center + } + if constexpr (IsNoneOf(TDir, Direction::North)) { + out.SetPixel(center + AmOffset(AmWidthOffset::None, AmHeightOffset::HalfTileDown), color); // south center + } +} + /** * @brief Draw 4 south-east facing lines, used to communicate trigger locations to the player. */ @@ -484,11 +604,11 @@ void FixVerticalDoor(const Surface &out, Point center, AutomapTile neTile, uint8 */ void DrawWallConnections(const Surface &out, Point center, AutomapTile nwTile, AutomapTile neTile, uint8_t colorBright, uint8_t colorDim) { - if (IsAnyOf(nwTile.type, AutomapTile::Types::Horizontal, AutomapTile::Types::HorizontalDiamond, AutomapTile::Types::FenceHorizontal, AutomapTile::Types::Cross, AutomapTile::Types::CaveVerticalWoodCross, AutomapTile::Types::CaveRightCorner)) { + if (IsAnyOf(nwTile.type, AutomapTile::Types::HorizontalWallLava, AutomapTile::Types::Horizontal, AutomapTile::Types::HorizontalDiamond, AutomapTile::Types::FenceHorizontal, AutomapTile::Types::Cross, AutomapTile::Types::CaveVerticalWoodCross, AutomapTile::Types::CaveRightCorner)) { DrawMapLineSE(out, center + AmOffset(AmWidthOffset::QuarterTileLeft, AmHeightOffset::ThreeQuartersTileUp), AmLine(AmLineLength::HalfTile), colorDim); FixHorizontalDoor(out, center, nwTile, colorBright); } - if (IsAnyOf(neTile.type, AutomapTile::Types::Vertical, AutomapTile::Types::VerticalDiamond, AutomapTile::Types::FenceVertical, AutomapTile::Types::Cross, AutomapTile::Types::CaveHorizontalWoodCross, AutomapTile::Types::CaveLeftCorner)) { + if (IsAnyOf(neTile.type, AutomapTile::Types::VerticalWallLava, AutomapTile::Types::Vertical, AutomapTile::Types::VerticalDiamond, AutomapTile::Types::FenceVertical, AutomapTile::Types::Cross, AutomapTile::Types::CaveHorizontalWoodCross, AutomapTile::Types::CaveLeftCorner)) { DrawMapLineNE(out, center + AmOffset(AmWidthOffset::None, AmHeightOffset::HalfTileUp), AmLine(AmLineLength::HalfTile), colorDim); FixVerticalDoor(out, center, neTile, colorBright); } @@ -578,12 +698,12 @@ void DrawCorner(const Surface &out, Point center, AutomapTile nwTile, AutomapTil * @brief Draw half-tile length lines to connect walls to any walls to the south-west and/or south-east * (For caves the horizontal/vertical flags are swapped) */ -void DrawCaveWallConnections(const Surface &out, Point center, AutomapTile swTile, AutomapTile seTile, uint8_t colorDim) +void DrawCaveWallConnections(const Surface &out, Point center, AutomapTile sTile, AutomapTile swTile, AutomapTile seTile, uint8_t colorDim) { - if (IsAnyOf(swTile.type, AutomapTile::Types::CaveVertical, AutomapTile::Types::CaveVerticalWood, AutomapTile::Types::CaveCross, AutomapTile::Types::CaveWoodCross, AutomapTile::Types::CaveRightWoodCross, AutomapTile::Types::CaveLeftWoodCross, AutomapTile::Types::CaveRightCorner)) { + if (IsAnyOf(swTile.type, AutomapTile::Types::CaveVerticalWallLava, AutomapTile::Types::CaveVertical, AutomapTile::Types::CaveVerticalWood, AutomapTile::Types::CaveCross, AutomapTile::Types::CaveWoodCross, AutomapTile::Types::CaveRightWoodCross, AutomapTile::Types::CaveLeftWoodCross, AutomapTile::Types::CaveRightCorner)) { DrawMapLineNE(out, center + AmOffset(AmWidthOffset::QuarterTileLeft, AmHeightOffset::ThreeQuartersTileDown), AmLine(AmLineLength::HalfTile), colorDim); } - if (IsAnyOf(seTile.type, AutomapTile::Types::CaveHorizontal, AutomapTile::Types::CaveHorizontalWood, AutomapTile::Types::CaveCross, AutomapTile::Types::CaveWoodCross, AutomapTile::Types::CaveRightWoodCross, AutomapTile::Types::CaveLeftWoodCross, AutomapTile::Types::CaveLeftCorner)) { + if (IsAnyOf(seTile.type, AutomapTile::Types::CaveHorizontalWallLava, AutomapTile::Types::CaveHorizontal, AutomapTile::Types::CaveHorizontalWood, AutomapTile::Types::CaveCross, AutomapTile::Types::CaveWoodCross, AutomapTile::Types::CaveRightWoodCross, AutomapTile::Types::CaveLeftWoodCross, AutomapTile::Types::CaveLeftCorner)) { DrawMapLineSE(out, center + AmOffset(AmWidthOffset::None, AmHeightOffset::HalfTileDown), AmLine(AmLineLength::HalfTile), colorDim); } } @@ -786,9 +906,9 @@ void DrawAutomapTile(const Surface &out, Point center, Point map) || swTile.type != AutomapTile::Types::None || sTile.type != AutomapTile::Types::None || seTile.type != AutomapTile::Types::None - || IsAnyOf(nwTile.type, AutomapTile::Types::CaveCross, AutomapTile::Types::CaveVertical, AutomapTile::Types::CaveVerticalCross, AutomapTile::Types::CaveLeftWoodCross) + || IsAnyOf(nwTile.type, AutomapTile::Types::CaveCross, AutomapTile::Types::CaveVertical, AutomapTile::Types::CaveVerticalCross, AutomapTile::Types::CaveVerticalWallLava, AutomapTile::Types::CaveLeftWoodCross) || IsAnyOf(nTile.type, AutomapTile::Types::CaveCross) - || IsAnyOf(neTile.type, AutomapTile::Types::CaveCross, AutomapTile::Types::CaveHorizontal, AutomapTile::Types::CaveHorizontalCross, AutomapTile::Types::CaveRightWoodCross) + || IsAnyOf(neTile.type, AutomapTile::Types::CaveCross, AutomapTile::Types::CaveHorizontal, AutomapTile::Types::CaveHorizontalCross, AutomapTile::Types::CaveHorizontalWallLava, AutomapTile::Types::CaveRightWoodCross) || IsAnyOf(wTile.type, AutomapTile::Types::CaveVerticalCross) || IsAnyOf(eTile.type, AutomapTile::Types::CaveHorizontalCross)))) { DrawDirt(out, center, nwTile, neTile, colorDim); @@ -800,11 +920,22 @@ void DrawAutomapTile(const Surface &out, Point center, Point map) if (!noConnect) { if (IsAnyOf(leveltype, DTYPE_TOWN, DTYPE_CAVES, DTYPE_NEST)) { - DrawCaveWallConnections(out, center, swTile, seTile, colorDim); + DrawCaveWallConnections(out, center, sTile, swTile, seTile, colorDim); } DrawWallConnections(out, center, nwTile, neTile, colorBright, colorDim); } + uint8_t lavaColor = MapColorsLava; + if (leveltype == DTYPE_NEST) { + lavaColor = MapColorsAcid; + } else if (setlevel && setlvlnum == Quests[Q_PWATER]._qslvl) { + if (Quests[Q_PWATER]._qactive != QUEST_DONE) { + lavaColor = MapColorsAcid; + } else { + lavaColor = MapColorsWater; + } + } + switch (tile.type) { case AutomapTile::Types::Diamond: // stand-alone column or other unpassable object DrawDiamond(out, center, colorDim); @@ -902,6 +1033,73 @@ void DrawAutomapTile(const Surface &out, Point center, Point map) case AutomapTile::Types::RiverRightOut: DrawRiverRightOut(out, center, MapColorsItem); break; + case AutomapTile::Types::HorizontalLavaThin: + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::VerticalLavaThin: + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::BendSouthLavaThin: + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::BendWestLavaThin: + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::BendEastLavaThin: + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::BendNorthLavaThin: + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::VerticalWallLava: + DrawVertical(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim); + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::HorizontalWallLava: + DrawHorizontal(out, center, tile, nwTile, neTile, swTile, colorBright, colorDim); + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::SELava: + DrawLava(out, center, lavaColor); + break; + case AutomapTile::Types::SWLava: + DrawLava(out, center, lavaColor); + break; + case AutomapTile::Types::NELava: + DrawLava(out, center, lavaColor); + break; + case AutomapTile::Types::NWLava: + DrawLava(out, center, lavaColor); + break; + case AutomapTile::Types::SLava: + DrawLava(out, center, lavaColor); + break; + case AutomapTile::Types::WLava: + DrawLava(out, center, lavaColor); + break; + case AutomapTile::Types::ELava: + DrawLava(out, center, lavaColor); + break; + case AutomapTile::Types::NLava: + DrawLava(out, center, lavaColor); + break; + case AutomapTile::Types::Lava: + DrawLava(out, center, lavaColor); + break; + case AutomapTile::Types::CaveHorizontalWallLava: + DrawCaveHorizontal(out, center, tile, nwTile, swTile, colorBright, colorDim); + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::CaveVerticalWallLava: + DrawCaveVertical(out, center, tile, neTile, seTile, colorBright, colorDim); + DrawLavaRiver(out, center, lavaColor, false); + break; + case AutomapTile::Types::HorizontalBridgeLava: + DrawLavaRiver(out, center, lavaColor, true); + break; + case AutomapTile::Types::VerticalBridgeLava: + DrawLavaRiver(out, center, lavaColor, true); + break; } } @@ -1174,6 +1372,71 @@ void InitAutomap() tileTypes[142] = { AutomapTile::Types::CaveWoodCross }; tileTypes[138] = { AutomapTile::Types::CaveRightWoodCross }; tileTypes[139] = { AutomapTile::Types::CaveLeftWoodCross }; + tileTypes[14] = { AutomapTile::Types::HorizontalLavaThin }; + tileTypes[15] = { AutomapTile::Types::HorizontalLavaThin }; + tileTypes[16] = { AutomapTile::Types::VerticalLavaThin }; + tileTypes[17] = { AutomapTile::Types::VerticalLavaThin }; + tileTypes[18] = { AutomapTile::Types::BendSouthLavaThin }; + tileTypes[19] = { AutomapTile::Types::BendWestLavaThin }; + tileTypes[20] = { AutomapTile::Types::BendEastLavaThin }; + tileTypes[21] = { AutomapTile::Types::BendNorthLavaThin }; + tileTypes[22] = { AutomapTile::Types::VerticalWallLava }; + tileTypes[23] = { AutomapTile::Types::HorizontalWallLava }; + tileTypes[24] = { AutomapTile::Types::SELava }; + tileTypes[25] = { AutomapTile::Types::SWLava }; + tileTypes[26] = { AutomapTile::Types::NELava }; + tileTypes[27] = { AutomapTile::Types::NWLava }; + tileTypes[28] = { AutomapTile::Types::SLava }; + tileTypes[29] = { AutomapTile::Types::WLava }; + tileTypes[30] = { AutomapTile::Types::ELava }; + tileTypes[31] = { AutomapTile::Types::NLava }; + tileTypes[32] = { AutomapTile::Types::Lava }; + tileTypes[33] = { AutomapTile::Types::Lava }; + tileTypes[34] = { AutomapTile::Types::Lava }; + tileTypes[35] = { AutomapTile::Types::Lava }; + tileTypes[36] = { AutomapTile::Types::Lava }; + tileTypes[37] = { AutomapTile::Types::Lava }; + tileTypes[38] = { AutomapTile::Types::Lava }; + tileTypes[39] = { AutomapTile::Types::Lava }; + tileTypes[40] = { AutomapTile::Types::Lava }; + tileTypes[41] = { AutomapTile::Types::CaveHorizontalWallLava }; + tileTypes[42] = { AutomapTile::Types::CaveVerticalWallLava }; + tileTypes[43] = { AutomapTile::Types::HorizontalBridgeLava }; + tileTypes[44] = { AutomapTile::Types::VerticalBridgeLava }; + } else if (IsAnyOf(leveltype, DTYPE_NEST)) { + tileTypes[102] = { AutomapTile::Types::HorizontalLavaThin }; + tileTypes[103] = { AutomapTile::Types::HorizontalLavaThin }; + tileTypes[108] = { AutomapTile::Types::HorizontalLavaThin }; + tileTypes[104] = { AutomapTile::Types::VerticalLavaThin }; + tileTypes[105] = { AutomapTile::Types::VerticalLavaThin }; + tileTypes[107] = { AutomapTile::Types::VerticalLavaThin }; + tileTypes[112] = { AutomapTile::Types::BendSouthLavaThin }; + tileTypes[113] = { AutomapTile::Types::BendWestLavaThin }; + tileTypes[110] = { AutomapTile::Types::BendEastLavaThin }; + tileTypes[111] = { AutomapTile::Types::BendNorthLavaThin }; + tileTypes[134] = { AutomapTile::Types::VerticalWallLava }; + tileTypes[135] = { AutomapTile::Types::HorizontalWallLava }; + tileTypes[118] = { AutomapTile::Types::SELava }; + tileTypes[119] = { AutomapTile::Types::SWLava }; + tileTypes[120] = { AutomapTile::Types::NELava }; + tileTypes[121] = { AutomapTile::Types::NWLava }; + tileTypes[106] = { AutomapTile::Types::SLava }; + tileTypes[114] = { AutomapTile::Types::WLava }; + tileTypes[130] = { AutomapTile::Types::ELava }; + tileTypes[122] = { AutomapTile::Types::NLava }; + tileTypes[117] = { AutomapTile::Types::Lava }; + tileTypes[124] = { AutomapTile::Types::Lava }; + tileTypes[126] = { AutomapTile::Types::Lava }; + tileTypes[127] = { AutomapTile::Types::Lava }; + tileTypes[128] = { AutomapTile::Types::Lava }; + tileTypes[129] = { AutomapTile::Types::Lava }; + tileTypes[131] = { AutomapTile::Types::Lava }; + tileTypes[132] = { AutomapTile::Types::Lava }; + tileTypes[133] = { AutomapTile::Types::Lava }; + tileTypes[136] = { AutomapTile::Types::CaveHorizontalWallLava }; + tileTypes[137] = { AutomapTile::Types::CaveVerticalWallLava }; + tileTypes[115] = { AutomapTile::Types::HorizontalBridgeLava }; + tileTypes[116] = { AutomapTile::Types::VerticalBridgeLava }; } break; case DTYPE_HELL: