Implement mana/hp/end replenishments if logged off for long enough

Default set to on with a default time of 6 hours (21600 seconds)
This commit is contained in:
Michael Cook (mackal) 2014-10-08 03:36:31 -04:00
parent b6294a28cb
commit a325380884
3 changed files with 12 additions and 2 deletions

View File

@ -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 )

View File

@ -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');

View File

@ -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. */