add spear tools
This commit is contained in:
parent
21486a09d5
commit
d132db6606
Binary file not shown.
After Width: | Height: | Size: 319 B |
Binary file not shown.
After Width: | Height: | Size: 320 B |
Binary file not shown.
After Width: | Height: | Size: 326 B |
|
@ -452,6 +452,16 @@ void setShovelRecipe(u16 input, u16 result)
|
|||
};
|
||||
setRecipe(r2,result,1);
|
||||
}
|
||||
// spear recipe, input is blade yields one result
|
||||
void setSpearRecipe(u16 input, u16 result)
|
||||
{
|
||||
u16 r[9] = {
|
||||
CONTENT_IGNORE, input, CONTENT_IGNORE,
|
||||
CONTENT_IGNORE, CONTENT_CRAFTITEM_STICK, CONTENT_IGNORE,
|
||||
CONTENT_IGNORE, CONTENT_CRAFTITEM_STICK, CONTENT_IGNORE
|
||||
};
|
||||
setRecipe(r,result,1);
|
||||
}
|
||||
// axe recipe, input is blade yields one result
|
||||
void setAxeRecipe(u16 input, u16 result)
|
||||
{
|
||||
|
|
|
@ -236,6 +236,8 @@ namespace crafting {
|
|||
void setSignRecipe(u16 input, u16 result);
|
||||
// shears recipe, input is blade yields one result
|
||||
void setShearsRecipe(u16 input, u16 result);
|
||||
// spear recipe, input is blade yields one result
|
||||
void setSpearRecipe(u16 input, u16 result);
|
||||
// shovel recipe, input is blade yields one result
|
||||
void setShovelRecipe(u16 input, u16 result);
|
||||
// axe recipe, input is blade yields one result
|
||||
|
|
|
@ -100,6 +100,8 @@ void MobFeatures::setAnimationFrames(MobAnimation type, int start, int end)
|
|||
|
||||
bool content_mob_spawn(ServerEnvironment *env, v3s16 pos, u32 active_object_count)
|
||||
{
|
||||
if (active_object_count > 20)
|
||||
return false;
|
||||
assert(env);
|
||||
Map *map = &env->getMap();
|
||||
|
||||
|
@ -344,7 +346,7 @@ void content_mob_init()
|
|||
f->spawn_max_height = 30;
|
||||
f->spawn_min_light = LIGHT_MAX/2;
|
||||
f->spawn_max_nearby_mobs = 3;
|
||||
f->spawn_chance = 150;
|
||||
f->spawn_chance = 1000;
|
||||
f->notices_player = true;
|
||||
f->attack_player_damage = 3;
|
||||
f->attack_player_range = v3f(1,1,1);
|
||||
|
@ -382,8 +384,11 @@ void content_mob_init()
|
|||
f->setTexture("mob_fish.png");
|
||||
f->setAnimationFrames(MA_STAND,1,80);
|
||||
f->setAnimationFrames(MA_MOVE,81,155);
|
||||
f->punch_action = MPA_PICKUP;
|
||||
f->dropped_item = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_FISH)+" 1";
|
||||
f->punch_action = MPA_HARM;
|
||||
f->special_punch_item = TT_SPEAR;
|
||||
f->special_dropped_item = CONTENT_CRAFTITEM_FISH;
|
||||
f->special_dropped_count = 1;
|
||||
f->special_dropped_max = 0;
|
||||
f->motion = MM_WANDER;
|
||||
f->motion_type = MMT_SWIM;
|
||||
f->spawn_on = CONTENT_SAND;
|
||||
|
@ -391,6 +396,7 @@ void content_mob_init()
|
|||
f->spawn_min_height = -30;
|
||||
f->spawn_max_height = -2;
|
||||
f->spawn_max_nearby_mobs = 5;
|
||||
f->hp = 5;
|
||||
f->lifetime = 1200.0;
|
||||
f->setCollisionBox(aabb3f(-0.25*BS, 0.25*BS, -0.25*BS, 0.25*BS, 0.75*BS, 0.25*BS));
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ struct MobFeatures {
|
|||
spawn_min_height = -20000;
|
||||
spawn_max_height = 100;
|
||||
spawn_max_nearby_mobs = 3;
|
||||
spawn_chance = 100;
|
||||
spawn_chance = 500;
|
||||
spawn_nearest_player = 0;
|
||||
spawn_farthest_player = 0;
|
||||
}
|
||||
|
|
|
@ -1126,12 +1126,16 @@ InventoryItem* MobSAO::createPickedUpItem(content_t punch_item)
|
|||
if (m.punch_action != MPA_PICKUP) {
|
||||
if (!m_removed) {
|
||||
if (m.special_dropped_item != CONTENT_IGNORE && (m.special_punch_item == TT_NONE || f.type == m.special_punch_item)) {
|
||||
if (m_special_count < m.special_dropped_count)
|
||||
return NULL;
|
||||
m_special_count -= m.special_dropped_count;
|
||||
if (m_special_count < 0) {
|
||||
m_special_count = 0;
|
||||
return NULL;
|
||||
if (m.special_dropped_max > 0) {
|
||||
if (m_special_count < m.special_dropped_count)
|
||||
return NULL;
|
||||
m_special_count -= m.special_dropped_count;
|
||||
if (m_special_count < 0) {
|
||||
m_special_count = 0;
|
||||
return NULL;
|
||||
}
|
||||
}else{
|
||||
m_removed = true;
|
||||
}
|
||||
if ((m.special_dropped_item&CONTENT_CRAFTITEM_MASK) == CONTENT_CRAFTITEM_MASK) {
|
||||
return new CraftItem(m.special_dropped_item,m.special_dropped_count);
|
||||
|
@ -1158,6 +1162,7 @@ u16 MobSAO::punch(content_t punch_item, v3f dir, const std::string &playername)
|
|||
if (m.punch_action == MPA_IGNORE)
|
||||
return 0;
|
||||
ToolItemFeatures f = content_toolitem_features(punch_item);
|
||||
u16 wear = 655;
|
||||
|
||||
actionstream<<playername<<" punches mob id="<<m_id
|
||||
<<" with a \""<<wide_to_narrow(f.description)<<"\" at "
|
||||
|
@ -1189,10 +1194,11 @@ u16 MobSAO::punch(content_t punch_item, v3f dir, const std::string &playername)
|
|||
|
||||
|
||||
u16 amount = 2;
|
||||
if (f.type == TT_SWORD) {
|
||||
if (f.type == TT_SWORD || f.type == TT_SPEAR) {
|
||||
amount = 4*((f.hardness/100)+1);
|
||||
wear = 65535/f.hardness;
|
||||
}else if (f.type == TT_AXE || f.type == TT_PICK) {
|
||||
amount = 2*((f.hardness/200)+1);
|
||||
amount = ((f.hardness/200)+1);
|
||||
}
|
||||
doDamage(amount);
|
||||
}else if (m.punch_action == MPA_DIE) {
|
||||
|
@ -1200,7 +1206,7 @@ u16 MobSAO::punch(content_t punch_item, v3f dir, const std::string &playername)
|
|||
m_removed = true;
|
||||
}
|
||||
|
||||
return 655;
|
||||
return wear;
|
||||
}
|
||||
bool MobSAO::rightClick(Player *player)
|
||||
{
|
||||
|
@ -1240,7 +1246,7 @@ bool MobSAO::rightClick(Player *player)
|
|||
}
|
||||
}
|
||||
// tame it maybe
|
||||
if (m.level < MOB_AGGRESSIVE || myrand_range(0,m.level*2) == 0)
|
||||
if (m.level < MOB_AGGRESSIVE || myrand_range(0,m.level*5) == 0)
|
||||
return true;
|
||||
|
||||
// add new tamed mob
|
||||
|
|
|
@ -87,6 +87,10 @@ DiggingProperties getDiggingProperties(content_t content, content_t tool)
|
|||
if (c_features.type != CMT_LIQUID)
|
||||
time = 10.;
|
||||
break;
|
||||
case TT_SPEAR:
|
||||
if (c_features.type == CMT_DIRT)
|
||||
time *= 2.0;
|
||||
break;
|
||||
case TT_NONE:
|
||||
if (c_features.type == CMT_DIRT)
|
||||
time *= 0.75;
|
||||
|
@ -458,4 +462,43 @@ void content_toolitem_init()
|
|||
f->type = TT_SPECIAL;
|
||||
crafting::set1To1Recipe(CONTENT_CRAFTITEM_GOLD_INGOT,CONTENT_TOOLITEM_KEY);
|
||||
lists::add("craftguide",i);
|
||||
|
||||
i = CONTENT_TOOLITEM_STONESPEAR;
|
||||
f = &g_content_toolitem_features[i];
|
||||
f->content = i;
|
||||
f->texture = "tool_stonespear.png";
|
||||
f->name = "stone_spear";
|
||||
f->description = wgettext("Stone Spear");
|
||||
f->type = TT_SPEAR;
|
||||
f->hardness = 150.;
|
||||
f->dig_time = 0.2;
|
||||
crafting::setSpearRecipe(CONTENT_ROUGHSTONE,CONTENT_TOOLITEM_STONESPEAR);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
||||
i = CONTENT_TOOLITEM_FLINTSPEAR;
|
||||
f = &g_content_toolitem_features[i];
|
||||
f->content = i;
|
||||
f->texture = "tool_flintspear.png";
|
||||
f->name = "flint_spear";
|
||||
f->description = wgettext("Flint Spear");
|
||||
f->type = TT_SPEAR;
|
||||
f->hardness = 250.;
|
||||
f->dig_time = 0.17;
|
||||
crafting::setSpearRecipe(CONTENT_CRAFTITEM_FLINT,CONTENT_TOOLITEM_FLINTSPEAR);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
||||
i = CONTENT_TOOLITEM_STEELSPEAR;
|
||||
f = &g_content_toolitem_features[i];
|
||||
f->content = i;
|
||||
f->texture = "tool_steelspear.png";
|
||||
f->name = "steel_spear";
|
||||
f->description = wgettext("Steel Spear");
|
||||
f->type = TT_SPEAR;
|
||||
f->hardness = 400.;
|
||||
f->dig_time = 0.15;
|
||||
crafting::setSpearRecipe(CONTENT_CRAFTITEM_STEEL_INGOT,CONTENT_TOOLITEM_STEELSPEAR);
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ enum ToolType {
|
|||
TT_SHOVEL,
|
||||
TT_SHEAR,
|
||||
TT_BUCKET,
|
||||
TT_SWORD
|
||||
TT_SWORD,
|
||||
TT_SPEAR
|
||||
};
|
||||
|
||||
struct ToolItemFeatures {
|
||||
|
@ -110,5 +111,8 @@ ToolItemFeatures & content_toolitem_features(std::string subname);
|
|||
#define CONTENT_TOOLITEM_FLINTAXE (CONTENT_TOOLITEM_MASK | 0x1A)
|
||||
#define CONTENT_TOOLITEM_FLINTSHEARS (CONTENT_TOOLITEM_MASK | 0x1B)
|
||||
#define CONTENT_TOOLITEM_KEY (CONTENT_TOOLITEM_MASK | 0x1C)
|
||||
#define CONTENT_TOOLITEM_STONESPEAR (CONTENT_TOOLITEM_MASK | 0x1D)
|
||||
#define CONTENT_TOOLITEM_FLINTSPEAR (CONTENT_TOOLITEM_MASK | 0x1E)
|
||||
#define CONTENT_TOOLITEM_STEELSPEAR (CONTENT_TOOLITEM_MASK | 0x1F)
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue