This repository was archived by the owner on Feb 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathmodPlayer.bas
8322 lines (7990 loc) · 472 KB
/
modPlayer.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 = "modPlayer"
Option Explicit
Public Sub SetupPlayers() 'this set's the players values to their defaults and prepares them for playing a level
Dim tempLocation As Location
Dim blankControls As Controls
Dim A As Integer
Dim B As Integer
Dim C As Integer
FreezeNPCs = False
qScreen = False
ForcedControls = False
'online stuff
If nPlay.Online = True Then
For A = 0 To 15
nPlay.Player(A).Controls = blankControls
nPlay.MyControls = blankControls
Next A
End If
If nPlay.Online = True Then
If nPlay.Mode = 1 Then
nPlay.MySlot = 0
Else
For A = 1 To 15
If nPlay.Player(A).IsMe Then
nPlay.MySlot = A
Exit For
End If
Next A
End If
End If
'battle mode
If BattleMode = True Then
For A = 1 To numPlayers
Player(A).State = 2
Player(A).Hearts = 2
Next A
Checkpoint = ""
Else
BattleIntro = 0
BattleOutro = 0
End If
For A = 1 To numPlayers 'set up players
With Player(A)
If .Character = 0 Then 'player has no character
.Character = 1 'Sets as Mario
If numPlayers = 2 And A = 2 And nPlay.Online = False Then .Character = 2 'Sets as Luigi
End If
If nPlay.Online = True Then 'online stuff
.State = 2 'Super mario
.Mount = 0
If A = nPlay.MySlot + 1 Then
If frmNetplay.optPlayer(2).Value = True Then
.Character = 2
ElseIf frmNetplay.optPlayer(3).Value = True Then
.Character = 3
ElseIf frmNetplay.optPlayer(4).Value = True Then
.Character = 4
Else
.Character = 1
End If
End If
End If
If .State = 0 Then 'if no state it defaults to small mario
.State = 1
End If
'box to hearts
If .Character = 3 Or .Character = 4 Or .Character = 5 Then 'Peach and Toad
If .Hearts <= 0 Then .Hearts = 1
'power up limiter
'If (.Character = 3 Or .Character = 4) And .State > 3 And .State <> 7 Then .State = 2
If .Hearts <= 1 And .State > 1 And .Character <> 5 Then .Hearts = 2
If .HeldBonus > 0 Then
.Hearts = .Hearts + 1
.HeldBonus = 0
End If
If .State = 1 And .Hearts > 1 Then .State = 2
If .Hearts > 3 Then .Hearts = 3
If .Mount = 3 Then .Mount = 0
Else 'Mario and Luigi
If .Hearts = 3 And .HeldBonus = 0 Then
.HeldBonus = 9
End If
.Hearts = 0
End If
If .Character = 5 Then .Mount = 0
.Location.Width = Physics.PlayerWidth(.Character, .State) 'set height
.Location.Height = Physics.PlayerHeight(.Character, .State) 'set width
If .State = 1 And .Mount = 1 Then .Location.Height = Physics.PlayerHeight(1, 2) 'if small and in a shoe then set the height to super mario
If numPlayers = 2 And A = 2 Then
B = 2
Else
B = 1
End If
If A = 2 And PlayerStart(B).X = 0 And PlayerStart(B).Y = 0 Then
.Location.X = PlayerStart(1).X + PlayerStart(1).Width * 0.5 - .Location.Width * 0.5
.Location.Y = PlayerStart(1).Y + PlayerStart(1).Height - .Location.Height '- 2
Else
.Location.X = PlayerStart(B).X + PlayerStart(B).Width * 0.5 - .Location.Width * 0.5
.Location.Y = PlayerStart(B).Y + PlayerStart(B).Height - .Location.Height '- 2
End If
If GrabAll = True Then
.CanGrabNPCs = True
Else
.CanGrabNPCs = False
End If
'reset all variables
If .Mount = 2 Then .Mount = 0
If .Character >= 3 And .Mount = 3 Then .Mount = 0
.Slippy = False
.DoubleJump = False
.FlySparks = False
.Quicksand = 0
.Bombs = 0
.Wet = 0
.ShellSurf = False
.WetFrame = False
.Slide = False
.Vine = 0
.Fairy = False
.GrabSpeed = 0
.GrabTime = 0
.SwordPoke = 0
.FireBallCD2 = 0
.SpinJump = False
.Stoned = False
.Slope = 0
.SpinFireDir = 0
.SpinFrame = 0
.YoshiNPC = 0
.YoshiPlayer = 0
.YoshiRed = False
.YoshiBlue = False
.YoshiYellow = False
.YoshiBFrame = 0
.YoshiBFrameCount = 0
.YoshiTFrame = 0
.YoshiTFrameCount = 0
.CanFly = False
.CanFly2 = False
.RunCount = 0
.FlyCount = 0
.ForceHitSpot3 = False
.StandUp = False
.StandUp2 = False
.TailCount = 0
.HasKey = False
.TimeToLive = 0
.Warp = 0
.WarpCD = 0
.CanPound = False
.GroundPound = False
.GroundPound2 = False
.Duck = False
.MountSpecial = 0
.YoshiTongueLength = 0
.Direction = 1
.Location.SpeedX = 0
.Location.SpeedY = 2
.Frame = 1
.FrameCount = 0
.NPCPinched = 0
.Pinched1 = 0
.Pinched2 = 0
.Pinched3 = 0
.StandingOnNPC = 0
.StandingOnTempNPC = 0
.Pinched4 = 0
.HoldingNPC = 0
.Dead = False
If nPlay.Online = True And nPlay.Mode = 0 Then
If nPlay.Player(A - 1).Active = False Then .Dead = True
End If
.TimeToLive = 0
.Bumped = 0
.Bumped2 = 0
.Effect = 0
.Effect2 = 0
.Immune = 0
.Immune2 = False
.Jump = 0
.Frame = 1
.FrameCount = 0
.RunRelease = False
.FloatTime = 0
.CanFloat = False
If .Character = 3 Then .CanFloat = True
If .Character = 3 Or .Character = 4 Then
If .State = 1 Then .Hearts = 1
If .State > 1 And .Hearts < 2 Then .Hearts = 2
End If
If numPlayers > 2 And GameMenu = False Then 'online stuff
If nPlay.Online = True Then
.Location = Player(1).Location
.Location.X = .Location.X + A * 32 - 32
ElseIf GameOutro = True Then
.Location = Player(1).Location
.Location.X = .Location.X + A * 52 - 52
Else
.Location = Player(1).Location
.Location.SpeedY = Rnd * -12 - 6
End If
End If
.Section = -1
CheckSection A 'find the section the player is in
If .Section = -1 Then
.Section = 0
CheckSection A
End If
If .Location.X + .Location.Width / 2 > level(.Section).X + (level(.Section).Width - level(.Section).X) / 2 Then .Direction = -1
If nPlay.Online = True And A <= 15 Then
If nPlay.Player(A - 1).Active = False And A <> 1 Then .Dead = True
End If
End With
SizeCheck A
Next A
If nPlay.Online = True Then
Netplay.sendData "1d" & nPlay.MySlot + 1 & "|" & Player(nPlay.MySlot + 1).Character & "|" & Player(nPlay.MySlot + 1).State & LB & Netplay.PutPlayerLoc(nPlay.MySlot + 1)
StartMusic Player(nPlay.MySlot + 1).Section
End If
SetupScreens 'setup the screen depending on how many players there are
If Checkpoint = FullFileName And Checkpoint <> "" Then 'if this level has a checkpoint the put the player in the correct position
For A = 1 To numNPCs
If NPC(A).Type = 192 Then
NPC(A).Killed = 9
tempLocation = NPC(A).Location
tempLocation.Height = 600
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
For B = 1 To numPlayers
Player(B).Location.Y = Block(C).Location.Y - Player(B).Location.Height
Player(B).Location.X = NPC(A).Location.X + NPC(A).Location.Width / 2 - Player(B).Location.Width / 2
CheckSection B
Next B
If numPlayers > 1 Then
Player(1).Location.X = Player(1).Location.X - 16
Player(2).Location.X = Player(2).Location.X + 16
End If
End If
Next A
ElseIf StartLevel <> FileName Then 'if not in the level for the checkpoint, blank the checkpoint
Checkpoint = ""
End If
End Sub
Public Sub UpdatePlayer() 'This is the main sub for the players
'this is 1 of the 2 clusterfuck subs in the code, be weary
Dim A As Integer
Dim B As Integer
Dim C As Single
Dim D As Single
Dim blankControls As Controls
Dim speedVar As Single 'adjusts the players speed by percentages
Dim fBlock As Long 'for collision detection optimizations
Dim lBlock As Long
Dim tempSpeed As Double
Dim HitSpot As Integer
'the hitspot is used for collision detection to find out where to put the player after it collides with a block
'the numbers tell what side the collision happened so it can move the plaer to the correct position
'1 means the player hit the block from the top
'2 is from the right
'3 is from the bottom
'4 is from the left
Dim tempBlockHit(1 To 2) As Integer
Dim tempBlockA(1 To 2) As Double
Dim tempHit As Boolean
Dim tempSpring As Boolean
Dim tempShell As Boolean
Dim tempHit2 As Boolean
Dim tempHit3 As Integer
Dim tempHitSpeed As Single
Dim oldSpeedY As Single 'holds the players previous Y speed
Dim tempLocation As Location
Dim tempLocation3 As Location
Dim spinKill As Boolean
Dim oldSlope As Integer
Dim A1 As Single
Dim B1 As Single
Dim C1 As Single
Dim X As Single
Dim Y As Single
Dim canWarp As Boolean
Dim tempBool As Boolean
Dim blankNPC As NPC
Dim MessageNPC As Integer
'used for slope calculations
Dim PlrMid As Double
Dim Slope As Double
Dim tempSlope As Integer
Dim tempSlope2 As Integer
Dim tempSlope2X As Double 'The old X before player was moved
Dim tempSlope3 As Integer 'keeps track of hit 5 for slope detection
Dim movingBlock As Boolean 'helps with collisions for moving blocks
Dim blockPushX As Integer
Dim oldLoc As Location
Dim curLoc As Location
Dim oldGrab As Integer
Dim DontResetGrabTime As Boolean 'helps with grabbing things from the top
Dim SlippySpeedX As Double
Dim wasSlippy As Boolean
Dim Angle As Double
Dim slideSpeed As Double
Dim maxSlideSpeed
StealBonus 'allows a dead player to come back to life by using a 1-up
ClownCar 'updates players in the clown car
'online stuff
If nPlay.Online = True Then
A = nPlay.MySlot + 1
nPlay.PlayerWaitCount = nPlay.PlayerWaitCount + 1
If Player(A).Dead = True Or Player(A).TimeToLive > 0 Then
If nPlay.PlayerWaitCount = 10 Then
nPlay.PlayerWaitCount = 0
Netplay.sendData "1p" & A & LB
End If
ElseIf Player(A).Effect <> 0 Then
If nPlay.PlayerWaitCount >= 10 Then
Netplay.sendData Netplay.PutPlayerLoc(nPlay.MySlot) & "1c" & A & "|" & Player(A).Effect & "|" & Player(A).Effect2 & LB & "1h" & A & "|" & Player(A).State & LB
nPlay.PlayerWaitCount = 0
End If
Else
If (nPlay.PlayerWaitCount >= 6 And (Player(nPlay.MySlot + 1).Location.SpeedX <> 0 Or Player(nPlay.MySlot + 1).Location.SpeedY <> 0) Or nPlay.PlayerWaitCount >= 60) Then
Netplay.sendData Netplay.PutPlayerLoc(nPlay.MySlot)
If Player(A).YoshiPlayer > 0 Then
Netplay.sendData Netplay.PutPlayerLoc(Player(A).YoshiPlayer - 1) & "1c" & Player(A).YoshiPlayer & "|" & Player(Player(A).YoshiPlayer).Effect & "|" & Player(Player(A).YoshiPlayer).Effect2 & LB & "1h" & A & "|" & Player(Player(A).YoshiPlayer).State & LB
End If
If Player(A).Mount = 3 Then
Netplay.sendData "1r" & A & "|" & Player(A).YoshiPlayer & LB
End If
nPlay.PlayerWaitCount = 0
End If
End If
End If
'A is the current player, numPlayers is the last player. this loop updates all the players
For A = 1 To numPlayers
If nPlay.Online = True And A > 1 Then
If nPlay.Player(A - 1).Active = False Then Player(A).Dead = True
If Player(A).Dead = True Then nPlay.Player(A - 1).Controls = blankControls
End If
'reset variables from the previous player
DontResetGrabTime = False
oldGrab = Player(A).HoldingNPC
movingBlock = False
blockPushX = 0
Player(A).ShowWarp = 0
Player(A).mountBump = 0
spinKill = False
tempHit = False
tempHit2 = False
tempHit3 = 0
tempBlockHit(1) = 0
tempBlockHit(2) = 0
tempBlockA(1) = 0
tempBlockA(2) = 0
With Player(A)
If .GrabTime > 0 Then 'if grabbing something, take control away from the player
.Slide = False
.Controls.Run = True
.Controls.Down = True
.Controls.AltRun = False
.Controls.Jump = False
.Controls.AltJump = False
End If
If .Dismount > 0 Then .Dismount = .Dismount - 1 'count down to being able to hop in a shoe or yoshi
If .Mount <> 0 Or .Stoned = True Or .Fairy = True Then 'if .holdingnpc is -1 then the player can't grab anything. this stops the player from grabbing things while on a yoshi/shoe
.HoldingNPC = -1
ElseIf .HoldingNPC = -1 Then .HoldingNPC = 0
End If
If .Controls.Drop = True And .DropRelease = True Then 'this is for the single player coop cheat code
If SingleCoop > 0 And .Controls.Down = True Then
SwapCoop
Else
DropBonus A
End If
End If
If .Controls.Drop = True Then 'for dropping something from the container. this makes the player have to let go of the drop button before dropping something else
.DropRelease = False
Else
.DropRelease = True
End If
'Handle the death effecs
If .TimeToLive > 0 Then
.TimeToLive = .TimeToLive + 1
If .TimeToLive >= 200 Or ScreenType <> 5 Then
B = CheckLiving
If BattleMode = True And BattleLives(1) > 0 And BattleLives(2) > 0 And BattleWinner = 0 Then
B = 20 + A
Player(20 + A).Location.Width = .Location.Width
Player(20 + A).Location.Height = .Location.Height
Player(20 + A).Location.X = PlayerStart(A).X + PlayerStart(A).Width * 0.5 - .Location.Width
Player(20 + A).Location.Y = PlayerStart(A).Y + PlayerStart(A).Height - .Location.Height
CheckSection 20 + A
If .Section <> Player(B).Section Then
.Location = Player(B).Location
.Section = Player(B).Section
End If
End If
If B > 0 Then 'Move camera to the other living players
If ScreenType = 5 Then
A1 = (Player(B).Location.X + Player(B).Location.Width * 0.5) - (.Location.X + .Location.Width * 0.5)
B1 = Player(B).Location.Y - .Location.Y
Else
A1 = (-vScreenX(1) + vScreen(1).Width * 0.5) - (.Location.X + .Location.Width * 0.5)
B1 = (-vScreenY(1) + vScreen(1).Height * 0.5) - .Location.Y
End If
C1 = Sqr((A1 * A1) + (B1 * B1))
If C1 <> 0 Then
X = A1 / C1
Y = B1 / C1
Else
X = 0
Y = 0
End If
.Location.X = .Location.X + X * 10
.Location.Y = .Location.Y + Y * 10
If ScreenType = 5 And Player(1).Section <> Player(2).Section Then
C1 = 0
If A = 1 Then
.Location.X = Player(2).Location.X
.Location.Y = Player(2).Location.Y
CheckSection A
Else
.Location.X = Player(1).Location.X
.Location.Y = Player(1).Location.Y
CheckSection A
End If
End If
If C1 < 10 And C1 > -10 Then KillPlayer (A)
ElseIf .TimeToLive >= 200 Then 'ScreenType = 1
KillPlayer (A) 'Time to die
End If
End If
ElseIf .Dead = True Then
If numPlayers > 2 Then
B = CheckLiving
.Location.X = Player(B).Location.X
.Location.Y = Player(B).Location.Y
.Section = Player(B).Section
Else
If A = 1 Then
.Location.X = Player(2).Location.X
.Location.Y = Player(2).Location.Y
CheckSection A
Else
.Location.X = Player(1).Location.X
.Location.Y = Player(1).Location.Y
CheckSection A
End If
End If
ElseIf .Dead = False Then
oldLoc = .Location
If .SlideCounter > 0 Then .SlideCounter = .SlideCounter - 1 'for making the slide Effect
'for the purple yoshi ground pound
If .Effect = 0 Then
If .Location.SpeedY <> 0 And .StandingOnNPC = 0 And .Slope = 0 Then
If .Mount = 3 And .MountType = 6 Then 'Purple Yoshi Pound
If .Controls.Down = True And .DuckRelease = True And .CanPound = True Then
.GroundPound = True
.GroundPound2 = True
If .Location.SpeedY < 0 Then .Location.SpeedY = 0
End If
End If
Else
.CanPound = False
End If
If .GroundPound = True Then
If .CanPound = False And .Location.SpeedY < 0 Then .GroundPound = False
.Controls.Down = True
.CanJump = False
.Controls.Left = False
.Controls.Up = False
.Controls.Right = False
.Controls.Jump = True
.Location.SpeedX = .Location.SpeedX * 0.95
.RunRelease = False
.CanFly = False
.FlyCount = 0
.CanFly2 = False
.Location.SpeedY = .Location.SpeedY + 1
.CanPound = False
.Jump = 0
Else
If .Location.SpeedY < -5 And ((.Jump < 15 And .Jump <> 0) Or .CanFly = True) Then
.CanPound = True
End If
If .GroundPound2 = True Then
.Location.SpeedY = -4
.StandingOnNPC = 0
.GroundPound2 = False
End If
End If
SizeCheck A 'check that the player is the correct size for it's character/state/mount and set it if not
If .Stoned = True Then 'stop the player from climbing/spinning/jumping when in tanooki statue form
.Jump = 0
.Vine = 0
.SpinJump = False
.Controls.Left = False
.Controls.Right = False
.Controls.AltJump = False
.Controls.Jump = False
.CanAltJump = False
.CanJump = False
End If
'let the player slide if not on a mount and holding something
If .GrabTime > 0 Then .Slide = False
If .Slope > 0 And .Controls.Down = True And .Mount = 0 And .HoldingNPC = 0 And Not (.Character = 3 Or .Character = 4 Or .Character = 5) And .GrabTime = 0 Then
If .Duck = True Then UnDuck A
.Slide = True
ElseIf .Location.SpeedX = 0 Then
.Slide = False
End If
If .Mount > 0 Or .HoldingNPC > 0 Then .Slide = False
'unduck a player that should be able to duck
If .Duck = True And (.Character = 1 Or .Character = 2) And .State = 1 And (.Mount = 0 Or .Mount = 2) Then UnDuck A
If GameMenu = True And .SpinJump = False Then .Direction = 1 'force the player to look right when on the game menu
WaterCheck A 'This sub handles all the water related stuff
PowerUps A 'misc power-up code
If .StandingOnNPC > 0 Then
If NPC(.StandingOnNPC).Type = 263 And NPC(.StandingOnNPC).Location.SpeedX = 0 Then .Slippy = True
End If
SlippySpeedX = .Location.SpeedX
'Player's X movement. ---------------------------
'Modify player's speed if he is running up/down hill
speedVar = 1 'Speed var is a percentage of the player's speed
If .Slope > 0 Then
If (.Location.SpeedX > 0 And BlockSlope(Block(.Slope).Type) = -1) Or .Location.SpeedX < 0 And BlockSlope(Block(.Slope).Type) = 1 Then
speedVar = (1 - Block(.Slope).Location.Height / Block(.Slope).Location.Width * 0.5)
ElseIf .Slide = False Then
speedVar = 1 + (Block(.Slope).Location.Height / Block(.Slope).Location.Width * 0.5) * 0.5
End If
End If
If .Stoned = True Then speedVar = 1 'if statue form reset to normal
If .Character = 3 Then speedVar = speedVar * 0.93
If .Character = 4 Then speedVar = speedVar * 1.07
'modify speedvar to slow the player down under water
If .Wet > 0 Then
If .Location.SpeedY = 0 Or .Slope > 0 Or .StandingOnNPC <> 0 Then
speedVar = speedVar * 0.25 'if walking go really slow
Else
speedVar = speedVar * 0.5 'if swimming go slower faster the walking
End If
End If
If .Slide = True Then 'Code used to move the player while sliding down a slope
If .Slope > 0 Then
Angle = 1 / (Block(.Slope).Location.Width / Block(.Slope).Location.Height)
slideSpeed = 0.1 * Angle * BlockSlope(Block(.Slope).Type)
If slideSpeed > 0 And .Location.SpeedX < 0 Then
.Location.SpeedX = .Location.SpeedX + slideSpeed * 2
ElseIf slideSpeed < 0 And .Location.SpeedX > 0 Then
.Location.SpeedX = .Location.SpeedX + slideSpeed * 2
Else
.Location.SpeedX = .Location.SpeedX + slideSpeed
End If
ElseIf .Location.SpeedY = 0 Or .StandingOnNPC <> 0 Then
If .Location.SpeedX > 0.2 Then
.Location.SpeedX = .Location.SpeedX - 0.1
ElseIf .Location.SpeedX < -0.2 Then
.Location.SpeedX = .Location.SpeedX + 0.1
Else
.Location.SpeedX = 0
.Slide = False
End If
End If
If .Location.SpeedX > 11 Then .Location.SpeedX = 11
If .Location.SpeedX < -11 Then .Location.SpeedX = -11
If .Controls.Jump = True Or .Controls.AltJump = True Then .Slide = False
'if not sliding and in the clown car
ElseIf .Mount = 2 Then
If .Controls.Jump = False Then .CanJump = True
If .Controls.AltJump = True And .CanAltJump = True Then ' Jump out of the Clown Car
.CanJump = False
tempBool = True
tempLocation = .Location
tempLocation.Height = Physics.PlayerHeight(.Character, .State)
tempLocation.Y = tempLocation.Y - Physics.PlayerHeight(.Character, .State)
tempLocation.Width = Physics.PlayerWidth(.Character, .State)
tempLocation.X = tempLocation.X + 64 - tempLocation.Width / 2
fBlock = FirstBlock((tempLocation.X / 32) - 1)
lBlock = LastBlock(((tempLocation.X + tempLocation.Width) / 32) + 1)
For B = fBlock To lBlock
If Block(B).Invis = False And BlockIsSizable(Block(B).Type) = False And BlockOnlyHitspot1(Block(B).Type) = False And BlockNoClipping(Block(B).Type) = False And Block(B).Hidden = False Then
If CheckCollision(tempLocation, Block(B).Location) = True Then
tempBool = False
PlaySound 3
End If
End If
Next B
For B = 1 To numNPCs
If NPCIsABlock(NPC(B).Type) = True And NPCStandsOnPlayer(NPC(B).Type) = False And NPC(B).Active = True And NPC(B).Type <> 56 Then
If CheckCollision(tempLocation, NPC(B).Location) = True Then
tempBool = False
PlaySound 3
End If
End If
Next B
If tempBool = True Then
.CanJump = False
PlaySound 1 'Jump sound
PlaySound 35
.Jump = Physics.PlayerJumpHeight
If .Character = 2 Then .Jump = .Jump + 3
If .SpinJump = True Then .Jump = .Jump - 6
.Mount = 0
numNPCs = numNPCs + 1
With NPC(numNPCs)
.Direction = Player(A).Direction
If .Direction = 1 Then .Frame = 4
.Frame = .Frame + SpecialFrame(2)
.Active = True
.TimeLeft = 100
.Type = 56
.Location.Height = 128
.Location.Width = 128
.Location.Y = Int(Player(A).Location.Y)
.Location.X = Int(Player(A).Location.X)
.Location.SpeedY = 0
.Location.SpeedX = 0
.CantHurt = 10
.CantHurtPlayer = A
End With
.Location.SpeedY = Physics.PlayerJumpVelocity - tempSpeed
.Location.Height = Physics.PlayerHeight(.Character, .State)
.Location.Width = Physics.PlayerWidth(.Character, .State)
.Location.X = .Location.X + 64 - Physics.PlayerWidth(.Character, .State) / 2
.StandUp = True
.StandUp2 = True
.ForceHitSpot3 = True
.Dismount = 30
.Slope = 0
.Location.Y = NPC(numNPCs).Location.Y - .Location.Height
For B = 1 To numPlayers
If B <> A And Player(B).Mount <> 2 And CheckCollision(.Location, Player(B).Location) = True Then
Player(B).Location.Y = .Location.Y - Player(B).Location.Height
End If
If Player(B).StandingOnTempNPC = 56 Then
Player(B).StandingOnNPC = numNPCs
Player(B).StandingOnTempNPC = 0
End If
Next B
For B = 1 To numNPCs
If NPC(B).standingOnPlayer = A Then
NPC(B).standingOnPlayer = 0
NPC(B).Location.SpeedY = 0
NPC(B).Location.Y = NPC(numNPCs).Location.Y - 0.1 - NPC(B).standingOnPlayerY
NPC(B).standingOnPlayerY = 0
If NPC(B).Type = 22 Then NPC(B).Special = 0
If NPC(B).Type = 50 Then
NPC(B).Killed = 9
NPC(B).Special = 0
ElseIf NPC(B).Type = 49 Then
NPC(B).Special = 0
End If
End If
Next B
End If
End If
ElseIf .Driving = True Then 'driving
If .Duck = True Then UnDuck A
.Driving = False
If .StandingOnNPC > 0 Then
NPC(.StandingOnNPC).Special4 = 1
If .Controls.Left = True Then
NPC(.StandingOnNPC).Special5 = -1
ElseIf .Controls.Right = True Then
NPC(.StandingOnNPC).Special5 = 1
Else
NPC(.StandingOnNPC).Special5 = 0
End If
If .Controls.Up = True Then
NPC(.StandingOnNPC).Special6 = -1
ElseIf .Controls.Down = True Then
NPC(.StandingOnNPC).Special6 = 1
Else
NPC(.StandingOnNPC).Special6 = 0
End If
End If
.Location.SpeedX = 0
ElseIf .Fairy = True Then 'if a fairy
If .Controls.Right = True Then
If .Location.SpeedX < 3 Then .Location.SpeedX = .Location.SpeedX + 0.15
If .Location.SpeedX < 0 Then .Location.SpeedX = .Location.SpeedX + 0.1
ElseIf .Controls.Left = True Then
If .Location.SpeedX > -3 Then .Location.SpeedX = .Location.SpeedX - 0.15
If .Location.SpeedX > 0 Then .Location.SpeedX = .Location.SpeedX - 0.1
ElseIf .Location.SpeedX > 0.1 Then
.Location.SpeedX = .Location.SpeedX - 0.1
ElseIf .Location.SpeedX < -0.1 Then
.Location.SpeedX = .Location.SpeedX + 0.1
Else
.Location.SpeedX = 0
End If
'if the player is climbing a vine
ElseIf .Vine > 0 Then
If .StandingOnNPC > 0 And .Controls.Up = False Then
.Vine = 0
End If
.CanFly = False
.CanFly2 = False
.RunCount = 0
.SpinJump = False
If .Controls.Left = True Then
.Location.SpeedX = -1.5
ElseIf .Controls.Right = True Then
.Location.SpeedX = 1.5
Else
.Location.SpeedX = 0
End If
If .Controls.Up = True And .Vine > 2 Then
.Location.SpeedY = -2
ElseIf .Controls.Down = True Then
.Location.SpeedY = 3
Else
.Location.SpeedY = 0
End If
.Location.SpeedX = .Location.SpeedX + NPC(.VineNPC).Location.SpeedX
.Location.SpeedY = .Location.SpeedY + NPC(.VineNPC).Location.SpeedY
Else
'if none of the above apply then the player controls like normal. remeber this is for the players X movement
'ducking for link
If .Duck = True And .WetFrame = True Then
If .Location.SpeedY <> 0 And .Slope = 0 And .StandingOnNPC = 0 Then UnDuck A
End If
'the following code controls the players ability to duck
If Not (.Character = 5 And ((.Location.SpeedY <> 0 And .Slope = 0 And .StandingOnNPC = 0) Or .FireBallCD <> 0)) Then 'Link can't duck/unduck in air
If .Controls.Down = True And .SpinJump = False And .Stoned = False And .Vine = 0 And .Slide = False And (.Slope = 0 Or .Mount > 0 Or .WetFrame = True Or .Character >= 3 Or .GrabTime > 0) And ((.WetFrame = False Or .Character >= 3) Or .Location.SpeedY = 0 Or .StandingOnNPC <> 0 Or .Slope <> 0 Or .Mount = 1) And .Fairy = False And .ShellSurf = False And .Driving = False Then
.Bumped = False
If .Mount <> 2 Then 'cant duck in the clown car
If .Mount = 3 Then 'duck on a yoshi
If .Duck = False Then
.Location.Y = .Location.Y + .Location.Height
.Location.Height = 31
.Location.Y = .Location.Y - .Location.Height
.Duck = True
'If nPlay.Online = True And A = nPlay.MySlot + 1 Then Netplay.sendData Netplay.PutPlayerLoc(nPlay.MySlot) & "1q" & A & LB
If nPlay.Online = True And A = nPlay.MySlot + 1 Then Netplay.sendData "1q" & A & LB
End If
Else 'normal duck
If (.State > 1 And .HoldingNPC <= 0) Or (.Character = 3 Or .Character = 4 Or .Character = 5) Then
If .Duck = False And .TailCount = 0 Then 'Player ducks
If .Character = 5 Then .SwordPoke = 0
.Duck = True
.Location.Y = .Location.Y + .Location.Height
.Location.Height = Physics.PlayerDuckHeight(.Character, .State)
.Location.Y = .Location.Y - .Location.Height
If nPlay.Online = True And A = nPlay.MySlot + 1 Then Netplay.sendData "1q" & A & LB
End If
ElseIf .Mount = 1 Then
If .Duck = False And .TailCount = 0 Then 'Player ducks
.Duck = True
.Location.Height = Physics.PlayerDuckHeight(1, 2)
.Location.Y = .Location.Y - Physics.PlayerDuckHeight(1, 2) + Physics.PlayerHeight(1, 2)
If nPlay.Online = True And A = nPlay.MySlot + 1 Then Netplay.sendData "1q" & A & LB
End If
End If
End If
End If
Else
If .Duck = True Then UnDuck A
End If
End If
C = 1
'If .Character = 5 Then C = 0.94
If .Character = 5 Then C = 0.95
If .Controls.Left = True And (.Duck = False And .GrabTime = 0 Or (.Location.SpeedY <> 0 And .StandingOnNPC = 0 And .Slope = 0) Or .Mount = 1) Then
.Bumped = False
If .Controls.Run = True Or .Location.SpeedX > -Physics.PlayerWalkSpeed * speedVar Or .Character = 5 Then
If .Location.SpeedX > -Physics.PlayerWalkSpeed * speedVar * C Then
If .Character = 2 Then .Location.SpeedX = .Location.SpeedX + 0.1 * 0.175 'LUIGI
If .Character = 3 Then .Location.SpeedX = .Location.SpeedX + 0.05 * 0.175 'PEACH
If .Character = 4 Then .Location.SpeedX = .Location.SpeedX - 0.05 * 0.175 'toad
.Location.SpeedX = .Location.SpeedX - 0.1 * speedVar
Else 'Running
If .Character = 2 Then .Location.SpeedX = .Location.SpeedX + 0.05 * 0.175 'LUIGI
If .Character = 3 Then .Location.SpeedX = .Location.SpeedX + 0.025 * 0.175 'PEACH
If .Character = 4 Then .Location.SpeedX = .Location.SpeedX - 0.025 * 0.175 'toad
If .Character = 5 Then 'Link
.Location.SpeedX = .Location.SpeedX - 0.025 * speedVar
Else 'Mario
.Location.SpeedX = .Location.SpeedX - 0.05 * speedVar
End If
End If
If .Location.SpeedX > 0 Then
.Location.SpeedX = .Location.SpeedX - 0.18
If .Character = 2 Then .Location.SpeedX = .Location.SpeedX + 0.18 * 0.29 'LUIGI
If .Character = 3 Then .Location.SpeedX = .Location.SpeedX + 0.09 * 0.29 'PEACH
If .Character = 4 Then .Location.SpeedX = .Location.SpeedX - 0.09 * 0.29 'toad
If SuperSpeed = True Then .Location.SpeedX = .Location.SpeedX * 0.95
End If
End If
If SuperSpeed = True And .Controls.Run = True Then .Location.SpeedX = .Location.SpeedX - 0.1
ElseIf .Controls.Right = True And ((.Duck = False And .GrabTime = 0) Or (.Location.SpeedY <> 0 And .StandingOnNPC = 0 And .Slope = 0) Or .Mount = 1) Then
.Bumped = False
If .Controls.Run = True Or .Location.SpeedX < Physics.PlayerWalkSpeed * speedVar Or .Character = 5 Then
If .Location.SpeedX < Physics.PlayerWalkSpeed * speedVar * C Then
If .Character = 2 Then .Location.SpeedX = .Location.SpeedX - 0.1 * 0.175 'LUIGI
If .Character = 3 Then .Location.SpeedX = .Location.SpeedX - 0.05 * 0.175 'PEACH
If .Character = 4 Then .Location.SpeedX = .Location.SpeedX + 0.05 * 0.175 'toad
.Location.SpeedX = .Location.SpeedX + 0.1 * speedVar
Else
If .Character = 2 Then .Location.SpeedX = .Location.SpeedX - 0.05 * 0.175 'LUIGI
If .Character = 3 Then .Location.SpeedX = .Location.SpeedX - 0.025 * 0.175 'PEACH
If .Character = 4 Then .Location.SpeedX = .Location.SpeedX + 0.025 * 0.175 'toad
If .Character = 5 Then 'Link
.Location.SpeedX = .Location.SpeedX + 0.025 * speedVar
Else 'Mario
.Location.SpeedX = .Location.SpeedX + 0.05 * speedVar
End If
End If
If .Location.SpeedX < 0 Then
.Location.SpeedX = .Location.SpeedX + 0.18
If .Character = 2 Then .Location.SpeedX = .Location.SpeedX - 0.18 * 0.29 'LUIGI
If .Character = 3 Then .Location.SpeedX = .Location.SpeedX - 0.09 * 0.29 'PEACH
If .Character = 4 Then .Location.SpeedX = .Location.SpeedX + 0.09 * 0.29 'toad
If SuperSpeed = True Then .Location.SpeedX = .Location.SpeedX * 0.95
End If
End If
If SuperSpeed = True And .Controls.Run = True Then .Location.SpeedX = .Location.SpeedX + 0.1
Else
If .Location.SpeedY = 0 Or .StandingOnNPC <> 0 Or .Slope > 0 Or .WetFrame = True Then 'Only lose speed when not in the air
If .Location.SpeedX > 0 Then .Location.SpeedX = .Location.SpeedX - 0.07 * speedVar
If .Location.SpeedX < 0 Then .Location.SpeedX = .Location.SpeedX + 0.07 * speedVar
If .Character = 2 Then .Location.SpeedX = .Location.SpeedX * 1.003 'LUIGI
If .Character = 3 Then .Location.SpeedX = .Location.SpeedX * 1.0015 'PEACH
If .Character = 4 Then .Location.SpeedX = .Location.SpeedX * 0.9985 'toad
If SuperSpeed = True Then .Location.SpeedX = .Location.SpeedX * 0.95
End If
If .Location.SpeedX > -0.18 And .Location.SpeedX < 0.18 Then
.Bumped = False
.Location.SpeedX = 0
End If
End If
If .Location.SpeedX < -16 Then
.Location.SpeedX = -16
ElseIf .Location.SpeedX > 16 Then
.Location.SpeedX = 16
End If
If .Controls.Run = True Or .Character = 5 Then
If .Location.SpeedX >= Physics.PlayerRunSpeed * speedVar Then
If SuperSpeed = False Then .Location.SpeedX = Physics.PlayerRunSpeed * speedVar
ElseIf .Location.SpeedX <= -Physics.PlayerRunSpeed * speedVar Then
If SuperSpeed = False Then .Location.SpeedX = -Physics.PlayerRunSpeed * speedVar
Else
End If
Else
If .Location.SpeedX > Physics.PlayerWalkSpeed + 0.1 * speedVar Then
.Location.SpeedX = .Location.SpeedX - 0.1
ElseIf .Location.SpeedX < -Physics.PlayerWalkSpeed - 0.1 * speedVar Then .Location.SpeedX = .Location.SpeedX + 0.1
ElseIf Abs(.Location.SpeedX) > Physics.PlayerWalkSpeed * speedVar Then
If .Location.SpeedX > 0 Then
.Location.SpeedX = Physics.PlayerWalkSpeed * speedVar
Else
.Location.SpeedX = -Physics.PlayerWalkSpeed * speedVar
End If
End If
End If
If .Mount = 1 And .MountType = 3 Then
.CanFly2 = True
.FlyCount = 1000
End If
If .Mount <> 3 Then .YoshiBlue = False
If FlyForever = True And .GroundPound = False Then
If .Mount = 3 Then .YoshiBlue = True
If (.State = 4 Or .State = 5) Or (.YoshiBlue = True And .Mount = 3) Or (.Mount = 1 And .MountType = 3) Then
.CanFly2 = True
Else
.CanFly2 = False
.CanFly = False
.FlyCount = 0
.YoshiBlue = False
End If
End If
'Racoon/Tanooki Mario. this handles the ability to fly after running
If (.State = 4 Or .State = 5) And .Wet = 0 Then
If (.Location.SpeedY = 0 Or .CanFly2 = True Or .StandingOnNPC <> 0 Or .Slope > 0) And (Abs(.Location.SpeedX) >= Physics.PlayerRunSpeed Or (.Character = 3 And Abs(.Location.SpeedX) >= 5.58)) Then
.RunCount = .RunCount + 1
Else
If Not (Abs(.Location.SpeedX) >= Physics.PlayerRunSpeed Or (.Character = 3 And Abs(.Location.SpeedX) >= 5.58)) Then
.RunCount = .RunCount - 0.3
End If
End If
If .RunCount >= 35 And .Character = 1 Then
.CanFly = True
.RunCount = 35
ElseIf .RunCount >= 40 And .Character = 2 Then
.CanFly = True
.RunCount = 40
ElseIf .RunCount >= 80 And .Character = 3 Then
.CanFly = True
.RunCount = 80
ElseIf .RunCount >= 60 And .Character = 4 Then
.CanFly = True
.RunCount = 60
ElseIf .RunCount >= 10 And .Character = 5 Then 'link flying
.CanFly = True
.RunCount = 10
Else
.CanFly = False
If .RunCount < 0 Then .RunCount = 0
End If
End If
If .Location.SpeedY = 0 Or .StandingOnNPC <> 0 Or .Slope > 0 Then .FlyCount = 1
If .FlyCount > 1 Then
.FlyCount = .FlyCount - 1
ElseIf .FlyCount = 1 Then
.CanFly2 = False
.FlyCount = 0
End If
End If
'stop link when stabbing
If .Character = 5 Then
If .FireBallCD > 0 And (.Location.SpeedY = 0 Or .Slope <> 0 Or .StandingOnNPC <> 0) Then
If .Slippy = True Then
.Location.SpeedX = .Location.SpeedX * 0.75
Else
.Location.SpeedX = 0
End If
End If
End If
'fairy stuff
If .FairyTime <> 0 And .Fairy = True Then
If Rnd * 10 > 9 Then
NewEffect 80, newLoc(.Location.X - 8 + Rnd * (.Location.Width + 16) - 4, .Location.Y - 8 + Rnd * (.Location.Height + 16)), , , ShadowMode
Effect(numEffects).Location.SpeedX = Rnd * 0.5 - 0.25
Effect(numEffects).Location.SpeedY = Rnd * 0.5 - 0.25
Effect(numEffects).Frame = 1
End If
If .FairyTime > 0 Then .FairyTime = .FairyTime - 1
If .FairyTime <> -1 And .FairyTime < 20 And .Character = 5 Then
For B = 1 To numNPCs
If NPC(B).Active = True Then
If NPC(B).Hidden = False Then
If NPCIsAVine(NPC(B).Type) Then
tempLocation = NPC(B).Location
tempLocation.Width = tempLocation.Width + 32
tempLocation.Height = tempLocation.Height + 32
tempLocation.X = tempLocation.X - 16
tempLocation.Y = tempLocation.Y - 16
If CheckCollision(tempLocation, .Location) Then
.FairyTime = 20
.FairyCD = 0
End If
End If
End If
End If
Next B
For B = 1 To numBackground
If BackgroundFence(Background(B).Type) Then
If Background(B).Hidden = False Then
tempLocation = Background(B).Location
tempLocation.Width = tempLocation.Width + 32
tempLocation.Height = tempLocation.Height + 32
tempLocation.X = tempLocation.X - 16
tempLocation.Y = tempLocation.Y - 16
If CheckCollision(tempLocation, .Location) Then
.FairyTime = 20
.FairyCD = 0