From 912a1e7adc650d20b0302a3dfe45816b5e541bc7 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 21 Dec 2012 11:04:08 +0000 Subject: Refactored the TakeDamage API to take equipped weapon and armor into consideration (PvP untested) http://forum.mc-server.org/showthread.php?tid=625 git-svn-id: http://mc-server.googlecode.com/svn/trunk@1087 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Mobs/Monster.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'source/Mobs/Monster.cpp') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index 82d69df57..88cfcd992 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -28,8 +28,8 @@ -cMonster::cMonster() - : m_Target(0) +cMonster::cMonster(void) + : m_Target(NULL) , m_bMovingToDestination(false) , m_DestinationTime( 0 ) , m_Gravity( -9.81f) @@ -318,20 +318,23 @@ void cMonster::HandlePhysics(float a_Dt) -void cMonster::TakeDamage(int a_Damage, cEntity* a_Instigator) +void cMonster::DoTakeDamage(TakeDamageInfo & a_TDI) { - cPawn::TakeDamage( a_Damage, a_Instigator ); - m_Target = a_Instigator; - AddReference( m_Target ); + super::DoTakeDamage(a_TDI); + if (a_TDI.Attacker != NULL) + { + m_Target = a_TDI.Attacker; + AddReference(m_Target); + } } -void cMonster::KilledBy( cEntity* a_Killer ) +void cMonster::KilledBy(cPawn * a_Killer) { - cPawn::KilledBy( a_Killer ); + super::KilledBy(a_Killer); m_DestroyTimer = 0; } @@ -513,7 +516,7 @@ void cMonster::Attack(float a_Dt) { // Setting this higher gives us more wiggle room for attackrate m_AttackInterval = 0.0; - ((cPawn *)m_Target)->TakeDamage((int)m_AttackDamage, this); + ((cPawn *)m_Target)->TakeDamage(*this); } } -- cgit v1.2.3