Index: source/World.h =================================================================== --- source/World.h (Revision 1053) +++ source/World.h (Arbeitskopie) @@ -76,6 +76,11 @@ Int64 GetWorldAge(void) const { return m_WorldAge; } Int64 GetTimeOfDay(void) const { return m_TimeOfDay; } + void DecCntSpawnMonster() + { + m_cntSpawnMonster--; + } + void SetTimeOfDay(Int64 a_TimeOfDay) { m_TimeOfDay = a_TimeOfDay; @@ -450,6 +455,7 @@ Int64 m_LastUnload; // The last WorldAge (in ticks) in which unloading was triggerred Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred Int64 m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned + Int64 m_cntSpawnMonster; // cnt monster spawned eGameMode m_GameMode; bool m_bEnabledPVP; Index: source/Mobs/Monster.cpp =================================================================== --- source/Mobs/Monster.cpp (Revision 1053) +++ source/Mobs/Monster.cpp (Arbeitskopie) @@ -46,6 +46,7 @@ , m_AttackInterval(0) , m_AttackRate(3) , idle_interval(0) + , m_Age(0) { LOGD("cMonster::cMonster()"); LOGD("In state: %s", GetState()); @@ -60,6 +61,7 @@ cMonster::~cMonster() { + m_World->DecCntSpawnMonster(); LOGD("cMonster::~cMonster()"); } @@ -113,6 +115,13 @@ void cMonster::Tick(float a_Dt) { cPawn::Tick(a_Dt); + + m_Age++; + if ( m_Age > 1000 ) + { + Destroy(); + return; + } if( m_Health <= 0 ) { Index: source/Mobs/Monster.h =================================================================== --- source/Mobs/Monster.h (Revision 1053) +++ source/Mobs/Monster.h (Arbeitskopie) @@ -92,6 +92,8 @@ float m_AttackDamage; float m_AttackRange; float m_AttackInterval; + + int m_Age; void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0); }; //tolua_export Index: source/World.cpp =================================================================== --- source/World.cpp (Revision 1053) +++ source/World.cpp (Arbeitskopie) @@ -225,6 +225,7 @@ m_TimeOfDay(0), m_LastTimeUpdate(0), m_LastSpawnMonster(0), + m_cntSpawnMonster(0), m_RSList(0), m_Weather(eWeather_Sunny), m_WeatherInterval(24000) // Guaranteed 1 day of sunshine at server start :) @@ -638,16 +639,17 @@ void cWorld::TickSpawnMobs(float a_Dt) { - if (!m_bAnimals || (m_WorldAge - m_LastSpawnMonster <= m_SpawnMonsterRate)) + //if (!m_bAnimals || (m_WorldAge - m_LastSpawnMonster <= m_SpawnMonsterRate)) + if (!m_bAnimals || m_cntSpawnMonster>50 || (m_WorldAgeSecs - m_LastSpawnMonster <= 1) ) // at the moment 50 mobs 2sec { return; } - m_LastSpawnMonster = m_WorldAge; + m_LastSpawnMonster = m_WorldAgeSecs; Vector3d SpawnPos; { cCSLock Lock(m_CSPlayers); - if ( m_Players.size() <= 0) + if ( m_Players.size() <= 0) // no player online - do not spawn { return; } @@ -716,6 +718,7 @@ if( Monster ) { + m_cntSpawnMonster++; Monster->Initialize(this); Monster->TeleportTo(SpawnPos.x, (double)(Height) + 2, SpawnPos.z); BroadcastSpawn(*Monster);