+ /*
+ 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);
+ }
+ }
+ }
+ /*
+ Fun things spawn in caves and dungeons
+ */
+ if(n.getContent() == CONTENT_STONE ||
+ n.getContent() == CONTENT_MOSSYCOBBLE)
+ {
+ if(myrand()%200 == 0 && active_object_count_wider == 0)
+ {
+ v3s16 p1 = p + v3s16(0,1,0);
+ MapNode n1a = m_map->getNodeNoEx(p1+v3s16(0,0,0));
+ if(n1a.getLightBlend(getDayNightRatio()) <= 3){
+ MapNode n1b = m_map->getNodeNoEx(p1+v3s16(0,1,0));
+ if(n1a.getContent() == CONTENT_AIR &&
+ n1b.getContent() == CONTENT_AIR)
+ {
+ v3f pos = intToFloat(p1, BS);
+ int i = myrand()%5;
+ if(i == 0 || i == 1){
+ Settings properties;
+ getMob_dungeon_master(properties);
+ ServerActiveObject *obj = new MobV2SAO(
+ this, 0, pos, &properties);
+ addActiveObject(obj);
+ } else if(i == 2 || i == 3){
+ for(int j=0; j<3; j++){
+ ServerActiveObject *obj = new RatSAO(
+ this, 0, pos);
+ addActiveObject(obj);
+ }
+ } else {
+ ServerActiveObject *obj = new Oerkki1SAO(
+ this, 0, pos);
+ addActiveObject(obj);
+ }
+ }
+ }
+ }
+ }
+ /*
+ Make trees from saplings!
+ */
+ if(n.getContent() == CONTENT_SAPLING)
+ {
+ if(myrand()%50 == 0)
+ {
+ core::map<v3s16, MapBlock*> modified_blocks;
+ v3s16 tree_p = p;
+ ManualMapVoxelManipulator vmanip(m_map);
+ v3s16 tree_blockp = getNodeBlockPos(tree_p);
+ vmanip.initialEmerge(tree_blockp - v3s16(1,1,1), tree_blockp + v3s16(1,1,1));
+ bool is_apple_tree = myrand()%4 == 0;
+ mapgen::make_tree(vmanip, tree_p, is_apple_tree);
+ vmanip.blitBackAll(&modified_blocks);
+
+ // update lighting
+ core::map<v3s16, MapBlock*> lighting_modified_blocks;
+ for(core::map<v3s16, MapBlock*>::Iterator
+ i = modified_blocks.getIterator();
+ i.atEnd() == false; i++)
+ {
+ lighting_modified_blocks.insert(i.getNode()->getKey(), i.getNode()->getValue());
+ }
+ m_map->updateLighting(lighting_modified_blocks, modified_blocks);
+
+ // Send a MEET_OTHER event
+ MapEditEvent event;
+ event.type = MEET_OTHER;
+ for(core::map<v3s16, MapBlock*>::Iterator
+ i = modified_blocks.getIterator();
+ i.atEnd() == false; i++)
+ {
+ v3s16 p = i.getNode()->getKey();
+ event.modified_blocks.insert(p, true);
+ }
+ m_map->dispatchEvent(&event);
+ }
+ }