summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors/BehaviorBrave.cpp
blob: 6aba310a1bc25e458828f4f60612fda571843632 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "Globals.h"  // NOTE: MSVC stupidness requires this to be the same across all modules

#include "BehaviorBrave.h"
#include "BehaviorAttacker.h"
#include "../Monster.h"
#include "../../Entities/Entity.h"

void cBehaviorBrave::AttachToMonster(cMonster & a_Parent)
{
	m_Parent = &a_Parent;
	m_Parent->AttachDoTakeDamageBehavior(this);
}




void cBehaviorBrave::DoTakeDamage(TakeDamageInfo & a_TDI)
{
	cBehaviorAttacker * AttackBehavior = m_Parent->GetBehaviorAttacker();
	if ((AttackBehavior != nullptr) && (a_TDI.Attacker != m_Parent) &&
		(a_TDI.Attacker != nullptr) && (a_TDI.Attacker->IsPawn())
	)
	{
			AttackBehavior->SetTarget(static_cast<cPawn*>(a_TDI.Attacker));
	}
}