blob: 74eee0e17b5c115de0bfd3854bdb6120df197fd2 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "BehaviorAggressive.h"
#include "BehaviorChaser.h"
#include "../Monster.h"
#include "../../Chunk.h"
#include "../../Entities/Player.h"
cBehaviorAggressive::cBehaviorAggressive(cMonster * a_Parent) : m_Parent(a_Parent)
{
ASSERT(m_Parent != nullptr);
m_ParentChaser = m_Parent->GetBehaviorChaser();
ASSERT(m_ParentChaser != nullptr);
}
bool cBehaviorAggressive::ActiveTick()
{
// Target something new if we have no target
if (m_ParentChaser->GetTarget() == nullptr)
{
m_ParentChaser->SetTarget(FindNewTarget());
}
return false;
}
void cBehaviorAggressive::Destroyed()
{
m_Target = nullptr;
}
bool cBehaviorAggressive::FindNewTarget()
{
cPlayer * Closest = m_Parent->GetNearestPlayer();
return Closest; // May be null
}
|