item_loot_template Loot by Skill/Class

I would like to ask, is there option to make loot of some player by its skill or class using conditions:

CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE = 5
+
CONDITION_SKILL = 7

When I use Standard items like Rare/Epic all is loot is fine. But when I put into loot table HeirLoom Items - all go bugged.
I can’t loot items if I don’t have auto-loot enabled.
Some items disappear.
Some items show up only its frame/border.
If I close item that have the loot. Next time if I open, I can’t see any items… just all go wrong.

Where I’m wrong?

TrinityCore rev. 6d08d0634130 2013-10-11 02:43:11

TDB 335.52+ all updates. No custom sql or other patches. Clean install.

– Create Custom item from existed itemID
DELETE FROM item_template WHERE (entry=8960);
INSERT INTO item_template (entry, class, subclass, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, AllowableClass, AllowableRace, ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, requiredspell, requiredhonorrank, RequiredCityRank, RequiredReputationFaction, RequiredReputationRank, maxcount, stackable, ContainerSlots, StatsCount, stat_type1, stat_value1, stat_type2, stat_value2, stat_type3, stat_value3, stat_type4, stat_value4, stat_type5, stat_value5, stat_type6, stat_value6, stat_type7, stat_value7, stat_type8, stat_value8, stat_type9, stat_value9, stat_type10, stat_value10, ScalingStatDistribution, ScalingStatValue, dmg_min1, dmg_max1, dmg_type1, dmg_min2, dmg_max2, dmg_type2, armor, holy_res, fire_res, nature_res, frost_res, shadow_res, arcane_res, delay, ammo_type, RangedModRange, spellid_1, spelltrigger_1, spellcharges_1, spellppmRate_1, spellcooldown_1, spellcategory_1, spellcategorycooldown_1, spellid_2, spelltrigger_2, spellcharges_2, spellppmRate_2, spellcooldown_2, spellcategory_2, spellcategorycooldown_2, spellid_3, spelltrigger_3, spellcharges_3, spellppmRate_3, spellcooldown_3, spellcategory_3, spellcategorycooldown_3, spellid_4, spelltrigger_4, spellcharges_4, spellppmRate_4, spellcooldown_4, spellcategory_4, spellcategorycooldown_4, spellid_5, spelltrigger_5, spellcharges_5, spellppmRate_5, spellcooldown_5, spellcategory_5, spellcategorycooldown_5, bonding, description, PageText, LanguageID, PageMaterial, startquest, lockid, Material, sheath, RandomProperty, RandomSuffix, block, itemset, MaxDurability, area, Map, BagFamily, TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom, WDBVerified) VALUES (8960, 9, 0, ‘Test Book’, 1143, 3, 4, 0, 1, 4, 1, 0, -1, -1, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 1, ‘Test Item’, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, ‘’, 0, 0, 50, 100, 0, 12340);

– Create test loot for our custom item.
DELETE FROM item_loot_template WHERE (entry=8960);
INSERT INTO item_loot_template VALUES
(8960, 37177, 100, 1, 0, 1, 1), – Wand of the San’layn (Wand)
(8960, 37179, 100, 1, 0, 1, 1), – Infantry Assault Blade (1H Sword)
(8960, 37190, 100, 1, 0, 1, 1), – Enraged Feral Staff (Staff)
(8960, 37615, 100, 1, 0, 1, 1), – Titanium Compound Bow (Bow)
(8960, 37653, 100, 1, 0, 1, 1); – Sword of Justice (2H Sword)

– Add conditions for items in item_loot_template
DELETE FROM conditions WHERE SourceTypeOrReferenceId = 5 AND ConditionTypeOrReference = 7 AND SourceGroup = 8960;
INSERT INTO conditions (SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName, Comment) VALUES (5, 8960, 37177, 0, 8960, 7, 0, 228, 1, 0, 0, 0, 0, ‘’, ‘Drop if player have ability to use Wand’);
INSERT INTO conditions (SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName, Comment) VALUES (5, 8960, 37179, 0, 8960, 7, 0, 43, 1, 0, 0, 0, 0, ‘’, ‘Drop if player have ability to use 1H Swords’);
INSERT INTO conditions (SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName, Comment) VALUES (5, 8960, 37190, 0, 8960, 7, 0, 136, 1, 0, 0, 0, 0, ‘’, ‘Drop if player have ability to use Staves’);
INSERT INTO conditions (SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName, Comment) VALUES (5, 8960, 37615, 0, 8960, 7, 0, 45, 1, 0, 0, 0, 0, ‘’, ‘Drop if player have ability to use Bows’);
INSERT INTO conditions (SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName, Comment) VALUES (5, 8960, 37653, 0, 8960, 7, 0, 55, 1, 0, 0, 0, 0, ‘’, ‘Drop if player have ability to use 2H Swords’);
– end

This example is with standard items and works fine.

When I change items with HeirLoom Items - bugs coming.

Thanks in advance.

Edit source and write all rules in there, this will be much easier, also you can do auto loot in there