-
Notifications
You must be signed in to change notification settings - Fork 0
/
03_cHarenaMission_setup.cpp
3407 lines (2859 loc) · 140 KB
/
03_cHarenaMission_setup.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
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
///////////////////////////////////////////////////////
//*-------------------------------------------------*//
//| Part of Project One (https://www.maus-games.at) |//
//*-------------------------------------------------*//
//| Copyright (c) 2010 Martin Mauersics |//
//| Released under the zlib License |//
//*-------------------------------------------------*//
///////////////////////////////////////////////////////
#include "main.h"
// ****************************************************************
// setup the Harena mission
void cHarenaMission::__SetupOwn()
{
// ################################################################
//
STAGE_MAIN({TAKE_ALWAYS})
{
if(HAS_FLAG(g_pGame->GetStatus(), GAME_STATUS_QUICK))
{
STAGE_FINISH_NOW
}
else
{
STAGE_FINISH_AFTER(MISSION_WAIT_INTRO)
}
});
// ################################################################
// start
STAGE_MAIN({TAKE_ALWAYS})
{
g_pEnvironment->ChangeBackground(cDesertBackground::ID, ENVIRONMENT_MIX_CURTAIN, 1.0f, coreVector2(1.0f,0.0f));
g_pEnvironment->SetTargetDirectionNow(ENVIRONMENT_DEFAULT_DIRECTION);
g_pEnvironment->SetTargetSideNow (ENVIRONMENT_DEFAULT_SIDE);
g_pEnvironment->SetTargetSpeedNow (6.0f);
g_pGame->StartIntro();
STAGE_FINISH_NOW
});
// ################################################################
// change background appearance
STAGE_MAIN({TAKE_ALWAYS, 0u, 1u, 2u})
{
cDesertBackground* pBackground = d_cast<cDesertBackground*>(g_pEnvironment->GetBackground());
pBackground->GetOutdoor()->LerpHeightNow(-0.5f, -30.0f);
pBackground->SetGroundDensity(0u, 0.0f);
pBackground->SetGroundDensity(1u, 0.0f);
pBackground->SetGroundDensity(2u, 0.0f);
pBackground->SetGroundDensity(3u, 0.0f);
pBackground->SetGroundDensity(5u, 1.0f);
pBackground->SetTrail(true);
STAGE_FINISH_NOW
});
// ################################################################
// show mission name
STAGE_MAIN({TAKE_ALWAYS, 0u})
{
if(HAS_FLAG(g_pGame->GetStatus(), GAME_STATUS_NAMELESS))
{
STAGE_FINISH_NOW
}
else
{
if(STAGE_BEGINNING)
{
g_pGame->GetInterface()->ShowMission(this);
}
STAGE_FINISH_AFTER(MISSION_WAIT_PLAY)
}
});
// ################################################################
// wait for play
STAGE_MAIN({TAKE_ALWAYS, 0u})
{
STAGE_FINISH_PLAY
});
// ################################################################
// ghost appears for few seconds (zelda wizzrobe)
// - no individual enemies at the beginning, otherwise the player won't see the mechanics if they just shoot them down
// - on first wave, two groups active at the same time to continue with changes while keeping enemies active for a longer time
// - on first wave, two different invincible states, hidden and flickering, to give the player perception of change while he has to wait (loading bar)
// - on first wave, diamond shape to not be able to kill 2 groups at the same time
// - on snake wave, pattern should not have too long straight lines, as this makes it too easy, and should have no corners, as this creates placement artifacts
// - stuttering side-movement needs to be only in one direction, otherwise player does not recognize the move pattern
// - stuttering side-movement needs a safe-space (bottom screen) because being in the middle of them is hard to evade, as it's already hard to hit
// - player should already look in the right direction at the start of the threshold wave, the previous wave is doing that with the movement-direction of the enemies
// - on threshold wave, the threshold should be shifted a bit, so that players don't hit with a side attack, and enemy bullets fly at an angle (more beautiful)
// - in order wave, no 3 in a row should be attackable from one and the same position (2 is ok because that's logical), if possible don't move 2 fields between 2 attacks and only rotate by 90 degrees
// - memory (invisible enemies that you can hit) didn't work at all, didn't create enough tension, and was too easy (just mow down), but would be good for badge
// TASK: destroy all broken enemies on their first appearance
// TASK: let the very last enemy survive, alone
// TASK EXTRA: kill 4 very quick enemies before they disappear
// ACHIEVEMENT: follow the head of the snake group for at least 10 seconds
// TODO 1: hardmode: bad visibility (sand storm) in one of the missions here, maybe has to disappear completely in a sinusoidal manner (or in another way), also bullets due to pressure
// TODO 1: hardmode: enemies also shoot when getting invisible
m_aInsanityStage[0] = [this]()
{
STAGE_ADD_PATH(pPath1)
{
pPath1->Reserve(17u);
pPath1->AddNode(coreVector2( 0.0f, 0.0f), coreVector2( 1.0f, 1.0f).Normalized());
pPath1->AddNode(coreVector2( 0.35f, 0.5f), coreVector2( 0.0f, 1.0f));
pPath1->AddNode(coreVector2( 0.0f, 0.85f), coreVector2(-1.0f, 0.0f));
pPath1->AddNode(coreVector2(-0.35f, 0.5f), coreVector2( 0.0f,-1.0f));
pPath1->AddNode(coreVector2( 0.0f, 0.0f), coreVector2( 1.0f,-1.0f).Normalized());
pPath1->AddNode(coreVector2( 0.35f,-0.5f), coreVector2( 0.0f,-1.0f));
pPath1->AddNode(coreVector2( 0.0f, -0.85f), coreVector2(-1.0f, 0.0f));
pPath1->AddNode(coreVector2(-0.35f,-0.5f), coreVector2( 0.0f, 1.0f));
pPath1->AddNode(coreVector2( 0.0f, 0.0f), coreVector2( 1.0f, 1.0f).Normalized());
pPath1->AddNode(coreVector2( 0.5f, 0.35f), coreVector2( 1.0f, 0.0f));
pPath1->AddNode(coreVector2( 0.85f, 0.0f), coreVector2( 0.0f,-1.0f));
pPath1->AddNode(coreVector2( 0.5f, -0.35f), coreVector2(-1.0f, 0.0f));
pPath1->AddNode(coreVector2( 0.0f, 0.0f), coreVector2(-1.0f, 1.0f).Normalized());
pPath1->AddNode(coreVector2(-0.5f, 0.35f), coreVector2(-1.0f, 0.0f));
pPath1->AddNode(coreVector2(-0.85f, 0.0f), coreVector2( 0.0f,-1.0f));
pPath1->AddNode(coreVector2(-0.5f, -0.35f), coreVector2( 1.0f, 0.0f));
pPath1->AddLoop();
pPath1->Refine();
});
STAGE_ADD_PATH(pPath2)
{
pPath2->Reserve(2u);
pPath2->AddNode(coreVector2(0.0f, 1.3f), coreVector2(0.0f,-1.0f));
pPath2->AddNode(coreVector2(0.0f,-1.3f), coreVector2(0.0f,-1.0f));
pPath2->Refine();
});
STAGE_ADD_SQUAD(pSquad1, cScoutEnemy, 158u)
{
STAGE_FOREACH_ENEMY_ALL(pSquad1, pEnemy, i)
{
pEnemy->SetSize (coreVector3(1.0f,1.0f,1.0f) * 1.4f);
pEnemy->Configure(4, COLOR_SHIP_GREY);
pEnemy->AddStatus(ENEMY_STATUS_GHOST | ENEMY_STATUS_HIDDEN);
});
});
constexpr coreUintW iRange = sizeof(coreUint32) * 8u;
constexpr coreUint32 iSnakeCount = 6u;
constexpr coreFloat fQuickDelay = 1.8f;
STAGE_GET_START(12u + iSnakeCount + GAME_PLAYERS)
STAGE_GET_UINT (iStateActive)
STAGE_GET_UINT (iStateGhost)
STAGE_GET_FLOAT (fChangeTime)
STAGE_GET_UINT (iChangeCount)
STAGE_GET_UINT_ARRAY (aiSnakeIndex, iSnakeCount)
STAGE_GET_UINT (iSnakeShift, iSnakeShift = iSnakeCount)
STAGE_GET_FLOAT (fLastValue)
STAGE_GET_UINT (iLastDual)
STAGE_GET_UINT (iFlipShow)
STAGE_GET_UINT (iFlipHide)
STAGE_GET_UINT (iFlipCount)
STAGE_GET_UINT (iQuickCount)
STAGE_GET_UINT (iBlockShot)
STAGE_GET_FLOAT_ARRAY(afFollowTime, GAME_PLAYERS)
STAGE_GET_END
if(STAGE_CLEARED)
{
if(m_iInsanity)
{
if(STAGE_SUB(10u)) STAGE_RESURRECT(pSquad1, 124u, 125u)
else if(STAGE_SUB(11u)) STAGE_RESURRECT(pSquad1, 126u, 141u)
else if(STAGE_SUB(12u)) STAGE_RESURRECT(pSquad1, 142u, 157u)
else if(STAGE_SUB(13u)) {}
}
else
{
if(STAGE_SUB( 1u)) STAGE_RESURRECT(pSquad1, 0u, 15u)
else if(STAGE_SUB( 2u)) STAGE_RESURRECT(pSquad1, 16u, 31u)
else if(STAGE_SUB( 3u)) STAGE_RESURRECT(pSquad1, 32u, 47u)
else if(STAGE_SUB( 4u)) STAGE_RESURRECT(pSquad1, 48u, 55u)
else if(STAGE_SUB( 5u)) STAGE_RESURRECT(pSquad1, 56u, 59u) // quick wave
else if(STAGE_SUB( 6u)) STAGE_RESURRECT(pSquad1, 60u, 75u)
else if(STAGE_SUB( 7u)) STAGE_RESURRECT(pSquad1, 76u, 81u)
else if(STAGE_SUB( 8u)) STAGE_RESURRECT(pSquad1, 82u, 93u)
else if(STAGE_SUB( 9u)) STAGE_RESURRECT(pSquad1, 94u, 123u)
}
iStateActive = 0u;
iStateGhost = 0u;
fChangeTime = 0.0f;
iChangeCount = 0u;
}
ASSERT(pSquad1->GetNumEnemiesAlive() < iRange)
const coreFloat fChangeTimePrev = fChangeTime;
const coreUint32 iChangeCountPrev = iChangeCount;
fChangeTime += 1.0f * TIME;
cHelper* pHelper = g_pGame->GetHelper(ELEMENT_GREEN);
if((m_iStageSub == 5u) && STAGE_BEGINNING2)
{
pHelper->Resurrect(false);
pHelper->SetPosition(coreVector3(0.0f,0.0f,0.0f));
}
else if((m_iStageSub == 6u) && STAGE_BEGINNING2)
{
pHelper->Kill(false);
}
if(!pHelper->HasStatus(HELPER_STATUS_DEAD))
{
if(fChangeTime >= fQuickDelay)
{
pHelper->SetAlpha(1.0f);
}
else if(fChangeTime >= fQuickDelay - 1.0f)
{
pHelper->SetAlpha((g_CurConfig.Graphics.iFlash && (FRACT(fChangeTime * 20.0f) < 0.5f)) ? 0.9f : 0.4f);
pHelper->RemoveStatus(HELPER_STATUS_HIDDEN);
}
else
{
pHelper->AddStatus(HELPER_STATUS_HIDDEN);
}
}
coreBool bPostpone = false;
if(m_iStageSub == 1u)
{
constexpr coreUint32 iGroupA = coreMath::RotateLeft32(0b0000'0000'0000'1111u, 0u % iRange);
constexpr coreUint32 iGroupB = coreMath::RotateLeft32(0b0000'0000'1111'0000u, 0u % iRange);
constexpr coreUint32 iGroupC = coreMath::RotateLeft32(0b0000'1111'0000'0000u, 0u % iRange);
constexpr coreUint32 iGroupD = coreMath::RotateLeft32(0b1111'0000'0000'0000u, 0u % iRange);
if(FRACT(fChangeTime * 1.05f) < FRACT(fChangeTimePrev * 1.05f))
{
iChangeCount += 1u;
iStateActive |= iStateGhost;
switch(iChangeCount % 4u)
{
default: UNREACHABLE
case 0u: iStateActive &= ~iGroupA; iStateGhost = iGroupD; break;
case 1u: iStateActive &= ~iGroupB; iStateGhost = iGroupA; break;
case 2u: iStateActive &= ~iGroupC; iStateGhost = iGroupB; break;
case 3u: iStateActive &= ~iGroupD; iStateGhost = iGroupC; break;
}
}
}
else if(m_iStageSub == 2u)
{
constexpr coreUint32 iGroupA = coreMath::RotateLeft32(0b11110000'11110000u, 16u % iRange);
constexpr coreUint32 iGroupB = coreMath::RotateLeft32(0b00001111'00001111u, 16u % iRange);
if(FRACT(fChangeTime * 0.75f) < FRACT(fChangeTimePrev * 0.75f))
{
iChangeCount += 1u;
iStateActive |= iStateGhost;
switch(iChangeCount % 2u)
{
default: UNREACHABLE
case 0u: iStateActive &= ~iGroupA; iStateGhost = iGroupA; break;
case 1u: iStateActive &= ~iGroupB; iStateGhost = iGroupB; break;
}
}
}
else if(m_iStageSub == 3u)
{
constexpr coreUint32 iGroupA = coreMath::RotateLeft32(0b11111111'00000000u, 32u % iRange);
constexpr coreUint32 iGroupB = coreMath::RotateLeft32(0b00000000'11111111u, 32u % iRange);
if(FRACT(fChangeTime * 0.75f) < FRACT(fChangeTimePrev * 0.75f))
{
iChangeCount += 1u;
iStateActive |= iStateGhost;
switch(iChangeCount % 2u)
{
default: UNREACHABLE
case 0u: iStateActive &= ~iGroupA; iStateGhost = iGroupA; break;
case 1u: iStateActive &= ~iGroupB; iStateGhost = iGroupB; break;
}
}
}
else if(m_iStageSub == 4u)
{
if(FRACT(fChangeTime * 2.5f) < FRACT(fChangeTimePrev * 2.5f))
{
iChangeCount += 1u;
iStateActive = (iChangeCount % 2u) ? 0xFFFFFFFFu : 0x00000000u;
iStateGhost = (iChangeCount % 2u) ? 0x00000000u : 0xFFFFFFFFu;
}
}
else if(m_iStageSub == 5u)
{
if(fChangeTime >= fQuickDelay + 1.2f)
{
pSquad1->ClearEnemies(false);
bPostpone = true;
}
else if(InBetween(fQuickDelay, fChangeTimePrev, fChangeTime))
{
iChangeCount += 1u;
iStateActive = coreMath::RotateLeft32(0b1111u, 56u % iRange);
iStateGhost = 0x00000000u;
}
}
else if(m_iStageSub == 6u)
{
constexpr coreUint32 iGroupA = coreMath::RotateLeft32(0b11111111'00000000u, 60u % iRange);
constexpr coreUint32 iGroupB = coreMath::RotateLeft32(0b00000000'11111111u, 60u % iRange);
if(FRACT(fChangeTime * 0.75f) < FRACT(fChangeTimePrev * 0.75f))
{
iChangeCount += 1u;
iStateActive |= iStateGhost;
switch(iChangeCount % 2u)
{
default: UNREACHABLE
case 0u: iStateActive &= ~iGroupA; iStateGhost = iGroupA; break;
case 1u: iStateActive &= ~iGroupB; iStateGhost = iGroupB; break;
}
}
}
else if(m_iStageSub == 7u)
{
iChangeCount = 1u - iChangeCount;
iStateActive = 0x00000000u;
iStateGhost = 0xFFFFFFFFu;
STAGE_FOREACH_ENEMY(pSquad1, pEnemy, i)
{
coreBool bPast = true;
STAGE_FOREACH_PLAYER(pPlayer, i)
{
if(pPlayer->GetPosition().x < pEnemy->GetPosition().x + 10.0f) bPast = false;
});
if(bPast) ADD_BIT(iStateActive, i % iRange)
});
}
else if(m_iStageSub == 8u)
{
iChangeCount = 1u - iChangeCount;
if(fChangeTime >= (1.0f/0.75f))
{
iStateGhost = 0xFFFFFFFFu;
}
if(fChangeTime >= (2.0f/0.75f))
{
constexpr coreUintW iFirst = 82u;
switch(pSquad1->GetNumEnemiesAlive())
{
default: UNREACHABLE
case 12u: iStateActive = BIT((iFirst + 3u) % iRange); break;
case 11u: iStateActive = BIT((iFirst + 7u) % iRange); break;
case 10u: iStateActive = BIT((iFirst + 10u) % iRange); break;
case 9u: iStateActive = BIT((iFirst + 6u) % iRange); break;
case 8u: iStateActive = BIT((iFirst + 11u) % iRange); break;
case 7u: iStateActive = BIT((iFirst + 1u) % iRange); break;
case 6u: iStateActive = BIT((iFirst + 5u) % iRange); break;
case 5u: iStateActive = BIT((iFirst + 8u) % iRange); break;
case 4u: iStateActive = BIT((iFirst + 4u) % iRange); break;
case 3u: iStateActive = BIT((iFirst + 2u) % iRange); break;
case 2u: iStateActive = BIT((iFirst + 9u) % iRange); break;
case 1u: iStateActive = BIT((iFirst + 0u) % iRange); break;
case 0u: iStateActive = 0u; break;
}
}
}
else if(m_iStageSub == 9u)
{
if(FRACT(fChangeTime * 5.0f) < FRACT(fChangeTimePrev * 5.0f))
{
iChangeCount += 1u;
if(iSnakeShift >= 2u)
{
if(aiSnakeIndex[iSnakeShift - 1u]) REMOVE_BIT(iStateActive, aiSnakeIndex[iSnakeShift - 1u] % iRange)
if(aiSnakeIndex[iSnakeShift - 1u]) REMOVE_BIT(iStateGhost, aiSnakeIndex[iSnakeShift - 1u] % iRange)
if(aiSnakeIndex[iSnakeShift - 2u]) ADD_BIT (iStateActive, aiSnakeIndex[iSnakeShift - 2u] % iRange)
const coreUint32 iNewShift = MIN(pSquad1->GetNumEnemiesAlive(), iSnakeCount);
if(iSnakeShift != iNewShift)
{
iSnakeShift = iNewShift;
}
else
{
std::memmove(aiSnakeIndex + 1u, aiSnakeIndex, sizeof(coreUint32) * (iSnakeShift - 1u));
aiSnakeIndex[0] = 0u;
for(coreUintW i = 94u; i < 124u; ++i)
{
if(!pSquad1->GetEnemy(i)->HasStatus(ENEMY_STATUS_DEAD) && !HAS_BIT(iStateGhost, i % iRange))
{
ADD_BIT(iStateGhost, i % iRange)
aiSnakeIndex[0] = i;
break;
}
}
}
}
else
{
aiSnakeIndex[0] = 0u;
}
}
STAGE_FOREACH_PLAYER(pPlayer, i)
{
const coreFloat fOffset = (0.25f/5.0f) + (1.0f/5.0f) * I_TO_F(iSnakeCount - iSnakeShift);
const coreVector2 vPos = pPath1->CalcPosition(FMOD(MAX0(fChangeTime - fOffset), pPath1->GetTotalDistance()));
const coreVector2 vDiff = pPlayer->GetPosition().xy() - vPos * FOREGROUND_AREA;
if(vDiff.LengthSq() < POW2(10.0f))
{
afFollowTime[i] += 1.0f * TIME;
if(afFollowTime[i] >= 10.0f) STAGE_BADGE(3u, BADGE_ACHIEVEMENT, pPlayer->GetPosition())
}
else
{
afFollowTime[i] = 0.0f;
}
});
}
else if(m_iStageSub == 10u)
{
if(FRACT(fChangeTime * 0.75f) < FRACT(fChangeTimePrev * 0.75f))
{
iChangeCount += 1u;
iStateActive |= iStateGhost;
iStateGhost = 0xFFFFFFFFu;
}
}
else if(m_iStageSub == 11u)
{
constexpr coreUint32 iGroupA = coreMath::RotateLeft32(0b10101010'10101010u, 126u % iRange);
constexpr coreUint32 iGroupB = coreMath::RotateLeft32(0b01010101'01010101u, 126u % iRange);
if(FRACT(fChangeTime * 0.75f) < FRACT(fChangeTimePrev * 0.75f))
{
iChangeCount += 1u;
iStateActive |= iStateGhost;
switch(iChangeCount % 2u)
{
default: UNREACHABLE
case 0u: iStateActive &= ~iGroupA; iStateGhost = iGroupA; break;
case 1u: iStateActive &= ~iGroupB; iStateGhost = iGroupB; break;
}
if((iChangeCount == 3u) && m_Tiger.ResurrectHelper(ELEMENT_ORANGE, false))
{
ASSERT(pHelper != g_pGame->GetHelper(ELEMENT_ORANGE))
g_pGame->GetHelper(ELEMENT_ORANGE)->SetPosition(coreVector3(0.0f,0.5f,0.0f) * FOREGROUND_AREA3);
}
}
}
else if(m_iStageSub == 12u)
{
constexpr coreUint32 iGroupA = coreMath::RotateLeft32(0b10011001'10011001u, 142u % iRange);
constexpr coreUint32 iGroupB = coreMath::RotateLeft32(0b01100110'01100110u, 142u % iRange);
if(FRACT(fChangeTime * 0.75f) < FRACT(fChangeTimePrev * 0.75f))
{
iChangeCount += 1u;
iStateActive |= iStateGhost;
switch(iChangeCount % 2u)
{
default: UNREACHABLE
case 0u: iStateActive &= ~iGroupA; iStateGhost = iGroupA; break;
case 1u: iStateActive &= ~iGroupB; iStateGhost = iGroupB; break;
}
}
}
const auto nAimFunc = [&](cEnemy* OUTPUT pEnemy, const coreUintW i)
{
coreVector2 vDir;
if(i < 48u) vDir = pEnemy->AimAtPlayerDual((i / 8u) % 2u);
else if(i < 60u) vDir = pEnemy->AimAtPlayerDual(i % 2u);
else if(i < 76u) vDir = pEnemy->AimAtPlayerSide();
else if(i < 94u) vDir = pEnemy->AimAtPlayerDual(((i - 76u) / 3u) % 2u);
else if(i < 124u) vDir = pEnemy->AimAtPlayerDual((pSquad1->GetNumEnemiesAlive() <= 15u) ? 1u : 0u);
else if(i < 126u) vDir = pEnemy->AimAtPlayerSide();
else vDir = pEnemy->AimAtPlayerDual(((i - 126u) / 8u) % 2u);
pEnemy->SetDirection(coreVector3(vDir.Normalized(), 0.0f));
};
STAGE_FOREACH_ENEMY(pSquad1, pEnemy, i)
{
const coreVector3 vSaveDir = pEnemy->GetDirection(); // movement patterns should not affect direction and aim
if(i < 60u)
{
// no path movement
}
else if(i < 76u)
{
STAGE_LIFETIME(pEnemy, 0.7f, 0.7f * I_TO_F((i - 60u) / 4u))
STAGE_REPEAT(pPath2->GetTotalDistance())
const coreVector2 vFactor = coreVector2(1.0f,1.0f);
const coreVector2 vOffset = coreVector2(I_TO_F((i - 60u) % 4u) * 0.2f - 0.9f, 0.0f);
pEnemy->DefaultMovePath(pPath2, vFactor, vOffset * vFactor, fLifeTime);
pEnemy->InvertY();
if(((i - 60u) / 4u) % 2u) pEnemy->Rotate180();
}
else if(i < 82u)
{
STAGE_LIFETIME(pEnemy, 1.1f, 1.3f * I_TO_F((i - 76u) % 2u))
STAGE_REPEAT(pPath2->GetTotalDistance())
const coreVector2 vFactor = coreVector2(1.0f,1.0f);
const coreVector2 vOffset = coreVector2((I_TO_F(i - 76u) - 2.5f) * 0.3f, 0.0f);
pEnemy->DefaultMovePath(pPath2, vFactor, vOffset * vFactor, fLifeTime);
pEnemy->Rotate90();
}
if(iChangeCount != iChangeCountPrev)
{
if(i < 16u)
{
const coreVector2 vPos = (0.75f * StepRotated90X(i / 4u) + 0.25f * StepRotated90X(i % 4u)) * 0.5f * SQRT2;
pEnemy->SetPosition(coreVector3(vPos.Rotated45() * FOREGROUND_AREA, 0.0f));
}
else if(i < 32u)
{
const coreVector2 vPos = coreVector2(((i - 16u) % 2u) ? 0.8f : 0.9f, (I_TO_F((i - 16u) % 8u) - 3.5f) * 0.27f);
pEnemy->SetPosition(coreVector3(-vPos.Rotated90() * FOREGROUND_AREA, 0.0f));
if(i < 24u) {}
else if(i < 32u) pEnemy->Rotate180();
}
else if(i < 48u)
{
const coreBool bVertical = (i < 40u);
const coreBool bGroup = (iChangeCount % 2u);
if(bVertical == bGroup)
{
const coreFloat fSide = -0.95f + 1.9f/7.0f * I_TO_F((i - 32u) % 8u);
const coreVector2 vTarget = pEnemy->NearestPlayerDual(((i - 32u) / 8u) % 2u)->GetPosition().xy();
if(bVertical) pEnemy->SetPosition(coreVector3(vTarget.x, fSide * FOREGROUND_AREA.y, 0.0f));
else pEnemy->SetPosition(coreVector3(fSide * FOREGROUND_AREA.x, vTarget.y, 0.0f));
}
}
else if(i < 56u)
{
STAGE_LIFETIME(pEnemy, 0.8f, 0.325f * I_TO_F(i - 48u))
STAGE_REPEAT(pPath2->GetTotalDistance())
const coreVector2 vFactor = coreVector2(1.0f,1.0f);
const coreVector2 vOffset = coreVector2((I_TO_F((((i - 48u) % 4u) * 2u + 1u) % 5u) - 1.5f) * 0.3f - 0.4f, 0.0f);
pEnemy->DefaultMovePath(pPath2, vFactor, vOffset * vFactor, fLifeTime);
pEnemy->Rotate90()->InvertX();
}
else if(i < 60u)
{
const coreVector2 vPos = coreVector2(0.0f, 0.9f);
pEnemy->SetPosition(coreVector3(MapStepRotated90(vPos * FOREGROUND_AREA, i - 56u), 0.0f));
}
else if(i < 82u)
{
// no point movement
}
else if(i < 94u)
{
const coreVector2 vPos = coreVector2((I_TO_F((i - 82u) % 3u) - 1.0f) * 0.3f, 0.8f);
pEnemy->SetPosition(coreVector3(MapStepRotated90(vPos * FOREGROUND_AREA, (i - 82u) / 3u), 0.0f));
}
else if(i < 124u)
{
if(aiSnakeIndex[0] == i)
{
const coreFloat fOffset = (1.0f/5.0f) * I_TO_F(iSnakeCount - iSnakeShift);
const coreVector2 vPos = pPath1->CalcPosition(FMOD(fChangeTime - fOffset, pPath1->GetTotalDistance()));
pEnemy->SetPosition(coreVector3(vPos * FOREGROUND_AREA, 0.0f));
}
}
else if(i < 126u)
{
const coreVector2 vPos = coreVector2(((i - 124u) % 2u) ? -0.6f : 0.6f, 0.6f);
pEnemy->SetPosition(coreVector3(vPos * FOREGROUND_AREA, 0.0f));
}
else if(i < 142u)
{
const coreVector2 vPos = coreVector2(((i - 126u) % 2u) ? 0.8f : 0.9f, (I_TO_F((i - 126u) % 8u) - 3.5f) * 0.27f);
pEnemy->SetPosition(coreVector3(-vPos * FOREGROUND_AREA, 0.0f));
if(i < 134u) {}
else if(i < 142u) pEnemy->Rotate180();
}
else if(i < 158u)
{
const coreUintW X = ((i - 142u)) % 2u;
const coreUintW Y = ((i - 142u) / 2u) % 2u;
const coreVector2 vPos = coreVector2((I_TO_F(X) + 2.5f) * 0.27f + ((Y == 1u) ? -0.1f : 0.0f), (I_TO_F(Y) + 2.5f) * 0.27f);
pEnemy->SetPosition(coreVector3(vPos * FOREGROUND_AREA, 0.0f));
if(i < 146u) {}
else if(i < 150u) pEnemy->InvertY();
else if(i < 154u) pEnemy->InvertX()->InvertY();
else if(i < 158u) pEnemy->InvertX();
}
}
pEnemy->SetDirection(vSaveDir);
if(iChangeCount != iChangeCountPrev)
{
if(HAS_BIT(iStateActive, i % iRange))
{
if(pEnemy->HasStatus(ENEMY_STATUS_GHOST))
{
pEnemy->SetBaseColor(COLOR_SHIP_GREEN);
pEnemy->SetAlpha (1.0f);
pEnemy->RemoveStatus(ENEMY_STATUS_GHOST | ENEMY_STATUS_HIDDEN);
iBlockShot = !iBlockShot;
if((!g_pGame->IsEasy() || iBlockShot) && g_pForeground->IsVisiblePoint(pEnemy->GetPosition().xy()) && !m_iInsanity)
{
nAimFunc(pEnemy, i);
const coreVector2 vPos = pEnemy->GetPosition ().xy();
const coreVector2 vDir = pEnemy->GetDirection().xy();
const coreVector2 vTan = vDir.Rotated90();
g_pGame->GetBulletManagerEnemy()->AddBullet<cConeBullet>(5, 1.3f, pEnemy, vPos + vTan, vDir)->ChangeSize(1.3f);
g_pGame->GetBulletManagerEnemy()->AddBullet<cConeBullet>(5, 1.3f, pEnemy, vPos - vTan, vDir)->ChangeSize(1.3f);
g_pSpecialEffects->CreateSplashColor(coreVector3(vPos, 0.0f), 5.0f, 3u, COLOR_ENERGY_ORANGE);
g_pSpecialEffects->PlaySound(coreVector3(vPos, 0.0f), 1.0f, 1.0f, SOUND_WEAPON_ENEMY);
}
}
}
else
{
if(!pEnemy->HasStatus(ENEMY_STATUS_GHOST))
{
pEnemy->SetBaseColor(COLOR_SHIP_GREY);
pEnemy->SetAlpha (0.0f);
pEnemy->AddStatus (ENEMY_STATUS_GHOST | ENEMY_STATUS_HIDDEN);
}
}
}
if(!HAS_BIT(iStateActive, i % iRange) && HAS_BIT(iStateGhost, i % iRange))
{
nAimFunc(pEnemy, i);
pEnemy->SetAlpha ((g_CurConfig.Graphics.iFlash && (FRACT(fChangeTime * 20.0f) < 0.5f)) ? 0.9f : 0.4f);
pEnemy->RemoveStatus(ENEMY_STATUS_HIDDEN);
}
if(g_pGame->IsTask())
{
if((m_iStageSub == 9u) && (pSquad1->GetNumEnemiesAlive() == 1u))
{
if(!fLastValue) iLastDual = g_pGame->GetPlayerIndex(pEnemy->NearestPlayerDual(1u));
fLastValue += 0.8f * TIME;
if(fLastValue >= 1.8f)
{
pEnemy->SetPosition(pEnemy->GetPosition() + pEnemy->GetDirection() * (320.0f * (fLastValue - 1.8f + 0.25f) * TIME));
}
else
{
coreVector2 vPos = pEnemy->GetPosition().xy();
coreVector2 vDir = pEnemy->AimAtPlayerDual(iLastDual).Normalized();
if(fLastValue >= 1.5f) vDir *= coreMatrix3::Rotation(LERPB(0.0f*PI, -1.0f*PI, (fLastValue - 1.5f) / 0.3f)).m12();
else if(fLastValue >= 1.0f) vPos += vDir * (60.0f * (fLastValue - 1.5f) * TIME);
pEnemy->SetPosition (coreVector3(CLAMP(vPos.x, -FOREGROUND_AREA.x, FOREGROUND_AREA.x), CLAMP(vPos.y, -FOREGROUND_AREA.y, FOREGROUND_AREA.y), 0.0f));
pEnemy->SetDirection(coreVector3(vDir, 0.0f));
}
if(fLastValue >= 1.0f)
{
pEnemy->AddStatus(ENEMY_STATUS_GHOST_BULLET);
STAGE_DELAY_START
}
if(!g_pForeground->IsVisiblePoint(pEnemy->GetPosition().xy()))
{
STAGE_BADGE(1u, BADGE_NORMAL, pEnemy->GetPosition())
pEnemy->Kill(true);
STAGE_DELAY_END
}
}
constexpr coreUintW aiFlip[] = {14u, 22u, 26u, 41u, 65u, 74u, 79u};
const coreUintW iFlipIndex = std::find(aiFlip, aiFlip + ARRAY_SIZE(aiFlip), i) - aiFlip;
if((iFlipIndex < ARRAY_SIZE(aiFlip)) && !HAS_BIT(iFlipHide, iFlipIndex))
{
if(!pEnemy->HasStatus(ENEMY_STATUS_GHOST))
{
pEnemy->SetOrientation(coreVector3(0.0f,0.0f,-1.0f));
pEnemy->AddStatus (ENEMY_STATUS_CRASH);
ADD_BIT(iFlipShow, iFlipIndex)
if(pEnemy->ReachedDeath())
{
if(++iFlipCount == ARRAY_SIZE(aiFlip))
{
STAGE_BADGE(0u, BADGE_EASY, pEnemy->GetPosition())
}
else
{
g_pGame->GetCombatText()->DrawProgress(iFlipCount, ARRAY_SIZE(aiFlip), pEnemy->GetPosition());
g_pSpecialEffects->PlaySound(pEnemy->GetPosition(), 1.0f, SPECIAL_SOUND_PROGRESS(iFlipCount, ARRAY_SIZE(aiFlip)), SOUND_ITEM_02);
}
}
}
else if(HAS_BIT(iFlipShow, iFlipIndex))
{
pEnemy->SetOrientation(coreVector3(0.0f,0.0f,1.0f));
pEnemy->RemoveStatus (ENEMY_STATUS_CRASH);
ADD_BIT(iFlipHide, iFlipIndex)
}
}
if(HAS_BIT(iFlipShow, iFlipIndex) && !HAS_BIT(iFlipHide, iFlipIndex))
{
pEnemy->DefaultRotate(pEnemy->GetLifeTime() * 5.0f);
}
}
if(g_pGame->IsTaskExtra())
{
if(i >= 56u && i < 60u)
{
if(pEnemy->ReachedDeath())
{
if(++iQuickCount == 4u) STAGE_BADGE(2u, BADGE_HARD, pEnemy->GetPosition())
}
}
}
this->CrashEnemy(pEnemy);
});
if(!m_iInsanity)
{
if(STAGE_BEGINNING)
{
g_pEnvironment->SetTargetDirectionLerp(coreVector2(1.0f,1.0f).Normalized(), 30.0f);
}
if(!bPostpone) STAGE_WAVE(0u, "3-1", {50.0f, 75.0f, 100.0f, 125.0f, 250.0f}) // DREIZEHN
}
};
STAGE_MAIN({TAKE_ALWAYS, 0u})
{
m_aInsanityStage[0]();
},
STAGE_PRE()
{
g_pGame->GetEnemyManager()->PrefetchEnemy<cScoutEnemy>();
g_pGame->GetBulletManagerEnemy()->PrefetchBullet<cConeBullet>();
});
// ################################################################
// reset helper
STAGE_MAIN({TAKE_ALWAYS, 0u})
{
g_pGame->KillHelpers();
STAGE_FINISH_NOW
});
// ################################################################
// change background appearance
STAGE_MAIN({TAKE_ALWAYS, 1u})
{
g_pEnvironment->SetTargetDirectionNow(coreVector2(1.0f,1.0f).Normalized());
STAGE_FINISH_NOW
});
// ################################################################
// wait for play
STAGE_MAIN({TAKE_ALWAYS, 1u})
{
STAGE_FINISH_PLAY
});
// ################################################################
// whac-a-mole
// - smoke can distract from bullets
// - non-linear movement is harder to track
// - shooting on "hide" instead of "show" is too overwhelming, identifying both initial bullet-direction and movement at the same time
// - 8-enemy pattern is quite overwhelming (order: 0, 3, 5, 2, 6, 1, 7, 4 (flawed)) (order: 0, 3, 6, 2, 7, 4, 1, 5 (perfect)) (0, 5, 2, 7, 4, 1, 6, 3 (circular))
// - during rotation, if move pattern moves against rotation the enemy stays in the air, which looks weird
// - hiding current enemy movement did not add any value, especially on rotating 8 enemies it is just too overwhelming (maybe for hard mode ? might be too light, also change pattern or order ?)
// - first enemy flies from below maybe through player, to show there is no harm
// TASK: kill golden enemy
// TASK: collect all eggs
// ACHIEVEMENT: attack every enemy once as the wrong target
// TODO 1: hardmode: big can change, like in tiger boss, just (iBig << 1u), maybe not on the first 1-2 hits
// TODO 5: coop: one enemy must be hit by both within the time limit
// TODO 5: idea: enemies which move close together (into the center)
// TODO 5: idea: eggs are layed when hitting an enemy, and stay in final phase? (will the last egg be hidden?)
// TODO 5: badge: ride the wave
m_aInsanityStage[1] = [this]()
{
constexpr coreUintW iNumEnemies = 8u;
STAGE_ADD_SQUAD(pSquad1, cCinderEnemy, iNumEnemies)
{
STAGE_FOREACH_ENEMY_ALL(pSquad1, pEnemy, i)
{
pEnemy->SetCollisionModifier(coreVector3(1.0f,1.0f,1.0f) * 1.1f);
pEnemy->Configure(1000, COLOR_SHIP_GREY);
pEnemy->AddStatus(ENEMY_STATUS_IMMORTAL | ENEMY_STATUS_GHOST | ENEMY_STATUS_HIDDEN);
pEnemy->Resurrect();
});
});
STAGE_GET_START(15u + 4u * iNumEnemies)
STAGE_GET_UINT (iVisible)
STAGE_GET_UINT (iBig)
STAGE_GET_UINT (iGold)
STAGE_GET_UINT (iHit)
STAGE_GET_UINT (iPoints)
STAGE_GET_UINT (iIteration)
STAGE_GET_UINT (iSingle)
STAGE_GET_UINT (iEggState)
STAGE_GET_UINT (iRevengeState)
STAGE_GET_FLOAT (fRotaSpeed)
STAGE_GET_FLOAT (fRotaValue)
STAGE_GET_FLOAT (fTime, fTime = 1.0f;)
STAGE_GET_FLOAT (fDelay, fDelay = 1.0f;)
STAGE_GET_VEC2_ARRAY(avPosFrom, iNumEnemies)
STAGE_GET_VEC2_ARRAY(avPosTo, iNumEnemies)
STAGE_GET_VEC2 (vSpawnPos)
STAGE_GET_END
cHelper* pHelper = g_pGame->GetHelper(ELEMENT_MAGENTA);
if(STAGE_BEGINNING)
{
avPosTo[0] = m_iInsanity ? HIDDEN_POS : coreVector2( 0.0f,-1.3f);
avPosTo[1] = m_iInsanity ? HIDDEN_POS : coreVector2( 0.0f, 1.3f);
avPosTo[2] = m_iInsanity ? HIDDEN_POS : coreVector2(-1.3f, 0.0f);
avPosTo[3] = m_iInsanity ? HIDDEN_POS : coreVector2( 1.3f, 0.0f);
avPosTo[4] = HIDDEN_POS;
avPosTo[5] = HIDDEN_POS;
avPosTo[6] = HIDDEN_POS;
avPosTo[7] = HIDDEN_POS;
this->EnableCorrect();
}
const auto nAttackFunc = [&](cEnemy* pEnemy, const coreUintW i)
{
const coreVector2 vPos = pEnemy->GetPosition().xy();
const coreFloat fBase = pEnemy->AimAtPlayerDual((iIteration % 2u) ? 0u : 1u).Angle();
const coreUintW iNum = g_pGame->IsEasy() ? 3u : 1u;
for(coreUintW j = iNum; j--; )
{
const coreVector2 vDir = coreVector2::Direction(DEG_TO_RAD((I_TO_F(j) - I_TO_F(iNum - 1u) * 0.5f) * 3.0f) + fBase);
g_pGame->GetBulletManagerEnemy()->AddBullet<cViewBullet>(5, 0.6f, pEnemy, vPos, vDir)->ChangeSize(1.6f);
}
g_pSpecialEffects->CreateSplashColor(coreVector3(vPos, 0.0f), 25.0f, 5u, COLOR_ENERGY_MAGENTA);
g_pSpecialEffects->PlaySound(coreVector3(vPos, 0.0f), 1.0f, 1.0f, SOUND_WEAPON_ENEMY);
};
const auto nPunishFunc = [&](cEnemy* pEnemy)
{
const coreVector2 vPos = pEnemy->GetPosition().xy();
for(coreUintW j = 10u; j--; )
{
if(g_pGame->IsEasy() && (j % 2u)) continue;
const coreVector2 vDir = coreVector2::Direction(DEG_TO_RAD(I_TO_F(j) * 18.0f));
g_pGame->GetBulletManagerEnemy()->AddBullet<cViewBullet>(5, 0.6f, pEnemy, vPos, vDir)->ChangeSize(1.6f);
g_pGame->GetBulletManagerEnemy()->AddBullet<cViewBullet>(5, 0.6f, pEnemy, vPos, -vDir)->ChangeSize(1.6f);
}
g_pSpecialEffects->CreateSplashColor(coreVector3(vPos, 0.0f), SPECIAL_SPLASH_TINY, COLOR_ENERGY_MAGENTA);
g_pSpecialEffects->PlaySound(coreVector3(vPos, 0.0f), 1.0f, 1.0f, SOUND_WEAPON_ENEMY);
};
const coreUint32 iPrevVisible = iVisible;
const coreUint32 iPrevBig = iBig;
const coreUint32 iPrevGold = iGold;
const coreUint32 iPrevPoints = iPoints;
STAGE_FOREACH_ENEMY(pSquad1, pEnemy, i)
{
if(HAS_BIT(iVisible, i) && pEnemy->WasDamaged())
{
if(!iHit)
{
if(HAS_BIT(iGold, i))
{
STAGE_BADGE(0u, BADGE_EASY, pEnemy->GetPosition())
REMOVE_BIT(iGold, i)
g_pSpecialEffects->CreateSplashColor(pEnemy->GetPosition(), SPECIAL_SPLASH_SMALL, COLOR_ENERGY_YELLOW);
g_pSpecialEffects->ShakeScreen(SPECIAL_SHAKE_TINY);
g_pSpecialEffects->PlaySound(pEnemy->GetPosition(), 1.0f, 1.0f, SOUND_ENEMY_EXPLOSION_01);
}
else if(!HAS_BIT(iBig, i))
{
nPunishFunc(pEnemy);
g_pSpecialEffects->ShakeScreen(SPECIAL_SHAKE_SMALL);
g_pSpecialEffects->PlaySound(pEnemy->GetPosition(), 1.0f, 1.0f, SOUND_ENEMY_EXPLOSION_04);
g_pSpecialEffects->PlaySound(pEnemy->GetPosition(), 1.5f, 1.0f, SOUND_EFFECT_ERROR);
g_pSpecialEffects->RumblePlayer(NULL, SPECIAL_RUMBLE_SMALL, 250u);
ADD_BIT(iRevengeState, i)
if(iRevengeState == BITLINE(iNumEnemies)) STAGE_BADGE(3u, BADGE_ACHIEVEMENT, pEnemy->GetPosition())
}
else
{
iPoints += 1u;
if(!m_iInsanity)
{
this->AddExtraScore(pEnemy->LastAttacker(), 100u, pEnemy->GetPosition());
}
if(iPoints > 15u)
{
REMOVE_BIT(iBig, i)
if(!iBig) pEnemy->Kill(true);
}
if(iPoints == 23u)
{
iSingle = i;
}
if(iPoints == 3u)
{
this->DisableCorrect(false);