From 621e70273fe15b6010fe2b436d21232923af2f2c Mon Sep 17 00:00:00 2001 From: carolus21rex <85852042+carolus21rex@users.noreply.github.com> Date: Thu, 15 May 2025 19:52:48 -0400 Subject: [PATCH] Fix double hit bug. Added endurance shield. pt 2 --- zone/attack.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/zone/attack.cpp b/zone/attack.cpp index cd91e1846..efb90cd95 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -4593,6 +4593,62 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons } } } //end `if damage was done` + else { + if (!iBuffTic) { //buff ticks do not send damage, instead they just call SendHPUpdate(), which is done above + static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct)); + auto a = (CombatDamage_Struct *) p.pBuffer; + a->target = GetID(); + + if (!attacker) { + a->source = 0; + } else if (attacker->IsClient() && attacker->CastToClient()->GMHideMe()) { + a->source = 0; + } else { + a->source = attacker->GetID(); + } + + a->type = (EQ::ValueWithin(skill_used, EQ::skills::Skill1HBlunt, EQ::skills::Skill2HPiercing)) ? + SkillDamageTypes[skill_used] : SkillDamageTypes[EQ::skills::SkillHandtoHand]; // was 0x1c + a->damage = damage; + a->spellid = spell_id; + + if (special == eSpecialAttacks::AERampage) { + a->special = 1; + } else if (special == eSpecialAttacks::Rampage) { + a->special = 2; + } else { + a->special = 0; + } + + a->hit_heading = attacker ? attacker->GetHeading() : 0.0f; + if (RuleB(Combat, MeleePush) && damage > 0 && !IsRooted() && + (IsClient() || zone->random.Roll(RuleI(Combat, MeleePushChance)))) { + a->force = EQ::skills::GetSkillMeleePushForce(skill_used); + + if (RuleR(Combat, MeleePushForceClientPercent) && IsClient()) { + a->force += a->force * RuleR(Combat, MeleePushForceClientPercent); + } + + if (RuleR(Combat, MeleePushForcePetPercent) && IsPet()) { + a->force += a->force * RuleR(Combat, MeleePushForcePetPercent); + } + + if (IsNPC()) { + if (!RuleB(Combat, NPCtoNPCPush) && attacker && attacker->IsNPC()) { + a->force = 0.0f; // 2013 change that disabled NPC vs NPC push + } else { + a->force *= 0.10f; // force against NPCs is divided by 10 I guess? ex bash is 0.3, parsed 0.03 against an NPC + } + + if (ForcedMovement == 0 && a->force != 0.0f && position_update_melee_push_timer.Check()) { + m_Delta.x += a->force * g_Math.FastSin(a->hit_heading); + m_Delta.y += a->force * g_Math.FastCos(a->hit_heading); + ForcedMovement = 3; + } + } + } + } + }