diff --git a/common/ruletypes.h b/common/ruletypes.h index c5004ffd1..528770ecb 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -201,6 +201,8 @@ RULE_INT ( Zone, EbonCrystalItemID, 40902) RULE_INT ( Zone, RadiantCrystalItemID, 40903) RULE_BOOL ( Zone, LevelBasedEXPMods, false) // Allows you to use the level_exp_mods table in consideration to your players EXP hits RULE_INT ( Zone, WeatherTimer, 600) // Weather timer when no duration is available +RULE_BOOL ( Zone, EnableLoggedOffReplenishments, true) +RULE_INT ( Zone, MinOfflineTimeToReplenishments, 21600) // 21600 seconds is 6 Hours RULE_CATEGORY_END() RULE_CATEGORY( Map ) diff --git a/utils/sql/git/optional/2014_10_08_LoggedOffReplenishments.sql b/utils/sql/git/optional/2014_10_08_LoggedOffReplenishments.sql new file mode 100644 index 000000000..cd553784c --- /dev/null +++ b/utils/sql/git/optional/2014_10_08_LoggedOffReplenishments.sql @@ -0,0 +1,2 @@ +INSERT INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (1, 'Zone:EnableLoggedOffReplenishments', 'true', 'Replenish mana/hp/end if logged off for MinOfflineTimeToReplenishments'); +INSERT INTO `rule_values` (`ruleset_id`, `rule_name`, `rule_value`, `notes`) VALUES (1, 'Zone:MinOfflineTimeToReplenishments', '21600', 'Minimum logged off time to trigger replenish mana/hp/end'); diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 7edd9202b..988a6d5f5 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1375,7 +1375,6 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) query = StringFormat("SELECT `lfp`, `lfg`, `xtargets`, `firstlogon`, `guild_id`, `rank` FROM `character_data` LEFT JOIN `guild_members` ON `id` = `char_id` WHERE `id` = %i", cid); results = database.QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { - m_pp.lastlogin = time(nullptr); if (row[4] && atoi(row[4]) > 0){ guild_id = atoi(row[4]); if (row[5] != nullptr){ guildrank = atoi(row[5]); } @@ -1661,11 +1660,18 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) #endif CalcBonuses(); + if (RuleB(Zone, EnableLoggedOffReplenishments) && + time(nullptr) - m_pp.lastlogin >= RuleI(Zone, MinOfflineTimeToReplenishments)) { + m_pp.cur_hp = GetMaxHP(); + m_pp.mana = GetMaxMana(); + m_pp.endurance = GetMaxEndurance(); + } + if (m_pp.cur_hp <= 0) m_pp.cur_hp = GetMaxHP(); SetHP(m_pp.cur_hp); - Mob::SetMana(m_pp.mana); + Mob::SetMana(m_pp.mana); // mob function doesn't send the packet SetEndurance(m_pp.endurance); /* Update LFP in case any (or all) of our group disbanded while we were zoning. */