forked from smbx/smbx-legacy-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodNPC.bas
12368 lines (11913 loc) · 640 KB
/
modNPC.bas
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
Attribute VB_Name = "modNPC"
Option Explicit
Public Sub UpdateNPCs()
'this is 1 of the 2 clusterfuck subs in the code, be weary
'misc variables used mainly for arrays
Dim A As Integer
Dim B As Integer
Dim C As Single
Dim D As Single
Dim E As Double
Dim F As Single
Dim tempStr As String
Dim oldSlope As Integer 'previous sloped block the npc was on
Dim tempNPC As NPC
Dim HitSpot As Integer 'used for collision detection
Dim tempHit As Double
Dim tmpBlock As Block
Dim tempHitBlock As Integer
Dim tempSpeedA As Single
Dim tempSpeedB As Single
Dim tempTurn As Boolean 'used for turning the npc around
Dim tempLocation As Location
Dim tempLocation2 As Location
Dim preBeltLoc As Location
Dim beltCount As Single
Dim tempBlockHit(1 To 2) As Integer 'Hit block from below code
Dim winningBlock As Integer 'More code for hitting the block from below
Dim numTempBlock As Integer
Dim speedVar As Single 'percent of the NPC it should actually moved. this helps when underwater
Dim tempBool As Boolean
Dim tempBool2 As Boolean
Dim tempBool3 As Boolean
Dim newY As Single
Dim straightLine As Boolean
Dim blankBlock As Block
Dim noBelt As Boolean
Dim oldBeltSpeed As Single
Dim beltFixX As Single
Dim oldDirection As Integer
'used for collision detection
Dim fBlock As Long
Dim lBlock As Long
Dim fBlock2 As Long
Dim lBlock2 As Long
Dim bCheck2 As Integer
Dim bCheck As Integer
Dim newAct(1 To maxNPCs) As Integer
Dim addBelt As Single
Dim numAct As Integer
Dim beltClear As Boolean 'stops belt movement when on a wall
Dim resetBeltSpeed As Boolean
Dim PlrMid As Double
Dim Slope As Double
Dim SlopeTurn As Boolean
Dim timeStr As String
Dim lyrX As Double 'for attaching to layers
Dim lyrY As Double 'for attaching to layers
NPC(0).Location.SpeedX = 0
NPC(0).Location.SpeedY = 0
If LevelMacro > 0 Then
If PSwitchTime > 0 Then PSwitchTime = 100
If PSwitchStop > 0 Then PSwitchStop = 100
End If
'used for the p switches
If PSwitchStop > 0 Then 'time stop
If PSwitchStop = Physics.NPCPSwitch Then
StopMusic
StartMusic -1
PlaySound 32
End If
If PSwitchTime > 2 Then PSwitchTime = 2
PSwitchStop = PSwitchStop - 1
If PSwitchStop <= 0 Then
FreezeNPCs = False
StopMusic
StartMusic Player(PSwitchPlayer).Section
End If
End If
If FreezeNPCs = True Then 'When time is paused
StopHit = 0
For A = numNPCs To 1 Step -1 ' check to see if NPCs should be killed
With NPC(A)
If NPCIsBoot(.Type) Or NPCIsYoshi(.Type) Then
If .CantHurt > 0 Then
.CantHurt = .CantHurt - 1
If .CantHurt = 0 Then .CantHurtPlayer = 0
End If
End If
If .TimeLeft > 0 Then .TimeLeft = .TimeLeft - 1
If .Immune > 0 Then .Immune = .Immune - 1
.JustActivated = 0
.Chat = False
If .TimeLeft = 0 Then Deactivate A
If .Killed > 0 Then
If .Location.SpeedX = 0 Then
.Location.SpeedX = Rnd * 2 - 1
If .Location.SpeedX < 0 Then
.Location.SpeedX = .Location.SpeedX - 0.5
Else
.Location.SpeedX = .Location.SpeedX + 0.5
End If
End If
KillNPC A, .Killed
End If
End With
Next A
CharStuff
Exit Sub
End If
If CoinMode = True Then 'this is a cheat code
If Lives >= 99 And Coins >= 99 Then
CoinMode = False
Else
PlaySound 14
Coins = Coins + 1
If Coins >= 100 Then
If Lives < 99 Then
Lives = Lives + 1
PlaySound 15
Coins = Coins - 100
Else
Coins = 99
End If
End If
End If
End If
For A = 1 To numNPCs
With NPC(A)
If .RespawnDelay > 0 Then
.Reset(1) = False
.Reset(2) = False
.RespawnDelay = .RespawnDelay - 1
End If
If .Hidden = True Then Deactivate A
If .TailCD > 0 Then
.TailCD = .TailCD - 1
End If
If A > maxNPCs - 100 Then .Killed = 9
'generator code
If .Generator = True Then
.Active = False
If .Hidden = False Then
.TimeLeft = 0
.GeneratorTime = .GeneratorTime + 1
If .GeneratorTime >= .GeneratorTimeMax * 6.5 Then .GeneratorTime = .GeneratorTimeMax * 6.5
If .GeneratorActive = True Then
.GeneratorActive = False
If .GeneratorTime >= .GeneratorTimeMax * 6.5 Then
tempBool = False
For B = 1 To numNPCs
If B <> A And NPC(B).Active = True And NPC(B).Type <> 57 Then
If CheckCollision(.Location, NPC(B).Location) = True Then tempBool = True
End If
Next B
If .Type <> 91 Then
For B = 1 To numBlock
If Block(B).Hidden = False And BlockIsSizable(Block(B).Type) = False Then
If CheckCollision(.Location, newLoc(Block(B).Location.X + 0.1, Block(B).Location.Y + 0.1, Block(B).Location.Width - 0.2, Block(B).Location.Height - 0.2)) = True Then tempBool = True
End If
Next B
For B = 1 To numPlayers
If Player(B).Dead = False And Player(B).TimeToLive = 0 Then
If CheckCollision(.Location, Player(B).Location) = True Then tempBool = True
End If
Next B
End If
If numNPCs = maxNPCs - 100 Then tempBool = True
If tempBool = True Then
.GeneratorTime = .GeneratorTimeMax
Else
.GeneratorTime = 0
numNPCs = numNPCs + 1
NPC(numNPCs) = NPC(A)
If .GeneratorEffect = 1 Then
NPC(numNPCs).Layer = .Layer
NPC(numNPCs).Effect3 = .GeneratorDirection
NPC(numNPCs).Effect = 4
NPC(numNPCs).Location.SpeedX = 0
NPC(numNPCs).TimeLeft = 100
If .GeneratorDirection = 1 Then
If NPCHeightGFX(.Type) > .Location.Height Then
NPC(numNPCs).Location.Y = .Location.Y + NPCHeightGFX(.Type)
NPC(numNPCs).Effect2 = NPC(numNPCs).Location.Y - (NPCHeightGFX(.Type) - .Location.Height)
Else
NPC(numNPCs).Location.Y = .Location.Y + .Location.Height
NPC(numNPCs).Effect2 = NPC(numNPCs).Location.Y
End If
ElseIf .GeneratorDirection = 3 Then
If NPCHeightGFX(.Type) > .Location.Height Then
NPC(numNPCs).Location.Y = .Location.Y - .Location.Height
NPC(numNPCs).Effect2 = NPC(numNPCs).Location.Y + .Location.Height + (NPCHeightGFX(.Type) - .Location.Height)
Else
NPC(numNPCs).Location.Y = .Location.Y - .Location.Height
NPC(numNPCs).Effect2 = NPC(numNPCs).Location.Y + .Location.Height
End If
ElseIf .GeneratorDirection = 2 Then
NPC(numNPCs).Location.Y = NPC(numNPCs).Location.Y - 4
NPC(numNPCs).Location.X = .Location.X + .Location.Width
NPC(numNPCs).Effect2 = NPC(numNPCs).Location.X
ElseIf .GeneratorDirection = 4 Then
NPC(numNPCs).Location.Y = NPC(numNPCs).Location.Y - 4
NPC(numNPCs).Location.X = .Location.X - .Location.Width
NPC(numNPCs).Effect2 = NPC(numNPCs).Location.X + .Location.Width
End If
ElseIf .GeneratorEffect = 2 Then ' projectile
NPC(numNPCs).Layer = "Spawned NPCs"
PlaySound 22
NPC(numNPCs).Projectile = True
If NPC(numNPCs).Type = 17 Then NPC(numNPCs).Projectile = False 'Normal Bullet Bills
If NPC(numNPCs).Type = 45 Then NPC(numNPCs).Special = 1
If .GeneratorDirection = 1 Then
NPC(numNPCs).Location.SpeedY = -10
NPC(numNPCs).Location.SpeedX = 0
NewEffect 10, newLoc(.Location.X, .Location.Y + 16, 32, 32)
If NPCIsVeggie(NPC(numNPCs).Type) = True Then
NPC(numNPCs).Location.SpeedX = Rnd * 2 - 1
'NPC(numNPCs).Location.SpeedY = -1
End If
ElseIf .GeneratorDirection = 2 Then
NPC(numNPCs).Location.SpeedX = -Physics.NPCShellSpeed
NewEffect 10, newLoc(.Location.X + 16, .Location.Y, 32, 32)
ElseIf .GeneratorDirection = 3 Then
NPC(numNPCs).Location.SpeedY = 8
NPC(numNPCs).Location.SpeedX = 0
NewEffect 10, newLoc(.Location.X, .Location.Y - 16, 32, 32)
Else
NPC(numNPCs).Location.SpeedX = Physics.NPCShellSpeed
SoundPause(3) = 1
NewEffect 10, newLoc(.Location.X - 16, .Location.Y, 32, 32)
End If
End If
With NPC(numNPCs)
.Direction = .DefaultDirection
.Frame = EditorNPCFrame(.Type, .Direction)
.DefaultDirection = .Direction
.DefaultType = 0
.Generator = False
.Active = True
.TimeLeft = 100
.TriggerActivate = NPC(A).TriggerActivate
.TriggerDeath = NPC(A).TriggerDeath
.TriggerLast = NPC(A).TriggerLast
.TriggerTalk = NPC(A).TriggerTalk
CheckSectionNPC numNPCs
If .TriggerActivate <> "" Then ProcEvent .TriggerActivate
If .Type = 287 Then .Type = RandomBonus
End With
End If
End If
End If
End If
End If
If .Type = 57 And .Hidden = False Then
CheckSectionNPC A
C = 0
For B = 1 To numPlayers
If Player(B).Section = .Section Then C = 1
Next B
If C = 1 Then
.TimeLeft = 100
.Active = True
.JustActivated = 0
End If
End If
numAct = 0
C = 0
If .TimeLeft = 1 Or .JustActivated <> 0 Then
If .Type = 169 Or .Type = 170 Then .Frame = EditorNPCFrame(.Type, .Direction, A)
End If
If .JustActivated <> 0 Then
If .Active = True And .TimeLeft > 1 And .Type <> 57 And .Type <> 46 And .Type <> 212 And NPCIsACoin(.Type) = False Then 'And .Type <> 47
If .TriggerActivate <> "" Then ProcEvent .TriggerActivate
tempLocation = .Location
tempLocation.Y = tempLocation.Y - 32
tempLocation.X = tempLocation.X - 32
tempLocation.Width = tempLocation.Width + 64
tempLocation.Height = tempLocation.Height + 64
For B = 1 To numNPCs
If (NPC(B).Active = False) And B <> A And NPC(B).Reset(1) = True And NPC(B).Reset(2) = True Then
If CheckCollision(tempLocation, NPC(B).Location) = True Then
numAct = numAct + 1
newAct(numAct) = B
NPC(B).Active = True
NPC(B).TimeLeft = .TimeLeft
NPC(B).JustActivated = 1
NPC(B).Section = .Section
If B < A Then
If NPC(B).TriggerActivate <> "" Then ProcEvent NPC(B).TriggerActivate
End If
End If
ElseIf B <> A And NPC(B).Active = True And NPC(B).TimeLeft < .TimeLeft - 1 Then
If CheckCollision(tempLocation, NPC(B).Location) = True Then NPC(B).TimeLeft = .TimeLeft - 1
End If
Next B
Do While numAct > C
C = C + 1
With NPC(newAct(C))
If .Type <> 57 And .Type <> 46 And .Type <> 212 And .Type <> 47 And NPCIsACoin(.Type) = False Then
tempLocation = .Location
tempLocation.Y = tempLocation.Y - 32
tempLocation.X = tempLocation.X - 32
tempLocation.Width = tempLocation.Width + 64
tempLocation.Height = tempLocation.Height + 64
For B = 1 To numNPCs
If (NPC(B).Active = False) And B <> A And NPC(B).Reset(1) = True And NPC(B).Reset(2) = True Then
If CheckCollision(tempLocation, NPC(B).Location) = True Then
numAct = numAct + 1
newAct(numAct) = B
NPC(B).Active = True
NPC(B).TimeLeft = .TimeLeft
NPC(B).JustActivated = 1
NPC(B).Section = .Section
If B < A Then
If NPC(B).TriggerActivate <> "" Then ProcEvent NPC(B).TriggerActivate
End If
End If
End If
Next B
End If
End With
Loop
End If
If .Type = 208 Then
For B = 1 To numNPCs
If NPC(B).Type <> 208 And NPC(B).Effect = 0 And NPC(B).Active = True Then
If NPCNoClipping(NPC(B).Type) = False Then
If .Location.Y < NPC(B).Location.Y Then
If .Location.Y + .Location.Height > NPC(B).Location.Y + NPC(B).Location.Height Then
If .Location.Y < NPC(B).Location.Y Then
If .Location.Y + .Location.Height > NPC(B).Location.Y + NPC(B).Location.Height Then
NPC(B).Frame = EditorNPCFrame(NPC(B).Type, NPC(B).Direction)
NPC(B).Effect = 208
End If
End If
End If
End If
End If
End If
Next B
End If
End If
.tempBlock = 0
If .Type = 60 Or .Type = 62 Or .Type = 64 Or .Type = 66 Then
.Active = True
.TimeLeft = 100
End If
If NPC(A).Location.Width = 32 Then
If Not .Type = 57 And Not .Type = 84 Then
'If .Type = 58 Or .Type = 21 Then
If Not (NPCIsAnExit(.Type) Or .Type = 8 Or .Type = 51 Or .Type = 52 Or .Type = 74 Or .Type = 256 Or .Type = 257 Or .Type = 93 Or .Type = 245) Then
NPC(A).Location.X = NPC(A).Location.X + 0.015
End If
NPC(A).Location.Width = NPC(A).Location.Width - 0.03
End If
ElseIf NPC(A).Location.Width = 256 Then
NPC(A).Location.Width = 255.9
ElseIf NPC(A).Location.Width = 128 Then
NPC(A).Location.Width = 127.9
End If
If (.Active = True And .TimeLeft > 1) Then
If .Type = 45 And .Special = 1 Then
If .Projectile = True Then
.Special2 = 0
Else
.Special2 = .Special2 + 1
If .Special2 >= 450 Then
NewEffect 10, .Location
.Killed = 9
End If
End If
End If
If NPCIsABlock(.Type) Or NPCIsAHit1Block(.Type) Or (NPCCanWalkOn(.Type) = True And Not (NPCIsCheep(.Type) And .Special = 2)) Then
If .Projectile = False And .HoldingPlayer = 0 And .Effect = 0 And Not (.Type = 45 And .Special = 1) And Not ((.Type = 46 Or .Type = 212) And .Special = 1) Or .Type = 58 Or .Type = 67 Or .Type = 68 Or .Type = 69 Or .Type = 70 Then
numBlock = numBlock + 1
Block(numBlock) = blankBlock
Block(numBlock).Type = 0
Block(numBlock).Location = .Location
Block(numBlock).Location.Y = Int(Block(numBlock).Location.Y + 0.02)
Block(numBlock).IsPlayer = .standingOnPlayer
Block(numBlock).standingOnPlayerY = .standingOnPlayerY
Block(numBlock).IsReally = A
If .Type = 56 Then Block(numBlock).Type = 25
If NPCIsAHit1Block(.Type) = True Or (NPCCanWalkOn(.Type) = True And Not NPCIsABlock(.Type)) Then Block(numBlock).Type = 26
If NPCCanWalkOn(.Type) = True And NPCIsAHit1Block(.Type) = False And NPCIsABlock(.Type) = False Then Block(numBlock).noProjClipping = True
With Block(numBlock)
If NPC(A).Type = 26 And .Location.Height <> 32 Then
.Location.Y = .Location.Y - 16
.Location.Height = .Location.Height + 16
End If
.Location.SpeedX = .Location.SpeedX + NPC(A).BeltSpeed
.IsNPC = NPC(A).Type
End With
numTempBlock = numTempBlock + 1
.tempBlock = numBlock
End If
End If
End If
End With
Next A
For A = 1 To numPlayers
With Player(A)
If .Mount = 2 Then
numBlock = numBlock + 1
Block(numBlock) = blankBlock
Block(numBlock).Type = 25
Block(numBlock).Location = .Location
With Block(numBlock)
.Location.X = Int(.Location.X) + 1
.Location.Y = Int(.Location.Y) + 1
.Location.Width = Int(.Location.Width) + 1
.IsPlayer = A
End With
numTempBlock = numTempBlock + 1
End If
End With
Next A
If numTempBlock > 1 Then
qSortBlocksX numBlock + 1 - numTempBlock, numBlock
End If
For A = numBlock + 1 - numTempBlock To numBlock
NPC(Block(A).IsReally).tempBlock = A
Next A
For A = 1 To numNPCs
Physics.NPCGravity = Physics.NPCGravityReal
With NPC(A)
lyrX = .Location.X
lyrY = .Location.Y
If .RealSpeedX <> 0 Then
.Location.SpeedX = .RealSpeedX
.RealSpeedX = 0
End If
StopHit = 0
If .Projectile = False Or .Type = 50 Or .Type = 78 Then .Multiplier = 0
If .Immune > 0 Then .Immune = .Immune - 1
If .Type = 56 And .TimeLeft > 1 Then .TimeLeft = 100
If .JustActivated <> 0 Then
If .Active = True Then
If .Type = 197 Then
tempLocation = NPC(A).Location
tempLocation.Height = 8000
C = 0
For B = 1 To numBlock
If CheckCollision(tempLocation, Block(B).Location) = True Then
If C = 0 Then
C = B
Else
If Block(B).Location.Y < Block(C).Location.Y Then C = B
End If
End If
Next B
If C > 0 Then
.Special2 = Block(C).Location.Y + 4
.Location.Y = Block(C).Location.Y - .Location.Height
.Special = 1
End If
ElseIf .Type = 199 Then 'blaarg
.Location.Y = .DefaultLocation.Y + .Location.Height + 36
ElseIf .Type = 17 Or .Type = 18 Or (NPCIsCheep(.Type) And .Special = 2) Or .Type = 42 Then 'Special Start for Jumping Fish and Bullet Bills
If .TimeLeft <= 1 Then
.Active = False
.TimeLeft = 0
ElseIf .Direction = -1 And .Location.X < Player(.JustActivated).Location.X Then
.Active = False
.TimeLeft = 0
ElseIf .Direction = 1 And .Location.X > Player(.JustActivated).Location.X Then
.Active = False
.TimeLeft = 0
ElseIf (NPCIsCheep(.Type) And .Special = 2) Then
.Location.Y = level(Player(.JustActivated).Section).Height - 0.1
.Location.SpeedX = (1 + (.Location.Y - .DefaultLocation.Y) * 0.005) * .Direction
.Special5 = 1
ElseIf Not .Type = 42 Then
PlaySound 22
End If
ElseIf .Type = 21 Then
.Special = 100
End If
End If
If .Type = 84 Or .Type = 181 Then .Special = Int(Rnd * 200)
.JustActivated = 0
.CantHurt = 0
.CantHurtPlayer = 0
If .Type = 21 Then .Projectile = False
If .Type = 22 Then .Projectile = False
ElseIf Not (NPCIsCheep(.Type) And .Special = 2) And Not .Type = 12 Then
If GameMenu = False And .Location.Y > level(.Section).Height + 16 Then
NPCHit A, 9
End If
End If
'Normal operations start here
If NPCIsAVine(.Type) Then
'.Location.SpeedX = 0
'.Location.SpeedY = 0
If .Type = 213 Or .Type = 214 Then
.Frame = BlockFrame(5)
ElseIf .Type >= 215 And .Type <= 220 Then
.Frame = SpecialFrame(7)
End If
ElseIf .Active = True And .Killed = 0 And .Generator = False Then
speedVar = 1
If .Slope > 0 And Not (NPCIsAShell(.Type) Or (.Type = 45 And .Special = 1)) Then
If (.Location.SpeedX > 0 And BlockSlope(Block(.Slope).Type) = -1) Or .Location.SpeedX < 0 And BlockSlope(Block(.Slope).Type) = 1 Then
If Not NPCCanWalkOn(.Type) Or NPCIsABlock(.Type) Or .Type = 78 Then speedVar = (1 - Block(.Slope).Location.Height / Block(.Slope).Location.Width * 0.4)
End If
End If
speedVar = 1
If .Projectile = False Then speedVar = speedVar * NPCSpeedvar(.Type)
'water check
'Things immune to water's effects
If .Type = 12 Or .Type = 17 Or .Type = 18 Or .Type = 30 Or .Type = 38 Or .Type = 42 Or .Type = 43 Or .Type = 44 Or .Type = 85 Or .Type = 87 Or .Type = 108 Or .Type = 171 Or .Type = 292 Or .Type = 197 Or .Type = 202 Or .Type = 210 Or .Type = 225 Or .Type = 226 Or .Type = 227 Or .Type = 47 Or .Type = 284 Or .Type = 179 Or .Type = 270 Or .Type = 269 Or (NPCIsACoin(.Type) And .Special = 0) Or .Type = 266 Or .Type = 259 Or .Type = 260 Then
.Wet = 0
.Quicksand = 0
Else
If .Wet > 0 Then .Wet = .Wet - 1
If .Quicksand > 0 Then .Quicksand = .Quicksand - 1
If UnderWater(.Section) = True Then .Wet = 2
For B = 1 To numWater
If Water(B).Hidden = False Then
If CheckCollision(.Location, Water(B).Location) = True Then
If .Wet = 0 And NPCIsACoin(.Type) = False Then
If .Location.SpeedY >= 1 Then
tempLocation.Width = 32
tempLocation.Height = 32
tempLocation.X = .Location.X + .Location.Width / 2 - tempLocation.Width / 2
tempLocation.Y = .Location.Y + .Location.Height - tempLocation.Height
NewEffect 114, tempLocation
End If
If Not (NPCIsCheep(.Type) And .Special = 1) And .Type <> 34 And .Type <> 13 Then
If .Location.SpeedY > 0.5 Then .Location.SpeedY = 0.5
If .Location.SpeedY < -0.5 Then .Location.SpeedY = -0.5
Else
If .Location.SpeedY > 2 Then .Location.SpeedY = 2
If .Location.SpeedY < -2 Then .Location.SpeedY = -2
End If
If .Type = 104 Then
.Special = .Location.SpeedY
End If
End If
If Water(B).Quicksand = True Then .Quicksand = 2
.Wet = 2
End If
End If
Next B
End If
If .Wet = 1 And .Location.SpeedY < -1 Then
tempLocation.Width = 32
tempLocation.Height = 32
tempLocation.X = .Location.X + .Location.Width / 2 - tempLocation.Width / 2
tempLocation.Y = .Location.Y + .Location.Height - tempLocation.Height
NewEffect 114, tempLocation
End If
If .Wet > 0 Then
If .Type = 263 Then
.Projectile = True
Physics.NPCGravity = -Physics.NPCGravityReal * 0.2
Else
Physics.NPCGravity = Physics.NPCGravityReal * 0.2
End If
If .Type = 195 And .Special4 = 1 Then
.Special5 = 0
ElseIf Not NPCIsCheep(.Type) And .Type <> 190 And .Type <> 205 And .Type <> 206 And .Type <> 207 Then
speedVar = speedVar * 0.5
ElseIf NPCIsCheep(.Type) And .Special = 2 And .Location.SpeedY > 0 Then
speedVar = speedVar * 0.5
End If
If .Location.SpeedY >= 3 Then .Location.SpeedY = 3 'Terminal Velocity in water
If .Location.SpeedY < -3 Then .Location.SpeedY = -3
ElseIf Not (.Type <> 190 And NPCIsCheep(.Type) = False) Then
.WallDeath = .WallDeath + 2
If .WallDeath >= 10 Then .WallDeath = 10
End If
If .Quicksand > 0 And NPCNoClipping(.Type) = False Then
.Location.SpeedY = .Location.SpeedY + 1
If .Location.SpeedY < -1 Then
.Location.SpeedY = -1
ElseIf .Location.SpeedY > 0.5 Then
.Location.SpeedY = 0.5
End If
speedVar = speedVar * 0.3
End If
If .Type = 147 Then
B = Int(Rnd * 9)
.Type = 139 + B
If .Type = 147 Then .Type = 92
.Location.X = .Location.X + .Location.Width / 2
.Location.Y = .Location.Y + .Location.Height / 2
.Location.Width = NPCWidth(.Type)
.Location.Height = NPCHeight(.Type)
.Location.X = .Location.X - .Location.Width / 2
.Location.Y = .Location.Y - .Location.Height / 2
End If
If .Text <> "" Then
.Chat = False
tempLocation = .Location
tempLocation.Y = tempLocation.Y - 25
tempLocation.Height = tempLocation.Height + 50
tempLocation.X = tempLocation.X - 25
tempLocation.Width = tempLocation.Width + 50
For B = 1 To numPlayers
If CheckCollision(tempLocation, Player(B).Location) = True Then .Chat = True
Next B
End If
oldDirection = .Direction
If .Type = 17 Or .Type = 18 Then
If .CantHurt > 0 Then
.CantHurt = 10000
If .Type = 18 Then .Location.SpeedX = 4 * .Direction
End If
If .TimeLeft > 3 And BattleMode = False Then .TimeLeft = 3
End If
If .Type = 267 Or .Type = 268 Or .Type = 280 Or .Type = 281 Then 'koopalings
If .TimeLeft > 1 Then .TimeLeft = Physics.NPCTimeOffScreen
End If
CheckSectionNPC A
If (.Type = 86 Or .Type = 259 Or .Type = 260) And .TimeLeft > 1 Then
.TimeLeft = 100
End If
If Not (.Type = 13 Or (NPCIsCheep(.Type) And .Special = 2) Or .Type = 50 Or .Type = 56 Or .Type = 60 Or .Type = 62 Or .Type = 64 Or .Type = 66 Or .Type = 86 Or NPCIsYoshi(.Type)) And .HoldingPlayer = 0 Then
C = 0
For B = 1 To numPlayers
If Player(B).Section = .Section Then C = 1
Next B
If C = 0 And .TimeLeft > 1 Then .TimeLeft = 0
End If
If (.Type = 225 Or .Type = 226 Or .Type = 227) And .TimeLeft > 10 Then .TimeLeft = 100
If .TimeLeft > 10 And NoTurnBack(.Section) = True Then .TurnBackWipe = True
If .TimeLeft < 1 Then
Deactivate A
End If
.TimeLeft = .TimeLeft - 1
If .Effect = 0 Then
'this code is for NPCs that are being held by a player
If .HoldingPlayer > 0 Then 'NPC is held
.standingOnPlayer = 0
If .Type = 56 Then
Player(.HoldingPlayer).HoldingNPC = 0
.HoldingPlayer = 0
End If
If Player(.HoldingPlayer).HoldingNPC = A And Player(.HoldingPlayer).TimeToLive = 0 And Player(.HoldingPlayer).Dead = False Then 'Player and NPC are on the same page
.Multiplier = 0
If .Type = 159 Then
Player(.HoldingPlayer).HoldingNPC = 0
.HoldingPlayer = 0
.Killed = 9
NewEffect 10, .Location
End If
If NPCIsYoshi(.Type) = True Then
.Special = .Type
.Type = 96
End If
If .Type = 91 Then
If .Special = 0 Then .Special = 147
.Generator = False
.Frame = 0
.Type = .Special
.Special = 0
If NPCIsYoshi(.Type) Then
.Special = .Type
.Type = 96
End If
If Not (.Type = 21 Or .Type = 22 Or .Type = 26 Or .Type = 31 Or .Type = 32 Or .Type = 238 Or .Type = 239 Or .Type = 193 Or .Type = 191 Or .Type = 35 Or .Type = 193 Or .Type = 49 Or NPCIsAnExit(.Type)) Then
.DefaultType = 0
End If
.Location.Height = NPCHeight(.Type)
.Location.Width = NPCWidth(.Type)
If .Type = 147 Then
B = Int(Rnd * 9)
.Type = 139 + B
If .Type = 147 Then .Type = 92
.Location.X = .Location.X + .Location.Width / 2
.Location.Y = .Location.Y + .Location.Height / 2
.Location.Width = NPCWidth(.Type)
.Location.Height = NPCHeight(.Type)
.Location.X = .Location.X - .Location.Width / 2
.Location.Y = .Location.Y - .Location.Height / 2
End If
End If
If .Type = 45 Then
.Special = 1
End If
If .Type = 133 Then
.Location.X = .Location.X + .Location.Width / 2
.Location.Y = .Location.Y + .Location.Height / 2
.Type = 138
.Location.Height = NPCHeight(.Type)
.Location.Width = NPCWidth(.Type)
.Location.X = .Location.X - .Location.Width / 2
.Location.Y = .Location.Y - .Location.Height / 2
End If
.TimeLeft = 100
.BeltSpeed = 0
If .Type = (NPCIsCheep(.Type) And .Special = 2) Then .Special5 = 0
.Direction = Player(.HoldingPlayer).Direction 'Face the player
.Location.SpeedY = Player(.HoldingPlayer).Location.SpeedY
.Location.SpeedX = 0
If Not (.Type = 195 Or .Type = 22 Or .Type = 26 Or .Type = 32 Or .Type = 238 Or .Type = 239 Or .Type = 193 Or .Type = 35 Or .Type = 191 Or .Type = 193 Or .Type = 49 Or .Type = 134 Or (.Type >= 154 And .Type <= 157) Or .Type = 31 Or .Type = 240 Or .Type = 278 Or .Type = 279 Or .Type = 292) Then
For B = 1 To numNPCs
If B <> A And NPC(B).Active = True And (NPC(B).HoldingPlayer = 0 Or (BattleMode = True And NPC(B).HoldingPlayer <> .HoldingPlayer)) And Not NPCIsABonus(NPC(B).Type) And (Not NPC(B).Type = 13 Or (BattleMode = True And NPC(B).CantHurtPlayer <> .HoldingPlayer)) And (Not NPC(B).Type = 265 Or (BattleMode = True And NPC(B).CantHurtPlayer <> .HoldingPlayer)) And Not NPC(B).Type = 21 And Not NPC(B).Type = 22 And Not NPC(B).Type = 26 And Not NPC(B).Type = 31 And Not NPC(B).Type = 32 And Not NPC(B).Type = 238 And NPC(B).Type <> 239 And Not NPC(B).Type = 191 And Not NPC(B).Type = 35 And Not NPC(B).Type = .Type = 193 And Not NPC(B).Type = 37 And Not NPC(B).Type = 180 And Not NPC(B).Type = 38 And Not NPC(B).Type = 39 And Not (NPC(B).Type = 45 And NPC(B).Special = 0) And Not NPC(B).Type = 91 And Not NPC(B).Type = 159 And Not NPC(B).Type = 195 And Not (NPC(B).Type = 30 And NPC(B).Projectile = True) And NPC(B).Type <> 241 And NPC(B).Type <> 263 And NPC(B).Type <> 291 Then
If .CantHurtPlayer <> NPC(B).CantHurtPlayer And NPC(B).Killed = 0 And (Player(.HoldingPlayer).StandingOnNPC <> B) And NPC(B).Inert = False Then
If CheckCollision(.Location, NPC(B).Location) = True Then
NPCHit B, 3, A
If NPC(B).Killed > 0 Then
NPC(B).Location.SpeedX = Physics.NPCShellSpeed * 0.5 * -Player(.HoldingPlayer).Direction
NPCHit A, 5, B
End If
If .Killed > 0 Then .Location.SpeedX = Physics.NPCShellSpeed * 0.5 * Player(.HoldingPlayer).Direction
Exit For
End If
End If
End If
Next B
End If
If .Type = 237 Or .Type = 263 Then 'Yoshi Ice
If Rnd * 100 > 93 Then
tempLocation.Height = EffectHeight(80)
tempLocation.Width = EffectWidth(80)
tempLocation.SpeedX = 0
tempLocation.SpeedY = 0
tempLocation.X = .Location.X - tempLocation.Width / 2 + Rnd * .Location.Width - 4
tempLocation.Y = .Location.Y - tempLocation.Height / 2 + Rnd * .Location.Height - 4
NewEffect 80, tempLocation
End If
End If
Else 'Player and NPC are not on the same page
Player(.HoldingPlayer).HoldingNPC = 0
If .Type = 272 Then .Projectile = True
.Location.SpeedX = 0
.Location.SpeedY = 0
If .Type = 29 Then
.Killed = 3
.Direction = -.Direction
End If
If .Type = 17 Then
PlaySound 22
.Location.SpeedX = 5 * .Direction
.Projectile = True
.CantHurt = 1000
.CantHurtPlayer = .HoldingPlayer
End If
.HoldingPlayer = 0
End If
Else 'NPC is not held
If .CantHurt <= 0 Then .CantHurtPlayer = 0
tempHit = 0
tempBlockHit(1) = 0
tempBlockHit(2) = 0
winningBlock = 0
If LevelWrap(.Section) = True And .Type <> 30 And .Type <> 108 Then 'Level wraparound
If .Location.X + .Location.Width < level(.Section).X Then
.Location.X = level(.Section).Width - 1
ElseIf .Location.X > level(.Section).Width Then
.Location.X = level(.Section).X - .Location.Width + 1
End If
End If
If NoTurnBack(.Section) = True And .Location.X < level(.Section).X - .Location.Width - 32 Then NPCHit A, 9
If .CantHurt > 0 Then
If Not .Type = 21 Then .CantHurt = .CantHurt - 1
Else
.CantHurtPlayer = 0
End If
If .Projectile = True Then
If .CantHurtPlayer <> 0 Then .BattleOwner = .CantHurtPlayer
Else
.BattleOwner = 0
End If
If NPCIsAShell(.Type) Then
.Special4 = .Special4 - 1
If .Special4 < 0 Then .Special4 = 0
End If
If .TurnAround = True Then
If (.Type = 267 Or .Type = 280) And .Special = 0 Then 'larry koopa
If Player(.Special5).Location.X + Player(.Special5).Location.Width / 2 < .Location.X + .Location.Width / 2 Then
If .Special2 < 0 Then
.Special3 = .Special3 + 30
End If
.Special2 = -1
Else
If .Special2 > 0 Then
.Special3 = .Special3 + 30
End If
.Special2 = 1
End If
End If
If .Type = 265 Then NPCHit A, 3, A
If NPCIsAShell(.Type) = True And .Location.SpeedX <> 0 And .Special4 = 0 Then
.Special4 = 5
tempLocation.Height = 0
tempLocation.Width = 0
tempLocation.Y = .Location.Y + .Location.Height / 2 - 16
tempLocation.X = .Location.X - 16
If .Direction = 1 Then tempLocation.X = .Location.X + .Location.Width - 16
NewEffect 132, tempLocation
End If
If .Type = 179 Then
.Special2 = -.Special2
End If
If Not (NPCIsAShell(.Type)) And Not .Type = 13 And Not .Type = 78 And Not .Type = 17 And Not .Type = 86 And Not NPCIsABot(.Type) And .Type <> 40 And .Type <> 133 And NPCIsVeggie(.Type) = False And .Type <> 160 And .Type <> 206 And .Type <> 205 And .Type <> 207 And .Type <> 265 And .Type <> 266 Then 'Don't turn around if a shell or a fireball
.Location.SpeedX = -.Location.SpeedX
If .tempBlock > 0 Then Block(.tempBlock).Location.SpeedX = -Block(.tempBlock).Location.SpeedX
End If
.TurnAround = False
End If
If .Type = 179 Then PlaySound 74 'play saw sound
'NPC Movement Code
'Default Movement Code
If (NPCDefaultMovement(.Type) = True Or (NPCIsCheep(.Type) = True And .Special <> 2)) And Not ((.Type = 55 Or .Type = 119) And .Special > 0) And .Type <> 91 Then
If .Direction = 0 Then
If Int(Rnd * 2) = 0 Then
.Direction = -1
Else
.Direction = 1
End If
End If
If NPCCanWalkOn(.Type) = True Then
If .Location.SpeedX < Physics.NPCWalkingOnSpeed And .Location.SpeedX > -Physics.NPCWalkingOnSpeed Then
If .Projectile = False Then .Location.SpeedX = Physics.NPCWalkingOnSpeed * .Direction
End If
If .Location.SpeedX > Physics.NPCWalkingOnSpeed Then
.Location.SpeedX = .Location.SpeedX - 0.05
If .Projectile = False Then .Location.SpeedX = .Location.SpeedX - 0.1
ElseIf .Location.SpeedX < -Physics.NPCWalkingOnSpeed Then
.Location.SpeedX = .Location.SpeedX + 0.05
If .Projectile = False Then .Location.SpeedX = .Location.SpeedX + 0.1
End If
ElseIf .Type = 125 Then
If .Location.SpeedX < 2 And .Location.SpeedX > -2 Then
If .Projectile = False Then .Location.SpeedX = 2 * .Direction
End If
If .Location.SpeedX > 2 Then
.Location.SpeedX = .Location.SpeedX - 0.05
ElseIf .Location.SpeedX < -2 Then
.Location.SpeedX = .Location.SpeedX + 0.05
End If
ElseIf Not (.Type >= 117 And .Type <= 120 And .Projectile = True) Then
If .Location.SpeedX < Physics.NPCWalkingSpeed And .Location.SpeedX > -Physics.NPCWalkingSpeed Then
If .Projectile = False Then
.Location.SpeedX = Physics.NPCWalkingSpeed * .Direction
End If
End If
If .Location.SpeedX > Physics.NPCWalkingSpeed Then
.Location.SpeedX = .Location.SpeedX - 0.05
ElseIf .Location.SpeedX < -Physics.NPCWalkingSpeed Then
.Location.SpeedX = .Location.SpeedX + 0.05
End If
End If
ElseIf .Type = 203 Then
If .Location.SpeedX > -2 And .Location.SpeedX < 2 Then
.Location.SpeedX = 2 * .Direction
End If
ElseIf .Type = 204 Then
If .Location.SpeedX > -2.5 And .Location.SpeedX < 2.5 Then
.Location.SpeedX = 2.5 * .Direction
End If
'Slow things down that shouldnt move
ElseIf .Type = 21 Or .Type = 22 Or .Type = 25 Or .Type = 26 Or .Type = 31 Or .Type = 32 Or .Type = 238 Or .Type = 239 Or .Type = 35 Or .Type = 191 Or .Type = 193 Or (.Type = 40 And .Projectile = True) Or .Type = 49 Or .Type = 58 Or .Type = 67 Or .Type = 68 Or .Type = 69 Or .Type = 70 Or (NPCIsVeggie(.Type) And .Projectile = False) Or (.Type = 29 And .Projectile = True) Or (.Projectile = True And (.Type = 54 And .Type = 15)) Or .Type = 75 Or .Type = 84 Or .Type = 181 Or .Type = 94 Or .Type = 198 Or .Type = 96 Or .Type = 134 Or .Type = 137 Or .Type = 101 Or .Type = 102 Or (NPCIsYoshi(.Type) And .Special = 0) Or (.Type >= 154 And .Type <= 157) Or .Type = 166 Or (.Type = 39 And .Projectile = True) Or .Type = 170 Or .Type = 169 Or .Type = 183 Or .Type = 188 Or .Type = 97 Or .Type = 196 Or .Type = 182 Or .Type = 240 Or .Type = 241 Or .Type = 249 Or .Type = 250 Or .Type = 254 Or .Type = 255 Or .Type = 278 Or .Type = 279 Or .Type = 277 Or .Type = 264 Or .Type = 288 Or .Type = 275 Then
If .Location.SpeedX > 0 Then
.Location.SpeedX = .Location.SpeedX - 0.05
ElseIf .Location.SpeedX < 0 Then
.Location.SpeedX = .Location.SpeedX + 0.05
End If
If .Location.SpeedX >= -0.05 And .Location.SpeedX <= 0.05 Then
.Location.SpeedX = 0
End If
If .Location.SpeedY >= -Physics.NPCGravity And .Location.SpeedY <= Physics.NPCGravity Then
If .Location.SpeedX > 0 Then
.Location.SpeedX = .Location.SpeedX - 0.3
ElseIf .Location.SpeedX < 0 Then
.Location.SpeedX = .Location.SpeedX + 0.3
End If
If .Location.SpeedX >= -0.3 And .Location.SpeedX <= 0.3 Then .Location.SpeedX = 0
End If
ElseIf .Type = 78 Then
.Projectile = True
.Direction = .DefaultDirection
.Location.SpeedX = 1 * .DefaultDirection
For B = 1 To numPlayers
If Not (Player(B).Effect = 0 Or Player(B).Effect = 3) Then
.Location.SpeedX = 0
.Location.SpeedY = 0
End If
Next B
'Mushroom Movement Code
ElseIf .Type = 9 Or .Type = 273 Or .Type = 90 Or .Type = 153 Or .Type = 184 Or .Type = 185 Or .Type = 186 Or .Type = 187 Or .Type = 163 Or .Type = 164 Then
If .Direction = 0 Then 'Move toward the closest player
C = 0
For B = 1 To numPlayers
If Player(B).Dead = False And Player(B).Section = .Section Then
If C = 0 Or Abs(.Location.X + .Location.Width / 2 - (Player(B).Location.X + Player(B).Location.Width / 2)) < C Then
C = Abs(.Location.X + .Location.Width / 2 - (Player(B).Location.X + Player(B).Location.Width / 2))
.Direction = -Player(B).Direction
End If
End If
Next B
End If
If .Location.SpeedX < Physics.NPCMushroomSpeed And .Location.SpeedX > -Physics.NPCMushroomSpeed Then
If .Projectile = False Then .Location.SpeedX = Physics.NPCMushroomSpeed * .Direction
End If
If .Location.SpeedX > Physics.NPCMushroomSpeed Then
.Location.SpeedX = .Location.SpeedX - 0.05
ElseIf .Location.SpeedX < -Physics.NPCMushroomSpeed Then
.Location.SpeedX = .Location.SpeedX + 0.05
End If
ElseIf .Type = 194 Then
.Projectile = True
C = 0
For B = 1 To numPlayers
If Player(B).Dead = False And Player(B).Section = .Section Then
If C = 0 Or Abs(.Location.X + .Location.Width / 2 - (Player(B).Location.X + Player(B).Location.Width / 2)) < C Then
C = Abs(.Location.X + .Location.Width / 2 - (Player(B).Location.X + Player(B).Location.Width / 2))
If .Location.X + .Location.Width / 2 > Player(B).Location.X + Player(B).Location.Width / 2 Then
.Direction = -1
Else
.Direction = 1
End If
End If
End If
Next B
.Location.SpeedX = .Location.SpeedX + 0.1 * .Direction
If .Location.SpeedX < -4 Then .Location.SpeedX = -4
If .Location.SpeedX > 4 Then .Location.SpeedX = 4
'Yoshi Fireball
ElseIf .Type = 108 Then
.Projectile = True
If .Location.SpeedX = 0 Then .Location.SpeedX = 5 * .Direction
'bully
ElseIf .Type = 168 Then
If .Projectile = False And .Special2 = 0 Then
C = 0
For B = 1 To numPlayers
If Player(B).Dead = False And Player(B).Section = .Section Then
If C = 0 Or Abs(.Location.X + .Location.Width / 2 - (Player(B).Location.X + Player(B).Location.Width / 2)) < C Then
C = Abs(.Location.X + .Location.Width / 2 - (Player(B).Location.X + Player(B).Location.Width / 2))
If .Location.X + .Location.Width / 2 > Player(B).Location.X + Player(B).Location.Width / 2 Then