replace only_peace_mobs with max_mob_level

This commit is contained in:
darkrose 2014-01-22 22:00:47 +10:00
parent 7e9b537336
commit 8d36224bdd
6 changed files with 56 additions and 39 deletions

View File

@ -133,8 +133,9 @@
#creative_mode = false
# Enable players getting damage and dying
#enable_damage = false
# Despawn all non-peaceful mobs
#only_peaceful_mobs = false
# The maximum 'level' of mobs to spawn: passive, aggressive, destructive
# roughly: passive = rats, aggressive = oerkki, destructive = DM
#max_mob_level = aggressive
# A chosen map seed for a new map, leave empty for random
#fixed_map_seed =
# Gives some stuff to players at the beginning

View File

@ -1426,9 +1426,9 @@ u16 MobV2SAO::punch(const std::string &toolname, v3f dir,
return 65536/100;
}
bool MobV2SAO::isPeaceful()
u8 MobV2SAO::level()
{
return m_properties->getBool("is_peaceful");
return mobLevelI(m_properties->get("level"));
}
void MobV2SAO::sendPosition()
@ -1497,7 +1497,7 @@ void MobV2SAO::doDamage(u16 d)
}
else
{
actionstream<<"A "<<(isPeaceful()?"peaceful":"non-peaceful")
actionstream<<"A "<<m_properties->get("level")
<<" mob id="<<m_id<<" dies at "<<PP(m_base_position)<<std::endl;
// Die
m_hp = 0;

View File

@ -98,7 +98,7 @@ public:
InventoryItem* createPickedUpItem(){return NULL;}
u16 punch(const std::string &toolname, v3f dir,
const std::string &playername);
bool isPeaceful(){return false;}
u8 level(){return MOB_AGGRESSIVE;}
private:
void doDamage(u16 d);
@ -159,7 +159,7 @@ public:
InventoryItem* createPickedUpItem(){return NULL;}
u16 punch(const std::string &toolname, v3f dir,
const std::string &playername);
bool isPeaceful();
u8 level();
private:
void sendPosition();
void setPropertyDefaults();

View File

@ -94,7 +94,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("strict_protocol_version_checking", "false");
settings->setDefault("creative_mode", "false");
settings->setDefault("enable_damage", "true");
settings->setDefault("only_peaceful_mobs", "false");
settings->setDefault("max_mob_level", "aggressive");
settings->setDefault("fixed_map_seed", "");
settings->setDefault("give_initial_stuff", "false");
settings->setDefault("default_password", "");

View File

@ -755,6 +755,7 @@ static void getMob_dungeon_master(Settings &properties)
properties.set("player_hit_damage", "1");
properties.set("player_hit_distance", "1.0");
properties.set("player_hit_interval", "0.5");
properties.set("level","destructive");
properties.setBool("mindless_rage", myrand_range(0,100)==0);
}
@ -1790,40 +1791,35 @@ void ServerEnvironment::step(float dtime)
ServerActiveObject *obj;
Settings properties;
int i = myrand()%5;
if (g_settings->getBool("only_peaceful_mobs")) {
if (i == 1) {
actionstream<<"Rat spawns at "
<<PP(p1)<<std::endl;
obj = new RatSAO(this, 0, pos);
addActiveObject(obj);
active_object_count_wider++;
}
}else{
switch (i) {
case 0:
u8 mob_level = mobLevelI(g_settings->get("max_mob_level"));
switch (i) {
case 0:
getMob_dungeon_master(properties);
if (mobLevelI(properties.get("level")) >= mob_level) {
actionstream<<"A dungeon master spawns at "
<<PP(p1)<<std::endl;
getMob_dungeon_master(properties);
<<PP(p1)<<std::endl;
obj = new MobV2SAO(this, 0, pos, &properties);
addActiveObject(obj);
active_object_count_wider++;
break;
case 1:
actionstream<<"Rat spawns at "
<<PP(p1)<<std::endl;
obj = new RatSAO(this, 0, pos);
addActiveObject(obj);
active_object_count_wider++;
break;
case 2:
}
break;
case 1:
actionstream<<"Rat spawns at "
<<PP(p1)<<std::endl;
obj = new RatSAO(this, 0, pos);
addActiveObject(obj);
active_object_count_wider++;
break;
case 2:
if (mob_level > MOB_PASSIVE) {
actionstream<<"An oerkki spawns at "
<<PP(p1)<<std::endl;
<<PP(p1)<<std::endl;
obj = new Oerkki1SAO(this, 0, pos);
addActiveObject(obj);
active_object_count_wider++;
break;
default:;
}
break;
default:;
}
}
}
@ -2422,7 +2418,7 @@ void ServerEnvironment::step(float dtime)
// This helps the objects to send data at the same time
bool send_recommended = false;
bool peaceful_mobs = g_settings->getBool("only_peaceful_mobs");
u8 mob_level = mobLevelI(g_settings->get("max_mob_level"));
m_send_recommended_timer += dtime;
if(m_send_recommended_timer > 0.10)
{
@ -2436,10 +2432,8 @@ void ServerEnvironment::step(float dtime)
{
ServerActiveObject* obj = i.getNode()->getValue();
// Remove non-peaceful mobs on peaceful mode
if(peaceful_mobs){
if(!obj->isPeaceful())
obj->m_removed = true;
}
if(obj->level() > mob_level)
obj->m_removed = true;
// Don't step if is to be removed or stored statically
if(obj->m_removed || obj->m_pending_deactivation)
continue;

View File

@ -24,6 +24,28 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "activeobject.h"
#include "utility.h"
#define MOB_PASSIVE 0
#define MOB_AGGRESSIVE 1
#define MOB_DESTRUCTIVE 2
inline u8 mobLevelI(std::string level)
{
if (level == "destructive")
return MOB_DESTRUCTIVE;
if (level == "aggressive")
return MOB_AGGRESSIVE;
return MOB_PASSIVE;
}
inline std::string mobLevelS(u8 level)
{
if (level == MOB_DESTRUCTIVE)
return std::string("destructive");
if (level == MOB_AGGRESSIVE)
return std::string("aggressive");
return std::string("passive");
}
/*
Some planning
@ -112,7 +134,7 @@ public:
*/
virtual void rightClick(Player *player){}
virtual bool isPeaceful(){return true;}
virtual u8 level(){return MOB_PASSIVE;}
/*
Number of players which know about this object. Object won't be