Advertisement
Guest User

Untitled

a guest
Dec 30th, 2014
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.58 KB | None | 0 0
  1. void ObjectMgr::LoadItemTemplates()
  2. {
  3.     uint32 oldMSTime = getMSTime();
  4.  
  5.     //                                                 0      1       2               3              4        5        6       7          8         9        10        11           12
  6.     QueryResult result = WorldDatabase.Query("SELECT entry, class, subclass, SoundOverrideSubclass, name, displayid, Quality, Flags, FlagsExtra, BuyCount, BuyPrice, SellPrice, InventoryType, "
  7.     //                                              13              14           15          16             17               18                19              20
  8.                                              "AllowableClass, AllowableRace, ItemLevel, RequiredLevel, RequiredSkill, RequiredSkillRank, requiredspell, requiredhonorrank, "
  9.     //                                              21                      22                       23               24        25          26             27           28
  10.                                              "RequiredCityRank, RequiredReputationFaction, RequiredReputationRank, maxcount, stackable, ContainerSlots, StatsCount, stat_type1, "
  11.     //                                            29           30          31           32          33           34          35           36          37           38
  12.                                              "stat_value1, stat_type2, stat_value2, stat_type3, stat_value3, stat_type4, stat_value4, stat_type5, stat_value5, stat_type6, "
  13.     //                                            39           40          41           42           43          44           45           46           47
  14.                                              "stat_value6, stat_type7, stat_value7, stat_type8, stat_value8, stat_type9, stat_value9, stat_type10, stat_value10, "
  15.     //                                                   48                    49           50        51        52         53        54         55      56      57        58
  16.                                              "ScalingStatDistribution, ScalingStatValue, dmg_min1, dmg_max1, dmg_type1, dmg_min2, dmg_max2, dmg_type2, armor, holy_res, fire_res, "
  17.     //                                            59          60         61          62       63       64            65            66          67               68
  18.                                              "nature_res, frost_res, shadow_res, arcane_res, delay, ammo_type, RangedModRange, spellid_1, spelltrigger_1, spellcharges_1, "
  19.     //                                              69              70                71                 72                 73           74               75
  20.                                              "spellppmRate_1, spellcooldown_1, spellcategory_1, spellcategorycooldown_1, spellid_2, spelltrigger_2, spellcharges_2, "
  21.     //                                              76               77              78                  79                 80           81               82
  22.                                              "spellppmRate_2, spellcooldown_2, spellcategory_2, spellcategorycooldown_2, spellid_3, spelltrigger_3, spellcharges_3, "
  23.     //                                              83               84              85                  86                 87           88               89
  24.                                              "spellppmRate_3, spellcooldown_3, spellcategory_3, spellcategorycooldown_3, spellid_4, spelltrigger_4, spellcharges_4, "
  25.     //                                              90               91              92                  93                  94          95               96
  26.                                              "spellppmRate_4, spellcooldown_4, spellcategory_4, spellcategorycooldown_4, spellid_5, spelltrigger_5, spellcharges_5, "
  27.     //                                              97               98              99                  100                 101        102         103       104          105
  28.                                              "spellppmRate_5, spellcooldown_5, spellcategory_5, spellcategorycooldown_5, bonding, description, PageText, LanguageID, PageMaterial, "
  29.     //                                            106       107     108      109          110            111       112     113         114       115   116     117
  30.                                              "startquest, lockid, Material, sheath, RandomProperty, RandomSuffix, block, itemset, MaxDurability, area, Map, BagFamily, "
  31.     //                                            118             119             120             121             122            123              124            125
  32.                                              "TotemCategory, socketColor_1, socketContent_1, socketColor_2, socketContent_2, socketColor_3, socketContent_3, socketBonus, "
  33.     //                                            126                 127                     128            129            130            131         132         133
  34.                                              "GemProperties, RequiredDisenchantSkill, ArmorDamageModifier, duration, ItemLimitCategory, HolidayId, ScriptName, DisenchantID, "
  35.     //                                           134        135            136
  36.                                              "FoodType, minMoneyLoot, maxMoneyLoot, flagsCustom FROM item_template");
  37.     //                                                            0        1       2       3
  38.  
  39.     if (!result)
  40.     {
  41.         TC_LOG_INFO("server.loading", ">> Loaded 0 item templates. DB table `item_template` is empty.");
  42.         return;
  43.     }
  44.  
  45.     _itemTemplateStore.rehash(result->GetRowCount());
  46.     uint32 count = 0;
  47.  
  48.  
  49.     do
  50.     {
  51.         bool enforceDBCAttributes = sWorld->getBoolConfig(CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES);
  52.  
  53.         Field* fields = result->Fetch();
  54.  
  55.  
  56.         uint32 entry = fields[0].GetUInt32();
  57.  
  58.         ItemTemplate& itemTemplate = _itemTemplateStore[entry];
  59.  
  60.         itemTemplate.ItemId                    = entry;
  61.         itemTemplate.Class                     = uint32(fields[1].GetUInt8());
  62.         itemTemplate.SubClass                  = uint32(fields[2].GetUInt8());
  63.         itemTemplate.SoundOverrideSubclass     = int32(fields[3].GetInt8());
  64.         itemTemplate.Name1                     = fields[4].GetString();
  65.         itemTemplate.DisplayInfoID             = fields[5].GetUInt32();
  66.         itemTemplate.Quality                   = uint32(fields[6].GetUInt8());
  67.         itemTemplate.Flags                     = fields[7].GetUInt32();
  68.         itemTemplate.Flags2                    = fields[8].GetUInt32();
  69.         itemTemplate.BuyCount                  = uint32(fields[9].GetUInt8());
  70.         itemTemplate.BuyPrice                  = int32(fields[10].GetInt64());
  71.         itemTemplate.SellPrice                 = fields[11].GetUInt32();
  72.         itemTemplate.InventoryType             = uint32(fields[12].GetUInt8());
  73.         itemTemplate.AllowableClass            = fields[13].GetInt32();
  74.         itemTemplate.AllowableRace             = fields[14].GetInt32();
  75.         itemTemplate.ItemLevel                 = uint32(fields[15].GetUInt16());
  76.         itemTemplate.RequiredLevel             = uint32(fields[16].GetUInt8());
  77.         itemTemplate.RequiredSkill             = uint32(fields[17].GetUInt16());
  78.         itemTemplate.RequiredSkillRank         = uint32(fields[18].GetUInt16());
  79.         itemTemplate.RequiredSpell             = fields[19].GetUInt32();
  80.         itemTemplate.RequiredHonorRank         = fields[20].GetUInt32();
  81.         itemTemplate.RequiredCityRank          = fields[21].GetUInt32();
  82.         itemTemplate.RequiredReputationFaction = uint32(fields[22].GetUInt16());
  83.         itemTemplate.RequiredReputationRank    = uint32(fields[23].GetUInt16());
  84.         itemTemplate.MaxCount                  = fields[24].GetInt32();
  85.         itemTemplate.Stackable                 = fields[25].GetInt32();
  86.         itemTemplate.ContainerSlots            = uint32(fields[26].GetUInt8());
  87.         itemTemplate.StatsCount                = uint32(fields[27].GetUInt8());
  88.  
  89.         for (uint8 i = 0; i < itemTemplate.StatsCount; ++i)
  90.         {
  91.             itemTemplate.ItemStat[i].ItemStatType  = uint32(fields[28 + i*2].GetUInt8());
  92.             itemTemplate.ItemStat[i].ItemStatValue = int32(fields[29 + i * 2].GetInt32());
  93.         }
  94.  
  95.         itemTemplate.ScalingStatDistribution = uint32(fields[48].GetUInt16());
  96.         itemTemplate.ScalingStatValue        = fields[49].GetInt32();
  97.  
  98.         for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
  99.         {
  100.             itemTemplate.Damage[i].DamageMin  = fields[50 + i*3].GetFloat();
  101.             itemTemplate.Damage[i].DamageMax  = fields[51 + i*3].GetFloat();
  102.             itemTemplate.Damage[i].DamageType = uint32(fields[52 + i*3].GetUInt8());
  103.         }
  104.  
  105.         itemTemplate.Armor          = uint32(fields[56].GetUInt16());
  106.         itemTemplate.HolyRes        = uint32(fields[57].GetUInt8());
  107.         itemTemplate.FireRes        = uint32(fields[58].GetUInt8());
  108.         itemTemplate.NatureRes      = uint32(fields[59].GetUInt8());
  109.         itemTemplate.FrostRes       = uint32(fields[60].GetUInt8());
  110.         itemTemplate.ShadowRes      = uint32(fields[61].GetUInt8());
  111.         itemTemplate.ArcaneRes      = uint32(fields[62].GetUInt8());
  112.         itemTemplate.Delay          = uint32(fields[63].GetUInt16());
  113.         itemTemplate.AmmoType       = uint32(fields[64].GetUInt8());
  114.         itemTemplate.RangedModRange = fields[65].GetFloat();
  115.  
  116.         for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
  117.         {
  118.             itemTemplate.Spells[i].SpellId               = fields[66 + i*7  ].GetInt32();
  119.             itemTemplate.Spells[i].SpellTrigger          = uint32(fields[67 + i*7].GetUInt8());
  120.             itemTemplate.Spells[i].SpellCharges          = int32(fields[68 + i*7].GetInt16());
  121.             itemTemplate.Spells[i].SpellPPMRate          = fields[69 + i*7].GetFloat();
  122.             itemTemplate.Spells[i].SpellCooldown         = fields[70 + i*7].GetInt32();
  123.             itemTemplate.Spells[i].SpellCategory         = uint32(fields[71 + i*7].GetUInt16());
  124.             itemTemplate.Spells[i].SpellCategoryCooldown = fields[72 + i*7].GetInt32();
  125.         }
  126.  
  127.         itemTemplate.Bonding        = uint32(fields[101].GetUInt8());
  128.         itemTemplate.PageText       = fields[103].GetUInt32();
  129.         itemTemplate.LanguageID     = uint32(fields[104].GetUInt8());
  130.         itemTemplate.PageMaterial   = uint32(fields[105].GetUInt8());
  131.         itemTemplate.StartQuest     = fields[106].GetUInt32();
  132.         itemTemplate.LockID         = fields[107].GetUInt32();
  133.         itemTemplate.Material       = int32(fields[108].GetInt8());
  134.         itemTemplate.Sheath         = uint32(fields[109].GetUInt8());
  135.         itemTemplate.RandomProperty = fields[110].GetUInt32();
  136.         itemTemplate.RandomSuffix   = fields[111].GetInt32();
  137.         itemTemplate.Block          = fields[112].GetUInt32();
  138.         itemTemplate.ItemSet        = fields[113].GetUInt32();
  139.         itemTemplate.MaxDurability  = uint32(fields[114].GetUInt16());
  140.         itemTemplate.Area           = fields[115].GetUInt32();
  141.         itemTemplate.Map            = uint32(fields[116].GetUInt16());
  142.         itemTemplate.BagFamily      = fields[117].GetUInt32();
  143.         itemTemplate.TotemCategory  = fields[118].GetUInt32();
  144.  
  145.         for (uint8 i = 0; i < MAX_ITEM_PROTO_SOCKETS; ++i)
  146.         {
  147.             itemTemplate.Socket[i].Color   = uint32(fields[119 + i*2].GetUInt8());
  148.             itemTemplate.Socket[i].Content = fields[120 + i*2].GetUInt32();
  149.         }
  150.  
  151.         itemTemplate.socketBonus             = fields[125].GetUInt32();
  152.         itemTemplate.GemProperties           = fields[126].GetUInt32();
  153.         itemTemplate.RequiredDisenchantSkill = uint32(fields[127].GetInt16());
  154.         itemTemplate.ArmorDamageModifier     = fields[128].GetFloat();
  155.         itemTemplate.Duration                = fields[129].GetUInt32();
  156.         itemTemplate.ItemLimitCategory       = uint32(fields[130].GetInt16());
  157.         itemTemplate.HolidayId               = fields[131].GetUInt32();
  158.         itemTemplate.ScriptId                = sObjectMgr->GetScriptId(fields[132].GetCString());
  159.         itemTemplate.DisenchantID            = fields[133].GetUInt32();
  160.         itemTemplate.FoodType                = uint32(fields[134].GetUInt8());
  161.         itemTemplate.MinMoneyLoot            = fields[135].GetUInt32();
  162.         itemTemplate.MaxMoneyLoot            = fields[136].GetUInt32();
  163.         itemTemplate.FlagsCu                 = fields[137].GetUInt32();
  164.  
  165.         QueryResult resultRequiredStat = WorldDatabase.Query("SELECT entry, reqStam, reqStr, reqInt from items_StatRequirement");
  166.  
  167.         _itemTemplateStore.rehash(resultRequiredStat->GetRowCount());
  168.  
  169.  
  170.         Field* fieldsStatReq = resultRequiredStat->Fetch();
  171.  
  172.         do {
  173.             if (fieldsStatReq[0].GetUInt32() == fields[0].GetUInt32()) {
  174.                 TC_LOG_INFO("server.loading", "Found requirements for item");
  175.                 itemTemplate.RequiredStamina = fieldsStatReq[1].GetUInt32();
  176.                 itemTemplate.RequiredStrength = fieldsStatReq[2].GetUInt32();
  177.                 itemTemplate.RequiredIntelligence = fieldsStatReq[3].GetUInt32();
  178.                 itemTemplate.Description = "\n|cffFF0000Required Stamina: " + std::to_string(fieldsStatReq[1].GetUInt32()) +
  179.                     "\nRequired Strength: " + std::to_string(fieldsStatReq[2].GetUInt32()) +
  180.                     "\nRequired Intelligence: " + std::to_string(fieldsStatReq[3].GetUInt32()) +
  181.                     "\n|cffFAAC58" + fields[102].GetString();
  182.  
  183.             }
  184.             else {
  185.                 TC_LOG_INFO("server.loading", "Did not find requirements for item");
  186.                 itemTemplate.RequiredStamina = 0;
  187.                 itemTemplate.RequiredStrength = 0;
  188.                 itemTemplate.RequiredIntelligence = 0;
  189.                 itemTemplate.Description = fields[102].GetString();
  190.             }
  191.         } while (resultRequiredStat->NextRow());
  192.  
  193.  
  194. there is more below this but i havent done anything there
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement