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/Job.h>
#include <modules/Items.h>
#include <modules/Units.h>
#include <TileTypes.h>
#include <vector>
#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;
if (!cont)
return false;
return 0;
int size = 0;
for (size_t i = 0; i < cont->size(); i++)
{
auto cur = (*cont)[i];
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);
if (mattype < 0 || has_contaminant(this, mattype, matindex))
if (mattype < 0 || has_contaminant(this, mattype, matindex) >= 50)
return false;
}
@ -253,15 +256,36 @@ struct product_hook : improvement_product {
if (object && (material || !product->material.reagent))
{
using namespace df::enums::improvement_type;
int mattype, matindex;
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(
mattype, matindex,
matter_state::Liquid, // TODO: heuristics or by reagent name
mattype, matindex, state,
object->getTemperature(),
probability, // used as size
-1,
size, -1,
0x8000 // not washed by water, and 'clean items' safe.
);
}

@ -4,38 +4,141 @@ reaction_spatter
Reaction name must start with 'SPATTER_ADD_':
[REACTION:SPATTER_ADD_EXTRACT_WEAPON]
[NAME:cover weapon with extract]
[BUILDING:CRAFTSMAN:CUSTOM_ALT_V]
[SKILL:DYER]
[REACTION:SPATTER_ADD_OBJECT_LIQUID]
[NAME:coat object with liquid]
[ADVENTURE_MODE_ENABLED]
[REAGENT:extract:10:LIQUID_MISC:NONE:NONE:NONE]
[MIN_DIMENSION:10]
[SKILL:WAX_WORKING]
[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]
[REAGENT:extract container:1:NONE:NONE:NONE:NONE]
[CONTAINS:extract]
[PRESERVE_REAGENT]
[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]
[PRESERVE_REAGENT]
The probability is used as spatter size instead:
[IMPROVEMENT:100:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE]
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_EXTRACT_AMMO]
[NAME:cover ammo with extract]
[BUILDING:CRAFTSMAN:CUSTOM_ALT_M]
[SKILL:DYER]
[ADVENTURE_MODE_ENABLED]
[REAGENT:extract:10:LIQUID_MISC:NONE:NONE:NONE]
[MIN_DIMENSION:10]
[REACTION:SPATTER_ADD_AMMO_EXTRACT]
[NAME:coat ammo with extract]
[BUILDING:CRAFTSMAN:NONE]
[SKILL:WAX_WORKING]
[REAGENT:extract:50:LIQUID_MISC:NONE:NONE:NONE]
[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_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]
[REAGENT:extract container:1:NONE:NONE:NONE:NONE]
[CONTAINS:extract]
[PRESERVE_REAGENT]
[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]
[PRESERVE_REAGENT]
The probability is used as spatter size instead:
[IMPROVEMENT:100:object:COVERED:GET_MATERIAL_FROM_REAGENT:extract:NONE]
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]