Azteco

creature_template

Apr 17th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. static bool HandleReloadCreatureTemplateCommand(ChatHandler* handler, const char* args)
  2. {
  3. if (!*args)
  4. return false;
  5.  
  6. Tokenizer entries(std::string(args), ' ');
  7.  
  8. for (Tokenizer::const_iterator itr = entries.begin(); itr != entries.end(); ++itr)
  9. {
  10. uint32 entry = uint32(atoi(*itr));
  11.  
  12. PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_TEMPLATE);
  13. stmt->setUInt32(0, entry);
  14. PreparedQueryResult result = WorldDatabase.Query(stmt);
  15.  
  16. if (!result)
  17. {
  18. handler->PSendSysMessage(LANG_COMMAND_CREATURETEMPLATE_NOTFOUND, entry);
  19. continue;
  20. }
  21.  
  22. CreatureTemplate* cInfo = const_cast<CreatureTemplate*>(sObjectMgr->GetCreatureTemplate(entry));
  23. if (!cInfo)
  24. {
  25. handler->PSendSysMessage(LANG_COMMAND_CREATURESTORAGE_NOTFOUND, entry);
  26. continue;
  27. }
  28.  
  29. sLog->outInfo(LOG_FILTER_GENERAL, "Reloading creature template entry %u", entry);
  30.  
  31. Field* fields = result->Fetch();
  32.  
  33. cInfo->DifficultyEntry[0] = fields[0].GetUInt32();
  34. cInfo->DifficultyEntry[1] = fields[1].GetUInt32();
  35. cInfo->DifficultyEntry[2] = fields[2].GetUInt32();
  36. cInfo->KillCredit[0] = fields[3].GetUInt32();
  37. cInfo->KillCredit[1] = fields[4].GetUInt32();
  38. cInfo->Modelid1 = fields[5].GetUInt32();
  39. cInfo->Modelid2 = fields[6].GetUInt32();
  40. cInfo->Modelid3 = fields[7].GetUInt32();
  41. cInfo->Modelid4 = fields[8].GetUInt32();
  42. cInfo->Name = fields[9].GetString();
  43. cInfo->SubName = fields[10].GetString();
  44. cInfo->IconName = fields[11].GetString();
  45. cInfo->GossipMenuId = fields[12].GetUInt32();
  46. cInfo->minlevel = fields[13].GetUInt8();
  47. cInfo->maxlevel = fields[14].GetUInt8();
  48. cInfo->expansion = fields[15].GetUInt16();
  49. cInfo->faction_A = fields[16].GetUInt16();
  50. cInfo->faction_H = fields[17].GetUInt16();
  51. cInfo->npcflag = fields[18].GetUInt32();
  52. cInfo->speed_walk = fields[19].GetFloat();
  53. cInfo->speed_run = fields[20].GetFloat();
  54. cInfo->scale = fields[21].GetFloat();
  55. cInfo->rank = fields[22].GetUInt8();
  56. cInfo->mindmg = fields[23].GetFloat();
  57. cInfo->maxdmg = fields[24].GetFloat();
  58. cInfo->dmgschool = fields[25].GetUInt8();
  59. cInfo->attackpower = fields[26].GetUInt32();
  60. cInfo->dmg_multiplier = fields[27].GetFloat();
  61. cInfo->baseattacktime = fields[28].GetUInt32();
  62. cInfo->rangeattacktime = fields[29].GetUInt32();
  63. cInfo->unit_class = fields[30].GetUInt8();
  64. cInfo->unit_flags = fields[31].GetUInt32();
  65. cInfo->unit_flags2 = fields[32].GetUInt32();
  66. cInfo->dynamicflags = fields[33].GetUInt32();
  67. cInfo->family = fields[34].GetUInt8();
  68. cInfo->trainer_type = fields[35].GetUInt8();
  69. cInfo->trainer_spell = fields[36].GetUInt32();
  70. cInfo->trainer_class = fields[37].GetUInt8();
  71. cInfo->trainer_race = fields[38].GetUInt8();
  72. cInfo->minrangedmg = fields[39].GetFloat();
  73. cInfo->maxrangedmg = fields[40].GetFloat();
  74. cInfo->rangedattackpower = fields[41].GetUInt16();
  75. cInfo->type = fields[42].GetUInt8();
  76. cInfo->type_flags = fields[43].GetUInt32();
  77. cInfo->lootid = fields[44].GetUInt32();
  78. cInfo->pickpocketLootId = fields[45].GetUInt32();
  79. cInfo->SkinLootId = fields[46].GetUInt32();
  80.  
  81. for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
  82. cInfo->resistance[i] = fields[47 + i -1].GetUInt16();
  83.  
  84. cInfo->spells[0] = fields[53].GetUInt32();
  85. cInfo->spells[1] = fields[54].GetUInt32();
  86. cInfo->spells[2] = fields[55].GetUInt32();
  87. cInfo->spells[3] = fields[56].GetUInt32();
  88. cInfo->spells[4] = fields[57].GetUInt32();
  89. cInfo->spells[5] = fields[58].GetUInt32();
  90. cInfo->spells[6] = fields[59].GetUInt32();
  91. cInfo->spells[7] = fields[60].GetUInt32();
  92. cInfo->PetSpellDataId = fields[61].GetUInt32();
  93. cInfo->VehicleId = fields[62].GetUInt32();
  94. cInfo->mingold = fields[63].GetUInt32();
  95. cInfo->maxgold = fields[64].GetUInt32();
  96. cInfo->AIName = fields[65].GetString();
  97. cInfo->MovementType = fields[66].GetUInt8();
  98. cInfo->InhabitType = fields[67].GetUInt8();
  99. cInfo->HoverHeight = fields[68].GetFloat();
  100. cInfo->ModHealth = fields[69].GetFloat();
  101. cInfo->ModMana = fields[70].GetFloat();
  102. cInfo->ModArmor = fields[71].GetFloat();
  103. cInfo->RacialLeader = fields[72].GetBool();
  104. cInfo->questItems[0] = fields[73].GetUInt32();
  105. cInfo->questItems[1] = fields[74].GetUInt32();
  106. cInfo->questItems[2] = fields[75].GetUInt32();
  107. cInfo->questItems[3] = fields[76].GetUInt32();
  108. cInfo->questItems[4] = fields[77].GetUInt32();
  109. cInfo->questItems[5] = fields[78].GetUInt32();
  110. cInfo->movementId = fields[79].GetUInt32();
  111. cInfo->RegenHealth = fields[80].GetBool();
  112. cInfo->MechanicImmuneMask = fields[81].GetUInt32();
  113. cInfo->flags_extra = fields[82].GetUInt32();
  114. cInfo->ScriptID = sObjectMgr->GetScriptId(fields[83].GetCString());
  115.  
  116. sObjectMgr->CheckCreatureTemplate(cInfo);
  117. }
  118.  
  119. handler->SendGlobalGMSysMessage("Creature template reloaded.");
  120. return true;
  121. }
Advertisement
Add Comment
Please, Sign In to add comment