Tweak the add spatter plugin.

develop
Alexander Gavrilov 2012-09-18 13:15:25 +04:00
parent d70a79deb9
commit f2e7ee4756
2 changed files with 155 additions and 28 deletions

@ -7,6 +7,7 @@
#include <modules/Maps.h> #include <modules/Maps.h>
#include <modules/Job.h> #include <modules/Job.h>
#include <modules/Items.h> #include <modules/Items.h>
#include <modules/Units.h>
#include <TileTypes.h> #include <TileTypes.h>
#include <vector> #include <vector>
#include <cstdio> #include <cstdio>
@ -121,20 +122,22 @@ static void find_material(int *type, int *index, df::item *input, MaterialSource
} }
} }
static bool has_contaminant(df::item_actual *item, int type, int index) static int has_contaminant(df::item_actual *item, int type, int index)
{ {
auto cont = item->contaminants; auto cont = item->contaminants;
if (!cont) if (!cont)
return false; return 0;
int size = 0;
for (size_t i = 0; i < cont->size(); i++) for (size_t i = 0; i < cont->size(); i++)
{ {
auto cur = (*cont)[i]; auto cur = (*cont)[i];
if (cur->mat_type == type && cur->mat_index == index) if (cur->mat_type == type && cur->mat_index == index)
return true; size += cur->size;
} }
return false; return size;
} }
/* /*
@ -209,7 +212,7 @@ struct item_hook : df::item_constructed {
find_material(&mattype, &matindex, material, product.material); find_material(&mattype, &matindex, material, product.material);
if (mattype < 0 || has_contaminant(this, mattype, matindex)) if (mattype < 0 || has_contaminant(this, mattype, matindex) >= 50)
return false; return false;
} }
@ -253,15 +256,36 @@ struct product_hook : improvement_product {
if (object && (material || !product->material.reagent)) if (object && (material || !product->material.reagent))
{ {
using namespace df::enums::improvement_type;
int mattype, matindex; int mattype, matindex;
find_material(&mattype, &matindex, material, product->material); find_material(&mattype, &matindex, material, product->material);
df::matter_state state = matter_state::Liquid;
switch (improvement_type)
{
case COVERED:
if (flags.is_set(reaction_product_improvement_flags::GLAZED))
state = matter_state::Solid;
break;
case BANDS:
state = matter_state::Paste;
break;
case SPIKES:
state = matter_state::Powder;
break;
default:
break;
}
int rating = unit ? Units::getEffectiveSkill(unit, df::job_skill(skill)) : 0;
int size = int(probability*(1.0f + 0.06f*rating)); // +90% at legendary
object->addContaminant( object->addContaminant(
mattype, matindex, mattype, matindex, state,
matter_state::Liquid, // TODO: heuristics or by reagent name
object->getTemperature(), object->getTemperature(),
probability, // used as size size, -1,
-1,
0x8000 // not washed by water, and 'clean items' safe. 0x8000 // not washed by water, and 'clean items' safe.
); );
} }

@ -4,38 +4,141 @@ reaction_spatter
Reaction name must start with 'SPATTER_ADD_': Reaction name must start with 'SPATTER_ADD_':
[REACTION:SPATTER_ADD_EXTRACT_WEAPON] [REACTION:SPATTER_ADD_OBJECT_LIQUID]
[NAME:cover weapon with extract] [NAME:coat object with liquid]
[BUILDING:CRAFTSMAN:CUSTOM_ALT_V]
[SKILL:DYER]
[ADVENTURE_MODE_ENABLED] [ADVENTURE_MODE_ENABLED]
[REAGENT:extract:10:LIQUID_MISC:NONE:NONE:NONE] [SKILL:WAX_WORKING]
[MIN_DIMENSION:10] [REAGENT:extract:150:LIQUID_MISC:NONE:NONE:NONE]
[MIN_DIMENSION:150]
[REAGENT:extract container:1:NONE:NONE:NONE:NONE]
[CONTAINS:extract]
[PRESERVE_REAGENT]
[DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
The object to improve must be after the input mat, so that it is known:
[REAGENT:object:1:NONE:NONE:NONE:NONE]
[PRESERVE_REAGENT]
Need some excuse why the spatter is water-resistant:
[REAGENT:grease:1:GLOB:NONE:NONE:NONE][REACTION_CLASS:FAT][UNROTTEN]
The probability is used as spatter size; Legendary gives +90%:
COVERED = liquid, GLAZED = solid, BANDS = paste, SPIKES = powder
[IMPROVEMENT:800:object:BANDS:GET_MATERIAL_FROM_REAGENT:extract:NONE]
[REACTION:SPATTER_ADD_WEAPON_EXTRACT]
[NAME:coat weapon with extract]
[BUILDING:CRAFTSMAN:NONE]
[SKILL:WAX_WORKING]
[REAGENT:extract:150:LIQUID_MISC:NONE:NONE:NONE]
[MIN_DIMENSION:150]
[REACTION_CLASS:CREATURE_EXTRACT] [REACTION_CLASS:CREATURE_EXTRACT]
[REAGENT:extract container:1:NONE:NONE:NONE:NONE] [REAGENT:extract container:1:NONE:NONE:NONE:NONE]
[CONTAINS:extract] [CONTAINS:extract]
[PRESERVE_REAGENT] [PRESERVE_REAGENT]
[DOES_NOT_DETERMINE_PRODUCT_AMOUNT] [DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
The object to improve must be the last reagent: The object to improve must be after the input mat, so that it is known:
[REAGENT:object:1:WEAPON:NONE:NONE:NONE] [REAGENT:object:1:WEAPON:NONE:NONE:NONE]
[PRESERVE_REAGENT] [PRESERVE_REAGENT]
The probability is used as spatter size instead: Need some excuse why the spatter is water-resistant:
[IMPROVEMENT:100:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE] [REAGENT:grease:1:GLOB:NONE:NONE:NONE][REACTION_CLASS:TALLOW][UNROTTEN]
The probability is used as spatter size; Legendary gives +90%:
COVERED = liquid, GLAZED = solid, BANDS = paste, SPIKES = powder
[IMPROVEMENT:800:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE]
[REACTION:SPATTER_ADD_EXTRACT_AMMO] [REACTION:SPATTER_ADD_AMMO_EXTRACT]
[NAME:cover ammo with extract] [NAME:coat ammo with extract]
[BUILDING:CRAFTSMAN:CUSTOM_ALT_M] [BUILDING:CRAFTSMAN:NONE]
[SKILL:DYER] [SKILL:WAX_WORKING]
[ADVENTURE_MODE_ENABLED] [REAGENT:extract:50:LIQUID_MISC:NONE:NONE:NONE]
[REAGENT:extract:10:LIQUID_MISC:NONE:NONE:NONE] [MIN_DIMENSION:50]
[MIN_DIMENSION:10] [REACTION_CLASS:CREATURE_EXTRACT]
[REAGENT:extract container:1:NONE:NONE:NONE:NONE]
[CONTAINS:extract]
[PRESERVE_REAGENT]
[DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
The object to improve must be after the input mat, so that it is known:
[REAGENT:object:1:AMMO:NONE:NONE:NONE]
[PRESERVE_REAGENT]
Need some excuse why the spatter is water-resistant:
[REAGENT:grease:1:GLOB:NONE:NONE:NONE][REACTION_CLASS:TALLOW][UNROTTEN]
The probability is used as spatter size; Legendary gives +90%:
COVERED = liquid, GLAZED = solid, BANDS = paste, SPIKES = powder
[IMPROVEMENT:200:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE]
[REACTION:SPATTER_ADD_WEAPON_GCS]
[NAME:coat weapon with GCS venom]
[BUILDING:CRAFTSMAN:NONE]
[SKILL:WAX_WORKING]
[REAGENT:extract:150:LIQUID_MISC:NONE:CAVE_SPIDER_GIANT:POISON]
[MIN_DIMENSION:150]
[REACTION_CLASS:CREATURE_EXTRACT]
[REAGENT:extract container:1:NONE:NONE:NONE:NONE]
[CONTAINS:extract]
[PRESERVE_REAGENT]
[DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
The object to improve must be after the input mat, so that it is known:
[REAGENT:object:1:WEAPON:NONE:NONE:NONE]
[PRESERVE_REAGENT]
Need some excuse why the spatter is water-resistant:
[REAGENT:grease:1:GLOB:NONE:NONE:NONE][REACTION_CLASS:TALLOW][UNROTTEN]
The probability is used as spatter size; Legendary gives +90%:
COVERED = liquid, GLAZED = solid, BANDS = paste, SPIKES = powder
[IMPROVEMENT:800:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE]
[REACTION:SPATTER_ADD_AMMO_GCS]
[NAME:coat ammo with GCS venom]
[BUILDING:CRAFTSMAN:NONE]
[SKILL:WAX_WORKING]
[REAGENT:extract:50:LIQUID_MISC:NONE:CAVE_SPIDER_GIANT:POISON]
[MIN_DIMENSION:50]
[REACTION_CLASS:CREATURE_EXTRACT]
[REAGENT:extract container:1:NONE:NONE:NONE:NONE]
[CONTAINS:extract]
[PRESERVE_REAGENT]
[DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
The object to improve must be after the input mat, so that it is known:
[REAGENT:object:1:AMMO:NONE:NONE:NONE]
[PRESERVE_REAGENT]
Need some excuse why the spatter is water-resistant:
[REAGENT:grease:1:GLOB:NONE:NONE:NONE][REACTION_CLASS:TALLOW][UNROTTEN]
The probability is used as spatter size; Legendary gives +90%:
COVERED = liquid, GLAZED = solid, BANDS = paste, SPIKES = powder
[IMPROVEMENT:200:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE]
[REACTION:SPATTER_ADD_WEAPON_GDS]
[NAME:coat weapon with GDS venom]
[BUILDING:CRAFTSMAN:NONE]
[SKILL:WAX_WORKING]
[REAGENT:extract:150:LIQUID_MISC:NONE:SCORPION_DESERT_GIANT:POISON]
[MIN_DIMENSION:150]
[REACTION_CLASS:CREATURE_EXTRACT]
[REAGENT:extract container:1:NONE:NONE:NONE:NONE]
[CONTAINS:extract]
[PRESERVE_REAGENT]
[DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
The object to improve must be after the input mat, so that it is known:
[REAGENT:object:1:WEAPON:NONE:NONE:NONE]
[PRESERVE_REAGENT]
Need some excuse why the spatter is water-resistant:
[REAGENT:grease:1:GLOB:NONE:NONE:NONE][REACTION_CLASS:TALLOW][UNROTTEN]
The probability is used as spatter size; Legendary gives +90%:
COVERED = liquid, GLAZED = solid, BANDS = paste, SPIKES = powder
[IMPROVEMENT:800:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE]
[REACTION:SPATTER_ADD_AMMO_GDS]
[NAME:coat ammo with GDS venom]
[BUILDING:CRAFTSMAN:NONE]
[SKILL:WAX_WORKING]
[REAGENT:extract:50:LIQUID_MISC:NONE:SCORPION_DESERT_GIANT:POISON]
[MIN_DIMENSION:50]
[REACTION_CLASS:CREATURE_EXTRACT] [REACTION_CLASS:CREATURE_EXTRACT]
[REAGENT:extract container:1:NONE:NONE:NONE:NONE] [REAGENT:extract container:1:NONE:NONE:NONE:NONE]
[CONTAINS:extract] [CONTAINS:extract]
[PRESERVE_REAGENT] [PRESERVE_REAGENT]
[DOES_NOT_DETERMINE_PRODUCT_AMOUNT] [DOES_NOT_DETERMINE_PRODUCT_AMOUNT]
The object to improve must be the last reagent: The object to improve must be after the input mat, so that it is known:
[REAGENT:object:1:AMMO:NONE:NONE:NONE] [REAGENT:object:1:AMMO:NONE:NONE:NONE]
[PRESERVE_REAGENT] [PRESERVE_REAGENT]
The probability is used as spatter size instead: Need some excuse why the spatter is water-resistant:
[IMPROVEMENT:100:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE] [REAGENT:grease:1:GLOB:NONE:NONE:NONE][REACTION_CLASS:TALLOW][UNROTTEN]
The probability is used as spatter size; Legendary gives +90%:
COVERED = liquid, GLAZED = solid, BANDS = paste, SPIKES = powder
[IMPROVEMENT:200:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE]