blob: 20b60a921ca852835cbfa9b848378e0c444a9d4f (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#pragma once
class cBehaviorChaser;
#include "Behavior.h"
class cBehaviorStriker;
/** Grants chase capability to the mob. Note that this is not the same as agression!
The mob may possess this trait and not attack anyone or only attack when provoked.
Unlike most traits, this one has several forms, and therefore it is an abstract type
You should use one of its derived classes, and you cannot use it directly. */
class cBehaviorChaser : public cBehavior
{
public:
cBehaviorChaser();
void AttachToMonster(cMonster & a_Parent, cBehaviorStriker & a_ParentStriker);
// Functions our host Monster should invoke:
bool IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
void Destroyed() override;
void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
void DoTakeDamage(TakeDamageInfo & a_TDI) override;
// Our host monster will call these once it loads its config file
void SetAttackRate(float a_AttackRate);
void SetAttackRange(int a_AttackRange);
void SetAttackDamage(int a_AttackDamage);
/** Returns the target pointer, or a nullptr if we're not targeting anyone. */
cPawn * GetTarget();
/** Sets the target. */
void SetTarget(cPawn * a_Target);
protected:
void ApproachTarget();
// virtual void ApproachTarget() = 0; //mobTodo
private:
/** Our parent */
cMonster * m_Parent;
cBehaviorStriker * m_ParentStriker;
// The mob we want to attack
cPawn * m_Target;
// Target stuff
bool TargetIsInStrikeRange();
bool TargetOutOfSight();
void StrikeTarget();
// Cooldown stuff
void ResetStrikeCooldown();
// Our attacking parameters (Set by the setter methods, loaded from a config file in cMonster)
float m_AttackRate;
int m_AttackDamage;
int m_AttackRange;
int m_AttackCoolDownTicksLeft;
int m_TicksSinceLastDamaged; // How many ticks ago were we last damaged by a player?
};
|