From 8b07f27bded440cd1e0e0178df07cd4dc6df5b44 Mon Sep 17 00:00:00 2001 From: ephphatha Date: Sat, 9 Oct 2021 23:25:27 +1100 Subject: [PATCH] Remove CowOffsets, always treat cows as 4 tile sprites --- Source/towners.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Source/towners.cpp b/Source/towners.cpp index bc7b625b7..58d3b07f3 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -16,13 +16,6 @@ std::unique_ptr CowCels; int CowMsg; int CowClicks; -/** - * Maps from direction to coordinate delta, which is used when - * placing cows in Tristram. A single cow may require space of up - * to three tiles when being placed on the map. - */ -Displacement CowOffsets[8] = { { -1, -1 }, { 0, -1 }, { -1, -1 }, { -1, 0 }, { -1, -1 }, { 0, -1 }, { -1, -1 }, { -1, 0 } }; - /** Specifies the active sound effect ID for interacting with cows. */ _sfx_id CowPlaying = SFX_NONE; @@ -225,14 +218,19 @@ void InitCows(Towner &towner, const TownerData &townerData) towner.name = _("Cow"); const Point position = townerData.position; - const Point offset = position + CowOffsets[static_cast(townerData.dir)]; - int index = -dMonster[position.x][position.y]; - if (dMonster[position.x][offset.y] == 0) - dMonster[position.x][offset.y] = index; - if (dMonster[offset.x][position.y] == 0) - dMonster[offset.x][position.y] = index; - if (dMonster[offset.x][offset.y] == 0) - dMonster[offset.x][offset.y] = index; + int cowId = dMonster[position.x][position.y]; + + // Cows are large sprites so take up multiple tiles. Vanilla Diablo/Hellfire allowed the player to stand adjacent + // to a cow facing an ordinal direction (the two top-right cows) which leads to visual clipping. It's easier to + // treat all cows as 4 tile sprites since this works for all facings. + // The active tile is always the south tile as this is closest to the camera, we mark the other 3 tiles as occupied + // using -id to match the convention used for moving/large monsters and players. + Point offset = position + Direction::NorthWest; + dMonster[offset.x][offset.y] = -cowId; + offset = position + Direction::NorthEast; + dMonster[offset.x][offset.y] = -cowId; + offset = position + Direction::North; + dMonster[offset.x][offset.y] = -cowId; } void InitFarmer(Towner &towner, const TownerData &townerData)