Example #1
0
		virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
			u32 active_object_count, u32 active_object_count_wider, MapNode neighbor, bool activate) {
			ServerMap *map = &env->getServerMap();
			if (map->transforming_liquid_size() > map->m_liquid_step_flow)
				return;
			if (   map->getNodeNoEx(p - v3s16(0,  1, 0 )).getContent() != CONTENT_AIR  // below
			    && map->getNodeNoEx(p - v3s16(1,  0, 0 )).getContent() != CONTENT_AIR  // right
			    && map->getNodeNoEx(p - v3s16(-1, 0, 0 )).getContent() != CONTENT_AIR  // left
			    && map->getNodeNoEx(p - v3s16(0,  0, 1 )).getContent() != CONTENT_AIR  // back
			    && map->getNodeNoEx(p - v3s16(0,  0, -1)).getContent() != CONTENT_AIR  // front
			   )
				return;
			map->transforming_liquid_push_back(p);
		}
Example #2
0
	virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
			u32 active_object_count, u32 active_object_count_wider)
	{
		if(active_object_count_wider != 0)
			return;

		INodeDefManager *ndef = env->getGameDef()->ndef();
		ServerMap *map = &env->getServerMap();

		v3s16 p1 = p + v3s16(0,1,0);
		MapNode n1a = map->getNodeNoEx(p1+v3s16(0,0,0));
		if(n1a.getLightBlend(env->getDayNightRatio(), ndef) <= 3){
			MapNode n1b = 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(
							env, pos, &properties);
					env->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(
								env, pos);
						env->addActiveObject(obj);
					}
				} else {
					actionstream<<"An oerkki spawns at "
							<<PP(p1)<<std::endl;
					ServerActiveObject *obj = new Oerkki1SAO(
							env, pos);
					env->addActiveObject(obj);
				}
			}
		}
	}
Example #3
0
		virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
			u32 active_object_count, u32 active_object_count_wider, MapNode neighbor, bool activate) {
			ServerMap *map = &env->getServerMap();
			INodeDefManager *ndef = env->getGameDef()->ndef();
			float heat = map->updateBlockHeat(env, p);
			content_t c = map->getNodeNoEx(p - v3s16(0,  -1, 0 )).getContent(); // top
			int melt = ((ItemGroupList) ndef->get(n).groups)["melt"];
			if (heat >= melt+1 && (activate || heat >= melt+40 ||
				((myrand_range(heat, melt+40)) >= (c == CONTENT_AIR ? melt+10 : melt+20)))) {
				if (ndef->get(n.getContent()).liquid_type == LIQUID_FLOWING || ndef->get(n.getContent()).liquid_type == LIQUID_SOURCE) {
					 c = map->getNodeNoEx(p - v3s16(0,  1, 0 )).getContent(); // below
					 if (c == CONTENT_AIR || c == CONTENT_IGNORE)
						return; // do not melt when falling (dirt->dirt_with_grass on air)
				}
				n.freezeMelt(ndef, +1);
				map->setNode(p, n);
				//env->getScriptIface()->node_falling_update(p); //enable after making FAST nodeupdate
			}
		}
Example #4
0
	virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
			u32 active_object_count, u32 active_object_count_wider)
	{
		if(active_object_count_wider != 0)
			return;

		INodeDefManager *ndef = env->getGameDef()->ndef();
		ServerMap *map = &env->getServerMap();
		
		v3s16 p1 = p + v3s16(myrand_range(-2, 2),
				0, myrand_range(-2, 2));
		MapNode n1 = map->getNodeNoEx(p1);
		MapNode n1b = map->getNodeNoEx(p1+v3s16(0,-1,0));
		if(n1b.getContent() == ndef->getId("dirt_with_grass") &&
				n1.getContent() == CONTENT_AIR)
		{
			v3f pos = intToFloat(p1, BS);
			ServerActiveObject *obj = new RatSAO(env, pos);
			env->addActiveObject(obj);
		}
	}
Example #5
0
	virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n)
	{
		INodeDefManager *ndef = env->getGameDef()->ndef();
		ServerMap *map = &env->getServerMap();
		
		MapNode n_top = map->getNodeNoEx(p+v3s16(0,1,0));
		if(!ndef->get(n_top).light_propagates ||
				ndef->get(n_top).isLiquid())
		{
			n.setContent(ndef->getId("dirt"));
			map->addNodeWithEvent(p, n);
		}
	}
Example #6
0
	virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n)
	{
		INodeDefManager *ndef = env->getGameDef()->ndef();
		ServerMap *map = &env->getServerMap();
		
		MapNode n_top = map->getNodeNoEx(p+v3s16(0,1,0));
		if(ndef->get(n_top).light_propagates &&
				!ndef->get(n_top).isLiquid() &&
				n_top.getLightBlend(env->getDayNightRatio(), ndef) >= 13)
		{
			n.setContent(ndef->getId("dirt_with_grass"));
			map->addNodeWithEvent(p, n);
		}
	}
Example #7
0
	virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
			u32 active_object_count, u32 active_object_count_wider)
	{
		INodeDefManager *ndef = env->getGameDef()->ndef();
		ServerMap *map = &env->getServerMap();
		
		MapNode n_below = map->getNodeNoEx(p - v3s16(0, 1, 0));
		if (n_below.getContent() != c_dirt &&
			n_below.getContent() != c_dirt_with_grass)
			return;
			
		bool is_jungle_tree = n.getContent() == c_junglesapling;
		
		actionstream <<"A " << (is_jungle_tree ? "jungle " : "")
				<< "sapling grows into a tree at "
				<< PP(p) << std::endl;

		std::map<v3s16, MapBlock*> modified_blocks;
		v3s16 tree_p = p;
		ManualMapVoxelManipulator vmanip(map);
		v3s16 tree_blockp = getNodeBlockPos(tree_p);
		vmanip.initialEmerge(tree_blockp - v3s16(1,1,1), tree_blockp + v3s16(1,1,1));
		
		if (is_jungle_tree) {
			treegen::make_jungletree(vmanip, tree_p, ndef, myrand());
		} else {
			bool is_apple_tree = myrand() % 4 == 0;
			treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand());
		}
		
		vmanip.blitBackAll(&modified_blocks);

		// update lighting
		std::map<v3s16, MapBlock*> lighting_modified_blocks;
		lighting_modified_blocks.insert(modified_blocks.begin(), modified_blocks.end());
		map->updateLighting(lighting_modified_blocks, modified_blocks);

		// Send a MEET_OTHER event
		MapEditEvent event;
		event.type = MEET_OTHER;
//		event.modified_blocks.insert(modified_blocks.begin(), modified_blocks.end());
		for(std::map<v3s16, MapBlock*>::iterator
			i = modified_blocks.begin();
			i != modified_blocks.end(); ++i)
		{
			event.modified_blocks.insert(i->first);
		}
		map->dispatchEvent(&event);
	}
Example #8
0
		virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
			u32 active_object_count, u32 active_object_count_wider, MapNode neighbor, bool activate) {
			ServerMap *map = &env->getServerMap();
			INodeDefManager *ndef = env->getGameDef()->ndef();

			float heat = map->updateBlockHeat(env, p);
			//heater = rare
			content_t c = map->getNodeNoEx(p - v3s16(0,  -1, 0 )).getContent(); // top
			//more chance to freeze if air at top
			int freeze = ((ItemGroupList) ndef->get(n).groups)["freeze"];
			if (heat <= freeze-1 && (activate || heat <= freeze-50 || 
				(myrand_range(freeze-50, heat) <= (c == CONTENT_AIR ? freeze-10 : freeze-40)))) {
				content_t c_self = n.getContent();
				// making freeze not annoying, do not freeze random blocks in center of ocean
				// todo: any block not water (dont freeze _source near _flowing)
				bool allow = activate || heat < freeze-40;
				// todo: make for(...)
				if (!allow) {
				 c = map->getNodeNoEx(p - v3s16(0,  1, 0 )).getContent(); // below
				 if (c == CONTENT_AIR || c == CONTENT_IGNORE)
				    if (ndef->get(n.getContent()).liquid_type == LIQUID_FLOWING || ndef->get(n.getContent()).liquid_type == LIQUID_SOURCE)
					return; // do not freeze when falling
				 if (c != c_self && c != CONTENT_IGNORE) allow = 1;
				 if (!allow) {
				  c = map->getNodeNoEx(p - v3s16(1,  0, 0 )).getContent(); // right
				  if (c != c_self && c != CONTENT_IGNORE) allow = 1;
				  if (!allow) {
				   c = map->getNodeNoEx(p - v3s16(-1, 0, 0 )).getContent(); // left
				   if (c != c_self && c != CONTENT_IGNORE) allow = 1;
				   if (!allow) {
				    c = map->getNodeNoEx(p - v3s16(0,  0, 1 )).getContent(); // back
				    if (c != c_self && c != CONTENT_IGNORE) allow = 1;
				    if (!allow) {
				     c = map->getNodeNoEx(p - v3s16(0,  0, -1)).getContent(); // front
				     if (c != c_self && c != CONTENT_IGNORE) allow = 1;
				    }
				   }
				  }
				 }
				}
				if (allow) {
					n.freezeMelt(ndef, -1);
					map->setNode(p, n);
				}
			}
		}