forked from LemonHaze420/DCMoHo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrate.cpp
More file actions
260 lines (204 loc) · 5.1 KB
/
Copy pathcrate.cpp
File metadata and controls
260 lines (204 loc) · 5.1 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#include "Common.h"
#include "Globals.h"
#include "Crate.h"
#include "Effect.h"
//******************************************************************************************
void CCrate::Init(CInitThing *i)
{
SUPERTYPE::Init(i);
StickToGround();
mZBase = mPos.Z;
mZVel = G0;
mSmashed = FALSE;
mOID = i->mOID;
if (mOID == OID_INVALID)
mOID = OID_NONE;
GET_TARGET;
}
//******************************************************************************************
#if TARGET == PC || TARGET == DC
//******************************************************************************************
void CCrate::WriteData(CInitThing &i)
{
#if TARGET == PC
SUPERTYPE::WriteData(i);
i.mOID = mOID;
WRITE_TARGET;
#endif
}
#if TARGET == PC && defined(LINK_EDITOR)
//******************************************************************************************
void CCrate::DeclareSpawnees()
{
SUPERTYPE::DeclareSpawnees();
WORLD.AccumulateOIDResources(mOID);
// WORLD.AccumulateOIDResources(OID_CPUPHealth);
}
#endif
//******************************************************************************************
#endif
//******************************************************************************************
void CCrate::Process()
{
// StickToGround();
SUPERTYPE::Process();
// move in Z
mPos.Z += mZVel;
if ((mZBase != mPos.Z) || (mZVel != G0))
{
mZVel += WORLD.Gravity();
if (mPos.Z >= mZBase)
{
mPos.Z = mZBase;
if (mZVel > WORLD.Gravity() * 3)
{
mZVel = -mZVel * G(0, 30000);
}
else
mZVel = G0;
}
}
}
//******************************************************************************************
void CCrate::Hit(CThing *that)
{
// that->Stun(G1);
}
//******************************************************************************************
void CCrate::Smash()
{
if (mSmashed)
return;
mSmashed = TRUE;
Die();
// Spawn bonus thing?
CThing *t = NULL;
if (mOID != OID_NONE)
t = SpawnThing(mOID);
if (t)
{
CInitThing i;
i.mPos = mPos;
i.mPos.Z -= GINT_HALF;
i.mVelocity = GVector(G0, G0, -G(0, 20000));
t->Init(&i);
// stop you spawning thing twice if you can smash crate again fast enough
mOID=OID_NONE;
}
// kill something??
if (mTarget)
mTarget->Die();
// sample
SOUND.PlaySample(SmashSample(), this);
}
//******************************************************************************************
void CCrate::Rock()
{
if (DoIRock())
{
// rock a bit
mZVel = -WORLD.Gravity() * 5;
}
}
//******************************************************************************************
BOOL CCrate::Strike(const CStrike& strike)
{
SUPERTYPE::Strike(strike);
// stop the effect of the damage function
mLife +=HitDamage() /4;
mLife -=HitDamage();
// if hit with a weapon then smash straight away
if (strike.mStrikedWith == SI_WEAPON) mLife = 0 ;
if (mLife <= 0)
Smash();
return TRUE ;
}
//******************************************************************************************
void CCrate::Damage(GINT amount)
{
mLife -= (HitDamage() /4) ;
if (mLife <= 0)
Smash();
else
{
if (mZVel == G0) Rock() ;
}
}
//******************************************************************************************
//******************************************************************************************
//******************************************************************************************
void CGenerator::Init(CInitThing *i)
{
SUPERTYPE::Init(i);
mEffect = SpawnThing(OID_CFXFlamer2);
if (mEffect)
{
CInitThing i;
i.mPos = mPos + GetRenderThingEmitter(0);
i.mOrientation.MakeRotationPitch(-G_PI_2);
i.mAngleType = AT_ORI;
mEffect->Init(&i);
}
mDeathCount = 0;
SOUND.PlaySample(SOUND_GENERATOR, this, G(0, 20000), TRUE, TRUE);
}
//******************************************************************************************
#ifdef LINK_EDITOR
void CGenerator::DeclareSpawnees()
{
SUPERTYPE::DeclareSpawnees();
WORLD.AccumulateOIDResources(OID_CFXFlamer2);
WORLD.AccumulateOIDResources(OID_CFXExplosion1);
WORLD.AccumulateOIDResources(OID_CFXExplosion2);
}
#endif
//******************************************************************************************
void CGenerator::Smash()
{
if (mEffect)
mEffect->Die();
// spawn explosion part 1
CThing *t = SpawnThing(OID_CFXExplosion1);
if (t)
{
CInitThing i;
i.mPos = mPos;
t->Init(&i);
}
//sound
SOUND.KillSamples(this);
SOUND.PlaySample(SOUND_GENER_DIE, this, G(0, 60000), FALSE, TRUE);
SUPERTYPE::Smash();
}
//******************************************************************************************
void CGenerator::Die()
{
mDeathCount = 1;
}
//******************************************************************************************
void CGenerator::Process()
{
if (mDeathCount)
{
mDeathCount ++;
if (mDeathCount == 16)
{
SuicideNext();
// spawn explosion part 2
CThing *t = SpawnThing(OID_CFXExplosion2);
if (t)
{
CInitThing i;
i.mPos = mPos;
t->Init(&i);
}
}
}
else
{
// regenerate sample
if (((GAME.GetGameTurn() + mNumber) & 15) == 0)
SOUND.PlaySample(SOUND_GENERATOR, this, G(0, 20000), TRUE, TRUE);
}
SUPERTYPE::Process();
}