- v3s16 p0;
- for(p0.X=0; p0.X<MAP_BLOCKSIZE; p0.X++)
- for(p0.Y=0; p0.Y<MAP_BLOCKSIZE; p0.Y++)
- for(p0.Z=0; p0.Z<MAP_BLOCKSIZE; p0.Z++)
- {
- v3s16 p = p0 + block->getPosRelative();
- MapNode n = block->getNodeNoEx(p0);
-
- /*
- Test something:
- Convert mud under proper lighting to grass
- */
- if(n.getContent() == CONTENT_MUD)
- {
- if(myrand()%20 == 0)
- {
- MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0));
- if(content_features(n_top).air_equivalent &&
- n_top.getLightBlend(getDayNightRatio()) >= 13)
- {
- n.setContent(CONTENT_GRASS);
- m_map->addNodeWithEvent(p, n);
- }
- }
- }
- /*
- Convert grass into mud if under something else than air
- */
- 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)
- {
- 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);
- }
- }
- }
- /*
- 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){
- actionstream<<"A dungeon master spawns at "
- <<PP(p1)<<std::endl;
- Settings properties;
- getMob_dungeon_master(properties);
- ServerActiveObject *obj = new MobV2SAO(
- this, 0, pos, &properties);
- addActiveObject(obj);
- } else if(i == 2 || i == 3){
- actionstream<<"Rats spawn at "
- <<PP(p1)<<std::endl;
- for(int j=0; j<3; j++){
- ServerActiveObject *obj = new RatSAO(
- this, 0, pos);
- addActiveObject(obj);
- }
- } else {
- actionstream<<"An oerkki spawns at "
- <<PP(p1)<<std::endl;
- ServerActiveObject *obj = new Oerkki1SAO(
- this, 0, pos);
- addActiveObject(obj);
- }
- }
- }
- }
- }
- /*
- Make trees from saplings!
- */
- if(n.getContent() == CONTENT_SAPLING)
- {
- if(myrand()%50 == 0)
- {
- actionstream<<"A sapling grows into a tree at "
- <<PP(p)<<std::endl;
-
- 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);
- }
- }
- }