diff --git a/docs/wiki.rst b/docs/wiki.rst index ce0e938e..a52a04a6 100644 --- a/docs/wiki.rst +++ b/docs/wiki.rst @@ -29,7 +29,7 @@ For the recommended method of using SARIF files in Ghidra, see: The Game itself ------------------ - :doc:`Load balancing of the core game engine ` -- Game Mechanics +- :doc:`Stockpile ` - AI Behavior - Graphics and Sound Systems - Modding Support diff --git a/docs/wiki/game-mechanics/stockpile.md b/docs/wiki/game-mechanics/stockpile.md new file mode 100644 index 00000000..77adfb5b --- /dev/null +++ b/docs/wiki/game-mechanics/stockpile.md @@ -0,0 +1,21 @@ +# Stockpile + +Removing a stockpile clears its nine walkable tiles. Its four building parts +are removed separately. + +For each walkable tile, cleanup: + +1. Clears the stockpile and wall/gatehouse map-logic flags and restores the + default terrain height. +2. Updates the former-building and display information according to the + building's rubble setting. The exact visual effect of one display flag + remains unidentified. +3. Removes the tile's building reference. + +## Placement + +Placing a keep creates a starting stockpile for both human and AI players. + +The first stockpile needs no adjacent existing stockpile. Further stockpiles +require available capacity and adjacency to the owner's stockpile, as well as +suitable terrain. AI castle placement uses the same placement rules. diff --git a/src/OpenSHC/Map/TileMapState/clearStockpileFootprintTiles.cpp b/src/OpenSHC/Map/TileMapState/clearStockpileFootprintTiles.cpp new file mode 100644 index 00000000..25adbabf --- /dev/null +++ b/src/OpenSHC/Map/TileMapState/clearStockpileFootprintTiles.cpp @@ -0,0 +1,32 @@ +#include "../TileMapState.func.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_TerrainDefinedData.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Map/LogicHelpers/Logic1.hpp" + +namespace OpenSHC { +namespace Map { + + // FUNCTION: STRONGHOLDCRUSADER 0x004FAF70 + void TileMapState::clearStockpileFootprintTiles(int x, int y) + { + for (int i = 0; i < 9; ++i) { + int tile = DAT_ViewportRenderState::instance + .translationMatrix[y + DAT_TerrainDefinedData::instance.StockpilePathableOffsets[i].y] + .addXgetTile + + x + DAT_TerrainDefinedData::instance.StockpilePathableOffsets[i].x; + + this->LogicLayer[tile] &= ~(LogicHelpers::L_STOCKPILEUnk | LogicHelpers::L_WALL_OR_GATEHOUSE); + this->HeightLayer[tile] = this->DefaultHeightLayer[tile]; + if (DAT_BuildingsState::instance.buildings[this->AlphaGFXLayer[tile]].noRubble == 0) { + this->BuildingWasLayer[tile] = 0; + } else { + this->MiscDisplayLayer[tile] |= 0x4000; + } + this->AlphaGFXLayer[tile] = 0; + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 10a0c2b0..006579f7 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -40367,7 +40367,7 @@ SHC_3BB0A8C1_0x004FAE50 | 0.0% | Pending SHC_3BB0A8C1_0x004FAEE0 | 0.0% | Pending -SHC_3BB0A8C1_0x004FAF70 | 0.0% | Pending +SHC_3BB0A8C1_0x004FAF70 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004FB0C0 | 0.0% | Pending