add sheep - that may or may not be possessed by michael jackson

This commit is contained in:
darkrose 2014-10-11 23:46:16 +10:00
parent 47bb775724
commit 5fe761d1d4
26 changed files with 583 additions and 354 deletions

BIN
data/models/sheep.b3d Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

BIN
data/textures/fur.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

BIN
data/textures/meat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

BIN
data/textures/mob_sheep.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -1,21 +1,28 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
* activeobject.h
* voxelands - 3d voxel world sandbox game
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef ACTIVEOBJECT_HEADER #ifndef ACTIVEOBJECT_HEADER
#define ACTIVEOBJECT_HEADER #define ACTIVEOBJECT_HEADER

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * content_cao.cpp
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#include "content_cao.h" #include "content_cao.h"
#include "content_mob.h" #include "content_mob.h"
@ -354,9 +360,9 @@ void MobCAO::updateNodePos()
v3f rot = m_node->getRotation(); v3f rot = m_node->getRotation();
if (m_draw_type == MDT_MODEL) { if (m_draw_type == MDT_MODEL) {
rot.Y = (90-m_yaw)+content_mob_features(m_content).model_rotation.Y; rot.Y = (90-pos_translator.yaw_show)+content_mob_features(m_content).model_rotation.Y;
}else if (m_draw_type == MDT_SPRITE) { }else if (m_draw_type == MDT_SPRITE) {
rot.Y = m_yaw+content_mob_features(m_content).model_rotation.Y; rot.Y = pos_translator.yaw_show+content_mob_features(m_content).model_rotation.Y;
} }
m_node->setRotation(rot); m_node->setRotation(rot);
} }
@ -439,9 +445,9 @@ void MobCAO::processMessage(const std::string &data)
if (cmd == 0) { if (cmd == 0) {
// pos // pos
m_position = readV3F1000(is); m_position = readV3F1000(is);
pos_translator.update(m_position);
// yaw // yaw
m_yaw = readF1000(is); m_yaw = readF1000(is);
pos_translator.update(m_position,m_yaw);
if (!m_walking) { if (!m_walking) {
m_walking = true; m_walking = true;
@ -521,7 +527,7 @@ bool MobCAO::directReportPunch(const std::string &toolname, v3f dir)
m_position += dir * BS; m_position += dir * BS;
pos_translator.sharpen(); pos_translator.sharpen();
pos_translator.update(m_position); pos_translator.update(m_position,m_yaw);
updateNodePos(); updateNodePos();
return false; return false;

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * content_cao.h
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#ifndef CONTENT_CAO_HEADER #ifndef CONTENT_CAO_HEADER
#define CONTENT_CAO_HEADER #define CONTENT_CAO_HEADER
@ -40,6 +46,9 @@ struct SmoothTranslator
f32 anim_counter; f32 anim_counter;
f32 anim_time; f32 anim_time;
f32 anim_time_counter; f32 anim_time_counter;
f32 yaw_old;
f32 yaw_show;
f32 yaw_aim;
SmoothTranslator(): SmoothTranslator():
vect_old(0,0,0), vect_old(0,0,0),
@ -47,7 +56,10 @@ struct SmoothTranslator
vect_aim(0,0,0), vect_aim(0,0,0),
anim_counter(0), anim_counter(0),
anim_time(0), anim_time(0),
anim_time_counter(0) anim_time_counter(0),
yaw_old(0),
yaw_show(0),
yaw_aim(0)
{} {}
void init(v3f vect) void init(v3f vect)
@ -58,6 +70,9 @@ struct SmoothTranslator
anim_counter = 0; anim_counter = 0;
anim_time = 0; anim_time = 0;
anim_time_counter = 0; anim_time_counter = 0;
yaw_old = 0;
yaw_show = 0;
yaw_aim = 0;
} }
void sharpen() void sharpen()
@ -65,14 +80,17 @@ struct SmoothTranslator
init(vect_show); init(vect_show);
} }
void update(v3f vect_new) void update(v3f vect_new,f32 yaw_new)
{ {
vect_old = vect_show; vect_old = vect_show;
vect_aim = vect_new; vect_aim = vect_new;
if(anim_time < 0.001 || anim_time > 1.0) yaw_old = yaw_show;
yaw_aim = wrapDegrees_0_360(yaw_new);
if (anim_time < 0.001 || anim_time > 1.0) {
anim_time = anim_time_counter; anim_time = anim_time_counter;
else }else{
anim_time = anim_time * 0.9 + anim_time_counter * 0.1; anim_time = anim_time * 0.9 + anim_time_counter * 0.1;
}
anim_time_counter = 0; anim_time_counter = 0;
anim_counter = 0; anim_counter = 0;
} }
@ -82,14 +100,21 @@ struct SmoothTranslator
anim_time_counter = anim_time_counter + dtime; anim_time_counter = anim_time_counter + dtime;
anim_counter = anim_counter + dtime; anim_counter = anim_counter + dtime;
v3f vect_move = vect_aim - vect_old; v3f vect_move = vect_aim - vect_old;
f32 yaw_move = yaw_aim - yaw_old;
if (yaw_move > 200) {
yaw_move -= 180;
}else if (yaw_move < -200) {
yaw_move += 180;
}
f32 moveratio = 1.0; f32 moveratio = 1.0;
if(anim_time > 0.001) if (anim_time > 0.001)
moveratio = anim_time_counter / anim_time; moveratio = anim_time_counter / anim_time;
// Move a bit less than should, to avoid oscillation // Move a bit less than should, to avoid oscillation
moveratio = moveratio * 0.5; moveratio = moveratio * 0.5;
if(moveratio > 1.5) if (moveratio > 1.5)
moveratio = 1.5; moveratio = 1.5;
vect_show = vect_old + vect_move * moveratio; vect_show = vect_old + vect_move * moveratio;
yaw_show = yaw_old + yaw_move * moveratio;
} }
bool is_moving() bool is_moving()

View File

@ -719,4 +719,33 @@ void content_craftitem_init()
lists::add("creative",i); lists::add("creative",i);
lists::add("cooking",i); lists::add("cooking",i);
i = CONTENT_CRAFTITEM_FUR;
f = &g_content_craftitem_features[i];
f->content = CONTENT_CRAFTITEM_FUR;
f->texture = "fur.png";
f->name = "fur";
f->description = wgettext("Fur");
lists::add("creative",i);
i = CONTENT_CRAFTITEM_MEAT;
f = &g_content_craftitem_features[i];
f->content = CONTENT_CRAFTITEM_MEAT;
f->texture = "meat.png";
f->name = "meat";
f->description = wgettext("Meat");
f->cook_result = "CraftItem cooked_meat 1";
lists::add("creative",i);
lists::add("cooking",i);
i = CONTENT_CRAFTITEM_COOKED_MEAT;
f = &g_content_craftitem_features[i];
f->content = CONTENT_CRAFTITEM_COOKED_MEAT;
f->texture = "cooked_meat.png";
f->name = "cooked_meat";
f->description = wgettext("Cooked Meat");
f->cook_result = "CraftItem ash 1";
f->edible = 6;
lists::add("creative",i);
lists::add("cooking",i);
} }

View File

@ -105,5 +105,8 @@ CraftItemFeatures & content_craftitem_features(std::string subname);
#define CONTENT_CRAFTITEM_OERKKI_DUST (CONTENT_CRAFTITEM_MASK | 0x44) #define CONTENT_CRAFTITEM_OERKKI_DUST (CONTENT_CRAFTITEM_MASK | 0x44)
#define CONTENT_CRAFTITEM_FISH (CONTENT_CRAFTITEM_MASK | 0x45) #define CONTENT_CRAFTITEM_FISH (CONTENT_CRAFTITEM_MASK | 0x45)
#define CONTENT_CRAFTITEM_COOKED_FISH (CONTENT_CRAFTITEM_MASK | 0x46) #define CONTENT_CRAFTITEM_COOKED_FISH (CONTENT_CRAFTITEM_MASK | 0x46)
#define CONTENT_CRAFTITEM_FUR (CONTENT_CRAFTITEM_MASK | 0x47)
#define CONTENT_CRAFTITEM_MEAT (CONTENT_CRAFTITEM_MASK | 0x48)
#define CONTENT_CRAFTITEM_COOKED_MEAT (CONTENT_CRAFTITEM_MASK | 0x49)
#endif #endif

View File

@ -22,6 +22,7 @@
#include "serverobject.h" #include "serverobject.h"
#include "content_sao.h" #include "content_sao.h"
#include "content_mob.h" #include "content_mob.h"
#include "content_craftitem.h"
#include "main.h" #include "main.h"
#include "settings.h" #include "settings.h"
#include "environment.h" #include "environment.h"
@ -111,6 +112,12 @@ bool content_mob_spawn(ServerEnvironment *env, v3s16 pos, u32 active_object_coun
content_t c2 = a2.getContent(); content_t c2 = a2.getContent();
u8 light = a1.getLightBlend(env->getDayNightRatio()); u8 light = a1.getLightBlend(env->getDayNightRatio());
u8 level = mobLevelI(g_settings->get("max_mob_level")); u8 level = mobLevelI(g_settings->get("max_mob_level"));
v3f pf = intToFloat(pos,BS);
Player *nearest = env->getNearestConnectedPlayer(pf);
f32 distance = 30000.0;
if (nearest)
distance = pf.getDistanceFrom(nearest->getPosition());
if (c0 == CONTENT_IGNORE || c1 == CONTENT_IGNORE || c2 == CONTENT_IGNORE) if (c0 == CONTENT_IGNORE || c1 == CONTENT_IGNORE || c2 == CONTENT_IGNORE)
return false; return false;
@ -121,6 +128,12 @@ bool content_mob_spawn(ServerEnvironment *env, v3s16 pos, u32 active_object_coun
continue; continue;
if (m.spawn_max_nearby_mobs < active_object_count) if (m.spawn_max_nearby_mobs < active_object_count)
continue; continue;
if (m.spawn_nearest_player != m.spawn_farthest_player) {
if (m.spawn_nearest_player > distance)
continue;
if (m.spawn_farthest_player < distance)
continue;
}
if (m.spawn_min_height > pos.Y) if (m.spawn_min_height > pos.Y)
continue; continue;
if (m.spawn_max_height < pos.Y) if (m.spawn_max_height < pos.Y)
@ -200,7 +213,6 @@ void content_mob_init()
f = &g_content_mob_features[i]; f = &g_content_mob_features[i];
f->content = i; f->content = i;
f->level = MOB_PASSIVE; f->level = MOB_PASSIVE;
//f->model = "rat.x";
f->model_scale = v3f(0.5,0.5,0.5); f->model_scale = v3f(0.5,0.5,0.5);
f->setTexture("mob_firefly.png"); f->setTexture("mob_firefly.png");
f->punch_action = MPA_PICKUP; f->punch_action = MPA_PICKUP;
@ -227,6 +239,7 @@ void content_mob_init()
f->setAnimationFrames(MA_STAND,24,36); f->setAnimationFrames(MA_STAND,24,36);
f->setAnimationFrames(MA_ATTACK,37,49); f->setAnimationFrames(MA_ATTACK,37,49);
f->punch_action = MPA_HARM; f->punch_action = MPA_HARM;
f->dropped_item = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_OERKKI_DUST)+" 2";
f->motion = MM_SEEKER; f->motion = MM_SEEKER;
f->spawn_on = CONTENT_STONE; f->spawn_on = CONTENT_STONE;
f->spawn_in = CONTENT_AIR; f->spawn_in = CONTENT_AIR;
@ -251,11 +264,13 @@ void content_mob_init()
f->setAnimationFrames(MA_MOVE,31,60); f->setAnimationFrames(MA_MOVE,31,60);
f->setAnimationFrames(MA_ATTACK,61,90); f->setAnimationFrames(MA_ATTACK,61,90);
f->punch_action = MPA_HARM; f->punch_action = MPA_HARM;
f->dropped_item = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_GUNPOWDER)+" 4";
f->motion = MM_SENTRY; f->motion = MM_SENTRY;
f->spawn_on = CONTENT_STONE; f->spawn_on = CONTENT_STONE;
f->spawn_in = CONTENT_AIR; f->spawn_in = CONTENT_AIR;
f->spawn_max_light = LIGHT_MAX/3; f->spawn_max_light = LIGHT_MAX/3;
f->spawn_max_nearby_mobs = 1; f->spawn_max_nearby_mobs = 1;
f->spawn_farthest_player = 20.0*BS;
f->notices_player = true; f->notices_player = true;
f->attack_throw_object = CONTENT_MOB_FIREBALL; f->attack_throw_object = CONTENT_MOB_FIREBALL;
f->attack_glow_light = LIGHT_MAX-1; f->attack_glow_light = LIGHT_MAX-1;
@ -267,7 +282,6 @@ void content_mob_init()
f = &g_content_mob_features[i]; f = &g_content_mob_features[i];
f->content = i; f->content = i;
f->level = MOB_DESTRUCTIVE; f->level = MOB_DESTRUCTIVE;
//f->model = "rat.x";
f->setTexture("mob_fireball.png"); f->setTexture("mob_fireball.png");
f->punch_action = MPA_IGNORE; f->punch_action = MPA_IGNORE;
f->motion = MM_CONSTANT; f->motion = MM_CONSTANT;
@ -293,6 +307,7 @@ void content_mob_init()
f->setAnimationFrames(MA_MOVE,0,60); f->setAnimationFrames(MA_MOVE,0,60);
f->setAnimationFrames(MA_ATTACK,0,60); f->setAnimationFrames(MA_ATTACK,0,60);
f->punch_action = MPA_HARM; f->punch_action = MPA_HARM;
f->dropped_item = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_FUR)+" 2";
f->motion = MM_SEEKER; f->motion = MM_SEEKER;
f->motion_type = MMT_WALK; f->motion_type = MMT_WALK;
f->spawn_on = CONTENT_WILDGRASS_SHORT; f->spawn_on = CONTENT_WILDGRASS_SHORT;
@ -318,6 +333,7 @@ void content_mob_init()
f->setAnimationFrames(MA_MOVE,0,60); f->setAnimationFrames(MA_MOVE,0,60);
f->setAnimationFrames(MA_ATTACK,0,60); f->setAnimationFrames(MA_ATTACK,0,60);
f->punch_action = MPA_HARM; f->punch_action = MPA_HARM;
f->dropped_item = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_MEAT)+" 2";
f->motion = MM_WANDER; f->motion = MM_WANDER;
f->motion_type = MMT_WALK; f->motion_type = MMT_WALK;
f->angry_motion = MM_SEEKER; f->angry_motion = MM_SEEKER;
@ -370,6 +386,7 @@ void content_mob_init()
f->setAnimationFrames(MA_MOVE,80,160); f->setAnimationFrames(MA_MOVE,80,160);
f->setAnimationFrames(MA_ATTACK,80,160); f->setAnimationFrames(MA_ATTACK,80,160);
f->punch_action = MPA_HARM; f->punch_action = MPA_HARM;
f->dropped_item = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_MEAT)+" 2";
f->motion = MM_SEEKER; f->motion = MM_SEEKER;
f->motion_type = MMT_SWIM; f->motion_type = MMT_SWIM;
f->spawn_on = CONTENT_SAND; f->spawn_on = CONTENT_SAND;
@ -413,5 +430,29 @@ void content_mob_init()
i = CONTENT_MOB_SHEEP; i = CONTENT_MOB_SHEEP;
f = &g_content_mob_features[i]; f = &g_content_mob_features[i];
//f->content = i; f->content = i;
f->level = MOB_PASSIVE;
f->hp = 30;
f->model = "sheep.b3d";
f->model_scale = v3f(0.8,0.8,0.8);
f->model_rotation = v3f(0,-90,0);
f->model_offset = v3f(0,0.6,0);
f->setTexture("mob_sheep.png");
f->setAnimationFrames(MA_STAND,61,120);
f->setAnimationFrames(MA_MOVE,0,60);
f->setAnimationFrames(MA_ATTACK,0,60);
f->punch_action = MPA_HARM;
f->dropped_item = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_MEAT)+" 2";
f->special_punch_item = TT_SHEAR;
f->special_dropped_item = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_STRING)+" 4";
f->motion = MM_SEEKER;
f->motion_type = MMT_WALK;
f->spawn_on = CONTENT_WILDGRASS_SHORT;
f->spawn_in = CONTENT_AIR;
f->spawn_min_height = 2;
f->spawn_max_height = 20;
f->spawn_min_light = LIGHT_MAX/2;
f->spawn_max_nearby_mobs = 3;
f->lifetime = 900.0;
f->setCollisionBox(aabb3f(-0.4*BS, 0., -0.4*BS, 0.4*BS, 1.*BS, 0.4*BS));
} }

View File

@ -24,6 +24,7 @@
#include "mapnode.h" #include "mapnode.h"
#include "serverobject.h" #include "serverobject.h"
#include "content_toolitem.h"
#ifndef SERVER #ifndef SERVER
#include "common_irrlicht.h" #include "common_irrlicht.h"
#endif #endif
@ -105,6 +106,8 @@ struct MobFeatures {
MobMotionType motion_type; MobMotionType motion_type;
MobMotion angry_motion; MobMotion angry_motion;
bool is_tamable; bool is_tamable;
content_t hunted_node;
content_t fleed_node;
bool notices_player; bool notices_player;
content_t tamed_mob; content_t tamed_mob;
content_t attack_throw_object; content_t attack_throw_object;
@ -115,6 +118,8 @@ struct MobFeatures {
u8 attack_glow_light; u8 attack_glow_light;
u16 hp; u16 hp;
std::string dropped_item; std::string dropped_item;
ToolType special_punch_item;
std::string special_dropped_item;
f32 lifetime; f32 lifetime;
u16 contact_explosion_diameter; u16 contact_explosion_diameter;
@ -126,6 +131,8 @@ struct MobFeatures {
s16 spawn_max_height; s16 spawn_max_height;
u8 spawn_max_nearby_mobs; u8 spawn_max_nearby_mobs;
s16 spawn_chance; s16 spawn_chance;
s16 spawn_nearest_player;
s16 spawn_farthest_player;
MobFeatures() MobFeatures()
{ {
@ -214,6 +221,8 @@ struct MobFeatures {
motion_type = MMT_WALK; motion_type = MMT_WALK;
angry_motion = MM_STATIC; angry_motion = MM_STATIC;
is_tamable = false; is_tamable = false;
hunted_node = CONTENT_IGNORE;
fleed_node = CONTENT_IGNORE;
notices_player = false; notices_player = false;
tamed_mob = CONTENT_IGNORE; tamed_mob = CONTENT_IGNORE;
attack_throw_object = CONTENT_IGNORE; attack_throw_object = CONTENT_IGNORE;
@ -224,6 +233,8 @@ struct MobFeatures {
attack_glow_light = 0; attack_glow_light = 0;
hp = 20; hp = 20;
dropped_item = ""; dropped_item = "";
special_punch_item = TT_NONE;
special_dropped_item = "";
lifetime = 0.0; lifetime = 0.0;
contact_explosion_diameter = 0; contact_explosion_diameter = 0;
spawn_on = CONTENT_IGNORE; spawn_on = CONTENT_IGNORE;
@ -234,6 +245,8 @@ struct MobFeatures {
spawn_max_height = 100; spawn_max_height = 100;
spawn_max_nearby_mobs = 3; spawn_max_nearby_mobs = 3;
spawn_chance = 100; spawn_chance = 100;
spawn_nearest_player = 0;
spawn_farthest_player = 0;
} }
}; };

View File

@ -1,21 +1,28 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
* content_object.h
* voxelands - 3d voxel world sandbox game
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef CONTENT_OBJECT_HEADER #ifndef CONTENT_OBJECT_HEADER
#define CONTENT_OBJECT_HEADER #define CONTENT_OBJECT_HEADER

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * content_sao.cpp
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#include "content_sao.h" #include "content_sao.h"
#include "content_mob.h" #include "content_mob.h"
@ -473,10 +479,7 @@ void MobSAO::step(float dtime, bool send_recommended)
if (m_next_pos_exists) { if (m_next_pos_exists) {
v3f pos_f = m_base_position; v3f pos_f = m_base_position;
v3f next_pos_f = intToFloat(m_next_pos_i, BS); v3f next_pos_f = intToFloat(m_next_pos_i, BS);
v3f v = next_pos_f - pos_f; v3f v = next_pos_f - pos_f;
m_yaw = atan2(v.Z, v.X) / PI * 180;
v3f diff = next_pos_f - pos_f; v3f diff = next_pos_f - pos_f;
v3f dir = diff; v3f dir = diff;
dir.normalize(); dir.normalize();
@ -485,6 +488,7 @@ void MobSAO::step(float dtime, bool send_recommended)
speed = BS * 2.0; speed = BS * 2.0;
if (m_falling) if (m_falling)
speed = BS * 3.0; speed = BS * 3.0;
dir *= dtime * speed; dir *= dtime * speed;
bool arrived = false; bool arrived = false;
if (dir.getLength() > diff.getLength()) { if (dir.getLength() > diff.getLength()) {
@ -492,6 +496,7 @@ void MobSAO::step(float dtime, bool send_recommended)
arrived = true; arrived = true;
} }
pos_f += dir; pos_f += dir;
m_yaw = wrapDegrees_180(180./PI*atan2(dir.Z, dir.X));
m_base_position = pos_f; m_base_position = pos_f;
if ((pos_f - next_pos_f).getLength() < 0.1 || arrived) if ((pos_f - next_pos_f).getLength() < 0.1 || arrived)
@ -556,8 +561,11 @@ void MobSAO::stepMotionWander(float dtime)
} }
u32 order[3*3*3]; u32 order[3*3*3];
get_random_u32_array(order, num_dps); get_random_u32_array(order, num_dps);
v3s16 op = floatToInt(m_oldpos,BS);
for (int i=0; i<num_dps; i++) { for (int i=0; i<num_dps; i++) {
v3s16 p = dps[order[i]] + pos_i; v3s16 p = dps[order[i]] + pos_i;
if (p == op)
continue;
if (!checkFreeAndWalkablePosition(p + pos_size_off)) if (!checkFreeAndWalkablePosition(p + pos_size_off))
continue; continue;
m_next_pos_i = p; m_next_pos_i = p;
@ -610,8 +618,11 @@ void MobSAO::stepMotionWander(float dtime)
} }
u32 order[3*3*3]; u32 order[3*3*3];
get_random_u32_array(order, num_dps); get_random_u32_array(order, num_dps);
v3s16 op = floatToInt(m_oldpos,BS);
for (int i=0; i<num_dps; i++) { for (int i=0; i<num_dps; i++) {
v3s16 p = dps[order[i]] + pos_i; v3s16 p = dps[order[i]] + pos_i;
if (p == op)
continue;
if (!checkFreePosition(p + pos_size_off)) if (!checkFreePosition(p + pos_size_off))
continue; continue;
m_next_pos_i = p; m_next_pos_i = p;
@ -664,8 +675,11 @@ void MobSAO::stepMotionWander(float dtime)
} }
u32 order[3*3*3]; u32 order[3*3*3];
get_random_u32_array(order, num_dps); get_random_u32_array(order, num_dps);
v3s16 op = floatToInt(m_oldpos,BS);
for (int i=0; i<num_dps; i++) { for (int i=0; i<num_dps; i++) {
v3s16 p = dps[order[i]] + pos_i; v3s16 p = dps[order[i]] + pos_i;
if (p == op)
continue;
if (!checkFreePosition(p + pos_size_off)) if (!checkFreePosition(p + pos_size_off))
continue; continue;
m_next_pos_i = p; m_next_pos_i = p;
@ -716,8 +730,11 @@ void MobSAO::stepMotionSeeker(float dtime)
} }
u32 order[3*3*3]; u32 order[3*3*3];
get_random_u32_array(order, num_dps); get_random_u32_array(order, num_dps);
v3s16 op = floatToInt(m_oldpos,BS);
for (int i=0; i<num_dps; i++) { for (int i=0; i<num_dps; i++) {
v3s16 p = dps[order[i]] + pos_i; v3s16 p = dps[order[i]] + pos_i;
if (p == op)
continue;
if (!checkFreeAndWalkablePosition(p)) if (!checkFreeAndWalkablePosition(p))
continue; continue;
m_next_pos_i = p; m_next_pos_i = p;
@ -772,8 +789,11 @@ void MobSAO::stepMotionSeeker(float dtime)
} }
u32 order[3*3*3]; u32 order[3*3*3];
get_random_u32_array(order, num_dps); get_random_u32_array(order, num_dps);
v3s16 op = floatToInt(m_oldpos,BS);
for (int i=0; i<num_dps; i++) { for (int i=0; i<num_dps; i++) {
v3s16 p = dps[order[i]] + pos_i; v3s16 p = dps[order[i]] + pos_i;
if (p == op)
continue;
if (!checkFreePosition(p)) if (!checkFreePosition(p))
continue; continue;
m_next_pos_i = p; m_next_pos_i = p;
@ -828,8 +848,11 @@ void MobSAO::stepMotionSeeker(float dtime)
} }
u32 order[3*3*3]; u32 order[3*3*3];
get_random_u32_array(order, num_dps); get_random_u32_array(order, num_dps);
v3s16 op = floatToInt(m_oldpos,BS);
for (int i=0; i<num_dps; i++) { for (int i=0; i<num_dps; i++) {
v3s16 p = dps[order[i]] + pos_i; v3s16 p = dps[order[i]] + pos_i;
if (p == op)
continue;
if (!checkFreePosition(p)) if (!checkFreePosition(p))
continue; continue;
m_next_pos_i = p; m_next_pos_i = p;
@ -1083,12 +1106,19 @@ void MobSAO::explodeSquare(v3s16 p0, v3s16 size)
} }
map->dispatchEvent(&event); map->dispatchEvent(&event);
} }
InventoryItem* MobSAO::createPickedUpItem() InventoryItem* MobSAO::createPickedUpItem(content_t punch_item)
{ {
MobFeatures m = content_mob_features(m_content); MobFeatures m = content_mob_features(m_content);
ToolItemFeatures f = content_toolitem_features(punch_item);
if (m.punch_action != MPA_PICKUP) { if (m.punch_action != MPA_PICKUP) {
if (!m_removed) if (!m_removed) {
if (m.special_dropped_item != "" && (m.special_punch_item == TT_NONE || f.type == m.special_punch_item)) {
std::istringstream is(m.special_dropped_item, std::ios_base::binary);
InventoryItem *item = InventoryItem::deSerialize(is);
return item;
}
return NULL; return NULL;
}
} }
if (m.dropped_item == "") if (m.dropped_item == "")
return NULL; return NULL;
@ -1098,14 +1128,15 @@ InventoryItem* MobSAO::createPickedUpItem()
m_removed = true; m_removed = true;
return item; return item;
} }
u16 MobSAO::punch(const std::string &toolname, v3f dir, const std::string &playername) u16 MobSAO::punch(content_t punch_item, v3f dir, const std::string &playername)
{ {
MobFeatures m = content_mob_features(m_content); MobFeatures m = content_mob_features(m_content);
if (m.punch_action == MPA_IGNORE) if (m.punch_action == MPA_IGNORE)
return 0; return 0;
ToolItemFeatures f = content_toolitem_features(punch_item);
actionstream<<playername<<" punches mob id="<<m_id actionstream<<playername<<" punches mob id="<<m_id
<<" with a \""<<toolname<<"\" at " <<" with a \""<<wide_to_narrow(f.description)<<"\" at "
<<PP(m_base_position/BS)<<std::endl; <<PP(m_base_position/BS)<<std::endl;
if (m.punch_action == MPA_HARM) { if (m.punch_action == MPA_HARM) {
@ -1130,7 +1161,6 @@ u16 MobSAO::punch(const std::string &toolname, v3f dir, const std::string &playe
sendPosition(); sendPosition();
ToolItemFeatures f = content_toolitem_features(toolname);
u16 amount = 2; u16 amount = 2;
if (f.type == TT_SWORD) { if (f.type == TT_SWORD) {
amount = 4*((f.hardness/100)+1); amount = 4*((f.hardness/100)+1);

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * content_sao.h
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#ifndef CONTENT_SAO_HEADER #ifndef CONTENT_SAO_HEADER
#define CONTENT_SAO_HEADER #define CONTENT_SAO_HEADER
@ -38,7 +44,7 @@ public:
std::string getClientInitializationData(); std::string getClientInitializationData();
std::string getStaticData(); std::string getStaticData();
InventoryItem* createInventoryItem(); InventoryItem* createInventoryItem();
InventoryItem* createPickedUpItem(){return createInventoryItem();} InventoryItem* createPickedUpItem(content_t punch_item){return createInventoryItem();}
void rightClick(Player *player); void rightClick(Player *player);
private: private:
std::string m_inventorystring; std::string m_inventorystring;
@ -60,8 +66,8 @@ public:
std::string getStaticData(); std::string getStaticData();
std::string getClientInitializationData(); std::string getClientInitializationData();
void step(float dtime, bool send_recommended); void step(float dtime, bool send_recommended);
InventoryItem* createPickedUpItem(); InventoryItem* createPickedUpItem(content_t punch_item);
u16 punch(const std::string &toolname, v3f dir, const std::string &playername); u16 punch(content_t punch_item, v3f dir, const std::string &playername);
u8 level(); u8 level();
private: private:
void sendPosition(); void sendPosition();

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * environment.cpp
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#include "environment.h" #include "environment.h"
#include "filesys.h" #include "filesys.h"

View File

@ -1,21 +1,28 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
* environment.h
* voxelands - 3d voxel world sandbox game
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef ENVIRONMENT_HEADER #ifndef ENVIRONMENT_HEADER
#define ENVIRONMENT_HEADER #define ENVIRONMENT_HEADER

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * game.cpp
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#include "game.h" #include "game.h"
#include "common_irrlicht.h" #include "common_irrlicht.h"

View File

@ -1,25 +1,28 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
* inventory.cpp
* voxelands - 3d voxel world sandbox game
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
(c) 2010 Perttu Ahola <celeron55@gmail.com>
*/
#include "inventory.h" #include "inventory.h"
#include "serialization.h" #include "serialization.h"

View File

@ -1,25 +1,28 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
* inventory.h
* voxelands - 3d voxel world sandbox game
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
(c) 2010 Perttu Ahola <celeron55@gmail.com>
*/
#ifndef INVENTORY_HEADER #ifndef INVENTORY_HEADER
#define INVENTORY_HEADER #define INVENTORY_HEADER

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * mapblock.cpp
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#include "mapblock.h" #include "mapblock.h"
#include "map.h" #include "map.h"

View File

@ -1,21 +1,28 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
* mapblock.h
* voxelands - 3d voxel world sandbox game
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MAPBLOCK_HEADER #ifndef MAPBLOCK_HEADER
#define MAPBLOCK_HEADER #define MAPBLOCK_HEADER

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * mapnode.h
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#ifndef MAPNODE_HEADER #ifndef MAPNODE_HEADER
#define MAPNODE_HEADER #define MAPNODE_HEADER

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * server.cpp
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#include "server.h" #include "server.h"
#include "utility.h" #include "utility.h"
@ -30,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "config.h" #include "config.h"
#include "servercommand.h" #include "servercommand.h"
#include "filesys.h" #include "filesys.h"
#include "content_object.h"
#include "content_mapnode.h" #include "content_mapnode.h"
#include "content_craft.h" #include "content_craft.h"
#include "content_craftitem.h" #include "content_craftitem.h"
@ -2291,10 +2298,22 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
// Left click, pick object up (usually) // Left click, pick object up (usually)
if(button == 0) if(button == 0)
{ {
content_t wield_item = CONTENT_IGNORE;
ToolItem *titem = NULL;
InventoryList *mlist = player->inventory.getList("main");
if (mlist != NULL) {
InventoryItem *item = mlist->getItem(item_i);
if (item) {
wield_item = item->getContent();
if ((wield_item&CONTENT_TOOLITEM_MASK) == CONTENT_TOOLITEM_MASK)
titem = (ToolItem*)item;
}
}
/* /*
Try creating inventory item Try creating inventory item
*/ */
InventoryItem *item = obj->createPickedUpItem(); InventoryItem *item = obj->createPickedUpItem(wield_item);
if (item) { if (item) {
InventoryList *ilist = player->inventory.getList("main"); InventoryList *ilist = player->inventory.getList("main");
@ -2315,7 +2334,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
} }
// Remove object from environment // Remove object from environment
obj->m_removed = true; if (obj->getType() != ACTIVEOBJECT_TYPE_MOB)
obj->m_removed = true;
} }
}else{ }else{
/* /*
@ -2325,24 +2345,12 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
actionstream<<player->getName()<<" punches object " actionstream<<player->getName()<<" punches object "
<<obj->getId()<<std::endl; <<obj->getId()<<std::endl;
ToolItem *titem = NULL;
std::string toolname = "";
InventoryList *mlist = player->inventory.getList("main");
if (mlist != NULL) {
InventoryItem *item = mlist->getItem(item_i);
if (item && (std::string)item->getName() == "ToolItem") {
titem = (ToolItem*)item;
toolname = titem->getToolName();
}
}
v3f playerpos = player->getPosition(); v3f playerpos = player->getPosition();
v3f objpos = obj->getBasePosition(); v3f objpos = obj->getBasePosition();
v3f dir = (objpos - playerpos).normalize(); v3f dir = (objpos - playerpos).normalize();
u16 wear = obj->punch(toolname, dir, player->getName()); u16 wear = obj->punch(wield_item, dir, player->getName());
item = obj->createPickedUpItem(); item = obj->createPickedUpItem(wield_item);
/* killing something might have caused a drop */ /* killing something might have caused a drop */
if (item) { if (item) {
InventoryList *ilist = player->inventory.getList("main"); InventoryList *ilist = player->inventory.getList("main");
@ -2365,8 +2373,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
} }
if (titem && g_settings->getBool("tool_wear")) { if (titem && g_settings->getBool("tool_wear")) {
bool weared_out = titem->addWear(wear); if (titem->addWear(wear))
if(weared_out)
mlist->deleteItem(item_i); mlist->deleteItem(item_i);
SendInventory(player->peer_id); SendInventory(player->peer_id);
} }

View File

@ -1,21 +1,27 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * serverobject.cpp
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#include "serverobject.h" #include "serverobject.h"
#include <fstream> #include <fstream>

View File

@ -1,27 +1,34 @@
/* /************************************************************************
Minetest-c55 * Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com> * Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
This program is free software; you can redistribute it and/or modify * serverobject.h
it under the terms of the GNU General Public License as published by * voxelands - 3d voxel world sandbox game
the Free Software Foundation; either version 2 of the License, or * Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
(at your option) any later version. *
* This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful, * it under the terms of the GNU General Public License as published by
but WITHOUT ANY WARRANTY; without even the implied warranty of * the Free Software Foundation, either version 3 of the License, or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * (at your option) any later version.
GNU General Public License for more details. *
* This program is distributed in the hope that it will be useful, but
You should have received a copy of the GNU General Public License along * WITHOUT ANY WARRANTY; without even the implied warranty of
with this program; if not, write to the Free Software Foundation, Inc., * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * See the GNU General Public License for more details.
*/ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
************************************************************************/
#ifndef SERVEROBJECT_HEADER #ifndef SERVEROBJECT_HEADER
#define SERVEROBJECT_HEADER #define SERVEROBJECT_HEADER
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "activeobject.h" #include "activeobject.h"
#include "mapnode.h"
#include "utility.h" #include "utility.h"
#define MOB_PASSIVE 0 #define MOB_PASSIVE 0
@ -102,15 +109,13 @@ public:
Item that the player gets when this object is picked up. Item that the player gets when this object is picked up.
If NULL, object cannot be picked up. If NULL, object cannot be picked up.
*/ */
virtual InventoryItem* createPickedUpItem(){return NULL;} virtual InventoryItem* createPickedUpItem(content_t punch_item) {return NULL;}
/* /*
If the object doesn't return an item, this will be called. If the object doesn't return an item, this will be called.
Return value is tool wear. Return value is tool wear.
*/ */
virtual u16 punch(const std::string &toolname, v3f dir, virtual u16 punch(content_t punch_item, v3f dir, const std::string &playername) {return 0;}
const std::string &playername)
{return 0;}
/* /*
*/ */