-
Notifications
You must be signed in to change notification settings - Fork 1
/
AWM-Utils.lua
1245 lines (831 loc) · 36 KB
/
AWM-Utils.lua
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
--[[===========================================================================
AccurateWorldMap Utility Functions
===============================================================================
Utility functions that help the main addon work.
---------------------------------------------------------------------------]]--
-------------------------------------------------------------------------------
-- Get base addon object, callbacks, and dependencies
-------------------------------------------------------------------------------
AWM = AWM or {}
local LocalCallbackManager = ZO_CallbackObject:Subclass()
local GPS = LibGPS3
local LZ = LibZone
local LMP = LibMapPing2
-------------------------------------------------------------------------------
-- Get addon info from addon manifest
-------------------------------------------------------------------------------
function getAddonInfo(addonName)
local AddOnManager = GetAddOnManager()
local numAddons = AddOnManager:GetNumAddOns()
for i = 1, numAddons do -- loop through all currently installed addon
-- get addon info from manifest
local name, title, author, description = AddOnManager:GetAddOnInfo(i)
if (name == addonName) then -- we've found our addon!
local addonTable = {}
-- set addon data to metatable
addonTable.title = title
addonTable.name = name
addonTable.author = author
addonTable.description = description
addonTable.options = {}
return addonTable
end
end
end
-------------------------------------------------------------------------------
-- Merge multiple tables into one
-------------------------------------------------------------------------------
local mergedTable = {}
function join(extra, newWorldspace)
if (newWorldspace) then
mergedTable = {}
end
table.insert(mergedTable, extra)
return mergedTable
end
-------------------------------------------------------------------------------
-- Get if can reposition icons function
-------------------------------------------------------------------------------
function getIfCanRepositionIcons()
return (GPS["GetMapMeasurementByMapId"] ~= nil)
end
-------------------------------------------------------------------------------
-- Is icon repositioning enabled function
-------------------------------------------------------------------------------
function isIconRepositioningEnabled()
return (GPS["GetMapMeasurementByMapId"] ~= nil and AWM.options.iconRepositioning)
end
-------------------------------------------------------------------------------
-- Is GeoParent enabled
-------------------------------------------------------------------------------
function isGeoParentEnabled()
return (LZ ~= nil and LZ["GetGeographicalParentMapId"] ~= nil)
end
-------------------------------------------------------------------------------
-- Print text to chat
-------------------------------------------------------------------------------
function print(message, isForced, ...)
if (AWM.options.isDebug or isForced) then
df("[%s] %s", AWM.name, tostring(message):format(...))
end
end
-------------------------------------------------------------------------------
-- Check if mouse is inside of the map window
-------------------------------------------------------------------------------
function isMouseWithinMapWindow()
local mouseOverControl = WINDOW_MANAGER:GetMouseOverControl()
return (not ZO_WorldMapContainer:IsHidden() and (mouseOverControl == ZO_WorldMapContainer or mouseOverControl:GetParent() == ZO_WorldMapContainer))
end
-------------------------------------------------------------------------------
-- Check if world map window is being shown
-------------------------------------------------------------------------------
local canFireCallback = false
function isWorldMapShown()
local isMapShown = ( ((not ZO_WorldMapContainer:IsHidden() and ZO_WorldMapContainer:GetAlpha() == 1) or ZO_WorldMap_IsWorldMapShowing()))
if (isMapShown and canFireCallback) then
zo_callLater(function()
CALLBACK_MANAGER:FireCallbacks("OnWorldMapShown", nil)
end, 300 )
canFireCallback = false
end
if (not isMapShown and not canFireCallback) then
canFireCallback = true
end
return isMapShown
end
-------------------------------------------------------------------------------
-- Check if world map window is active
-------------------------------------------------------------------------------
function isWorldMapActive()
return ( isWorldMapShown() and isMouseWithinMapWindow() )
end
-------------------------------------------------------------------------------
-- Check if champion point window is being shown
-------------------------------------------------------------------------------
function isChampionPointWindowShown()
return ( not ZO_ChampionPerksCanvas:IsHidden() and ZO_ChampionPerksCanvas:GetAlpha() == 1 )
end
-------------------------------------------------------------------------------
-- Get world map offsets from the sides of the screen
-------------------------------------------------------------------------------
function getWorldMapOffsets()
return math.floor(ZO_WorldMapContainer:GetLeft()), math.floor(ZO_WorldMapContainer:GetTop())
end
-------------------------------------------------------------------------------
-- Determine whether a variable X is numeric or not
-------------------------------------------------------------------------------
function isNumeric(x)
if tonumber(x) ~= nil then
return true
end
return false
end
-------------------------------------------------------------------------------
-- Check if table has a certain value
-------------------------------------------------------------------------------
function hasValue (tab, val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
-------------------------------------------------------------------------------
-- Simpler function to check if user is in gamepad mode
-------------------------------------------------------------------------------
local lastGamepadPreference
function isInGamepadMode()
if (lastGamepadPreference ~= IsInGamepadPreferredMode()) then
lastGamepadPreference = IsInGamepadPreferredMode()
AWM.canRedrawMap = true
end
return (IsInGamepadPreferredMode() and not ZO_WorldMapCenterPoint:IsHidden())
end
-------------------------------------------------------------------------------
-- Get current cursor's position in screenspace
-------------------------------------------------------------------------------
function getMouseCoordinates()
if (isInGamepadMode()) then
return ZO_WorldMapScroll:GetCenter()
else
return GetUIMousePosition()
end
end
-------------------------------------------------------------------------------
-- Return a number to set significant figure
-------------------------------------------------------------------------------
function sigFig(num, figures)
local x = figures - math.ceil(math.log10(math.abs(num)))
return(math.floor(num*10^x+0.5)/10^x)
end
-------------------------------------------------------------------------------
-- Get normalised cursor coordinates relative to worldmap
-------------------------------------------------------------------------------
function getNormalisedMouseCoordinates()
local mouseX, mouseY = getMouseCoordinates()
local currentOffsetX = ZO_WorldMapContainer:GetLeft()
local currentOffsetY = ZO_WorldMapContainer:GetTop()
local parentOffsetX = ZO_WorldMap:GetLeft()
local parentOffsetY = ZO_WorldMap:GetTop()
local mapWidth, mapHeight = ZO_WorldMapContainer:GetDimensions()
local parentWidth, parentHeight = ZO_WorldMap:GetDimensions()
local normalisedMouseX = math.floor((((mouseX - currentOffsetX) / mapWidth) * 1000) + 0.5)/1000
local normalisedMouseY = math.floor((((mouseY - currentOffsetY) / mapHeight) * 1000) + 0.5)/1000
return normalisedMouseX, normalisedMouseY
end
-------------------------------------------------------------------------------
-- Get the mapID of the current zone
-------------------------------------------------------------------------------
function getCurrentMapID()
local zoneID = GetCurrentMapId()
if (zoneID == nil) then
zoneID = 0
end
return zoneID
end
-------------------------------------------------------------------------------
-- Get zoneInfo object by ID
-------------------------------------------------------------------------------
function getZoneInfoByID(zoneID, optionalIsDuplicate)
if (mapData ~= nil) then
for mapID, mapInfo in pairs(mapData) do
if (mapInfo.zoneData ~= nil) then
local zoneInfo = mapInfo.zoneData
for zoneIndex, zoneInfo in pairs(zoneInfo) do
if (optionalIsDuplicate ~= nil and optionalIsDuplicate) then
if (zoneInfo.zoneID == zoneID and zoneInfo.isDuplicate ~= nil) then
return zoneInfo
end
else
if (zoneInfo.zoneID == zoneID and zoneInfo.isDuplicate == nil) then
return zoneInfo
end
end
end
end
end
end
end
-------------------------------------------------------------------------------
-- Get map name from ID
-------------------------------------------------------------------------------
function getZoneNameFromID(zoneID, getDuplicateName)
local zoneInfo
if (getDuplicateName) then
zoneInfo = getZoneInfoByID(zoneID, true)
else
zoneInfo = getZoneInfoByID(zoneID)
end
-- does this map have a custom name / are custom names enabled?
if ((zoneInfo ~= nil and zoneInfo.overrideLoreRenames ~= nil) or AWM.options.loreRenames) then
if (zoneInfo ~= nil) then
return zoneInfo.zoneName
else
return GetMapNameById(zoneID)
end
else
-- else return vanilla name
return GetMapNameById(zoneID)
end
end
-------------------------------------------------------------------------------
-- Get map id from zone hitbox polygon name
-------------------------------------------------------------------------------
function getMapIDFromPolygonName(polygonName)
return tonumber(string.match (polygonName, "%d+"))
end
-------------------------------------------------------------------------------
-- Is developer function
-------------------------------------------------------------------------------
function isDeveloper()
return GetDisplayName() == "@Thal-J"
end
-------------------------------------------------------------------------------
-- Strip unneeded characters away from zone names
-------------------------------------------------------------------------------
function processZoneName(name)
-- example: transform "Stros M'Kai" to "strosmkai"
name = name:gsub("'", "")
name = name:gsub(" ", "")
name = name:gsub("-", "")
name = name:lower()
return name
end
-------------------------------------------------------------------------------
-- Get blob file directory from map name
-------------------------------------------------------------------------------
function getFileDirectoryFromMapName(providedZoneName)
local providedZoneName = providedZoneName
providedZoneName = processZoneName(providedZoneName)
local blobFileDirectory = ("AccurateWorldMap/blobs/blob-"..providedZoneName..".dds")
return blobFileDirectory
end
-------------------------------------------------------------------------------
-- Get debug blob file directory from map name
-------------------------------------------------------------------------------
function getDebugFileDirectoryFromMapName(providedZoneName)
local providedZoneName = providedZoneName
providedZoneName = processZoneName(providedZoneName)
local blobFileDirectory = ("AccurateWorldMap/blobs/blob-"..providedZoneName.."-debug.dds")
return blobFileDirectory
end
-------------------------------------------------------------------------------
-- Hide all zone blobs (hitboxes) on the map
-------------------------------------------------------------------------------
function hideAllZoneBlobs()
for i = 1, ZO_WorldMapContainer:GetNumChildren() do
local childControl = ZO_WorldMapContainer:GetChild(i)
local controlName = childControl:GetName()
if (string.match(controlName, "blobHitbox-")) then
childControl:SetHidden(true)
childControl:SetMouseEnabled(false)
end
end
end
-------------------------------------------------------------------------------
-- Navigate map to provided map via map data object or ID
-------------------------------------------------------------------------------
local GPS = LibGPS3
function navigateToMap(mapInfo)
local mapID
-- mapInfo can be either an int or a zoneData object, need to determine which it is
-- if it's a zoneData object, then it will have an id
if (mapInfo ~= nil) then
if (isNumeric(mapInfo)) then -- it is an int
mapID = tonumber(mapInfo)
else -- it is not an int
if (mapInfo.zoneID ~= nil) then -- it is a zoneData object
mapID = mapInfo.zoneID
end
end
SetMapToMapId(mapID)
GPS:SetPlayerChoseCurrentMap()
hideAllZoneBlobs()
CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
-- force map to zoom out
local mapPanAndZoom = ZO_WorldMap_GetPanAndZoom()
mapPanAndZoom:SetCurrentNormalizedZoom(0)
end
end
-------------------------------------------------------------------------------
-- Get current zone info table if it exists
-------------------------------------------------------------------------------
function getCurrentZoneInfo()
return getZoneInfoByID(getCurrentMapID())
end
-------------------------------------------------------------------------------
-- Update location info on the side bar
-------------------------------------------------------------------------------
function updateLocationsInfo()
-- recalculate normalised info, as will be based on
-- vanilla values by the time this is done
GPS:ClearMapMeasurements()
GPS:CalculateMapMeasurement()
if (VOTANS_IMPROVED_LOCATIONS) then
VOTANS_IMPROVED_LOCATIONS.mapData = nil
WORLD_MAP_LOCATIONS:BuildLocationList()
else
local locations = WORLD_MAP_LOCATIONS
locations.data.mapData = nil
ZO_ScrollList_Clear(locations.list)
local scrollData = ZO_ScrollList_GetDataList(locations.list)
local mapData = locations.data:GetLocationList()
for i,entry in ipairs(mapData) do
scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(1, entry)
end
ZO_ScrollList_Commit(locations.list)
end
end
-------------------------------------------------------------------------------
-- Get whether the current map is exclusive or not
-------------------------------------------------------------------------------
function getIsCurrentMapExclusive()
local currentZoneInfo = getCurrentZoneInfo()
return (currentZoneInfo ~= nil and (currentZoneInfo.isExclusive ~= nil and currentZoneInfo.isExclusive))
end
-------------------------------------------------------------------------------
-- Get whether the provided map has custom zone data or not
-------------------------------------------------------------------------------
function doesMapHaveCustomZoneData(mapID)
return ((mapData[mapID] ~= nil and mapData[mapID].zoneData ~= nil) or getZoneInfoByID(mapID) ~= nil)
end
-------------------------------------------------------------------------------
-- Get whether the current map has custom zone data or not
-------------------------------------------------------------------------------
function doesCurrentMapHaveCustomZoneData()
return doesMapHaveCustomZoneData(getCurrentMapID())
end
-------------------------------------------------------------------------------
-- Creates zone hitbox on the map given some coordinates
-------------------------------------------------------------------------------
function createZoneHitbox(polygonData, zoneInfo)
local polygonID
local isDebug
if (zoneInfo ~= nil) then
if (zoneInfo.isDuplicate ~= nil and zoneInfo.isDuplicate) then
polygonID = "blobHitbox-"..zoneInfo.zoneID.."-"..zoneInfo.zoneName.."duplicate"
else
polygonID = "blobHitbox-"..zoneInfo.zoneID.."-"..zoneInfo.zoneName
end
else
isDebug = true
polygonID = "debugPolygon"
end
-- check if polygon by this name exists
if (WINDOW_MANAGER:GetControlByName(polygonID) == nil) then
local polygon = ZO_WorldMapContainer:CreateControl(polygonID, CT_POLYGON)
polygon:SetAnchorFill(ZO_WorldMapContainer)
local polygonCode = ""
if (isDebug) then
AWM_EditTextWindow:SetHidden(false)
end
for key, data in pairs(polygonData) do
if (isDebug) then
d(AWM.polygonData)
polygonCode = polygonCode .. ("{ xN = "..string.format("%.03f", data.xN)..", yN = "..string.format("%.03f", data.yN).." },\n")
end
polygon:AddPoint(data.xN, data.yN)
end
if (isDebug) then
AWM_EditTextTextBox:SetText(polygonCode)
end
if (isDebug) then
polygon:SetCenterColor(0, 1, 0, 0.5)
else
polygon:SetCenterColor(0, 0, 0, 0)
end
polygon:SetMouseEnabled(true)
polygon:SetHandler("OnMouseDown", function(control, button, ctrl, alt, shift, command)
if (waitForRelease == false) then
currentMapOffsetX, currentMapOffsetY = getWorldMapOffsets()
waitForRelease = true
end
AWM.currentlySelectedPolygon = polygon
ZO_WorldMap_MouseDown(button, ctrl, alt, shift)
end)
polygon:SetHandler("OnMouseUp", function(control, button, upInside, ctrl, alt, shift, command)
ZO_WorldMap_MouseUp(control, button, upInside)
if (AWM.blobZoneInfo ~= nil and upInside and button == MOUSE_BUTTON_INDEX_LEFT) then
if (waitForRelease) then
local mapOffsetX, mapOffsetY = getWorldMapOffsets()
local deltaX, deltaY
if (mapOffsetX >= currentMapOffsetX) then
deltaX = mapOffsetX - currentMapOffsetX
else
deltaX = currentMapOffsetX - mapOffsetX
end
if (mapOffsetY >= currentMapOffsetY) then
deltaY = mapOffsetY - currentMapOffsetY
else
deltaY = currentMapOffsetY - mapOffsetY
end
print(tostring(deltaX))
if ( (deltaX <= 10 and deltaX <= 10) and not (shift or ctrl or alt or command) ) then
navigateToMap(AWM.blobZoneInfo)
end
end
end
waitForRelease = false
end)
polygon:SetHandler("OnMouseEnter", function()
if (not isInGamepadMode()) then
updateCurrentPolygon(polygon)
end
end)
else
-- it already exists, we just need to show it again
WINDOW_MANAGER:GetControlByName(polygonID):SetHidden(false)
WINDOW_MANAGER:GetControlByName(polygonID):SetMouseEnabled(true)
end
end
-------------------------------------------------------------------------------
-- Compile map textures
-------------------------------------------------------------------------------
function compileMapTextures()
AWM_TextureControl:SetAlpha(0)
local hasError = false
-- iterate through all of mapData
for mapID, zoneData in pairs(mapData) do
if (zoneData.zoneData ~= nil) then
--print("got to here!")
local zoneInfo = zoneData.zoneData
for zoneIndex, zoneInfo in pairs(zoneInfo) do
--print("checking zone info!")
if (zoneInfo.zoneName ~= nil) then
local hasDebugTexture = (zoneInfo.debugXN ~= nil or zoneInfo.debugBlobTexture ~= nil)
--print("there is a zone name!")
if ( (zoneInfo.blobTexture == nil or zoneInfo.debugBlobTexture == nil) or (zoneInfo.nBlobTextureWidth == nil or zoneInfo.nDebugBlobTextureWidth == nil) ) then
local mapResolution = 8704
-- load in textures
local textureDirectory
if (zoneInfo.blobTexture ~= nil) then
textureDirectory = zoneInfo.blobTexture
else
textureDirectory = getFileDirectoryFromMapName(zoneInfo.zoneName)
end
-- load texture into control from name
AWM_TextureControl:SetTexture(textureDirectory)
-- check if texture exists before doing stuff
if (AWM_TextureControl:IsTextureLoaded()) then
-- get the dimensions
local textureHeight, textureWidth = AWM_TextureControl:GetTextureFileDimensions()
-- save texture name and dimensions
mapData[mapID].zoneData[zoneIndex].blobTexture = textureDirectory
mapData[mapID].zoneData[zoneIndex].nBlobTextureHeight = textureHeight * 2 / mapResolution
mapData[mapID].zoneData[zoneIndex].nBlobTextureWidth = textureWidth * 2 / mapResolution
else
print("The following texture failed to load: "..textureDirectory)
hasError = true
end
if (hasDebugTexture) then
-- load in textures
local debugTextureDirectory
if (zoneInfo.debugBlobTexture ~= nil) then
debugTextureDirectory = zoneInfo.debugBlobTexture
else
debugTextureDirectory = getDebugFileDirectoryFromMapName(zoneInfo.zoneName)
end
-- load texture into control from name
AWM_TextureControl:SetTexture(debugTextureDirectory)
-- check if texture exists before doing stuff
if (AWM_TextureControl:IsTextureLoaded()) then
-- get the dimensions
local debugTextureHeight, debugTextureWidth = AWM_TextureControl:GetTextureFileDimensions()
-- save texture name and dimensions
mapData[mapID].zoneData[zoneIndex].debugBlobTexture = debugTextureDirectory
mapData[mapID].zoneData[zoneIndex].nDebugBlobTextureWidth = debugTextureWidth * 2/ mapResolution
mapData[mapID].zoneData[zoneIndex].nDebugBlobTextureHeight = debugTextureHeight * 2 / mapResolution
else
print("The following debug texture failed to load: "..debugTextureDirectory)
hasError = true
end
end
end
end
end
end
end
-- if texture compilation has had no issues, then go ahead
if (hasError == false and not AWM.areTexturesCompiled) then
print("Finished loading.", true)
AWM.areTexturesCompiled = true
-- recalculate normalised info, as will be based on
-- vanilla values by the time this is done
GPS:ClearMapMeasurements()
GPS:CalculateMapMeasurement()
-- force reload map in case user has opened it
navigateToMap(getCurrentMapID())
end
end
function parseMapData(mapID)
if (mapID ~= nil) then
print("Current map id: ".. mapID)
-- Check if the current zone/map has any custom map data set to it
if (mapData[mapID] ~= nil) then
--print("This map has custom data!")
if (mapData[mapID].isExclusive ~= nil) then
isExclusive = mapData[mapID].isExclusive
else
isExclusive = false
end
if (mapData[mapID].zoneData ~= nil) then
--print("This map has custom zone data!")
local zoneData = mapData[mapID].zoneData
for zoneAttribute, zoneInfo in pairs(zoneData) do
if (zoneInfo.zoneName ~= nil) then
print(zoneInfo.zoneName)
print(tostring(zoneAttribute))
print(tostring(zoneInfo))
if (zoneInfo.xN ~= nil and zoneInfo.yN ~= nil) then
if (zoneInfo.blobTexture ~= nil and zoneInfo.nBlobTextureHeight ~= nil and zoneInfo.nBlobTextureHeight ~= nil ) then
if (zoneInfo.zonePolygonData ~= nil) then
createZoneHitbox(zoneInfo.zonePolygonData, zoneInfo)
-- add polygons, make zone data
else
print("Warning: Custom Zone "..zoneInfo.zoneName.." ".."is missing its hitbox polygon!")
end
else
print("Warning: Custom Zone "..zoneInfo.zoneName.." ".."is missing its texture details!")
-- rerun texture details for this zone
-- getTextureDetails() --getTextureDetails(nil)
end
else
print("Warning: Custom Zone "..zoneInfo.zoneName.." ".." has invalid zone coordinates!")
end
else
print("Warning: Custom Zone ID #"..tostring(zoneInfo.zoneID).." has no name!")
end
end
end
else
isExclusive = false
end
end
print("isExclusive: "..tostring(isExclusive))
end
-------------------------------------------------------------------------------
-- Get zoneInfo object by name function
-------------------------------------------------------------------------------
function getZoneInfoByName(name)
if (mapData ~= nil) then
for mapID, mapInfo in pairs(mapData) do
if (mapInfo.zoneName ~= nil) then
local zoneInfo = mapInfo.zoneData
for zoneIndex, zoneInfo in pairs(zoneInfo) do
if (zoneInfo.zoneName == name) then
return zoneInfo
end
end
end
end
end
end
-------------------------------------------------------------------------------
-- Is Tamriel Map function
-------------------------------------------------------------------------------
function isMapTamriel(mapID)
if (mapID == nil) then
mapID = getCurrentMapID()
end
local zoneInfo = getZoneInfoByID(mapID)
return (zoneInfo ~= nil and zoneInfo.zoneName == "Tamriel")
end
-------------------------------------------------------------------------------
-- Is Map Artaeum function
-------------------------------------------------------------------------------
function isMapArtaeum(mapID)
local zoneInfo = getZoneInfoByID(mapID)
return (zoneInfo ~= nil and zoneInfo.zoneName == "Artaeum")
end
-------------------------------------------------------------------------------
-- Is Map Aurbis function
-------------------------------------------------------------------------------
function isMapAurbis(mapID)
local zoneInfo = getZoneInfoByID(mapID)
return (zoneInfo ~= nil and zoneInfo.zoneName == "The Aurbis")
end
-------------------------------------------------------------------------------
-- Get Aurbis map ID function
-------------------------------------------------------------------------------
function getAurbisMapID()
return 439
end
-------------------------------------------------------------------------------
-- Get Tamriel map ID function
-------------------------------------------------------------------------------
function getTamrielMapID()
return 27
end
-------------------------------------------------------------------------------
-- Get parent mapID function
-------------------------------------------------------------------------------
function getParentMapID(mapID)
if (mapID == nil) then
mapID = getCurrentMapID()
end
local parentMapID
if (isGeoParentEnabled() and AWM.isLoaded) then
parentMapID = LZ:GetGeographicalParentMapId(mapID)
else
local _, _, _, zoneIndex, _ = GetMapInfoById(mapID)
parentMapID = GetParentZoneId(GetZoneId(zoneIndex))
end
if (parentMapID ~= nil) then
-- if parentMapId is zero, then return itself
if (parentMapID == 0) then
return mapID
end
-- if we have overwritten this map's parent ID, then return itself
if (mapData[mapID] ~= nil and mapData[mapID].parentMapID ~= nil) then
return mapID
end
end
return parentMapID
end
-------------------------------------------------------------------------------
-- Check if map is inside the Aurbis map
-------------------------------------------------------------------------------
function isMapInAurbis(mapID)
if (mapID == nil) then
mapID = getCurrentMapID()
end
local parentMapID = getParentMapID(mapID)
local isInAurbis = false
if (isMapTamriel(parentMapID) or isMapAurbis(parentMapID)) then
return isInAurbis
end
-- does this map have custom defined data
if (doesMapHaveCustomZoneData(parentMapID)) then
local aurbisMapData = mapData[getAurbisMapID()].zoneData
-- then check if it's in the aurbis
for zoneIndex, data in pairs(aurbisMapData) do
local zoneData = mapData[getAurbisMapID()].zoneData[zoneIndex]
if (zoneData.zoneID == parentMapID) then
isInAurbis = true
end
end
end
return isInAurbis
end