Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Messages] Fix multiple errors in spell damage at death. #4264

Merged
merged 2 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions zone/attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ void Client::Damage(Mob* other, int64 damage, uint16 spell_id, EQ::skills::Skill
}
}

bool Client::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillType attack_skill, KilledByTypes killed_by)
bool Client::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillType attack_skill, KilledByTypes killed_by, bool is_buff_tic)
{
if (!ClientFinishedLoading() || dead) {
return false;
Expand Down Expand Up @@ -1786,12 +1786,25 @@ bool Client::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::Skil
/* Make Death Packet */
EQApplicationPacket app(OP_Death, sizeof(Death_Struct));
Death_Struct* d = (Death_Struct*)app.pBuffer;

// Convert last message to color to avoid duplicate damage messages
// that occur in these rare cases when this is the death blow.
if (IsValidSpell(spell) &&
(attack_skill == EQ::skills::SkillTigerClaw ||
(IsDamageSpell(spell) && IsDiscipline(spell)) ||
!is_buff_tic)) {
d->attack_skill = DamageTypeSpell;
d->spell_id = (is_buff_tic) ? UINT32_MAX : spell;
}
else {
d->attack_skill = SkillDamageTypes[attack_skill];
d->spell_id = UINT32_MAX;
}

d->spawn_id = GetID();
d->killer_id = killer_mob ? killer_mob->GetID() : 0;
d->corpseid = GetID();
d->bindzoneid = m_pp.binds[0].zone_id;
d->spell_id = IsValidSpell(spell) ? spell : 0xffffffff;
d->attack_skill = IsValidSpell(spell) ? 0xe7 : attack_skill;
d->damage = damage;
app.priority = 6;
entity_list.QueueClients(this, &app);
Expand Down Expand Up @@ -2380,7 +2393,7 @@ void NPC::Damage(Mob* other, int64 damage, uint16 spell_id, EQ::skills::SkillTyp
}
}

bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillType attack_skill, KilledByTypes killed_by)
bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillType attack_skill, KilledByTypes killed_by, bool is_buff_tic)
{
LogCombat(
"Fatal blow dealt by [{}] with [{}] damage, spell [{}], skill [{}]",
Expand Down Expand Up @@ -2493,12 +2506,24 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
auto app = new EQApplicationPacket(OP_Death, sizeof(Death_Struct));

auto d = (Death_Struct*) app->pBuffer;

// Convert last message to color to avoid duplicate damage messages
// that occur in these rare cases when this is the death blow.
if (IsValidSpell(spell) &&
(attack_skill == EQ::skills::SkillTigerClaw ||
(IsDamageSpell(spell) && IsDiscipline(spell)) ||
!is_buff_tic)) {
d->attack_skill = DamageTypeSpell;
d->spell_id = (is_buff_tic) ? UINT32_MAX : spell;
}
else {
d->attack_skill = SkillDamageTypes[attack_skill];
d->spell_id = UINT32_MAX;
}

d->spawn_id = GetID();
d->killer_id = killer_mob ? killer_mob->GetID() : 0;
d->bindzoneid = 0;
d->spell_id = UINT32_MAX;
d->attack_skill = SkillDamageTypes[attack_skill];
d->damage = damage;
d->corpseid = GetID();

Expand Down Expand Up @@ -4257,8 +4282,8 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons

if (!IsSaved && !TrySpellOnDeath()) {
SetHP(-500);

if (Death(attacker, damage, spell_id, skill_used)) {
// killedByType is clarified in Client::Death if we are client.
if (Death(attacker, damage, spell_id, skill_used, KilledByTypes::Killed_NPC, iBuffTic)) {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion zone/beacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Beacon : public Mob
~Beacon();

//abstract virtual function implementations requird by base abstract class
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC) { return true; }
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC, bool is_buff_tic = false) { return true; }
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) { return; }
virtual bool HasRaid() { return false; }
virtual bool HasGroup() { return false; }
Expand Down
2 changes: 1 addition & 1 deletion zone/bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4341,7 +4341,7 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client*
}
}

bool Bot::Death(Mob *killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by)
bool Bot::Death(Mob *killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by, bool is_buff_tic)
{
if (!NPC::Death(killer_mob, damage, spell_id, attack_skill)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion zone/bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Bot : public NPC {
Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double totalPlayTime, uint32 lastZoneId, NPCType *npcTypeData, int32 expansion_bitmask);

//abstract virtual override function implementations requird by base abstract class
bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC) override;
bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC, bool is_buff_tic = false) override;
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;

Expand Down
2 changes: 1 addition & 1 deletion zone/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class Client : public Mob
bool GotoPlayerRaid(const std::string& player_name);

//abstract virtual function implementations required by base abstract class
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC);
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC, bool is_buff_tic = false);
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);
virtual bool HasRaid() { return (GetRaid() ? true : false); }
virtual bool HasGroup() { return (GetGroup() ? true : false); }
Expand Down
3 changes: 2 additions & 1 deletion zone/corpse.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class Corpse : public Mob {
int64 damage,
uint16 spell_id,
EQ::skills::SkillType attack_skill,
KilledByTypes killed_by = KilledByTypes::Killed_NPC
KilledByTypes killed_by = KilledByTypes::Killed_NPC,
bool is_buff_tic = false
) { return true; }

virtual void Damage(
Expand Down
2 changes: 1 addition & 1 deletion zone/encounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Encounter : public Mob
~Encounter();

//abstract virtual function implementations required by base abstract class
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC) { return true; }
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC, bool is_buff_tic = false) { return true; }
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) { return; }
bool Attack(Mob* other, int Hand = EQ::invslot::slotPrimary, bool FromRiposte = false, bool IsStrikethrough = false,
bool IsFromSpell = false, ExtraAttackOptions *opts = nullptr) override {
Expand Down
2 changes: 1 addition & 1 deletion zone/merc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4070,7 +4070,7 @@ Mob* Merc::GetOwnerOrSelf() {
return Result;
}

bool Merc::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillType attack_skill, uint8 killed_by)
bool Merc::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillType attack_skill, uint8 killed_by, bool is_buff_tic)
{
if (!NPC::Death(killer_mob, damage, spell, attack_skill)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion zone/merc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Merc : public NPC {
virtual ~Merc();

//abstract virtual function implementations requird by base abstract class
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, uint8 killed_by = 0);
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, uint8 killed_by = 0, bool is_buff_tic = false);
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);
virtual bool Attack(Mob* other, int Hand = EQ::invslot::slotPrimary, bool FromRiposte = false, bool IsStrikethrough = false,
bool IsFromSpell = false, ExtraAttackOptions *opts = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion zone/mob.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class Mob : public Entity {
bool CanClassEquipItem(uint32 item_id);
bool CanRaceEquipItem(uint32 item_id);
bool AffectedBySpellExcludingSlot(int slot, int effect);
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC) = 0;
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC, bool is_buff_tic = false) = 0;
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;
void SetHP(int64 hp);
Expand Down
2 changes: 1 addition & 1 deletion zone/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class NPC : public Mob
static NPC * SpawnZonePointNodeNPC(std::string name, const glm::vec4 &position);

//abstract virtual function implementations requird by base abstract class
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC);
virtual bool Death(Mob* killer_mob, int64 damage, uint16 spell_id, EQ::skills::SkillType attack_skill, KilledByTypes killed_by = KilledByTypes::Killed_NPC, bool is_buff_tic = false);
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);
bool Attack(Mob* other, int Hand = EQ::invslot::slotPrimary, bool FromRiposte = false, bool IsStrikethrough = false,
bool IsFromSpell = false, ExtraAttackOptions *opts = nullptr) override;
Expand Down