forked from wingzero0/GameProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActorStateMachine.h
79 lines (71 loc) · 1.94 KB
/
ActorStateMachine.h
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include "TheFlyWin32.h"
#include "FyFx.h"
#include <map>
#include <string>
#define STATEATTACK 0
#define STATEDAMAGE 1
#define STATEIDLE 2
#define STATERUN 3
#define STATECOMBATIDEL 4
#define STATEDIE 5
#define STATEGUARD 6
#define STATEVANISH 7
typedef int ActorState;
#define MAXATTACK 4
#define NORMAL_ATT 0
#define HEAVY_ATT 1
#define ULTIMATE_ATT 2
typedef int ATTACK_CODE;
#define OUTSHOT_DIS 200.0
#define SMALL_OUTSHOT_DIS 25.0
#define MAX_LIFE 100.0
#define ROBOT_ATTACKRANGE 18000.0
#define STUCK_SHOT 0
#define SMALL_SHOT 1
#define BIG_SHOT 2
typedef int SHOT_CODE;
// actor free meaning it can do anything by the controller.
// actor stay meaning that it can't be move beacuse of being attacked.
class ActorStateMachine
{
public:
ActorState state;
ACTORid character;
int attackKeyQueue[MAXATTACK];
BOOL newAttack;
BOOL effectiveAttack;
int life;
protected:
int currentAttackIndex;
int lastAttackIndex;
BOOL attackDisable;
BOOL startAttack;
float lastAttackFrame;
BOOL initActionIDMap(char *ActionFilename);
std::map<std::string, ACTIONid> ActionIDMap;
virtual BOOL PlayAttackAction(int skip);
BOOL SetNewAction(std::string systemName);
virtual BOOL UpdateEffectiveAttack();
OBJECTid bloodID;
virtual BOOL initLife();
eF3DFX *fxDie;
public:
ActorStateMachine(void);
virtual ~ActorStateMachine(void);
ActorStateMachine(ACTORid character, char * ActionFilename);
//int ChangeStateAndAction();
int ChangeState(ActorState s, BOOL forceCheck = FALSE);
BOOL CharacterSetIdle();
BOOL CharacterSetGuard();
BOOL CanBeControl();
BOOL CanWalk();
BOOL CanAttack();
int Damage();
BOOL AppendAttackCode(ATTACK_CODE code);
virtual BOOL PlayAction(int skip);
BOOL CheckEffectiveAttack();
virtual int AttackEnemy(float enemyPos[3], SHOT_CODE *shot_code = NULL); // shot_code will be assgin a value after the call
virtual void TakeDamage(int damage, SHOT_CODE shot_code, float* attackerPos);
void UpdateLifeBillboard(); // billboard
};