From 22ef16947cbb015732d1e48cedd9800884430cf4 Mon Sep 17 00:00:00 2001 From: Natedog2012 Date: Thu, 28 May 2015 11:24:17 -0700 Subject: [PATCH] Bots will no longer crash when disbanding on death or normal disbanding.. HP values on bots will no longer roll over when checking STAMINA --- zone/bot.cpp | 26 +++++++++++++++++--------- zone/client_packet.cpp | 5 +++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 10e00e3f2..a3e07707c 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -751,9 +751,13 @@ void Bot::GenerateBaseStats() { this->DR = DiseaseResist; this->PR = PoisonResist; this->CR = ColdResist; + this->PhR = 0; this->Corrup = CorruptionResist; SetBotSpellID(BotSpellID); this->size = BotSize; + + this->pAggroRange = 0; + this->pAssistRange = 0; } void Bot::GenerateAppearance() { @@ -1374,20 +1378,20 @@ int32 Bot::GenerateBaseHitPoints() // Calc Base Hit Points int new_base_hp = 0; uint32 lm = GetClassLevelFactor(); - uint32 Post255; - uint32 NormalSTA = GetSTA(); - + int32 Post255; + int32 NormalSTA = GetSTA(); + if(GetOwner() && GetOwner()->CastToClient() && GetOwner()->CastToClient()->GetClientVersion() >= ClientVersion::SoD && RuleB(Character, SoDClientUseSoDHPManaEnd)) { float SoDPost255; - + if(((NormalSTA - 255) / 2) > 0) SoDPost255 = ((NormalSTA - 255) / 2); else SoDPost255 = 0; - + int hp_factor = GetClassHPFactor(); - + if(level < 41) { new_base_hp = (5 + (GetLevel() * hp_factor / 12) + ((NormalSTA - SoDPost255) * GetLevel() * hp_factor / 3600)); @@ -1415,7 +1419,7 @@ int32 Bot::GenerateBaseHitPoints() new_base_hp = (5)+(GetLevel()*lm/10) + (((NormalSTA-Post255)*GetLevel()*lm/3000)) + ((Post255*1)*lm/6000); } this->base_hp = new_base_hp; - + return new_base_hp; } @@ -5913,7 +5917,12 @@ bool Bot::Death(Mob *killerMob, int32 damage, uint16 spell_id, SkillUseTypes att g->members[j] = nullptr; } } - + + //Make sure group still exists if it doesnt they were already updated in RemoveBotFromGroup + g = GetGroup(); + if (!g) + break; + // update the client group EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct)); GroupJoin_Struct* gu = (GroupJoin_Struct*)outapp->pBuffer; @@ -10196,7 +10205,6 @@ int32 Bot::CalcMaxHP() { bot_hp += GenerateBaseHitPoints() + itembonuses.HP; nd += aabonuses.MaxHP; //Natural Durability, Physical Enhancement, Planar Durability - bot_hp = (float)bot_hp * (float)nd / (float)10000; //this is to fix the HP-above-495k issue bot_hp += spellbonuses.HP + aabonuses.HP; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 9f527476c..01046d7fb 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -6362,7 +6362,12 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) } } } + + group = GetGroup(); + if (!group) //We must recheck this here.. incase the final bot disbanded the party..otherwise we crash + return; #endif + if (group->GroupCount() < 3) { group->DisbandGroup();