Skip to content

Commit

Permalink
Add a plugin implementing 'add spatter to item' reactions.
Browse files Browse the repository at this point in the history
  • Loading branch information
angavrilov committed Sep 17, 2012
1 parent 613063c commit 36e44c6
Show file tree
Hide file tree
Showing 10 changed files with 526 additions and 5 deletions.
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@ DFHack v0.34.11-r2 (UNRELEASED)
and restricting operator skill range like with ordinary workshops.
Disclaimer: not in any way to undermine the future siege update from Toady, but the aiming
logic of existing engines hasn't been updated since 2D, and is almost useless as/is.

New Add Spatter plugin:
Detects reactions with certain names in the raws, and changes them from adding
improvements to adding item contaminants. This allows directly covering items
with poisons. The added spatters are immune both to water and 'clean items'.
5 changes: 5 additions & 0 deletions library/include/modules/Materials.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ namespace DFHack
bool findPlant(const std::string &token, const std::string &subtoken);
bool findCreature(const std::string &token, const std::string &subtoken);

bool findProduct(df::material *material, const std::string &name);
bool findProduct(const MaterialInfo &info, const std::string &name) {
return findProduct(info.material, name);
}

std::string getToken();
std::string toString(uint16_t temp = 10015, bool named = true);

Expand Down
13 changes: 13 additions & 0 deletions library/modules/Materials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,19 @@ bool MaterialInfo::findCreature(const std::string &token, const std::string &sub
return decode(-1);
}

bool MaterialInfo::findProduct(df::material *material, const std::string &name)
{
if (!material || name.empty())
return decode(-1);

auto &pids = material->reaction_product.id;
for (size_t i = 0; i < pids.size(); i++)
if ((*pids[i]) == name)
return decode(material->reaction_product.material, i);

return decode(-1);
}

std::string MaterialInfo::getToken()
{
if (isNone())
Expand Down
2 changes: 1 addition & 1 deletion library/xml
Submodule xml updated from a6b95f to 260ff4
4 changes: 4 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ install(DIRECTORY lua/
install(DIRECTORY raw/
DESTINATION ${DFHACK_DATA_DESTINATION}/raw
FILES_MATCHING PATTERN "*.txt")
install(DIRECTORY raw/
DESTINATION ${DFHACK_DATA_DESTINATION}/raw
FILES_MATCHING PATTERN "*.diff")

# Protobuf
FILE(GLOB PROJECT_PROTOS ${CMAKE_CURRENT_SOURCE_DIR}/proto/*.proto)
Expand Down Expand Up @@ -120,6 +123,7 @@ if (BUILD_SUPPORTED)
DFHACK_PLUGIN(steam-engine steam-engine.cpp)
DFHACK_PLUGIN(power-meter power-meter.cpp LINK_LIBRARIES lua)
DFHACK_PLUGIN(siege-engine siege-engine.cpp LINK_LIBRARIES lua)
DFHACK_PLUGIN(add-spatter add-spatter.cpp)
# not yet. busy with other crud again...
#DFHACK_PLUGIN(versionosd versionosd.cpp)
endif()
Expand Down
Loading

0 comments on commit 36e44c6

Please sign in to comment.