This repository was archived by the owner on Feb 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 511
/
Copy pathBULLET.CPP
786 lines (705 loc) · 36.1 KB
/
BULLET.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
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
/*
** Command & Conquer(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c\vcs\code\bullet.cpv 2.18 16 Oct 1995 16:50:00 JOE_BOSTIC $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : BULLET.CPP *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : April 23, 1994 *
* *
* Last Update : March 18, 1995 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* BulletClass::AI -- Logic processing for bullet. *
* BulletClass::As_Target -- Converts the bullet into a target value. *
* BulletClass::BulletClass -- Bullet constructor. *
* BulletClass::BulletClass -- Default constructor for bullet objects. *
* BulletClass::Detach -- Removes specified target from this bullet's targeting system. *
* BulletClass::Draw_It -- Displays the bullet at location specified. *
* BulletClass::Init -- Clears the bullets array for scenario preparation. *
* BulletClass::Mark -- Performs related map refreshing under bullet. *
* BulletClass::Occupy_List -- Determines the bullet occupation list. *
* BulletClass::Unlimbo -- Transitions a bullet object into the game render/logic system. *
* BulletClass::delete -- Bullet memory delete. *
* BulletClass::new -- Allocates memory for bullet object. *
* BulletClass::Validate -- validates bullet pointer *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#define GRAVITY 3
/*
** This contains the value of the Virtual Function Table Pointer
*/
void * BulletClass::VTable;
/***********************************************************************************************
* BulletClass::Validate -- validates bullet pointer *
* *
* INPUT: *
* none. *
* *
* OUTPUT: *
* 1 = ok, 0 = error *
* *
* WARNINGS: *
* none. *
* *
* HISTORY: *
* 08/09/1995 BRR : Created. *
*=============================================================================================*/
#ifdef CHEAT_KEYS
int BulletClass::Validate(void) const
{
int num;
num = Bullets.ID(this);
if (num < 0 || num >= BULLET_MAX) {
Validate_Error("BULLET");
return (0);
}
else
return (1);
}
#else
#define Validate()
#endif
/***********************************************************************************************
* BulletClass::BulletClass -- Default constructor for bullet objects. *
* *
* This is the default constructor for bullet objects. A bullet constructed by this routine *
* is not in a usable state for game purposes. It must be constructed by the full *
* (parameterized) constructor -- usually called as part of the overloaded "new" operator. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: Do not use bullets that were constructed solely by this routine. *
* *
* HISTORY: *
* 09/24/1994 JLB : Created. *
*=============================================================================================*/
BulletClass::BulletClass(void) :
Class(0)
{
Payback = NULL;
IsToAnimate = false;
Altitude = 0;
Riser = 0;
TarCom = TARGET_NONE;
Strength = 0;
IsLocked = true;
IsInaccurate = false;
}
/***********************************************************************************************
* BulletClass::new -- Allocates memory for bullet object. *
* *
* This function will "allocate" a block of memory for a bullet object. *
* This memory block is merely lifted from a fixed pool of blocks. *
* *
* INPUT: size -- The size of the memory block needed. *
* *
* OUTPUT: Returns with a pointer to an available bullet object block. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/02/1994 JLB : Created. *
*=============================================================================================*/
void * BulletClass::operator new(size_t )
{
void * ptr = Bullets.Allocate();
if (ptr) {
((BulletClass *)ptr)->IsActive = true;
}
return(ptr);
}
/***********************************************************************************************
* BulletClass::delete -- Bullet memory delete. *
* *
* Since bullets memory is merely "allocated" out of a pool, it never *
* actually gets deleted. *
* *
* INPUT: ptr -- Generic pointer to bullet object. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/02/1994 JLB : Created. *
*=============================================================================================*/
void BulletClass::operator delete(void *ptr)
{
if (ptr) {
((BulletClass *)ptr)->IsActive = false;
}
Bullets.Free((BulletClass *)ptr);
}
/***********************************************************************************************
* BulletClass::BulletClass -- Bullet constructor. *
* *
* This is the constructor for the bullet class. It handles all *
* initialization of the bullet and starting it in motion toward its *
* target. *
* *
* INPUT: id -- The type of bullet this is (could be missile). *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/02/1994 JLB : Created. *
* 06/20/1994 JLB : Firer is a base class pointer. *
* 12/10/1994 JLB : Auto calculate range optional. *
* 12/12/1994 JLB : Handles small arms as an instantaneous effect. *
* 12/23/1994 JLB : Fixed scatter algorithm for non-homing projectiles. *
* 12/31/1994 JLB : Removed range parameter (not needed). *
*=============================================================================================*/
BulletClass::BulletClass(BulletType id) :
Class(&BulletTypeClass::As_Reference(id))
{
Altitude = 0;
IsInaccurate = false;
IsLocked = true;
// IsLocked = false;
IsToAnimate = false;
Payback = 0;
Riser = 0;
Strength = Class->MaxStrength;
TarCom = TARGET_NONE;
}
/***********************************************************************************************
* BulletClass::Occupy_List -- Determines the bullet occupation list. *
* *
* This function will determine the cell occupation list and return a pointer to it. Most *
* bullets are small and the list is usually short, but on occasion, it can be a list that *
* rivals the size of regular vehicles. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with a pointer to the cell offset list that covers all the cells a bullet *
* is over. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/20/1994 JLB : Created. *
* 01/05/1995 JLB : Handles projectiles with altitude. *
*=============================================================================================*/
short const *BulletClass::Occupy_List(void) const
{
Validate();
switch (*this) {
case BULLET_FLAME:
return(Coord_Spillage_List(Coord, 25));
case BULLET_NUKE_UP:
case BULLET_NUKE_DOWN:
return(Coord_Spillage_List(Coord, 48));
default:
if (Altitude) {
static CELL _list[10];
const short * ptr = Coord_Spillage_List(Coord, 5);
int index = 0;
CELL cell1 = Coord_Cell(Coord);
while (ptr[index] != REFRESH_EOL) {
_list[index] = ptr[index];
index++;
}
COORDINATE coord = XY_Coord(0, Altitude);
coord = Coord_Sub(Coord, coord);
CELL cell2 = Coord_Cell(coord);
ptr = Coord_Spillage_List(coord, 5);
while (*ptr != REFRESH_EOL) {
_list[index++] = (*ptr++) + (cell2 - cell1);
}
_list[index] = REFRESH_EOL;
return(_list);
}
}
return(Coord_Spillage_List(Coord, 10));
}
/***********************************************************************************************
* BulletClass::Mark -- Performs related map refreshing under bullet. *
* *
* This routine marks the objects under the bullet so that they will *
* be redrawn. This is necessary as the bullet moves -- objects under *
* its path need to be restored. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/02/1994 JLB : Created. *
*=============================================================================================*/
bool BulletClass::Mark(MarkType mark)
{
Validate();
if (ObjectClass::Mark(mark)) {
if (!Class->IsInvisible) {
Map.Refresh_Cells(Coord_Cell(Coord), Occupy_List());
}
return(true);
}
return(false);
}
/***********************************************************************************************
* BulletClass::AI -- Logic processing for bullet. *
* *
* This routine will perform all logic (flight) logic on the bullet. *
* Primarily this is motion, fuse tracking, and detonation logic. Call *
* this routine no more than once per bullet per game tick. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/02/1994 JLB : Created. *
*=============================================================================================*/
void BulletClass::AI(void)
{
Validate();
COORDINATE coord;
ObjectClass::AI();
/*
** Balistic objects are handled here.
*/
bool forced = false; // Forced explosion.
if (Class->IsArcing) {
Altitude += Riser;
if (Altitude <= 0) {
forced = true;
}
if (Riser > -100) {
Riser -= GRAVITY;
}
}
if (Class->IsDropping) {
Altitude += Riser;
if (Altitude <= 0) {
forced = true;
}
if (Riser > -100) {
Riser -= 1;
}
}
/*
** Homing projectiles constantly change facing to face toward the target but
** they only do so every other game frame (improves game speed and makes
** missiles not so deadly).
*/
if ((Frame & 0x01) && Class->IsHoming && Target_Legal(TarCom)) {
PrimaryFacing.Set_Desired(Direction256(Coord, ::As_Coord(TarCom)));
}
/*
** Move the projectile forward according to its speed
** and direction.
*/
coord = Coord;
if (Class->IsFlameEquipped) {
if (IsToAnimate) {
new AnimClass(ANIM_SMOKE_PUFF, coord, 1);
}
IsToAnimate = !IsToAnimate;
}
/*
** Handle any body rotation at this time. This process must
** occur every game fame in order to achieve smooth rotation.
*/
if (PrimaryFacing.Is_Rotating()) {
PrimaryFacing.Rotation_Adjust(Class->ROT);
}
switch (Physics(coord, PrimaryFacing)) {
/*
** When a projectile reaches the edge of the world, it
** vanishes from existence -- presumed to explode off
** map.
*/
case IMPACT_EDGE:
// if (IsLocked) {
Mark();
delete this;
// }
break;
default:
case IMPACT_NONE:
/*
** The projectile has moved. Check its fuse. If detonation
** is signaled, then do so. Otherwise, just move.
*/
case IMPACT_NORMAL:
Mark();
// IsLocked = true;
if (!Class->IsHigh) {
CellClass * cellptr = &Map[Coord_Cell(coord)];
if (cellptr->Overlay != OVERLAY_NONE && OverlayTypeClass::As_Reference(cellptr->Overlay).IsHigh) {
forced = true;
Coord = coord = Cell_Coord(Coord_Cell(coord));
}
}
/*
** Bullets are generaly more effective when they are fired at aircraft.
*/
if (Class->IsAntiAircraft && As_Aircraft(TarCom) && Distance(TarCom) < 0x0080) {
forced = true;
if (*this == BULLET_TOW) {
Strength += Strength/3;
} else {
Strength += Strength/2;
}
}
if (!forced && (Class->IsDropping || !Fuse_Checkup(coord))) {
Coord = coord;
Mark();
/*
** Certain projectiles loose strength when they travel.
*/
if (*this == BULLET_BULLET) {
if (Strength > 5) Strength--;
}
} else {
/*
** When the target is reached, explode and do the damage
** required of it. For homing objects, don't force the explosion to
** match the target position. Non-homing projectiles adjust position so
** that they hit the target. This compensates for the error in line of
** flight logic.
*/
Mark();
if (!forced && !Class->IsArcing && !Class->IsHoming && Fuse_Target()) {
Coord = Fuse_Target();
}
/*
** Non-aircraft targets apply damage to the ground.
*/
if (!Is_Target_Aircraft(TarCom) || As_Aircraft(TarCom)->In_Which_Layer() == LAYER_GROUND) {
Explosion_Damage(Coord, Strength, Payback, Class->Warhead);
} else {
/*
** Special damage apply for SAM missiles. This is the only way that missile
** damage affects the aircraft target.
*/
if (Distance(TarCom) < 0x0080) {
AircraftClass * object = As_Aircraft(TarCom);
int str = Strength;
if (object) object->Take_Damage(str, 0, Class->Warhead, Payback);
}
}
/*
** For projectiles that are invisible while travelling toward the target,
** allow scatter effect for the impact animation.
*/
if (Class->IsInvisible) {
Coord = Coord_Scatter(Coord, 0x0020);
}
if (Class->Explosion != ANIM_NONE) {
new AnimClass(Class->Explosion, Coord);
}
delete this;
return;
}
break;
}
}
/***********************************************************************************************
* BulletClass::Draw_It -- Displays the bullet at location specified. *
* *
* This routine displays the bullet visual at the location specified. *
* *
* INPUT: x,y -- The center coordinate to render the bullet at. *
* *
* window -- The window to clip to. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/20/1994 JLB : Created. *
* 06/27/1994 JLB : Takes a window clipping parameter. *
* 01/08/1995 JLB : Handles translucent colors if necessary. *
*=============================================================================================*/
void BulletClass::Draw_It(int x, int y, WindowNumberType window)
{
Validate();
int facing = Facing_To_32(PrimaryFacing);
/*
** Certain projectiles aren't visible. This includes small bullets (which are actually
** invisible) and flame thrower flames (which are rendered as an animation instead of a projectile).
*/
if (Class->IsInvisible) return;
/*
** If there is no shape loaded for this object, then
** it obviously can't be rendered -- just bail.
*/
void const * shapeptr = Class->Get_Image_Data();
if (!shapeptr) return;
/*
** Get the basic shape number for this projectile.
*/
int shapenum = 0;
if (!Class->IsFaceless) {
shapenum = UnitClass::BodyShape[facing];
}
/*
** For tumbling projectiles, fetch offset stage.
*/
if (*this == BULLET_NAPALM) {
shapenum += Frame % 6;
}
if (*this == BULLET_GRENADE) {
shapenum += Frame % 8;
// Timer++;
}
/*
** For flying projectiles, draw the shadow and adjust the actual projectile body
** render position.
*/
if (Altitude) {
CC_Draw_Shape(shapeptr, shapenum, x, y, window, SHAPE_PREDATOR|SHAPE_CENTER|SHAPE_WIN_REL|SHAPE_FADING, NULL, Map.FadingShade);
y -= Lepton_To_Pixel(Altitude);
}
/*
** Draw the main body of the projectile.
*/
ShapeFlags_Type flags = SHAPE_NORMAL;
if (Class->IsTranslucent) {
flags = SHAPE_GHOST;
}
CC_Draw_Shape(shapeptr, shapenum, x, y, window, flags|SHAPE_CENTER|SHAPE_WIN_REL, NULL, Map.UnitShadow);
}
/***********************************************************************************************
* BulletClass::Init -- Clears the bullets array for scenario preparation. *
* *
* This routine will zero out the bullet tracking list and object array in preparation for *
* the start of a new scenario. All bullets cease to exists after this function is *
* called. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 08/15/1994 JLB : Created. *
*=============================================================================================*/
void BulletClass::Init(void)
{
BulletClass *ptr;
Bullets.Free_All();
ptr = new BulletClass();
VTable = ((void **)(((char *)ptr) + sizeof(AbstractClass) - 4))[0];
delete ptr;
}
/***********************************************************************************************
* BulletClass::Detach -- Removes specified target from this bullet's targeting system. *
* *
* When an object is removed from the game system, it must be removed all targeting and *
* tracking systems as well. This routine is used to remove the specified object from the *
* bullet. If the object isn't part of this bullet's tracking system, then no action is *
* performed. *
* *
* INPUT: target -- The target to remove from this tracking system. *
* *
* all -- Is the target going away for good as opposed to just cloaking/hiding? *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/24/1994 JLB : Created. *
*=============================================================================================*/
void BulletClass::Detach(TARGET target, bool all)
{
Validate();
ObjectClass * obj = As_Object(target);
if (obj == Payback) {
Payback = 0;
}
if (all && target == TarCom) {
TarCom = TARGET_NONE;
}
}
/***********************************************************************************************
* BulletClass::Unlimbo -- Transitions a bullet object into the game render/logic system. *
* *
* This routine is used to take a bullet object that is in limbo and transition it to the *
* game system. A bullet object so transitioned, will be drawn and logic processing *
* performed. In effect, it comes into existance. *
* *
* INPUT: coord -- The location where the bullet object is to appear. *
* *
* dir -- The initial facing for the bullet object. *
* *
* OUTPUT: bool; Was the unlimbo successful? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 01/10/1995 JLB : Created. *
*=============================================================================================*/
bool BulletClass::Unlimbo(COORDINATE coord, DirType dir)
{
Validate();
/*
** Try to unlimbo the bullet as far as the base class is concerned. Use the already
** set direction and strength if the "punt" values were passed in. This allows a bullet
** to be setup prior to being launched.
*/
if (ObjectClass::Unlimbo(coord)) {
COORDINATE tcoord = As_Coord(TarCom);
/*
** Homing projectiles (missiles) do NOT override facing. They just fire in the
** direction specified and let the chips fall where they may.
*/
if (!Class->IsHoming && !Class->IsDropping) {
dir = Direction(tcoord);
}
/*
** Possibly adjust the target if this projectile is inaccurate. This occurs whenever
** certain weapons are trained upon targets they were never designed to attack. Example: when
** turrets or anti-tank missiles are fired at infantry. Indirect
** fire is inherently inaccurate.
*/
if (IsInaccurate || Class->IsInaccurate ||
((Is_Target_Cell(TarCom) || Is_Target_Infantry(TarCom)) && (Class->Warhead == WARHEAD_AP || Class->IsFueled))) {
/*
** Inaccuracy for low velocity or homing projectiles manifests itself as a standard
** Cicular Error of Probability (CEP) algorithm. High speed projectiles usually
** just overshoot the target by extending the straight line flight.
*/
if (Class->IsHoming || Class->IsArcing) {
int scatterdist = ::Distance(coord, tcoord)/3;
scatterdist = MIN(scatterdist, 0x0200);
if (*this == BULLET_GRENADE) {
scatterdist = ::Distance(coord, tcoord)/4;
scatterdist = MIN(scatterdist, 0x0080);
}
dir = (DirType)((dir + (Random_Pick(0, 10)-5)) & 0x00FF);
tcoord = Coord_Scatter(tcoord, Random_Pick(0, scatterdist));
} else {
tcoord = Coord_Move(tcoord, dir, Random_Pick(0, 0x0100));
}
/*
** Limit scatter to the weapon range of the firer.
*/
if (Payback) {
if (!Payback->In_Range(tcoord, 0) && !Payback->In_Range(tcoord, 1)) {
tcoord = Coord_Move(tcoord, ::Direction(tcoord, Coord), Distance(tcoord) - MAX(Payback->Weapon_Range(0), Payback->Weapon_Range(1)));
}
}
}
/*
** For very fast and invisible projectiles, just make the projectile exist at the target
** location and dispense with the actual flight.
*/
if (Class->MaxSpeed == MPH_LIGHT_SPEED && Class->IsInvisible) {
Coord = tcoord;
}
/*
** Set the range equal to either the class defined range or the calculated
** number of game frames it would take for the projectile to reach the target.
*/
int range = 0xFF;
if (!Class->Range) {
if (!Class->IsDropping) {
range = (::Distance(tcoord, Coord) / Class->MaxSpeed) + 4;
}
} else {
range = Class->Range;
}
/*
** Projectile speed is usually the default value for that projectile, but
** certian projectiles alter speed according to the distance to the
** target.
*/
int speed = Class->MaxSpeed;
if (speed == MPH_LIGHT_SPEED) speed = MPH_IMMOBILE;
if (Class->IsArcing) {
speed = Class->MaxSpeed + (Distance(tcoord)>>5);
/*
** Set minimum speed (i.e., distance) for arcing projectiles.
*/
speed = MAX(speed, 25);
}
if (!Class->IsDropping) {
Fly_Speed(255, (MPHType)speed);
}
/*
** Arm the fuse.
*/
Arm_Fuse(Coord, tcoord, range, ((As_Aircraft(TarCom)!=0) ? 0 : Class->Arming));
/*
** Projectiles that make a ballistic flight to impact point must determine a
** vertical component for the projectile launch. This is crudely simulated
** by biasing ground speed according to target distance and then giving
** enough vertical velocity to keep the projectile airborne for the
** desired amount of time. The mathematically correct solution would be to
** calculate launch angle (given fixed projectile velocity) and then derive
** the vertical and horizontal components. This solution would require a
** of square root and an arcsine lookup table. OUCH!
*/
Altitude = 0;
Riser = 0;
if (Class->IsArcing) {
Altitude = 1;
Riser = ((Distance(tcoord)/2) / (speed+1))*GRAVITY;
Riser = MAX(Riser, 10);
}
if (Class->IsDropping) {
Altitude = Pixel_To_Lepton(24);
Riser = 0;
}
PrimaryFacing = dir;
return(true);
}
return(false);
}
/***********************************************************************************************
* BulletClass::As_Target -- Converts the bullet into a target value. *
* *
* This support routine is used to convert the bullet (as a pointer) into a target *
* value (which is a number). *
* *
* INPUT: none *
* *
* OUTPUT: Returns the bullet as a target value. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/08/1994 JLB : Created. *
*=============================================================================================*/
TARGET BulletClass::As_Target(void) const
{
Validate();
return(Build_Target(KIND_BULLET, Bullets.ID(this)));
}