From e348fa3b1e4ef50955a9d9a023243b560402ff21 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 11 Sep 2022 05:44:54 +0200 Subject: [PATCH] Implement town map --- CMake/Assets.cmake | 2 + .../assets/levels/towndata/automap.amp | Bin 0 -> 312 bytes .../assets/levels/towndata/automap.dun | Bin 0 -> 54404 bytes Source/automap.cpp | 281 ++++++++++++++++-- Source/control.cpp | 12 +- Source/diablo.cpp | 3 + Source/levels/town.cpp | 17 ++ 7 files changed, 283 insertions(+), 32 deletions(-) create mode 100644 Packaging/resources/assets/levels/towndata/automap.amp create mode 100644 Packaging/resources/assets/levels/towndata/automap.dun diff --git a/CMake/Assets.cmake b/CMake/Assets.cmake index 4da83d212..7c6227ee1 100644 --- a/CMake/Assets.cmake +++ b/CMake/Assets.cmake @@ -159,6 +159,8 @@ set(devilutionx_assets gendata/cutstartw.clx levels/l1data/sklkngt.dun levels/l2data/bonechat.dun + levels/towndata/automap.dun + levels/towndata/automap.amp nlevels/l5data/cornerstone.dun nlevels/l5data/uberroom.dun ui_art/diablo.pal diff --git a/Packaging/resources/assets/levels/towndata/automap.amp b/Packaging/resources/assets/levels/towndata/automap.amp new file mode 100644 index 0000000000000000000000000000000000000000..55a83f62d3b3ddb1ed961594ae657bb5e4c07888 GIT binary patch literal 312 zcmY+9feykT5JMl^5|Pd6)Ty7tr}61tIf#?yLV;enMiOUcV6h?(j7*%w>snbmMQ`w| z=Z!m8ZpPp2e0Vk0!~EoSF*Su^9hnkvxF|I3Z+B;DsLHPE3e82H^nd>6It#Jos41+y gI%ds#T*>Yo@^VDWuhQJA)747vA&;>Hq)$ literal 0 HcmV?d00001 diff --git a/Packaging/resources/assets/levels/towndata/automap.dun b/Packaging/resources/assets/levels/towndata/automap.dun new file mode 100644 index 0000000000000000000000000000000000000000..831a1b365dcc1ddb3b499a02cea5b1224e1aeab0 GIT binary patch literal 54404 zcmeI!&2G~`6vgoo6t$&o7Fi-e5g$@npguz1u33NtY$yUA7N1-n-)oPXDl0aBEY%ao zbLP%(>#SqEDtq zHPI{Xf7jlY3fJc#N=#$l*mcDUS0=dSA@@h)9vu|8G8%D@AK0Yt|dJN6hGnT~j!Rb%CnC7Z0M^<%_0@g9F$+`sHS|E#QjjJRiaFe&a?u7|R8 zEq93f_G8G==fjmnUR@8pTgs}};;v)HhOtv>u+f@958m^5(T@Jv9G%weDw;9dEqedcXH|%(|;;_TiazM>YN4R5NPZJvGnF z%L-e%sR3J>L}l2_BtrFHQPZRpQ=?(;6n^K;!kO*@zJoH(!0PWqjUJY`&# zU$hu+H+=6k(esyib3@mpXR)q&w)5G~nMK}Og*7i{UR!a8#><&G?{>JVBi|ptXZ`P_ zGczw|<~&un8RnjqyH|g{8^^ABt}ye|+LX#`PF LoadAutomapData(size_t &tileCount) { switch (leveltype) { + case DTYPE_TOWN: + return LoadFileInMem("levels\\towndata\\automap.amp", &tileCount); case DTYPE_CATHEDRAL: return LoadFileInMem("levels\\l1data\\l1.amp", &tileCount); case DTYPE_CATACOMBS: @@ -634,12 +869,10 @@ void AutomapZoomOut() void DrawAutomap(const Surface &out) { - if (leveltype == DTYPE_TOWN) { - DrawAutomapText(out); - return; + Automap = { (ViewPosition.x - 8) / 2, (ViewPosition.y - 8) / 2 }; + if (leveltype != DTYPE_TOWN) { + Automap += { -4, -4 }; } - - Automap = { (ViewPosition.x - 16) / 2, (ViewPosition.y - 16) / 2 }; while (Automap.x + AutomapOffset.deltaX < 0) AutomapOffset.deltaX++; while (Automap.x + AutomapOffset.deltaX >= DMAXX) diff --git a/Source/control.cpp b/Source/control.cpp index 9d8576f42..a745bd3a7 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -713,14 +713,10 @@ void control_check_btn_press() void DoAutoMap() { - if (leveltype != DTYPE_TOWN || gbIsMultiplayer) { - if (!AutomapActive) - StartAutomap(); - else - AutomapActive = false; - } else { - InitDiabloMsg(EMSG_NO_AUTOMAP_IN_TOWN); - } + if (!AutomapActive) + StartAutomap(); + else + AutomapActive = false; } void CheckPanelInfo() diff --git a/Source/diablo.cpp b/Source/diablo.cpp index e3906616a..3fcb8df49 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -2202,6 +2202,9 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir) DeltaLoadLevel(); IncProgress(); + for (int x = 0; x < DMAXX; x++) + for (int y = 0; y < DMAXY; y++) + UpdateAutomapExplorer({ x, y }, MAP_EXP_SELF); } if (!gbIsMultiplayer) ResyncQuests(); diff --git a/Source/levels/town.cpp b/Source/levels/town.cpp index 8bd8f9fe7..c511d03b4 100644 --- a/Source/levels/town.cpp +++ b/Source/levels/town.cpp @@ -75,6 +75,9 @@ void FillTile(int xx, int yy, int t) */ void TownCloseHive() { + dungeon[35][27] = 18; + dungeon[36][27] = 63; + dPiece[78][60] = 0x489; dPiece[79][60] = 0x4ea; dPiece[78][61] = 0x4eb; @@ -198,14 +201,23 @@ void DrlgTPass3() FillSector("levels\\towndata\\sector3s.dun", 0, 46); FillSector("levels\\towndata\\sector4s.dun", 0, 0); + auto dunData = LoadFileInMem("levels\\towndata\\automap.dun"); + PlaceDunTiles(dunData.get(), { 0, 0 }); + if (!IsWarpOpen(DTYPE_CATACOMBS)) { + dungeon[20][7] = 10; + dungeon[20][6] = 8; FillTile(48, 20, 320); } if (!IsWarpOpen(DTYPE_CAVES)) { + dungeon[4][30] = 8; FillTile(16, 68, 332); FillTile(16, 70, 331); } if (!IsWarpOpen(DTYPE_HELL)) { + dungeon[15][35] = 7; + dungeon[16][35] = 7; + dungeon[17][35] = 7; for (int x = 36; x < 46; x++) { FillTile(x, 78, GenerateRnd(4) + 1); } @@ -249,6 +261,8 @@ bool OpensGrave(Point position) void TownOpenHive() { + dungeon[36][27] = 47; + dPiece[78][60] = 0x489; dPiece[79][60] = 0x48a; dPiece[78][61] = 0x48b; @@ -299,6 +313,9 @@ void TownOpenHive() void TownOpenGrave() { + dungeon[14][8] = 47; + dungeon[14][7] = 47; + dPiece[36][21] = 0x532; dPiece[37][21] = 0x533; dPiece[36][22] = 0x534;