-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChallenge.cpp
More file actions
executable file
·328 lines (285 loc) · 8.7 KB
/
Copy pathChallenge.cpp
File metadata and controls
executable file
·328 lines (285 loc) · 8.7 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#include <list>
using namespace std;
#include <time.h>
#include <stdlib.h>
#include "stdafx.h"
#include <zmouse.h>
#include "resource.h"
#include "ddutil.h"
#include "dxutil.h"
#include "dsutil.h"
#include "sprite.h"
#include "sounds.h"
#include "scene.h"
#include "weapon.h"
#include "physicalobject.h"
#include "font.h"
#include "globaldata.h"
#include "scoreunit.h"
#include "target.h"
#include "gameevents.h"
#include "challenge.h"
extern CDisplay TheDisplay;
extern SoundQueue GameSounds;
extern ScoreUnit ScoreBox;
extern GameEvents Events;
int NumChallenges = 3;
void Challenge::ChallengeUpdate(int TimeDiff)
{
if(mTimerRunning)
{
mInternalTimer -= TimeDiff;
if(mInternalTimer <= 0)
{
mTimerRunning = false;
onInternalTimerExpire();
}
}
}
///////////DUCK HUNT CHALLENGE/////////////
void Challenge_DuckHunt::onRoundStart()
{
DucksLaunched = DucksHit = 0;
ScoreBox.ResetScore();
ScoreBox.SetTitle("ACCURACY");
ScoreBox.SetCaption("PCT");
ScoreBox.SetDigitsToDisplay(3);
AddClayPigeon(TheDisplay, 5.5, -2.5);
}
void Challenge_DuckHunt::RecalcPercentage()
{
int PCt;
if(DucksHit == 0)
PCt = 0;
else
PCt = 100;
if(DucksLaunched != 0){
PCt = (DucksHit * 100) / DucksLaunched;
}
Percent = PCt;
ScoreBox.SetScore(PCt);
}
void Challenge_DuckHunt::onTargetDeath(Target* TheTarget, bool EndOfRound)
{
DucksLaunched++;
RecalcPercentage();
int TheTime = rand()%500 + 500;
if(!(DucksLaunched % 5)){// EVERY FIFTH DUCK, HOLD FOR A RELOAD.
TheTime += 2000;
Events.ChangeNotificationString("RELOAD IMMEDIATELY", 1500);
}
if(!EndOfRound){
SetInternalTimer(TheTime);
}
}
void Challenge_DuckHunt::onBulletHit(Target* TheTarget, Bullet* TheBullet, int Score)
{
if(Score == 1)
DucksHit++;
RecalcPercentage();
}
void Challenge_DuckHunt::onRoundEnd()
{
//DO NOTHING, SON.
}
void Challenge_DuckHunt::onInternalTimerExpire()
{
AddClayPigeon(TheDisplay, 5.5, -2.5);
}
void Challenge_DuckHunt::onRecapRequest()
{
char buf[500];
char FinalAnalysis[500];
if(Percent > 90)
strcpy(FinalAnalysis, "Exemplary Shooting");
else if(Percent > 70)
strcpy(FinalAnalysis, "Excellent Work");
else if(Percent > 50)
strcpy(FinalAnalysis, "This Is Above Average");
else if(Percent > 40)
strcpy(FinalAnalysis, "This Constitutes Average Performance");
else if(Percent > 30)
strcpy(FinalAnalysis, "It Is Advised To Practice Further");
else
strcpy(FinalAnalysis, "More Practice Is Necessary");
sprintf(buf, "FINAL SCORE\nOut of %d targets launched you managed to strike %d giving you a percentage total of %d\n\n%s\n\nCharles Cox\nDirector of The Training Centre\n\nPress SPACE to continue", DucksLaunched, DucksHit, Percent, FinalAnalysis);
SetRecap(buf);
}
void Challenge_DuckHunt::onBriefingRequest()
{
char buf[1500];
sprintf(buf, "TRAINING MODULE 0002\nDUCK HUNT\n\nTargets will be lofted from the sides of the range across the target area\nYou must neutralize these targets as they pass\nAfter every fifth launch you will be given a short interval in which to reload\n\nYou may use as many bullets as you wish in neutralizing the targets but be aware of your reload times\n\nShould any of the targets fall to the ground or pass the end of the range unscathed there will be a penalty\n\nThis is a category III test\nShotguns only\n\nGood luck\n\nPress space to continue");
SetBriefing(buf);
}
///////BULLSEYE CHALLENGE//////////
void Challenge_Bullseye::onInternalTimerExpire()
{
//DO NOTHING.
}
void Challenge_Bullseye::onBriefingRequest()
{
char buf[1500];
sprintf(buf, "TRAINING MODULE 0001\nBULLSEYE\n\nTimed targets will appear\nThey will disappear after their timers expire\nYou must attempt to hit the bullseye on each target\nmultiple hits do not count as only the highest score on the target when the target is removed counts\nthere will always be 4 targets visible at any time\n\nGood luck\n\nPress space to continue");
SetBriefing(buf);
}
void Challenge_Bullseye::onRoundStart()
{
PointsGained = 0;
AddMediumTimedPaperTarget(TheDisplay);
AddMediumTimedPaperTarget(TheDisplay);
AddMediumTimedPaperTarget(TheDisplay);
AddMediumTimedPaperTarget(TheDisplay);
ScoreBox.SetTitle("POINTS EARNED");
ScoreBox.SetCaption("PTS");
ScoreBox.SetDigitsToDisplay(4);
PointsPossible = 40;
}
void Challenge_Bullseye::onBulletHit(Target* TheTarget, Bullet* TheBullet, int Score)
{
//DO NOTHING, SON
}
void Challenge_Bullseye::onTargetDeath(Target* TheTarget, bool EndOfRound)
{
int Gained = TheTarget->QueryForFinalScoreUponDeath();
PointsGained += Gained;
ScoreBox.AddToScore(Gained);
if(!EndOfRound){
AddMediumTimedPaperTarget(TheDisplay);
PointsPossible += 10;
}
}
void Challenge_Bullseye::onRoundEnd()
{
//DO NOTHING, SON
}
void Challenge_Bullseye::onRecapRequest()
{
char buf[1500];
int Percent;
if(PointsPossible){
Percent = PointsGained * 100 / PointsPossible;
}
else{
Percent = 0;
}
char FinalAnalysis[500];
if(Percent > 90)
strcpy(FinalAnalysis, "Exemplary Shooting");
else if(Percent > 70)
strcpy(FinalAnalysis, "Excellent Work");
else if(Percent > 50)
strcpy(FinalAnalysis, "This Is Above Average");
else if(Percent > 40)
strcpy(FinalAnalysis, "This Constitutes Average Performance");
else if(Percent > 30)
strcpy(FinalAnalysis, "It Is Advised To Practice Further");
else
strcpy(FinalAnalysis, "More Practice Is Necessary");
sprintf(buf, "FINAL SCORE\nYou scored %d points out of a possible %d\nthis is calculated as a %d efficiency percentage\n\n%s\n\nCharles Cox\nDirector Of The Training Centre\n\nPress SPACE to continue",PointsGained, PointsPossible, Percent, FinalAnalysis);
SetRecap(buf);
}
void Challenge_Popups::onInternalTimerExpire()
{
//DO NOTHING.
if(rand()%4)
{
if(rand()%2)
AddBodyArmorPopupTarget(TheDisplay);
else
AddHeadArmorPopupTarget(TheDisplay);
}
else
AddStandardPopupTarget(TheDisplay);
}
/////////////POPUPS CHALLENGE BEGIN//////////////
void Challenge_Popups::RecalcPercentage()
{
int PCt;
if(ShotDown == 0)
PCt = 0;
else
PCt = 100;
if(PoppedUp != 0){
PCt = (ShotDown * 100) / PoppedUp;
}
Percent = PCt;
ScoreBox.SetScore(PCt);
}
void Challenge_Popups::onBriefingRequest()
{
char buf[1500];
sprintf(buf, "TRAINING MODULE 0003\nPOPUPS\n\nTimed targets will appear\nThey will disappear after their timers expire\nThey may or may not be shielded by body or head armor which is shown in blue\nkill zones are shown in red\n\nyou must hit the kill zone to down the target\n\nThe target timers are extremely short and accuracy beyond hitting a kill zone does not count towards a final score\n\nGood luck\n\nPress space to continue");
SetBriefing(buf);
}
void Challenge_Popups::onRoundStart()
{
PoppedUp = ShotDown = 0;
if(rand()%4)
{
if(rand()%2)
AddBodyArmorPopupTarget(TheDisplay);
else
AddHeadArmorPopupTarget(TheDisplay);
}
else
AddStandardPopupTarget(TheDisplay);
ScoreBox.SetTitle("ACCURACY");
ScoreBox.SetCaption("PCT");
ScoreBox.SetDigitsToDisplay(3);
}
void Challenge_Popups::onBulletHit(Target* TheTarget, Bullet* TheBullet, int Score)
{
//DO NOTHING, SON
}
void Challenge_Popups::onTargetDeath(Target* TheTarget, bool EndOfRound)
{
int Gained = TheTarget->QueryForFinalScoreUponDeath();
if(Gained){
ShotDown++;
}
if(!EndOfRound){
SetInternalTimer(rand()% 2500 + 1);
}
PoppedUp++;
RecalcPercentage();
}
void Challenge_Popups::onRoundEnd()
{
//DO NOTHING, SON
}
void Challenge_Popups::onRecapRequest()
{
char buf[1500];
char FinalAnalysis[500];
if(Percent > 90)
strcpy(FinalAnalysis, "Exemplary Shooting");
else if(Percent > 70)
strcpy(FinalAnalysis, "Excellent Work");
else if(Percent > 50)
strcpy(FinalAnalysis, "This Is Above Average");
else if(Percent > 40)
strcpy(FinalAnalysis, "This Constitutes Average Performance");
else if(Percent > 30)
strcpy(FinalAnalysis, "It Is Advised To Practice Further");
else
strcpy(FinalAnalysis, "More Practice Is Necessary");
sprintf(buf, "FINAL SCORE\n%d targets were popped up\nyou struck %d\nthis is calculated as a %d efficiency percentage\n\n%s\n\nCharles Cox\nDirector Of The Training Centre\n\nPress SPACE to continue",PoppedUp, ShotDown, Percent, FinalAnalysis);
SetRecap(buf);
}
void MakeNewChallenge(Challenge** ChallengeToFill, int* CurrentChallengeNumber)
{
switch(*CurrentChallengeNumber)
{
case 0:
*ChallengeToFill = new Challenge_DuckHunt;
break;
case 1:
*ChallengeToFill = new Challenge_Bullseye;
break;
case 2:
*ChallengeToFill = new Challenge_Popups;
break;
}
(*CurrentChallengeNumber)++;
(*CurrentChallengeNumber) %= NumChallenges;
}