[Bots] Add BotHealOnLevel to fully heal/mana on level. (#3745)

Adds the rule ***Bots, BotHealOnLevel***, default false, to control whether or not bots will gain full health and mana when their owner levels.
This commit is contained in:
nytmyr 2023-12-07 21:25:17 -06:00 committed by GitHub
parent 16dc210cd8
commit 6466c2ff21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -649,6 +649,7 @@ RULE_BOOL(Bots, ResurrectionSickness, true, "Use Resurrection Sickness based on
RULE_INT(Bots, OldResurrectionSicknessSpell, 757, "757 is Default Old Resurrection Sickness Spell")
RULE_INT(Bots, ResurrectionSicknessSpell, 756, "756 is Default Resurrection Sickness Spell")
RULE_BOOL(Bots, AllowPickpocketCommand, true, "Allows the use of the bot command 'pickpocket'")
RULE_BOOL(Bots, BotHealOnLevel, false, "Setting whether a bot should heal completely when leveling. Default FALSE.")
RULE_CATEGORY_END()
RULE_CATEGORY(Chat)

View File

@ -3634,12 +3634,27 @@ void Bot::LevelBotWithClient(Client* client, uint8 level, bool sendlvlapp) {
for (auto biter = blist.begin(); biter != blist.end(); ++biter) {
Bot* bot = *biter;
if (bot && (bot->GetLevel() != client->GetLevel())) {
bot->SetPetChooser(false); // not sure what this does, but was in bot 'update' code
bot->CalcBotStats(client->GetBotOption(Client::booStatsUpdate));
if (sendlvlapp)
if (sendlvlapp) {
bot->SendLevelAppearance();
}
// modified from Client::SetLevel()
if (!RuleB(Bots, BotHealOnLevel)) {
int mhp = bot->CalcMaxHP();
if (bot->GetHP() > mhp) {
bot->SetHP(mhp);
}
}
else {
bot->SetHP(bot->CalcMaxHP());
bot->SetMana(bot->CalcMaxMana());
}
bot->SendHPUpdate();
bot->SendAppearancePacket(AT_WhoLevel, level, true, true); // who level change
bot->AI_AddBotSpells(bot->GetBotSpellID());
}