-
Notifications
You must be signed in to change notification settings - Fork 0
/
bullet.c
1530 lines (1318 loc) · 44 KB
/
bullet.c
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
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Lacewing
Copyright (C) 2003 Linley Henzell & Captain Pork
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
the Free Software Foundation; either version 2 of the Licence, 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 Licence for more details.
You should have received a copy of the GNU General Public Licence
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
The GPL version 2 is included in this distribution in a file called
LICENCE.TXT. Use any text editor or the TYPE command to read it.
You should be able to reach us by sending an email to
captainpork@fastmail.fm.
File: bullet.c
History:
6/10/2003 - Version 1.0 finalised
This file contains:
- functions relating to bullets and dangerous projectiles
*/
#define ALLEGRO_NO_CLEAR_BITMAP_ALIAS
#define ALLEGRO_NO_VHLINE_ALIAS
#include "allegro.h"
#include <math.h>
#include "config.h"
#include "globvars.h"
#include "stuff.h"
#include "cloud.h"
#include "enemy.h"
#include "actor.h"
#include "sound.h"
#include "palette.h"
int create_bullet(int type, int x, int y,
int x_speed, int y_speed, int owner,
int damage, int timer, int mass, int angle,
int status, unsigned char seed, int colours [4], int speed_div,
int special1, int special2, int special3, int special4, int special5);
void manage_bullet(int b);
int move_bullet(int mbull, char limited);
int detect_collision(int b, int things [2]);
int detect_enemy_collision(int b, int things [2]);
void bullet_impact(int b, int k, int hit_what);
void destroy_bullet(int b);
void apply_force_to_actor(int a, int fx, int fy);
void apply_force_to_enemy(int e, int fx, int fy);
void blast(int x, int y, int radius, int damage, int force, int owner);
void drag_bullet(int b, float drag_amount);
extern int inflicteda, inflictede;
int enemy_bullet_track_target(int b, int attacking, int turning);
int closest_target(int x, int y);
int nearby_target(int range, int x, int y);
void bullet_sound(int b, int sound);
void bullet_soundf(int b, int sound, int freq);
enum
{
BSOUND_BOMB,
BSOUND_MISSILE,
BSOUND_MINE,
BSOUND_SEEKMINE,
BSOUND_ORBITAL,
BSOUND_SEEKBLOB_BANG1,
BSOUND_SEEKBLOB_BANG2,
BSOUND_TUBE,
BSOUND_MINE2,
BSOUND_HIT
};
enum
{
HIT_NOTHING,
HIT_ACTOR,
HIT_ENEMY,
HIT_EDGE
};
void init_bullets(void)
{
int b;
for (b = 0; b < NO_BULLETS; b++)
{
bullet[b].type = BULLET_NONE;
}
}
int create_bullet(int type, int x, int y,
int x_speed, int y_speed, int owner,
int damage, int timer, int mass, int angle,
int status, unsigned char seed, int colours [4], int speed_div,
int special1, int special2, int special3, int special4, int special5)
{
int b = 0;
for (b = 1; b < NO_BULLETS; b++)
{
/* if ((bullet_type == BULLET_SPARK || bullet_type == BULLET_SPECK)
&& bcounter > MAX_BULLETS / 2)
return -1; // these bullets just for decoration*/
if (b == NO_BULLETS - 1) return -1;
if (bullet[b].type == BULLET_NONE) break;
}
bullet[b].type = type;
// bullet[b].x = x + (x_speed - actor[owner].x_speed);
// bullet[b].y = y + (y_speed - actor[owner].y_speed);
if (owner != OWNER_ENEMY)
{
bullet[b].x = x + (x_speed - actor[owner].x_speed) / speed_div;
bullet[b].y = y + (y_speed - actor[owner].y_speed) / speed_div;
}
else
{
bullet[b].x = x + x_speed / speed_div;
bullet[b].y = y + y_speed / speed_div;
}
bullet[b].x2 = x;
bullet[b].y2 = y;
bullet[b].x_speed = x_speed;
bullet[b].y_speed = y_speed;
bullet[b].owner = owner;
bullet[b].seed = seed;
bullet[b].timeout = timer;
// bullet[b].status = status;
bullet[b].damage = damage;
bullet[b].left_owner = 0;
bullet[b].mass = mass;
bullet[b].angle = angle;
bullet[b].colours [0] = colours [0];
bullet[b].colours [1] = colours [1];
bullet[b].colours [2] = colours [2];
bullet[b].colours [3] = colours [3];
bullet[b].special1 = special1;
bullet[b].special2 = special2;
bullet[b].special3 = special3;
bullet[b].special4 = special4;
bullet[b].special5 = special5;
switch(type)
{
case BULLET_CURVE:
if (grand(2) == 0)
bullet[b].angle = angle + ANGLE_HALF;
// else
// bullet[b].angle = angle - ANGLE_QUARTER;
bullet[b].angle %= ANGLE_FULL;
if (grand(10) == 0)
bullet[b].angle = grand(ANGLE_FULL);
break;
case BULLET_TORPEDO2:
bullet[b].x_speed = 0;
bullet[b].y_speed = 0;
break;
}
return b;
}
void run_bullets(void)
{
int b;
for (b = 1; b < NO_BULLETS; b++)
{
if (bullet[b].type != BULLET_NONE) manage_bullet(b);
}
}
void manage_bullet(int b)
{
// int x_gain = 0;
// int y_gain = 0;
// char angle_change;
int cx, cy;
int c2x, c2y;
int passing_colour [5];
if (bullet[b].left_owner < 100)
bullet[b].left_owner ++;
if (bullet[b].timeout > 0)
{
bullet[b].timeout --;
if (bullet[b].timeout <= 0)
{
bullet_impact(b, -1, HIT_NOTHING);
return;
}
}
switch(bullet[b].type)
{
case BULLET_MISSILE:
if (bullet[b].special3 == LOCK_ACTOR0 || bullet[b].special3 == LOCK_ACTOR1)
{
if (bullet[b].special3 == LOCK_ACTOR0)
cx = 0;
else
cx = 1;
if (hypot(bullet[b].y - actor[cx].y, bullet[b].x - actor[cx].x)
< 30000)
// < 5000)
bullet[b].angle = turn_towards_xy(bullet[b].x, bullet[b].y, actor[cx].x, actor[cx].y, bullet[b].angle - ANGLE_QUARTER, bullet[b].special4) + ANGLE_QUARTER;
else
bullet[b].angle = turn_towards_xy(bullet[b].x, bullet[b].y, actor[cx].x + (actor[cx].x_speed * bullet[b].special5), actor[cx].y + (actor[cx].y_speed * bullet[b].special5), bullet[b].angle - ANGLE_QUARTER, bullet[b].special4) + ANGLE_QUARTER;
}
else
if (bullet[b].special3 >= 0)
{
// destroyed enemies have locks cleared in register_destroyed (enemy.c)
if (hypot(bullet[b].y - enemy[bullet[b].special3].y, bullet[b].x - enemy[bullet[b].special3].x)
< 30000)
// < 5000)
bullet[b].angle = turn_towards_xy(bullet[b].x, bullet[b].y, enemy[bullet[b].special3].x, enemy[bullet[b].special3].y, bullet[b].angle - ANGLE_QUARTER, bullet[b].special4) + ANGLE_QUARTER;
else
bullet[b].angle = turn_towards_xy(bullet[b].x, bullet[b].y, enemy[bullet[b].special3].x + (enemy[bullet[b].special3].x_speed * bullet[b].special5), enemy[bullet[b].special3].y + (enemy[bullet[b].special3].y_speed * bullet[b].special5), bullet[b].angle - ANGLE_QUARTER, bullet[b].special4) + ANGLE_QUARTER;
// What this does: if missile is close to enemy, heads straight for it.
// Otherwise, leads it slightly (to an extent specified by bullet[b].special5)
// For this reason, enemy[].x_speed must be set correctly.
}
cx = cos(angle_to_radians(bullet[b].angle) + ANGLE_QUARTER) * GRAIN;
cy = sin(angle_to_radians(bullet[b].angle) + ANGLE_QUARTER) * GRAIN;
c2x = (cx * bullet[b].special1) / GRAIN;
c2y = (cy * bullet[b].special1) / GRAIN;
bullet[b].x_speed += c2x;
bullet[b].y_speed += c2y;
drag_bullet(b, 0.03);
if (crandom(2) != 0)
{
passing_colour [0] = bullet[b].colours [0];
passing_colour [1] = bullet[b].colours [1]; // 1->1
passing_colour [2] = bullet[b].colours [3]; // 2->3
// place_rocket_trail(bullet[b].x, bullet[b].y, bullet[b].x_speed + cx*3, bullet[b].y_speed + cy*3, 5 + grand(5), passing_colour);
// place_rocket_trail(bullet[b].x, bullet[b].y, bullet[b].x_speed + cx*3, bullet[b].y_speed + cy*3, 1, passing_colour);
place_rocket_trail(bullet[b].x + grand(3001) - 1500 - cx, bullet[b].y + grand(3001) - 1500 - cy, bullet[b].x_speed - cx*2, bullet[b].y_speed - cy*2, 140, passing_colour);
}
break;
case BULLET_CURVE:
cx = cos(angle_to_radians(bullet[b].angle) + ANGLE_QUARTER) * 200;
cy = sin(angle_to_radians(bullet[b].angle) + ANGLE_QUARTER) * 200;
bullet[b].x_speed += cx;
bullet[b].y_speed += cy;
break;
case BULLET_PLASMA:
passing_colour [0] = bullet[b].colours [grand(4)];
cx = bullet[b].x_speed / 3;
cy = bullet[b].y_speed / 3;
create_cloud(CLOUD_SMALL_TRANS_CIRCLE,
bullet[b].x + grand(4001) - 2000,
bullet[b].y + grand(4001) - 2000,
cx, cy,
0,
0,
250 + crandom(200),70,0, 0, 0, 0, passing_colour);
break;
case BULLET_SEEKER_BLOB2:
if (counter % 6 == 0)
{
passing_colour [0] = COLOUR_GREEN6;
create_cloud(CLOUD_GROWING_CIRCLE,
bullet[b].x,
bullet[b].y,
0, 0,
// bullet[b].x_speed - cx*5, bullet[b].y_speed - cy*5,
0, 0,
100,3,0, 0, 100, 0, passing_colour);
}
if (bullet[b].special1 == ATTACK_NONE)
break;
bullet[b].angle = enemy_bullet_track_target(b, bullet[b].special1, 4);
cx = cos(angle_to_radians(bullet[b].angle)) * 225;
cy = sin(angle_to_radians(bullet[b].angle)) * 225;
bullet[b].x_speed += cx;
bullet[b].y_speed += cy;
drag_bullet(b, 0.07);
break;
case BULLET_TORPEDO:
// bullet[b].angle += grand(11) - 5;
cx = cos(angle_to_radians(bullet[b].angle)) * 205;
cy = sin(angle_to_radians(bullet[b].angle)) * 205;
bullet[b].x_speed += cx;
bullet[b].y_speed += cy;
drag_bullet(b, 0.01);
if (bullet[b].timeout % 4 != 0)
break;
passing_colour [0] = COLOUR_YELLOW6;
create_cloud(CLOUD_GROWING_CIRCLE,
bullet[b].x,
bullet[b].y,
0, 0,
// bullet[b].x_speed - cx*5, bullet[b].y_speed - cy*5,
0, 0,
100,3,0, 0, 100, 0, passing_colour);
break;
case BULLET_BOSS4:
passing_colour [0] = TRANS_YELLOW;//bullet[b].colours [grand(4)];
if (grand(3) == 0)
passing_colour [0] = TRANS_WHITE;
cx = bullet[b].x_speed / 3;
cy = bullet[b].y_speed / 3;
create_cloud(CLOUD_SMALL_TRANS_CIRCLE,
bullet[b].x + grand(8001) - 4000,
bullet[b].y + grand(8001) - 4000,
cx, cy,
0,
0,
500 + crandom(300),70,0, 0, 0, 0, passing_colour);
create_cloud(CLOUD_SMALL_TRANS_CIRCLE,
bullet[b].x + cos(angle_to_radians(bullet[b].timeout * 40 + bullet[b].angle)) * 30000,
bullet[b].y + sin(angle_to_radians(bullet[b].timeout * 40 + bullet[b].angle)) * 30000,
0, 0,
0,
0,
300 + crandom(200),50,0, 0, 0, 0, passing_colour);
create_cloud(CLOUD_SMALL_TRANS_CIRCLE,
bullet[b].x + cos(angle_to_radians(ANGLE_FULL - (bullet[b].timeout * 40 + bullet[b].angle))) * 30000,
bullet[b].y + sin(angle_to_radians(ANGLE_FULL - (bullet[b].timeout * 40 + bullet[b].angle))) * 30000,
0, 0,
0,
0,
300 + crandom(200),50,0, 0, 0, 0, passing_colour);
if (bullet[b].timeout % 16 == 0)
bullet_sound(b, BSOUND_MINE2);
break;
case BULLET_FLAK:
if (counter % 3 != 0)
break;
passing_colour [0] = COLOUR_RED8;
create_cloud(CLOUD_SHRINKING_CIRCLE,
bullet[b].x,
bullet[b].y,
0, 0,
0, 0,
500,-50,10, 0, 0, 0, passing_colour);
break;
case BULLET_LINES:
passing_colour [0] = COLOUR_GREY6;
// cx = bullet[b].x_speed / 3;
// cy = bullet[b].y_speed / 3;
create_cloud(CLOUD_LINE_SHADOW,
bullet[b].x,
bullet[b].y,
0, 0,
0,
0,
20 + grand(60),3 + grand(7),0, bullet[b].angle, 0, 0, passing_colour);
break;
case BULLET_PRESEEKMINE:
// if (grand(4) == 0)
if (grand(3) == 0 && grand(abs(bullet[b].x_speed) + abs(bullet[b].y_speed)) > 2000)
{
passing_colour[0] = COLOUR_WHITE;
passing_colour[1] = COLOUR_BLUE8;
passing_colour[2] = COLOUR_BLUE6;
passing_colour[3] = COLOUR_BLUE4;
passing_colour[4] = COLOUR_BLUE2;
create_cloud(CLOUD_SPECK, bullet[b].x + grand(6001) - 3000, bullet[b].y + grand(6001) - 3000,
0, 0, 0, 0, 24, 1,
0, 0, 0, 0, passing_colour);
}
drag_bullet(b, 0.08);
if (abs(bullet[b].x_speed) + abs(bullet[b].y_speed) < 1000)
bullet[b].timeout = 1;
else
bullet[b].timeout ++;
break;
case BULLET_PREMINE:
// if (grand(4) == 0 && abs(bullet[b].x_speed) + abs(bullet[b].y_speed) > 2000)
if (grand(3) == 0 && grand(abs(bullet[b].x_speed) + abs(bullet[b].y_speed)) > 2000)
{
passing_colour[0] = COLOUR_YELLOW8;
passing_colour[1] = COLOUR_RED8;
passing_colour[2] = COLOUR_RED6;
passing_colour[3] = COLOUR_RED4;
passing_colour[4] = COLOUR_RED2;
create_cloud(CLOUD_SPECK, bullet[b].x + grand(6001) - 3000, bullet[b].y + grand(6001) - 3000,
0, 0, 0, 0, 24, 1,
0, 0, 0, 0, passing_colour);
}
drag_bullet(b, 0.08);
if (abs(bullet[b].x_speed) + abs(bullet[b].y_speed) < 1000)
bullet[b].timeout = 1;
else
bullet[b].timeout ++;
break;
case BULLET_SEEKMINE:
case BULLET_MINE:
bullet[b].x_speed = 0;
bullet[b].y_speed = 0;
break;
case BULLET_SEEKER_BLOB:
if (bullet[b].special1 == ATTACK_NONE)
break;
bullet[b].angle = enemy_bullet_track_target(b, bullet[b].special1, 4);
// cx = cos(angle_to_radians(bullet[b].angle) + ANGLE_QUARTER) * 1200;
// cy = sin(angle_to_radians(bullet[b].angle) + ANGLE_QUARTER) * 1200;
cx = cos(angle_to_radians(bullet[b].angle)) * 1900;
cy = sin(angle_to_radians(bullet[b].angle)) * 1900;
bullet[b].x_speed = cx;
bullet[b].y_speed = cy;
break;
case BULLET_PRONG:
bullet[b].x_speed += grand(201) - 100;
bullet[b].y_speed += grand(201) - 100;
bullet[b].angle += 64;
if (bullet[b].angle > ANGLE_FULL)
bullet[b].angle -= ANGLE_FULL;
break;
case BULLET_SEEKER_BLOB3:
passing_colour [0] = TRANS_LBLUE;
if (grand(3) == 0)
passing_colour [0] = TRANS_DBLUE;
// if (grand(4) == 0)
// passing_colour [0] = TRANS_WHITE;
create_cloud(CLOUD_SMALL_TRANS_CIRCLE,
bullet[b].x + grand(4001) - 2000,
bullet[b].y + grand(4001) - 2000,
0, 0, 0, 0, 250 + crandom(200),10,5, 0, 0, 0, passing_colour);
if (bullet[b].special1 == ATTACK_NONE)
break;
bullet[b].angle = enemy_bullet_track_target(b, bullet[b].special1, 8);
cx = cos(angle_to_radians(bullet[b].angle)) * 2300;
cy = sin(angle_to_radians(bullet[b].angle)) * 2300;
bullet[b].x_speed = cx;
bullet[b].y_speed = cy;
break;
case BULLET_STING:
if (bullet[b].timeout % 3 != 0)
break;
passing_colour[0] = bullet[b].colours [1];
passing_colour[1] = bullet[b].colours [1];
passing_colour[2] = bullet[b].colours [2];
passing_colour[3] = bullet[b].colours [2];
passing_colour[4] = bullet[b].colours [3];
// create_cloud(CLOUD_SPECK, bullet[b].x, bullet[b].y, 0, 0,
// 0, 0, 15 + grand(15), 1,
// 1, 0, 0, 0, passing_colour);
create_cloud(CLOUD_SPECK, bullet[b].x + grand(5001) - 2500, bullet[b].y + grand(5001) - 2500, 0, 0,
0, 0, 15 + grand(15), 1,
1, 0, 0, 0, passing_colour);
break;
/* case BULLET_PRONG:
bullet[b].x_speed += grand(201) - 100;
bullet[b].y_speed += grand(201) - 100;
bullet[b].angle += 64;
if (bullet[b].angle > ANGLE_FULL)
bullet[b].angle -= ANGLE_FULL;
break;*/
}
// other switch after move_bullet
// if (counter % 5 != 0)
// return;
if (move_bullet(b, 1) == 0)
return;
// other switch before move_bullet
switch(bullet[b].type)
{
case BULLET_HOSTILE:
passing_colour [0] = bullet[b].colours [0];
passing_colour [1] = bullet[b].colours [1];
passing_colour [2] = bullet[b].colours [2];
passing_colour [3] = bullet[b].colours [3];
cx = bullet[b].x + grand(16001) - 8000;
cy = bullet[b].y + grand(16001) - 8000;
create_cloud(CLOUD_FADING_LINE,
bullet[b].x2 - bullet[b].x_speed,
bullet[b].y2 - bullet[b].y_speed,
cx,
cy,
0,
0,
10, 1,0, 0, 0, 0, passing_colour);
bullet[b].x2 = cx;
bullet[b].y2 = cy;
break;
case BULLET_TORPEDO2:
if (bullet[b].timeout < 35)
{
if (bullet[b].timeout == 34)
bullet_sound(b, BSOUND_TUBE);
cx = cos(angle_to_radians(bullet[b].angle)) * (400 + (35 - bullet[b].timeout) * 20);
cy = sin(angle_to_radians(bullet[b].angle)) * (400 + (35 - bullet[b].timeout) * 20);
bullet[b].x_speed += cx;
bullet[b].y_speed += cy;
// drag_bullet(b, 0.01);
passing_colour [0] = COLOUR_GREY1;
passing_colour [1] = COLOUR_GREY3;
passing_colour [2] = COLOUR_GREY5;
passing_colour [3] = COLOUR_WHITE;
create_cloud(CLOUD_FADING_LINE,
bullet[b].x2 - bullet[b].x_speed,
bullet[b].y2 - bullet[b].y_speed,
bullet[b].x,
bullet[b].y,
0,
0,
10, 1,0, 0, 0, 0, passing_colour);
bullet[b].x2 = bullet[b].x;
bullet[b].y2 = bullet[b].y;
}
break;
case BULLET_SUPERSTING:
// if (bullet[b].timeout % 2 == 0)
{
passing_colour [3] = bullet[b].colours [0];
passing_colour [2] = bullet[b].colours [1];
passing_colour [1] = bullet[b].colours [2];
passing_colour [0] = bullet[b].colours [3];
c2x = cos(angle_to_radians(bullet[b].angle + ANGLE_QUARTER)) * 3000;
c2y = sin(angle_to_radians(bullet[b].angle + ANGLE_QUARTER)) * 3000;
create_cloud(CLOUD_FADING_LINE,
bullet[b].x2 - (bullet[b].x_speed * 1) + c2x,
bullet[b].y2 - (bullet[b].y_speed * 1) + c2y,
bullet[b].x - c2x,
bullet[b].y - c2y,
0,
0,
10, 1,0, 0, 0, 0, passing_colour);
create_cloud(CLOUD_FADING_LINE,
bullet[b].x - (bullet[b].x_speed * 1) - c2x,
bullet[b].y - (bullet[b].y_speed * 1) - c2y,
bullet[b].x + c2x,
bullet[b].y + c2y,
0,
0,
10, 1,0, 0, 0, 0, passing_colour);
}
// bullet[b].x2 = bullet[b].x + c2x;
// bullet[b].y2 = bullet[b].y + c2y;
/* c2x = cos(angle_to_radians(bullet[b].angle + ANGLE_QUARTER)) * 5000;
c2y = sin(angle_to_radians(bullet[b].angle + ANGLE_QUARTER)) * 5000;
// cx = bullet[b].x + c2x;
// cy = bullet[b].y + c2y;
create_cloud(CLOUD_FADING_LINE,
// bullet[b].x2 - bullet[b].x_speed + c2x,
// bullet[b].y2 - bullet[b].y_speed + c2y,
bullet[b].x2 + c2x,
bullet[b].y2 + c2y,
bullet[b].x - c2x,
bullet[b].y - c2y,
0,
0,
10, 1,0, 0, 0, 0, passing_colour);
bullet[b].x2 = bullet[b].x - c2x;
bullet[b].y2 = bullet[b].y - c2y;*/
break;
}
int things [2];
int k;
switch(bullet[b].type)
{
case BULLET_BOMB:
case BULLET_BOMB_SIDE:
return;
}
// Only collision detection can be from this point on, as bombs
// return above (they don't do collision detection)
if (bullet[b].owner == OWNER_ENEMY || game.type == GAME_DUEL)
{
k = detect_collision(b, things);
if (k != -1)
{
bullet[b].x = things [0];
bullet[b].y = things [1];
// bullet_hits_actor
hurt_actor(k, bullet[b].owner, bullet[b].damage);
bullet_impact(b, k, HIT_ACTOR);
return;
}
}
// else
if (bullet[b].owner != OWNER_ENEMY) // || game.type == GAME_DUEL)
{
k = detect_enemy_collision(b, things);
if (k != -1)
{
bullet[b].x = things [0];
bullet[b].y = things [1];
hurt_enemy(k, bullet[b].damage, bullet[b].owner, 1);
bullet_soundf(b, BSOUND_HIT, 800 + grand(200) - eclass[enemy[k].type].mass);
bullet_impact(b, k, HIT_ENEMY);
// bullet_hits_enemy
return;
}
}
}
void bullet_impact(int b, int k, int hit_what)
{
int j;
int xs = bullet[b].x_speed;
int ys = bullet[b].y_speed;
int passing_colours [5];
if (hit_what == HIT_ACTOR && k != -1)
{
xs = actor[k].x_speed;
ys = actor[k].y_speed;
}
else
{
if (hit_what == HIT_ENEMY && k != -1)
{
xs = enemy[k].x_speed;
ys = enemy[k].y_speed;
}
else
{
xs = 0;
ys = 0;
}
}
switch(bullet[b].type)
{
case BULLET_MISSILE:
passing_colours [0] = bullet[b].colours [1];
passing_colours [1] = bullet[b].colours [2];
passing_colours [2] = bullet[b].colours [3];
// passing_colours [3] = bullet[b].colours [3];
// place_rocket_trail(bullet[b].x, bullet[b].y, bullet[b].x_speed, bullet[b].y_speed, 700 + grand(450), passing_colours);
place_explosion_with_smoke(bullet[b].x, bullet[b].y, 0, 0, 700 + grand(450), passing_colours);
blast(bullet[b].x, bullet[b].y, 30000, bullet[b].damage * 10, 3000, bullet[b].owner);
for (j = 0; j < bullet[b].damage / 14 + 1; j ++)
{
xs = bullet[b].x + grand(40001) - 20000;
ys = bullet[b].y + grand(40001) - 20000;
place_explosion_with_smoke(xs, ys, 0, 0, 100 + grand(150), passing_colours);
blast(xs, ys, 15000, bullet[b].damage * 2, 2000, bullet[b].owner);
}
// passing_colours [0] = TRANS_YELLOW;
passing_colours [0] = TRANS_YELLOW;
passing_colours [1] = COLOUR_YELLOW8;
place_line_burst(bullet[b].x, bullet[b].y, 0, 0, 5 + (bullet[b].damage / 3), 15 + (bullet[b].damage / 8), 15, 1200 + (bullet[b].damage * 3), 300, passing_colours);
bullet_sound(b, BSOUND_MISSILE);
break;
case BULLET_TORPEDO2:
passing_colours [0] = TRANS_DBLUE;
passing_colours [1] = TRANS_LBLUE;
passing_colours [2] = TRANS_WHITE;
place_explosion(bullet[b].x, bullet[b].y, 0, 0, 700 + grand(450), passing_colours);
blast(bullet[b].x, bullet[b].y, 30000, bullet[b].damage * 5, 3000, bullet[b].owner);
passing_colours [0] = TRANS_LBLUE;
passing_colours [1] = COLOUR_BLUE8;
place_line_burst(bullet[b].x, bullet[b].y, 0, 0, 5, 15, 15, 1200, 300, passing_colours);
bullet_sound(b, BSOUND_MISSILE);
break;
case BULLET_LINES:
passing_colours [0] = TRANS_WHITE;
passing_colours [1] = COLOUR_GREY6;
place_line_burst(bullet[b].x, bullet[b].y, 0, 0, 5 + grand(3), 15, 15, 1200, 300, passing_colours);
break;
case BULLET_PRONG:
// passing_colours [0] = TRANS_LGREEN;
// passing_colours [1] = COLOUR_GREEN8;
// place_line_burst(bullet[b].x, bullet[b].y, 0, 0, 5 + grand(3), 15, 15, 1200, 300, passing_colours);
passing_colours[0] = bullet[b].colours [0];
passing_colours[1] = bullet[b].colours [1];
passing_colours[2] = bullet[b].colours [1];
passing_colours[3] = bullet[b].colours [2];
passing_colours[4] = bullet[b].colours [2];
place_speck_burst(bullet[b].x, bullet[b].y, xs,
ys, 4, 10, 21, 450, passing_colours);
passing_colours [0] = colour_to_trans(bullet[b].colours [0]);
create_cloud(CLOUD_SMALL_TRANS_CIRCLE,
bullet[b].x,
bullet[b].y,
xs, ys,
0,
0,
250 + crandom(200),10,10, 0, 0, 0, passing_colours);
break;
case BULLET_BOMB:
bullet_sound(b, BSOUND_BOMB);
// assumes side bombs always explode at same time
case BULLET_BOMB_SIDE:
passing_colours [0] = bullet[b].colours [1];
passing_colours [1] = bullet[b].colours [2];
passing_colours [2] = bullet[b].colours [3];
place_explosion_with_smoke(bullet[b].x, bullet[b].y, 0, 0, 200 + grand(300) + bullet[b].damage * 10, passing_colours);
blast(bullet[b].x, bullet[b].y, bullet[b].special1, bullet[b].damage * 10, 3000, bullet[b].owner);
for (j = 0; j < bullet[b].damage / 12 + 1; j ++)
{
xs = bullet[b].x + grand(40001) - 20000;
ys = bullet[b].y + grand(40001) - 20000;
place_explosion_with_smoke(xs, ys, 0, 0, 100 + grand(150), passing_colours);
// blast(xs, ys, 15000, bullet[b].damage * 5, 2000, bullet[b].owner);
}
passing_colours [3] = TRANS_WHITE2;
passing_colours [2] = TRANS_LGREY;
passing_colours [1] = TRANS_GREY;
passing_colours [0] = TRANS_DGREY;
create_cloud(CLOUD_SHOCKWAVE,
bullet[b].x,
bullet[b].y,
0, 0,
0,
0,
200 + crandom(50) + bullet[b].special1 / 200,15,0, 0, 250 + grand(100) + bullet[b].special1 / 200, 0, passing_colours);
break;
case BULLET_FLAK:
passing_colours [0] = TRANS_LGREY; //bullet[b].colours [1];
// passing_colours [1] = TRANS_DRED; //bullet[b].colours [2];
passing_colours [1] = TRANS_DRED; //bullet[b].colours [3];
passing_colours [2] = TRANS_WHITE; //bullet[b].colours [3];
place_explosion_with_smoke(bullet[b].x, bullet[b].y, 0, 0, 200 + grand(200), passing_colours);
blast(bullet[b].x, bullet[b].y, 30000, 200, 3000, bullet[b].owner);
passing_colours [3] = TRANS_LRED;
passing_colours [2] = TRANS_LRED;
passing_colours [1] = TRANS_DRED;
passing_colours [0] = TRANS_DRED;
create_cloud(CLOUD_SHOCKWAVE, bullet[b].x, bullet[b].y, 0, 0, 0, 0,
200 + crandom(50) + bullet[b].special1 / 200,15,0, 0, 250 + grand(100) + bullet[b].special1 / 200, 0, passing_colours);
bullet_sound(b, BSOUND_MINE);
/* passing_colours [0] = TRANS_LGREY; //bullet[b].colours [1];
// passing_colours [1] = TRANS_DRED; //bullet[b].colours [2];
passing_colours [1] = TRANS_YELLOW; //bullet[b].colours [3];
passing_colours [2] = TRANS_YELLOW; //bullet[b].colours [3];
place_explosion_with_smoke(bullet[b].x, bullet[b].y, 0, 0, 200 + grand(200), passing_colours);
blast(bullet[b].x, bullet[b].y, 30000, 200, 3000, bullet[b].owner);
passing_colours [3] = TRANS_YELLOW;
passing_colours [2] = TRANS_LORANGE;
passing_colours [1] = TRANS_LRED;
passing_colours [0] = TRANS_DRED;
create_cloud(CLOUD_SHOCKWAVE, bullet[b].x, bullet[b].y, 0, 0, 0, 0,
200 + crandom(50) + bullet[b].special1 / 200,15,0, 0, 250 + grand(100) + bullet[b].special1 / 200, 0, passing_colours);*/
break;
case BULLET_STING:
case BULLET_STING2:
case BULLET_ZAP:
// for (j = 0; j < 4; j ++)
// {
passing_colours[0] = bullet[b].colours [0];
passing_colours[1] = bullet[b].colours [1];
passing_colours[2] = bullet[b].colours [1];
passing_colours[3] = bullet[b].colours [2];
passing_colours[4] = bullet[b].colours [2];
place_speck_burst(bullet[b].x, bullet[b].y, xs,
ys, 4, 10, 21, 450, passing_colours);
// place_speck_burst(bullet[b].x, bullet[b].y, 0,
// 0, 4, 10, 21, 450, passing_colours);
// }
/* create_cloud(CLOUD_TRAIL1,
bullet[b].x,
bullet[b].y,
0, 0,
xs,
ys,
10 + grand(21), 0, 0, 0);*/
break;
case BULLET_POWERED:
passing_colours[0] = bullet[b].colours [0];
passing_colours[1] = bullet[b].colours [1];
passing_colours[2] = bullet[b].colours [1];
passing_colours[3] = bullet[b].colours [2];
passing_colours[4] = bullet[b].colours [2];
place_speck_burst(bullet[b].x, bullet[b].y, xs,
ys, 4, 10, 21, 450, passing_colours);
passing_colours [0] = colour_to_trans(bullet[b].colours [3]);
create_cloud(CLOUD_SMALL_TRANS_CIRCLE,
bullet[b].x,
bullet[b].y,
xs, ys,
0,
0,
250 + crandom(200),10,10, 0, 0, 0, passing_colours);
break;
case BULLET_ORBITAL:
passing_colours[0] = bullet[b].colours [0];
create_cloud(CLOUD_MED_CIRCLE, bullet[b].x, bullet[b].y, 0, 0,
// enemy[e].x_speed, enemy[e].y_speed, 300, 100,
0, 0, 300, 20,
2, 0, 0, 0, passing_colours);
// simple_cloud(COLOUR_BLUE6, ox, oy, enemy[e].x_speed, enemy[e].y_speed, 200);
if (hit_what != HIT_NOTHING)
bullet_sound(b, BSOUND_ORBITAL);
break;
case BULLET_NICE_ORBITAL:
passing_colours[0] = bullet[b].colours [1];
passing_colours[1] = bullet[b].colours [1];
passing_colours[2] = bullet[b].colours [2];
passing_colours[3] = bullet[b].colours [2];
passing_colours[4] = bullet[b].colours [3];
create_cloud(CLOUD_SPECK, bullet[b].x, bullet[b].y, 0, 0,
0, 0, 24, 1,
2, 0, 0, 0, passing_colours);
// bullet_sound(b, BSOUND_ORBITAL);
if (hit_what != HIT_NOTHING)
bullet_sound(b, BSOUND_ORBITAL);
break;
case BULLET_PLASMA:
passing_colours[0] = bullet[b].colours [0];
passing_colours[1] = bullet[b].colours [1];
passing_colours[2] = bullet[b].colours [2];
place_explosion(bullet[b].x, bullet[b].y, 0, 0, 700 + grand(450), passing_colours);
blast(bullet[b].x, bullet[b].y, 5000, bullet[b].damage, 500, bullet[b].owner);
bullet_sound(b, BSOUND_MINE);
break;
case BULLET_SEEKER_BLOB:
bullet_sound(b, BSOUND_SEEKBLOB_BANG1);
passing_colours[0] = TRANS_DBLUE;
passing_colours[1] = TRANS_LBLUE;
passing_colours[2] = TRANS_WHITE;
place_explosion(bullet[b].x, bullet[b].y, 0, 0, 300 + grand(150), passing_colours);
break;
case BULLET_SEEKER_BLOB3:
bullet_sound(b, BSOUND_SEEKBLOB_BANG2);
case BULLET_BLUE_BLOB:
passing_colours[0] = TRANS_DBLUE;
passing_colours[1] = TRANS_LBLUE;
passing_colours[2] = TRANS_WHITE;
place_explosion(bullet[b].x, bullet[b].y, 0, 0, 300 + grand(150), passing_colours);
break;
case BULLET_SEEKER_BLOB2:
passing_colours[0] = TRANS_DGREEN;
passing_colours[1] = TRANS_LGREEN;
passing_colours[2] = TRANS_WHITE;
place_explosion(bullet[b].x, bullet[b].y, 0, 0, 300 + grand(150), passing_colours);
break;
case BULLET_TORPEDO:
passing_colours [0] = TRANS_LGREY; //bullet[b].colours [1];
passing_colours [1] = TRANS_YELLOW; //bullet[b].colours [3];
passing_colours [2] = TRANS_YELLOW; //bullet[b].colours [3];
place_explosion_with_smoke(bullet[b].x, bullet[b].y, 0, 0, 200 + grand(200), passing_colours);
blast(bullet[b].x, bullet[b].y, 30000, 200, 3000, bullet[b].owner);
passing_colours [3] = TRANS_WHITE2;
passing_colours [2] = TRANS_YELLOW;
passing_colours [1] = TRANS_LGREY;
passing_colours [0] = TRANS_DGREY;
create_cloud(CLOUD_SHOCKWAVE, bullet[b].x, bullet[b].y, 0, 0, 0, 0,
200 + crandom(50) + bullet[b].special1 / 200,15,0, 0, 250 + grand(100) + bullet[b].special1 / 200, 0, passing_colours);
bullet_sound(b, BSOUND_MINE);
break;
case BULLET_BOSS4:
passing_colours [0] = TRANS_LGREY;
passing_colours [1] = TRANS_YELLOW;
passing_colours [2] = TRANS_WHITE;
place_explosion_with_smoke(bullet[b].x, bullet[b].y, 0, 0, 2500 + grand(200), passing_colours);
blast(bullet[b].x, bullet[b].y, 50000, 500, 5000, bullet[b].owner);
passing_colours [3] = TRANS_WHITE2;
passing_colours [2] = TRANS_YELLOW;
passing_colours [1] = TRANS_LORANGE;
passing_colours [0] = TRANS_LRED;
create_cloud(CLOUD_SHOCKWAVE, bullet[b].x, bullet[b].y, 0, 0, 0, 0,
800 + crandom(50),25,0, 0, 850 + grand(100), 0, passing_colours);
// place_line_burst(bullet[b].x, bullet[b].y, 0, 0, 5), 15 + (bullet[b].damage / 8), 15, 1200 + (bullet[b].damage * 3), 300, passing_colours);
bullet_sound(b, BSOUND_BOMB);
break;
case BULLET_RED_BLOB:
passing_colours[0] = TRANS_DRED;
passing_colours[1] = TRANS_LRED;
passing_colours[2] = TRANS_WHITE;
place_explosion(bullet[b].x, bullet[b].y, 0, 0, 300 + grand(150), passing_colours);
break;
case BULLET_CURVE:
case BULLET_PURPLE_BLOB:
case BULLET_SUPERSTING:
passing_colours[0] = TRANS_DBLUE;
passing_colours[1] = TRANS_PURPLE;
passing_colours[2] = TRANS_WHITE;
place_explosion(bullet[b].x, bullet[b].y, 0, 0, 300 + grand(150), passing_colours);
break;
case BULLET_ORANGE_BLOB:
passing_colours[0] = TRANS_DORANGE;
passing_colours[1] = TRANS_LORANGE;
passing_colours[2] = TRANS_YELLOW;
place_explosion(bullet[b].x, bullet[b].y, 0, 0, 300 + grand(150), passing_colours);
break;
case BULLET_YELLOW_BLOB:
passing_colours[0] = TRANS_LORANGE;
passing_colours[1] = TRANS_YELLOW;
passing_colours[2] = TRANS_WHITE;
place_explosion(bullet[b].x, bullet[b].y, 0, 0, 300 + grand(150), passing_colours);
break;
case BULLET_PREMINE:
bullet[b].type = BULLET_MINE;
bullet[b].timeout = 333 + grand(100);
bullet[b].x_speed = 0;
bullet[b].y_speed = 0;
return;
// NOTE: not break!
case BULLET_PRESEEKMINE:
bullet[b].type = BULLET_SEEKMINE;
bullet[b].timeout = 333 + grand(100);
bullet[b].x_speed = 0;
bullet[b].y_speed = 0;
return;
// NOTE: not break!
case BULLET_SEEKMINE:
bullet[b].type = BULLET_SEEKER_BLOB;
bullet[b].timeout = 333 + grand(100);
bullet[b].special1 = closest_target(bullet[b].x, bullet[b].y);
passing_colours [1] = TRANS_LBLUE;
passing_colours [2] = TRANS_WHITE;
place_burstlet_burst(bullet[b].x, bullet[b].y, 0, 0, 3 + grand(3),
4, 2, 1000, 1500, 4, passing_colours);
return;
// NOTE: not break!
case BULLET_MINE:
passing_colours [0] = TRANS_DRED;
passing_colours [1] = TRANS_LRED;
passing_colours [2] = TRANS_YELLOW;
place_explosion_with_smoke(bullet[b].x, bullet[b].y, 0, 0, 300 + grand(300), passing_colours);
blast(bullet[b].x, bullet[b].y, 30000, 200, 9000, bullet[b].owner);
passing_colours [3] = TRANS_WHITE2;
passing_colours [2] = TRANS_LGREY;
passing_colours [1] = TRANS_GREY;
passing_colours [0] = TRANS_DGREY;
create_cloud(CLOUD_SHOCKWAVE,
bullet[b].x, bullet[b].y,
0, 0, 0, 0,
200 + crandom(50),15,0, 0, 250 + grand(100), 0, passing_colours);
bullet_sound(b, BSOUND_MINE);
break;
}
// Note: not all bullets get this far (eg mines)
destroy_bullet(b);
}
void destroy_bullet(int b)
{
bullet[b].type = BULLET_NONE;
}
int move_bullet(int mbull, char limited)
{