-
Notifications
You must be signed in to change notification settings - Fork 0
/
AIHORSE.CPP
110 lines (87 loc) · 3.37 KB
/
AIHORSE.CPP
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* ========================================================================
Copyright (c) 1990,1996 Synergistic Software
All Rights Reserved
========================================================================
Filename: aihorse.cpp -
Author: Greg Hightower
========================================================================
Contains the following general functions:
======================================================================== */
/* ------------------------------------------------------------------------
Includes
------------------------------------------------------------------------ */
#include "avatar.hxx"
#include "sound.hxx"
/* ------------------------------------------------------------------------
Notes
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Defines and Compile Flags
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Macros
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Prototypes
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Global Variables
------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------
Local Variables
------------------------------------------------------------------------ */
/* ========================================================================
Function - Horse
Description - AI function to have a riderless horse run off the battle field
Returns - Current state
======================================================================== */
void CAvatar::Horse (CAvatar *pAvatar, CAvatar::AISTATUS Status)
{
MOVEMENT_RATE myRate;
switch( Status )
{
case AI_INIT:
myRate = pAvatar->mfGetMarchRate();
pAvatar->fHorse.TargetX = (pAvatar->mfX() > 0) ? myRate : -myRate;
pAvatar->Status = AI_MOVING;
pAvatar->mfStartAnimationLoop(MARCHSEQ);
pAvatar->hEnemy = fERROR;
break;
case AI_RELEASE:
pAvatar->Status = AI_INIT;
break;
case AI_BEGIN_PAUSE:
case AI_PAUSED:
case AI_END_PAUSE:
case AI_BEGIN_LISTEN:
case AI_LISTEN:
case AI_END_LISTEN:
case AI_BEGIN_LISTEN_BOW:
case AI_END_LISTEN_BOW:
case AI_ROTATE_TO_CAMERA:
case AI_RETURN_TO_POSITION:
case AI_FALLING:
case AI_DEAD:
case AI_DEFEND:
case AI_ATTACK:
case AI_SEARCH:
break;
case AI_MOVING: // run off the field
//GEH check to see this horse is even remotely able to be seen
// if not, just shoot him
if( abs(pAvatar->mfX()) > 3000 ||
abs(pAvatar->mfY()) > 3000 ||
!pAvatar->mfIsVisible() )
{
pAvatar->DeleteAvatar(pAvatar->hThis);
return;
}
pAvatar->mfStartAnimationOnce(MARCHSEQ);
LONG newx = pAvatar->mfX() + pAvatar->fHorse.TargetX;
LONG newy = pAvatar->mfY() - 10 + random(20);
pAvatar->FaceTo(newx, newy);
myRate = pAvatar->mfGetMarchRate();
pAvatar->MoveToward(newx,newy,0,myRate);
break;
}
}