X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fcontent_abm.cpp;h=1ee41b2ecf4cceaf73fd690603a40c06ca1d6974;hb=e5b4748bb44a12fd09a92f7d36986b4bda86e6bf;hp=9289035b8c1557a07ea0a782a0b306adbb9d4200;hpb=69a59f1e419d8204cc90cfaa25ad690c9b3d9e16;p=oweals%2Fminetest.git diff --git a/src/content_abm.cpp b/src/content_abm.cpp index 9289035b8..1ee41b2ec 100644 --- a/src/content_abm.cpp +++ b/src/content_abm.cpp @@ -32,216 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" -class LiquidFlowABM : public ActiveBlockModifier { - private: - std::set contents; - - public: - LiquidFlowABM(ServerEnvironment *env, INodeDefManager *nodemgr) { - std::set liquids; - nodemgr->getIds("group:liquid", liquids); - for(std::set::const_iterator k = liquids.begin(); k != liquids.end(); k++) - contents.insert(nodemgr->get(*k).liquid_alternative_flowing); - } - virtual std::set getTriggerContents() { - return contents; - } - virtual float getTriggerInterval() - { return 10.0; } - virtual u32 getTriggerChance() - { return 10; } - virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) { - ServerMap *map = &env->getServerMap(); - if (map->transforming_liquid_size() > 500) - return; - map->transforming_liquid_add(p); - } -}; - -class LiquidDropABM : public ActiveBlockModifier { - private: - std::set contents; - - public: - LiquidDropABM(ServerEnvironment *env, INodeDefManager *nodemgr) { - std::set liquids; - nodemgr->getIds("group:liquid", liquids); - for(std::set::const_iterator k = liquids.begin(); k != liquids.end(); k++) - contents.insert(nodemgr->get(*k).liquid_alternative_source); - } - virtual std::set getTriggerContents() - { return contents; } - virtual std::set getRequiredNeighbors() { - std::set neighbors; - neighbors.insert("air"); - return neighbors; - } - virtual float getTriggerInterval() - { return 20.0; } - virtual u32 getTriggerChance() - { return 10; } - virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) { - ServerMap *map = &env->getServerMap(); - if (map->transforming_liquid_size() > 500) - 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_add(p); - } -}; - -class LiquidFreeze : public ActiveBlockModifier { - public: - LiquidFreeze(ServerEnvironment *env, INodeDefManager *nodemgr) { } - virtual std::set getTriggerContents() { - std::set s; - s.insert("group:freezes"); - return s; - } - virtual std::set getRequiredNeighbors() { - std::set s; - s.insert("air"); - s.insert("group:melts"); - return s; - } - virtual float getTriggerInterval() - { return 10.0; } - virtual u32 getTriggerChance() - { return 20; } - virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) { - 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 - if (heat <= -1 && (heat <= -50 || (myrand_range(-50, heat) <= (c == CONTENT_AIR ? -10 : -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 = heat < -40; - // todo: make for(...) - if (!allow) { - c = map->getNodeNoEx(p - v3s16(0, 1, 0 )).getContent(); // below - if (c == CONTENT_AIR || c == CONTENT_IGNORE) - 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); - map->addNodeWithEvent(p, n); - } - } - } -}; - -class LiquidMeltWeather : public ActiveBlockModifier { - public: - LiquidMeltWeather(ServerEnvironment *env, INodeDefManager *nodemgr) { } - virtual std::set getTriggerContents() { - std::set s; - s.insert("group:melts"); - return s; - } - virtual std::set getRequiredNeighbors() { - std::set s; - s.insert("air"); - s.insert("group:freezes"); - return s; - } - virtual float getTriggerInterval() - { return 10.0; } - virtual u32 getTriggerChance() - { return 20; } - virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) { - 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 - if (heat >= 1 && (heat >= 40 || ((myrand_range(heat, 40)) >= (c == CONTENT_AIR ? 10 : 20)))) { - n.freezeMelt(ndef); - map->addNodeWithEvent(p, n); - env->getScriptIface()->node_falling_update(p); - } - } -}; - -class LiquidMeltHot : public ActiveBlockModifier { - public: - LiquidMeltHot(ServerEnvironment *env, INodeDefManager *nodemgr) { } - virtual std::set getTriggerContents() { - std::set s; - s.insert("group:melts"); - return s; - } - virtual std::set getRequiredNeighbors() { - std::set s; - s.insert("group:igniter"); - s.insert("group:hot"); - return s; - } - virtual float getTriggerInterval() - { return 2.0; } - virtual u32 getTriggerChance() - { return 4; } - virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n) { - ServerMap *map = &env->getServerMap(); - INodeDefManager *ndef = env->getGameDef()->ndef(); - n.freezeMelt(ndef); - map->addNodeWithEvent(p, n); - env->getScriptIface()->node_falling_update(p); - } -}; - -/* too buggy, later via liquid flow code -class LiquidMeltAround : public LiquidMeltHot { - public: - LiquidMeltAround(ServerEnvironment *env, INodeDefManager *nodemgr) - : LiquidMeltHot(env, nodemgr) { } - virtual std::set getRequiredNeighbors() { - std::set s; - s.insert("group:melt_around"); - return s; - } - virtual float getTriggerInterval() - { return 40.0; } - virtual u32 getTriggerChance() - { return 60; } -}; -*/ - void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef) { - if (g_settings->getBool("liquid_finite")) { - env->addActiveBlockModifier(new LiquidFlowABM(env, nodedef)); - env->addActiveBlockModifier(new LiquidDropABM(env, nodedef)); - env->addActiveBlockModifier(new LiquidMeltHot(env, nodedef)); - //env->addActiveBlockModifier(new LiquidMeltAround(env, nodedef)); - if (env->m_use_weather) { - env->addActiveBlockModifier(new LiquidFreeze(env, nodedef)); - env->addActiveBlockModifier(new LiquidMeltWeather(env, nodedef)); - } - } + }