All weapons looted have a 25% chance to have a random enchant visual
This is purely visual fun and the visual will be replaced when the weapon is enchanted.
This script is 100% automatic. You can only put it to your script folder and it will work.
]]
local chance = 0.25
-- Do not edit anything below
local charactersSQL = [[
CREATE TABLE IF NOT EXISTS `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;
]]
CharDBQuery(charactersSQL)
-- 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, 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) then return
false
end
local iguid = item:GetGUIDLow()
local enID = item:GetEnchantmentId(PERM_ENCHANTMENT_SLOT) or 0
if (enID ~= 0) then
CharDBExecute("DELETE FROM custom_item_enchant_visuals WHERE iguid = "..iguid)
DD[iguid] = nil
display = enID
elseif (not display) then
if (not DD[iguid]) then
return false
end
display = DD[iguid]
else
CharDBExecute("REPLACE INTO custom_item_enchant_visuals (iguid, display) VALUES ("..iguid..", "..display..")")