Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Remove sound when dodge on @GetHit Need to return 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhobean committed Sep 8, 2024
1 parent 0c4e6e3 commit dae2ad1
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions src/game/chars/CCharFight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ int CChar::CalcArmorDefense() const
// RETURN: damage done
// -1 = already dead / invalid target.
// 0 = no damage.
// 3 = Dodge the hit
// INT32_MAX = killed.
int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhysical, int iDmgFire, int iDmgCold, int iDmgPoison, int iDmgEnergy, SPELL_TYPE spell)
{
Expand Down Expand Up @@ -750,8 +751,15 @@ int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhys
CItem* pItemHit = nullptr;
if ( IsTrigUsed(TRIGGER_GETHIT) )
{
if ( OnTrigger( CTRIG_GetHit, pSrc, &Args ) == TRIGRET_RET_TRUE )
return 0;

switch (OnTrigger(CTRIG_GetHit, pSrc, &Args))
{
case TRIGRET_RET_TRUE:
return false;
case 3: //dodge
return 3;
}

iDmg = (int)(Args.m_iN1);
uType = (DAMAGE_TYPE)(Args.m_iN2);

Expand Down Expand Up @@ -1352,7 +1360,7 @@ bool CChar::Fight_Attack( CChar *pCharTarg, bool fToldByMaster )
{
ADDTOCALLSTACK("CChar::Fight_Attack");

if ( !pCharTarg || pCharTarg == this || pCharTarg->IsStatFlag(STATF_DEAD|STATF_INVUL|STATF_STONE) || IsStatFlag(STATF_DEAD) )
if ( !pCharTarg || pCharTarg == this || pCharTarg->IsStatFlag(STATF_DEAD|STATF_INVUL|STATF_STONE) )
{
// Not a valid target.
Fight_Clear(pCharTarg, true);
Expand Down Expand Up @@ -1703,6 +1711,7 @@ WAR_SWING_TYPE CChar::Fight_CanHit(CChar * pCharSrc, bool fSwingNoRange)
WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg )
{
ADDTOCALLSTACK("CChar::Fight_Hit");
bool fMakeSound = true;

if ( !pCharTarg || (pCharTarg == this) )
return WAR_SWING_INVALID;
Expand Down Expand Up @@ -1745,7 +1754,7 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg )
const CCPropsChar* pCCPChar = GetComponentProps<CCPropsChar>();
const CCPropsChar* pBaseCCPChar = Base_GetDef()->GetComponentProps<CCPropsChar>();

pCharTarg->OnTakeDamage(
if (pCharTarg->OnTakeDamage(
Fight_CalcDamage(m_uidWeapon.ItemFind()),
this,
iDmgType,
Expand All @@ -1754,8 +1763,10 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg )
(int)GetPropNum(pCCPChar, PROPCH_DAMCOLD, pBaseCCPChar),
(int)GetPropNum(pCCPChar, PROPCH_DAMPOISON, pBaseCCPChar),
(int)GetPropNum(pCCPChar, PROPCH_DAMENERGY, pBaseCCPChar)
);

) == 3) //If == 3 that mean target dodge the hit
{
fMakeSound=false;
}
return WAR_SWING_EQUIPPING;
}
}
Expand Down Expand Up @@ -2017,7 +2028,7 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg )
iSound = sm_Snd_Miss[(size_t)g_Rand.Get16ValFast(ARRAY_COUNT(sm_Snd_Miss))];
}
}
Sound(iSound);
Sound(iSound); //Sound when missing

return WAR_SWING_EQUIPPING_NOWAIT;
}
Expand Down Expand Up @@ -2164,9 +2175,6 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg )
pAmmo->ConsumeAmount(1);
}

// Hit noise (based on weapon type)
SoundChar(CRESND_HIT);

if ( pWeapon )
{
// Check if the weapon is poisoned
Expand Down Expand Up @@ -2202,7 +2210,7 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg )
// Took my swing. Do Damage !
const CCPropsChar* pCCPChar = GetComponentProps<CCPropsChar>();
const CCPropsChar* pBaseCCPChar = Base_GetDef()->GetComponentProps<CCPropsChar>();
pCharTarg->OnTakeDamage(
if (pCharTarg->OnTakeDamage(
iDmg,
this,
iDmgType,
Expand All @@ -2211,7 +2219,16 @@ WAR_SWING_TYPE CChar::Fight_Hit( CChar * pCharTarg )
(int)GetPropNum(pCCPChar, PROPCH_DAMCOLD, pBaseCCPChar),
(int)GetPropNum(pCCPChar, PROPCH_DAMPOISON, pBaseCCPChar),
(int)GetPropNum(pCCPChar, PROPCH_DAMENERGY, pBaseCCPChar)
);
) == 3) //If == 3 that mean target dodge the hit
{
fMakeSound = false;
}

// Hit noise (based on weapon type)
if (fMakeSound)
{
SoundChar(CRESND_HIT); //Sound when we hit
}

if ( iDmg > 0 )
{
Expand Down

0 comments on commit dae2ad1

Please sign in to comment.