-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLemGame.pas
8837 lines (7564 loc) · 275 KB
/
LemGame.pas
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
{$include lem_directives.inc}
{-------------------------------------------------------------------------------
Some source code notes:
• Transition() method: It has a default parameter. So if you see a
call to Transition() with three parameters and the last one is TRUE, it means
that the lemming has to turn around as well. I commented this too at all
places where this happens.
-------------------------------------------------------------------------------}
unit LemGame;
interface
uses
System.Types, Generics.Collections,
PngInterface,
Windows, Classes, Contnrs, SysUtils, Math, Forms, Dialogs,
Controls, StrUtils, UMisc,
GR32, GR32_OrdinalMaps,
LemCore, LemTypes, LemStrings,
LemLevel,
LemRenderHelpers, LemRendering,
LemNeoTheme,
LemGadgets, LemGadgetsConstants, LemLemming, LemProjectile, LemRecolorSprites,
LemReplay,
LemTalisman,
LemGameMessageQueue,
GameControl, GameSound,
SharedGlobals;
const
ParticleColorIndices: array[0..15] of Byte =
(4, 15, 14, 13, 12, 11, 10, 9, 8, 11, 10, 9, 8, 7, 6, 2);
AlwaysAnimateObjects = [DOM_NONE, DOM_EXIT, DOM_FORCELEFT, DOM_FORCERIGHT,
DOM_DECORATION, DOM_WATER, DOM_FIRE, DOM_UPDRAFT,
DOM_ONEWAYLEFT, DOM_ONEWAYRIGHT, DOM_ONEWAYDOWN,
DOM_NOSPLAT, DOM_SPLAT, DOM_RADIATION, DOM_SLOWFREEZE,
DOM_BLASTICINE, DOM_VINEWATER, DOM_POISON, DOM_LAVA];
type
TLemmingKind = (lkNormal, lkNeutral, lkZombie // Rivals are lkNormal for the purposes of TLemmingKind
);
TLemmingKinds = set of TLemmingKind;
type
TLemmingGame = class;
TLemmingGameSavedState = class
public
LemmingList: TLemmingList;
ProjectileList: TProjectileList;
SelectedSkill: TSkillPanelButton;
TerrainLayer: TBitmap32; // The visual terrain image
PhysicsMap: TBitmap32; // The actual physics
ZombieMap: TByteMap; // Still needed for now, because there is no proper method to set the ZombieMap
CurrentIteration: Integer;
ClockFrame: Integer;
ButtonsRemain: Integer;
CollectiblesRemain: Integer;
LemmingsToRelease: Integer;
LemmingsCloned: Integer;
LemmingsOut: Integer;
fSpawnedDead: Integer;
LemmingsIn: Integer;
LemmingsRemoved: Integer;
NextLemmingCountdown: Integer;
DelayEndFrames: Integer;
TimePlay: Integer;
EntriesOpened: Boolean;
Gadgets: TGadgetList;
CurrSpawnInterval: Integer;
CurrSkillCount: array[TBasicLemmingAction] of Integer; // Should only be called with arguments in AssignableSkills
UsedSkillCount: array[TBasicLemmingAction] of Integer; // Should only be called with arguments in AssignableSkills
IsInfiniteSkillsMode: Boolean;
IsInfiniteTimeMode: Boolean;
NukeIsActive: Boolean;
ExploderAssignInProgress: Boolean;
Index_LemmingToBeNuked: Integer;
constructor Create;
destructor Destroy; override;
end;
TLemmingGameSavedStateList = class(TObjectList)
private
function GetItem(Index: Integer): TLemmingGameSavedState;
public
procedure TidyList(aCurrentIteration: Integer);
function FindNearestState(aTargetIteration: Integer): Integer;
procedure ClearAfterIteration(aTargetIteration: Integer);
function Add: TLemmingGameSavedState;
property Items[Index: Integer]: TLemmingGameSavedState read GetItem; default;
property List;
end;
TLemmingMethod = function (L: TLemming): Boolean of object;
TLemmingMethodArray = array[TBasicLemmingAction] of TLemmingMethod;
TNewSkillMethod = function (L: TLemming): Boolean of object;
TNewSkillMethodArray = array[TBasicLemmingAction] of TNewSkillMethod;
TLemmingEvent = procedure (L: TLemming) of object;
TLemmingGame = class(TComponent)
private
fRenderInterface : TRenderInterface;
fMessageQueue : TGameMessageQueue;
fTalismanReceived : Boolean;
fNewTalismanReceived : Boolean;
fCollectiblesCompleted : Boolean;
fSelectedSkill : TSkillPanelButton; // TUserSelectedSkill; // Currently selected skill restricted by F3-F9
fDoneAssignmentThisFrame : Boolean;
{ internal objects }
LemmingList : TLemmingList; // List of lemmings
ProjectileList : TProjectileList;
PhysicsMap : TBitmap32;
BlockerMap : TBitmap32; // For blockers
ZombieMap : TByteMap;
ExitMap : TArrayArrayBoolean;
LockedExitMap : TArrayArrayBoolean;
WaterMap : TArrayArrayBoolean;
FireMap : TArrayArrayBoolean;
TrapMap : TArrayArrayBoolean;
TeleporterMap : TArrayArrayBoolean;
UpdraftMap : TArrayArrayBoolean;
PickupMap : TArrayArrayBoolean;
ButtonMap : TArrayArrayBoolean;
CollectibleMap : TArrayArrayBoolean;
SplitterMap : TArrayArrayBoolean;
NoSplatMap : TArrayArrayBoolean;
SplatMap : TArrayArrayBoolean;
ForceLeftMap : TArrayArrayBoolean;
ForceRightMap : TArrayArrayBoolean;
AnimMap : TArrayArrayBoolean;
BlasticineMap : TArrayArrayBoolean;
VinewaterMap : TArrayArrayBoolean;
PoisonMap : TArrayArrayBoolean;
LavaMap : TArrayArrayBoolean;
RadiationMap : TArrayArrayBoolean;
SlowfreezeMap : TArrayArrayBoolean;
fReplayManager : TReplay;
{ reference objects, mostly for easy access in the mechanics-code }
fRenderer : TRenderer; // Ref to gameparams.renderer
fLevel : TLevel; // Ref to gameparams.level
{ masks }
TimebomberMask : TBitmap32;
BomberMask : TBitmap32;
FreezerMask : TBitmap32;
BasherMasks : TBitmap32;
FencerMasks : TBitmap32;
MinerMasks : TBitmap32;
GrenadeMask : TBitmap32;
SpearMasks : TBitmap32;
//BatMask : TBitmap32; // Batter
LaserMask : TBitmap32;
fMasksLoaded : Boolean;
{ vars }
fCurrentIteration : Integer;
fClockFrame : Integer; // 17 frames is one game-second
ButtonsRemain : Byte;
CollectiblesRemain : Byte;
LemmingsToRelease : Integer; // Number of lemmings that were created
LemmingsCloned : Integer; // Number of cloned lemmings
LemmingsOut : Integer; // Number of lemmings currently walking around
fSpawnedDead : Integer; // Number of zombies that were created
LemmingsIn : integer; // Number of lemmings that made it to heaven
LemmingsRemoved : Integer; // Number of lemmings removed
DelayEndFrames : Integer;
fCursorPoint : TPoint;
fIsSelectWalkerHotkey : Boolean;
fIsSelectUnassignedHotkey : Boolean;
fIsShowAthleteInfo : Boolean;
fIsHighlightHotkey : Boolean;
TimePlay : Integer; // Positive when time limit
// Negative when just counting time used
fPlaying : Boolean; // Game in active playing mode?
HatchesOpened : Boolean;
LemmingMethods : TLemmingMethodArray; // Method for each basic lemming state
NewSkillMethods : TNewSkillMethodArray; // The replacement of SkillMethods
fLemSelected : TLemming; // Lem under cursor, who would receive the skill
fLemWithShadow : TLemming; // Needed for CheckForNewShadow to erase previous shadow
fLemWithShadowButton : TSkillPanelButton; // Correct skill to be erased
fExistShadow : Boolean; // Whether a shadow is currently drawn somewhere
fLemNextAction : TBasicLemmingAction; // Action to transition to at the end of lemming movement
fLemJumpToHoistAdvance : Boolean; // When using above with Jumper -> Hoister, whether to apply a frame offset
fLastBlockerCheckLem : TLemming; // Blocker responsible for last blocker field check, or nil if none
Gadgets : TGadgetList; // List of objects excluding entrances
CurrSpawnInterval : Integer; // The current spawn interval, obviously
CurrSkillCount : array[TBasicLemmingAction] of Integer; // Should only be called with arguments in AssignableSkills
UsedSkillCount : array[TBasicLemmingAction] of Integer; // Should only be called with arguments in AssignableSkills
fIsInfiniteSkillsMode : Boolean;
fIsInfiniteTimeMode : Boolean;
fNukeIsActive : Boolean;
ExploderAssignInProgress : Boolean;
DoExplosionCrater : Boolean;
Index_LemmingToBeNuked : Integer;
fGameFinished : Boolean;
fGameCheated : Boolean;
NextLemmingCountDown : Integer;
fTargetIteration : Integer; // This is used in hyperspeed
fHyperSpeedCounter : Integer; // No screenoutput
fHyperSpeed : Boolean; // We are at hyperspeed no targetbitmap output
fLeavingHyperSpeed : Boolean; // In between state (see UpdateLemmings)
fPauseOnHyperSpeedExit : Boolean; // To maintain pause state before invoking a savestate
fIsBackstepping : Boolean; // Track any game action that causes backward movement
fIsSuperlemmingMode : Boolean;
fPauseWasPressed : Boolean;
fReplayLoaded : Boolean;
fHitTestAutoFail : Boolean;
fHighlightLemmingID : Integer;
fTargetLemmingID : Integer; // For replay skill assignments
{ events }
fParticleFinishTimer : Integer; // Extra frames to enable viewing of explosions
fSimulationDepth : Integer; // Whether we are in simulation mode for drawing shadows
fSoundList : TList<string>; // List of sounds that have been played already on this frame
{ pixel combine eventhandlers }
// CombineMaskPixels has variants based on the direction of destruction
procedure CombineMaskPixels(F: TColor32; var B: TColor32; M: TColor32; E: Cardinal); // General-purpose
procedure CombineMaskPixelsLeft(F: TColor32; var B: TColor32; M: Cardinal); // Left-facing basher
procedure CombineMaskPixelsRight(F: TColor32; var B: TColor32; M: Cardinal); // Right-facing basher
procedure CombineMaskPixelsUpLeft(F: TColor32; var B: TColor32; M: Cardinal); // Left-facing fencer
procedure CombineMaskPixelsUpRight(F: TColor32; var B: TColor32; M: Cardinal); // Right-facing fencer
procedure CombineMaskPixelsDownLeft(F: TColor32; var B: TColor32; M: Cardinal); // Left-facing miner
procedure CombineMaskPixelsDownRight(F: TColor32; var B: TColor32; M: Cardinal); // Right-facing miner
procedure CombineMaskPixelsNeutral(F: TColor32; var B: TColor32; M: Cardinal); // Bomber & Timebomber
procedure CombineNoOverwriteFreezer(F: TColor32; var B: TColor32; M: Cardinal);
procedure CombineNoOverwriteMask(F: TColor32; var B: TColor32; M: Cardinal);
{ internal methods }
procedure DoTalismanCheck;
function AllZombiesKilled: Boolean; // Checks for remaining zombies, returning False if nuke is used or if zombies remain
function ZombiesRemain: Boolean; // Slightly different - checks for remaining zombies, returns True if zombies remain
function LevelHasKillZombiesTalisman: Boolean;
function CheckForClassicMode: Boolean; // Checks if classic mode is activated
function CheckForNoPause: Boolean; // Checks if pause has been pressed at any time
procedure CheckReplayLoaded; // Checks for action on any future frame and sets flag to True if it finds any
function GetIsReplaying: Boolean;
function GetIsReplayingNoRR(isPaused: Boolean): Boolean;
procedure ApplySpear(P: TProjectile);
//procedure ApplyBat(P: TProjectile); // Batter
procedure ApplyGrenadeExplosionMask(P: TProjectile);
procedure ApplyLaserMask(P: TPoint; L: TLemming);
procedure ApplyBashingMask(L: TLemming; MaskFrame: Integer);
procedure ApplyFencerMask(L: TLemming; MaskFrame: Integer);
procedure ApplyTimebombMask(L: TLemming);
procedure ApplyExplosionMask(L: TLemming);
procedure ApplyFreezerIceCube(L: TLemming);
procedure ApplyMinerMask(L: TLemming; MaskFrame, AdjustX, AdjustY: Integer);
procedure AddConstructivePixel(X, Y: Integer; Color: TColor32);
function CalculateNextLemmingCountdown: Integer;
procedure ZombieCheckForProjectiles(L: TLemming);
procedure ZombieCheckForLaser(L: TLemming);
// The next few procedures are for checking the behavior of lems in trigger areas!
procedure CheckTriggerArea(L: TLemming; IsPostTeleportCheck: Boolean = False);
function GetGadgetCheckPositions(L: TLemming): TArrayArrayInt;
function FindGadgetID(X, Y: Integer; TriggerType: TTriggerTypes): Word;
function HandleTrap(L: TLemming; PosX, PosY: Integer): Boolean;
function HandleAnimation(L: TLemming; PosX, PosY: Integer): Boolean;
function HandleTeleport(L: TLemming; PosX, PosY: Integer): Boolean;
function HandlePickup(L: TLemming; PosX, PosY: Integer): Boolean;
function HandleButton(L: TLemming; PosX, PosY: Integer): Boolean;
function HandleCollectible(L: TLemming; PosX, PosY: Integer): Boolean;
function HandleExit(L: TLemming; PosX, PosY: Integer): Boolean;
function HandleForceField(L: TLemming; Direction: Integer): Boolean;
function HandleFire(L: TLemming): Boolean;
function HandleSplitter(L: TLemming; PosX, PosY: Integer): Boolean;
function HandleRadiation(L: TLemming; PosX, PosY: Integer): Boolean;
function HandleSlowfreeze(L: TLemming; PosX, PosY: Integer): Boolean;
procedure StartSwimming(L: TLemming);
function HandleWaterFatality(L: TLemming): Boolean;
function HandleWaterSwim(L: TLemming): Boolean;
function HandleBlasticineFatality(L: TLemming): Boolean;
function HandleBlasticineSwim(L: TLemming): Boolean;
function HandleVinewaterFatality(L: TLemming): Boolean;
function HandleVinewaterSwim(L: TLemming): Boolean;
function HandleLavaFatality(L: TLemming): Boolean;
function HandleLavaSwim(L: TLemming): Boolean;
function HandlePoison(L: TLemming): Boolean;
function CheckForOverlappingField(L: TLemming): Boolean;
procedure CheckForQueuedAction;
procedure CheckForReplayAction(PausedRRCheck: Boolean = False);
procedure CheckLemmings;
function CheckLemTeleporting(L: TLemming): Boolean;
procedure HandlePostTeleport(L: TLemming);
procedure CheckReleaseLemming;
procedure CheckUpdateNuking;
procedure CueExitSound(L: TLemming);
procedure CueSoundEffect(aSound: String); overload;
procedure CueSoundEffect(aSound: String; aOrigin: TPoint); overload;
//procedure CueSoundEffectFrequency(aSound: String; aFrequency: Single);
function DigOneRow(PosX, PosY: Integer): Boolean;
//function PropellerOneRow(PosX, PosY: Integer): Boolean; // Propeller
procedure DrawAnimatedGadgets;
procedure IncrementIteration;
procedure InitializeAllTriggerMaps;
function IsStartingSeconds: Boolean;
function GetIsSimulating: Boolean;
procedure LayBrick(L: TLemming);
procedure LayLadder(L:TLemming);
function LayStackBrick(L: TLemming): Boolean;
procedure MoveLemToReceivePoint(L: TLemming; GadgetID: Byte);
procedure RecordNuke(aInsert: Boolean);
procedure RecordSpawnInterval(aSI: Integer);
procedure RecordSkillAssignment(L: TLemming; aSkill: TBasicLemmingAction);
procedure RemoveLemming(L: TLemming; RemMode: Integer = 0; Silent: Boolean = False);
procedure RemovePixelAt(X, Y: Integer);
procedure ReplaySkillAssignment(aReplayItem: TReplaySkillAssignment);
procedure SetGadgetMap;
procedure WriteTriggerMap(Map: TArrayArrayBoolean; Rect: TRect);
function ReadTriggerMap(X, Y: Integer; Map: TArrayArrayBoolean): Boolean;
procedure SetBlockerMap;
procedure WriteBlockerMap(X, Y: Integer; aLemmingIndex: Word; aFieldEffect: Byte);
function ReadBlockerMap(X, Y: Integer; L: TLemming = nil): Byte;
procedure SetZombieField(L: TLemming);
procedure WriteZombieMap(X, Y: Integer; aValue: Byte);
function ReadZombieMap(X, Y: Integer): Byte;
procedure SimulateTransition(L: TLemming; NewAction: TBasicLemmingAction);
function SimulateLem(L: TLemming; DoCheckObjects: Boolean = True): TArrayArrayInt;
procedure AddPreplacedLemmings;
procedure FixDuplicatePreplacedLemmingIdentifiers;
procedure Transition(L: TLemming; NewAction: TBasicLemmingAction; DoTurn: Boolean = False);
procedure TurnAround(L: TLemming);
function UpdateExplosionTimer(L: TLemming): Boolean;
function UpdateFreezerExplosionTimer(L: TLemming): Boolean;
procedure UpdateFreezingTimer(L: TLemming);
procedure UpdateUnfreezingTimer(L: TLemming);
procedure UpdateBalloonPopTimer(L: TLemming);
procedure UpdateGadgets;
procedure UpdateProjectiles;
function CheckSkillAvailable(aAction: TBasicLemmingAction; L: TLemming): Boolean;
procedure UpdateSkillCount(aAction: TBasicLemmingAction; Amount: Integer = -1);
{ lemming actions }
function HandleLemming(L: TLemming): Boolean;
function CheckLevelBoundaries(L: TLemming) : Boolean;
//procedure WrapLemming(L: TLemming; WrapPosX, WrapPosY: Integer);
function HandleWalking(L: TLemming): Boolean;
function HandleAscending(L: TLemming): Boolean;
function HandleDigging(L: TLemming): Boolean;
function HandleClimbing(L: TLemming): Boolean;
function HandleDrowning(L: TLemming): Boolean;
function HandleHoisting(L: TLemming): Boolean;
function HandleBuilding(L: TLemming): Boolean;
function HandleBashing(L: TLemming): Boolean;
function HandleMining(L: TLemming): Boolean;
function HandleFalling(L: TLemming): Boolean;
function HandleBallooning(L: TLemming): Boolean;
function HandleFloating(L: TLemming): Boolean;
function HandleSplatting(L: TLemming): Boolean;
function HandleExiting(L: TLemming): Boolean;
function HandleVaporizing(L: TLemming): Boolean;
function HandleVinetrapping(L: TLemming): Boolean;
function HandleBlocking(L: TLemming): Boolean;
function HandleShrugging(L: TLemming): Boolean;
function HandleTimebombing(L: TLemming): Boolean;
function HandleTimebombFinish(L: TLemming): Boolean;
function HandleOhNoing(L: TLemming): Boolean;
function HandleExploding(L: TLemming): Boolean;
function HandleFreezing(L: TLemming): Boolean;
function HandleFreezerExplosion(L: TLemming): Boolean;
function HandleFrozen(L: TLemming): Boolean;
function HandleUnfreezing(L: TLemming): Boolean;
function HandleLaddering(L: TLemming): Boolean;
function HandlePlatforming(L: TLemming): Boolean;
function LemCanLadder(L: TLemming): Boolean;
function LemCanPlatform(L: TLemming): Boolean;
function HandleStacking(L: TLemming): Boolean;
function HandleSwimming(L: TLemming): Boolean;
function HandleDrifting(L: TLemming): Boolean;
function HandleGliding(L: TLemming): Boolean;
function HandleDisarming(L: TLemming): Boolean;
function HandleFencing(L: TLemming): Boolean;
function HandleReaching(L: TLemming) : Boolean;
function HandleShimmying(L: TLemming) : Boolean;
function HandleTurning(L: TLemming) : Boolean;
function HandleJumping(L: TLemming) : Boolean;
function HandleDehoisting(L: TLemming) : Boolean;
function LemCanDehoist(L: TLemming; AlreadyMovedX: Boolean): Boolean;
function HandleSliding(L: TLemming) : Boolean;
function LemSliderTerrainChecks(L: TLemming; MaxYCheckOffset: Integer = 7): Boolean;
function HandleDangling(L: TLemming) : Boolean;
//function HandlePropelling(L: TLemming) : Boolean; // Propeller
function HandleLasering(L: TLemming) : Boolean;
function HandleThrowing(L: TLemming) : Boolean;
//function HandleBatting(L: TLemming) : Boolean; // Batter
function HandleLooking(L: TLemming) : Boolean;
function HandleSleeping(L: TLemming): Boolean;
// Make sure non-Freezer lems can ascend out of Freezer cubes
procedure BoostAscend(L: TLemming; YBoost: Integer; ShouldTurn: Boolean = False);
procedure CheckIfShouldBoostAscend(L: TLemming);
{ interaction }
function AssignNewSkill(Skill: TBasicLemmingAction; IsHighlight: Boolean = False; IsReplayAssignment: Boolean = False): Boolean;
procedure GenerateClonedLem(L: TLemming);
function GetPriorityLemming(out PriorityLem: TLemming;
NewSkillOrig: TBasicLemmingAction;
MousePos: TPoint;
IsHighlight: Boolean = False;
IsReplay: Boolean = False): Integer;
function DoSkillAssignment(L: TLemming; NewSkill: TBasicLemmingAction): Boolean;
function MayAssignWalker(L: TLemming): Boolean;
function MayAssignClimber(L: TLemming): Boolean;
function MayAssignFloaterGlider(L: TLemming): Boolean;
function MayAssignSwimmer(L: TLemming): Boolean;
function MayAssignBallooner(L: TLemming) : Boolean;
function MayAssignDisarmer(L: TLemming): Boolean;
function MayAssignBlocker(L: TLemming): Boolean;
function MayAssignTimebomber(L: TLemming): Boolean;
function MayAssignExploder(L: TLemming): Boolean;
function MayAssignFreezer(L: TLemming): Boolean;
function MayAssignBuilder(L: TLemming): Boolean;
function MayAssignLadderer(L: TLemming): Boolean;
function MayAssignPlatformer(L: TLemming): Boolean;
function MayAssignStacker(L: TLemming): Boolean;
function MayAssignBasher(L: TLemming): Boolean;
function MayAssignFencer(L: TLemming): Boolean;
function MayAssignMiner(L: TLemming): Boolean;
function MayAssignDigger(L: TLemming): Boolean;
function MayAssignCloner(L: TLemming): Boolean;
function MayAssignShimmier(L: TLemming) : Boolean;
function MayAssignJumper(L: TLemming) : Boolean;
function MayAssignSlider(L: TLemming) : Boolean;
function MayAssignLaserer(L: TLemming) : Boolean;
//function MayAssignPropeller(L: TLemming) : Boolean; // Propeller
function MayAssignThrowingSkill(L: TLemming) : Boolean;
// For properties
function GetSkillCount(aSkill: TSkillPanelButton): Integer;
function GetUsedSkillCount(aSkill: TSkillPanelButton): Integer;
function GetActiveLemmingTypes: TLemmingKinds;
function GetOutOfTime: Boolean;
procedure UpdateLevelRecords;
public
GameResultRec : TGameResultsRec;
fSelectDx : Integer;
fXmasPal : Boolean;
fActiveSkills : array[0..MAX_SKILL_TYPES_PER_LEVEL-1] of TSkillPanelButton;
SpawnIntervalModifier : Integer; // Negative = decrease each update, positive = increase each update, 0 = no change
fSpawnIntervalChanged : Boolean; // Set to True in AdjustSpawnInterval when the SI has changed
ReplayInsert : Boolean;
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
{ iteration }
procedure PrepareParams;
procedure PlayMusic;
procedure Start(aReplay: Boolean = False);
procedure UpdateLemmings;
{ callable }
// All checks for terrain, objects, etc
function HasPixelAt(X, Y: Integer): Boolean;
function HasTriggerAt(X, Y: Integer; TriggerType: TTriggerTypes; L: TLemming = nil): Boolean;
function HasWaterObjectAt(X, Y: Integer): Boolean;
function FindGroundPixel(x, y: Integer): Integer;
function HasSteelAt(x, y: Integer): Boolean;
function HasIndestructibleAt(x, y, Direction: Integer; Skill: TBasicLemmingAction): Boolean;
function HasLaserAt(X, Y: Integer): Boolean;
function HasProjectileAt(X, Y: Integer): Boolean;
function ShouldExitToPostview: Boolean;
procedure MaybeExitToPostview;
function StateIsUnplayable: Boolean;
procedure CheckAdjustSpawnInterval;
procedure AdjustSpawnInterval(aSI: Integer);
function CheckIfLegalSI(aSI: Integer): Boolean;
procedure Finish(aReason: Integer);
procedure Cheat;
procedure HitTest(Autofail: Boolean = False);
function ProcessSkillAssignment(IsHighlight: Boolean = False): Boolean;
function ProcessHighlightAssignment: Boolean;
procedure RegainControl(Force: Boolean = False);
procedure EnsureCorrectReplayDetails;
procedure SetGameResult;
procedure SetSelectedSkill(Value: TSkillPanelButton; MakeActive: Boolean = True; RightClick: Boolean = False);
procedure SaveGameplayImage(Filename: String);
function GetSelectedSkill: Integer;
function Checkpass: Boolean;
function CheckFinishedTest: Boolean;
function GetHighlitLemming: TLemming;
function GetTargetLemming: TLemming;
function LemIsInCursor(L: TLemming; MousePos: TPoint): Boolean;
function GetCursorLemmingCount: Integer;
procedure CheckForNewShadow(aForceRedraw: Boolean = False);
function SpawnIntervalChanged: Boolean;
procedure PlayAssignFailSound(PlayForHighlit: Boolean = False);
procedure PopBalloon(L: TLemming; BalloonPopTimerValue: Integer; NewAction: TBasicLemmingAction);
procedure ResetSkillCount;
procedure SetSkillsToInfinite;
procedure RecordInfiniteSkills;
procedure RecordInfiniteTime;
procedure GenerateNewLemming(X, Y: Integer; Left: Boolean; ShiftPressed: Boolean = False; AltPressed: Boolean = False);
{ properties }
property CurrentIteration: Integer read fCurrentIteration;
property LemmingsToSpawn: Integer read LemmingsToRelease;
property SpawnedDead: Integer read fSpawnedDead;
property LemmingsActive: Integer read LemmingsOut;
property LemmingsSaved: Integer read LemmingsIn;
property CurrentSpawnInterval: Integer read CurrSpawnInterval; // For skill panel's usage
property SkillCount[Index: TSkillPanelButton]: Integer read GetSkillCount;
property SkillsUsed[Index: TSkillPanelButton]: Integer read GetUsedSkillCount;
property ClockFrame: Integer read fClockFrame;
property CursorPoint: TPoint read fCursorPoint write fCursorPoint;
property GameFinished: Boolean read fGameFinished;
property CollectiblesCompleted: Boolean read fCollectiblesCompleted write fCollectiblesCompleted;
property Level: TLevel read fLevel write fLevel;
property MessageQueue: TGameMessageQueue read fMessageQueue;
property Playing: Boolean read fPlaying write fPlaying;
property Renderer: TRenderer read fRenderer;
property Replaying: Boolean read GetIsReplaying;
property PauseWasPressed: Boolean read fPauseWasPressed write fPauseWasPressed;
property ReplayLoaded: Boolean read fReplayLoaded write fReplayLoaded;
property ReplayingNoRR[isPaused: Boolean]: Boolean read GetIsReplayingNoRR;
property ReplayManager: TReplay read fReplayManager;
property IsSelectWalkerHotkey: Boolean read fIsSelectWalkerHotkey write fIsSelectWalkerHotkey;
property IsSelectUnassignedHotkey: Boolean read fIsSelectUnassignedHotkey write fIsSelectUnassignedHotkey;
property IsShowAthleteInfo: Boolean read fIsShowAthleteInfo write fIsShowAthleteInfo;
property IsHighlightHotkey: Boolean read fIsHighlightHotkey write fIsHighlightHotkey;
property IsBackstepping: Boolean read fIsBackstepping write fIsBackstepping;
property TargetIteration: Integer read fTargetIteration write fTargetIteration;
property IsSuperlemmingMode: Boolean read fIsSuperlemmingMode;
property HitTestAutoFail: Boolean read fHitTestAutoFail write fHitTestAutoFail;
property IsOutOfTime: Boolean read GetOutOfTime;
property RenderInterface: TRenderInterface read fRenderInterface;
property IsSimulating: Boolean read GetIsSimulating;
property IsInfiniteSkillsMode: Boolean read fIsInfiniteSkillsMode write fIsInfiniteSkillsMode;
property IsInfiniteTimeMode: Boolean read fIsInfiniteTimeMode write fIsInfiniteTimeMode;
property NukeIsActive: Boolean read fNukeIsActive write fNukeIsActive;
property ActiveLemmingTypes: TLemmingKinds read GetActiveLemmingTypes;
function GetLevelWidth: Integer;
function GetLevelHeight: Integer;
{ save / load state }
procedure CreateSavedState(aState: TLemmingGameSavedState);
procedure LoadSavedState(aState: TLemmingGameSavedState);
end;
{-------------------------------------------------------------------------------
The global game mechanics instance, which has to be global (for now) because
we have to be able to start/save/load replay from the postview screen.
GlobalGame is initialized by the mainform.
-------------------------------------------------------------------------------}
var
GlobalGame: TLemmingGame;
implementation
uses
LemNeoLevelPack;
const
LEMMIX_REPLAY_VERSION = 105;
MAX_FALLDISTANCE = 62;
type
TJumpPattern = array[0..5] of array[0..1] of Integer;
const
{ Each entry in a pattern should only move ONE pixel, be it horizontal or vertical. Horizontal
movements here are for right-facing lemmings. }
JUMP_PATTERNS: array[0..8] of TJumpPattern =
(
(( 0, -1), ( 0, -1), ( 1, 0), ( 0, -1), ( 0, -1), ( 1, 0)), // Occurs twice
(( 0, -1), ( 1, 0), ( 0, -1), ( 1, 0), ( 0, -1), ( 1, 0)), // Occurs twice
(( 0, -1), ( 1, 0), ( 0, -1), ( 1, 0), ( 1, 0), ( 0, 0)),
(( 0, -1), ( 1, 0), ( 1, 0), ( 0, -1), ( 1, 0), ( 0, 0)),
(( 1, 0), ( 1, 0), ( 1, 0), ( 1, 0), ( 0, 0), ( 0, 0)),
(( 1, 0), ( 0, 1), ( 1, 0), ( 1, 0), ( 0, 1), ( 0, 0)),
(( 1, 0), ( 1, 0), ( 0, 1), ( 1, 0), ( 0, 1), ( 0, 0)),
(( 1, 0), ( 0, 1), ( 1, 0), ( 0, 1), ( 1, 0), ( 0, 1)), // Occurs twice
(( 1, 0), ( 0, 1), ( 0, 1), ( 1, 0), ( 0, 1), ( 0, 1)) // Occurs twice
);
SUPER_JUMP_PATTERNS: array[0..14] of TJumpPattern =
(
(( 0, -1), ( 0, -1), ( 0, -1), ( 1, 0), ( 0, -1), ( 1, 0)),
(( 0, -1), ( 1, 0), ( 1, 0), ( 0, -1), ( 1, 0), ( 0, -1)),
(( 1, 0), ( 1, 0), ( 0, -1), ( 1, 0), ( 0, -1), ( 1, 0)),
(( 1, 0), ( 0, -1), ( 1, 0), ( 1, 0), ( 0, -1), ( 1, 0)), // Occurs 3 times
(( 1, 0), ( 1, 0), ( 0, -1), ( 1, 0), ( 1, 0), ( 0, -1)),
(( 1, 0), ( 1, 0), ( 1, 0), ( 1, 0), ( 0, -1), ( 1, 0)),
(( 1, 0), ( 1, 0), ( 1, 0), ( 0, -1), ( 1, 0), ( 1, 0)),
(( 1, 0), ( 1, 0), ( 1, 0), ( 1, 0), ( 1, 0), ( 1, 0)),
(( 1, 0), ( 0, 1), ( 1, 0), ( 1, 0), ( 1, 0), ( 1, 0)),
(( 0, 1), ( 1, 0), ( 1, 0), ( 1, 0), ( 1, 0), ( 0, 1)),
(( 1, 0), ( 1, 0), ( 0, 1), ( 1, 0), ( 1, 0), ( 1, 0)),
(( 0, 1), ( 1, 0), ( 1, 0), ( 0, 1), ( 1, 0), ( 1, 0)), // Occurs 3 times
(( 0, 1), ( 1, 0), ( 0, 1), ( 1, 0), ( 1, 0), ( 0, 1)),
(( 1, 0), ( 0, 1), ( 1, 0), ( 1, 0), ( 0, 1), ( 1, 0)),
(( 0, 1), ( 1, 0), ( 0, 1), ( 0, 1), ( 0, 1), ( 0, 0))
);
HOP_JUMP_PATTERNS: array[0..3] of TJumpPattern =
(
(( 1, 0), ( 1, 0), ( 1, 0), ( 0, 1), ( 1, 0), ( 1, 0)),
(( 0, 1), ( 1, 0), ( 0, 1), ( 1, 0), ( 0, 1), ( 0, 1)),
(( 1, 0), ( 0, 1), ( 0, 1), ( 1, 0), ( 0, 1), ( 0, 1)),
(( 0, 1), ( 1, 0), ( 0, 1), ( 0, 1), ( 0, 1), ( 0, 1))
);
const
// Removal modes
RM_NEUTRAL = 0;
RM_SAVE = 1;
RM_KILL = 2;
RM_ZOMBIE = 3;
HEAD_MIN_Y = -7;
LEMMING_MAX_Y = 9;
const
// Order is important, because fTalismans[i].SkillLimit uses the corresponding integers!!!
// THIS IS NOT THE ORDER THE PICKUP-SKILLS ARE NUMBERED!!!
ActionListArray: array[0..25] of TBasicLemmingAction =
(baToWalking, baClimbing, baSwimming, baFloating, baGliding, baFixing,
baTimebombing, baExploding, baFreezing, baBlocking, baPlatforming, baBuilding,
baStacking, baBashing, baMining, baDigging, baCloning, baFencing, baShimmying,
baJumping, baSliding, baLasering, baSpearing, baGrenading,
baBallooning, baLaddering//, baBatting, baPropelling // Batter // Propeller
); // Double-check these skills are in the correct place after adding them
function CheckRectCopy(const A, B: TRect): Boolean;
begin
Result := (RectWidth(A) = RectWidth(B))
and (Rectheight(A) = Rectheight(B));
end;
{ TLemmingGameSavedState }
constructor TLemmingGameSavedState.Create;
begin
inherited;
LemmingList := TLemmingList.Create(True);
ProjectileList := TProjectileList.Create(True);
Gadgets := TGadgetList.Create(True);
TerrainLayer := TBitmap32.Create;
PhysicsMap := TBitmap32.Create;
ZombieMap := TByteMap.Create;
end;
destructor TLemmingGameSavedState.Destroy;
begin
LemmingList.Free;
ProjectileList.Free;
Gadgets.Free;
TerrainLayer.Free;
PhysicsMap.Free;
ZombieMap.Free;
inherited;
end;
{ TLemmingGameSavedStateList }
procedure TLemmingGameSavedStateList.TidyList(aCurrentIteration: Integer);
var
i: Integer;
function CheckKeepSaveState(aStateIndex: Integer): Boolean;
const
MINUTE_IN_FRAMES = 17 * 60;
HALF_MINUTE_IN_FRAMES = 17 * 30;
TEN_SECONDS_IN_FRAMES = 17 * 10;
begin
Result := False;
if Items[aStateIndex].CurrentIteration = 0 then
Result := True;
if Items[aStateIndex].CurrentIteration mod MINUTE_IN_FRAMES = 0 then
Result := True;
if (Items[aStateIndex].CurrentIteration mod HALF_MINUTE_IN_FRAMES = 0)
and (aCurrentIteration - Items[aStateIndex].CurrentIteration <= MINUTE_IN_FRAMES * 3) then
Result := True;
if (Items[aStateIndex].CurrentIteration mod TEN_SECONDS_IN_FRAMES = 0)
and (aCurrentIteration - Items[aStateIndex].CurrentIteration <= MINUTE_IN_FRAMES) then
Result := True;
end;
begin
{ What we want to save:
-- Last minute: One save every 10 seconds
-- Last 3 minutes: One save every 30 seconds
-- Beyond that: One save every minute
-- Additionally, a save immediately after the level is initially rendered
This will result in 11 saved states, plus one more for every minute taken
that isn't in the most recent 3 minutes. This should be manageable. }
for i := Count-1 downto 0 do
if not CheckKeepSaveState(i) then Delete(i);
end;
function TLemmingGameSavedStateList.Add: TLemmingGameSavedState;
begin
// Creates a new TLemmingGameSavedState, adds it, and returns it.
Result := TLemmingGameSavedState.Create;
inherited Add(Result);
end;
function TLemmingGameSavedStateList.GetItem(Index: Integer): TLemmingGameSavedState;
begin
// Gets a TLemmingGameSavedState from the list.
Result := inherited Get(Index);
end;
function TLemmingGameSavedStateList.FindNearestState(aTargetIteration: Integer): Integer;
var
i: Integer;
ClosestFrame: Integer;
begin
Result := -1;
ClosestFrame := -1;
for i := 0 to Count-1 do
if (Items[i].CurrentIteration < aTargetIteration) and (Items[i].CurrentIteration > ClosestFrame) then
begin
Result := i;
ClosestFrame := Items[i].CurrentIteration;
end;
end;
procedure TLemmingGameSavedStateList.ClearAfterIteration(aTargetIteration: Integer);
var
i: Integer;
begin
for i := Count-1 downto 0 do
if Items[i].CurrentIteration > aTargetIteration then Delete(i);
end;
{ TLemmingGame }
procedure TLemmingGame.CreateSavedState(aState: TLemmingGameSavedState);
var
i: Integer;
begin
// Simple stuff
aState.SelectedSkill := fSelectedSkill;
aState.TerrainLayer.Assign(fRenderer.TerrainLayer);
aState.PhysicsMap.Assign(PhysicsMap);
aState.ZombieMap.Assign(ZombieMap);
aState.CurrentIteration := fCurrentIteration;
aState.ClockFrame := fClockFrame;
aState.ButtonsRemain := ButtonsRemain;
aState.CollectiblesRemain := CollectiblesRemain;
aState.LemmingsToRelease := LemmingsToRelease;
aState.LemmingsCloned := LemmingsCloned;
aState.LemmingsOut := LemmingsOut;
aState.fSpawnedDead := fSpawnedDead;
aState.LemmingsIn := LemmingsIn;
aState.LemmingsRemoved := LemmingsRemoved;
aState.NextLemmingCountdown := NextLemmingCountdown;
aState.DelayEndFrames := DelayEndFrames;
aState.TimePlay := TimePlay;
aState.EntriesOpened := HatchesOpened;
aState.CurrSpawnInterval := CurrSpawnInterval;
for i := 0 to Integer(LAST_SKILL_BUTTON) do
begin
aState.CurrSkillCount[ActionListArray[i]] := CurrSkillCount[ActionListArray[i]];
aState.UsedSkillCount[ActionListArray[i]] := UsedSkillCount[ActionListArray[i]];
end;
aState.NukeIsActive := NukeIsActive;
aState.IsInfiniteSkillsMode := IsInfiniteSkillsMode;
aState.IsInfiniteTimeMode := IsInfiniteTimeMode;
aState.ExploderAssignInProgress := ExploderAssignInProgress;
aState.Index_LemmingToBeNuked := Index_LemmingToBeNuked;
// Lemmings.
aState.LemmingList.Clear;
for i := 0 to LemmingList.Count-1 do
begin
aState.LemmingList.Add(TLemming.Create);
aState.LemmingList[i].Assign(LemmingList[i]);
end;
// Projectiles.
aState.ProjectileList.Clear;
for i := 0 to ProjectileList.Count-1 do
aState.ProjectileList.Add(TProjectile.CreateAssign(ProjectileList[i]));
// Objects.
aState.Gadgets.Clear;
for i := 0 to Gadgets.Count-1 do
begin
aState.Gadgets.Add(TGadget.Create(Gadgets[i]));
Gadgets[i].AssignTo(aState.Gadgets[i]);
end;
end;
procedure TLemmingGame.LoadSavedState(aState: TLemmingGameSavedState);
var
i: Integer;
begin
// Simple stuff
fRenderer.TerrainLayer.Assign(aState.TerrainLayer);
PhysicsMap.Assign(aState.PhysicsMap);
ZombieMap.Assign(aState.ZombieMap);
fCurrentIteration := aState.CurrentIteration;
fClockFrame := aState.ClockFrame;
ButtonsRemain := aState.ButtonsRemain;
CollectiblesRemain := aState.CollectiblesRemain;
LemmingsToRelease := aState.LemmingsToRelease;
LemmingsCloned := aState.LemmingsCloned;
LemmingsOut := aState.LemmingsOut;
fSpawnedDead := aState.fSpawnedDead;
LemmingsIn := aState.LemmingsIn;
LemmingsRemoved := aState.LemmingsRemoved;
NextLemmingCountdown := aState.NextLemmingCountdown;
DelayEndFrames := aState.DelayEndFrames;
TimePlay := aState.TimePlay;
HatchesOpened := aState.EntriesOpened;
CurrSpawnInterval := aState.CurrSpawnInterval;
for i := 0 to Integer(LAST_SKILL_BUTTON) do
begin
CurrSkillCount[ActionListArray[i]] := aState.CurrSkillCount[ActionListArray[i]];
UsedSkillCount[ActionListArray[i]] := aState.UsedSkillCount[ActionListArray[i]];
end;
NukeIsActive := aState.NukeIsActive;
IsInfiniteSkillsMode := aState.IsInfiniteSkillsMode;
IsInfiniteTimeMode := aState.IsInfiniteTimeMode;
ExploderAssignInProgress := aState.ExploderAssignInProgress;
Index_LemmingToBeNuked := aState.Index_LemmingToBeNuked;
// Lemmings.
LemmingList.Clear;
for i := 0 to aState.LemmingList.Count-1 do
begin
LemmingList.Add(TLemming.Create);
LemmingList[i].Assign(aState.LemmingList[i]);
LemmingList[i].LemIndex := i;
end;
// Projectiles.
ProjectileList.Clear;
for i := 0 to aState.ProjectileList.Count-1 do
begin
ProjectileList.Add(TProjectile.CreateAssign(aState.ProjectileList[i]));
ProjectileList[i].Relink(PhysicsMap, LemmingList);
end;
// Objects
for i := 0 to Gadgets.Count-1 do
begin
aState.Gadgets[i].AssignTo(Gadgets[i]);
end;
// Recreate Blocker map
SetBlockerMap;
SpawnIntervalModifier := 0; // We don't want to continue changing it if it's currently changing
end;
procedure TLemmingGame.DoTalismanCheck;
var
i: Integer;
function CheckTalisman(aTalisman: TTalisman): Boolean;
var
TotalSkills: Integer;
TotalSkillTypes: Integer;
SaveReq: Integer;
i: TSkillPanelButton;
begin
Result := False;
if aTalisman.RescueCount >= 0 then
SaveReq := aTalisman.RescueCount
else
SaveReq := Level.Info.RescueCount;
if LemmingsSaved < SaveReq then Exit;
if (CurrentIteration >= aTalisman.TimeLimit) and (aTalisman.TimeLimit >= 0) then Exit;
TotalSkills := 0;
TotalSkillTypes := 0;
for i := Low(TSkillPanelButton) to LAST_SKILL_BUTTON do
begin
if (SkillsUsed[i] > aTalisman.SkillLimit[i]) and (aTalisman.SkillLimit[i] >= 0) then Exit;
Inc(TotalSkills, SkillsUsed[i]);
if SkillsUsed[i] > 0 then
Inc(TotalSkillTypes);
end;
if (TotalSkills > aTalisman.TotalSkillLimit) and (aTalisman.TotalSkillLimit >= 0) then Exit;
if (TotalSkillTypes > aTalisman.SkillTypeLimit) and (aTalisman.SkillTypeLimit >= 0) then Exit;
if (aTalisman.RequireKillZombies) then
if not AllZombiesKilled then
Exit;
if (aTalisman.RequireClassicMode) then
if not CheckForClassicMode then
Exit;
if (aTalisman.RequireNoPause) then
if not CheckForNoPause then
Exit;
Result := True;
end;
begin
for i := 0 to Level.Talismans.Count-1 do
begin
if CheckTalisman(Level.Talismans[i]) then
begin
fTalismanReceived := True;
if fReplayManager.IsThisUsersReplay then
begin
if not GameParams.CurrentLevel.TalismanStatus[Level.Talismans[i].ID] then
fNewTalismanReceived := True;
GameParams.CurrentLevel.TalismanStatus[Level.Talismans[i].ID] := True;
end;
end;
end;
end;
function TLemmingGame.CheckForClassicMode: Boolean;
begin
Result := False;
// Check if a replay has been loaded
if ReplayLoaded then Exit;
// Classic mode has to be active
if GameParams.ClassicMode then
Result := True;
end;
function TLemmingGame.CheckForNoPause: Boolean;
begin
Result := False;
// Check if a replay has been loaded
if ReplayLoaded then Exit;
// Check if pause was pressed
if PauseWasPressed then Exit;
Result := True;
end;
function TLemmingGame.AllZombiesKilled: Boolean;
var
i: Integer;
ReleaseOffset: Integer;
begin
Result := False;
if NukeIsActive then
Exit;
for i := 0 to LemmingList.Count-1 do