aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-02-19 22:25:59 +0100
committerShauren <shauren.trinity@gmail.com>2015-02-19 22:25:59 +0100
commit474d299b0e567a2b11415c4168d10ee85e82f021 (patch)
tree9454b18cc3326a125b53617a5a8fd58b18e3a9cb
parent1cb513295bef82b1b4defd9c9a7854010cf5296e (diff)
Core/Auras: Implemented using Mount.db2 for selecting mount display id
-rw-r--r--src/server/game/DataStores/DB2Stores.cpp21
-rw-r--r--src/server/game/DataStores/DB2Stores.h3
-rw-r--r--src/server/game/DataStores/DB2Structure.h14
-rw-r--r--src/server/game/DataStores/DB2fmt.h1
-rw-r--r--src/server/game/DataStores/DBCEnums.h13
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp4
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp51
-rw-r--r--src/server/game/Spells/SpellInfo.cpp5
8 files changed, 71 insertions, 41 deletions
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp
index 875505425f5..fed1c1e60b3 100644
--- a/src/server/game/DataStores/DB2Stores.cpp
+++ b/src/server/game/DataStores/DB2Stores.cpp
@@ -37,6 +37,7 @@ DB2Storage<ItemModifiedAppearanceEntry> sItemModifiedAppearanceStore(ItemMod
DB2Storage<ItemSparseEntry> sItemSparseStore(ItemSparsefmt);
DB2Storage<ItemXBonusTreeEntry> sItemXBonusTreeStore(ItemXBonusTreeEntryfmt);
DB2Storage<KeyChainEntry> sKeyChainStore(KeyChainfmt);
+DB2Storage<MountEntry> sMountStore(Mountfmt);
DB2Storage<OverrideSpellDataEntry> sOverrideSpellDataStore(OverrideSpellDataEntryfmt);
DB2Storage<PhaseGroupEntry> sPhaseGroupStore(PhaseGroupEntryfmt);
DB2Storage<SpellAuraRestrictionsEntry> sSpellAuraRestrictionsStore(SpellAuraRestrictionsEntryfmt);
@@ -138,6 +139,7 @@ void DB2Manager::LoadStores(std::string const& dataPath)
LoadDB2(availableDb2Locales, bad_db2_files, _stores, sItemSparseStore, db2Path, "Item-sparse.db2");
LoadDB2(availableDb2Locales, bad_db2_files, _stores, sItemXBonusTreeStore, db2Path, "ItemXBonusTree.db2");
LoadDB2(availableDb2Locales, bad_db2_files, _stores, sKeyChainStore, db2Path, "KeyChain.db2");
+ LoadDB2(availableDb2Locales, bad_db2_files, _stores, sMountStore, db2Path, "Mount.db2");
LoadDB2(availableDb2Locales, bad_db2_files, _stores, sOverrideSpellDataStore, db2Path, "OverrideSpellData.db2");
LoadDB2(availableDb2Locales, bad_db2_files, _stores, sPhaseGroupStore, db2Path, "PhaseXPhaseGroup.db2");
LoadDB2(availableDb2Locales, bad_db2_files, _stores, sSpellAuraRestrictionsStore, db2Path, "SpellAuraRestrictions.db2");
@@ -191,15 +193,19 @@ void DB2Manager::LoadStores(std::string const& dataPath)
_heirloomCurvePoints[curvePoint->CurveID][curvePoint->Index] = curvePoint;
}
- for (uint32 i = 0; i < sSpellPowerStore.GetNumRows(); ++i)
- if (SpellPowerEntry const* power = sSpellPowerStore.LookupEntry(i))
- sSpellPowerBySpellIDStore[power->SpellID] = power;
+ for (uint32 i = 0; i < sMountStore.GetNumRows(); ++i)
+ if (MountEntry const* mount = sMountStore.LookupEntry(i))
+ _mountsBySpellId[mount->SpellId] = mount;
for (uint32 i = 0; i < sPhaseGroupStore.GetNumRows(); ++i)
if (PhaseGroupEntry const* group = sPhaseGroupStore.LookupEntry(i))
if (PhaseEntry const* phase = sPhaseStore.LookupEntry(group->PhaseID))
_phasesByGroup[group->PhaseGroupID].insert(phase->ID);
+ for (uint32 i = 0; i < sSpellPowerStore.GetNumRows(); ++i)
+ if (SpellPowerEntry const* power = sSpellPowerStore.LookupEntry(i))
+ sSpellPowerBySpellIDStore[power->SpellID] = power;
+
for (uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i)
if (TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i))
sTaxiPathSetBySource[entry->From][entry->To] = TaxiPathBySourceAndDestination(entry->ID, entry->Cost);
@@ -448,6 +454,15 @@ DB2Manager::ItemBonusList DB2Manager::GetItemBonusList(uint32 bonusListId) const
return ItemBonusList();
}
+MountEntry const* DB2Manager::GetMount(uint32 spellId) const
+{
+ auto itr = _mountsBySpellId.find(spellId);
+ if (itr != _mountsBySpellId.end())
+ return itr->second;
+
+ return nullptr;
+}
+
std::set<uint32> DB2Manager::GetPhasesForGroup(uint32 group) const
{
auto itr = _phasesByGroup.find(group);
diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h
index f721fd4bc19..f43dd2098f2 100644
--- a/src/server/game/DataStores/DB2Stores.h
+++ b/src/server/game/DataStores/DB2Stores.h
@@ -72,6 +72,7 @@ public:
typedef std::unordered_map<uint32 /*bonusListId*/, ItemBonusList> ItemBonusListContainer;
typedef std::unordered_multimap<uint32 /*itemId*/, uint32 /*bonusTreeId*/> ItemToBonusTreeContainer;
typedef std::unordered_map<uint32, std::set<ItemBonusTreeNodeEntry const*>> ItemBonusTreeContainer;
+ typedef std::unordered_map<uint32, MountEntry const*> MountContainer;
typedef std::unordered_map<uint32, std::set<uint32>> PhaseGroupContainer;
static DB2Manager& Instance()
@@ -92,6 +93,7 @@ public:
uint32 GetItemDisplayId(uint32 itemId, uint32 appearanceModId) const;
std::set<uint32> GetItemBonusTree(uint32 itemId, uint32 itemBonusTreeMod) const;
ItemBonusList GetItemBonusList(uint32 bonusListId) const;
+ MountEntry const* GetMount(uint32 spellId) const;
std::set<uint32> GetPhasesForGroup(uint32 group) const;
private:
@@ -103,6 +105,7 @@ private:
ItemBonusListContainer _itemBonusLists;
ItemToBonusTreeContainer _itemToBonusTree;
ItemBonusTreeContainer _itemBonusTrees;
+ MountContainer _mountsBySpellId;
PhaseGroupContainer _phasesByGroup;
};
diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h
index 7c68e5bb39a..be0ee1b9e75 100644
--- a/src/server/game/DataStores/DB2Structure.h
+++ b/src/server/game/DataStores/DB2Structure.h
@@ -239,6 +239,20 @@ struct KeyChainEntry
uint8 Key[KEYCHAIN_SIZE];
};
+struct MountEntry
+{
+ uint32 Id;
+ uint32 MountTypeId;
+ uint32 DisplayId;
+ uint32 Flags;
+ LocalizedString* Name;
+ LocalizedString* Description;
+ LocalizedString* SourceDescription;
+ uint32 Source;
+ uint32 SpellId;
+ uint32 PlayerConditionId;
+};
+
#define MAX_OVERRIDE_SPELL 10
struct OverrideSpellDataEntry
diff --git a/src/server/game/DataStores/DB2fmt.h b/src/server/game/DataStores/DB2fmt.h
index 3a56fb75ca5..84b69ef03b4 100644
--- a/src/server/game/DataStores/DB2fmt.h
+++ b/src/server/game/DataStores/DB2fmt.h
@@ -32,6 +32,7 @@ char const ItemModifiedAppearanceEntryfmt[] = "niiiii";
char const ItemSparsefmt[] = "niiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffffffffffiiifisssssiiiiiiiiiiiiiiiiiiifiiifiii";
char const ItemXBonusTreeEntryfmt[] = "nii";
char const KeyChainfmt[] = "nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
+char const Mountfmt[] = "niiisssiii";
char const OverrideSpellDataEntryfmt[] = "niiiiiiiiiixx";
char const PhaseGroupEntryfmt[] = "nii";
char const SpellAuraRestrictionsEntryfmt[] = "diiiiiiii";
diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h
index cc97e50fa3e..0a97e431fdc 100644
--- a/src/server/game/DataStores/DBCEnums.h
+++ b/src/server/game/DataStores/DBCEnums.h
@@ -474,10 +474,19 @@ enum ItemLimitCategoryMode
ITEM_LIMIT_CATEGORY_MODE_EQUIP = 1 // limit applied to amount equipped items (including used gems)
};
+enum MountCapabilityFlags
+{
+ MOUNT_CAPABILITY_FLAG_CAN_PITCH = 0x4, // client checks MOVEMENTFLAG2_FULL_SPEED_PITCHING
+ MOUNT_CAPABILITY_FLAG_CAN_SWIM = 0x8, // client checks MOVEMENTFLAG_SWIMMING
+};
+
enum MountFlags
{
- MOUNT_FLAG_CAN_PITCH = 0x4, // client checks MOVEMENTFLAG2_FULL_SPEED_PITCHING
- MOUNT_FLAG_CAN_SWIM = 0x8, // client checks MOVEMENTFLAG_SWIMMING
+ MOUNT_FLAG_SELF_MOUNT = 0x02, // Player becomes the mount himself
+ MOUNT_FLAG_FACTION_SPECIFIC = 0x04,
+ MOUNT_FLAG_PREFERRED_SWIMMING = 0x10,
+ MOUNT_FLAG_PREFERRED_WATER_WALKING = 0x20,
+ MOUNT_FLAG_HIDE_IF_UNKNOWN = 0x40
};
enum SkillRaceClassInfoFlags
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 057b3b984ef..92caf93a49f 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -9638,12 +9638,12 @@ MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const
if (HasExtraUnitMovementFlag(MOVEMENTFLAG2_FULL_SPEED_PITCHING))
{
- if (!(mountCapability->Flags & MOUNT_FLAG_CAN_PITCH))
+ if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_CAN_PITCH))
continue;
}
else if (HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING))
{
- if (!(mountCapability->Flags & MOUNT_FLAG_CAN_SWIM))
+ if (!(mountCapability->Flags & MOUNT_CAPABILITY_FLAG_CAN_SWIM))
continue;
}
else if (!(mountCapability->Flags & 0x1)) // unknown flags, checked in 4.2.2 14545 client
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 24d142da1a3..6ce9fec1ed4 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -666,12 +666,18 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
m_canBeRecalculated = false;
break;
case SPELL_AURA_MOUNTED:
- if (MountCapabilityEntry const* mountCapability = GetBase()->GetUnitOwner()->GetMountCapability(uint32(GetMiscValueB())))
+ {
+ uint32 mountType = uint32(GetMiscValueB());
+ if (MountEntry const* mountEntry = sDB2Manager.GetMount(GetId()))
+ mountType = mountEntry->MountTypeId;
+
+ if (MountCapabilityEntry const* mountCapability = GetBase()->GetUnitOwner()->GetMountCapability(mountType))
{
amount = mountCapability->ID;
m_canBeRecalculated = false;
}
break;
+ }
case SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE:
{
if (caster)
@@ -2660,22 +2666,24 @@ void AuraEffect::HandleAuraMounted(AuraApplication const* aurApp, uint8 mode, bo
uint32 displayId = 0;
uint32 vehicleId = 0;
- // Festive Holiday Mount
- if (target->HasAura(62061))
+ if (MountEntry const* mountEntry = sDB2Manager.GetMount(GetId()))
{
- if (GetBase()->HasEffectType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
- creatureEntry = 24906;
- else
- creatureEntry = 15665;
+ displayId = mountEntry->DisplayId;
+ // TODO: CREATE TABLE mount_vehicle (mountId, vehicleCreatureId) for future mounts that are vehicles (new mounts no longer have proper data in MiscValue)
+ //if (MountVehicle const* mountVehicle = sObjectMgr->GetMountVehicle(mountEntry->Id))
+ // creatureEntry = mountVehicle->VehicleCreatureId;
}
if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry))
{
- displayId = ObjectMgr::ChooseDisplayId(creatureInfo);
- sObjectMgr->GetCreatureModelRandomGender(&displayId);
-
vehicleId = creatureInfo->VehicleId;
+ if (!displayId || vehicleId)
+ {
+ displayId = ObjectMgr::ChooseDisplayId(creatureInfo);
+ sObjectMgr->GetCreatureModelRandomGender(&displayId);
+ }
+
//some spell has one aura of mount and one of vehicle
for (SpellEffectInfo const* effect : GetBase()->GetSpellEffectInfos())
if (effect && effect->Effect == SPELL_EFFECT_SUMMON && effect->MiscValue == GetMiscValue())
@@ -5020,29 +5028,6 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
target->PlayDirectSound(14972, target->ToPlayer());
}
break;
- case 62061: // Festive Holiday Mount
- if (target->HasAuraType(SPELL_AURA_MOUNTED))
- {
- uint32 creatureEntry = 0;
- if (apply)
- {
- if (target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
- creatureEntry = 24906;
- else
- creatureEntry = 15665;
- }
- else
- creatureEntry = target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).front()->GetMiscValue();
-
- if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry))
- {
- uint32 displayID = ObjectMgr::ChooseDisplayId(creatureInfo);
- sObjectMgr->GetCreatureModelRandomGender(&displayID);
-
- target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, displayID);
- }
- }
- break;
}
break;
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 6abb007c999..46b7c2f92e4 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -1823,7 +1823,10 @@ SpellCastResult SpellInfo::CheckLocation(uint32 map_id, uint32 zone_id, uint32 a
}
case SPELL_AURA_MOUNTED:
{
- if (effect->MiscValueB && !player->GetMountCapability(effect->MiscValueB))
+ uint32 mountType = effect->MiscValueB;
+ if (MountEntry const* mountEntry = sDB2Manager.GetMount(Id))
+ mountType = mountEntry->MountTypeId;
+ if (mountType && !player->GetMountCapability(mountType))
return SPELL_FAILED_NOT_HERE;
break;
}