mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 12:31:31 +00:00
[Crash] Fix Bot Crash in Bot::Bot Constructor. (#2868)
* [Crash] Fix Bot Crash in Bot::Bot Constructor. * fix another potential crash in bot contructor.
This commit is contained in:
parent
9825c61a13
commit
924e91cf64
39
zone/bot.cpp
39
zone/bot.cpp
@ -86,8 +86,6 @@ Bot::Bot(NPCType *npcTypeData, Client* botOwner) : NPC(npcTypeData, nullptr, glm
|
|||||||
|
|
||||||
m_alt_combat_hate_timer.Start(250);
|
m_alt_combat_hate_timer.Start(250);
|
||||||
m_auto_defend_timer.Disable();
|
m_auto_defend_timer.Disable();
|
||||||
//m_combat_jitter_timer.Disable();
|
|
||||||
//SetCombatJitterFlag(false);
|
|
||||||
SetGuardFlag(false);
|
SetGuardFlag(false);
|
||||||
SetHoldFlag(false);
|
SetHoldFlag(false);
|
||||||
SetAttackFlag(false);
|
SetAttackFlag(false);
|
||||||
@ -198,8 +196,6 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
|
|||||||
|
|
||||||
m_alt_combat_hate_timer.Start(250);
|
m_alt_combat_hate_timer.Start(250);
|
||||||
m_auto_defend_timer.Disable();
|
m_auto_defend_timer.Disable();
|
||||||
//m_combat_jitter_timer.Disable();
|
|
||||||
//SetCombatJitterFlag(false);
|
|
||||||
SetGuardFlag(false);
|
SetGuardFlag(false);
|
||||||
SetHoldFlag(false);
|
SetHoldFlag(false);
|
||||||
SetAttackFlag(false);
|
SetAttackFlag(false);
|
||||||
@ -251,12 +247,13 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
|
|||||||
|
|
||||||
LoadAAs();
|
LoadAAs();
|
||||||
|
|
||||||
// copied from client CompleteConnect() handler - watch for problems
|
if (!database.botdb.LoadBuffs(this)) {
|
||||||
// (may have to move to post-spawn location if certain buffs still don't process correctly)
|
if (bot_owner) {
|
||||||
if (database.botdb.LoadBuffs(this) && bot_owner) {
|
bot_owner->Message(Chat::White, "&s for '%s'", BotDatabase::fail::LoadBuffs(), GetCleanName());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
//reapply some buffs
|
//reapply some buffs
|
||||||
uint32 buff_count = GetMaxTotalSlots();
|
uint32 buff_count = GetMaxBuffSlots();
|
||||||
for (uint32 j1 = 0; j1 < buff_count; j1++) {
|
for (uint32 j1 = 0; j1 < buff_count; j1++) {
|
||||||
if (!IsValidSpell(buffs[j1].spellid)) {
|
if (!IsValidSpell(buffs[j1].spellid)) {
|
||||||
continue;
|
continue;
|
||||||
@ -326,11 +323,6 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//case SE_SummonHorse: {
|
|
||||||
// SummonHorse(buffs[j1].spellid);
|
|
||||||
// //hasmount = true; //this was false, is that the correct thing?
|
|
||||||
// break;
|
|
||||||
//}
|
|
||||||
case SE_Silence:
|
case SE_Silence:
|
||||||
{
|
{
|
||||||
Silence(true);
|
Silence(true);
|
||||||
@ -357,12 +349,8 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
|
|||||||
{
|
{
|
||||||
if (!zone->CanLevitate())
|
if (!zone->CanLevitate())
|
||||||
{
|
{
|
||||||
//if (!GetGM())
|
|
||||||
//{
|
|
||||||
SendAppearancePacket(AT_Levitate, 0);
|
SendAppearancePacket(AT_Levitate, 0);
|
||||||
BuffFadeByEffect(SE_Levitate);
|
BuffFadeByEffect(SE_Levitate);
|
||||||
//Message(Chat::White, "You can't levitate in this zone.");
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SendAppearancePacket(AT_Levitate, 2);
|
SendAppearancePacket(AT_Levitate, 2);
|
||||||
@ -400,9 +388,6 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
bot_owner->Message(Chat::White, "&s for '%s'", BotDatabase::fail::LoadBuffs(), GetCleanName());
|
|
||||||
}
|
|
||||||
|
|
||||||
CalcBotStats(false);
|
CalcBotStats(false);
|
||||||
hp_regen = CalcHPRegen();
|
hp_regen = CalcHPRegen();
|
||||||
@ -6355,7 +6340,17 @@ bool Bot::CastSpell(
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::SpellOnTarget(uint16 spell_id, Mob* spelltar) {
|
bool Bot::SpellOnTarget(
|
||||||
|
uint16 spell_id,
|
||||||
|
Mob *spelltar,
|
||||||
|
int reflect_effectiveness,
|
||||||
|
bool use_resist_adjust,
|
||||||
|
int16 resist_adjust,
|
||||||
|
bool isproc,
|
||||||
|
int level_override,
|
||||||
|
int duration_override,
|
||||||
|
bool disable_buff_overwrite
|
||||||
|
) {
|
||||||
if (!IsValidSpell(spell_id)) {
|
if (!IsValidSpell(spell_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
32
zone/bot.h
32
zone/bot.h
@ -147,10 +147,10 @@ public:
|
|||||||
void Damage(Mob* from, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, bool avoidable = true, int8 buffslot = -1,
|
void Damage(Mob* from, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, bool avoidable = true, int8 buffslot = -1,
|
||||||
bool iBuffTic = false, eSpecialAttacks special = eSpecialAttacks::None) override;
|
bool iBuffTic = false, eSpecialAttacks special = eSpecialAttacks::None) override;
|
||||||
|
|
||||||
bool HasRaid() override { return (GetRaid() ? true : false); }
|
bool HasRaid() final { return (GetRaid() ? true : false); }
|
||||||
bool HasGroup() override { return (GetGroup() ? true : false); }
|
bool HasGroup() final { return (GetGroup() ? true : false); }
|
||||||
Raid* GetRaid() override { return entity_list.GetRaidByMob(this); }
|
Raid* GetRaid() final { return entity_list.GetRaidByMob(this); }
|
||||||
Group* GetGroup() override { return entity_list.GetGroupByMob(this); }
|
Group* GetGroup() final { return entity_list.GetGroupByMob(this); }
|
||||||
|
|
||||||
// Common, but informal "interfaces" with Client object
|
// Common, but informal "interfaces" with Client object
|
||||||
uint32 CharacterID() { return GetBotID(); } // Just returns the Bot Id
|
uint32 CharacterID() { return GetBotID(); } // Just returns the Bot Id
|
||||||
@ -354,8 +354,8 @@ public:
|
|||||||
void AI_Bot_Start(uint32 iMoveDelay = 0);
|
void AI_Bot_Start(uint32 iMoveDelay = 0);
|
||||||
|
|
||||||
// Mob AI Virtual Override Methods
|
// Mob AI Virtual Override Methods
|
||||||
void AI_Process() override;
|
void AI_Process() final;
|
||||||
void AI_Stop() override;
|
void AI_Stop() final;
|
||||||
|
|
||||||
// Mob Spell Virtual Override Methods
|
// Mob Spell Virtual Override Methods
|
||||||
void SpellProcess() override;
|
void SpellProcess() override;
|
||||||
@ -365,7 +365,17 @@ public:
|
|||||||
void DoBuffTic(const Buffs_Struct &buff, int slot, Mob* caster = nullptr) override;
|
void DoBuffTic(const Buffs_Struct &buff, int slot, Mob* caster = nullptr) override;
|
||||||
virtual bool CastSpell(uint16 spell_id, uint16 target_id, EQ::spells::CastingSlot slot = EQ::spells::CastingSlot::Item, int32 casttime = -1, int32 mana_cost = -1, uint32* oSpellWillFinish = 0,
|
virtual bool CastSpell(uint16 spell_id, uint16 target_id, EQ::spells::CastingSlot slot = EQ::spells::CastingSlot::Item, int32 casttime = -1, int32 mana_cost = -1, uint32* oSpellWillFinish = 0,
|
||||||
uint32 item_slot = 0xFFFFFFFF, int16 *resist_adjust = nullptr, uint32 aa_id = 0);
|
uint32 item_slot = 0xFFFFFFFF, int16 *resist_adjust = nullptr, uint32 aa_id = 0);
|
||||||
virtual bool SpellOnTarget(uint16 spell_id, Mob* spelltar);
|
bool SpellOnTarget(
|
||||||
|
uint16 spell_id,
|
||||||
|
Mob* spelltar,
|
||||||
|
int reflect_effectiveness = 0,
|
||||||
|
bool use_resist_adjust = false,
|
||||||
|
int16 resist_adjust = 0,
|
||||||
|
bool isproc = false,
|
||||||
|
int level_override = -1,
|
||||||
|
int duration_override = 0,
|
||||||
|
bool disable_buff_overwrite = false
|
||||||
|
) final;
|
||||||
bool IsImmuneToSpell(uint16 spell_id, Mob *caster) override;
|
bool IsImmuneToSpell(uint16 spell_id, Mob *caster) override;
|
||||||
virtual bool DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_center, CastAction_type &CastAction, EQ::spells::CastingSlot slot);
|
virtual bool DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_center, CastAction_type &CastAction, EQ::spells::CastingSlot slot);
|
||||||
virtual bool DoCastSpell(uint16 spell_id, uint16 target_id, EQ::spells::CastingSlot slot = EQ::spells::CastingSlot::Item, int32 casttime = -1, int32 mana_cost = -1,
|
virtual bool DoCastSpell(uint16 spell_id, uint16 target_id, EQ::spells::CastingSlot slot = EQ::spells::CastingSlot::Item, int32 casttime = -1, int32 mana_cost = -1,
|
||||||
@ -376,10 +386,10 @@ public:
|
|||||||
bool IsFromSpell = false, ExtraAttackOptions *opts = nullptr) override
|
bool IsFromSpell = false, ExtraAttackOptions *opts = nullptr) override
|
||||||
{ return Mob::Attack(other, Hand, FromRiposte, IsStrikethrough, IsFromSpell, opts); }
|
{ return Mob::Attack(other, Hand, FromRiposte, IsStrikethrough, IsFromSpell, opts); }
|
||||||
|
|
||||||
[[nodiscard]] int GetMaxBuffSlots() const override { return EQ::spells::LONG_BUFFS; }
|
[[nodiscard]] int GetMaxBuffSlots() const final { return EQ::spells::LONG_BUFFS; }
|
||||||
[[nodiscard]] int GetMaxSongSlots() const override { return EQ::spells::SHORT_BUFFS; }
|
[[nodiscard]] int GetMaxSongSlots() const final { return EQ::spells::SHORT_BUFFS; }
|
||||||
[[nodiscard]] int GetMaxDiscSlots() const override { return EQ::spells::DISC_BUFFS; }
|
[[nodiscard]] int GetMaxDiscSlots() const final { return EQ::spells::DISC_BUFFS; }
|
||||||
[[nodiscard]] int GetMaxTotalSlots() const override { return EQ::spells::TOTAL_BUFFS; }
|
[[nodiscard]] int GetMaxTotalSlots() const final { return EQ::spells::TOTAL_BUFFS; }
|
||||||
|
|
||||||
bool GetBotOwnerDataBuckets();
|
bool GetBotOwnerDataBuckets();
|
||||||
bool GetBotDataBuckets();
|
bool GetBotDataBuckets();
|
||||||
|
|||||||
@ -514,7 +514,7 @@ public:
|
|||||||
virtual bool Death(Mob* killerMob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill) = 0;
|
virtual bool Death(Mob* killerMob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill) = 0;
|
||||||
virtual void Damage(Mob* from, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill,
|
virtual void Damage(Mob* from, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill,
|
||||||
bool avoidable = true, int8 buffslot = -1, bool iBuffTic = false, eSpecialAttacks special = eSpecialAttacks::None) = 0;
|
bool avoidable = true, int8 buffslot = -1, bool iBuffTic = false, eSpecialAttacks special = eSpecialAttacks::None) = 0;
|
||||||
virtual void SetHP(int64 hp);
|
void SetHP(int64 hp);
|
||||||
bool ChangeHP(Mob* other, int32 amount, uint16 spell_id = 0, int8 buffslot = -1, bool iBuffTic = false);
|
bool ChangeHP(Mob* other, int32 amount, uint16 spell_id = 0, int8 buffslot = -1, bool iBuffTic = false);
|
||||||
inline void SetOOCRegen(int64 new_ooc_regen) { ooc_regen = new_ooc_regen; }
|
inline void SetOOCRegen(int64 new_ooc_regen) { ooc_regen = new_ooc_regen; }
|
||||||
virtual void Heal();
|
virtual void Heal();
|
||||||
@ -628,7 +628,7 @@ public:
|
|||||||
virtual void SetEndurance(int32 newEnd) { return; }
|
virtual void SetEndurance(int32 newEnd) { return; }
|
||||||
int64 GetItemHPBonuses();
|
int64 GetItemHPBonuses();
|
||||||
int64 GetSpellHPBonuses();
|
int64 GetSpellHPBonuses();
|
||||||
virtual const int64& SetMana(int64 amount);
|
const int64& SetMana(int64 amount);
|
||||||
inline float GetManaRatio() const { return max_mana == 0 ? 100 :
|
inline float GetManaRatio() const { return max_mana == 0 ? 100 :
|
||||||
((static_cast<float>(current_mana) / max_mana) * 100); }
|
((static_cast<float>(current_mana) / max_mana) * 100); }
|
||||||
virtual int64 CalcMaxMana();
|
virtual int64 CalcMaxMana();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user