Back to Home

ESO Lua File v101041

publicallingames/character/character_utils.lua

[◄ back to folders ]
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
local EQUIP_SLOT_TO_EQUIP_TYPES =
{
    [EQUIP_SLOT_MAIN_HAND]  = { EQUIP_TYPE_MAIN_HAND, EQUIP_TYPE_ONE_HAND, EQUIP_TYPE_TWO_HAND },
    [EQUIP_SLOT_OFF_HAND]   = { EQUIP_TYPE_OFF_HAND, EQUIP_TYPE_ONE_HAND },
    [EQUIP_SLOT_POISON]     = { EQUIP_TYPE_POISON },
    [EQUIP_SLOT_BACKUP_MAIN]= { EQUIP_TYPE_MAIN_HAND, EQUIP_TYPE_ONE_HAND, EQUIP_TYPE_TWO_HAND },
    [EQUIP_SLOT_BACKUP_OFF] = { EQUIP_TYPE_OFF_HAND, EQUIP_TYPE_ONE_HAND },
    [EQUIP_SLOT_BACKUP_POISON] = { EQUIP_TYPE_POISON },
    [EQUIP_SLOT_HEAD]       = { EQUIP_TYPE_HEAD },
    [EQUIP_SLOT_CHEST]      = { EQUIP_TYPE_CHEST },
    [EQUIP_SLOT_SHOULDERS]  = { EQUIP_TYPE_SHOULDERS},
    [EQUIP_SLOT_WAIST]      = { EQUIP_TYPE_WAIST },
    [EQUIP_SLOT_HAND]       = { EQUIP_TYPE_HAND },
    [EQUIP_SLOT_LEGS]       = { EQUIP_TYPE_LEGS },
    [EQUIP_SLOT_FEET]       = { EQUIP_TYPE_FEET },
    [EQUIP_SLOT_COSTUME]    = { EQUIP_TYPE_COSTUME },
    [EQUIP_SLOT_NECK]       = { EQUIP_TYPE_NECK },
    [EQUIP_SLOT_RING1]      = { EQUIP_TYPE_RING },
    [EQUIP_SLOT_RING2]      = { EQUIP_TYPE_RING },
}
    return EQUIP_SLOT_TO_EQUIP_TYPES
end
    return pairs(EQUIP_SLOT_TO_EQUIP_TYPES)
end
function ZO_Character_DoesEquipSlotUseEquipType(equipSlot, equipType)
    local equipTypes = EQUIP_SLOT_TO_EQUIP_TYPES[equipSlot]
    if equipTypes then
        for i, usedEquipType in ipairs(equipTypes) do
            if usedEquipType == equipType then
                return true
            end
        end
    end
    return false
end
function ZO_Character_GetEquipSlotForEquipType(equipType, optionalWornBagId)
    local equipSlot = nil
    optionalWornBagId = optionalWornBagId or BAG_WORN
    for _, testSlot in ZO_Character_EnumerateOrderedEquipSlots(optionalWornBagId) do
        local locked = IsLockedWeaponSlot(testSlot)
        local isEquipped = HasItemInSlot(optionalWornBagId, testSlot)
        local isCorrectSlot = ZO_Character_DoesEquipSlotUseEquipType(testSlot, equipType)
        if not locked and isEquipped and isCorrectSlot then
            equipSlot = testSlot
            break
        end
    end
    return equipSlot
end
local ORDERED_EQUIP_TYPES =
{
    EQUIP_SLOT_MAIN_HAND,
    EQUIP_SLOT_OFF_HAND,
    EQUIP_SLOT_POISON,
    EQUIP_SLOT_BACKUP_MAIN,
    EQUIP_SLOT_BACKUP_OFF,
    EQUIP_SLOT_BACKUP_POISON,
    EQUIP_SLOT_HEAD,
    EQUIP_SLOT_CHEST,
    EQUIP_SLOT_SHOULDERS,
    EQUIP_SLOT_WAIST,
    EQUIP_SLOT_HAND,
    EQUIP_SLOT_LEGS,
    EQUIP_SLOT_FEET,
    EQUIP_SLOT_COSTUME,
    EQUIP_SLOT_NECK,
    EQUIP_SLOT_RING1,
    EQUIP_SLOT_RING2,
}
local COMPANION_ORDERED_EQUIP_TYPES =
{
    EQUIP_SLOT_MAIN_HAND,
    EQUIP_SLOT_OFF_HAND,
    EQUIP_SLOT_HEAD,
    EQUIP_SLOT_CHEST,
    EQUIP_SLOT_SHOULDERS,
    EQUIP_SLOT_WAIST,
    EQUIP_SLOT_HAND,
    EQUIP_SLOT_LEGS,
    EQUIP_SLOT_FEET,
    EQUIP_SLOT_COSTUME,
    EQUIP_SLOT_NECK,
    EQUIP_SLOT_RING1,
    EQUIP_SLOT_RING2,
}
    if bagId == BAG_COMPANION_WORN then
        return ipairs(COMPANION_ORDERED_EQUIP_TYPES)
    else
        return ipairs(ORDERED_EQUIP_TYPES)
    end
end
local EQUIP_SLOT_TO_EQUIP_SLOT_VISUAL_CATEGORY =
{
    [EQUIP_SLOT_MAIN_HAND]  = EQUIP_SLOT_VISUAL_CATEGORY_WEAPONS,
    [EQUIP_SLOT_OFF_HAND]   = EQUIP_SLOT_VISUAL_CATEGORY_WEAPONS,
    [EQUIP_SLOT_POISON]     = EQUIP_SLOT_VISUAL_CATEGORY_WEAPONS,
    [EQUIP_SLOT_BACKUP_MAIN]= EQUIP_SLOT_VISUAL_CATEGORY_WEAPONS,
    [EQUIP_SLOT_BACKUP_OFF] = EQUIP_SLOT_VISUAL_CATEGORY_WEAPONS,
    [EQUIP_SLOT_BACKUP_POISON] = EQUIP_SLOT_VISUAL_CATEGORY_WEAPONS,
    [EQUIP_SLOT_HEAD]       = EQUIP_SLOT_VISUAL_CATEGORY_APPAREL,
    [EQUIP_SLOT_CHEST]      = EQUIP_SLOT_VISUAL_CATEGORY_APPAREL,
    [EQUIP_SLOT_SHOULDERS]  = EQUIP_SLOT_VISUAL_CATEGORY_APPAREL,
    [EQUIP_SLOT_WAIST]      = EQUIP_SLOT_VISUAL_CATEGORY_APPAREL,
    [EQUIP_SLOT_HAND]       = EQUIP_SLOT_VISUAL_CATEGORY_APPAREL,
    [EQUIP_SLOT_LEGS]       = EQUIP_SLOT_VISUAL_CATEGORY_APPAREL,
    [EQUIP_SLOT_FEET]       = EQUIP_SLOT_VISUAL_CATEGORY_APPAREL,
    [EQUIP_SLOT_COSTUME]    = EQUIP_SLOT_VISUAL_CATEGORY_ACCESSORIES,
    [EQUIP_SLOT_NECK]       = EQUIP_SLOT_VISUAL_CATEGORY_ACCESSORIES,
    [EQUIP_SLOT_RING1]      = EQUIP_SLOT_VISUAL_CATEGORY_ACCESSORIES,
    [EQUIP_SLOT_RING2]      = EQUIP_SLOT_VISUAL_CATEGORY_ACCESSORIES,
}
    return EQUIP_SLOT_TO_EQUIP_SLOT_VISUAL_CATEGORY[equipSlot]
end
local SLOT_TEXTURES =
{
    [EQUIP_SLOT_HEAD]       = "EsoUI/Art/CharacterWindow/gearSlot_head.dds",
    [EQUIP_SLOT_NECK]       = "EsoUI/Art/CharacterWindow/gearSlot_neck.dds",
    [EQUIP_SLOT_CHEST]      = "EsoUI/Art/CharacterWindow/gearSlot_chest.dds",
    [EQUIP_SLOT_SHOULDERS]  = "EsoUI/Art/CharacterWindow/gearSlot_shoulders.dds",
    [EQUIP_SLOT_MAIN_HAND]  = "EsoUI/Art/CharacterWindow/gearSlot_mainHand.dds",
    [EQUIP_SLOT_OFF_HAND]   = "EsoUI/Art/CharacterWindow/gearSlot_offHand.dds",
    [EQUIP_SLOT_POISON]     = "EsoUI/Art/CharacterWindow/gearSlot_poison.dds",
    [EQUIP_SLOT_WAIST]      = "EsoUI/Art/CharacterWindow/gearSlot_belt.dds",
    [EQUIP_SLOT_LEGS]       = "EsoUI/Art/CharacterWindow/gearSlot_legs.dds",
    [EQUIP_SLOT_FEET]       = "EsoUI/Art/CharacterWindow/gearSlot_feet.dds",
    [EQUIP_SLOT_COSTUME]    = "EsoUI/Art/CharacterWindow/gearSlot_costume.dds",
    [EQUIP_SLOT_RING1]      = "EsoUI/Art/CharacterWindow/gearSlot_ring.dds",
    [EQUIP_SLOT_RING2]      = "EsoUI/Art/CharacterWindow/gearSlot_ring.dds",
    [EQUIP_SLOT_HAND]       = "EsoUI/Art/CharacterWindow/gearSlot_hands.dds",
    [EQUIP_SLOT_BACKUP_MAIN]= "EsoUI/Art/CharacterWindow/gearSlot_mainHand.dds",
    [EQUIP_SLOT_BACKUP_OFF] = "EsoUI/Art/CharacterWindow/gearSlot_offHand.dds",
    [EQUIP_SLOT_BACKUP_POISON] = "EsoUI/Art/CharacterWindow/gearSlot_poison.dds",
}
    return SLOT_TEXTURES[equipSlot]
end