Repository navigation
Expand file tree
/
Copy pathcharnoball.cpp
More file actions
134 lines (106 loc) · 2.98 KB
/
Copy pathcharnoball.cpp
File metadata and controls
134 lines (106 loc) · 2.98 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "Common.h"
#if 0
#include "CharNoBall.h"
#include "Globals.h"
#define CharNoBall_ACCEL GINT(0, 1311)
#define CharNoBall_STUN_TIME 15
#define CharNoBall_TILT_DAMP GINT(0, 55000)
#define CharNoBall_TILT_MAG GINT(0, 15000)
#define CharNoBall_DIE_TILT GINT(1, 40000)
#define CharNoBall_DIE_ACCEL GINT(0, 500)
#define CharNoBall_DIE_DAMP GINT(0, 26214)
//******************************************************************************************
void CCharNoBall::Init(CInitThing *i)
{
SUPERTYPE::Init(i);
mTilt = G0;
mDir = mOrientation * GVector(G0, G1, G0);
SitOnGround();
mTiltVelocity = G0;
}
//******************************************************************************************
void CCharNoBall::StateNormal()
{
// try to head towards person
GVector d = WORLD.GetPrimaryPosition() - mPos;
GINT dist = d.Magnitude();
d /= dist;
mDir = d;
GINT force = G0;
if ((dist < G(2)) &&
(mVelocity * d < G(0)))
force = G(-1); //go away
else
force = G( 1);
if (mFlags & TF_ON_GROUND)
{
mVelocity += d * CharNoBall_ACCEL * force;
}
force = d * mVelocity;
mTilt = (mTilt * CharNoBall_TILT_DAMP) + (force * CharNoBall_TILT_MAG);
}
//******************************************************************************************
void CCharNoBall::StateDead()
{
mTiltVelocity += (mTiltTo > G0) ? CharNoBall_DIE_ACCEL : - CharNoBall_DIE_ACCEL;
mTilt += mTiltVelocity;
if (((mTiltTo > G0) && (mTilt > mTiltTo)) ||
((mTiltTo < G0) && (mTilt < mTiltTo)))
{
mTilt = mTiltTo;
mTiltVelocity = -mTiltVelocity * CharNoBall_DIE_DAMP;
}
}
//******************************************************************************************
void CCharNoBall::StateAsleep()
{
// rock!
mTilt = (GSIN(G(GAME.GetGameTurn() + mNumber * 43) / 10) + G1) / 10;
SUPERTYPE::StateAsleep();
}
//******************************************************************************************
void CCharNoBall::Process()
{
SUPERTYPE::Process();
// it's just about ok to do this after the process, because it only affects orientation.
GINT v = mDir.MagnitudeXY();
if (v > GINT(0, 100))
{
GINT sn = -mDir.X / v;
GINT cs = mDir.Y / v;
mOrientation.MakeRotationYawSC(sn, cs);
}
if (mTilt != G0)
{
// tilt in direction of force
GMatrix m;
GVector ax = mDir ^ GVector(G0, G0, G(1));
if (ax.MagnitudeSq() > G(0, 100))
{
m.MakeGeneralAxisRotation(ax, mTilt);
mOrientation = m * mOrientation;
}
}
}
//******************************************************************************************
void CCharNoBall::StartDieProcess(BOOL hit_fan)
{
ChangeState(CS_DEAD, CStateInit());
mTiltVelocity = G0;
mTiltTo = (mTilt > G0) ? (-CharNoBall_DIE_TILT) : CharNoBall_DIE_TILT;
}
//******************************************************************************************
void CCharNoBall::Hit(CThing *that)
{
/*if (mState != CS_DEAD)
{
if (that->IsFriendly())
{
GINT v = (mVelocity - that->GetVelocity()).MagnitudeXY() * G(2);
if (v > G1)
v = G1;
that->Damage(v);
}
}*/
}
#endif