forked from oerkki/voxelands
add support for extra_dug_item to restricted to certain tool levels
This commit is contained in:
parent
a62ff30da9
commit
5e0a19550d
|
@ -466,7 +466,8 @@ void content_mapnode_init(bool repeat)
|
|||
f->is_ground_content = true;
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->extra_dug_item = std::string("MaterialItem2 ")+itos(CONTENT_ROCK)+" 1";
|
||||
f->extra_dug_item_rarity = 5;
|
||||
f->extra_dug_item_rarity = 3;
|
||||
f->extra_dug_item_max_level = 1;
|
||||
f->type = CMT_DIRT;
|
||||
f->hardness = 1.0;
|
||||
f->farm_ploughable = true;
|
||||
|
@ -498,6 +499,7 @@ void content_mapnode_init(bool repeat)
|
|||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->extra_dug_item = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_SALTPETER)+" 1";
|
||||
f->extra_dug_item_rarity = 30;
|
||||
f->extra_dug_item_min_level = 3;
|
||||
f->cook_result = std::string("MaterialItem2 ")+itos(CONTENT_GLASS)+" 1";
|
||||
f->type = CMT_DIRT;
|
||||
f->hardness = 1.0;
|
||||
|
@ -516,6 +518,7 @@ void content_mapnode_init(bool repeat)
|
|||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->extra_dug_item = std::string("CraftItem lump_of_flint 1");
|
||||
f->extra_dug_item_rarity = 10;
|
||||
f->extra_dug_item_min_level = 1;
|
||||
f->type = CMT_DIRT;
|
||||
f->hardness = 1.75;
|
||||
lists::add("creative",i);
|
||||
|
|
|
@ -291,6 +291,7 @@ void content_toolitem_init()
|
|||
f->name = "WShovel";
|
||||
f->description = wgettext("Stone Trowel");
|
||||
f->type = TT_SHOVEL;
|
||||
f->level = 1;
|
||||
f->hardness = 50.;
|
||||
f->dig_time = 0.4;
|
||||
crafting::set1over1Recipe(CONTENT_ROCK,CONTENT_CRAFTITEM_STICK,i);
|
||||
|
@ -304,6 +305,7 @@ void content_toolitem_init()
|
|||
f->name = "STShovel";
|
||||
f->description = wgettext("Stone Shovel");
|
||||
f->type = TT_SHOVEL;
|
||||
f->level = 1;
|
||||
f->hardness = 150.;
|
||||
f->dig_time = 0.2;
|
||||
crafting::setShovelRecipe(CONTENT_ROUGHSTONE,CONTENT_TOOLITEM_STSHOVEL);
|
||||
|
@ -345,6 +347,7 @@ void content_toolitem_init()
|
|||
f->name = "WAxe";
|
||||
f->description = wgettext("Small Stone Axe");
|
||||
f->type = TT_AXE;
|
||||
f->level = 1;
|
||||
f->hardness = 30.;
|
||||
f->dig_time = 1.5;
|
||||
{
|
||||
|
@ -365,6 +368,7 @@ void content_toolitem_init()
|
|||
f->name = "STAxe";
|
||||
f->description = wgettext("Stone Axe");
|
||||
f->type = TT_AXE;
|
||||
f->level = 1;
|
||||
f->hardness = 100.;
|
||||
f->dig_time = 0.75;
|
||||
crafting::setAxeRecipe(CONTENT_ROUGHSTONE,CONTENT_TOOLITEM_STAXE);
|
||||
|
@ -408,6 +412,7 @@ void content_toolitem_init()
|
|||
f->type = TT_CLUB;
|
||||
f->hardness = 120.;
|
||||
f->dig_time = 1.5;
|
||||
f->level = 1;
|
||||
crafting::setCol1Recipe(CONTENT_CRAFTITEM_WOOD_PLANK,i);
|
||||
crafting::setCol1Recipe(CONTENT_CRAFTITEM_JUNGLE_PLANK,i);
|
||||
lists::add("craftguide",i);
|
||||
|
@ -422,6 +427,7 @@ void content_toolitem_init()
|
|||
f->type = TT_SWORD;
|
||||
f->hardness = 300.;
|
||||
f->dig_time = 1.0;
|
||||
f->level = 1;
|
||||
crafting::setSwordRecipe(CONTENT_ROUGHSTONE,CONTENT_TOOLITEM_STSWORD);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -478,6 +484,7 @@ void content_toolitem_init()
|
|||
f->type = TT_BUCKET;
|
||||
f->hardness = 30.;
|
||||
f->dig_time = 0.0;
|
||||
f->level = 1;
|
||||
f->damaging_nodes_diggable = false;
|
||||
crafting::setURecipe(CONTENT_CRAFTITEM_JUNGLE_PLANK,CONTENT_TOOLITEM_WBUCKET);
|
||||
crafting::setURecipe(CONTENT_CRAFTITEM_WOOD_PLANK,CONTENT_TOOLITEM_WBUCKET);
|
||||
|
@ -568,6 +575,7 @@ void content_toolitem_init()
|
|||
f->description = wgettext("Fire Starter");
|
||||
f->liquids_pointable = true;
|
||||
f->type = TT_SPECIAL;
|
||||
f->level = 3;
|
||||
f->has_fire_effect = true;
|
||||
crafting::set1Any2Recipe(CONTENT_CRAFTITEM_FLINT,CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_FIRESTARTER);
|
||||
lists::add("craftguide",i);
|
||||
|
@ -580,6 +588,7 @@ void content_toolitem_init()
|
|||
f->name = "crowbar";
|
||||
f->description = wgettext("Crowbar");
|
||||
f->type = TT_SPECIAL;
|
||||
f->level = 3;
|
||||
f->has_rotate_effect = true;
|
||||
crafting::set1over1Recipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_CROWBAR);
|
||||
lists::add("craftguide",i);
|
||||
|
@ -592,6 +601,7 @@ void content_toolitem_init()
|
|||
f->name = "key";
|
||||
f->description = wgettext("Key");
|
||||
f->type = TT_SPECIAL;
|
||||
f->level = 4;
|
||||
f->has_unlock_effect = true;
|
||||
crafting::set1To1Recipe(CONTENT_CRAFTITEM_GOLD_INGOT,CONTENT_TOOLITEM_KEY);
|
||||
lists::add("craftguide",i);
|
||||
|
@ -603,6 +613,7 @@ void content_toolitem_init()
|
|||
f->name = "stone_spear";
|
||||
f->description = wgettext("Stone Spear");
|
||||
f->type = TT_SPEAR;
|
||||
f->level = 1;
|
||||
f->hardness = 100.;
|
||||
f->dig_time = 1.5;
|
||||
crafting::setSpearRecipe(CONTENT_ROUGHSTONE,CONTENT_TOOLITEM_STONESPEAR);
|
||||
|
@ -644,6 +655,7 @@ void content_toolitem_init()
|
|||
f->name = "bow";
|
||||
f->description = wgettext("Bow");
|
||||
f->type = TT_SPECIAL;
|
||||
f->level = 2;
|
||||
f->thrown_item = CONTENT_CRAFTITEM_ARROW;
|
||||
{
|
||||
content_t r[9] = {
|
||||
|
@ -874,6 +886,7 @@ void content_toolitem_init()
|
|||
f->name = "mob_spawner";
|
||||
f->description = wgettext("Mob Spawner");
|
||||
f->type = TT_SPECIAL;
|
||||
f->level = 4;
|
||||
f->param_type = CPT_DROP;
|
||||
{
|
||||
content_t r[9] = {
|
||||
|
|
|
@ -80,7 +80,7 @@ struct ToolItemFeatures {
|
|||
type(TT_NONE),
|
||||
hardness(0.),
|
||||
dig_time(3.),
|
||||
level(1),
|
||||
level(0),
|
||||
param_type(CPT_NONE),
|
||||
thrown_item(CONTENT_IGNORE),
|
||||
onplace_replace_item(CONTENT_IGNORE),
|
||||
|
|
|
@ -375,6 +375,10 @@ struct ContentFeatures
|
|||
// Extra dug item and its rarity
|
||||
std::string extra_dug_item;
|
||||
s32 extra_dug_item_rarity;
|
||||
// the minimum tool level required to get the extra dug item
|
||||
u8 extra_dug_item_min_level;
|
||||
// the maximum tool level required to get the extra dug item
|
||||
u8 extra_dug_item_max_level;
|
||||
|
||||
// when dug, this node will replace the dug node
|
||||
content_t ondig_replace_node;
|
||||
|
@ -540,6 +544,8 @@ struct ContentFeatures
|
|||
dug_item = "";
|
||||
extra_dug_item = "";
|
||||
extra_dug_item_rarity = 2;
|
||||
extra_dug_item_min_level = 0;
|
||||
extra_dug_item_max_level = 100;
|
||||
ondig_replace_node = CONTENT_IGNORE;
|
||||
ondig_replace_node_requires = CONTENT_IGNORE;
|
||||
ondig_special_drop = CONTENT_IGNORE;
|
||||
|
|
|
@ -3503,7 +3503,13 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
if (item == NULL) {
|
||||
std::string &extra_dug_s = selected_node_features.extra_dug_item;
|
||||
s32 extra_rarity = selected_node_features.extra_dug_item_rarity;
|
||||
if (extra_dug_s != "" && extra_rarity != 0 && myrand() % extra_rarity == 0) {
|
||||
if (
|
||||
extra_dug_s != ""
|
||||
&& extra_rarity != 0
|
||||
&& selected_node_features.extra_dug_item_min_level <= wielded_tool_features.level
|
||||
&& selected_node_features.extra_dug_item_max_level >= wielded_tool_features.level
|
||||
&& myrand_range(0,extra_rarity) == 0
|
||||
) {
|
||||
std::istringstream is(extra_dug_s, std::ios::binary);
|
||||
item = InventoryItem::deSerialize(is);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue