-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathClientAreas_FE.bb
More file actions
1531 lines (1331 loc) · 53.9 KB
/
Copy pathClientAreas_FE.bb
File metadata and controls
1531 lines (1331 loc) · 53.9 KB
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
;Set Constants
Const MaxFogFar# = 2000.0
Global SkyEN, CloudEN, StarsEN
Global SkyTexID = 65535, CloudTexID = 65535, StormCloudTexID = 65535, StarsTexID = 65535
Global FogR, FogG, FogB, FogNear#, FogFar#
Global Outdoors
Global AmbientR = 100, AmbientG = 100, AmbientB = 100
Global DefaultLightPitch#, DefaultLightYaw#
Global LoadingTexID = 65535, LoadingMusicID = 65535
Global MapTexID
Global SlopeRestrict# = 0.6
Type Remove_Surf
Field ID
End Type
Type Cluster
Field XC#, YC#, ZC#
Field Mesh, Surf[200]
End Type
Type Scenery
Field SceneryID ; Set by user, used for scenery ownerships {##}
Field EN, MeshID
Field AnimationMode ; 0 = no animation, 1 = constant animation (loops), 2 = constant (ping-pongs), 3 = animate when selected
Field ScaleX#, ScaleY#, ScaleZ#
Field Lightmap$ ; Lightmap filename
Field RCTE$ ; Used by toolbox editors only
Field TextureID ; To alter the texture loaded automatically with the model, if required (65535 to ignore)
Field CatchRain
Field Locked
Field CastShadow ;[010]
Field ReceiveShadow
Field RenderRange ;[011]
Field SceneryType$ ;Variable declaration for view distance Ramoida
Field ENWF$
Field LightID ; Dynamic lighting
Field ENName$
Field ENLight$
Field TexHandle
Field ENFM$
Field ENFL$
Field Name$
End Type
;LOD Ramoida (Set view distances here)
Const BuildingMinViewDistance# = 230.0 ; If distance < this value will be Visible, else will autofade slowly
Const BuildingMaxViewDistance# = 250.0 ; If distance > this value will be 100% invisible
Const GrassMinViewDistance# = 75.0
Const GrassMaxViewDistance# = 90.0
Const RunicMinViewDistance# = 5.0
Const RunicMaxViewDistance# = 10.0
Const ParticleMaxViewDistance# = 10.0
Type Water
Field EN, TexID, Opacity
Field Red, Green, Blue
Field ScaleX#, ScaleZ#
Field TexHandle, TexScale#, U#, V#
Field ServerWater ; Used by editor only
; Water refraction terrier
Field WaterClipplane
End Type
Type ColBox
Field EN
Field ScaleX#, ScaleY#, ScaleZ#
End Type
Type Emitter
Field Config, ConfigName$, EN, TexID
End Type
Type Terrain
Field EN, DetailTex
Field BaseTexID, DetailTexID
Field DetailTexScale#
Field ScaleX#, ScaleY#, ScaleZ#
Field Detail, Morph, Shading
End Type
Type SoundZone
Field EN, Radius#
Field SoundID, MusicID ; Can be one or the other
Field RepeatTime ; Number of seconds to wait before repeating the sound, or -1 to play it once only
Field Volume ; Volume (1% - 100%)
Field LoadedSound, MusicFilename$
Field Is3D
Field Channel, Timer, Fade# ; Variables for updating the sound zone in the client
End Type
; Generated from scenery objects to prevent rain/snow particles falling through
Type CatchPlane
Field MinX#, MinZ#, MaxX#, MaxZ#, Y#
End Type
; Creates a subdivided plane (used for water)
Function CreateSubdividedPlane(XDivs, ZDivs, UScale# = 1.0, VScale# = 1.0, Parent = 0)
; Clamp divisions to a sane minimum (see ClientAreas.bb for the
; full reasoning). XDivs/ZDivs of 1 would divide-by-zero on the
; XPos/ZPos normalization. Below 2 has no actual subdivision.
If XDivs < 2 Then XDivs = 2
If ZDivs < 2 Then ZDivs = 2
EN = CreateMesh(Parent)
Surf = CreateSurface(EN)
For x = 0 To XDivs - 1
For z = 0 To ZDivs - 1
XPos# = Float#(x) / Float#(XDivs - 1)
ZPos# = Float#(z) / Float#(ZDivs - 1)
V = AddVertex(Surf, XPos#, 0.0, ZPos#, XPos# * UScale#, ZPos# * VScale#)
VertexNormal(Surf, V, 0.0, 1.0, 0.0)
If x > 0 And z > 0
v1 = ((x - 1) * ZDivs) + (z - 1)
v2 = ((x - 1)* ZDivs) + z
v3 = (x * ZDivs) + (z - 1)
v4 = (x * ZDivs) + z
AddTriangle(Surf, v1, v2, v4)
AddTriangle(Surf, v1, v4, v3)
EndIf
Next
Next
PositionMesh(EN, -0.5, 0.0, -0.5)
Return EN
End Function
;&&&&&&&&&&&&&&& Refractive water terrier
Function RenderWater(Camera)
For W.Water = Each Water
; CameraFogMode Camera,0
;HideEntity CameraSprite
; ShowClipplane W\WaterClipplane =>
AlignClipplane W\WaterClipplane, W\EN
;EntityAlpha W\EN,0.25 => sinon impose un alpha au plan d'eau
EntityTexture W\EN, FoamTexture
Next
SetBuffer TextureBuffer(RefractTexture)
; CameraViewport Camera, 0,0, TextureWidth(RefractTexture), TextureHeight(RefractTexture)
; CameraViewport Camera, 0,0, 1, 1
;CameraViewport Camera, 0, 0, TextureWidth(RefractTexture) , TextureHeight(RefractTexture)
; ScaleEntity Camera,1,Float(GraphicsHeight())/Float(GraphicsWidth()),1
;
;ShowEntity(Camera)
RenderWorld
HideEntity(Camera)
; render world in backBuffer (set refractions texture to water plane)
For W.Water = Each Water
; If CameraUnderWater = True
; ;ShowEntity CameraSprite
; CameraFogMode Camera,1
; CameraFogRange Camera,0.5,35
; CameraFogColor Camera,20,20,40
;Else
;HideEntity CameraSprite
;CameraFogMode Camera,1
;CameraFogRange Camera,20,250
;CameraFogColor Camera,190,200,220
;EndIf
HideClipplane W\WaterClipplane
EntityTexture W\EN, BumpTexture, (BumpTextureFrame Mod 32), 0
EntityTexture W\EN, RefractTexture, 0, 1
;EntityAlpha W\EN,1 => sinon impose un alpha au plan d'eau
EntityColor W\EN,25,30,35 ; => renforce le r�alisme mais bleu par d�faut
SetBuffer BackBuffer()
ShowEntity(Camera)
; CameraViewport Camera, 0,0, GraphicsWidth(), GraphicsHeight()
; ScaleEntity Camera,1,1,1 ; ����������� ��������� ������
;RenderWorld ;=> fait gagner 10 FPS de +
Next
End Function
; Loads the client (3D) data for an area
Function LoadArea(Name$, CameraEN, DisplayItems = False, UpdateRottNet = False)
; RottNet update
Local RNUpdateTime% = MilliSecs()
Local PLoadMusic%, CLoadMusic%
;Adding shadows to options menu Cysis145
F = ReadFile("Data\Options.dat")
Width = ReadShort(F)
Height = ReadShort(F)
Depth = ReadByte(F)
AA = ReadByte(F)
DefaultVolume# = ReadFloat#(F)
GrassEnabled = ReadByte(F)
AnisotropyLevel = ReadByte(F)
FullScreen = ReadByte(F)
VSync = ReadByte(F)
Bloom = ReadByte(F)
Rays = ReadByte(F)
AWater = ReadByte(F)
ShadowC = ReadByte(F)
ShadowQ = ReadByte(F)
ShadowR = ReadByte(F)
CloseFile(F)
Select ShadowQ
Case 0
CreateShadow 0
Case 1
CreateShadow 1
Case 2
CreateShadow 2
End Select
Select ShadowR
Case 0
ShadowRange 50
Case 1
ShadowRange 75
Case 2
ShadowRange 100
Case 3
ShadowRange 130
End Select
;Season = GetSeason()
; Dusk
;If TimeH = SeasonDuskH(Season)
; ShadowPower 0.0 ;Set Shadow Opacity
; Dawn
;ElseIf TimeH = SeasonDawnH(Season)
; ShadowPower 0.0 ;Set Shadow Opacity
;EndIf
ShadowPower 0.4 ;Set Shadow Opacity
ShadowColor 255, 255, 255
;ShadowLight DefaultLight\EN
ShadowTexture = ShadowTexture() ; Gets shadow map
;Shadow Fading
FadeOutTexture = LoadTexture("Data\Textures\Shadows\fade.png", 59)
ShadowFade FadeOutTexture
; Open file. Lock AFTER the missing-file check (matching AreaLoader.bb):
; locking first leaked both Media.bb lock handles on every failed load,
; since the next Lock call overwrites the handle Global without closing
; the old one. The early return below holds no locks.
F = ReadFile("Data\Areas\" + Name$ + ".dat")
If F = 0 Then Return False
LockMeshes()
LockTextures()
; Loading screen
LoadingTexID = ReadShort(F)
LoadingMusicID = ReadShort(F)
; Music
If LoadingMusicID < 65535 Then
PLoadMusic = LoadSound("Data\Music\" + GetMusicName$(LoadingMusicID), False)
LoopSound PLoadMusic
CLoadMusic = PlaySound(PLoadMusic)
EndIf
If DisplayItems = False
; Progress bar
LoadProgressBar = GY_CreateProgressBar(0, 0.3, 0.9, 0.4, 0.035, 0, 100, 255, 255, 255, -3012)
; Preset image
LoadScreen = CreateMesh(GY_Cam)
Surf = CreateSurface(LoadScreen)
v1 = AddVertex(Surf, 0.0, -1.0, 0.0, 0.0, 1.0)
v2 = AddVertex(Surf, 1.0, -1.0, 0.0, 1.0, 1.0)
v3 = AddVertex(Surf, 1.0, 0.0, 0.0, 1.0, 0.0)
v4 = AddVertex(Surf, 0.0, 0.0, 0.0, 0.0, 0.0)
AddTriangle Surf, v3, v2, v1
AddTriangle Surf, v4, v3, v1
;Widescreen Ramoida
If ResolutionType = 1 ; 16:9 ratio
ScaleMesh LoadScreen, 27.0, 15.05, 1.0 ;x,y,z
PositionEntity LoadScreen, -13.5, 7.55, 10.0
Else ;;4:3 ratio
ScaleMesh LoadScreen, 20.5, 15.5, 1.0
PositionEntity LoadScreen, -10.07, 7.55, 10.0
EndIf
EntityOrder LoadScreen,-3011
EntityFX LoadScreen, 1 + 8
If LoadingTexID < 65535
Tex = GetTexture(LoadingTexID)
If Tex <> 0
EntityTexture(LoadScreen, Tex)
UnloadTexture(LoadingTexID)
EndIf
; Random image
ElseIf RandomImages > 0
D = ReadDir("Data\Textures\Random")
If D = 0
EntityColor(LoadScreen, 0, 0, 0)
Else
For i = 1 To Rand(1, RandomImages)
Repeat
File$ = NextFile$(D)
Until FileType("Data\Textures\Random\" + File$) = 1 Or File$ = ""
If File$ = "" Then Exit
Next
If FileType("Data\Textures\Random\" + File$) = 1
Tex = LoadTexture("Data\Textures\Random\" + File$)
If Tex = 0
EntityColor(LoadScreen, 0, 0, 0)
Else
EntityTexture(LoadScreen, Tex)
FreeTexture(Tex)
EndIf
Else
EntityColor(LoadScreen, 0, 0, 0)
EndIf
CloseDir(D)
EndIf
; No image
Else
EntityColor(LoadScreen, 0, 0, 0)
EndIf
EndIf
; Loading bar update
If LoadScreen <> 0
GY_UpdateProgressBar(LoadProgressBar, 0)
RenderWorld()
Flip()
EndIf
; Environment
SkyTexID = ReadShort(F)
CloudTexID = ReadShort(F)
StormCloudTexID = ReadShort(F)
StarsTexID = ReadShort(F)
FogR = ReadByte(F)
FogG = ReadByte(F)
FogB = ReadByte(F)
FogNear# = ReadFloat#(F)
FogFar# = ReadFloat#(F)
If FogFar# > MaxFogFar# Then FogFar# = MaxFogFar#
FogNearNow# = FogNear#
FogFarNow# = FogFar#
; Sky
If SkyTexID > -1 And SkyTexID < 65535
EntityTexture(SkyEN, GetTexture(SkyTexID))
EntityAlpha(SkyEN, 1.0)
Else
EntityAlpha(SkyEN, 0.0)
EndIf
If CloudTexID > -1 And CloudTexID < 65535
EntityTexture(CloudEN, GetTexture(CloudTexID))
EntityAlpha(CloudEN, 0.4)
ElseIf StormCloudTexID > -1 And StormCloudTexID < 65535
EntityTexture(CloudEN, GetTexture(StormCloudTexID))
EntityAlpha(CloudEN, 0.4)
Else
EntityAlpha(CloudEN, 0.0)
EndIf
If StarsTexID > -1 And StarsTexID < 65535
EntityTexture(StarsEN, GetTexture(StarsTexID))
EntityAlpha(StarsEN, 1.0)
Else
EntityAlpha(StarsEN, 0.0)
EndIf
; Camera
If CameraEN <> 0
SetViewDistance(CameraEN, FogNear#, FogFar#)
CameraFogColor(CameraEN, FogR, FogG, FogB)
CameraClsColor(CameraEN, FogR, FogG, FogB)
EndIf
MapTexID = ReadShort(F)
Outdoors = ReadByte(F)
AmbientR = ReadByte(F)
AmbientG = ReadByte(F)
AmbientB = ReadByte(F)
DefaultLightPitch# = ReadFloat#(F)
DefaultLightYaw# = ReadFloat#(F)
SlopeRestrict# = ReadFloat#(F)
AmbientLight(AmbientR, AmbientG, AmbientB)
;&&&&& Camera refractive water terrier
CameraSprite = CreateSprite(Camera)
PositionEntity CameraSprite,0,0,0.11
EntityColor CameraSprite,20,20,40
EntityAlpha CameraSprite,0.35
; RottNet update
If UpdateRottNet = True And MilliSecs() - RNUpdateTime > 500 Then RCE_Update() : RCE_CreateMessages() : RNUpdateTime = MilliSecs()
; Loading bar update
If LoadScreen <> 0
GY_UpdateProgressBar(LoadProgressBar, 5)
RenderWorld() ;[998]
Flip()
EndIf
; Scenery
Sceneries = ReadShort(F)
For i = 1 To Sceneries
S.Scenery = New Scenery
; Mesh (from media database ID)
S\MeshID = ReadShort(F)
; Nasty hack to disable decryption on RCTE terrains in a subfolder DISABLED terrains are no longer encrypted so no need to keep code.
NoDecrypt = False
Name$ = Upper$(GetMeshName$(S\MeshID))
;If Instr(Name$, "RCTE\") = 1 Or Instr(Name$, "RCTE/") = 1
; If Instr(Name$, "\", 6) > 0 Or Instr(Name$, "/", 6) > 0 Then NoDecrypt = True
;EndIf
; Load the mesh
S\EN = GetMesh(S\MeshID, False)
; Read position/rotation/scale
X# = ReadFloat#(F) : Y# = ReadFloat#(F) : Z# = ReadFloat#(F)
Pitch# = ReadFloat#(F) : Yaw# = ReadFloat#(F) : Roll# = ReadFloat#(F)
S\ScaleX# = ReadFloat#(F) : S\ScaleY# = ReadFloat#(F) : S\ScaleZ# = ReadFloat#(F)
; is it a bump mesh? [BUMP]
If Instr(Name$, "BUMPED\") Then
meshName$ = GetMeshNameClean$(S\MeshID)
bumpMap = LoadTexture("Data\Meshes\"+meshName$+"_NORMAL.jpg")
;TextureCoords(colorMap, 1)
EntityTexture S\EN, bumpMap, 0, 1
TextureBlend bumpMap,4
FreeTexture(bumpMap)
EndIf
; bump mesh end
; Animation mode and ownership ID
S\AnimationMode = ReadByte(F)
S\SceneryID = ReadByte(F) ;{##}
; Retexturing
S\TextureID = ReadShort(F)
; Collision/picking
S\CatchRain = ReadByte(F)
Collides = ReadByte(F)
; Lightmap information and RCTE data. Bound the asset paths
; so a corrupted Area data file can't hang the loader on a
; wild ReadInt length prefix (260 = Windows MAX_PATH).
S\Lightmap$ = ReadBoundedString$(F, 260)
S\RCTE$ = ReadBoundedString$(F, 260)
;v1.104 options cysis145 [010]
S\CastShadow = ReadByte(F)
S\ReceiveShadow = ReadByte(F)
S\RenderRange = ReadByte(F) ;[011]
If S\EN <> 0
; Toolbox extras [~@~]
;If Len(S\RCTE$) > 5
; Select Left$(S\RCTE$, 5)
; Case "_TREE"
; If DisplayItems = False
; swingsty = Int(Mid$(S\RCTE$, 6, 1))
; evergrn = Int(Mid$(S\RCTE$, 7, 1))
; S\EN = LoadTree("", evergrn, S\EN, swingsty)
; EndIf
; Case "_GRSS"
; swingsty = Int(Mid$(S\RCTE$, 6, 1))
; evergrn = Int(Mid$(S\RCTE$, 7, 1))
; S\EN = LoadGrass("", evergrn, S\EN, swingsty)
; Case "_RCDN"
; If DisplayItems = False
; RotateMesh(S\EN, Pitch#, Yaw#, Roll#)
; ScaleEntity(S\EN, S\ScaleX#, S\ScaleY#, S\ScaleZ#)
; ChunkTerrain(S\EN, 3, 3, 3, X#, Y#, Z#)
; Delete S
; Goto CancelScenery
; EndIf
; End Select
;EndIf
; Set position/rotation
PositionEntity S\EN, X#, Y#, Z# : RotateEntity S\EN, Pitch#, Yaw#, Roll#
ScaleEntity S\EN, S\ScaleX#, S\ScaleY#, S\ScaleZ#
;Dynamic Lighting
S\ENName=Left(Lower(GetFilename$(Name$)), 2)
S\LightID=0
S\ENLight=Lower(GetFilename$(Name$))
S\ENWF=Lower(GetFilename$(Name$))
S\ENFM=Lower(GetFilename$(Name$))
S\ENFL=Lower(GetFilename$(Name$))
;;LOD RAMOIDA
; S\SceneryType$ = "" ;initiate the variable just in case Ramoida
; If Instr(Name$, "RCTE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\CITYPATHS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFSCAFFOLD\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\ICE CAVES\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\CAVE\") Or Instr(Name$, "AAAAAAAM\OLD_MINE\OLD_MINE\")
; S\SceneryType$ = "T" ;If it is Terrain, mark it as "T" ;This will be used at Client.bb
; ;;BUILDINGS
; ElseIf Instr(Name$, "BUILDINGS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\ALKERZ\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\DONE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\DRAGON GATE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\MIDDEL EAST\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\NEWBUILDINGS2\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\RUINED_BRIDGE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\TREE BASE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\TROPICAL\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\WAGONS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\WARTORN\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\CASTLE2\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\FARM\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\MARKET STALLS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\NEW BUILDINGS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\RESPAWN POINT\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\SNOW PILES\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\DOCKS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\FIRT06\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\FOUNTAIN\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\STATUES\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\VILLAGE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ALKERZARK CENTER CHURCH\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ANCIENT_RUINS03\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ARTERIA3D_TROPICALPACK\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ELVENCITY_2010_UPDATE_GENERIC\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\OLD PORTAL\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\RUINED_BRIDGE\") Or Instr(Name$, "AAAAAAAM\CATAPULTS-SRC\") Or Instr(Name$, "AAAAAAAM\STONE BRIDGE\") Or Instr(Name$, "AAAAAAAM\WAGONS\") Or Instr(Name$, "AAAAAAAM\WINDMILL\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\NICE RS\") Or Instr(Name$, "RCTREES\") Or Instr(Name$, "AAAAAAAM\SPIKES\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\")
; S\SceneryType$ = "B"
; EntityAutoFade S\EN,BuildingMinViewDistance#,BuildingMaxViewDistance#;If it is an object set autofade
; ;GRASS
; ElseIf Instr(Name$, "GRASS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\FOREST GRASSS\") Or Instr(Name$, "AAAAAAAM\CRATES3D\CRATES\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\BARRELS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\HANGING ANIMALS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\BANNERS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\LAMP POST\") Or Instr(Name$, "ACTORS\HORSE AND CHART\") Or Instr(Name$, "ACTORS\NPC'S\ALKERZARK SOLDIERS\")
; S\SceneryType$ = "G"
; EntityAutoFade S\EN, GrassMinViewDistance#, GrassMaxViewDistance#
; ;;RUNIC
; ElseIf Instr(Name$, "EFFECTS\RUNICPATH\")
; S\SceneryType$ = "Z"
; EntityAutoFade S\EN, RunicMinViewDistance#, RunicMaxViewDistance#
; EndIf
;
; ;Shadows file trackers
; ;Recievers
; If Instr(Name$, "RCTE\") Or Instr(Name$, "Decles\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\ALKERZ\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\DRAGON GATE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\TRACK 1.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\TRACK 2.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\TRACK END.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\TRACK SLIGHT TURN.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\TRACK STRAIGHT END.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\TRACK STRAIGHT.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\TRACK TIGHT TURN.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\NEWBUILDINGS2\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\RUINED_BRIDGE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\TREE BASE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\TROPICAL\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\WAGONS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\FARM\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\MARKET STALLS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\NEW BUILDINGS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\RESPAWN POINT\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\VIKINGPACK2\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\CITYPATHS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\DOCKS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\FOUNTAIN\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\STATUES\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\VILLAGE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ALKERZARK CENTER CHURCH\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ANCIENT_RUINS03\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ARTERIA3D_TROPICALPACK\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ELVENCITY_2010_UPDATE_GENERIC\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\OLD PORTAL\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\RUINED_BRIDGE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\NICE RS\") Or Instr(Name$, "AAAAAAAM\CATAPULTS-SRC\") Or Instr(Name$, "AAAAAAAM\PEASANT_HOUSE\") Or Instr(Name$, "AAAAAAAM\STONE BRIDGE\") Or Instr(Name$, "AAAAAAAM\WAGONS\") Or Instr(Name$, "AAAAAAAM\WINDMILL\") Or Instr(Name$, "AAAFROMDEMO\") Or Instr(Name$, "AAAM") Or Instr(Name$, "ATREEMAGIK\") Or Instr(Name$, "B3D ACTORS\") Or Instr(Name$, "BRIDGES\") Or Instr(Name$, "ITEMS\") Or Instr(Name$, "MYMODLES\") Or Instr(Name$, "MYWEAPONS\") Or Instr(Name$, "RCTREES\") Or Instr(Name$, "SHADRE\") Or Instr(Name$, "TREEMAGIK\") Or Instr(Name$, "AAAAAAAM\SPIKES\") Or Instr(Name$, "CHARACTER SET\")
; ;Any models in the rcte folder becomes a receiver
; EntityTexture S\EN, ShadowTexture, 0, 2
; ;AttachShadowReceiver% (S\EN) ; removes incorrect shadows (this was disabled as it was massively impacting on performance of around 30 fps)
; EndIf
; ;Casters
; If Instr(Name$, "AAAAAAAAAAAAMMMMMM2\ALKERZ\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\BONES DINO\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\DONE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\CLIFF SUPPORT.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\CRANE.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\MINE CART.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\PROP SET1.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\PROP SET2.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\SHAFT SUPPORT.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\STATUE.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\STONE CARVING.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\FROZENREEFMINES\TRACK STOPPER.B3D") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\DRAGO RUINS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\DRAGON GATE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\MIDDEL EAST\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\NEWBUILDINGS2\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\RUINED_BRIDGE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\TROPICAL\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\WAGONS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\WARTORN\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\CASTLE2\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\LAMP POST\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\MARKET STALLS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\NEW BUILDINGS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\RESPAWN POINT\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\VIKINGPACK2\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\DOCKS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\FIRT06\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\FOUNTAIN\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\STATUES\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\VILLAGE\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ALKERZARK CENTER CHURCH\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ANCIENT_RUINS03\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ARTERIA3D_TROPICALPACK\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ELVENCITY_2010_UPDATE_GENERIC\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\ROOTS\") Or Instr(Name$, "AAAAAAAAAAAAMMMMMM2\AMMMMM222\AMMMMM1\AMMMM\RUINED_BRIDGE\") Or Instr(Name$, "AAAAAAAM\CATAPULTS-SRC\") Or Instr(Name$, "AAAAAAAM\CRATES3D\") Or Instr(Name$, "AAAAAAAM\LOGS\") Or Instr(Name$, "AAAAAAAM\PEASANT_HOUSE\") Or Instr(Name$, "AAAAAAAM\STONE BRIDGE\") Or Instr(Name$, "AAAAAAAM\WAGONS") Or Instr(Name$, "AAAAAAAM\WINDMILL") Or Instr(Name$, "AAAM\") Or Instr(Name$, "AFROM RANDOM\") Or Instr(Name$, "ANIMAL PACKS\") Or Instr(Name$, "ATREEMAGIK\") Or Instr(Name$, "B3D ACTORS\") Or Instr(Name$, "BRIDGES\") Or Instr(Name$, "DUNGEON PACK 1\") Or Instr(Name$, "ITEMS\") Or Instr(Name$, "MY MODLES\") Or Instr(Name$, "MYWEAPONS\") Or Instr(Name$, "RCTREES\")
; CreateShadowCaster% (S\EN)
; EndIf
; NewLOD cysis145 [011]
S\SceneryType$ = ""
If DisplayItems = False
;Always Renders
If S\RenderRange = 0
S\SceneryType$ = "T"
;Short Range
ElseIf S\RenderRange = 1
S\SceneryType$ = "G"
EntityAutoFade S\EN, GrassMinViewDistance#, GrassMaxViewDistance#
;Long Range
ElseIf S\RenderRange =2
S\SceneryType$ = "B"
EntityAutoFade S\EN, BuildingMinViewDistance#, BuildingMaxViewDistance#
EndIf
EndIf
; Scenery Shadows cysis145 [010]
If S\ReceiveShadow And DisplayItems = False
EntityTexture S\EN, ShadowTexture, 0, 2
AttachShadowReceiver S\EN ;helps remove incorrect shadowing
EndIf
If S\CastShadow And DisplayItems = False
CreateShadowCaster S\EN
EndIf
; Chunking for dungeons etc.
If DisplayItems = False
Name$ = Upper$(GetMeshName$(S\MeshID))
If Instr(Name$, "RCDUNGEON\") Or Instr(Name$, "CUSTOMCHUNK\")
RotateMesh(S\EN, Pitch#, Yaw#, Roll#)
ScaleEntity(S\EN, S\ScaleX#, S\ScaleY#, S\ScaleZ#)
ChunkTerrain(S\EN, 3, 3, 3, X#, Y#, Z#)
Delete S
Goto CancelScenery
EndIf
EndIf
; Lightmap
If S\Lightmap$ <> ""
LMap = LoadTexture("Data\Textures\Lightmaps\" + S\Lightmap$)
TextureCoords(LMap, 1)
EntityTexture(S\EN, LMap, 0, 1)
FreeTexture(LMap)
EndIf
; Retexturing
; If Instr(Name$, "BUMPED\") Then
; colorMap = LoadTexture ("Data\Meshes\"+meshName$+"_DIMMER.jpg")
; ;TextureCoords(colorMap, 1)
; EntityTexture S\EN, colorMap, 0, 0
; TextureBlend colorMap, 3
; FreeTexture(colorMap)
; Else
; If S\TextureID < 65535 Then EntityTexture S\EN, GetTexture(S\TextureID)
; EndIf
If Instr(Name$, "BUMPED\") Then
colorMap = LoadTexture ("Data\Meshes\"+meshName$+"_SPEC.jpg")
;TextureCoords(colorMap, 1)
EntityTexture S\EN, colorMap, 0, 0
TextureBlend colorMap, 3
FreeTexture(colorMap)
Else
If S\TextureID < 65535 Then EntityTexture S\EN, GetTexture(S\TextureID)
EndIf
If Instr(Name$, "BUMPED\") Then
colorMap = LoadTexture ("Data\Meshes\"+meshName$+"_COLOR.jpg")
;TextureCoords(colorMap, 1)
EntityTexture S\EN, colorMap, 0, 2
TextureBlend colorMap, 2
FreeTexture(colorMap)
Else
If S\TextureID < 65535 Then EntityTexture S\EN, GetTexture(S\TextureID)
EndIf
;Glow models
; If Instr(Name$, "GLOWMODELS\") Then
; colorMap = LoadTexture ("Data\Meshes\"+meshName$+"_GLOW.jpg")
; ;TextureCoords(colorMap, 1)
; EntityTexture S\EN, colorMap, 0, 4
; TextureBlend colorMap, 3
; FreeTexture(colorMap)
; Else
; If S\TextureID < 65535 Then EntityTexture S\EN, GetTexture(S\TextureID)
; EndIf
; Type handle
NameEntity S\EN, Handle(S)
; Animation
If DisplayItems = False
If S\AnimationMode = 1
Animate(S\EN, 1)
ElseIf S\AnimationMode = 2
Animate(S\EN, 2)
EndIf
EndIf
; Set collision/picking
EntityType(S\EN, Collides)
If Collides = C_Sphere
EntityPickMode(S\EN, 1)
MaxLength# = MeshWidth#(S\EN) * S\ScaleX#
If MeshDepth#(S\EN) * S\ScaleZ# > MaxLength# Then MaxLength# = MeshDepth#(S\EN) * S\ScaleZ#
EntityRadius(S\EN, MaxLength# / 2.0, (MeshHeight#(S\EN) * S\ScaleY#) / 2.0)
ElseIf Collides = C_Triangle
EntityPickMode(S\EN, 2)
ElseIf Collides = C_Box
EntityPickMode(S\EN, 3)
WidthT# = MeshWidth#(S\EN) * S\ScaleX#
HeightT# = MeshHeight#(S\EN) * S\ScaleY#
DepthT# = MeshDepth#(S\EN) * S\ScaleZ#
EntityBox(S\EN, WidthT# / -2.0, HeightT# / -2.0, DepthT# / -2.0, WidthT#, HeightT#, DepthT#)
EndIf
ResetEntity(S\EN)
; Create catch plane if required
If S\CatchRain And DisplayItems = False
MMV.MeshMinMaxVertices = MeshMinMaxVerticesTransformed(S\EN, Pitch#, Yaw#, Roll#, S\ScaleX#, S\ScaleY#, S\ScaleZ#)
CP.CatchPlane = New CatchPlane
CP\Y# = MMV\MaxY# + Y#
CP\MinX# = MMV\MinX# + X#
CP\MinZ# = MMV\MinZ# + Z#
CP\MaxX# = MMV\MaxX# + X#
CP\MaxZ# = MMV\MaxZ# + Z#
EndIf
; Mesh has been deleted or removed from the database!
Else
; Soft-fail: log and drop the scenery. Pre-fix, the
; live-game path (DisplayItems=False) RuntimeError-
; crashed every player entering a zone with a missing
; MeshID -- bad world data could grief the entire
; server. The editor path (True) already silently
; Delete'd; now both branches log + drop uniformly.
WriteLog(MainLog, "LoadArea: scenery MeshID " + S\MeshID + " not found in model database; dropping scenery (zone: " + Name$ + ")")
Delete(S)
EndIf
.CancelScenery
; RottNet update
If UpdateRottNet = True And MilliSecs() - RNUpdateTime > 500 Then RCE_Update() : RCE_CreateMessages() : RNUpdateTime = MilliSecs()
; Loading bar update every alternate object
If LoadScreen <> 0 And (i Mod 2) = 0
GY_UpdateProgressBar(LoadProgressBar, 5 + (40 * i) / Sceneries)
RenderWorld()
Flip()
EndIf
Next
; Water
Waters = ReadShort(F)
For i = 1 To Waters
W.Water = New Water
; Entity/Texture
W\TexID = ReadShort(F)
W\TexHandle = GetTexture(W\TexID, True)
W\TexScale# = ReadFloat#(F)
; Position/size
X# = ReadFloat#(F) : Y# = ReadFloat#(F) : Z# = ReadFloat#(F)
W\ScaleX# = ReadFloat#(F) : W\ScaleZ# = ReadFloat#(F)
XDivs = Ceil(W\ScaleX# / 15.0)
ZDivs = Ceil(W\ScaleZ# / 15.0)
If XDivs > 70 Then XDivs = 70
If ZDivs > 70 Then ZDivs = 70
W\EN = CreateSubdividedPlane(XDivs, ZDivs, W\ScaleX#, W\ScaleZ#)
ScaleEntity W\EN, W\ScaleX#, 1.0, W\ScaleZ#
PositionEntity W\EN, X#, Y#, Z#
ScaleTexture W\TexHandle, W\TexScale#, W\TexScale#
EntityTexture W\EN, W\TexHandle,0,2 ; 1 par d�faut mais invisible avec refract
;&&& Water edit terrier
;BumpTexA = LoadAnimTexture("Data\Textures\Water\water_anim.jpg", 9, 64, 64, 0, 32) ;I'm using the FastExt demo bump. If you are using your own, you may need to change the parameters.
;TextureBlend BumpTexA, FE_BUMPLUM
; bump
BumpTexture = LoadAnimTexture ( "Data\Textures\Water\water_anim.jpg", 9, 64, 64, 0, 32 )
TextureBlend BumpTexture, FE_BUMP
;ScaleTexture BumpTexture,0.012,0.012
; <<<< ����� ����� ��� �����
FoamTexture = LoadTexture ( "Data\Textures\Water\foam.png", 1+2 )
TextureBlend FoamTexture, 1
ScaleTexture FoamTexture,30,30
ScaleTexture BumpTexture,W\TexScale#, W\TexScale#
;ScaleTexture FoamTexture,W\TexScale#, W\TexScale#
W\WaterClipplane = CreateClipplane ( WaterPlane )
;ClipPivotUp = CreatePivot() : RotateEntity ClipPivotUp,0,0,180 : PositionEntity ClipPivotUp, 0, 0.05, 0
AlignClipplane W\WaterClipplane, W\EN
; Colour
W\Red = ReadByte(F)
W\Green = ReadByte(F)
W\Blue = ReadByte(F)
; Opacity
W\Opacity = ReadByte(F)
If W\Opacity >= 100
EntityFX(W\EN, 1 + 16)
Else
EntityFX(W\EN, 16)
EndIf
Alpha# = Float#(W\Opacity) / 100.0
If Alpha# > 1.0 Then Alpha# = 1.0
EntityAlpha(W\EN, Alpha#)
; Picking
EntityBox W\EN, W\ScaleX# / -2.0, -1.0, W\ScaleZ# / -2.0, W\ScaleX#, 2.0, W\ScaleZ#
; Type handle
NameEntity W\EN, Handle(W)
; If I am a walking only character, create a collision box here
If DisplayItems = False And Me.ActorInstance <> Null
If Me\Actor\Environment = Environment_Walk
C.ColBox = New ColBox
C\EN = CreateCube()
EntityAlpha C\EN, 0.0
; Position/rotation/size
Y# = Y# - 1000.0
C\ScaleX# = Abs(W\ScaleX# / 2.0) : C\ScaleY# = 1000.0 : C\ScaleZ# = Abs(W\ScaleZ# / 2.0)
PositionEntity C\EN, X#, Y#, Z#
ScaleEntity C\EN, C\ScaleX#, C\ScaleY#, C\ScaleZ#
; Collisions
EntityBox C\EN, -C\ScaleX#, -C\ScaleY#, -C\ScaleZ#, C\ScaleX# * 2.0, C\ScaleY# * 2.0, C\ScaleZ# * 2.0
EntityType C\EN, C_Box
; Type handle
NameEntity C\EN, Handle(C)
EndIf
EndIf
; RottNet update
If UpdateRottNet = True And MilliSecs() - RNUpdateTime > 500 Then RCE_Update() : RCE_CreateMessages() : RNUpdateTime = MilliSecs()
Next
; Loading bar update
If LoadScreen <> 0
GY_UpdateProgressBar(LoadProgressBar, 60)
RenderWorld()
Flip()
EndIf
; Collision zones
ColBoxes = ReadShort(F)
For i = 1 To ColBoxes
C.ColBox = New ColBox
C\EN = CreateCube()
If DisplayItems = True Then EntityAlpha C\EN, 0.4 Else EntityAlpha C\EN, 0.0
; Position/rotation/size
X# = ReadFloat#(F) : Y# = ReadFloat#(F) : Z# = ReadFloat#(F)
Pitch# = ReadFloat#(F) : Yaw# = ReadFloat#(F) : Roll# = ReadFloat#(F)
C\ScaleX# = ReadFloat#(F) : C\ScaleY# = ReadFloat#(F) : C\ScaleZ# = ReadFloat#(F)
PositionEntity C\EN, X#, Y#, Z#
RotateEntity C\EN, Pitch#, Yaw#, Roll#
ScaleEntity C\EN, C\ScaleX#, C\ScaleY#, C\ScaleZ#
; Collisions
EntityBox C\EN, -C\ScaleX#, -C\ScaleY#, -C\ScaleZ#, C\ScaleX# * 2.0, C\ScaleY# * 2.0, C\ScaleZ# * 2.0
EntityType C\EN, C_Box
; Type handle
NameEntity C\EN, Handle(C)
Next
; Loading bar update
If LoadScreen <> 0
GY_UpdateProgressBar(LoadProgressBar, 65)
RenderWorld()
Flip()
EndIf
; Emitters
Emitters = ReadShort(F)
For i = 1 To Emitters
; Create emitter parent entity
E.Emitter = New Emitter
If DisplayItems = True
E\EN = CreateCone() : ScaleMesh E\EN, 3, 3, 3 : EntityAlpha E\EN, 0.5
Else
E\EN = CreatePivot()
EndIf
; Read in emitter data. Same length-prefix DoS hardening.
E\ConfigName$ = ReadBoundedString$(F, 260)
E\TexID = ReadShort(F)
Texture = GetTexture(E\TexID)
X# = ReadFloat#(F) : Y# = ReadFloat#(F) : Z# = ReadFloat#(F)
Pitch# = ReadFloat#(F) : Yaw# = ReadFloat#(F) : Roll# = ReadFloat#(F)
; Load config
E\Config = RP_LoadEmitterConfig("Data\Emitter Configs\" + E\ConfigName$ + ".rpc", Texture, CameraEN)
; Loaded successfully, create the emitter
If E\Config <> 0
EmitterEN = RP_CreateEmitter(E\Config)
EntityParent EmitterEN, E\EN, False
EntityPickMode E\EN, 2
NameEntity E\EN, Handle(E)
; Position/rotation
PositionEntity E\EN, X#, Y#, Z#
RotateEntity E\EN, Pitch#, Yaw#, Roll#
; Failed to load config, remove the emitter and (pre-fix)
; RuntimeError on the live-game path. Now soft-fail: log
; and continue zone load. Same threat-model as the scenery
; site above -- a bad emitter ConfigName$ in world data
; should not crash the whole client.
Else
WriteLog(MainLog, "LoadArea: emitter config '" + E\ConfigName$ + "' could not load; dropping emitter (zone: " + Name$ + ")")
HideEntity(E\EN)
FreeEntity(E\EN)
Delete(E)
EndIf
; EntityAutoFade E\EN, 10, 20
; RottNet update
If UpdateRottNet = True And MilliSecs() - RNUpdateTime > 500 Then RCE_Update() : RCE_CreateMessages() : RNUpdateTime = MilliSecs()
Next
; Loading bar update
If LoadScreen <> 0
GY_UpdateProgressBar(LoadProgressBar, 80)
RenderWorld()
Flip()
EndIf
; Blitz LOD terrains
Terrains = ReadShort(F)
For i = 1 To Terrains
T.Terrain = New Terrain
; Textures
T\BaseTexID = ReadShort(F)
T\DetailTexID = ReadShort(F)
; Terrain heights
GridSize = ReadInt(F)
T\EN = CreateTerrain(GridSize)
For X = 0 To TerrainSize(T\EN)
For Z = 0 To TerrainSize(T\EN)
ModifyTerrain(T\EN, X, Z, ReadFloat#(F), False)
Next
Next
; Position/rotation/size
X# = ReadFloat#(F) : Y# = ReadFloat#(F) : Z# = ReadFloat#(F)
Pitch# = ReadFloat#(F) : Yaw# = ReadFloat#(F) : Roll# = ReadFloat#(F)
T\ScaleX# = ReadFloat#(F)
T\ScaleY# = ReadFloat#(F)
T\ScaleZ# = ReadFloat#(F)
PositionEntity T\EN, X#, Y#, Z# : RotateEntity T\EN, Pitch#, Yaw#, Roll#
ScaleEntity T\EN, T\ScaleX#, T\ScaleY#, T\ScaleZ#
; Texture scale
T\DetailTexScale# = ReadFloat#(F)
; Apply textures
Tex = GetTexture(T\BaseTexID, True)
If Tex <> 0
ScaleTexture(Tex, TerrainSize(T\EN), TerrainSize(T\EN))
EntityTexture(T\EN, Tex, 0, 0)
FreeTexture(Tex)
EndIf
If T\DetailTexID > 0 And T\DetailTexID < 65535
T\DetailTex = GetTexture(T\DetailTexID, True)
ScaleTexture(T\DetailTex, T\DetailTexScale#, T\DetailTexScale#)
EntityTexture(T\EN, T\DetailTex, 0, 1)
If DisplayItems = False
FreeTexture(T\DetailTex)
T\DetailTex = 0
EndIf
EndIf
; Detail etc.
T\Detail = ReadInt(F)
T\Morph = ReadByte(F)
T\Shading = ReadByte(F)
TerrainDetail(T\EN, T\Detail, T\Morph)
TerrainShading(T\EN, T\Shading)
; Collisions
EntityType T\EN, C_Triangle
EntityPickMode T\EN, 2
; Type handle
NameEntity T\EN, Handle(T)
; RottNet update
If UpdateRottNet = True And MilliSecs() - RNUpdateTime > 500 Then RCE_Update() : RCE_CreateMessages() : RNUpdateTime = MilliSecs()
; Loading bar update
If LoadScreen <> 0
GY_UpdateProgressBar(LoadProgressBar, 80 + ((15 * i) / Terrains))
RenderWorld()
Flip()
EndIf
Next
; Loading bar update
If LoadScreen <> 0
GY_UpdateProgressBar(LoadProgressBar, 98) ;95
RenderWorld()
Flip()
EndIf
; Sound zones
Sounds = ReadShort(F)
For i = 1 To Sounds
SZ.SoundZone = New SoundZone
If DisplayItems = True
SZ\EN = CreateSphere()
EntityAlpha SZ\EN, 0.5
EntityColor SZ\EN, 255, 255, 0
Else
SZ\EN = CreatePivot()
EndIf
; Position/size
X# = ReadFloat#(F) : Y# = ReadFloat#(F) : Z# = ReadFloat#(F)
SZ\Radius# = ReadFloat#(F)
ScaleEntity SZ\EN, SZ\Radius#, SZ\Radius#, SZ\Radius#
PositionEntity SZ\EN, X#, Y#, Z#
; Sound options
SZ\SoundID = ReadShort(F)
SZ\MusicID = ReadShort(F)
SZ\RepeatTime = ReadInt(F)
SZ\Volume = ReadByte(F)
; Load sound
If SZ\SoundID <> 65535
SZ\LoadedSound = GetSound(SZ\SoundID)
SZ\Is3D = Asc(Right$(GetSoundName$(SZ\SoundID), 1))
Else
SZ\MusicFilename$ = "Data\Music\" + GetMusicName$(SZ\MusicID)
EndIf
; Type handle
NameEntity SZ\EN, Handle(SZ)
; RottNet update
If UpdateRottNet = True And MilliSecs() - RNUpdateTime > 500 Then RCE_Update() : RCE_CreateMessages() : RNUpdateTime = MilliSecs()
Next
CloseFile(F)
UnlockMeshes()
UnlockTextures()
; End loading screen
If LoadScreen <> 0
FreeEntity(LoadScreen)
;FreeEntity(LoadLabel)
GY_FreeGadget(LoadProgressBar)
EndIf
If ChannelPlaying(CLoadMusic) = True Then StopChannel(CLoadMusic)
FreeSound PLoadMusic
Return True
End Function