diff --git a/common/ruletypes.h b/common/ruletypes.h index 2f5b9f246..f4ca7c2d9 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -280,6 +280,7 @@ RULE_BOOL(Zone, UseZoneController, true, "Enables the ability to use persistent RULE_BOOL(Zone, EnableZoneControllerGlobals, false, "Enables the ability to use quest globals with the zone controller NPC") RULE_INT(Zone, GlobalLootMultiplier, 1, "Sets Global Loot drop multiplier for database based drops, useful for double, triple loot etc") RULE_BOOL(Zone, KillProcessOnDynamicShutdown, true, "When process has booted a zone and has hit its zone shut down timer, it will hard kill the process to free memory back to the OS") +RULE_INT(Zone, SecondsBeforeIdle, 60, "Seconds before IDLE_WHEN_EMPTY define kicks in") RULE_CATEGORY_END() RULE_CATEGORY(Map) diff --git a/zone/entity.cpp b/zone/entity.cpp index 23ff268fc..0441aac48 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -498,11 +498,30 @@ void EntityList::MobProcess() size_t sz = mob_list.size(); #ifdef IDLE_WHEN_EMPTY + static int old_client_count=0; + static Timer *mob_settle_timer = new Timer(); + + if (numclients == 0 && old_client_count > 0 && + RuleI(Zone, SecondsBeforeIdle) > 0) { + // Start Timer to allow any mobs that chased chars from zone + // to return home. + mob_settle_timer->Start(RuleI(Zone, SecondsBeforeIdle) * 1000); + } + + old_client_count = numclients; + + // Disable settle timer if someone zones into empty zone + if (numclients > 0 || mob_settle_timer->Check()) { + mob_settle_timer->Disable(); + } + if (numclients > 0 || - mob->GetWanderType() == 4 || mob->GetWanderType() == 6) { + mob->GetWanderType() == 4 || mob->GetWanderType() == 6 || + mob_settle_timer->Enabled()) { // Normal processing, or assuring that spawns that should // path and depop do that. Otherwise all of these type mobs - // will be up and at starting positions when idle zone wakes up. + // will be up and at starting positions, or waiting at the zoneline + // if they chased the PCs when idle zone wakes up. mob_dead = !mob->Process(); } else {