From cbc82a1fc5e24c69e679256ff72fadbbb44155ba Mon Sep 17 00:00:00 2001 From: Jhobean Date: Sat, 14 Oct 2023 23:09:08 -0400 Subject: [PATCH 01/13] Add some item props functionnality --- Changelog.txt | 4 + src/game/chars/CChar.h | 1 + src/game/chars/CCharAct.cpp | 19 +++++ src/game/chars/CCharFight.cpp | 79 +++++++++++++++++++ src/game/components/CCPropsItemEquippable.cpp | 24 +++--- 5 files changed, 115 insertions(+), 12 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 9e74e3d91..c25defe79 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3380,3 +3380,7 @@ Additionally, the problem of zig-zag issue following in the South direction has 08-10-2023, Nolok & xwerswoodx - Fixed: Setting P inside the @Click trigger made it being called endlessly. + +14-10-2023, Jhobean +- Added: Item properties functionnality:HITAREAPHYSICAL,HITAREAFIRE,HITAREACOLD,HITAREAPOISON,HITAREAENERGY,HITFIREBALL,HITHARM,HITLIGHTNING,HITMAGICARROW,REFLECTPHYSICALDAM +- Fixed: Item properties functionnality:HITLEECHMANA,HITLEECHSTAM diff --git a/src/game/chars/CChar.h b/src/game/chars/CChar.h index b3c85975c..e6b56aeac 100644 --- a/src/game/chars/CChar.h +++ b/src/game/chars/CChar.h @@ -1298,6 +1298,7 @@ public: void StatFlag_Mod(uint64 uiStatFlag, bool fMod) noexcept; // Outside events that occur to us. int OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhysical = 0, int iDmgFire = 0, int iDmgCold = 0, int iDmgPoison = 0, int iDmgEnergy = 0, SPELL_TYPE spell = SPELL_NONE ); + void OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgPhysical = 0, int iDmgFire = 0, int iDmgCold = 0, int iDmgPoison = 0, int iDmgEnergy = 0, HUE_TYPE effectHue = HUE_DEFAULT, SOUND_TYPE effectSound = SOUND_NONE); void OnHarmedBy( CChar * pCharSrc ); bool OnAttackedBy( CChar * pCharSrc, bool fPetsCommand = false, bool fShouldReveal = true ); diff --git a/src/game/chars/CCharAct.cpp b/src/game/chars/CCharAct.cpp index fb211b25a..74d9a33d5 100644 --- a/src/game/chars/CCharAct.cpp +++ b/src/game/chars/CCharAct.cpp @@ -2197,6 +2197,24 @@ bool CChar::ItemEquip( CItem * pItem, CChar * pCharMsg, bool fFromDClick ) ModPropNum(pCCPChar, PROPCH_DAMPOISON, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMPOISON, pItemBaseCCPItemEquippable)); ModPropNum(pCCPChar, PROPCH_DAMENERGY, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + + ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREACOLD, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + + ModPropNum(pCCPChar, PROPCH_HITFIREBALL, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITHARM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + + ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + + + if ( pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_NIGHTSIGHT, pItemBaseCCPItemEquippable) ) { StatFlag_Mod( STATF_NIGHTSIGHT, 1 ); @@ -2206,6 +2224,7 @@ bool CChar::ItemEquip( CItem * pItem, CChar * pCharMsg, bool fFromDClick ) if (pItem->IsTypeWeapon()) { + //Necromancy Curse weapon CItem * pCursedMemory = LayerFind(LAYER_SPELL_Curse_Weapon); // Remove the cursed state from SPELL_Curse_Weapon. if (pCursedMemory) pItem->ModPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHLIFE, + pCursedMemory->m_itSpell.m_spelllevel, pItemBaseCCPItemEquippable); diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index 9515810fe..b7e953dd3 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -983,6 +983,30 @@ int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhys return iDmg; } +void CChar::OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgPhysical, int iDmgFire, int iDmgCold, int iDmgPoison, int iDmgEnergy, HUE_TYPE effectHue, SOUND_TYPE effectSound) +{ + ADDTOCALLSTACK("CChar::OnTakeDamageArea"); + + bool fMakeSound = false; + // Damage perimeter should be ajust to more realist "nearby targets" + // Like this area damage touch everyone! Pet, NPC etc + CWorldSearch AreaChars(GetTopPoint(), UO_MAP_VIEW_SIGHT); + for (;;) + { + CChar* pChar = AreaChars.GetChar(); + if (!pChar) + break; + if ((pChar == this) || (pChar == pSrc)) + continue; + + pChar->OnTakeDamage(iDmg, pSrc, uType, iDmgPhysical, iDmgFire, iDmgCold, iDmgPoison, iDmgEnergy); + pChar->Effect(EFFECT_OBJ, ITEMID_FX_SPARKLE_2, this, 1, 15, false, effectHue); + fMakeSound = true; + } + if (fMakeSound && (effectSound != SOUND_NONE)) + Sound(effectSound); +} + //******************************************************************************* // Fight specific memories. @@ -2165,6 +2189,61 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg ) if ( fMakeLeechSound ) Sound(0x44d); + + //There a bug here... This line never read correctly the target REFLECTPHYSICALDAM value + if (pCharTarg->GetPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, pBaseCCPChar)) + { + // REFLECTPHYSICALDAM suppose to reflect only physical? How we block other damage here? + OnTakeDamage( + iDmg * pCharTarg->GetPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, pBaseCCPChar) / 100, + this, + iDmgType, + (int)GetPropNum(pCCPChar, PROPCH_DAMPHYSICAL, pBaseCCPChar), + (int)GetPropNum(pCCPChar, PROPCH_DAMFIRE, pBaseCCPChar), + (int)GetPropNum(pCCPChar, PROPCH_DAMCOLD, pBaseCCPChar), + (int)GetPropNum(pCCPChar, PROPCH_DAMPOISON, pBaseCCPChar), + (int)GetPropNum(pCCPChar, PROPCH_DAMENERGY, pBaseCCPChar) + ); + } + + if (pWeapon) + { + bool fElemental = IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE); + + if (fElemental) + { + if (GetPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 100, 0, 0, 0, 0, static_cast(0x32), static_cast(0x10E)); + + if (GetPropNum(pCCPChar, PROPCH_HITAREAFIRE, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 100, 0, 0, 0, static_cast(0x488), static_cast(0x11D)); + + if (GetPropNum(pCCPChar, PROPCH_HITAREACOLD, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 100, 0, 0, static_cast(0x834), static_cast(0xFC)); + + if (GetPropNum(pCCPChar, PROPCH_HITAREAPOISON, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 0, 100, 0, static_cast(0x48E), static_cast(0x205)); + + if (GetPropNum(pCCPChar, PROPCH_HITAREAENERGY, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 0, 0, 100, static_cast(0x78), static_cast(0x1F1)); + + } + + if (GetPropNum(pCCPChar, PROPCH_HITDISPEL, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Dispel, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + + if (GetPropNum(pCCPChar, PROPCH_HITFIREBALL, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Fireball, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + + if (GetPropNum(pCCPChar, PROPCH_HITHARM, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Harm, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + + if (GetPropNum(pCCPChar, PROPCH_HITLIGHTNING, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Lightning, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + + if (GetPropNum(pCCPChar, PROPCH_HITMAGICARROW, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Magic_Arrow, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + } // Make blood effects if ( pCharTarg->_wBloodHue != (HUE_TYPE)(-1) ) diff --git a/src/game/components/CCPropsItemEquippable.cpp b/src/game/components/CCPropsItemEquippable.cpp index fa3f597e8..37dba2b27 100644 --- a/src/game/components/CCPropsItemEquippable.cpp +++ b/src/game/components/CCPropsItemEquippable.cpp @@ -331,39 +331,39 @@ void CCPropsItemEquippable::AddPropsTooltipData(CObjBase* pLinkedObj) case PROPIEQUIP_FASTERCASTRECOVERY: // unimplemented ADDTNUM(1060412); // faster cast recovery ~1_val~ break; - case PROPIEQUIP_HITAREACOLD: // unimplemented + case PROPIEQUIP_HITAREACOLD: if (IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE)) ADDTNUM(1060416); // hit cold area ~1_val~% break; - case PROPIEQUIP_HITAREAENERGY: // unimplemented + case PROPIEQUIP_HITAREAENERGY: if (IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE)) ADDTNUM(1060418); // hit energy area ~1_val~% break; - case PROPIEQUIP_HITAREAFIRE: // unimplemented + case PROPIEQUIP_HITAREAFIRE: if (IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE)) ADDTNUM(1060419); // hit fire area ~1_val~% break; - case PROPIEQUIP_HITAREAPHYSICAL: // unimplemented + case PROPIEQUIP_HITAREAPHYSICAL: if (IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE)) ADDTNUM(1060428); // hit physical area ~1_val~% break; - case PROPIEQUIP_HITAREAPOISON: // unimplemented + case PROPIEQUIP_HITAREAPOISON: if (IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE)) ADDTNUM(1060429); // hit poison area ~1_val~% break; case PROPIEQUIP_HITCURSE: // unimplemented ADDTNUM(1113712); // Hit Curse ~1_val~% break; - case PROPIEQUIP_HITDISPEL: // unimplemented + case PROPIEQUIP_HITDISPEL: ADDTNUM(1060417); // hit dispel ~1_val~% break; case PROPIEQUIP_HITFATIGUE: // unimplemented ADDTNUM(1113700); // // Hit Fatigue ~1_val~% break; - case PROPIEQUIP_HITFIREBALL: // unimplemented + case PROPIEQUIP_HITFIREBALL: ADDTNUM(1060420); // hit fireball ~1_val~% break; - case PROPIEQUIP_HITHARM: // unimplemented + case PROPIEQUIP_HITHARM: ADDTNUM(1060421); // hit harm ~1_val~% break; case PROPIEQUIP_HITLEECHLIFE: @@ -375,7 +375,7 @@ void CCPropsItemEquippable::AddPropsTooltipData(CObjBase* pLinkedObj) case PROPIEQUIP_HITLEECHSTAM: ADDTNUM(1060430); // hit stamina leech ~1_val~% break; - case PROPIEQUIP_HITLIGHTNING: // unimplemented + case PROPIEQUIP_HITLIGHTNING: ADDTNUM(1060422); // hit lightning ~1_val~% break; case PROPIEQUIP_HITLOWERATK: // unimplemented @@ -384,10 +384,10 @@ void CCPropsItemEquippable::AddPropsTooltipData(CObjBase* pLinkedObj) case PROPIEQUIP_HITLOWERDEF: // unimplemented ADDTNUM(1060425); // hit lower defense ~1_val~% break; - case PROPIEQUIP_HITMAGICARROW: // unimplemented + case PROPIEQUIP_HITMAGICARROW: ADDTNUM(1060426); // hit magic arrow ~1_val~% break; - case PROPIEQUIP_HITMANADRAIN: // unimplemented + case PROPIEQUIP_HITMANADRAIN: ADDTNUM(1113699); // Hit Mana Drain ~1_val~% break; case PROPIEQUIP_HITSPARKS: // unimplemented @@ -459,7 +459,7 @@ void CCPropsItemEquippable::AddPropsTooltipData(CObjBase* pLinkedObj) case PROPIEQUIP_REACTIVEPARALYZE: // Unimplemented ADDT(1112364); // reactive paralyze break; - case PROPIEQUIP_REFLECTPHYSICALDAM: // Unimplemented + case PROPIEQUIP_REFLECTPHYSICALDAM: ADDTNUM(1060442); // reflect physical damage ~1_val~% break; case PROPIEQUIP_REGENFOOD: // unimplemented From 53f60e9dcdda1435a702a83326f3ad4ab180ae54 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Sun, 15 Oct 2023 09:07:02 -0400 Subject: [PATCH 02/13] Fix reflect damage and and LOS on damage area --- src/game/chars/CCharAct.cpp | 26 +++---- src/game/chars/CCharFight.cpp | 131 ++++++++++++++++++---------------- 2 files changed, 83 insertions(+), 74 deletions(-) diff --git a/src/game/chars/CCharAct.cpp b/src/game/chars/CCharAct.cpp index 74d9a33d5..61be7fb47 100644 --- a/src/game/chars/CCharAct.cpp +++ b/src/game/chars/CCharAct.cpp @@ -2197,21 +2197,21 @@ bool CChar::ItemEquip( CItem * pItem, CChar * pCharMsg, bool fFromDClick ) ModPropNum(pCCPChar, PROPCH_DAMPOISON, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMPOISON, pItemBaseCCPItemEquippable)); ModPropNum(pCCPChar, PROPCH_DAMENERGY, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREACOLD, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREACOLD, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITFIREBALL, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITHARM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITFIREBALL, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITHARM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); @@ -2224,7 +2224,7 @@ bool CChar::ItemEquip( CItem * pItem, CChar * pCharMsg, bool fFromDClick ) if (pItem->IsTypeWeapon()) { - //Necromancy Curse weapon + //Necromancy Curse weapon CItem * pCursedMemory = LayerFind(LAYER_SPELL_Curse_Weapon); // Remove the cursed state from SPELL_Curse_Weapon. if (pCursedMemory) pItem->ModPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHLIFE, + pCursedMemory->m_itSpell.m_spelllevel, pItemBaseCCPItemEquippable); diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index b7e953dd3..20e062875 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -985,26 +985,32 @@ int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhys void CChar::OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgPhysical, int iDmgFire, int iDmgCold, int iDmgPoison, int iDmgEnergy, HUE_TYPE effectHue, SOUND_TYPE effectSound) { - ADDTOCALLSTACK("CChar::OnTakeDamageArea"); + ADDTOCALLSTACK("CChar::OnTakeDamageArea"); - bool fMakeSound = false; - // Damage perimeter should be ajust to more realist "nearby targets" - // Like this area damage touch everyone! Pet, NPC etc - CWorldSearch AreaChars(GetTopPoint(), UO_MAP_VIEW_SIGHT); - for (;;) - { - CChar* pChar = AreaChars.GetChar(); - if (!pChar) - break; - if ((pChar == this) || (pChar == pSrc)) - continue; + bool fMakeSound = false; + // Like this area damage touch everyone! Pet, NPC etc We should ignore pet and Criminal action? - pChar->OnTakeDamage(iDmg, pSrc, uType, iDmgPhysical, iDmgFire, iDmgCold, iDmgPoison, iDmgEnergy); - pChar->Effect(EFFECT_OBJ, ITEMID_FX_SPARKLE_2, this, 1, 15, false, effectHue); - fMakeSound = true; - } - if (fMakeSound && (effectSound != SOUND_NONE)) - Sound(effectSound); + int iDistance = 5; + if (IsAosFlagEnabled(FEATURE_AOS_DAMAGE)) + iDistance=10; // 5 for ML and 10 for aos + + CWorldSearch AreaChars(GetTopPoint(), iDistance); + for (;;) + { + CChar* pChar = AreaChars.GetChar(); + if (!pChar) + break; + if (!pChar->CanSeeLOS(pSrc)) + break; + if ((pChar == this) || (pChar == pSrc)) + continue; + + pChar->OnTakeDamage(iDmg, pSrc, uType, iDmgPhysical, iDmgFire, iDmgCold, iDmgPoison, iDmgEnergy); + pChar->Effect(EFFECT_OBJ, ITEMID_FX_SPARKLE_2, this, 1, 15, false, effectHue); + fMakeSound = true; + } + if (fMakeSound && (effectSound != SOUND_NONE)) + Sound(effectSound); } //******************************************************************************* @@ -2189,61 +2195,64 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg ) if ( fMakeLeechSound ) Sound(0x44d); - - //There a bug here... This line never read correctly the target REFLECTPHYSICALDAM value - if (pCharTarg->GetPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, pBaseCCPChar)) - { - // REFLECTPHYSICALDAM suppose to reflect only physical? How we block other damage here? - OnTakeDamage( - iDmg * pCharTarg->GetPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, pBaseCCPChar) / 100, - this, - iDmgType, - (int)GetPropNum(pCCPChar, PROPCH_DAMPHYSICAL, pBaseCCPChar), - (int)GetPropNum(pCCPChar, PROPCH_DAMFIRE, pBaseCCPChar), - (int)GetPropNum(pCCPChar, PROPCH_DAMCOLD, pBaseCCPChar), - (int)GetPropNum(pCCPChar, PROPCH_DAMPOISON, pBaseCCPChar), - (int)GetPropNum(pCCPChar, PROPCH_DAMENERGY, pBaseCCPChar) - ); - } - if (pWeapon) - { - bool fElemental = IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE); + // REFLECTPHYSICALDAM + const CCPropsChar* pCCPCharTarg = pCharTarg->GetComponentProps(); + const CCPropsChar* pBaseCCPCharTarg = pCharTarg->Base_GetDef()->GetComponentProps(); + int iTargReflectPhysicalDam =pCharTarg->GetPropNum(pCCPCharTarg, PROPCH_REFLECTPHYSICALDAM, pBaseCCPCharTarg); + if (iTargReflectPhysicalDam) + { + // REFLECTPHYSICALDAM suppose to reflect only physical? How we block other damage here? + OnTakeDamage( + iDmg * iTargReflectPhysicalDam / 100, + this, + iDmgType, + (int)GetPropNum(pCCPChar, PROPCH_DAMPHYSICAL, pBaseCCPChar), + (int)GetPropNum(pCCPChar, PROPCH_DAMFIRE, pBaseCCPChar), + (int)GetPropNum(pCCPChar, PROPCH_DAMCOLD, pBaseCCPChar), + (int)GetPropNum(pCCPChar, PROPCH_DAMPOISON, pBaseCCPChar), + (int)GetPropNum(pCCPChar, PROPCH_DAMENERGY, pBaseCCPChar) + ); + } - if (fElemental) - { - if (GetPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 100, 0, 0, 0, 0, static_cast(0x32), static_cast(0x10E)); + if (pWeapon) + { + bool fElemental = IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE); + + if (fElemental) + { + if (GetPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 100, 0, 0, 0, 0, static_cast(0x32), static_cast(0x10E)); - if (GetPropNum(pCCPChar, PROPCH_HITAREAFIRE, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 100, 0, 0, 0, static_cast(0x488), static_cast(0x11D)); + if (GetPropNum(pCCPChar, PROPCH_HITAREAFIRE, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 100, 0, 0, 0, static_cast(0x488), static_cast(0x11D)); - if (GetPropNum(pCCPChar, PROPCH_HITAREACOLD, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 100, 0, 0, static_cast(0x834), static_cast(0xFC)); + if (GetPropNum(pCCPChar, PROPCH_HITAREACOLD, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 100, 0, 0, static_cast(0x834), static_cast(0xFC)); - if (GetPropNum(pCCPChar, PROPCH_HITAREAPOISON, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 0, 100, 0, static_cast(0x48E), static_cast(0x205)); + if (GetPropNum(pCCPChar, PROPCH_HITAREAPOISON, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 0, 100, 0, static_cast(0x48E), static_cast(0x205)); - if (GetPropNum(pCCPChar, PROPCH_HITAREAENERGY, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 0, 0, 100, static_cast(0x78), static_cast(0x1F1)); + if (GetPropNum(pCCPChar, PROPCH_HITAREAENERGY, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 0, 0, 100, static_cast(0x78), static_cast(0x1F1)); - } + } - if (GetPropNum(pCCPChar, PROPCH_HITDISPEL, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnSpellEffect(SPELL_Dispel, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + if (GetPropNum(pCCPChar, PROPCH_HITDISPEL, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Dispel, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); - if (GetPropNum(pCCPChar, PROPCH_HITFIREBALL, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnSpellEffect(SPELL_Fireball, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + if (GetPropNum(pCCPChar, PROPCH_HITFIREBALL, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Fireball, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); - if (GetPropNum(pCCPChar, PROPCH_HITHARM, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnSpellEffect(SPELL_Harm, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + if (GetPropNum(pCCPChar, PROPCH_HITHARM, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Harm, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); - if (GetPropNum(pCCPChar, PROPCH_HITLIGHTNING, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnSpellEffect(SPELL_Lightning, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + if (GetPropNum(pCCPChar, PROPCH_HITLIGHTNING, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Lightning, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); - if (GetPropNum(pCCPChar, PROPCH_HITMAGICARROW, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnSpellEffect(SPELL_Magic_Arrow, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); - } + if (GetPropNum(pCCPChar, PROPCH_HITMAGICARROW, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnSpellEffect(SPELL_Magic_Arrow, this, Skill_GetAdjusted(SKILL_MAGERY), pWeapon); + } // Make blood effects if ( pCharTarg->_wBloodHue != (HUE_TYPE)(-1) ) From ab95a24ce64abc658d865c5a6be74ee45c0b3521 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Sun, 15 Oct 2023 14:07:30 -0400 Subject: [PATCH 03/13] Reflect only physical damage --- src/game/chars/CCharAct.cpp | 40 ++++++++++++++++++++++++----------- src/game/chars/CCharFight.cpp | 21 +++++++++--------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/game/chars/CCharAct.cpp b/src/game/chars/CCharAct.cpp index 61be7fb47..a9570dfc0 100644 --- a/src/game/chars/CCharAct.cpp +++ b/src/game/chars/CCharAct.cpp @@ -537,6 +537,22 @@ void CChar::OnRemoveObj( CSObjContRec* pObRec ) // Override this = called when r ModPropNum(pCCPChar, PROPCH_DAMPOISON, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMPOISON, pItemBaseCCPItemEquippable)); ModPropNum(pCCPChar, PROPCH_DAMENERGY, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + + ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREACOLD, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + + ModPropNum(pCCPChar, PROPCH_HITFIREBALL, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITHARM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + + ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + if (pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_NIGHTSIGHT, pItemBaseCCPItemEquippable)) { StatFlag_Mod(STATF_NIGHTSIGHT, 0); @@ -2197,21 +2213,21 @@ bool CChar::ItemEquip( CItem * pItem, CChar * pCharMsg, bool fFromDClick ) ModPropNum(pCCPChar, PROPCH_DAMPOISON, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMPOISON, pItemBaseCCPItemEquippable)); ModPropNum(pCCPChar, PROPCH_DAMENERGY, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREACOLD, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREACOLD, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITFIREBALL, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITHARM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITFIREBALL, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITHARM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, +pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index 20e062875..752eb94a2 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -2202,17 +2202,16 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg ) int iTargReflectPhysicalDam =pCharTarg->GetPropNum(pCCPCharTarg, PROPCH_REFLECTPHYSICALDAM, pBaseCCPCharTarg); if (iTargReflectPhysicalDam) { - // REFLECTPHYSICALDAM suppose to reflect only physical? How we block other damage here? - OnTakeDamage( - iDmg * iTargReflectPhysicalDam / 100, - this, - iDmgType, - (int)GetPropNum(pCCPChar, PROPCH_DAMPHYSICAL, pBaseCCPChar), - (int)GetPropNum(pCCPChar, PROPCH_DAMFIRE, pBaseCCPChar), - (int)GetPropNum(pCCPChar, PROPCH_DAMCOLD, pBaseCCPChar), - (int)GetPropNum(pCCPChar, PROPCH_DAMPOISON, pBaseCCPChar), - (int)GetPropNum(pCCPChar, PROPCH_DAMENERGY, pBaseCCPChar) - ); + // REFLECTPHYSICALDAM suppose to reflect only physical (A physical blow of some sort.) + if (iDmgType & (DAMAGE_HIT_BLUNT | DAMAGE_HIT_PIERCE | DAMAGE_HIT_SLASH)) + { + OnTakeDamage( + iDmg * iTargReflectPhysicalDam / 100, + this, + iDmgType, + 100,0,0,0,0 + ); + } } if (pWeapon) From c1ae2565a405f9a015ac19ade06146a6c1f45462 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Mon, 16 Oct 2023 20:15:04 -0400 Subject: [PATCH 04/13] Move REFLECTPHYSICALDAM on OnTakeDamage --- src/game/chars/CCharFight.cpp | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index 752eb94a2..c5c7d96a5 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -939,8 +939,20 @@ int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhys pSrc->Sound(0x1F1); pSrc->Effect(EFFECT_OBJ, ITEMID_FX_CURSE_EFFECT, this, 10, 16); } - } - } + } + } + // Check if REFLECTPHYSICALDAM will reflect some damage back. + // Preventing recurrent reflection with DAMAGE_REACTIVE. + if (!(uType & DAMAGE_REACTIVE)) + { + int iReflectPhysical = GetPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, pBaseCCPChar); + if (iReflectPhysical) + { + int iReflectPhysicalDam = (iDmg * iReflectPhysical) / 100; + pSrc->OnTakeDamage(iReflectPhysicalDam, this, (DAMAGE_TYPE)(DAMAGE_FIXED | DAMAGE_REACTIVE), iDmgPhysical, iDmgFire, iDmgCold, iDmgPoison, iDmgEnergy); + } + } + } } @@ -2196,24 +2208,6 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg ) if ( fMakeLeechSound ) Sound(0x44d); - // REFLECTPHYSICALDAM - const CCPropsChar* pCCPCharTarg = pCharTarg->GetComponentProps(); - const CCPropsChar* pBaseCCPCharTarg = pCharTarg->Base_GetDef()->GetComponentProps(); - int iTargReflectPhysicalDam =pCharTarg->GetPropNum(pCCPCharTarg, PROPCH_REFLECTPHYSICALDAM, pBaseCCPCharTarg); - if (iTargReflectPhysicalDam) - { - // REFLECTPHYSICALDAM suppose to reflect only physical (A physical blow of some sort.) - if (iDmgType & (DAMAGE_HIT_BLUNT | DAMAGE_HIT_PIERCE | DAMAGE_HIT_SLASH)) - { - OnTakeDamage( - iDmg * iTargReflectPhysicalDam / 100, - this, - iDmgType, - 100,0,0,0,0 - ); - } - } - if (pWeapon) { bool fElemental = IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE); From ffe9f068acd14757f156a81a9f07efc22b2382b3 Mon Sep 17 00:00:00 2001 From: Jhobean <51728381+Jhobean@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:01:37 -0400 Subject: [PATCH 05/13] Update CCharAct.cpp --- src/game/chars/CCharAct.cpp | 51 ++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/game/chars/CCharAct.cpp b/src/game/chars/CCharAct.cpp index a9570dfc0..cf18802e5 100644 --- a/src/game/chars/CCharAct.cpp +++ b/src/game/chars/CCharAct.cpp @@ -537,21 +537,21 @@ void CChar::OnRemoveObj( CSObjContRec* pObRec ) // Override this = called when r ModPropNum(pCCPChar, PROPCH_DAMPOISON, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMPOISON, pItemBaseCCPItemEquippable)); ModPropNum(pCCPChar, PROPCH_DAMENERGY, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHMANA, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHSTAM, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREACOLD, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAPHYSICAL, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAFIRE, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREACOLD, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREACOLD, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAPOISON, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITFIREBALL, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITHARM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITFIREBALL, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITFIREBALL, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITHARM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITHARM, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLIGHTNING, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITMAGICARROW, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_REFLECTPHYSICALDAM, pItemBaseCCPItemEquippable)); if (pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_NIGHTSIGHT, pItemBaseCCPItemEquippable)) { @@ -2213,24 +2213,23 @@ bool CChar::ItemEquip( CItem * pItem, CChar * pCharMsg, bool fFromDClick ) ModPropNum(pCCPChar, PROPCH_DAMPOISON, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMPOISON, pItemBaseCCPItemEquippable)); ModPropNum(pCCPChar, PROPCH_DAMENERGY, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHMANA, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHSTAM, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREACOLD, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAPHYSICAL, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAFIRE, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREACOLD, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREACOLD, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAPOISON, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITFIREBALL, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITHARM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITFIREBALL, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITFIREBALL, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITHARM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITHARM, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLIGHTNING, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITMAGICARROW, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); + ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_REFLECTPHYSICALDAM, pItemBaseCCPItemEquippable)); - - + if ( pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_NIGHTSIGHT, pItemBaseCCPItemEquippable) ) { StatFlag_Mod( STATF_NIGHTSIGHT, 1 ); From fced243c0517eeb83f39f110fe1cf9591e4a31b5 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Tue, 17 Oct 2023 19:19:18 -0400 Subject: [PATCH 06/13] Update --- Changelog.txt | 1 - src/game/chars/CCharAct.cpp | 33 --------------------------------- 2 files changed, 34 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 3d6a75eba..95cf86dbc 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3388,4 +3388,3 @@ Additionally, the problem of zig-zag issue following in the South direction has 17-10-2023, Jhobean - Added: Item properties functionnality:HITAREAPHYSICAL,HITAREAFIRE,HITAREACOLD,HITAREAPOISON,HITAREAENERGY,HITFIREBALL,HITHARM,HITLIGHTNING,HITMAGICARROW,REFLECTPHYSICALDAM -- Fixed: Item properties functionnality:HITLEECHMANA,HITLEECHSTAM diff --git a/src/game/chars/CCharAct.cpp b/src/game/chars/CCharAct.cpp index cf18802e5..625ea470a 100644 --- a/src/game/chars/CCharAct.cpp +++ b/src/game/chars/CCharAct.cpp @@ -537,22 +537,6 @@ void CChar::OnRemoveObj( CSObjContRec* pObRec ) // Override this = called when r ModPropNum(pCCPChar, PROPCH_DAMPOISON, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMPOISON, pItemBaseCCPItemEquippable)); ModPropNum(pCCPChar, PROPCH_DAMENERGY, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHMANA, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHSTAM, pItemBaseCCPItemEquippable)); - - ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAPHYSICAL, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAFIRE, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREACOLD, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREACOLD, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAPOISON, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAENERGY, pItemBaseCCPItemEquippable)); - - ModPropNum(pCCPChar, PROPCH_HITFIREBALL, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITFIREBALL, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITHARM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITHARM, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLIGHTNING, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITMAGICARROW, pItemBaseCCPItemEquippable)); - - ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, - pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_REFLECTPHYSICALDAM, pItemBaseCCPItemEquippable)); - if (pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_NIGHTSIGHT, pItemBaseCCPItemEquippable)) { StatFlag_Mod(STATF_NIGHTSIGHT, 0); @@ -2212,23 +2196,6 @@ bool CChar::ItemEquip( CItem * pItem, CChar * pCharMsg, bool fFromDClick ) ModPropNum(pCCPChar, PROPCH_DAMCOLD, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMCOLD, pItemBaseCCPItemEquippable)); ModPropNum(pCCPChar, PROPCH_DAMPOISON, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMPOISON, pItemBaseCCPItemEquippable)); ModPropNum(pCCPChar, PROPCH_DAMENERGY, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_DAMENERGY, pItemBaseCCPItemEquippable)); - - ModPropNum(pCCPChar, PROPCH_HITLEECHMANA, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHMANA, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLEECHSTAM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLEECHSTAM, pItemBaseCCPItemEquippable)); - - ModPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAPHYSICAL, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAFIRE, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAFIRE, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREACOLD, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREACOLD, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAPOISON, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAPOISON, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITAREAENERGY, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITAREAENERGY, pItemBaseCCPItemEquippable)); - - ModPropNum(pCCPChar, PROPCH_HITFIREBALL, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITFIREBALL, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITHARM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITHARM, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITLIGHTNING, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITLIGHTNING, pItemBaseCCPItemEquippable)); - ModPropNum(pCCPChar, PROPCH_HITMAGICARROW, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_HITMAGICARROW, pItemBaseCCPItemEquippable)); - - ModPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, + pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_REFLECTPHYSICALDAM, pItemBaseCCPItemEquippable)); - if ( pItem->GetPropNum(pItemCCPItemEquippable, PROPIEQUIP_NIGHTSIGHT, pItemBaseCCPItemEquippable) ) { From 97c3f04028990b446bd5927eeb3f7735379fe172 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Wed, 25 Oct 2023 21:18:08 -0400 Subject: [PATCH 07/13] Add mypet check on area damage and capped MAX 250 on Reflec physical --- src/game/chars/CCharFight.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index c5c7d96a5..1ef90beb8 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -945,7 +945,8 @@ int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhys // Preventing recurrent reflection with DAMAGE_REACTIVE. if (!(uType & DAMAGE_REACTIVE)) { - int iReflectPhysical = GetPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, pBaseCCPChar); + int iReflectPhysical = minimum(GetPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, pBaseCCPChar),250); //Capped to 250 + if (iReflectPhysical) { int iReflectPhysicalDam = (iDmg * iReflectPhysical) / 100; @@ -1000,8 +1001,7 @@ void CChar::OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgP ADDTOCALLSTACK("CChar::OnTakeDamageArea"); bool fMakeSound = false; - // Like this area damage touch everyone! Pet, NPC etc We should ignore pet and Criminal action? - + int iDistance = 5; if (IsAosFlagEnabled(FEATURE_AOS_DAMAGE)) iDistance=10; // 5 for ML and 10 for aos @@ -1012,10 +1012,14 @@ void CChar::OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgP CChar* pChar = AreaChars.GetChar(); if (!pChar) break; - if (!pChar->CanSeeLOS(pSrc)) - break; if ((pChar == this) || (pChar == pSrc)) continue; + if (pChar->NPC_IsOwnedBy(pSrc,false)) // it's my pet? + continue; + + if (!pChar->CanSeeLOS(pSrc)) //Avoid hit someone in nearby house + continue; + // FIXME. On UO guide damage occur to nearby targets the wielder can legally attack. How can add legaly check? pChar->OnTakeDamage(iDmg, pSrc, uType, iDmgPhysical, iDmgFire, iDmgCold, iDmgPoison, iDmgEnergy); pChar->Effect(EFFECT_OBJ, ITEMID_FX_SPARKLE_2, this, 1, 15, false, effectHue); From fc15cb330287af1d6c57c57e7d801a9c2088dab2 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Fri, 3 Nov 2023 22:20:08 -0400 Subject: [PATCH 08/13] Add Canhit check --- src/game/chars/CCharFight.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index 1ef90beb8..823bad2df 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -1008,15 +1008,19 @@ void CChar::OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgP CWorldSearch AreaChars(GetTopPoint(), iDistance); for (;;) + //pSrc = char make the attach + //pChar = char get scan on loop iteration + //this = Char get the initial hit { CChar* pChar = AreaChars.GetChar(); if (!pChar) break; if ((pChar == this) || (pChar == pSrc)) continue; - if (pChar->NPC_IsOwnedBy(pSrc,false)) // it's my pet? + if (pChar->Fight_CanHit(pSrc,true) == WAR_SWING_INVALID) //Check if target can be hit (IsDisconnected, stone, safe zone etc) + continue; + if (!pChar->m_pClient && pChar->NPC_IsOwnedBy(pSrc,false)) // it's my pet? continue; - if (!pChar->CanSeeLOS(pSrc)) //Avoid hit someone in nearby house continue; // FIXME. On UO guide damage occur to nearby targets the wielder can legally attack. How can add legaly check? From 5664db38bde7651cf4407c331eff7bfea61ed249 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Fri, 10 Nov 2023 13:09:17 -0500 Subject: [PATCH 09/13] Add check of criminal act --- src/game/chars/CCharFight.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index 823bad2df..e91fede2a 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -1017,13 +1017,14 @@ void CChar::OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgP break; if ((pChar == this) || (pChar == pSrc)) continue; - if (pChar->Fight_CanHit(pSrc,true) == WAR_SWING_INVALID) //Check if target can be hit (IsDisconnected, stone, safe zone etc) + if (pChar->Fight_CanHit(pSrc,true) == WAR_SWING_INVALID) //Check if target can be hit (I am invul, stone etc. Target is Disconnected,safe zone etc) continue; if (!pChar->m_pClient && pChar->NPC_IsOwnedBy(pSrc,false)) // it's my pet? continue; if (!pChar->CanSeeLOS(pSrc)) //Avoid hit someone in nearby house continue; - // FIXME. On UO guide damage occur to nearby targets the wielder can legally attack. How can add legaly check? + if (pChar->Noto_CalcFlag(pSrc) == NOTO_GOOD) //Avoid to hit someone we can't legally attack (Same NOT , same guild, same party etc) + continue; pChar->OnTakeDamage(iDmg, pSrc, uType, iDmgPhysical, iDmgFire, iDmgCold, iDmgPoison, iDmgEnergy); pChar->Effect(EFFECT_OBJ, ITEMID_FX_SPARKLE_2, this, 1, 15, false, effectHue); From 3686e9ffb71acfea5ba8c99b9d55e24c636c3600 Mon Sep 17 00:00:00 2001 From: Jhobean <51728381+Jhobean@users.noreply.github.com> Date: Fri, 17 Nov 2023 14:35:33 -0500 Subject: [PATCH 10/13] Use STD function instead of internal --- src/game/chars/CCharFight.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index 247f8e2cc..d80c682bf 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -945,7 +945,7 @@ int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhys // Preventing recurrent reflection with DAMAGE_REACTIVE. if (!(uType & DAMAGE_REACTIVE)) { - int iReflectPhysical = minimum(GetPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, pBaseCCPChar),250); //Capped to 250 + int iReflectPhysical = (ushort)std::min(GetPropNum(pCCPChar, PROPCH_REFLECTPHYSICALDAM, pBaseCCPChar),250); //Capped to 250 if (iReflectPhysical) { From 5bd11e4d4b5098fd981e686b4c7c207b75e87cc1 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Mon, 11 Dec 2023 07:56:25 -0500 Subject: [PATCH 11/13] Move CanseeLos check at the end --- src/game/chars/CCharFight.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index d80c682bf..bd19b1e7d 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -1021,10 +1021,10 @@ void CChar::OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgP continue; if (!pChar->m_pClient && pChar->NPC_IsOwnedBy(pSrc,false)) // it's my pet? continue; - if (!pChar->CanSeeLOS(pSrc)) //Avoid hit someone in nearby house - continue; if (pChar->Noto_CalcFlag(pSrc) == NOTO_GOOD) //Avoid to hit someone we can't legally attack (same guild, same party, Vendor etc) continue; + if (!pChar->CanSeeLOS(pSrc)) //Avoid hit someone in nearby house + continue; pChar->OnTakeDamage(iDmg, pSrc, uType, iDmgPhysical, iDmgFire, iDmgCold, iDmgPoison, iDmgEnergy); pChar->Effect(EFFECT_OBJ, ITEMID_FX_SPARKLE_2, this, 1, 15, false, effectHue); From f5dcb5d77d70b0fd5f21d83ef5d7398858682a13 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Wed, 13 Dec 2023 21:07:01 -0500 Subject: [PATCH 12/13] Set the correct damage type on areadamage --- src/game/chars/CCharFight.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index bd19b1e7d..45c578de9 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -2224,19 +2224,19 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg ) if (fElemental) { if (GetPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 100, 0, 0, 0, 0, static_cast(0x32), static_cast(0x10E)); + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_HIT_BLUNT, 100, 0, 0, 0, 0, static_cast(0x32), static_cast(0x10E)); if (GetPropNum(pCCPChar, PROPCH_HITAREAFIRE, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 100, 0, 0, 0, static_cast(0x488), static_cast(0x11D)); + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_FIRE, 0, 100, 0, 0, 0, static_cast(0x488), static_cast(0x11D)); if (GetPropNum(pCCPChar, PROPCH_HITAREACOLD, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 100, 0, 0, static_cast(0x834), static_cast(0xFC)); + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_COLD, 0, 0, 100, 0, 0, static_cast(0x834), static_cast(0xFC)); if (GetPropNum(pCCPChar, PROPCH_HITAREAPOISON, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 0, 100, 0, static_cast(0x48E), static_cast(0x205)); + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_POISON, 0, 0, 0, 100, 0, static_cast(0x48E), static_cast(0x205)); if (GetPropNum(pCCPChar, PROPCH_HITAREAENERGY, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_GENERAL, 0, 0, 0, 0, 100, static_cast(0x78), static_cast(0x1F1)); + pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_ENERGY, 0, 0, 0, 0, 100, static_cast(0x78), static_cast(0x1F1)); } From cc3bb50da2325dc6915ceac096d8e3c0f9944bd7 Mon Sep 17 00:00:00 2001 From: Jhobean Date: Thu, 14 Dec 2023 07:37:03 -0500 Subject: [PATCH 13/13] Change function name and Mode physical damage out of elemental engine --- src/game/chars/CChar.h | 2 +- src/game/chars/CCharFight.cpp | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/game/chars/CChar.h b/src/game/chars/CChar.h index 378e368ce..b1f125c7b 100644 --- a/src/game/chars/CChar.h +++ b/src/game/chars/CChar.h @@ -1300,7 +1300,7 @@ public: void StatFlag_Mod(uint64 uiStatFlag, bool fMod) noexcept; // Outside events that occur to us. int OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhysical = 0, int iDmgFire = 0, int iDmgCold = 0, int iDmgPoison = 0, int iDmgEnergy = 0, SPELL_TYPE spell = SPELL_NONE ); - void OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgPhysical = 0, int iDmgFire = 0, int iDmgCold = 0, int iDmgPoison = 0, int iDmgEnergy = 0, HUE_TYPE effectHue = HUE_DEFAULT, SOUND_TYPE effectSound = SOUND_NONE); + void OnTakeDamageInflictArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgPhysical = 0, int iDmgFire = 0, int iDmgCold = 0, int iDmgPoison = 0, int iDmgEnergy = 0, HUE_TYPE effectHue = HUE_DEFAULT, SOUND_TYPE effectSound = SOUND_NONE); void OnHarmedBy( CChar * pCharSrc ); bool OnAttackedBy( CChar * pCharSrc, bool fPetsCommand = false, bool fShouldReveal = true ); diff --git a/src/game/chars/CCharFight.cpp b/src/game/chars/CCharFight.cpp index 460d8d9d0..90fd013d4 100644 --- a/src/game/chars/CCharFight.cpp +++ b/src/game/chars/CCharFight.cpp @@ -996,9 +996,9 @@ int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhys return iDmg; } -void CChar::OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgPhysical, int iDmgFire, int iDmgCold, int iDmgPoison, int iDmgEnergy, HUE_TYPE effectHue, SOUND_TYPE effectSound) +void CChar::OnTakeDamageInflictArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgPhysical, int iDmgFire, int iDmgCold, int iDmgPoison, int iDmgEnergy, HUE_TYPE effectHue, SOUND_TYPE effectSound) { - ADDTOCALLSTACK("CChar::OnTakeDamageArea"); + ADDTOCALLSTACK("CChar::OnTakeDamageInflictArea"); bool fMakeSound = false; @@ -1026,6 +1026,10 @@ void CChar::OnTakeDamageArea(int iDmg, CChar* pSrc, DAMAGE_TYPE uType, int iDmgP if (!pChar->CanSeeLOS(pSrc)) //Avoid hit someone in nearby house continue; + /* On servUo they modify the damage depending of the distance with this formula + There no info about this on UO Wiki + damage *= ( 11 - from.GetDistanceToSqrt( m ) ) / 10; */ + pChar->OnTakeDamage(iDmg, pSrc, uType, iDmgPhysical, iDmgFire, iDmgCold, iDmgPoison, iDmgEnergy); pChar->Effect(EFFECT_OBJ, ITEMID_FX_SPARKLE_2, this, 1, 15, false, effectHue); fMakeSound = true; @@ -2220,24 +2224,25 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg ) if (pWeapon) { - bool fElemental = IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE); + + if (GetPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, pBaseCCPChar) > Calc_GetRandLLVal(100)) + pCharTarg->OnTakeDamageInflictArea(iDmg / 2, this, DAMAGE_HIT_BLUNT, 100, 0, 0, 0, 0, static_cast(0x32), static_cast(0x10E)); - if (fElemental) + bool fElemental = IsSetCombatFlags(COMBAT_ELEMENTAL_ENGINE); + if (fElemental) { - if (GetPropNum(pCCPChar, PROPCH_HITAREAPHYSICAL, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_HIT_BLUNT, 100, 0, 0, 0, 0, static_cast(0x32), static_cast(0x10E)); if (GetPropNum(pCCPChar, PROPCH_HITAREAFIRE, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_FIRE, 0, 100, 0, 0, 0, static_cast(0x488), static_cast(0x11D)); + pCharTarg->OnTakeDamageInflictArea(iDmg / 2, this, DAMAGE_FIRE, 0, 100, 0, 0, 0, static_cast(0x488), static_cast(0x11D)); if (GetPropNum(pCCPChar, PROPCH_HITAREACOLD, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_COLD, 0, 0, 100, 0, 0, static_cast(0x834), static_cast(0xFC)); + pCharTarg->OnTakeDamageInflictArea(iDmg / 2, this, DAMAGE_COLD, 0, 0, 100, 0, 0, static_cast(0x834), static_cast(0xFC)); if (GetPropNum(pCCPChar, PROPCH_HITAREAPOISON, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_POISON, 0, 0, 0, 100, 0, static_cast(0x48E), static_cast(0x205)); + pCharTarg->OnTakeDamageInflictArea(iDmg / 2, this, DAMAGE_POISON, 0, 0, 0, 100, 0, static_cast(0x48E), static_cast(0x205)); if (GetPropNum(pCCPChar, PROPCH_HITAREAENERGY, pBaseCCPChar) > Calc_GetRandLLVal(100)) - pCharTarg->OnTakeDamageArea(iDmg / 2, this, DAMAGE_ENERGY, 0, 0, 0, 0, 100, static_cast(0x78), static_cast(0x1F1)); + pCharTarg->OnTakeDamageInflictArea(iDmg / 2, this, DAMAGE_ENERGY, 0, 0, 0, 0, 100, static_cast(0x78), static_cast(0x1F1)); }