-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathWeapon_Visual_Style.lua
More file actions
195 lines (176 loc) · 6.09 KB
/
Copy pathWeapon_Visual_Style.lua
File metadata and controls
195 lines (176 loc) · 6.09 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
-- Enchant display (Visual) system for weapons:
-- First create the database, the SQL is provided below. After that import script, reload eluna. And type in game ''enchant'' to open menu. Enjoy
-- Created by: Poszer
--[[
-- SQL:
CREATE TABLE `custom_item_enchant_visuals` (
`iguid` INT(10) UNSIGNED NOT NULL COMMENT 'item DB guid',
`display` INT(10) UNSIGNED NOT NULL COMMENT 'enchantID',
PRIMARY KEY (`iguid`)
)
COMMENT='stores the enchant IDs for the visuals'
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB;
]]
-- script variables:
local EQUIPMENT_SLOT_MAINHAND = 15
local EQUIPMENT_SLOT_OFFHAND = 16
local PLAYER_VISIBLE_ITEM_1_ENCHANTMENT = 284
local PERM_ENCHANTMENT_SLOT = 0
local DD = {}
-- functions
local LoadDB, setVisual, applyVisuals, VISUAL_LOGOUT, LOGIN
function LoadDB()
DD = {}
CharDBQuery("DELETE FROM custom_item_enchant_visuals WHERE NOT EXISTS(SELECT 1 FROM item_instance WHERE custom_item_enchant_visuals.iguid = item_instance.guid)")
local Q = CharDBQuery("SELECT iguid, display FROM custom_item_enchant_visuals")
if(Q) then
repeat
local iguid, display = Q:GetUInt32(0), Q:GetUInt32(1)
DD[iguid] = display
until not Q:NextRow()
end
end
LoadDB()
function setVisual(player, item, display)
if(not player or not item or not item:IsEquipped()) then return false end
local iguid = item:GetGUIDLow()
if(not display) then
if(not DD[iguid]) then return false end
display = DD[iguid]
elseif(display ~= 0) then
CharDBExecute("REPLACE INTO custom_item_enchant_visuals (iguid, display) VALUES ("..iguid..", "..display..")")
DD[iguid] = display
end
if(display == 0) then
display = item:GetEnchantmentId(PERM_ENCHANTMENT_SLOT) or 0
if(DD[iguid]) then
CharDBExecute("DELETE FROM custom_item_enchant_visuals WHERE iguid = "..iguid)
DD[iguid] = nil
end
end
player:SetUInt16Value(PLAYER_VISIBLE_ITEM_1_ENCHANTMENT + (item:GetSlot() * 2), 0, display)
return true
end
function applyVisuals(player)
if(not player) then return end
for i = EQUIPMENT_SLOT_MAINHAND, EQUIPMENT_SLOT_OFFHAND do
setVisual(player, player:GetItemByPos(255, i))
end
end
function LOGIN(event, player)
applyVisuals(player)
end
RegisterPlayerEvent(3, LOGIN)
RegisterPlayerEvent(29, function(e,p,i,b,s) setVisual(p, i) end)
-- Enchant display gossip:
-- Enchant IDs and their names
local E = {
{0, "Reset"},
{3789, "Berserking"},
{3854, "Spell Power"},
{3273, "Deathfrost"},
{3225, "Executioner"},
{3870, "Blood Draining"},
{1899, "Unholy Weapon"},
{2674, "Spellsurge"},
{2675, "Battlemaster"},
{2671, "Arcane and Fire Spell Power"},
{2672, "Shadow and Frost Spell Power"},
{3365, "Rune of Swordshattering"},
{2673, "Mongoose"},
{2343, "Spell Power"},
{425, "Black Temple Dummy"},
{3855, "Spell Power"},
{1894, "Icy Weapon"},
{1103, "Agility"},
{1898, "Lifestealing"},
{3345, "Earthliving 1"},
{1743, "MHTest02"},
{3093, "Attack Power vs Undead and Demons"},
{1900, "Crusader"},
{3846, "Spell Power"},
{1606, "Attack Power"},
{283, "Windfury 1"},
{1, "Rockbiter 3"},
{3265, "Blessed Weapon Coating"},
{2, "Frostbrand 1"},
{3, "Flametongue 3"},
{3266, "Righteous Weapon Coating"},
{1903, "Spirit"},
{13, "Sharpened (+3 Damage)"},
{26, "Frost Oil"},
{7, "Deadly Poison"},
{803, "Fiery Weapon"},
{1896, "Weapon Damage"},
{2666, "Intellect"},
{25, "Shadow Oil"},
}
-- script variables:
local VISUAL_CHATCommand = "enchant"
local maxGossipItems = 14 -- per page
local menu_id = 123
local safeGossipItems = 100 -- main menu: sender = safeGossipItems-1
local EQUIPMENT_SLOT_MAINHAND = 15
local EQUIPMENT_SLOT_OFFHAND = 16
local D = {}
-- functions:
local showItems, HELLO, SELECT, VISUAL_CHAT
function showItems(player, unit, offset)
local temp = (maxGossipItems)*offset+1
for i = temp, temp+maxGossipItems-1 do
local v = E[i]
if(not v) then break end
player:GossipMenuAddItem(9, v[2], safeGossipItems+offset, v[1]+1)
end
if(temp+maxGossipItems-1 < #E) then
player:GossipMenuAddItem(7, "Next..", safeGossipItems+offset+1, 0)
end
player:GossipMenuAddItem(7, "Back..", safeGossipItems+offset-1, 0)
player:GossipSendMenu(100, unit, menu_id)
end
function HELLO(event, player, unit)
player:GossipMenuAddItem(9, "Main hand", 0, EQUIPMENT_SLOT_MAINHAND)
player:GossipMenuAddItem(9, "Off hand", 0, EQUIPMENT_SLOT_OFFHAND)
player:GossipSendMenu(100, unit, menu_id)
end
function VISUAL_CHAT(event, player, msg, Type, lang)
if(msg == VISUAL_CHATCommand) then
player:GossipClearMenu()
HELLO(1, player, player)
return false
end
end
function SELECT(event, player, unit, sender, action, code)
local guid = player:GetGUIDLow()
if(not D[guid]) then
D[guid] = {}
end
if(sender == safeGossipItems-1 and action == 0) then
HELLO(event, player, unit)
elseif(sender >= safeGossipItems) then
if(action ~= 0) then
D[guid].display = action-1
if(D[guid].slot and D[guid].display) then
local item = player:GetItemByPos(255, D[guid].slot)
if(not item) then
player:SendNotification("No item equipped in selected slot")
else
setVisual(player, item, D[guid].display)
end
end
end
showItems(player, unit, sender-safeGossipItems)
elseif(sender == 0) then
D[guid].slot = action
showItems(player, unit, 0)
else
player:GossipCloseMenu()
end
end
function VISUAL_LOGOUT(event, player)
D[player:GetGUIDLow()] = nil
end
RegisterPlayerEvent(4, VISUAL_LOGOUT)
RegisterPlayerEvent(18, VISUAL_CHAT)
RegisterPlayerGossipEvent(menu_id, 2, SELECT)