Skip to content

Commit

Permalink
Do not apply damage to Claw on contact with enemy actors which are no…
Browse files Browse the repository at this point in the history
…t in combat with him
  • Loading branch information
pjasicek committed Aug 20, 2017
1 parent 1f984ef commit 8e2041d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Binary file modified Build_Release/ASSETS.ZIP
Binary file not shown.
2 changes: 1 addition & 1 deletion Build_Release/ASSETS/ActorPrototypes/BASE_ENEMY.XML
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<FixtureType>DamageAura</FixtureType>
<CollisionShape>Rectangle</CollisionShape>
<IsSensor>true</IsSensor>
<Size width="40" height="85" />
<Size width="40" height="50" />
<Offset x="0" y="0" />
<CollisionFlag>262144</CollisionFlag>
<CollisionMask>1048578</CollisionMask>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../../Actor.h"
#include "../../../GameApp/BaseGameApp.h"
#include "../../../GameApp/BaseGameLogic.h"
#include "../EnemyAI/EnemyAIComponent.h"

const char* BaseAuraComponent::g_Name = "BaseAuraComponent";
const char* DamageAuraComponent::g_Name = "DamageAuraComponent";
Expand Down Expand Up @@ -174,7 +175,8 @@ void BaseAuraComponent::SetEnabled(bool enabled)

DamageAuraComponent::DamageAuraComponent()
:
m_Damage(0)
m_Damage(0),
m_bIsEnemyUnit(false)
{
}

Expand All @@ -189,7 +191,7 @@ bool DamageAuraComponent::VDelegateInit(TiXmlElement* data)

void DamageAuraComponent::VPostInit()
{

m_bIsEnemyUnit = MakeStrongPtr(_owner->GetComponent<EnemyAIComponent>()) != nullptr;
}

void DamageAuraComponent::VCreateInheritedXmlElements(TiXmlElement* pBaseElement)
Expand All @@ -203,6 +205,19 @@ void DamageAuraComponent::VOnAuraApply(Actor* pActorInAura)
MakeStrongPtr(pActorInAura->GetComponent<HealthComponent>(HealthComponent::g_Name));
if (pHealthComponent)
{
// If owner of this aura is some Enemy and he is not in combat, do not apply this aura
if (m_bIsEnemyUnit)
{
EnemyAIComponent* pEnemyAIComponent = MakeStrongPtr(_owner->GetComponent<EnemyAIComponent>()).get();
assert(pEnemyAIComponent != NULL);
if (pEnemyAIComponent->GetCurrentState() == NULL ||
pEnemyAIComponent->GetCurrentState()->VGetStateType() == EnemyAIState_None ||
pEnemyAIComponent->GetCurrentState()->VGetStateType() == EnemyAIState_Patrolling)
{
return;
}
}

// TODO: In original game this causes the damage impact anim effect
pHealthComponent->AddHealth((-1) * m_Damage, DamageType_None, Point(0, 0), _owner->GetGUID());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class DamageAuraComponent : public BaseAuraComponent

private:
int m_Damage;
bool m_bIsEnemyUnit;
};

#endif

0 comments on commit 8e2041d

Please sign in to comment.