#define WATER_VISC 1
#define LAVA_VISC 7
-// TODO: Get rid of these and set up some attributes like toughness,
-// fluffyness, and a funciton to calculate time and durability loss
-// (and sound? and whatever else) from them
-void setStoneLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
-void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
-void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
+void setConstantMaterialProperties(MaterialProperties &mprop, float time)
+{
+ mprop.diggability = DIGGABLE_CONSTANT;
+ mprop.constant_time = time;
+}
+
+void setStoneLikeMaterialProperties(MaterialProperties &mprop, float toughness)
+{
+ mprop.diggability = DIGGABLE_NORMAL;
+ mprop.weight = 5.0 * toughness;
+ mprop.crackiness = 1.0;
+ mprop.crumbliness = -0.1;
+ mprop.cuttability = -0.2;
+}
+
+void setDirtLikeMaterialProperties(MaterialProperties &mprop, float toughness)
+{
+ mprop.diggability = DIGGABLE_NORMAL;
+ mprop.weight = toughness * 2.0;
+ mprop.crackiness = 0;
+ mprop.crumbliness = 1.2;
+ mprop.cuttability = -0.4;
+}
+
+void setGravelLikeMaterialProperties(MaterialProperties &mprop, float toughness)
+{
+ mprop.diggability = DIGGABLE_NORMAL;
+ mprop.weight = toughness * 2.0;
+ mprop.crackiness = 0.5;
+ mprop.crumbliness = 1.5;
+ mprop.cuttability = -1.0;
+}
+
+void setWoodLikeMaterialProperties(MaterialProperties &mprop, float toughness)
+{
+ mprop.diggability = DIGGABLE_NORMAL;
+ mprop.weight = toughness * 1.0;
+ mprop.crackiness = 2.0;
+ mprop.crumbliness = -1.0;
+ mprop.cuttability = 2.0;
+}
+
+void setLeavesLikeMaterialProperties(MaterialProperties &mprop, float toughness)
+{
+ mprop.diggability = DIGGABLE_NORMAL;
+ mprop.weight = -0.5 * toughness;
+ mprop.crackiness = 0;
+ mprop.crumbliness = 0;
+ mprop.cuttability = 2.0;
+}
+
+void setGlassLikeMaterialProperties(MaterialProperties &mprop, float toughness)
+{
+ mprop.diggability = DIGGABLE_NORMAL;
+ mprop.weight = 0.5 * toughness;
+ mprop.crackiness = 2.0;
+ mprop.crumbliness = -1.0;
+ mprop.cuttability = -1.0;
+}
/*
A conversion table for backwards compatibility.
f->is_ground_content = true;
f->often_contains_mineral = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 1";
- setStoneLikeDiggingProperties(f->digging_properties, 1.0);
+ setStoneLikeMaterialProperties(f->material, 1.0);
if(invisible_stone)
f->solidness = 0; // For debugging, hides regular stone
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
- setDirtLikeDiggingProperties(f->digging_properties, 1.0);
+ setDirtLikeMaterialProperties(f->material, 1.0);
i = CONTENT_GRASS_FOOTSTEPS;
f = &content_features(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
- setDirtLikeDiggingProperties(f->digging_properties, 1.0);
+ setDirtLikeMaterialProperties(f->material, 1.0);
i = CONTENT_MUD;
f = &content_features(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setDirtLikeDiggingProperties(f->digging_properties, 1.0);
+ setDirtLikeMaterialProperties(f->material, 1.0);
i = CONTENT_SAND;
f = &content_features(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setDirtLikeDiggingProperties(f->digging_properties, 1.0);
+ setDirtLikeMaterialProperties(f->material, 1.0);
i = CONTENT_GRAVEL;
f = &content_features(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setDirtLikeDiggingProperties(f->digging_properties, 1.75);
+ setGravelLikeMaterialProperties(f->material, 1.0);
i = CONTENT_SANDSTONE;
f = &content_features(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAND)+" 1";
- setDirtLikeDiggingProperties(f->digging_properties, 1.0);
+ setDirtLikeMaterialProperties(f->material, 1.0);
i = CONTENT_CLAY;
f = &content_features(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("CraftItem lump_of_clay 4");
- setDirtLikeDiggingProperties(f->digging_properties, 1.0);
+ setDirtLikeMaterialProperties(f->material, 1.0);
i = CONTENT_BRICK;
f = &content_features(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("CraftItem clay_brick 4");
- setStoneLikeDiggingProperties(f->digging_properties, 1.0);
+ setStoneLikeMaterialProperties(f->material, 1.0);
i = CONTENT_TREE;
f = &content_features(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setWoodLikeDiggingProperties(f->digging_properties, 1.0);
+ setWoodLikeMaterialProperties(f->material, 1.0);
i = CONTENT_JUNGLETREE;
f = &content_features(i);
f->param_type = CPT_MINERAL;
//f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setWoodLikeDiggingProperties(f->digging_properties, 1.0);
+ setWoodLikeMaterialProperties(f->material, 1.0);
i = CONTENT_JUNGLEGRASS;
f = &content_features(i);
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->solidness = 0; // drawn separately, makes no faces
f->walkable = false;
- setWoodLikeDiggingProperties(f->digging_properties, 0.10);
+ setLeavesLikeMaterialProperties(f->material, 1.0);
i = CONTENT_LEAVES;
f = &content_features(i);
f->extra_dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAPLING)+" 1";
f->extra_dug_item_rarity = 20;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setWoodLikeDiggingProperties(f->digging_properties, 0.15);
+ setLeavesLikeMaterialProperties(f->material, 1.0);
i = CONTENT_CACTUS;
f = &content_features(i);
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setWoodLikeDiggingProperties(f->digging_properties, 0.75);
+ setWoodLikeMaterialProperties(f->material, 0.75);
i = CONTENT_PAPYRUS;
f = &content_features(i);
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
f->solidness = 0; // drawn separately, makes no faces
f->walkable = false;
- setWoodLikeDiggingProperties(f->digging_properties, 0.25);
+ setLeavesLikeMaterialProperties(f->material, 0.5);
i = CONTENT_BOOKSHELF;
f = &content_features(i);
//f->setInventoryTextureCube("wood.png", "bookshelf.png", "bookshelf.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
- setWoodLikeDiggingProperties(f->digging_properties, 0.75);
+ setWoodLikeMaterialProperties(f->material, 0.75);
i = CONTENT_GLASS;
f = &content_features(i);
f->visual_solidness = 1;
f->setAllTextures("glass.png");
f->setInventoryTextureCube("glass.png", "glass.png", "glass.png");
- setWoodLikeDiggingProperties(f->digging_properties, 0.15);
+ setGlassLikeMaterialProperties(f->material, 1.0);
i = CONTENT_FENCE;
f = &content_features(i);
f->air_equivalent = true; // grass grows underneath
f->setInventoryTexture("fence.png");
f->used_texturenames["fence.png"] = true;
- setWoodLikeDiggingProperties(f->digging_properties, 0.75);
+ setWoodLikeMaterialProperties(f->material, 0.75);
i = CONTENT_RAIL;
f = &content_features(i);
f->air_equivalent = true; // grass grows underneath
f->walkable = false;
f->selection_box.type = NODEBOX_FIXED;
- setDirtLikeDiggingProperties(f->digging_properties, 0.75);
+ setDirtLikeMaterialProperties(f->material, 0.75);
i = CONTENT_LADDER;
f = &content_features(i);
f->walkable = false;
f->climbable = true;
f->selection_box.type = NODEBOX_WALLMOUNTED;
- setWoodLikeDiggingProperties(f->digging_properties, 0.5);
+ setWoodLikeMaterialProperties(f->material, 0.5);
// Deprecated
i = CONTENT_COALSTONE;
f = &content_features(i);
f->setAllTextures("stone.png^mineral_coal.png");
f->is_ground_content = true;
- setStoneLikeDiggingProperties(f->digging_properties, 1.5);
+ setStoneLikeMaterialProperties(f->material, 1.5);
i = CONTENT_WOOD;
f = &content_features(i);
f->setInventoryTextureCube("wood.png", "wood.png", "wood.png");
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setWoodLikeDiggingProperties(f->digging_properties, 0.75);
+ setWoodLikeMaterialProperties(f->material, 0.75);
i = CONTENT_MESE;
f = &content_features(i);
f->setInventoryTextureCube("mese.png", "mese.png", "mese.png");
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setStoneLikeDiggingProperties(f->digging_properties, 0.5);
+ setStoneLikeMaterialProperties(f->material, 0.5);
i = CONTENT_CLOUD;
f = &content_features(i);
-BS/10, -BS/2, -BS/10, BS/10, -BS/2+BS/3.333*2, BS/10);
f->selection_box.wall_side = core::aabbox3d<f32>(
-BS/2, -BS/3.333, -BS/10, -BS/2+BS/3.333, BS/3.333, BS/10);
- f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
+ setConstantMaterialProperties(f->material, 0.0);
i = CONTENT_SIGN_WALL;
f = &content_features(i);
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
if(f->initial_metadata == NULL)
f->initial_metadata = new SignNodeMetadata("Some sign");
- f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
+ setConstantMaterialProperties(f->material, 0.5);
f->selection_box.type = NODEBOX_WALLMOUNTED;
i = CONTENT_CHEST;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
if(f->initial_metadata == NULL)
f->initial_metadata = new ChestNodeMetadata();
- setWoodLikeDiggingProperties(f->digging_properties, 1.0);
+ setWoodLikeMaterialProperties(f->material, 1.0);
i = CONTENT_LOCKABLE_CHEST;
f = &content_features(i);
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
if(f->initial_metadata == NULL)
f->initial_metadata = new LockingChestNodeMetadata();
- setWoodLikeDiggingProperties(f->digging_properties, 1.0);
+ setWoodLikeMaterialProperties(f->material, 1.0);
i = CONTENT_FURNACE;
f = &content_features(i);
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_COBBLE)+" 6";
if(f->initial_metadata == NULL)
f->initial_metadata = new FurnaceNodeMetadata();
- setStoneLikeDiggingProperties(f->digging_properties, 3.0);
+ setStoneLikeMaterialProperties(f->material, 3.0);
i = CONTENT_COBBLE;
f = &content_features(i);
f->param_type = CPT_NONE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setStoneLikeDiggingProperties(f->digging_properties, 0.9);
+ setStoneLikeMaterialProperties(f->material, 0.9);
i = CONTENT_MOSSYCOBBLE;
f = &content_features(i);
f->param_type = CPT_NONE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setStoneLikeDiggingProperties(f->digging_properties, 0.8);
+ setStoneLikeMaterialProperties(f->material, 0.8);
i = CONTENT_STEEL;
f = &content_features(i);
f->param_type = CPT_NONE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setStoneLikeDiggingProperties(f->digging_properties, 5.0);
+ setStoneLikeMaterialProperties(f->material, 5.0);
i = CONTENT_NC;
f = &content_features(i);
f->setTexture(4, "nc_back.png"); // Z+
f->setInventoryTexture("nc_front.png");
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setStoneLikeDiggingProperties(f->digging_properties, 3.0);
+ setStoneLikeMaterialProperties(f->material, 3.0);
i = CONTENT_NC_RB;
f = &content_features(i);
f->setAllTextures("nc_rb.png");
f->setInventoryTexture("nc_rb.png");
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
- setStoneLikeDiggingProperties(f->digging_properties, 3.0);
+ setStoneLikeMaterialProperties(f->material, 3.0);
i = CONTENT_SAPLING;
f = &content_features(i);
f->air_equivalent = false;
f->solidness = 0; // drawn separately, makes no faces
f->walkable = false;
- f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
+ setConstantMaterialProperties(f->material, 0.0);
i = CONTENT_APPLE;
f = &content_features(i);
f->walkable = false;
f->air_equivalent = true;
f->dug_item = std::string("CraftItem apple 1");
- f->digging_properties.set("", DiggingProperties(true, 0.0, 0));
-
- // NOTE: Remember to add frequently used stuff to the texture atlas in tile.cpp
-
-
- /*
- Add MesePick to everything
- */
- for(u16 i=0; i<=MAX_CONTENT; i++)
- {
- content_features(i).digging_properties.set("MesePick",
- DiggingProperties(true, 0.0, 65535./1337));
- }
-
-}
-
-void setStoneLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
-{
- list.set("",
- DiggingProperties(true, 15.0*toughness, 0));
-
- list.set("WPick",
- DiggingProperties(true, 1.3*toughness, 65535./30.*toughness));
- list.set("STPick",
- DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
- list.set("SteelPick",
- DiggingProperties(true, 0.50*toughness, 65535./333.*toughness));
-
- /*list.set("MesePick",
- DiggingProperties(true, 0.0*toughness, 65535./20.*toughness));*/
-}
-
-void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
-{
- list.set("",
- DiggingProperties(true, 0.75*toughness, 0));
-
- list.set("WShovel",
- DiggingProperties(true, 0.4*toughness, 65535./50.*toughness));
- list.set("STShovel",
- DiggingProperties(true, 0.2*toughness, 65535./150.*toughness));
- list.set("SteelShovel",
- DiggingProperties(true, 0.15*toughness, 65535./400.*toughness));
-}
-
-void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness)
-{
- list.set("",
- DiggingProperties(true, 3.0*toughness, 0));
-
- list.set("WAxe",
- DiggingProperties(true, 1.5*toughness, 65535./30.*toughness));
- list.set("STAxe",
- DiggingProperties(true, 0.75*toughness, 65535./100.*toughness));
- list.set("SteelAxe",
- DiggingProperties(true, 0.5*toughness, 65535./333.*toughness));
+ setConstantMaterialProperties(f->material, 0.0);
}
#include "mapnode.h"
#include "mapnode_contentfeatures.h"
-// NOTE: DEPRECATED
-DiggingPropertiesList * getDiggingPropertiesList(u16 content)
+struct ToolProperties
{
- return &content_features(content).digging_properties;
+ // time = basetime + sum(feature here * feature in MaterialProperties)
+ float basetime;
+ float dt_weight;
+ float dt_crackiness;
+ float dt_crumbliness;
+ float dt_cuttability;
+ float basedurability;
+ float dd_weight;
+ float dd_crackiness;
+ float dd_crumbliness;
+ float dd_cuttability;
+
+ ToolProperties(float a=0.75, float b=0, float c=0, float d=0, float e=0,
+ float f=50, float g=0, float h=0, float i=0, float j=0):
+ basetime(a),
+ dt_weight(b),
+ dt_crackiness(c),
+ dt_crumbliness(d),
+ dt_cuttability(e),
+ basedurability(f),
+ dd_weight(g),
+ dd_crackiness(h),
+ dd_crumbliness(i),
+ dd_cuttability(j)
+ {}
+};
+
+ToolProperties getToolProperties(const std::string &toolname)
+{
+ // weight, crackiness, crumbleness, cuttability
+ if(toolname == "WPick")
+ return ToolProperties(2.0, 0,-1,2,0, 50, 0,0,0,0);
+ else if(toolname == "STPick")
+ return ToolProperties(1.5, 0,-1,2,0, 100, 0,0,0,0);
+ else if(toolname == "SteelPick")
+ return ToolProperties(1.0, 0,-1,2,0, 300, 0,0,0,0);
+
+ else if(toolname == "MesePick")
+ return ToolProperties(0, 0,0,0,0, 1337, 0,0,0,0);
+
+ else if(toolname == "WShovel")
+ return ToolProperties(1.5, 0.5,2,-1.5,0.3, 50, 0,0,0,0);
+ else if(toolname == "STShovel")
+ return ToolProperties(1.0, 0.5,2,-1.5,0.1, 100, 0,0,0,0);
+ else if(toolname == "SteelShovel")
+ return ToolProperties(0.6, 0.5,2,-1.5,0.0, 300, 0,0,0,0);
+
+ // weight, crackiness, crumbleness, cuttability
+ else if(toolname == "WAxe")
+ return ToolProperties(2.0, 0.5,-0.2,1,-0.5, 50, 0,0,0,0);
+ else if(toolname == "STAxe")
+ return ToolProperties(1.5, 0.5,-0.2,1,-0.5, 100, 0,0,0,0);
+ else if(toolname == "SteelAxe")
+ return ToolProperties(1.0, 0.5,-0.2,1,-0.5, 300, 0,0,0,0);
+
+ else if(toolname == "WSword")
+ return ToolProperties(3.0, 3,0,1,-1, 50, 0,0,0,0);
+ else if(toolname == "STSword")
+ return ToolProperties(2.5, 3,0,1,-1, 100, 0,0,0,0);
+ else if(toolname == "SteelSword")
+ return ToolProperties(2.0, 3,0,1,-1, 300, 0,0,0,0);
+
+ // Properties of hand
+ return ToolProperties(0.5, 1,0.4,-0.75,0, 50, 0,0,0,0);
}
-DiggingProperties getDiggingProperties(u16 content, const std::string &tool)
+DiggingProperties getDiggingProperties(u16 material, const std::string &tool)
{
- DiggingPropertiesList *mprop = getDiggingPropertiesList(content);
- if(mprop == NULL)
- // Not diggable
- return DiggingProperties();
+ MaterialProperties &mp = content_features(material).material;
+ if(mp.diggability == DIGGABLE_NOT)
+ return DiggingProperties(false, 0, 0);
+ if(mp.diggability == DIGGABLE_CONSTANT)
+ return DiggingProperties(true, mp.constant_time, 0);
+
+ ToolProperties tp = getToolProperties(tool);
- return mprop->get(tool);
+ float time = tp.basetime;
+ time += tp.dt_weight * mp.weight;
+ time += tp.dt_crackiness * mp.crackiness;
+ time += tp.dt_crumbliness * mp.crumbliness;
+ time += tp.dt_cuttability * mp.cuttability;
+ if(time < 0.2)
+ time = 0.2;
+
+ float durability = tp.basedurability;
+ durability += tp.dd_weight * mp.weight;
+ durability += tp.dd_crackiness * mp.crackiness;
+ durability += tp.dd_crumbliness * mp.crumbliness;
+ durability += tp.dd_cuttability * mp.cuttability;
+ if(durability < 1)
+ durability = 1;
+
+ float wear = 1.0 / durability;
+ u16 wear_i = wear/65535.;
+ return DiggingProperties(true, time, wear_i);
}