Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/wiki.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <wiki/load-balancing-table>`
- Game Mechanics
- :doc:`Stockpile <wiki/game-mechanics/stockpile>`
- AI Behavior
- Graphics and Sound Systems
- Modding Support
Expand Down
21 changes: 21 additions & 0 deletions docs/wiki/game-mechanics/stockpile.md
Original file line number Diff line number Diff line change
@@ -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.
32 changes: 32 additions & 0 deletions src/OpenSHC/Map/TileMapState/clearStockpileFootprintTiles.cpp
Original file line number Diff line number Diff line change
@@ -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;
Comment thread
TheRedDaemon marked this conversation as resolved.
}
this->AlphaGFXLayer[tile] = 0;
}
}

}
}
2 changes: 1 addition & 1 deletion status/addresses-SHC-3BB0A8C1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down