Пример #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();
			INodeDefManager *ndef = env->getGameDef()->ndef();
			int cold = ((ItemGroupList) ndef->get(neighbor).groups)["cold"];
			int freeze = ((ItemGroupList) ndef->get(n).groups)["freeze"];
			if (cold < freeze) {
				n.freezeMelt(ndef, -1);
				map->setNode(p, n);
			}
		}
Пример #2
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();
			int hot = ((ItemGroupList) ndef->get(neighbor).groups)["hot"];
			int melt = ((ItemGroupList) ndef->get(n).groups)["melt"];
			if (hot > melt) {
				n.freezeMelt(ndef, +1);
				map->setNode(p, n);
				env->getScriptIface()->node_falling_update(p);
			}
		}
Пример #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);
			//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);
				}
			}
		}
Пример #4
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
			}
		}