-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.bb
5993 lines (5197 loc) · 183 KB
/
game.bb
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
;-------------------------------------------------------------;
;-------------------- SCP - 087 - D ----------------------;
;--------- Modification of SCP-087-B -----------;
;--------- Based on SCP-087-B Extended Edition -----------;
;-------------------------------------------------------------;
Graphics3D 640, 480, 32, 2
Global GAME_VERSION$ = "v0.35"
AppTitle "SCP 087-D " + GAME_VERSION
Global ButtonSFX = LoadSound("SFX\Button.ogg")
Dim ChosenButton(5)
ChosenButton(0) = 0
ChosenButton(1) = 0
ChosenButton(2) = 0
ChosenButton(3) = 0
Global MapString$
MapString = ""
Include "server.bb"
Include "scancode.bb"
Global SelectedInputBox = 0
Global JoinToServer = False
Global MenuFont1%,MenuFont2%
Global MouseHit1%,MouseHit2%
;Global PointerImg%
Global launchertex%
Global BRIGHTNESS_MAX% = 140 ; 200
Global DO_ANIMATION% = True
;PointerImg = LoadImage("GFX\cursor.PNG")
;MaskImage PointerImg,0,0,0
MenuFont1 = LoadFont("OCR A Becker RUS-LAT.TTF", 13)
MenuFont2 = LoadFont("OCR A Becker RUS-LAT.TTF", 16)
Global screenwidth = GetINIInt("options.ini","options","width")
Global screenheight = GetINIInt("options.ini","options","height")
Global colordepth = GetINIInt("options.ini","options","colordepth")
Global fullscreen = max(GetINIInt("options.ini","options","fullscreen"), (Not Windowed3D()))
Global InvertMouse = GetINIInt("options.ini","options","invert mouse y")
Global Brightness=max(min(GetINIInt("options.ini","options","brightness"), BRIGHTNESS_MAX), 10)
Global Launcher = GetINIInt("options.ini","options","launcher")
Global framelimit = GetINIInt("options.ini","options","framelimit")
Global skipintro = GetINIInt("options.ini","options","skipintro")
Global area$ = GetINIString("options.ini","options","area")
Global sector$ = GetINIString("options.ini","options","sector")
Global skipupdate = GetINIInt("options.ini","options","skip auto-update")
If Launcher Then
SetBuffer BackBuffer()
SetFont MenuFont1
ClsColor 0,0,0
Cls
Color 255,255,255
Local selectedGFXmode%
selectedGFXmode=1
For i = 1 To CountGfxModes3D()
If (GfxMode3D(i) And GfxModeDepth(i) = colordepth) Then
If (GfxModeWidth(i)>=screenwidth And GfxModeHeight(i)>=screenheight) Then
selectedGFXmode=i
Exit
EndIf
selectedGFXmode=i
EndIf
Next
screenwidth = GfxModeWidth(selectedGFXmode)
screenheight = GfxModeHeight(selectedGFXmode)
PutINIValue("options.ini", "options", "width", Str(screenwidth))
PutINIValue("options.ini", "options", "height", Str(screenheight))
launchertex = LoadImage("GFX\launcher.jpg")
launchertex_a1 = LoadImage("GFX\launcher_a1.png")
launchertex_a2 = LoadImage("GFX\launcher_a2.png")
launchertex_a1_s1 = LoadImage("GFX\launcher_a1_s1.png")
launchertex_a1_s2 = LoadImage("GFX\launcher_a1_s2.png")
launchertex_s1 = LoadImage("GFX\launcher_s1.png")
launchertex_s2 = LoadImage("GFX\launcher_s2.png")
While True
Local StrTemp$
SetFont MenuFont1
MouseHit1 = MouseHit(1)
MouseHit2 = MouseHit(2)
Cls
If MultiplayerButton = False Then
If area = "The Second" Then
DrawImage launchertex_a2,0,0
Color 0,0,0
Text 640-129,480-345,"Area:"
Color 255,255,255
Text 640-129,480-346,"Area:"
Color 30,30,30
StrTemp = "The Second"
If (Button(640-87,480-347,85,24,StrTemp,False)) Then
area = "The First"
PutINIValue("options.ini","options","area",Str(area))
EndIf
ElseIf area = "The First" Then
If sector = "Lower" Then
DrawImage launchertex_a1_s2,0,0
Else
DrawImage launchertex_a1_s1,0,0
EndIf
Color 0,0,0
Text 640-129,480-345,"Area:"
Color 255,255,255
Text 640-129,480-346,"Area:"
Color 30,30,30
StrTemp = "The First"
If (Button(640-87,480-347,85,24,StrTemp,False)) Then
area = "The Second"
PutINIValue("options.ini","options","area",Str(area))
EndIf
Color 0,0,0
Text 640-139,480-315,"Sector:"
Color 255,255,255
Text 640-139,480-316,"Sector:"
If sector = "Upper" Then
Color 30,30,30
StrTemp = "Upper"
If (Button(640-87,480-317,85,24,StrTemp,False)) Then
sector = "Lower"
PutINIValue("options.ini","options","sector",Str(sector))
EndIf
Else
Color 30,30,30
StrTemp = "Lower"
If (Button(640-87,480-317,85,24,StrTemp,False)) Then
sector = "Upper"
PutINIValue("options.ini","options","sector",Str(sector))
EndIf
EndIf
Else
If sector = "Upper" Then
DrawImage launchertex_s1,0,0
Color 0,0,0
Text 640-139,480-315,"Sector:"
Color 255,255,255
Text 640-139,480-316,"Sector:"
Color 30,30,30
StrTemp = "Upper"
If (Button(640-87,480-317,85,24,StrTemp,False)) Then
sector = "Lower"
PutINIValue("options.ini","options","sector",Str(sector))
EndIf
ElseIf sector = "Lower" Then
DrawImage launchertex_s2,0,0
Color 0,0,0
Text 640-139,480-315,"Sector:"
Color 255,255,255
Text 640-139,480-316,"Sector:"
Color 30,30,30
StrTemp = "Lower"
If (Button(640-87,480-317,85,24,StrTemp,False)) Then
sector = "Upper"
PutINIValue("options.ini","options","sector",Str(sector))
EndIf
Else
DrawImage launchertex,0,0
EndIf
EndIf
Color 30,30,30
If (Button(640-336,480-32,124,24,"MULTIPLAYER",False)) Then
MultiplayerButton = True
EndIf
Color 30,30,30
If Button(640-100,480-32,100,24,"PLAY") Then Flip : Delay 8 : Exit
Color 30,30,30
If Button(640-206,480-32,100,24,"EXIT") Then Flip : Delay 8 : End
Else
DrawImage launchertex,0,0
Color 0,0,0
Text 640-357,480-63,"IP:"
Color 255,255,255
Text 640-357,480-64,"IP:"
ServerAddress$ = InputBox(640-336,480-68,114,24,ServerAddress$,1,True)
Color 0,0,0
Text 640-379,480-93,"Name:"
Color 255,255,255
Text 640-379,480-94,"Name:"
SetFont MenuFont2
If Len(PlayerName$) > 12 Then
PlayerName$ = InputBox(640-336,480-98,114,24,Mid(PlayerName$,1,12),2,True)
Else
PlayerName$ = InputBox(640-336,480-98,114,24,PlayerName$,2,True)
EndIf
SetFont MenuFont1
Color 30, 30, 30
If (Button(640-336,480-32,124,24,"SINGLEPLAYER",False)) Then
MultiplayerButton = False
EndIf
Color 30,30,30
If Button(640-100,480-32,100,24,"HOST SERVER") Then
PutINIValue("options.ini","multiplayer","name",Str(PlayerName$))
PlayState=GAME_SERVER ;let the game know you're a server
Players(0)=New Player
Players(0)\IP = 1 ;for initialize in UpdateServer() function
Exit
EndIf
Color 30,30,30
If Button(640-206,480-32,100,24,"JOIN SERVER") Then
PutINIValue("options.ini","multiplayer","name",Str(PlayerName$))
PutINIValue("options.ini","multiplayer","ip",Str(ServerAddress$))
ConnectToServer(ServerAddress)
If PlayState = GAME_CLIENT Then Exit
EndIf
EndIf
Color 255,255,255
Local dx%,dy%
dx = 0 : dy = 0
Color 0,0,0
Text 36,101,"Resolution:"
Color 255,255,255
Text 35,100,"Resolution:"
For i=1 To CountGfxModes3D()
If (GfxMode3D(i)) Then
If (GfxModeDepth(i) = colordepth) Then
If selectedGFXmode = i Then Color 30,30,100 Else Color 30,30,30
If (Button(dx+35,dy+120,80,20,Str(GfxModeWidth(i))+ "x" +Str(GfxModeHeight(i)),False)) Then
selectedGFXmode=i
screenwidth=GfxModeWidth(i)
screenheight=GfxModeHeight(i)
PutINIValue("options.ini","options","width",Str(screenwidth))
PutINIValue("options.ini","options","height",Str(screenheight))
EndIf
dy=dy+20
If (dy>=240) Then
dx=dx+80
dy=0
EndIf
EndIf
EndIf
Next
Color 0,0,0
Text 36,480-53,"Brightness:"
Color 255,255,255
Text 35,480-54,"Brightness:"
Rect 35,480-22,BRIGHTNESS_MAX,5,False
Color 0,0,0
Rect 34,480-23,BRIGHTNESS_MAX+2,7,False
Color 0,0,50
Button(Brightness+20,480-30,40,20,Str(Brightness))
If (MouseX()>=35 And MouseX()<=35+BRIGHTNESS_MAX-10 And MouseY()>=480-30 And MouseY()<=480-10 And MouseDown(1)) Then
Brightness=MouseX()-25
PutINIValue("options.ini","options","brightness",Str(Brightness))
EndIf
Color 0,0,0
Text 640-129,480-95,"Color depth:"
If fullscreen Then Color 255,255,255 Else Color 100,100,100
Text 640-130,480-96,"Color depth:"
Color 30,30,30
If (Button(640-46,480-100,44,24,Str(colordepth)+ "-bit",(Not fullscreen))) Then
If (colordepth=32) Then
colordepth=16
Else
colordepth=32
EndIf
PutINIValue("options.ini","options","colordepth",Str(colordepth))
For i=1 To CountGfxModes3D()
If (GfxMode3D(i) And GfxModeDepth(i) = colordepth) Then
If (GfxModeWidth(i)>=screenwidth And GfxModeHeight(i)>=screenheight) Then
selectedGFXmode=i
Exit
EndIf
selectedGFXmode=i
EndIf
Next
EndIf
Color 0,0,0
Text 640-129,480-65,"Mode:"
Color 255,255,255
Text 640-130,480-66,"Mode:"
Color 30,30,30
If (fullscreen) Then StrTemp = "Fullscreen" Else StrTemp = "Window"
If (Button(640-84,480-70,82,24,StrTemp,(Not Windowed3D()))) Then
fullscreen=(Not fullscreen)
PutINIValue("options.ini","options","fullscreen",Str(fullscreen))
EndIf
Color 0,0,0
Text 640-129,480-125,"Framelimit:"
Color 255,255,255
Text 640-130,480-126,"Framelimit:"
Color 30,30,30
Color 0,0,0
Text 640-129,480-155,"Skip intro:"
Color 255,255,255
Text 640-130,480-156,"Skip intro:"
Color 30,30,30
If skipintro Then StrTemp = "Yes" Else StrTemp = "No"
If (Button(640-46,480-160,44,24,StrTemp,False)) Then
skipintro = Not skipintro
PutINIValue("options.ini","options","skipintro",skipintro)
EndIf
Color 30,30,30
StrTemp = framelimit
If (Button(640-46,480-130,44,24,StrTemp,False)) Then
If framelimit >= 60 Then
framelimit = 30
Else
framelimit = framelimit + 15
EndIf
PutINIValue("options.ini","options","framelimit",framelimit)
EndIf
Color 255,255,255
Flip
Delay 6
Wend
EndIf
screenwidth = GetINIInt("options.ini","options","width")
screenheight = GetINIInt("options.ini","options","height")
colordepth = GetINIInt("options.ini","options","colordepth")
fullscreen = GetINIInt("options.ini","options","fullscreen")
framelimit = GetINIInt("options.ini","options","framelimit")
skipintro = GetINIInt("options.ini","options","skipintro")
If fullscreen Then
Graphics3D (screenwidth,screenheight,colordepth)
Else
Graphics3D (screenwidth,screenheight,colordepth,2)
EndIf
AntiAlias True
HidePointer
SetBuffer BackBuffer()
ClsColor 0,0,0
Cls
Local tempImg%
tempImg = LoadImage("GFX\scp.jpg")
DrawImage(tempImg,(GraphicsWidth()/2)-(ImageWidth(tempImg)/2),(GraphicsHeight()/2)-(ImageHeight(tempImg)/2))
Flip
FreeImage tempImg
Global LogoImg = LoadImage("GFX\scplogo.png")
ScaleImage(LogoImg,GraphicsWidth() / 1280.0, GraphicsHeight() / 720.0)
Global font1 = LoadFont("OCR A Becker RUS-LAT.TTF", 24) ;LoadFont("GFX\YouMurderer BB.TTF", 24)
Global font = LoadFont("OCR A Becker RUS-LAT.TTF", 128) ;LoadFont("GFX\YouMurderer BB.TTF", 128)
Global signfont = LoadFont("GFX\YouMurderer BB.TTF", 128)
Const hit_map = 1
Const hit_map2 = 5
Const hit_monster = 2
Const hit_friendly = 3
Const hit_invisible = 4
Const hit_player = 6
SeedRnd MilliSecs()
; -- Viewport.
Global viewport_center_x = GraphicsWidth () / 2
Global viewport_center_y = GraphicsHeight () / 2
;^^^^^^
; -- Mouselook.
Global mouselook_x_inc# = 0.3 ; This sets both the sensitivity and direction (+/-) of the mouse on the X axis.
Global mouselook_y_inc# = 0.3 ; This sets both the And direction (+/-) of the mouse on the Y axis.
Global mouse_left_limit = 250 ; Used to limit the mouse movement to within a certain number of pixels (250 is used here) from the center of the screen. This produces smoother mouse movement than continuously moving the mouse back to the center each loop.
Global mouse_right_limit = GraphicsWidth () - 250 ; As above.
Global mouse_top_limit = 250 ; As above.
Global mouse_bottom_limit = GraphicsHeight () - 250 ; As above.
;^^^^^^
; -- Mouse smoothing que.
Global mouse_x_speed_1#, mouse_x_speed_2#,mouse_x_speed_3#,mouse_x_speed_4#,mouse_x_speed_5#
Global mouse_y_speed_1#,mouse_y_speed_2#,mouse_y_speed_3#,mouse_y_speed_4#,mouse_y_speed_5#
; -- User.
Global user_camera_pitch#
Global up#, side#
Global STAMINA_MAX# = 500.0
Global Stamina# = STAMINA_MAX
Global StaminaOverload# = 0.0
Global StaminaTimer# = 0.0
Global BlurTimer# = 0.0
Global FogTimer# = 0.0
Global ColliderXRadius# = 0.2
Global ColliderYRadius# = 0.72
Global ColliderYRadiusCrouch# = 0.4
Global camshake# = 0.0
Global ColliderDefaultY# = -1.0
Global DropSpeed#
;^^^^^^
Global shake2coeff# = 1.5
Global shakeZ# = 1.5
Global shakeX# = 0.0
Type ENEMIES
Field obj ; objekti
Field collider ; "t?rm?yspallo"
Field yspeed# ;pudotusnopeus
Field speed#
Field oldX
Field oldZ
Field dorotation
Field steptimer#
Field soundemitter
Field playerlastx
Field playerlastz
Field playerlastseen
End Type
Type GLIMPSES
Field obj
End Type
Type FLOORS
Field mesh
Field sign
End Type
Type OBJECTS
Field mesh
End Type
Global camera
camera = CreateCamera()
CameraRange camera, 0.001, 10
CameraFogMode camera, 1
CameraFogRange camera, 1, 5
CameraFogColor camera,70,70,70
microphone=CreateListener(camera) ; Create listener, make it child of camera
Include "dreamfilter.bb"
Include "bumpmapping.bb"
CreateBlurImage()
;ShowEntity Fog
Global PlayerFloor, KillTimer%
AmbientLight Brightness + 35,Brightness + 25,Brightness + 5 ; 34
Global collider = CreatePivot()
PositionEntity collider,-2.5,-1.3,-0.5
EntityType collider, hit_player
EntityRadius (collider, ColliderXRadius,ColliderYRadius)
Dim FloorNumberTexture(flooramount+1)
;Brick, concrete & sign textures
Global brickwalltexture = LoadTexture("GFX\brickwall.jpg")
Global brickwalltexture_a2 = LoadTexture("GFX\brickwall_a2.jpg")
Global whitetexture = LoadTexture("GFX\white.jpg")
Global sign = LoadImage("GFX\sign.jpg")
Global map, map1, map2, map3
Global btn, btn1, btn2, btn3, btn4, btn5, wall, door, door1, door2, platform1, platform2, label
Global CurrEnemy.ENEMIES, CurrObject, SoundEmitter = CreatePivot()
ScaleEntity SoundEmitter, 0.1,0.1,0.1
Const ACT_STEPS = 1, ACT_LIGHTS = 2, ACT_FLASH = 3, ACT_WALK = 4, ACT_KALLE = 6, ACT_BREATH = 7
Const ACT_PROCEED = 8, ACT_TRAP=9, ACT_173 = 11, ACT_CELL = 12, ACT_LOCK = 13
Const ACT_RADIO2 = 15, ACT_RADIO3 = 16, ACT_RADIO4 = 17, ACT_TRICK1 = 18, ACT_TRICK2 = 19
Const ACT_ROAR = 20, ACT_DARKNESS = 21, ACT_WAIT = 22, ACT_BEHIND = 23, ACT_CHARGE173 = 24, ACT_ENDING = 25, ACT_LIGHT = 26, ACT_ELEVATOR = 27
Const ACT_BLUR = 28, ACT_BROKENROOM = 29, ACT_173_2 = 30, ACT_BIGSTAIRSROOM = 31, ACT_MAZE = 32, ACT_NOTHING = 33, ACT_RUN = 34, ACT_RUN_2 = 35
Const ACT_RUN_3 = 36, ACT_RUN_4 = 37, ACT_ILLUSIONS = 38, ACT_ILLUSIONS_2 = 39, ACT_HALLWAYTRAP = 40, ACT_TRICK3 = 41, ACT_ENDING_2 = 42, ACT_TRANSITION = 43, ACT_ATTENTION = 44
Const ACT_ELEVATOR_START = 45, ACT_ELEVATOR_END = 46, ACT_FLASH_2 = 47, ACT_CELL_2 = 48, ACT_CORNER_TRAP = 49, ACT_MENTAL_TRAP = 50, ACT_TURNAROUND = 51, ACT_UNKNOWN = 52, ACT_SPIDER = 53, ACT_SUDDEN_ATTACK = 54
Const ACT_GORIGHT = 55, ACT_RANDOM_SOUND = 56
;Collisions hit_er,hit_map, 2,3
;-----------------------------------------------------------;
;----------------- SFX Start ---------------------;
Dim StepSFX(8)
Dim MonsterStepSFX(4)
Dim RunSFX(8)
Dim RunBreathSFX(3)
For i = 0 To 3
MonsterStepSFX(i) = Load3DSound("SFX\Monsters\step" + (i + 1) + ".ogg")
Next
For i = 0 To 7
StepSFX(i) = Load3DSound("SFX\Player\step" + (i + 1) + ".ogg")
RunSFX(i) = Load3DSound("SFX\Player\run" + (i + 1) + ".ogg")
SoundVolume StepSFX(i), 0.6
SoundVolume RunSFX(i), 0.6
Next
For i = 0 To 3
RunBreathSFX(i) = LoadSound("SFX\Player\breath" + i + ".ogg")
Next
RunBreathSFX(3)=LoadSound("SFX\Player\breath3.ogg")
Global BreathChnl = RunBreathSFX(0), BreathChannel
BreathChannel = PlaySound(0)
loudstepsound=Load3DSound("SFX\Events\loudstep.ogg")
Dim HorrorSFX(9)
For i = 0 To 8
HorrorSFX(i) = LoadSound("SFX\Horror\horror" + (i + 1) + ".ogg")
Next
Global DeathSFX = LoadSound("SFX\death.ogg")
;Global IntroSFX = LoadSound("SFX\introdoor.ogg") <---- Unused for now, since i can't find out how to use this sound
Global RoarSFX = LoadSound("SFX\Events\roar.ogg")
Global BreathSFX = LoadSound("SFX\Events\breath.ogg")
Global StoneSFX = LoadSound("SFX\Events\stone.ogg")
Global NoSFX = LoadSound("SFX\Monsters\no.ogg")
Global BehindSFX = LoadSound("SFX\Monsters\behind.ogg")
Global WaitSFX = LoadSound("SFX\Monsters\wait.ogg")
Global ColumnmoveSFX = LoadSound("SFX\Events\columnmove.ogg")
Global LightSFX = LoadSound("SFX\Events\light.ogg")
Global ActRadioSFX = LoadSound("SFX\Monsters\act_radio6.ogg")
Global DontlookSFXReverb = LoadSound("SFX\Monsters\dontlook_reverb.ogg")
Global DontlookSFX = LoadSound("SFX\Monsters\dontlook.ogg")
Global DamageSFX = LoadSound("SFX\Player\damage.ogg")
Global Crush1SFX = LoadSound("SFX\Events\crush1.ogg")
Global Crush2SFX = LoadSound("SFX\Events\crush2.ogg")
Global BellSFX = LoadSound("SFX\Events\bell.ogg")
Global EyeKillerSFX = LoadSound("SFX\Monsters\eyekiller.ogg")
Global TransitionSFX = LoadSound("SFX\Events\transition.ogg")
Global SpiderSFX = LoadSound("SFX\Other\spider.ogg")
Global MUSIC_ON = True
Dim AmbientSFX(111)
For i = 0 To 110
AmbientSFX(i) = Load3DSound("SFX\Ambients\ambient" + (i + 1) + ".ogg")
Next
Dim RadioSFX(5)
For i = 0 To 4
RadioSFX(i) = LoadSound("SFX\Radio\radio" + (i + 1)+ ".ogg")
Next
Global MusicIntro = LoadSound("SFX\Music\The Beginning.ogg")
Global MusicDeep = LoadSound("SFX\Music\Deep Hell.ogg")
Global MusicSecondArea = LoadSound("SFX\Music\Ice Demon.ogg")
Global MusicElevator = LoadSound("SFX\Music\Elevator.ogg")
Global Music = LoadSound("SFX\Music\Gathering Darkness.ogg"), MusicChannel
Global ChaseSFX = LoadSound("SFX\Events\chase.ogg"), ChaseChannel
Global SoundSFX = Load3DSound("SFX\Monsters\dontlook.ogg"), SoundChannel
Global SoundSFXReverb = Load3DSound("SFX\Monsters\dontlook_reverb.ogg"), SoundChannelReverb
Global StepChannel
Global RadioMusic = Load3DSound("SFX\Radio\radioMusic.ogg")
Global FireOn = LoadSound("SFX\Events\match.ogg")
Global FireOff = LoadSound("SFX\Events\fireout.ogg")
Global TransisionSFX = LoadSound("SFX\Events\transision.ogg")
Dim GoRightSFX(3)
GoRightSFX(0) = LoadSound("SFX\Monsters\dontgoleft.ogg")
GoRightSFX(1) = LoadSound("SFX\Monsters\goright.ogg")
GoRightSFX(2) = LoadSound("SFX\Monsters\youwillstayforever.ogg")
;Ending sounds
Global BellEndingSFX = LoadSound("SFX\Events\bellEnding.ogg")
Global EscapeSFX = LoadSound("SFX\Music\Escape.ogg")
Global LastSecondsOfLifeSFX = LoadSound("SFX\Music\Last Seconds Of Life.ogg")
Global EndingSFX = LoadSound("SFX\Music\Ending.ogg")
Global RadioEndingSFX = LoadSound("SFX\Radio\radioEnding.ogg")
Global LightsOnSFX = LoadSound("SFX\Events\lightsOn.ogg")
Global PDExplosionSFX = LoadSound("SFX\PDExplosion.ogg")
Global MetalSFX = LoadSound("SFX\Events\metal.ogg")
Global YouAreBraveSFX = LoadSound("SFX\Monsters\youarebrave.ogg")
Global AmbientCaveSFX = LoadSound("SFX\Events\ambient_cave.ogg")
;----------------- SFX End ---------------------;
;---------------------------------------------------------;
;---------------------------------------------------------;
;----------------- GFX Start -------------------;
Global mentalmesh = PlayerMesh
Global spider
; Monsters
Dim MentalTextures(2)
MentalTextures(0) = LoadTexture("GFX\npc\mental.jpg")
MentalTextures(1) = LoadTexture("GFX\npc\mental-2.jpg")
MentalTextures(2) = LoadTexture("GFX\npc\mental-3.jpg")
Global mental = LoadTexture("GFX\npc\mental.jpg") ; need for server
Global mental2 = LoadTexture("GFX\npc\mental-2.jpg")
Global mental3 = LoadTexture("GFX\npc\mental-3.jpg")
Dim RedmistTextures(2)
RedmistTextures(0) = LoadTexture("GFX\npc\173.jpg")
RedmistTextures(1) = LoadTexture("GFX\npc\173-2.jpg")
RedmistTextures(2) = LoadTexture("GFX\npc\173-3.jpg")
Global tex173 = LoadTexture("GFX\npc\173.jpg") ; need for server
Global tex1732 = LoadTexture("GFX\npc\173-2.jpg")
Dim EyekillerTextures(2)
EyekillerTextures(0) = LoadTexture("GFX\npc\eyekiller.jpg")
EyekillerTextures(1) = LoadTexture("GFX\npc\eyekiller-2.jpg")
EyekillerTextures(2) = LoadTexture("GFX\npc\eyekiller-3.jpg")
Global eyekiller = LoadTexture("GFX\npc\eyekiller.jpg") ; need for server
Dim UnknownTextures(2)
UnknownTextures(0) = LoadTexture("GFX\npc\unknown.jpg")
UnknownTextures(1) = LoadTexture("GFX\npc\unknown-2.jpg")
UnknownTextures(2) = LoadTexture("GFX\npc\unknown-3.jpg")
Global clothwandertex = LoadTexture("GFX\npc\clothwander.jpg") ;;TODO make/find more texture variants for clothwander
;Global unknowntex = LoadTexture("GFX\npc\unknown.jpg")
Dim GlimpseTextures(6)
GlimpseTextures(0)= LoadTexture("GFX\npc\glimpse1.png",1+2)
GlimpseTextures(1)= LoadTexture("GFX\npc\glimpse2.png",1+2)
GlimpseTextures(2)= LoadTexture("GFX\npc\glimpse3.png",1+2)
GlimpseTextures(3)= LoadTexture("GFX\npc\glimpse4.png",1+2)
GlimpseTextures(4)= LoadTexture("GFX\npc\glimpse5.png",1+2)
GlimpseTextures(5)= LoadTexture("GFX\npc\glimpse6.png",1+2)
GlimpseTextures(6)= LoadTexture("GFX\npc\glimpse7.png",1+2)
Global EnemyMental.ENEMIES
Global EnemyRedmist.ENEMIES
Global EnemyClothwander.ENEMIES
Global EnemyClothwander2.ENEMIES
Global EnemyClothwander3.ENEMIES
Global EnemyClothwander4.ENEMIES
Collisions hit_monster,hit_map, 2,3
Collisions hit_friendly,hit_map, 2,2
Collisions hit_player,hit_player, 1,3
Collisions hit_player,hit_map, 2,2
Collisions hit_friendly,hit_monster, 1,3
Collisions hit_monster,hit_friendly, 1,3
Collisions hit_monster,hit_map, 2,2
Collisions hit_invisible,hit_map, 2,2
;----------------- GFX End ---------------------;
;---------------------------------------------------------;
;Create the vignette
VignetteTexture = LoadTexture("GFX\fog.jpg", 1)
Vignette = CreateSprite(Camera)
ScaleSprite(Vignette, Max(GraphicWidth / 1240.0, 1.0), Max(GraphicHeight / 960.0 * 0.8, 0.8))
EntityTexture(Vignette, VignetteTexture)
EntityBlend (Vignette, 2)
EntityOrder Vignette, -1000
MoveEntity(Vignette, 0, 0, 1.0)
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
;Ending settings
Global EndingFogRange# = 2.0
Global EndingFogLight = 0
Global SpeedLimit# = 1.0
Global EndingSceneMod = False
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
CameraFogRange(camera, 1, 6.5)
Global GameStarted = False
Global timerlowfps = 0
Global time, elapsed, ticks, tween#
Global period=1000/60
time=MilliSecs()-period
Global IsPaused = False
Global PauseTimer = 0
Global PauseBool = False
Global QUIT = True
Global GAME_END = False
dropspeed# = 0.000
Global steptimer = 0
Global breathtimer = 0
Global crouchtimer = 0
Global IsCrouched = False
Global RestartGame = False
Global MusicTimer# = 100.0
Global ZoomTimer# = 0.0
Global Sensitivity# = GetINIFloat("options.ini","options","sensitivity")
Global collider_oldy# = 0.0
Global AmbientTimer = Rand(500,2000)
Global DeepMusicON = False
Global Radio
Global DebugMode = False
ChannelVolume MusicChannel,0.00
If PlayState <> GAME_CLIENT Then
CreateMap(flooramount)
If area = "The Second" Then
ElseIf PlayState = GAME_SOLO
CreateGlimpses()
EndIf
EndIf
If JoinToServer Then
JoinServer(ServerAddress)
EndIf
;Intro Initialization
If introskip = False And PlayState = GAME_SOLO Then
intro1SFX = LoadSound("SFX\intro1.ogg")
intro2SFX = LoadSound("SFX\intro2.ogg")
Dim introimg(5)
For i = 0 To 4
introimg(i) = LoadImage("GFX\intro" + (i + 1) + ".jpg")
ScaleImage(introimg(i),GraphicsWidth() / 1920.0,GraphicsHeight() / 1080.0)
Next
EndIf
;end
Delay 50
Cls
tempImg = LoadImage("GFX\scpdone.jpg")
DrawImage(tempImg,(GraphicsWidth()/2)-(ImageWidth(tempImg)/2),(GraphicsHeight()/2)-(ImageHeight(tempImg)/2))
Flip
FreeImage tempImg
temp = True
While temp
If KeyHit(57) Or PlayState <> GAME_SOLO Then temp = False
Delay 30
Wend
Cls
Flip
;----------------- Intro Sequence ---------------------;
;---------------------------------------------------------;
If PlayState = GAME_SOLO And skipintro = False And area <> "The Second" And sector <> "Lower" Then
Delay 1500
;DrawImage(tempImg,(GraphicsWidth()/2)-(ImageWidth(tempImg)/2),(GraphicsHeight()/2)-(ImageHeight(tempImg)/2))
For i = 0 To 4
Cls
DrawImage(introimg(4-i),(GraphicsWidth()/2)-(ImageWidth(introimg(4-i))/2),(GraphicsHeight()/2)-(ImageHeight(introimg(4-i))/2))
Flip
Delay 70
Next
SoundChannel = PlaySound(intro1SFX)
While ChannelPlaying(SoundChannel)
Delay 30
Wend
For i = 0 To 4
Cls
DrawImage(introimg(i),(GraphicsWidth()/2)-(ImageWidth(introimg(4-i))/2),(GraphicsHeight()/2)-(ImageHeight(introimg(4-i))/2))
Flip
Delay 80
Next
For i = 0 To 4
FreeImage introimg(i)
Next
Cls
Flip
Delay 200
SoundChannel = PlaySound(intro2SFX)
While ChannelPlaying(SoundChannel)
Delay 30
Wend
EndIf
;----------------End Of Intro Sequence--------------------;
;---------------------------------------------------------;
EntityType collider, hit_map
MoveMouse viewport_center_x, viewport_center_y
PositionEntity collider, -2.5, ColliderDefaultY#, -0.5
TurnEntity collider, 0.0, -90.0, 0.0
EntityType collider, hit_player
If PlayState = GAME_SOLO Then
If sector = "Lower" Then
PositionEntity collider,7.7,-98.5,-13.0
GameStarted = True
DeepMusicON = True
EndIf
If area = "The Second" Then
PositionEntity collider,0.5,-280.5,-0.5
MoveEntity collider, 0.0, 0.1, 0.0
RotateEntity collider, 0.0, -90.0, 0.0
GameStarted = True
DeepMusicON = True
EndIf
EndIf
Global introtimer = 150
PlayerFloor = (-EntityY(collider)-0.3)/2+0.1
collider_oldy = EntityY(collider)
Global CanMove = True
If PlayState = GAME_CLIENT Then
JoinServer(ServerAddress)
EndIf
If PlayState <> GAME_SOLO Then
GameStarted = True
EndIf
Local SensTimer% = 0
Global LoopDelay = MilliSecs()
Global ChatOpened% = False
Global message$ = ""
Global frameTimer=CreateTimer(60)
Global AFKMode% = False
Global MatchTimer = Rand(15600,30000)
Global testlight = 100
Color 255,255,255
While QUIT
If PLAYSTATE <> GAME_SOLO Then
UpdateServer()
EndIf
;;;;;;DEBUG MODE;;;;;;;
;AmbientLight 255,255,255
;CameraRange camera, 0.001, 3000.0
;CameraFogMode camera, 0
;CameraFogRange camera, 1, 2000.5
;CameraFogColor camera,0,0,0
DebugLog "x = " + EntityX(camera)
DebugLog "z = " + EntityZ(camera)
;-------------------------------------------------------------------------;
;----------------- Setting up pause screen ---------------------;
If IntroTimer > 0 And PLAYSTATE = GAME_SOLO Then
If introtimer = 100 Then PlaySound(FireOn)
If introtimer <= 80 Then
If gamestarted Then fogrange# = 4.5 Else fogrange# = 6.5
templight1# = (81.0-introtimer)/80.0
templight2# = max(0,templight1*24.0)
AmbientLight (templight1#*BRIGHTNESS)+templight2#,(templight1#*BRIGHTNESS)+templight2#,(templight1#*BRIGHTNESS)+templight2#
CameraFogRange camera, templight1#*1.0, templight1#*fogrange#
Else
AmbientLight 0,0,0
CameraFogRange camera, 0.1, 0.1
EndIf
introtimer = introtimer - 1
EndIf
While IsPaused And PLAYSTATE = GAME_SOLO
Cls
RenderWorld
UpdateBlur(0.97)
BlurTimer = 250
SetFont font
Color 10,10,10
Text (GraphicsWidth () / 2)-197,(GraphicsHeight () / 2)-115,"PAUSED"
Color PauseTimer,PauseTimer,PauseTimer
Text (GraphicsWidth () / 2)-194,(GraphicsHeight () / 2)-118,"PAUSED"
SetFont font1
Color 10,10,10
Text (GraphicsWidth () / 2)-114,(GraphicsHeight () / 2)+2,"Press ESC to continue"
Color PauseTimer,PauseTimer,PauseTimer
Text (GraphicsWidth () / 2)-111,(GraphicsHeight () / 2),"Press ESC to continue"
Color 10,10,10
Text (GraphicsWidth () / 2)-114,(GraphicsHeight () / 2)+21,"Press SPACEBAR to quit"
Color PauseTimer,PauseTimer,PauseTimer
Text (GraphicsWidth () / 2)-111,(GraphicsHeight () / 2)+19,"Press SPACEBAR to quit"
Color 10,10,10
Text (GraphicsWidth () / 2)-184,(GraphicsHeight () / 2)+41,"Press +/- to change mouse sensitivity"
Color PauseTimer,PauseTimer,PauseTimer
Text (GraphicsWidth () / 2)-181,(GraphicsHeight () / 2)+39,"Press +/- to change mouse sensitivity"
If SensTimer > 10 Then
Color 10,10,10
Text (GraphicsWidth () / 2)-84,(GraphicsHeight () / 2)+61,"Sensitivity: " + Int(sensitivity*100)/100.0
Color min(PauseTimer,SensTimer),min(PauseTimer,SensTimer),min(PauseTimer,SensTimer)
Text (GraphicsWidth () / 2)-81,(GraphicsHeight () / 2)+59,"Sensitivity: " + Int(sensitivity*100)/100.0
EndIf
Flip
Delay 20
If PauseTimer > 200 Then
PauseBool = True
ElseIf PauseTimer < 100 Then
PauseBool = False
EndIf
If PauseBool Then
PauseTimer = PauseTimer - 1
Else
PauseTimer = PauseTimer + 1
EndIf
If KeyDown(12) Then
sensitivity = sensitivity-0.01
SensTimer = min(250,max(150,SensTimer+2))
If SensTimer = 250 Then sensitivity = sensitivity - 0.04
PutINIValue("options.ini","options","sensitivity",Int(sensitivity*100)/100.0)
EndIf
If KeyDown(13) Then
sensitivity = sensitivity+0.01
SensTimer = min(250,max(150,SensTimer+2))
If SensTimer = 250 Then sensitivity = sensitivity + 0.04
PutINIValue("options.ini","options","sensitivity",Int(sensitivity*100)/100.0)
EndIf
sensitivity = max(0.1,min(10,sensitivity))
Senstimer = max(0,Senstimer - 1)
If KeyHit(1) Then
IsPaused = False
PauseTimer = 0
MoveMouse viewport_center_x, viewport_center_y
EndIf
If KeyDown(57) Then
QUIT = False
IsPaused = False
EndIf
Wend
If KeyHit(1) Then
If PlayState <> GAME_SOLO And AFKMode = False Then
If IsPaused Then
IsPaused = False
MoveMouse viewport_center_x, viewport_center_y
Else
IsPaused = True
EndIf
ElseIf killtimer = 0 And PlayState = GAME_SOLO Then
If FloorTimer(PlayerFloor)>1 And GameStarted Then
SetFont font1
PauseTimer = 150