-
-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathTileEngine.bas
1973 lines (1483 loc) · 66.8 KB
/
TileEngine.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 = "Mod_TileEngine"
'Argentum Online 0.11.6
'
'Copyright (C) 2002 Marquez Pablo Ignacio
'Copyright (C) 2002 Otto Perez
'Copyright (C) 2002 Aaron Perkins
'Copyright (C) 2002 Matias Fernando Pequeno
'
'This program is free software; you can redistribute it and/or modify
'it under the terms of the Affero General Public License;
'either version 1 of the License, or any later version.
'
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'Affero General Public License for more details.
'
'You should have received a copy of the Affero General Public License
'along with this program; if not, you can find it at http://www.affero.org/oagpl.html
'
'Argentum Online is based on Baronsoft's VB6 Online RPG
'You can contact the original creator of ORE at [email protected]
'for more information about ORE please visit http://www.baronsoft.com/
'
'
'You can contact me at:
'www.geocities.com/gmorgolock
'Calle 3 numero 983 piso 7 dto A
'La Plata - Pcia, Buenos Aires - Republica Argentina
'Codigo Postal 1900
'Pablo Ignacio Marquez
Option Explicit
Dim temp_verts(3) As TLVERTEX
Public OffsetCounterX As Single
Public OffsetCounterY As Single
Public WeatherFogX1 As Single
Public WeatherFogY1 As Single
Public WeatherFogX2 As Single
Public WeatherFogY2 As Single
Public WeatherFogCount As Byte
Public ParticleOffsetX As Long
Public ParticleOffsetY As Long
Public LastOffsetX As Integer
Public LastOffsetY As Integer
'Map sizes in tiles
Public Const XMaxMapSize As Byte = 100
Public Const XMinMapSize As Byte = 1
Public Const YMaxMapSize As Byte = 100
Public Const YMinMapSize As Byte = 1
Private Const GrhFogata As Long = 1521
Private Const TIME_MS_MOUSE As Byte = 10
Private MouseLastUpdate As Long
Private MouseTimeAcumulated As Long
''
'Sets a Grh animation to loop indefinitely.
Private Const INFINITE_LOOPS As Integer = -1
Public Const DegreeToRadian As Single = 0.01745329251994 'Pi / 180
'Encabezado bmp
Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
'Info del encabezado del bmp
Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
'Posicion en un mapa
Public Type Position
X As Long
Y As Long
End Type
'Posicion en el Mundo
Public Type WorldPos
Map As Integer
X As Integer
Y As Integer
End Type
'Contiene info acerca de donde se puede encontrar un grh tamano y animacion
Public Type GrhData
sX As Integer
sY As Integer
FileNum As Long
pixelWidth As Integer
pixelHeight As Integer
TileWidth As Single
TileHeight As Single
NumFrames As Integer
Frames() As Long
Speed As Single
End Type
'apunta a una estructura grhdata y mantiene la animacion
Public Type Grh
GrhIndex As Long
FrameCounter As Single
Speed As Single
Started As Byte
Loops As Integer
angle As Single
End Type
'Lista de cuerpos
Public Type BodyData
Walk(E_Heading.NORTH To E_Heading.WEST) As Grh
HeadOffset As Position
End Type
'Lista de cabezas
Public Type HeadData
Head(E_Heading.NORTH To E_Heading.WEST) As Grh
End Type
'Lista de las animaciones de las armas
Type WeaponAnimData
WeaponWalk(E_Heading.NORTH To E_Heading.WEST) As Grh
End Type
'Lista de las animaciones de los escudos
Type ShieldAnimData
ShieldWalk(E_Heading.NORTH To E_Heading.WEST) As Grh
End Type
'Apariencia del personaje
Public Type Char
Escribiendot As Byte
Escribiendo As Boolean
Movement As Boolean
active As Byte
Heading As E_Heading
Pos As Position
iHead As Integer
iBody As Integer
Body As BodyData
Head As HeadData
Casco As HeadData
Arma As WeaponAnimData
Escudo As ShieldAnimData
UsandoArma As Boolean
fX As Grh
FxIndex As Integer
Criminal As Byte
Atacable As Byte
Nombre As String
Clan As String
scrollDirectionX As Integer
scrollDirectionY As Integer
Moving As Byte
MoveOffsetX As Single
MoveOffsetY As Single
pie As Boolean
muerto As Boolean
invisible As Boolean
priv As Byte
attacking As Boolean
Aura(1 To 4) As Aura
ParticleIndex As Integer
Particle_Count As Long
Particle_Group() As Long
End Type
'Info de un objeto
Public Type obj
ObjIndex As Integer
Amount As Integer
End Type
'Tipo de las celdas del mapa
Public Type MapBlock
Graphic(1 To 4) As Grh
CharIndex As Integer
ObjGrh As Grh
Damage As DList
NPCIndex As Integer
OBJInfo As obj
TileExit As WorldPos
Blocked As Byte
Trigger As Integer
Engine_Light(0 To 3) As Long 'Standelf, Light Engine.
Particle_Group_Index As Long 'Particle Engine
fX As Grh
FxIndex As Integer
End Type
'Info de cada mapa
Public Type mapInfo
Music As String
name As String
Zona As String
StartPos As WorldPos
MapVersion As Integer
End Type
Public IniPath As String
'Bordes del mapa
Public MinXBorder As Byte
Public MaxXBorder As Byte
Public MinYBorder As Byte
Public MaxYBorder As Byte
'Status del user
Public CurMap As Integer 'Mapa actual
Public UserIndex As Integer
Public UserMoving As Byte
Public UserBody As Integer
Public UserHead As Integer
Public UserPos As Position 'Posicion
Public AddtoUserPos As Position 'Si se mueve
Public UserCharIndex As Integer
Public EngineRun As Boolean
Public FPS As Long
Public FramesPerSecCounter As Long
Public FPSLastCheck As Long
'Tamano del la vista en Tiles
Private WindowTileWidth As Integer
Private WindowTileHeight As Integer
Public HalfWindowTileWidth As Integer
Public HalfWindowTileHeight As Integer
'Tamano de los tiles en pixels
Public TilePixelHeight As Integer
Public TilePixelWidth As Integer
'Number of pixels the engine scrolls per frame. MUST divide evenly into pixels per tile
Public ScrollPixelsPerFrameX As Integer
Public ScrollPixelsPerFrameY As Integer
Dim timerElapsedTime As Single
Public timerTicksPerFrame As Single
Public NumChars As Integer
Public LastChar As Integer
Public NumWeaponAnims As Integer
Private MouseTileX As Byte
Private MouseTileY As Byte
'?????????Graficos???????????
Public GrhData() As GrhData 'Guarda todos los grh
Public BodyData() As BodyData
Public HeadData() As HeadData
Public FxData() As tIndiceFx
Public WeaponAnimData() As WeaponAnimData
Public ShieldAnimData() As ShieldAnimData
Public CascoAnimData() As HeadData
'?????????????????????????
'?????????Mapa????????????
Public MapData() As MapBlock ' Mapa
Public mapInfo As mapInfo ' Info acerca del mapa en uso
'?????????????????????????
Public Normal_RGBList(3) As Long
Public Color_Shadow(3) As Long
Public Color_Arbol(3) As Long
Public Color_Paralisis As Long
Public Color_Invisibilidad As Long
Public Color_Montura As Long
' Control de Lluvia
Public bRain As Boolean
Public bTecho As Boolean 'hay techo?
Public bFogata As Boolean
Public charlist(1 To 10000) As Char
' Used by GetTextExtentPoint32
Private Type Size
cx As Long
cy As Long
End Type
'[CODE 001]:MatuX
Public Enum PlayLoop
plNone = 0
plLluviain = 1
plLluviaout = 2
End Enum
'[END]'
'
' [END]
'?????????????????????????
'Very percise counter 64bit system counter
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Public Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Sub ConvertCPtoTP(ByVal viewPortX As Integer, ByVal viewPortY As Integer, ByRef TX As Byte, ByRef TY As Byte)
'******************************************
'Converts where the mouse is in the main window to a tile position. MUST be called eveytime the mouse moves.
'******************************************
TX = UserPos.X + viewPortX \ TilePixelWidth - WindowTileWidth \ 2
TY = UserPos.Y + viewPortY \ TilePixelHeight - WindowTileHeight \ 2
End Sub
Sub MakeChar(ByVal CharIndex As Integer, ByVal Body As Integer, ByVal Head As Integer, ByVal Heading As Byte, ByVal X As Integer, ByVal Y As Integer, ByVal Arma As Integer, ByVal Escudo As Integer, ByVal Casco As Integer)
On Error Resume Next
'Apuntamos al ultimo Char
If CharIndex > LastChar Then LastChar = CharIndex
With charlist(CharIndex)
'If the char wasn't allready active (we are rewritting it) don't increase char count
If .active = 0 Then _
NumChars = NumChars + 1
If Arma = 0 Then Arma = 2
If Escudo = 0 Then Escudo = 2
If Casco = 0 Then Casco = 2
.iHead = Head
.iBody = Body
.Head = HeadData(Head)
.Body = BodyData(Body)
.Arma = WeaponAnimData(Arma)
.Escudo = ShieldAnimData(Escudo)
.Casco = CascoAnimData(Casco)
.Heading = Heading
'Reset moving stats
.Moving = 0
.MoveOffsetX = 0
.MoveOffsetY = 0
'Update position
.Pos.X = X
.Pos.Y = Y
'attack state
.attacking = False
'Make active
.active = 1
End With
'Plot on map
MapData(X, Y).CharIndex = CharIndex
End Sub
Public Sub InitGrh(ByRef Grh As Grh, ByVal GrhIndex As Long, Optional ByVal Started As Byte = 2)
'*****************************************************************
'Sets up a grh. MUST be done before rendering
'*****************************************************************
Grh.GrhIndex = GrhIndex
If Started = 2 Then
If GrhData(Grh.GrhIndex).NumFrames > 1 Then
Grh.Started = 1
Else
Grh.Started = 0
End If
Else
'Make sure the graphic can be started
If GrhData(Grh.GrhIndex).NumFrames = 1 Then Started = 0
Grh.Started = Started
End If
If Grh.Started Then
Grh.Loops = INFINITE_LOOPS
Else
Grh.Loops = 0
End If
Grh.FrameCounter = 1
Grh.Speed = GrhData(Grh.GrhIndex).Speed
End Sub
Sub MoveCharbyHead(ByVal CharIndex As Integer, ByVal nHeading As E_Heading)
'*****************************************************************
'Starts the movement of a character in nHeading direction
'*****************************************************************
Dim addx As Integer
Dim addy As Integer
Dim X As Integer
Dim Y As Integer
Dim nX As Integer
Dim nY As Integer
With charlist(CharIndex)
X = .Pos.X
Y = .Pos.Y
'Figure out which way to move
Select Case nHeading
Case E_Heading.NORTH
addy = -1
Case E_Heading.EAST
addx = 1
Case E_Heading.SOUTH
addy = 1
Case E_Heading.WEST
addx = -1
End Select
nX = X + addx
nY = Y + addy
If nX <= 0 Then nX = 1
If nY <= 0 Then nY = 1
MapData(nX, nY).CharIndex = CharIndex
.Pos.X = nX
.Pos.Y = nY
If (X Or Y) = 0 Then Exit Sub
MapData(X, Y).CharIndex = 0
.MoveOffsetX = -1 * (TilePixelWidth * addx)
.MoveOffsetY = -1 * (TilePixelHeight * addy)
.Moving = 1
.Heading = nHeading
.scrollDirectionX = addx
.scrollDirectionY = addy
End With
If UserEstado = 0 Then Call DoPasosFx(CharIndex)
If CharIndex <> UserCharIndex Then
If Not EstaDentroDelArea(nX, nY) Then
Call Char_Erase(CharIndex)
End If
End If
End Sub
Public Sub DoFogataFx()
Dim Location As Position
If bFogata Then
bFogata = HayFogata(Location)
If Not bFogata Then
Call Audio.StopWave(FogataBufferIndex)
FogataBufferIndex = 0
End If
Else
bFogata = HayFogata(Location)
If bFogata And FogataBufferIndex = 0 Then FogataBufferIndex = Audio.PlayWave("fuego.wav", Location.X, Location.Y, LoopStyle.Enabled)
End If
End Sub
Public Function EstaPCarea(ByVal CharIndex As Integer) As Boolean
'***************************************************
'Author: Unknown
'Last Modification: 09/21/2010
' 09/21/2010: C4b3z0n - Changed from Private Funtion tu Public Function.
'***************************************************
With charlist(CharIndex).Pos
EstaPCarea = .X > UserPos.X - MinXBorder And _
.X < UserPos.X + MinXBorder And _
.Y > UserPos.Y - MinYBorder And _
.Y < UserPos.Y + MinYBorder
End With
End Function
Sub DoPasosFx(ByVal CharIndex As Integer)
If Not UserNavegando Then
With charlist(CharIndex)
If Not .muerto And EstaPCarea(CharIndex) And (.priv = 0 Or .priv > 5) Then
.pie = Not .pie
If .pie Then
Call Audio.PlayWave(SND_PASOS1, .Pos.X, .Pos.Y)
Else
Call Audio.PlayWave(SND_PASOS2, .Pos.X, .Pos.Y)
End If
End If
End With
Else
' TODO : Actually we would have to check if the CharIndex char is in the water or not....
Call Audio.PlayWave(SND_NAVEGANDO, charlist(CharIndex).Pos.X, charlist(CharIndex).Pos.Y)
End If
End Sub
Private Function HayFogata(ByRef Location As Position) As Boolean
Dim J As Long
Dim k As Long
For J = UserPos.X - 8 To UserPos.X + 8
For k = UserPos.Y - 6 To UserPos.Y + 6
If InMapBounds(J, k) Then
If MapData(J, k).ObjGrh.GrhIndex = GrhFogata Then
Location.X = J
Location.Y = k
HayFogata = True
Exit Function
End If
End If
Next k
Next J
End Function
Function NextOpenChar() As Integer
'*****************************************************************
'Finds next open char slot in CharList
'*****************************************************************
Dim LoopC As Long
Dim Dale As Boolean
LoopC = 1
Do While charlist(LoopC).active And Dale
LoopC = LoopC + 1
Dale = (LoopC <= UBound(charlist))
Loop
NextOpenChar = LoopC
End Function
Function InMapBounds(ByVal X As Integer, ByVal Y As Integer) As Boolean
'*****************************************************************
'Checks to see if a tile position is in the maps bounds
'*****************************************************************
If X < XMinMapSize Or X > XMaxMapSize Or Y < YMinMapSize Or Y > YMaxMapSize Then
Exit Function
End If
InMapBounds = True
End Function
Function GetBitmapDimensions(ByVal BmpFile As String, ByRef bmWidth As Long, ByRef bmHeight As Long)
'*****************************************************************
'Gets the dimensions of a bmp
'*****************************************************************
Dim BMHeader As BITMAPFILEHEADER
Dim BINFOHeader As BITMAPINFOHEADER
Open BmpFile For Binary Access Read As #1
Get #1, , BMHeader
Get #1, , BINFOHeader
Close #1
bmWidth = BINFOHeader.biWidth
bmHeight = BINFOHeader.biHeight
End Function
Public Sub DrawTransparentGrhtoHdc(ByVal dsthdc As Long, ByVal srchdc As Long, ByRef SourceRect As RECT, ByRef DestRect As RECT, ByVal TransparentColor As Long)
'**************************************************************
'Author: Torres Patricio (Pato)
'Last Modify Date: 27/07/2012 - ^[GS]^
'*************************************************************
Dim Color As Long
Dim X As Long
Dim Y As Long
For X = SourceRect.Left To SourceRect.Right
For Y = SourceRect.Top To SourceRect.Bottom
Color = GetPixel(srchdc, X, Y)
If Color <> TransparentColor Then
Call SetPixel(dsthdc, DestRect.Left + (X - SourceRect.Left), DestRect.Top + (Y - SourceRect.Top), Color)
End If
Next Y
Next X
End Sub
Public Sub DrawImageInPicture(ByRef PictureBox As PictureBox, ByRef Picture As StdPicture, ByVal x1 As Single, ByVal y1 As Single, Optional Width1, Optional Height1, Optional x2, Optional y2, Optional Width2, Optional Height2)
'**************************************************************
'Author: Torres Patricio (Pato)
'Last Modify Date: 12/28/2009
'Draw Picture in the PictureBox
'*************************************************************
Call PictureBox.PaintPicture(Picture, x1, y1, Width1, Height1, x2, y2, Width2, Height2)
End Sub
Sub RenderScreen(ByVal tilex As Integer, _
ByVal tiley As Integer, _
ByVal PixelOffsetX As Integer, _
ByVal PixelOffsetY As Integer)
'**************************************************************
'Author: Aaron Perkins
'Last Modify Date: 8/14/2007
'Last modified by: Juan Martin Sotuyo Dodero (Maraxus)
'Renders everything to the viewport
'**************************************************************
On Error GoTo RenderScreen_Err
Dim Y As Long 'Keeps track of where on map we are
Dim X As Long 'Keeps track of where on map we are
Dim screenminY As Integer 'Start Y pos on current screen
Dim screenmaxY As Integer 'End Y pos on current screen
Dim screenminX As Integer 'Start X pos on current screen
Dim screenmaxX As Integer 'End X pos on current screen
Dim minY As Integer 'Start Y pos on current map
Dim maxY As Integer 'End Y pos on current map
Dim minX As Integer 'Start X pos on current map
Dim maxX As Integer 'End X pos on current map
Dim ScreenX As Integer 'Keeps track of where to place tile on screen
Dim ScreenY As Integer 'Keeps track of where to place tile on screen
Dim minXOffset As Integer
Dim minYOffset As Integer
Dim PixelOffsetXTemp As Integer 'For centering grhs
Dim PixelOffsetYTemp As Integer 'For centering grhs
Dim ElapsedTime As Single
ElapsedTime = Engine_ElapsedTime()
'Figure out Ends and Starts of screen
screenminY = tiley - HalfWindowTileHeight
screenmaxY = tiley + HalfWindowTileHeight
screenminX = tilex - HalfWindowTileWidth
screenmaxX = tilex + HalfWindowTileWidth
minY = screenminY - TileBufferSize
maxY = screenmaxY + TileBufferSize * 2 ' WyroX: Parche para que no desaparezcan techos y arboles
minX = screenminX - TileBufferSize
maxX = screenmaxX + TileBufferSize
'Make sure mins and maxs are allways in map bounds
If minY < XMinMapSize Then
minYOffset = YMinMapSize - minY
minY = YMinMapSize
End If
If maxY > YMaxMapSize Then maxY = YMaxMapSize
If minX < XMinMapSize Then
minXOffset = XMinMapSize - minX
minX = XMinMapSize
End If
If maxX > XMaxMapSize Then maxX = XMaxMapSize
'If we can, we render around the view area to make it smoother
If screenminY > YMinMapSize Then
screenminY = screenminY - 1
Else
screenminY = 1
ScreenY = 1
End If
If screenmaxY < YMaxMapSize Then screenmaxY = screenmaxY + 1
If screenminX > XMinMapSize Then
screenminX = screenminX - 1
Else
screenminX = 1
ScreenX = 1
End If
If screenmaxX < XMaxMapSize Then screenmaxX = screenmaxX + 1
ParticleOffsetX = (Engine_PixelPosX(screenminX) - PixelOffsetX)
ParticleOffsetY = (Engine_PixelPosY(screenminY) - PixelOffsetY)
'Draw floor layer
For Y = screenminY To screenmaxY
For X = screenminX To screenmaxX
PixelOffsetXTemp = (ScreenX - 1) * TilePixelWidth + PixelOffsetX
PixelOffsetYTemp = (ScreenY - 1) * TilePixelHeight + PixelOffsetY
'Layer 1 **********************************
If MapData(X, Y).Graphic(1).GrhIndex <> 0 Then
Call Draw_Grh(MapData(X, Y).Graphic(1), PixelOffsetXTemp, PixelOffsetYTemp, 1, MapData(X, Y).Engine_Light(), 1)
End If
'******************************************
'Layer 2 **********************************
If MapData(X, Y).Graphic(2).GrhIndex <> 0 Then
Call Draw_Grh(MapData(X, Y).Graphic(2), PixelOffsetXTemp, PixelOffsetYTemp, 1, MapData(X, Y).Engine_Light(), 1)
End If
'******************************************
ScreenX = ScreenX + 1
Next
'Reset ScreenX to original value and increment ScreenY
ScreenX = ScreenX - X + screenminX
ScreenY = ScreenY + 1
Next
'<----- Layer Obj, Char, 3 ----->
ScreenY = minYOffset - TileBufferSize
For Y = minY To maxY
ScreenX = minXOffset - TileBufferSize
For X = minX To maxX
If Map_InBounds(X, Y) Then
PixelOffsetXTemp = ScreenX * TilePixelWidth + PixelOffsetX
PixelOffsetYTemp = ScreenY * TilePixelHeight + PixelOffsetY
With MapData(X, Y)
'Object Layer **********************************
If .ObjGrh.GrhIndex <> 0 Then
Call Draw_Grh(.ObjGrh, PixelOffsetXTemp, PixelOffsetYTemp, 1, .Engine_Light(), 1)
End If
'***********************************************
'Char layer********************************
If .CharIndex <> 0 Then
Call CharRender(.CharIndex, PixelOffsetXTemp, PixelOffsetYTemp)
End If
'*************************************************
'Layer 3 *****************************************
If .Graphic(3).GrhIndex <> 0 Then
If .Graphic(3).GrhIndex = 735 Or .Graphic(3).GrhIndex >= 6994 And .Graphic(3).GrhIndex <= 7002 Then
' Transparencia de Arboles
If Abs(UserPos.X - X) < 2 And (Abs(UserPos.Y - Y)) < 5 And (Abs(UserPos.Y) < Y) Then
Call Draw_Grh(.Graphic(3), PixelOffsetXTemp, PixelOffsetYTemp, 1, Color_Arbol(), 1)
Else 'NORMAL
Call Draw_Grh(.Graphic(3), PixelOffsetXTemp, PixelOffsetYTemp, 1, .Engine_Light(), 1)
End If
Else 'NORMAL
Call Draw_Grh(.Graphic(3), PixelOffsetXTemp, PixelOffsetYTemp, 1, .Engine_Light(), 1)
End If
End If
'************************************************
'Dibujamos los danos.
If .Damage.Activated Then
Call mDx8_Dibujado.Damage_Draw(X, Y, PixelOffsetXTemp, PixelOffsetYTemp - 20)
End If
'Particulas
If .Particle_Group_Index Then
'Solo las renderizamos si estan cerca del area de vision.
If EstaDentroDelArea(X, Y) Then
Call mDx8_Particulas.Particle_Group_Render(.Particle_Group_Index, PixelOffsetXTemp + 16, PixelOffsetYTemp + 16)
End If
End If
If Not .FxIndex = 0 Then
Call Draw_Grh(.fX, PixelOffsetXTemp + FxData(MapData(X, Y).FxIndex).OffsetX, PixelOffsetYTemp + FxData(.FxIndex).OffsetY, 1, .Engine_Light(), 1, True)
If .fX.Started = 0 Then .FxIndex = 0
End If
End With
End If
ScreenX = ScreenX + 1
Next X
ScreenY = ScreenY + 1
Next Y
'<----- Layer 4 ----->
ScreenY = minYOffset - TileBufferSize
For Y = minY To maxY
ScreenX = minXOffset - TileBufferSize
For X = minX To maxX
PixelOffsetXTemp = ScreenX * TilePixelWidth + PixelOffsetX
PixelOffsetYTemp = ScreenY * TilePixelHeight + PixelOffsetY
'Layer 4
If MapData(X, Y).Graphic(4).GrhIndex Then
If bTecho Then
Call Draw_Grh(MapData(X, Y).Graphic(4), PixelOffsetXTemp, PixelOffsetYTemp, 1, temp_rgb(), 1)
Else
If ColorTecho = 250 Then
Call Draw_Grh(MapData(X, Y).Graphic(4), PixelOffsetXTemp, PixelOffsetYTemp, 1, MapData(X, Y).Engine_Light(), 1)
Else
Call Draw_Grh(MapData(X, Y).Graphic(4), PixelOffsetXTemp, PixelOffsetYTemp, 1, temp_rgb(), 1)
End If
End If
End If
ScreenX = ScreenX + 1
Next X
ScreenY = ScreenY + 1
Next Y
If ClientSetup.ParticleEngine Then
'Weather Update & Render - Aca se renderiza la lluvia, nieve, etc.
Call mDx8_Particulas.Engine_Weather_Update
End If
If ClientSetup.ProyectileEngine Then
If LastProjectile > 0 Then
Dim J As Long ' Long siempre en los bucles es mucho mas rapido
For J = 1 To LastProjectile
If ProjectileList(J).Grh.GrhIndex Then
Dim angle As Single
'Update the position
angle = DegreeToRadian * Engine_GetAngle(ProjectileList(J).X, ProjectileList(J).Y, ProjectileList(J).TX, ProjectileList(J).TY)
ProjectileList(J).X = ProjectileList(J).X + (Sin(angle) * ElapsedTime * 0.8)
ProjectileList(J).Y = ProjectileList(J).Y - (Cos(angle) * ElapsedTime * 0.8)
'Update the rotation
If ProjectileList(J).RotateSpeed > 0 Then
ProjectileList(J).Rotate = ProjectileList(J).Rotate + (ProjectileList(J).RotateSpeed * ElapsedTime * 0.01)
Do While ProjectileList(J).Rotate > 360
ProjectileList(J).Rotate = ProjectileList(J).Rotate - 360
Loop
End If
'Draw if within range
X = ((-minX - 1) * 32) + ProjectileList(J).X + PixelOffsetX + ((10 - TileBufferSize) * 32) - 288 + ProjectileList(J).OffsetX
Y = ((-minY - 1) * 32) + ProjectileList(J).Y + PixelOffsetY + ((10 - TileBufferSize) * 32) - 288 + ProjectileList(J).OffsetY
If Y >= -32 Then
If Y <= (ScreenHeight + 32) Then
If X >= -32 Then
If X <= (ScreenWidth + 32) Then
If ProjectileList(J).Rotate = 0 Then
Call Draw_Grh(ProjectileList(J).Grh, X, Y, 0, MapData(50, 50).Engine_Light(), 0, True, ProjectileList(J).Rotate + 128)
Else
Call Draw_Grh(ProjectileList(J).Grh, X, Y, 0, MapData(50, 50).Engine_Light(), 0, True, ProjectileList(J).Rotate + 128)
End If
End If
End If
End If
End If
End If
Next J
'Check if it is close enough to the target to remove
For J = 1 To LastProjectile
If ProjectileList(J).Grh.GrhIndex Then
If Abs(ProjectileList(J).X - ProjectileList(J).TX) < 20 Then
If Abs(ProjectileList(J).Y - ProjectileList(J).TY) < 20 Then
Call Engine_Projectile_Erase(J)
End If
End If
End If
Next J
End If
End If
If colorRender <> 240 Then
Call DrawText(frmMain.MainViewPic.Width / 2, 50, renderText, render_msg(0), True, 2)
End If
' Set Offsets
LastOffsetX = ParticleOffsetX
LastOffsetY = ParticleOffsetY
If ClientSetup.PartyMembers Then Call Draw_Party_Members
Call RenderCount
RenderScreen_Err:
If Err.number Then
Call LogError(Err.number, Err.Description, "Mod_TileEngine.RenderScreen")
End If
End Sub
Public Function RenderSounds()
'**************************************************************
'Author: Juan Martin Sotuyo Dodero
'Last Modify Date: 3/30/2008
'Actualiza todos los sonidos del mapa.
'**************************************************************
Dim Location As Position
If bRain And bLluvia(UserMap) Then
If bTecho Then
If frmMain.IsPlaying <> PlayLoop.plLluviain Then
If RainBufferIndex Then
Call Audio.StopWave(RainBufferIndex)
End If
RainBufferIndex = Audio.PlayWave("lluviain.wav", 0, 0, LoopStyle.Enabled)
frmMain.IsPlaying = PlayLoop.plLluviain
End If
Else
If frmMain.IsPlaying <> PlayLoop.plLluviaout Then
If RainBufferIndex Then
Call Audio.StopWave(RainBufferIndex)
End If
RainBufferIndex = Audio.PlayWave("lluviaout.wav", 0, 0, LoopStyle.Enabled)
frmMain.IsPlaying = PlayLoop.plLluviaout
End If
End If
End If
If bFogata Then
bFogata = Map_CheckBonfire(Location)
If Not bFogata Then
Call Audio.StopWave(FogataBufferIndex)
FogataBufferIndex = 0
End If
Else
bFogata = Map_CheckBonfire(Location)
If bFogata And FogataBufferIndex = 0 Then
FogataBufferIndex = Audio.PlayWave("fuego.wav", Location.X, Location.Y, LoopStyle.Enabled)
End If
End If
End Function