aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNay <dnpd.dd@gmail.com>2013-02-18 12:24:18 +0000
committerNay <dnpd.dd@gmail.com>2013-02-18 12:24:18 +0000
commit028c72a9f2c606e8af391d284931c60247ad0160 (patch)
tree36e084637e6d9ad0bc954b506fefd0e839724d08 /src
parent87d4e8c0673c6482b27bd2135a1e3c04874eb0ca (diff)
Core/NPCs: Refactor equipments
- creature_template.equipment_id deleted - creature_equip_template.entry == creature_template.entry - id field added to creature_equip_template -> PK(entry, id) - id field in creature_equip_template starts at 1 - creature.equipment_id references id of creature_equip_template - creature.equipment_id = 0 means no equipment at all (default 1) - creature.equipment_id = -1 means pick a random equipment from creature_equip_template - add equipment info to .npc info command While table creature_equip_template got bigger in size, this system is easier to mantain and allows creatures to have a random template from a group of equipments
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp4
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp15
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp20
-rw-r--r--src/server/game/Entities/Creature/Creature.h17
-rw-r--r--src/server/game/Events/GameEventMgr.cpp20
-rw-r--r--src/server/game/Events/GameEventMgr.h4
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp82
-rw-r--r--src/server/game/Globals/ObjectMgr.h2
-rw-r--r--src/server/game/Miscellaneous/Language.h3
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
-rw-r--r--src/server/game/World/World.cpp6
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp1
-rw-r--r--src/server/scripts/Commands/cs_reload.cpp7
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp6
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp2
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp8
-rw-r--r--src/server/shared/Database/Implementation/WorldDatabase.cpp2
17 files changed, 110 insertions, 91 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 6c947d11f07..2da40f287a5 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -370,9 +370,7 @@ void ScriptedAI::SetEquipmentSlots(bool loadDefault, int32 mainHand /*= EQUIP_NO
{
if (loadDefault)
{
- if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(me->GetEntry()))
- me->LoadEquipment(creatureInfo->equipmentId, true);
-
+ me->LoadEquipment(me->GetOriginalEquipmentId(), true);
return;
}
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 80388ce0be9..bc94169687c 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -1459,15 +1459,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (Creature* npc = (*itr)->ToCreature())
{
uint32 slot[3];
- if (e.action.equip.entry)
+ int8 equipId = (int8)e.action.equip.entry;
+ if (equipId)
{
- EquipmentInfo const* einfo = sObjectMgr->GetEquipmentInfo(e.action.equip.entry);
+ EquipmentInfo const* einfo = sObjectMgr->GetEquipmentInfo(npc->GetEntry(), equipId);
if (!einfo)
{
- sLog->outError(LOG_FILTER_SQL, "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info entry %u", e.action.equip.entry);
+ sLog->outError(LOG_FILTER_SQL, "SmartScript: SMART_ACTION_EQUIP uses non-existent equipment info id %u for creature %u", equipId, npc->GetEntry());
return;
}
- npc->SetCurrentEquipmentId(e.action.equip.entry);
+ npc->SetCurrentEquipmentId(equipId);
slot[0] = einfo->ItemEntry[0];
slot[1] = einfo->ItemEntry[1];
slot[2] = einfo->ItemEntry[2];
@@ -1478,11 +1479,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
slot[1] = e.action.equip.slot2;
slot[2] = e.action.equip.slot3;
}
- if (!e.action.equip.mask || e.action.equip.mask & 1)
+ if (!e.action.equip.mask || (e.action.equip.mask & 1))
npc->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, slot[0]);
- if (!e.action.equip.mask || e.action.equip.mask & 2)
+ if (!e.action.equip.mask || (e.action.equip.mask & 2))
npc->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, slot[1]);
- if (!e.action.equip.mask || e.action.equip.mask & 4)
+ if (!e.action.equip.mask || (e.action.equip.mask & 4))
npc->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, slot[2]);
}
}
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 0bcb2d76055..9b991393c6e 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -145,7 +145,7 @@ Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapCreature(),
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLowGUID(0),
m_PlayerDamageReq(0), m_lootRecipient(0), m_lootRecipientGroup(0), m_corpseRemoveTime(0), m_respawnTime(0),
m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE),
-m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_AlreadyCallAssistance(false),
+m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(1), m_originalEquipmentId(1), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
m_creatureInfo(NULL), m_creatureData(NULL), m_path_id(0), m_formation(NULL)
{
@@ -323,8 +323,8 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData* data
// Load creature equipment
if (!data || data->equipmentId == 0) // use default from the template
- LoadEquipment(cinfo->equipmentId);
- else if (data && data->equipmentId != -1) // override, -1 means no equipment
+ LoadEquipment(GetOriginalEquipmentId());
+ else if (data && data->equipmentId != 0) // override, 0 means no equipment
LoadEquipment(data->equipmentId);
SetName(normalInfo->Name); // at normal entry always
@@ -1089,7 +1089,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.mapid = mapid;
data.phaseMask = phaseMask;
data.displayid = displayId;
- data.equipmentId = GetEquipmentId();
+ data.equipmentId = GetCurrentEquipmentId();
data.posX = GetPositionX();
data.posY = GetPositionY();
data.posZ = GetPositionZMinusOffset();
@@ -1124,7 +1124,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
stmt->setUInt8(index++, spawnMask);
stmt->setUInt16(index++, uint16(GetPhaseMask()));
stmt->setUInt32(index++, displayId);
- stmt->setInt32(index++, int32(GetEquipmentId()));
+ stmt->setInt32(index++, int32(GetCurrentEquipmentId()));
stmt->setFloat(index++, GetPositionX());
stmt->setFloat(index++, GetPositionY());
stmt->setFloat(index++, GetPositionZ());
@@ -1355,24 +1355,24 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap)
return true;
}
-void Creature::LoadEquipment(uint32 equip_entry, bool force)
+void Creature::LoadEquipment(int8 id, bool force /*= true*/)
{
- if (equip_entry == 0)
+ if (id == 0)
{
if (force)
{
- for (uint8 i = 0; i < 3; ++i)
+ for (uint8 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, 0);
m_equipmentId = 0;
}
return;
}
- EquipmentInfo const* einfo = sObjectMgr->GetEquipmentInfo(equip_entry);
+ EquipmentInfo const* einfo = sObjectMgr->GetEquipmentInfo(GetEntry(), id);
if (!einfo)
return;
- m_equipmentId = equip_entry;
+ m_equipmentId = id;
for (uint8 i = 0; i < 3; ++i)
SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, einfo->ItemEntry[i]);
}
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index efc4e44798f..827de8bfcef 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -136,7 +136,6 @@ struct CreatureTemplate
uint32 questItems[MAX_CREATURE_QUEST_ITEMS];
uint32 movementId;
bool RegenHealth;
- uint32 equipmentId;
uint32 MechanicImmuneMask;
uint32 flags_extra;
uint32 ScriptID;
@@ -236,7 +235,8 @@ struct EquipmentInfo
};
// Benchmarked: Faster than std::map (insert/find)
-typedef UNORDERED_MAP<uint16, EquipmentInfo> EquipmentInfoContainer;
+typedef UNORDERED_MAP<uint8, EquipmentInfo> EquipmentInfoContainerInternal;
+typedef UNORDERED_MAP<uint32, EquipmentInfoContainerInternal> EquipmentInfoContainer;
// from `creature` table
struct CreatureData
@@ -246,7 +246,7 @@ struct CreatureData
uint16 mapid;
uint16 phaseMask;
uint32 displayid;
- int32 equipmentId;
+ int8 equipmentId;
float posX;
float posY;
float posZ;
@@ -454,13 +454,12 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, uint32 team, float x, float y, float z, float ang, const CreatureData* data = NULL);
bool LoadCreaturesAddon(bool reload = false);
void SelectLevel(const CreatureTemplate* cinfo);
- void LoadEquipment(uint32 equip_entry, bool force=false);
+ void LoadEquipment(int8 id = 1, bool force = false);
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
void Update(uint32 time); // overwrited Unit::Update
void GetRespawnPosition(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
- uint32 GetEquipmentId() const { return GetCreatureTemplate()->equipmentId; }
void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
uint32 GetCorpseDelay() const { return m_corpseDelay; }
@@ -558,8 +557,11 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
void UpdateMaxPower(Powers power);
void UpdateAttackPowerAndDamage(bool ranged = false);
void UpdateDamagePhysical(WeaponAttackType attType);
+
+ uint8 GetOriginalEquipmentId() const { return m_originalEquipmentId; }
uint32 GetCurrentEquipmentId() { return m_equipmentId; }
- void SetCurrentEquipmentId(uint32 entry) { m_equipmentId = entry; }
+ void SetCurrentEquipmentId(uint8 id) { m_equipmentId = id; }
+
float GetSpellDamageMod(int32 Rank);
VendorItemData const* GetVendorItems() const;
@@ -754,7 +756,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
void Regenerate(Powers power);
MovementGeneratorType m_defaultMovementType;
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
- uint32 m_equipmentId;
+ uint8 m_equipmentId;
+ uint8 m_originalEquipmentId;
bool m_AlreadyCallAssistance;
bool m_AlreadySearchedAssistance;
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index 95ed06bff37..3fc1345f444 100644
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -450,8 +450,8 @@ void GameEventMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
- // 0 1 2 3
- QueryResult result = WorldDatabase.Query("SELECT creature.guid, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id "
+ // 0 1 2 3 4
+ QueryResult result = WorldDatabase.Query("SELECT creature.guid, creature.id, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id "
"FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid");
if (!result)
@@ -466,7 +466,8 @@ void GameEventMgr::LoadFromDB()
Field* fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
- uint16 event_id = fields[1].GetUInt8();
+ uint32 entry = fields[1].GetUInt32();
+ uint16 event_id = fields[2].GetUInt8();
if (event_id >= mGameEventModelEquip.size())
{
@@ -476,17 +477,18 @@ void GameEventMgr::LoadFromDB()
ModelEquipList& equiplist = mGameEventModelEquip[event_id];
ModelEquip newModelEquipSet;
- newModelEquipSet.modelid = fields[2].GetUInt32();
- newModelEquipSet.equipment_id = fields[3].GetUInt32();
+ newModelEquipSet.modelid = fields[3].GetUInt32();
+ newModelEquipSet.equipment_id = fields[4].GetUInt8();
newModelEquipSet.equipement_id_prev = 0;
newModelEquipSet.modelid_prev = 0;
if (newModelEquipSet.equipment_id > 0)
{
- if (!sObjectMgr->GetEquipmentInfo(newModelEquipSet.equipment_id))
+ int8 equipId = static_cast<int8>(newModelEquipSet.equipment_id);
+ if (!sObjectMgr->GetEquipmentInfo(entry, equipId))
{
- sLog->outError(LOG_FILTER_SQL, "Table `game_event_model_equip` have creature (Guid: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.",
- guid, newModelEquipSet.equipment_id);
+ sLog->outError(LOG_FILTER_SQL, "Table `game_event_model_equip` have creature (Guid: %u, entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.",
+ guid, entry, newModelEquipSet.equipment_id);
continue;
}
}
@@ -1363,7 +1365,7 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
sObjectMgr->GetCreatureModelRandomGender(&displayID);
if (data2->equipmentId == 0)
- itr->second.equipement_id_prev = cinfo->equipmentId;
+ itr->second.equipement_id_prev = 1;
else if (data2->equipmentId != -1)
itr->second.equipement_id_prev = data->equipmentId;
itr->second.modelid_prev = displayID;
diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h
index d15b3e48dc9..4175e57f28a 100644
--- a/src/server/game/Events/GameEventMgr.h
+++ b/src/server/game/Events/GameEventMgr.h
@@ -73,9 +73,9 @@ struct GameEventData
struct ModelEquip
{
uint32 modelid;
- uint32 equipment_id;
uint32 modelid_prev;
- uint32 equipement_id_prev;
+ uint8 equipment_id;
+ uint8 equipement_id_prev;
};
struct NPCVendorEntry
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 1dd824759c9..f21de9cbfa7 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -404,8 +404,8 @@ void ObjectMgr::LoadCreatureTemplates()
"spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, "
// 68 69 70 71 72 73 74 75 76 77 78
"InhabitType, HoverHeight, Health_mod, Mana_mod, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, "
- // 79 80 81 82 83 84
- " questItem6, movementId, RegenHealth, equipment_id, mechanic_immune_mask, flags_extra, ScriptName "
+ // 79 80 81 82 83 84
+ " questItem6, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName "
"FROM creature_template;");
if (!result)
@@ -500,10 +500,9 @@ void ObjectMgr::LoadCreatureTemplates()
creatureTemplate.movementId = fields[80].GetUInt32();
creatureTemplate.RegenHealth = fields[81].GetBool();
- creatureTemplate.equipmentId = fields[82].GetUInt32();
- creatureTemplate.MechanicImmuneMask = fields[83].GetUInt32();
- creatureTemplate.flags_extra = fields[84].GetUInt32();
- creatureTemplate.ScriptID = GetScriptId(fields[85].GetCString());
+ creatureTemplate.MechanicImmuneMask = fields[82].GetUInt32();
+ creatureTemplate.flags_extra = fields[83].GetUInt32();
+ creatureTemplate.ScriptID = GetScriptId(fields[84].GetCString());
++count;
}
@@ -858,15 +857,6 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
const_cast<CreatureTemplate*>(cInfo)->MovementType = IDLE_MOTION_TYPE;
}
- if (cInfo->equipmentId > 0) // 0 no equipment
- {
- if (!GetEquipmentInfo(cInfo->equipmentId))
- {
- sLog->outError(LOG_FILTER_SQL, "Table `creature_template` lists creature (Entry: %u) with `equipment_id` %u not found in table `creature_equip_template`, set to no equipment.", cInfo->Entry, cInfo->equipmentId);
- const_cast<CreatureTemplate*>(cInfo)->equipmentId = 0;
- }
- }
-
/// if not set custom creature scale then load scale from CreatureDisplayInfo.dbc
if (cInfo->scale <= 0.0f)
{
@@ -986,11 +976,28 @@ CreatureAddon const* ObjectMgr::GetCreatureTemplateAddon(uint32 entry)
return NULL;
}
-EquipmentInfo const* ObjectMgr::GetEquipmentInfo(uint32 entry)
+EquipmentInfo const* ObjectMgr::GetEquipmentInfo(uint32 entry, int8& id)
{
EquipmentInfoContainer::const_iterator itr = _equipmentInfoStore.find(entry);
- if (itr != _equipmentInfoStore.end())
- return &(itr->second);
+ if (itr == _equipmentInfoStore.end())
+ return NULL;
+
+ if (itr->second.empty())
+ return NULL;
+
+ if (id == -1) // select a random element
+ {
+ EquipmentInfoContainerInternal::const_iterator ritr = itr->second.begin();
+ std::advance(ritr, urand(0u, itr->second.size()));
+ id = std::distance(itr->second.begin(), ritr) + 1;
+ return &ritr->second;
+ }
+ else
+ {
+ EquipmentInfoContainerInternal::const_iterator itr2 = itr->second.find(id);
+ if (itr2 != itr->second.end())
+ return &itr2->second;
+ }
return NULL;
}
@@ -999,7 +1006,8 @@ void ObjectMgr::LoadEquipmentTemplates()
{
uint32 oldMSTime = getMSTime();
- QueryResult result = WorldDatabase.Query("SELECT entry, itemEntry1, itemEntry2, itemEntry3 FROM creature_equip_template");
+ // 0 1 2 3 4
+ QueryResult result = WorldDatabase.Query("SELECT entry, id, itemEntry1, itemEntry2, itemEntry3 FROM creature_equip_template");
if (!result)
{
@@ -1012,13 +1020,21 @@ void ObjectMgr::LoadEquipmentTemplates()
{
Field* fields = result->Fetch();
- uint16 entry = fields[0].GetUInt16();
+ uint32 entry = fields[0].GetUInt32();
+
+ if (!sObjectMgr->GetCreatureTemplate(entry))
+ {
+ sLog->outError(LOG_FILTER_SQL, "Creature template (Entry: %u) does not exist but has a record in `creature_equip_template`", entry);
+ continue;
+ }
+
+ uint8 id = fields[1].GetUInt8();
- EquipmentInfo& equipmentInfo = _equipmentInfoStore[entry];
+ EquipmentInfo& equipmentInfo = _equipmentInfoStore[entry][id];
- equipmentInfo.ItemEntry[0] = fields[1].GetUInt32();
- equipmentInfo.ItemEntry[1] = fields[2].GetUInt32();
- equipmentInfo.ItemEntry[2] = fields[3].GetUInt32();
+ equipmentInfo.ItemEntry[0] = fields[2].GetUInt32();
+ equipmentInfo.ItemEntry[1] = fields[3].GetUInt32();
+ equipmentInfo.ItemEntry[2] = fields[4].GetUInt32();
for (uint8 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
{
@@ -1029,8 +1045,8 @@ void ObjectMgr::LoadEquipmentTemplates()
if (!dbcItem)
{
- sLog->outError(LOG_FILTER_SQL, "Unknown item (entry=%u) in creature_equip_template.itemEntry%u for entry = %u, forced to 0.",
- equipmentInfo.ItemEntry[i], i+1, entry);
+ sLog->outError(LOG_FILTER_SQL, "Unknown item (entry=%u) in creature_equip_template.itemEntry%u for entry = %u and id=%u, forced to 0.",
+ equipmentInfo.ItemEntry[i], i+1, entry, id);
equipmentInfo.ItemEntry[i] = 0;
continue;
}
@@ -1045,8 +1061,8 @@ void ObjectMgr::LoadEquipmentTemplates()
dbcItem->InventoryType != INVTYPE_THROWN &&
dbcItem->InventoryType != INVTYPE_RANGEDRIGHT)
{
- sLog->outError(LOG_FILTER_SQL, "Item (entry=%u) in creature_equip_template.itemEntry%u for entry = %u is not equipable in a hand, forced to 0.",
- equipmentInfo.ItemEntry[i], i+1, entry);
+ sLog->outError(LOG_FILTER_SQL, "Item (entry=%u) in creature_equip_template.itemEntry%u for entry = %u and id = %u is not equipable in a hand, forced to 0.",
+ equipmentInfo.ItemEntry[i], i+1, entry, id);
equipmentInfo.ItemEntry[i] = 0;
}
}
@@ -1493,13 +1509,13 @@ void ObjectMgr::LoadCreatures()
if (!ok)
continue;
- // -1 no equipment, 0 use default
- if (data.equipmentId > 0)
+ // -1 random, 0 no equipment, 1 is default (may or may not have equipment)
+ if (data.equipmentId != 0)
{
- if (!GetEquipmentInfo(data.equipmentId))
+ if (!GetEquipmentInfo(data.id, data.equipmentId) && data.equipmentId != 1)
{
sLog->outError(LOG_FILTER_SQL, "Table `creature` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", data.id, data.equipmentId);
- data.equipmentId = -1;
+ data.equipmentId = 1;
}
}
@@ -1673,7 +1689,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 /*team*/, uint32 mapId, float
data.id = entry;
data.mapid = mapId;
data.displayid = 0;
- data.equipmentId = cInfo->equipmentId;
+ data.equipmentId = 1;
data.posX = x;
data.posY = y;
data.posZ = z;
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index 9339684964c..88496fa9d6e 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -663,7 +663,7 @@ class ObjectMgr
CreatureModelInfo const* GetCreatureModelRandomGender(uint32* displayID);
static uint32 ChooseDisplayId(uint32 team, const CreatureTemplate* cinfo, const CreatureData* data = NULL);
static void ChooseCreatureFlags(const CreatureTemplate* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData* data = NULL);
- EquipmentInfo const* GetEquipmentInfo(uint32 entry);
+ EquipmentInfo const* GetEquipmentInfo(uint32 entry, int8& id);
CreatureAddon const* GetCreatureAddon(uint32 lowguid);
CreatureAddon const* GetCreatureTemplateAddon(uint32 entry);
ItemTemplate const* GetItemTemplate(uint32 entry);
diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h
index 5868b60b722..28f7a2cb8a0 100644
--- a/src/server/game/Miscellaneous/Language.h
+++ b/src/server/game/Miscellaneous/Language.h
@@ -1033,7 +1033,8 @@ enum TrinityStrings
LANG_COMMAND_NO_ACHIEVEMENT_CRITERIA_FOUND = 5033,
LANG_COMMAND_NO_OUTDOOR_PVP_FORUND = 5034,
LANG_CALL_FOR_HELP = 5035,
- // Room for more Trinity strings 5036-9999
+ LANG_NPCINFO_EQUIPMENT = 5036,
+ // Room for more Trinity strings 5037-9999
// Level requirement notifications
LANG_SAY_REQ = 6604,
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 93e4b2e4771..f5504f8b7c1 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -3902,7 +3902,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
unitTarget->CastSpell(unitTarget, iTmpSpellId, true);
Creature* npc = unitTarget->ToCreature();
- npc->LoadEquipment(npc->GetEquipmentId());
+ npc->LoadEquipment();
return;
}
// Emblazon Runeblade
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index d8eec66ea07..29ecdbb033e 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1405,12 +1405,12 @@ void World::SetInitialWorldSettings()
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Creature Model Based Info Data...");
sObjectMgr->LoadCreatureModelInfo();
- sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Equipment templates...");
- sObjectMgr->LoadEquipmentTemplates();
-
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Creature templates...");
sObjectMgr->LoadCreatureTemplates();
+ sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Equipment templates..."); // must be after LoadCreatureTemplates
+ sObjectMgr->LoadEquipmentTemplates();
+
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading Creature template addons...");
sObjectMgr->LoadCreatureTemplateAddons();
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index 7ccd5ed1177..818a17438bf 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -645,6 +645,7 @@ public:
handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), target->GetGUIDLow(), faction, npcflags, Entry, displayid, nativeid);
handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel());
+ handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, target->GetCurrentEquipmentId(), target->GetOriginalEquipmentId());
handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction());
handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());
diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp
index 43c2001fbf7..b2542d6a668 100644
--- a/src/server/scripts/Commands/cs_reload.cpp
+++ b/src/server/scripts/Commands/cs_reload.cpp
@@ -508,10 +508,9 @@ public:
cInfo->questItems[5] = fields[78].GetUInt32();
cInfo->movementId = fields[79].GetUInt32();
cInfo->RegenHealth = fields[80].GetBool();
- cInfo->equipmentId = fields[81].GetUInt32();
- cInfo->MechanicImmuneMask = fields[82].GetUInt32();
- cInfo->flags_extra = fields[83].GetUInt32();
- cInfo->ScriptID = sObjectMgr->GetScriptId(fields[84].GetCString());
+ cInfo->MechanicImmuneMask = fields[81].GetUInt32();
+ cInfo->flags_extra = fields[82].GetUInt32();
+ cInfo->ScriptID = sObjectMgr->GetScriptId(fields[83].GetCString());
sObjectMgr->CheckCreatureTemplate(cInfo);
}
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
index 96293c635d6..14321873b0d 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
@@ -102,10 +102,8 @@ public:
npc_unworthy_initiateAI(Creature* creature) : ScriptedAI(creature)
{
me->SetReactState(REACT_PASSIVE);
- if (!me->GetEquipmentId())
- if (const CreatureTemplate* info = sObjectMgr->GetCreatureTemplate(28406))
- if (info->equipmentId)
- const_cast<CreatureTemplate*>(me->GetCreatureTemplate())->equipmentId = info->equipmentId;
+ if (!me->GetCurrentEquipmentId())
+ me->SetCurrentEquipmentId(me->GetOriginalEquipmentId());
}
uint64 playerGUID;
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp
index f508266434b..7e2515c42a7 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp
@@ -237,7 +237,7 @@ public:
case 2:
me->SetStandState(UNIT_STAND_STATE_STAND);
DoCast(me, SPELL_KOLTIRA_TRANSFORM);
- me->LoadEquipment(me->GetEquipmentId());
+ me->LoadEquipment();
break;
case 3:
SetEscortPaused(true);
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
index 2c8d067a865..37bad9c4e4f 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp
@@ -316,7 +316,7 @@ public:
me->SetDisplayId(MODEL_NIGHTELF);
// and reseting equipment
- me->LoadEquipment(me->GetEquipmentId());
+ me->LoadEquipment();
if (instance && instance->GetData64(DATA_LEOTHERAS_EVENT_STARTER))
{
@@ -410,7 +410,7 @@ public:
if (me->HasAura(AURA_BANISH))
return;
- me->LoadEquipment(me->GetEquipmentId());
+ me->LoadEquipment();
}
void UpdateAI(const uint32 diff)
@@ -558,7 +558,7 @@ public:
{
//switch to nightelf form
me->SetDisplayId(MODEL_NIGHTELF);
- me->LoadEquipment(me->GetEquipmentId());
+ me->LoadEquipment();
CastConsumingMadness();
DespawnDemon();
@@ -589,7 +589,7 @@ public:
Talk(SAY_FINAL_FORM);
me->SetDisplayId(MODEL_NIGHTELF);
- me->LoadEquipment(me->GetEquipmentId());
+ me->LoadEquipment();
}
}
};
diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp
index b807736f47b..89f3cf8fdce 100644
--- a/src/server/shared/Database/Implementation/WorldDatabase.cpp
+++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp
@@ -78,7 +78,7 @@ void WorldDatabaseConnection::DoPrepareStatements()
PrepareStatement(WORLD_INS_CREATURE_TRANSPORT, "INSERT INTO creature_transport (guid, npc_entry, transport_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO) values (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(WORLD_UPD_CREATURE_TRANSPORT_EMOTE, "UPDATE creature_transport SET emote = ? WHERE transport_entry = ? AND guid = ?", CONNECTION_ASYNC);
PrepareStatement(WORLD_SEL_COMMANDS, "SELECT name, security, help FROM command", CONNECTION_SYNCH);
- PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction_A, faction_H, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, Health_mod, Mana_mod, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, equipment_id, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?", CONNECTION_SYNCH);
+ PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, modelid1, modelid2, modelid3, modelid4, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction_A, faction_H, npcflag, speed_walk, speed_run, scale, rank, mindmg, maxdmg, dmgschool, attackpower, dmg_multiplier, baseattacktime, rangeattacktime, unit_class, unit_flags, unit_flags2, dynamicflags, family, trainer_type, trainer_spell, trainer_class, trainer_race, minrangedmg, maxrangedmg, rangedattackpower, type, type_flags, lootid, pickpocketloot, skinloot, resistance1, resistance2, resistance3, resistance4, resistance5, resistance6, spell1, spell2, spell3, spell4, spell5, spell6, spell7, spell8, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, InhabitType, HoverHeight, Health_mod, Mana_mod, Armor_mod, RacialLeader, questItem1, questItem2, questItem3, questItem4, questItem5, questItem6, movementId, RegenHealth, mechanic_immune_mask, flags_extra, ScriptName FROM creature_template WHERE entry = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_IP2NATION_COUNTRY, "SELECT c.country FROM ip2nationCountries c, ip2nation i WHERE i.ip < ? AND c.code = i.country ORDER BY i.ip DESC LIMIT 0,1", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME, "SELECT entry FROM item_template WHERE name = ?", CONNECTION_SYNCH);