File: EnemyType.d

package info (click to toggle)
parsec47 0.2.dfsg1-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 6,352 kB
  • sloc: xml: 2,178; ansic: 47; makefile: 28
file content (657 lines) | stat: -rw-r--r-- 18,394 bytes parent folder | download
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
/*
 * $Id: EnemyType.d,v 1.4 2004/01/01 11:26:41 kenta Exp $
 *
 * Copyright 2003 Kenta Cho. All rights reserved.
 */
module abagames.p47.EnemyType;

private:
import std.math;
import bulletml;
import abagames.util.Vector;
import abagames.util.Rand;
import abagames.p47.BarrageManager;
import abagames.p47.MorphBullet;

/**
 * Barrage pattern.
 */
public class Barrage {
 public:
  BulletMLParser *parser;
  BulletMLParser *[MorphBullet.MORPH_MAX] morphParser;
  int morphNum, morphCnt;
  float rank, speedRank, morphRank;
  int shape, color;
  float bulletSize;
  float xReverse;
}

/**
 * Enemys' wing with batteries.
 */
public class BatteryType {
 public:
  static const int WING_SHAPE_POINT_NUM = 3;
  static const int WING_BATTERY_MAX = 3;
  static const int BARRAGE_PATTERN_MAX = 8;
  Vector[WING_SHAPE_POINT_NUM] wingShapePos;
  Vector collisionPos, collisionSize;
  Vector[WING_BATTERY_MAX] batteryPos;
  int batteryNum;
  float r, g, b;
  Barrage[BARRAGE_PATTERN_MAX] barrage;
  bool xReverseAlternate;
  int shield;

  public this() {
    for (int i = 0; i < BARRAGE_PATTERN_MAX; i++) {
      barrage[i] = new Barrage;
    }
    for (int i = 0; i < WING_SHAPE_POINT_NUM; i++) {
      wingShapePos[i] = new Vector;
    }
    collisionPos = new Vector;
    collisionSize = new Vector;
    for (int i = 0; i < WING_BATTERY_MAX; i++) {
      batteryPos[i] = new Vector;
    }
  }
}

/**
 * Enemys' specifications.
 */
public class EnemyType {
 public:
  static const int BARRAGE_PATTERN_MAX = BatteryType.BARRAGE_PATTERN_MAX;
  static const int BODY_SHAPE_POINT_NUM = 4;
  static const int BATTERY_MAX = 4;
  static const int ENEMY_TYPE_MAX = 32;
  // Whether each type of the enemy is exist or not.
  static bool[ENEMY_TYPE_MAX] isExist;
  Barrage[BARRAGE_PATTERN_MAX] barrage;
  Vector[BODY_SHAPE_POINT_NUM] bodyShapePos;
  Vector collisionSize;
  bool wingCollision;
  float r, g, b;
  float retroSize;
  BatteryType[BATTERY_MAX] batteryType;
  int batteryNum;
  int shield;
  int fireInterval, firePeriod, barragePatternNum;
  int id;
  static enum {
    SMALL, MIDDLE, LARGE, MIDDLEBOSS, LARGEBOSS,
  }
  int type;
  // To avoid the forward reference.
  static enum {
    ROLL, LOCK,
  }
 private:
  static Rand rand;
  static BarrageManager barrageManager;
  static int idCnt;

  public static void init(BarrageManager manager) {
    rand = new Rand;
    barrageManager = manager;
    idCnt = 0;
  }

  public static void clearIsExistList() {
    for (int i = 0; i < idCnt; i++)
      isExist[i] = false;
  }

  public this() {
    for (int i = 0; i < BODY_SHAPE_POINT_NUM; i++) {
      bodyShapePos[i] = new Vector;
    }
    collisionSize = new Vector;
    for (int i = 0; i < BARRAGE_PATTERN_MAX; i++) {
      barrage[i] = new Barrage;
    }
    for (int i = 0; i < BATTERY_MAX; i++) {
      batteryType[i] = new BatteryType;
    }
    assert(idCnt < ENEMY_TYPE_MAX);
    id = idCnt;
    idCnt++;
  }

  // To avoid using the same morph pattern.
  private static bool[BarrageManager.BARRAGE_MAX] usedMorphParser;
  
  private void setBarrageType(Barrage br, int btn, int mode) {
    br.parser = barrageManager.parser
      [btn]
      [rand.nextInt(barrageManager.parserNum[btn])];
    for (int i = 0; i< BarrageManager.BARRAGE_MAX; i++)
      usedMorphParser[i] = false;
    int mpn;
    if (mode == ROLL)
      mpn = barrageManager.parserNum[BarrageManager.MORPH];
    else
      mpn = barrageManager.parserNum[BarrageManager.MORPH_LOCK];
    for (int i = 0; i< br.morphParser.length; i++) {
      int mi = rand.nextInt(mpn);
      for (int j = 0; j < mpn; j++) {
	if (!usedMorphParser[mi])
	  break;
	mi++;
	if (mi >= mpn) mi = 0;
      }
      if (mode == ROLL)
	br.morphParser[i] = barrageManager.parser[BarrageManager.MORPH][mi];
      else
	br.morphParser[i] = barrageManager.parser[BarrageManager.MORPH_LOCK][mi];
      usedMorphParser[mi] = true;
    }
    br.morphNum = br.morphParser.length;
  }

  // Barrage intense.
  enum {
    NORMAL, WEAK, VERYWEAK, MORPHWEAK
  }

  private void setBarrageRank(Barrage br, float rank, int intense, int mode) {
    if (rank <= 0) {
      br.rank = 0;
      return;
    }
    br.rank = sqrt(rank) / (8 - rand.nextInt(3));
    if (br.rank > 0.8)
      br.rank = rand.nextFloat(0.2) + 0.8;
    rank /= (br.rank + 2);
    if (intense == WEAK)
      br.rank /= 2;
    if (mode == ROLL)
      br.speedRank = sqrt(rank) * (rand.nextFloat(0.2) + 1);
    else
      br.speedRank = sqrt(rank * 0.66) * (rand.nextFloat(0.2) + 0.8);
    if (br.speedRank < 1)
      br.speedRank = 1;
    if (br.speedRank > 2)
      br.speedRank = sqrt(br.speedRank) + 0.27;
    br.morphRank = rank / br.speedRank;
    br.morphCnt = 0;
    while (br.morphRank > 1) {
      br.morphCnt++;
      br.morphRank /= 3;
    }
    if (intense == VERYWEAK) {
      br.morphRank /= 2;
      br.morphCnt /= 1.7f;
    } else if (intense == MORPHWEAK) {
      br.morphRank /= 2;
    } else if (intense == WEAK) {
      br.morphRank /= 1.5f;
    }
  }

  private void setBarrageRankSlow(Barrage br, float rank, int intense, int mode, float slow) {
    setBarrageRank(br, rank, intense, mode);
    br.speedRank *= slow;
  }

  public static const int BULLET_SHAPE_NUM = 7;
  public static const int BULLET_COLOR_NUM = 4;

  private void setBarrageShape(Barrage br, float size) {
    // To avoid the forward reference.
    //br.shape = rand.nextInt(BulletActor.BULLET_SHAPE_NUM);
    //br.color = rand.nextInt(BulletActor.BULLET_COLOR_NUM);
    br.shape = rand.nextInt(BULLET_SHAPE_NUM);
    br.color = rand.nextInt(BULLET_COLOR_NUM);
    br.bulletSize = (1.0 + rand.nextSignedFloat(0.1)) * size;
  }

  private float er, eg, eb;
  private int ect;

  private void setEnemyColorType() {
    ect = rand.nextInt(3);
  }

  private void createEnemyColor() {
    switch (ect) { default: break;
    case 0:
      er = 1;
      eg = rand.nextFloat(0.7) + 0.3;
      eb = rand.nextFloat(0.7) + 0.3;
      break;
    case 1:
      er = rand.nextFloat(0.7) + 0.3;
      eg = 1;
      eb = rand.nextFloat(0.7) + 0.3;
      break;
    case 2:
      er = rand.nextFloat(0.7) + 0.3;
      eg = rand.nextFloat(0.7) + 0.3;
      eb = 1;
      break;
    }
  }

  private static const float[][] enemySize = 
    [
     [0.3, 0.3, 0.3, 0.1,  0.1,  1.0, 0.4, 0.6, 0.9],
     [0.4, 0.2, 0.4, 0.1,  0.15,  2.2, 0.2, 1.6, 1.0],
     [0.6, 0.3, 0.5, 0.1,  0.2,  3.0, 0.3, 1.4, 1.2],
     [0.9, 0.3, 0.7, 0.2,  0.25,  5.0, 0.6, 3.0, 1.5],
     [1.2, 0.2, 0.9, 0.1,  0.3,  7.0, 0.8, 4.5, 1.5],
     ];
//  private enum {
//    SMALL, MIDDLE, LARGE, MIDDLEBOSS, LARGEBOSS,
//  }

  // Set the shepe of the BatteryType.
  private void setEnemyShapeAndWings(int size) {
    createEnemyColor();
    r = er;
    g = eg;
    b = eb;
    float x1 = enemySize[size][0] + rand.nextSignedFloat(enemySize[size][1]);
    float y1 = enemySize[size][2] + rand.nextSignedFloat(enemySize[size][3]);
    float x2 = enemySize[size][0] + rand.nextSignedFloat(enemySize[size][1]);
    float y2 = enemySize[size][2] + rand.nextSignedFloat(enemySize[size][3]);
    bodyShapePos[0].x = -x1;
    bodyShapePos[0].y = y1;
    bodyShapePos[1].x = x1;
    bodyShapePos[1].y = y1;
    bodyShapePos[2].x = x2;
    bodyShapePos[2].y = -y2;
    bodyShapePos[3].x = -x2;
    bodyShapePos[3].y = -y2;
    retroSize = enemySize[size][4];
    switch (size) { default: break;
    case SMALL:
    case MIDDLE:
    case MIDDLEBOSS:
      batteryNum = 2;
      break;
    case LARGE:
    case LARGEBOSS:
      batteryNum = 4;
      break;
    }
    float px, py, mpx, mpy;
    int bsl;
    if (x1 > x2)
      collisionSize.x = x1;
    else
      collisionSize.x = x2;
    if (y1 > y2)
      collisionSize.y = y1;
    else
      collisionSize.y = y2;
    for (int i = 0; i < batteryNum; i++) {
      BatteryType bt = batteryType[i];
      int wrl = 1;
      if (i % 2 == 0) {
	px = enemySize[size][5] + rand.nextFloat(enemySize[size][6]);
	if (batteryNum <= 2) {
	  py = rand.nextSignedFloat(enemySize[size][7]);
	} else {
	  if (i < 2) {
	    py = rand.nextFloat(enemySize[size][7] / 2) + enemySize[size][7] / 2;
	  } else {
	    py = -rand.nextFloat(enemySize[size][7] / 2) - enemySize[size][7] / 2;
	  }
	}
	float md;
	if (rand.nextInt(2) == 0)
	  md = rand.nextFloat(std.math.PI / 2) - std.math.PI / 4;
	else
	  md = rand.nextFloat(std.math.PI / 2) + std.math.PI / 4 * 3;
	mpx = px / 2 + sin(md) * (enemySize[size][8] / 2 + rand.nextFloat(enemySize[size][8]/2));
	mpy = py / 2 + cos(md) * (enemySize[size][8] / 2 + rand.nextFloat(enemySize[size][8]/2));
	switch (size) { default: break;
	case SMALL:
	case MIDDLE:
	case LARGE:
	  bsl = 1;
	  break;
	case MIDDLEBOSS:
	  bsl = 150 + rand.nextInt(30);
	  break;
	case LARGEBOSS:
	  bsl = 200 + rand.nextInt(50);
	  break;
	}
	createEnemyColor();
	wrl = -1;
	if (!wingCollision) {
	  if (px > collisionSize.x)
	    collisionSize.x = px;
	  float cpy = fabs(py);
	  if (cpy > collisionSize.y)
	    collisionSize.y = cpy;
	  cpy = fabs(mpy);
	  if (cpy > collisionSize.y)
	    collisionSize.y = cpy;
	}
      }
      switch (wrl) { default: break;
      case 1:
	bt.wingShapePos[0].x = px / 4 * wrl;
	bt.wingShapePos[0].y = py / 4;
	bt.wingShapePos[1].x = px * wrl;
	bt.wingShapePos[1].y = py;
	bt.wingShapePos[2].x = mpx * wrl;
	bt.wingShapePos[2].y = mpy;
	break;
      case -1:
	bt.wingShapePos[0].x = px / 4 * wrl;
	bt.wingShapePos[0].y = py / 4;
	bt.wingShapePos[1].x = px * wrl;
	bt.wingShapePos[1].y = py;
	bt.wingShapePos[2].x = mpx * wrl;
	bt.wingShapePos[2].y = mpy;
	break;
      }
      bt.collisionPos.x = (px + px / 4) / 2 * wrl;
      bt.collisionPos.y = (py + mpy + py / 4) / 3;
      bt.collisionSize.x = px / 4 * 3 / 2;
      float sy1 = fabs(py - mpy) / 2;
      float sy2 = fabs(py - py / 4) / 2;
      if (sy1 > sy2)
	bt.collisionSize.y = sy1;
      else
	bt.collisionSize.y = sy2;
      bt.r = er;
      bt.g = eg;
      bt.b = eb;
      bt.shield =bsl;
    }
  }

  // Set the barrage of the BatteryType.
  private void setBattery(float rank, int n, int barrageType, int barrageIntense, 
			  int idx, int ptnIdx, float slow, int mode) {
    BatteryType bt = batteryType[idx];
    BatteryType bt2 = batteryType[idx + 1];
    Barrage br = bt.barrage[ptnIdx];
    Barrage br2 = bt2.barrage[ptnIdx];
    setBarrageType(br, barrageType, mode);
    setBarrageRankSlow(br, rank / n, barrageIntense, mode, slow);
    setBarrageShape(br, 0.8);
    br.xReverse = rand.nextInt(2) * 2 - 1;
    br2.parser = br.parser;
    for (int i = 0; i < MorphBullet.MORPH_MAX; i++) {
      br2.morphParser[i] = br.morphParser[i];
    }
    br2.morphNum = br.morphNum;
    br2.morphCnt = br.morphCnt;
    br2.rank = br.rank;
    br2.speedRank = br.speedRank;
    br2.morphRank = br.morphRank;
    br2.shape = br.shape;
    br2.color = br.color;
    br2.bulletSize = br.bulletSize;
    br2.xReverse = -br.xReverse;
    if (rand.nextInt(4) == 0)
      bt.xReverseAlternate = bt2.xReverseAlternate = true;
    else
      bt.xReverseAlternate = bt2.xReverseAlternate = false;
    float px = bt.wingShapePos[1].x, py = bt.wingShapePos[1].y;
    float mpx = bt.wingShapePos[2].x, mpy = bt.wingShapePos[2].y;
    for (int i = 0; i < n; i++) {
      bt.batteryPos[i].x = px;
      bt.batteryPos[i].y = py;
      bt2.batteryPos[i].x = -px;
      bt2.batteryPos[i].y = py;
      px += (mpx - px) / (n - 1);
      py += (mpy - py) / (n - 1);
    }
    bt.batteryNum = bt2.batteryNum = n;
  }

  public void setSmallEnemyType(float rank, int mode) {
    type = SMALL;
    barragePatternNum = 1;
    wingCollision = false;
    setEnemyColorType();
    Barrage br = barrage[0];
    if (mode == ROLL)
      setBarrageType(br, BarrageManager.SMALL, mode);
    else
      setBarrageType(br, BarrageManager.SMALL_LOCK, mode);
    setBarrageRank(br, rank, VERYWEAK, mode);
    setBarrageShape(br, 0.7);
    br.xReverse = rand.nextInt(2) * 2 - 1;
    setEnemyShapeAndWings(SMALL);
    setBattery(0, 0, 0, NORMAL, 0, 0, 1, mode);
    shield = 1;
    fireInterval = 99999;
    firePeriod = 150 + rand.nextInt(40);
    if (rank < 10)
      firePeriod /= (2 - rank * 0.1);
  }

  public void setMiddleEnemyType(float rank, int mode) {
    type = MIDDLE;
    barragePatternNum = 1;
    wingCollision = false;
    setEnemyColorType();
    Barrage br = barrage[0];
    setBarrageType(br, BarrageManager.MIDDLE, mode);
    float cr, sr;
    if (mode == ROLL) {
      switch (rand.nextInt(6)) { default: break;
      case 0:
      case 1:
	cr = rank / 3 * 2;
	sr = 0;
	break;
      case 2:
	cr = rank / 4;
	sr = rank / 4;
	break;
      case 3:
      case 4:
      case 5:
	cr = 0;
	sr = rank / 2;
	break;
      }
    } else {
      switch (rand.nextInt(6)) { default: break;
      case 0:
      case 1:
	cr = rank / 5;
	sr = rank / 4;
	break;
      case 2:
      case 3:
      case 4:
      case 5:
	cr = 0;
	sr = rank / 2;
	break;
      }
    }
    setBarrageRank(br, cr, MORPHWEAK, mode);
    setBarrageShape(br, 0.75);
    br.xReverse = rand.nextInt(2) * 2 - 1;
    setEnemyShapeAndWings(MIDDLE);
    if (mode == ROLL) {
      shield = 40 + rand.nextInt(10);
      setBattery(sr, 1, BarrageManager.MIDDLESUB, NORMAL, 0, 0, 1, mode);
      fireInterval = 100 + rand.nextInt(60);
      firePeriod = cast(int)(fireInterval / (1.8 + rand.nextFloat(0.7)));
    } else {
      shield = 30 + rand.nextInt(8);
      setBattery(sr, 1, BarrageManager.MIDDLESUB_LOCK, NORMAL, 0, 0, 1, mode);
      fireInterval = 72 + rand.nextInt(30);
      firePeriod = cast(int)(fireInterval / (1.2 + rand.nextFloat(0.2)));
    }
    if (rank < 10)
      firePeriod /= (2 - rank * 0.1);
  }

  public void setLargeEnemyType(float rank, int mode) {
    type = LARGE;
    barragePatternNum = 1;
    wingCollision = false;
    setEnemyColorType();
    Barrage br = barrage[0];
    setBarrageType(br, BarrageManager.LARGE, mode);
    float cr, sr1, sr2;
    if (mode == ROLL) {
      switch (rand.nextInt(9)) { default: break;
      case 0:
      case 1:
      case 2:
      case 3:
	cr = rank;
	sr1 = sr2 = 0;
	break;
      case 4:
	cr = rank / 3 * 2;
	sr1 = rank / 3 * 2;
	sr2 = 0;
	break;
      case 5:
	cr = rank / 3 * 2;
	sr1 = 0;
	sr2 = rank / 3 * 2;
	break;
      case 6:
      case 7:
      case 8:
	cr = 0;
	sr1 = rank / 3 * 2;
	sr2 = rank / 3 * 2;
	break;
      }
    } else {
      switch (rand.nextInt(9)) { default: break;
      case 0:
	cr = rank / 4 * 3;
	sr1 = sr2 = 0;
	break;
      case 1:
      case 2:
	cr = rank / 4 * 2;
	sr1 = rank / 3 * 2;
	sr2 = 0;
	break;
      case 3:
      case 4:
	cr = rank / 4 * 2;
	sr1 = 0;
	sr2 = rank / 3 * 2;
	break;
      case 5:
      case 6:
      case 7:
      case 8:
	cr = 0;
	sr1 = rank / 3 * 2;
	sr2 = rank / 3 * 2;
	break;
      }
    }
    setBarrageRank(br, cr, WEAK, mode);
    setBarrageShape(br, 0.8);
    br.xReverse = rand.nextInt(2) * 2 - 1;
    setEnemyShapeAndWings(LARGE);
    if (mode == ROLL) {
      shield = 60 + rand.nextInt(10);
      setBattery(sr1, 1, BarrageManager.MIDDLESUB, NORMAL, 0, 0, 1, mode);
      setBattery(sr2, 1, BarrageManager.MIDDLESUB, NORMAL, 2, 0, 1, mode);
      fireInterval = 150 + rand.nextInt(60);
      firePeriod = cast(int)(fireInterval / (1.3 + rand.nextFloat(0.8)));
    } else {
      shield = 45 + rand.nextInt(8);
      setBattery(sr1, 1, BarrageManager.MIDDLESUB_LOCK, NORMAL, 0, 0, 1, mode);
      setBattery(sr2, 1, BarrageManager.MIDDLESUB_LOCK, NORMAL, 2, 0, 1, mode);
      fireInterval = 100 + rand.nextInt(50);
      firePeriod = cast(int)(fireInterval / (1.2 + rand.nextFloat(0.2)));
    }
    if (rank < 10)
      firePeriod /= (2 - rank * 0.1);
  }

  public void setMiddleBossEnemyType(float rank, int mode) {
    type = MIDDLEBOSS;
    barragePatternNum = 2 + rand.nextInt(2);
    wingCollision = true;
    setEnemyColorType();
    int bn = 1 + rand.nextInt(2);
    for (int i = 0; i < barragePatternNum; i++) {
      Barrage br = barrage[i];
      setBarrageType(br, BarrageManager.LARGE, mode);
      float cr, sr;
      switch (rand.nextInt(3)) { default: break;
      case 0:
	cr = rank;
	sr = 0;
	break;
      case 1:
	cr = rank / 3;
	sr = rank / 3;
	break;
      case 2:
	cr = 0;
	sr = rank;
	break;
      }
      setBarrageRankSlow(br, cr, NORMAL, mode, 0.9);
      setBarrageShape(br, 0.9);
      br.xReverse = rand.nextInt(2) * 2 - 1;
      setEnemyShapeAndWings(MIDDLEBOSS);
      setBattery(sr, bn, BarrageManager.MIDDLE, WEAK, 0, i, 0.9, mode);
    }
    shield = 300 + rand.nextInt(50);
    fireInterval = 200 + rand.nextInt(40);
    firePeriod = cast(int)(fireInterval / (1.2 + rand.nextFloat(0.4)));
    if (rank < 10)
      firePeriod /= (2 - rank * 0.1);
  }

  public void setLargeBossEnemyType(float rank, int mode) {
    type = LARGEBOSS;
    barragePatternNum = 2 + rand.nextInt(3);
    wingCollision = true;
    setEnemyColorType();
    int bn1 = 1 + rand.nextInt(3);
    int bn2 = 1 + rand.nextInt(3);
    for (int i = 0; i < barragePatternNum; i++) {
      Barrage br = barrage[i];
      setBarrageType(br, BarrageManager.LARGE, mode);
      float cr, sr1, sr2;
      switch (rand.nextInt(3)) { default: break;
      case 0:
	cr = rank;
	sr1 = sr2 = 0;
	break;
      case 1:
	cr = rank / 3;
	sr1 = rank / 3;
	sr2 = 0;
	break;
      case 2:
	cr = rank / 3;
	sr1 = 0;
	sr2 = rank / 3;
	break;
      }
      setBarrageRankSlow(br, cr, NORMAL, mode, 0.9);
      setBarrageShape(br, 1.0);
      br.xReverse = rand.nextInt(2) * 2 - 1;
      setEnemyShapeAndWings(LARGEBOSS);
      setBattery(sr1, bn1, BarrageManager.MIDDLE, NORMAL, 0, i, 0.9, mode);
      setBattery(sr2, bn2, BarrageManager.MIDDLE, NORMAL, 2, i, 0.9, mode);
    }
    shield = 400 + rand.nextInt(50);
    fireInterval = 220 + rand.nextInt(60);
    firePeriod = cast(int)(fireInterval / (1.2 + rand.nextFloat(0.3)));
    if (rank < 10)
      firePeriod /= (2 - rank * 0.1);
  }
}