summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-07-30 17:51:21 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-07-30 17:51:21 +0300
commit4556c212dba726271352b05a9299564e05abb218 (patch)
tree40cf46d5d3bb7ba423f7daca4a18e0966dccb94b /src
parent8ceb0586b29d66ad0b4c073420590625a4b63769 (diff)
downloadminetest-4556c212dba726271352b05a9299564e05abb218.tar.gz
minetest-4556c212dba726271352b05a9299564e05abb218.tar.bz2
minetest-4556c212dba726271352b05a9299564e05abb218.zip
Made rats cookable and made them spawn near trees
Diffstat (limited to 'src')
-rw-r--r--src/content_inventory.cpp10
-rw-r--r--src/content_sao.cpp2
-rw-r--r--src/defaultsettings.cpp2
-rw-r--r--src/environment.cpp42
4 files changed, 50 insertions, 6 deletions
diff --git a/src/content_inventory.cpp b/src/content_inventory.cpp
index 322250606..24840d6af 100644
--- a/src/content_inventory.cpp
+++ b/src/content_inventory.cpp
@@ -65,6 +65,10 @@ std::string item_craft_get_image_name(const std::string &subname)
return "clay_brick.png";
else if(subname == "rat")
return "rat.png";
+ else if(subname == "cooked_rat")
+ return "cooked_rat.png";
+ else if(subname == "scorched_stuff")
+ return "scorched_stuff.png";
else if(subname == "firefly")
return "firefly.png";
else
@@ -98,7 +102,7 @@ s16 item_craft_get_drop_count(const std::string &subname)
bool item_craft_is_cookable(const std::string &subname)
{
- if(subname == "lump_of_iron" || subname == "lump_of_clay")
+ if(subname == "lump_of_iron" || subname == "lump_of_clay" || subname == "rat" || subname == "cooked_rat")
return true;
return false;
@@ -110,6 +114,10 @@ InventoryItem* item_craft_create_cook_result(const std::string &subname)
return new CraftItem("steel_ingot", 1);
else if(subname == "lump_of_clay")
return new CraftItem("clay_brick", 1);
+ else if(subname == "rat")
+ return new CraftItem("cooked_rat", 1);
+ else if(subname == "cooked_rat")
+ return new CraftItem("scorched_stuff", 1);
return NULL;
}
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 0b81855c1..eadaa6e5f 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -232,7 +232,7 @@ RatSAO::RatSAO(ServerEnvironment *env, u16 id, v3f pos):
m_oldpos = v3f(0,0,0);
m_last_sent_position = v3f(0,0,0);
- m_yaw = 0;
+ m_yaw = myrand_range(0,PI*2);
m_counter1 = 0;
m_counter2 = 0;
m_age = 0;
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 8326a0f0d..947892d12 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -79,7 +79,7 @@ void set_default_settings()
// Server stuff
g_settings.setDefault("enable_experimental", "false");
g_settings.setDefault("creative_mode", "false");
- g_settings.setDefault("enable_damage", "false"); //TODO: Set to true when healing is possible
+ g_settings.setDefault("enable_damage", "true");
g_settings.setDefault("give_initial_stuff", "false");
g_settings.setDefault("default_password", "");
g_settings.setDefault("default_privs", "build, shout");
diff --git a/src/environment.cpp b/src/environment.cpp
index d72369620..e9b94f3fa 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -816,7 +816,7 @@ void ServerEnvironment::step(float dtime)
if(m_active_blocks_test_interval.step(dtime, 10.0))
{
//float dtime = 10.0;
-
+
for(core::map<v3s16, bool>::Iterator
i = m_active_blocks.m_list.getIterator();
i.atEnd()==false; i++)
@@ -846,6 +846,21 @@ void ServerEnvironment::step(float dtime)
searching loop to keep things fast.
*/
// TODO: Implement usage of ActiveBlockModifier
+
+ // Find out how many objects the block contains
+ u32 active_object_count = block->m_static_objects.m_active.size();
+ // Find out how many objects this and all the neighbors contain
+ u32 active_object_count_wider = 0;
+ for(s16 x=-1; x<=1; x++)
+ for(s16 y=-1; y<=1; y++)
+ for(s16 z=-1; z<=1; z++)
+ {
+ MapBlock *block = m_map->getBlockNoCreateNoEx(p+v3s16(x,y,z));
+ if(block==NULL)
+ continue;
+ active_object_count_wider +=
+ block->m_static_objects.m_active.size();
+ }
v3s16 p0;
for(p0.X=0; p0.X<MAP_BLOCKSIZE; p0.X++)
@@ -875,18 +890,39 @@ void ServerEnvironment::step(float dtime)
/*
Convert grass into mud if under something else than air
*/
- else if(n.getContent() == CONTENT_GRASS)
+ if(n.getContent() == CONTENT_GRASS)
{
//if(myrand()%20 == 0)
{
MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0));
- if(content_features(n_top).air_equivalent == false)
+ if(content_features(n_top).air_equivalent == false)
{
n.setContent(CONTENT_MUD);
m_map->addNodeWithEvent(p, n);
}
}
}
+ /*
+ Rats spawn around regular trees
+ */
+ if(n.getContent() == CONTENT_TREE ||
+ n.getContent() == CONTENT_JUNGLETREE)
+ {
+ if(myrand()%200 == 0 && active_object_count_wider == 0)
+ {
+ v3s16 p1 = p + v3s16(myrand_range(-2, 2),
+ 0, myrand_range(-2, 2));
+ MapNode n1 = m_map->getNodeNoEx(p1);
+ MapNode n1b = m_map->getNodeNoEx(p1+v3s16(0,-1,0));
+ if(n1b.getContent() == CONTENT_GRASS &&
+ n1.getContent() == CONTENT_AIR)
+ {
+ v3f pos = intToFloat(p1, BS);
+ ServerActiveObject *obj = new RatSAO(this, 0, pos);
+ addActiveObject(obj);
+ }
+ }
+ }
}
}
}