add levels to tools, randomise mineral drop quantity with max based on tool level
This commit is contained in:
parent
4ccbb18a73
commit
3acc33215c
|
@ -124,6 +124,7 @@ void content_toolitem_init()
|
|||
f->type = TT_PICK;
|
||||
f->hardness = 30.;
|
||||
f->dig_time = 1.5;
|
||||
f->level = 1;
|
||||
crafting::setPickRecipe(CONTENT_WOOD,CONTENT_TOOLITEM_WPICK);
|
||||
crafting::setPickRecipe(CONTENT_JUNGLEWOOD,CONTENT_TOOLITEM_WPICK);
|
||||
lists::add("craftguide",i);
|
||||
|
@ -138,6 +139,7 @@ void content_toolitem_init()
|
|||
f->type = TT_PICK;
|
||||
f->hardness = 100.;
|
||||
f->dig_time = 0.75;
|
||||
f->level = 2;
|
||||
crafting::setPickRecipe(CONTENT_ROUGHSTONE,CONTENT_TOOLITEM_STPICK);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -151,6 +153,7 @@ void content_toolitem_init()
|
|||
f->type = TT_PICK;
|
||||
f->hardness = 180.;
|
||||
f->dig_time = 1.2;
|
||||
f->level = 2;
|
||||
crafting::setPickRecipe(CONTENT_CRAFTITEM_FLINT,CONTENT_TOOLITEM_FLINTPICK);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -164,6 +167,7 @@ void content_toolitem_init()
|
|||
f->type = TT_PICK;
|
||||
f->hardness = 333.;
|
||||
f->dig_time = 0.5;
|
||||
f->level = 3;
|
||||
crafting::setPickRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_STEELPICK);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -177,6 +181,7 @@ void content_toolitem_init()
|
|||
f->type = TT_PICK;
|
||||
f->hardness = 1337.;
|
||||
f->dig_time = 0.;
|
||||
f->level = 4;
|
||||
f->has_punch_effect = false;
|
||||
crafting::setPickRecipe(CONTENT_MESE,CONTENT_TOOLITEM_MESEPICK);
|
||||
lists::add("craftguide",i);
|
||||
|
@ -219,6 +224,7 @@ void content_toolitem_init()
|
|||
f->type = TT_SHOVEL;
|
||||
f->hardness = 250.;
|
||||
f->dig_time = 0.17;
|
||||
f->level = 2;
|
||||
crafting::setShovelRecipe(CONTENT_CRAFTITEM_FLINT,CONTENT_TOOLITEM_FLINTSHOVEL);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -232,6 +238,7 @@ void content_toolitem_init()
|
|||
f->type = TT_SHOVEL;
|
||||
f->hardness = 400.;
|
||||
f->dig_time = 0.15;
|
||||
f->level = 3;
|
||||
crafting::setShovelRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_STEELSHOVEL);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -272,6 +279,7 @@ void content_toolitem_init()
|
|||
f->type = TT_AXE;
|
||||
f->hardness = 180.;
|
||||
f->dig_time = 0.65;
|
||||
f->level = 2;
|
||||
crafting::setAxeRecipe(CONTENT_CRAFTITEM_FLINT,CONTENT_TOOLITEM_FLINTAXE);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -285,6 +293,7 @@ void content_toolitem_init()
|
|||
f->type = TT_AXE;
|
||||
f->hardness = 333.;
|
||||
f->dig_time = 0.5;
|
||||
f->level = 3;
|
||||
crafting::setAxeRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_STEELAXE);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -325,6 +334,7 @@ void content_toolitem_init()
|
|||
f->type = TT_SWORD;
|
||||
f->hardness = 380.;
|
||||
f->dig_time = 0.5;
|
||||
f->level = 3;
|
||||
crafting::setSwordRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_STEELSWORD);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -351,6 +361,7 @@ void content_toolitem_init()
|
|||
f->type = TT_SHEAR;
|
||||
f->hardness = 333.;
|
||||
f->dig_time = 0.5;
|
||||
f->level = 2;
|
||||
crafting::setShearsRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_STEELSHEARS);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -381,6 +392,7 @@ void content_toolitem_init()
|
|||
f->type = TT_BUCKET;
|
||||
f->hardness = 50.;
|
||||
f->dig_time = 0.0;
|
||||
f->level = 2;
|
||||
f->damaging_nodes_diggable = false;
|
||||
crafting::setURecipe(CONTENT_CRAFTITEM_TIN_INGOT,CONTENT_TOOLITEM_TINBUCKET);
|
||||
lists::add("craftguide",i);
|
||||
|
@ -418,6 +430,7 @@ void content_toolitem_init()
|
|||
f->type = TT_BUCKET;
|
||||
f->hardness = 80.;
|
||||
f->dig_time = 0.0;
|
||||
f->level = 3;
|
||||
crafting::setURecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_STEELBUCKET);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -503,6 +516,7 @@ void content_toolitem_init()
|
|||
f->type = TT_SPEAR;
|
||||
f->hardness = 200.;
|
||||
f->dig_time = 1.0;
|
||||
f->level = 2;
|
||||
crafting::setSpearRecipe(CONTENT_CRAFTITEM_FLINT,CONTENT_TOOLITEM_FLINTSPEAR);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
@ -516,6 +530,7 @@ void content_toolitem_init()
|
|||
f->type = TT_SPEAR;
|
||||
f->hardness = 300.;
|
||||
f->dig_time = 0.5;
|
||||
f->level = 3;
|
||||
crafting::setSpearRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_STEELSPEAR);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
|
|
@ -32,6 +32,35 @@ MineralFeatures & mineral_features(u8 i)
|
|||
return g_mineral_features[i];
|
||||
}
|
||||
|
||||
CraftItem *getDiggedMineralItem(u8 mineral, Player *player, InventoryItem *tool)
|
||||
{
|
||||
MineralFeatures m = mineral_features(mineral);
|
||||
if (m.dug_item == CONTENT_IGNORE)
|
||||
return NULL;
|
||||
|
||||
if (content_craftitem_features(m.dug_item).content == CONTENT_IGNORE)
|
||||
return NULL;
|
||||
|
||||
if (!tool && m.min_level > 0)
|
||||
return NULL;
|
||||
|
||||
ToolItemFeatures *t = &content_toolitem_features(tool->getContent());
|
||||
if (t->content == CONTENT_IGNORE && m.min_level > 0)
|
||||
return NULL;
|
||||
|
||||
if (t->level < m.min_level)
|
||||
return NULL;
|
||||
|
||||
u16 count = m.dug_count_min;
|
||||
if (m.dug_count_min != m.dug_count_max && t->level > count) {
|
||||
count = myrand_range(m.dug_count_min,t->level);
|
||||
if (count > m.dug_count_max)
|
||||
count = m.dug_count_max;
|
||||
}
|
||||
|
||||
return new CraftItem(m.dug_item, count, 0);
|
||||
}
|
||||
|
||||
void init_mineral()
|
||||
{
|
||||
u8 i;
|
||||
|
@ -41,38 +70,41 @@ void init_mineral()
|
|||
f = &mineral_features(i);
|
||||
f->texture = "mineral_coal.png";
|
||||
f->dug_item = CONTENT_CRAFTITEM_COAL;
|
||||
f->dug_count = 2;
|
||||
|
||||
i = MINERAL_IRON;
|
||||
f = &mineral_features(i);
|
||||
f->texture = "mineral_iron.png";
|
||||
f->dug_item = CONTENT_CRAFTITEM_IRON;
|
||||
f->dug_count = 2;
|
||||
f->min_level = 2;
|
||||
|
||||
i = MINERAL_TIN;
|
||||
f = &mineral_features(i);
|
||||
f->texture = "mineral_tin.png";
|
||||
f->dug_item = CONTENT_CRAFTITEM_TIN;
|
||||
f->dug_count = 2;
|
||||
f->min_level = 2;
|
||||
|
||||
i = MINERAL_COPPER;
|
||||
f = &mineral_features(i);
|
||||
f->texture = "mineral_copper.png";
|
||||
f->dug_item = CONTENT_CRAFTITEM_COPPER;
|
||||
f->dug_count = 2;
|
||||
f->dug_count_max = 4;
|
||||
f->min_level = 2;
|
||||
|
||||
i = MINERAL_SILVER;
|
||||
f = &mineral_features(i);
|
||||
f->texture = "mineral_silver.png";
|
||||
f->dug_item = CONTENT_CRAFTITEM_SILVER;
|
||||
f->min_level = 3;
|
||||
|
||||
i = MINERAL_GOLD;
|
||||
f = &mineral_features(i);
|
||||
f->texture = "mineral_gold.png";
|
||||
f->dug_item = CONTENT_CRAFTITEM_GOLD;
|
||||
f->min_level = 3;
|
||||
|
||||
i = MINERAL_QUARTZ;
|
||||
f = &mineral_features(i);
|
||||
f->texture = "mineral_quartz.png";
|
||||
f->dug_item = CONTENT_CRAFTITEM_QUARTZ;
|
||||
f->min_level = 3;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#define MINERAL_HEADER
|
||||
|
||||
#include "inventory.h"
|
||||
#include "player.h"
|
||||
|
||||
#define MINERAL_NONE 0
|
||||
#define MINERAL_COAL 1
|
||||
|
@ -42,12 +43,17 @@ struct MineralFeatures {
|
|||
// the dug item
|
||||
content_t dug_item;
|
||||
// the number of dug_items received when dug
|
||||
s16 dug_count;
|
||||
s16 dug_count_min;
|
||||
s16 dug_count_max;
|
||||
// tools below this level give no mineral
|
||||
u8 min_level;
|
||||
|
||||
MineralFeatures():
|
||||
texture(""),
|
||||
dug_item(CONTENT_IGNORE),
|
||||
dug_count(1)
|
||||
dug_count_min(1),
|
||||
dug_count_max(5),
|
||||
min_level(1)
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -64,14 +70,7 @@ MineralFeatures & mineral_features(u8 i);
|
|||
|
||||
#define MINERAL_MAX 255
|
||||
|
||||
inline CraftItem * getDiggedMineralItem(u8 mineral)
|
||||
{
|
||||
MineralFeatures m = mineral_features(mineral);
|
||||
if (m.dug_item == CONTENT_IGNORE)
|
||||
return NULL;
|
||||
|
||||
return new CraftItem(content_craftitem_features(m.dug_item).name,m.dug_count, 0);
|
||||
}
|
||||
CraftItem *getDiggedMineralItem(u8 mineral, Player *player, InventoryItem *tool);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3495,7 +3495,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
item = NULL;
|
||||
|
||||
if (mineral != MINERAL_NONE)
|
||||
item = getDiggedMineralItem(mineral);
|
||||
item = getDiggedMineralItem(mineral,player,wielditem);
|
||||
|
||||
// If not mineral
|
||||
if (item == NULL) {
|
||||
|
|
Loading…
Reference in New Issue