DMs and oerkkis spawn with only_peaceful_monsters = true

jn
Member
 
Posts: 106
Joined: Tue Jan 03, 2012 19:15

DMs and oerkkis spawn with only_peaceful_monsters = true

by jn » Thu Jan 12, 2012 21:15

I made this simple, obvious (EDIT: slightly buggy, see below) patch, but we should probably use obj->isPeaceful().
Complaints appreciated. :-)

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
commit 9ba566da754b869b31348849ead22f0e19afa5d4
Author: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Date:   Wed Jan 11 19:19:36 2012 +0100

    content_abm: don't spawn oerkkis and DMs with only_peaceful_monsters set

diff --git a/src/content_abm.cpp b/src/content_abm.cpp
index 63867b7..5e6a6a4 100644
--- a/src/content_abm.cpp
+++ b/src/content_abm.cpp
@@ -26,6 +26,7 @@
 #include "settings.h"
 #include "mapblock.h" // For getNodeBlockPos
 #include "mapgen.h" // For mapgen::make_tree
+#include "main.h" // For g_settings
 
 #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
 
@@ -173,7 +174,10 @@ class SpawnInCavesABM : public ActiveBlockModifier
             {
                 v3f pos = intToFloat(p1, BS);
                 int i = myrand()%5;
-                if(i == 0 || i == 1){
+                bool peaceful_only = g_settings
+                    ->getBool("only_peaceful_mobs");
+
+                if((i == 0 || i == 1) && !peaceful_only){
                     actionstream<<"A dungeon master spawns at "
                             <<PP(p1)<<std::endl;
                     Settings properties;
@@ -181,7 +185,13 @@ class SpawnInCavesABM : public ActiveBlockModifier
                     ServerActiveObject *obj = new MobV2SAO(
                             env, pos, &properties);
                     env->addActiveObject(obj);
-                } else if(i == 2 || i == 3){
+                } else if(i == 2 && !peaceful_only) {
+                    actionstream<<"An oerkki spawns at "
+                            <<PP(p1)<<std::endl;
+                    ServerActiveObject *obj = new Oerkki1SAO(
+                            env, pos);
+                    env->addActiveObject(obj);
+                } else {
                     actionstream<<"Rats spawn at "
                             <<PP(p1)<<std::endl;
                     for(int j=0; j<3; j++){
@@ -189,12 +199,6 @@ class SpawnInCavesABM : public ActiveBlockModifier
                                 env, pos);
                         env->addActiveObject(obj);
                     }
-                } else {
-                    actionstream<<"An oerkki spawns at "
-                            <<PP(p1)<<std::endl;
-                    ServerActiveObject *obj = new Oerkki1SAO(
-                            env, pos);
-                    env->addActiveObject(obj);
                 }
             }
         }



Version 2: http://paste.opensuse.org/view/raw/57678777
Last edited by jn on Fri Jan 27, 2012 00:15, edited 1 time in total.
 

User avatar
dannydark
Member
 
Posts: 428
Joined: Fri Aug 12, 2011 21:28

by dannydark » Sat Jan 14, 2012 21:37

With "one_peaceful_monsters = true" set DM's and oerkkis still spawn but should immediately de-spawn...well at least that's how I thought it worked although I don't have peaceful mode set so I could be wrong.
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Sat Jan 14, 2012 22:49

this also despawns rats.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
IPushButton2653
Member
 
Posts: 666
Joined: Wed Nov 16, 2011 22:47

by IPushButton2653 » Sat Jan 14, 2012 23:09

I have the same problem. I go into the minetest.conf and set it to despawn non-peaceful mobs, but they still spawn.
 

jn
Member
 
Posts: 106
Joined: Tue Jan 03, 2012 19:15

by jn » Sat Jan 14, 2012 23:45

dannydark wrote:With "one_peaceful_monsters = true" set DM's and oerkkis still spawn but should immediately de-spawn...well at least that's how I thought it worked although I don't have peaceful mode set so I could be wrong.

Yes, that's how it is. But I felt that preventing them from being spawned in the first place was a good idea.


Jordach wrote:this also despawns rats.

Really? This patch?


IPushButton wrote:I have the same problem. I go into the minetest.conf and set it to despawn non-peaceful mobs, but they still spawn.

And do they survive the despawning of non-peaceful mobs that happens every tick, which is about five times a second at least?
If so, there's a bug somewhere else. If you just want to get rid of DMs and oerkkis in the server log, feel free to try my half-baked patch.
 

User avatar
IPushButton2653
Member
 
Posts: 666
Joined: Wed Nov 16, 2011 22:47

by IPushButton2653 » Sat Jan 14, 2012 23:49

They never disappear. I made my house out of a cave, and when I return, dm griefs it :(
 

jn
Member
 
Posts: 106
Joined: Tue Jan 03, 2012 19:15

by jn » Sun Jan 15, 2012 02:33

@IPushBotton: are you sure you spelled the option right?
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Mon Jan 23, 2012 22:14

@jn: heres what i mean:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
+                    actionstream<<"An oerkki spawns at "
+                            <<PP(p1)<<std::endl;
+                    ServerActiveObject *obj = new Oerkki1SAO(
+                            env, pos);
+                    env->addActiveObject(obj);
+                } else {
                     actionstream<<"Rats spawn at "

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

jn
Member
 
Posts: 106
Joined: Tue Jan 03, 2012 19:15

by jn » Tue Jan 24, 2012 22:44

@Jordach: No, it doesn't (I tested it), you must have misread the patch. The block/hunk you posted stems from the fact that I reordered some of the code.
But I just noticed an actual bug in it: With one_peaceful_monsters set 2.5 times as many rats are spawned (got to fix this).
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Wed Jan 25, 2012 08:00

maybe enforce a population check?

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

jn
Member
 
Posts: 106
Joined: Tue Jan 03, 2012 19:15

by jn » Fri Jan 27, 2012 00:16

 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 6 guests

cron