stop too many mobs spawning

This commit is contained in:
darkrose 2013-06-15 12:18:10 +10:00
parent c6bee901ce
commit 483052661e
1 changed files with 36 additions and 22 deletions

View File

@ -1150,27 +1150,40 @@ void ServerEnvironment::step(float dtime)
ServerActiveObject *obj; ServerActiveObject *obj;
Settings properties; Settings properties;
int i = myrand()%5; int i = myrand()%5;
switch (i) { if (g_settings->getBool("only_peaceful_mobs")) {
case 0: if (i == 1) {
actionstream<<"A dungeon master spawns at " actionstream<<"Rat spawns at "
<<PP(p1)<<std::endl; <<PP(p1)<<std::endl;
getMob_dungeon_master(properties); obj = new RatSAO(this, 0, pos);
obj = new MobV2SAO(this, 0, pos, &properties); addActiveObject(obj);
addActiveObject(obj); active_object_count_wider++;
break; }
case 1: }else{
actionstream<<"Rat spawns at " switch (i) {
<<PP(p1)<<std::endl; case 0:
obj = new RatSAO(this, 0, pos); actionstream<<"A dungeon master spawns at "
addActiveObject(obj); <<PP(p1)<<std::endl;
break; getMob_dungeon_master(properties);
case 2: obj = new MobV2SAO(this, 0, pos, &properties);
actionstream<<"An oerkki spawns at " addActiveObject(obj);
<<PP(p1)<<std::endl; active_object_count_wider++;
obj = new Oerkki1SAO(this, 0, pos); break;
addActiveObject(obj); case 1:
break; actionstream<<"Rat spawns at "
default:; <<PP(p1)<<std::endl;
obj = new RatSAO(this, 0, pos);
addActiveObject(obj);
active_object_count_wider++;
break;
case 2:
actionstream<<"An oerkki spawns at "
<<PP(p1)<<std::endl;
obj = new Oerkki1SAO(this, 0, pos);
addActiveObject(obj);
active_object_count_wider++;
break;
default:;
}
} }
} }
} }
@ -1399,6 +1412,7 @@ void ServerEnvironment::step(float dtime)
// This helps the objects to send data at the same time // This helps the objects to send data at the same time
bool send_recommended = false; bool send_recommended = false;
bool peaceful_mobs = g_settings->getBool("only_peaceful_mobs");
m_send_recommended_timer += dtime; m_send_recommended_timer += dtime;
if(m_send_recommended_timer > 0.10) if(m_send_recommended_timer > 0.10)
{ {
@ -1412,7 +1426,7 @@ void ServerEnvironment::step(float dtime)
{ {
ServerActiveObject* obj = i.getNode()->getValue(); ServerActiveObject* obj = i.getNode()->getValue();
// Remove non-peaceful mobs on peaceful mode // Remove non-peaceful mobs on peaceful mode
if(g_settings->getBool("only_peaceful_mobs")){ if(peaceful_mobs){
if(!obj->isPeaceful()) if(!obj->isPeaceful())
obj->m_removed = true; obj->m_removed = true;
} }