From a253344a020d7f31d1caff93a0ed272564f18b03 Mon Sep 17 00:00:00 2001 From: sanctum32 Date: Mon, 5 Aug 2013 18:37:27 +0300 Subject: [PATCH] [12659] Fixed mounts --- src/game/DBCEnums.h | 5 ++++ src/game/DBCStores.cpp | 4 +++ src/game/DBCStores.h | 2 ++ src/game/DBCStructure.h | 20 +++++++++++++ src/game/DBCfmt.h | 2 ++ src/game/SpellAuras.cpp | 10 +++++-- src/game/Unit.cpp | 61 ++++++++++++++++++++++++++++++++++++++++ src/game/Unit.h | 2 ++ src/shared/revision_nr.h | 2 +- 9 files changed, 105 insertions(+), 3 deletions(-) diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h index 21653374e..ffb68fcdd 100644 --- a/src/game/DBCEnums.h +++ b/src/game/DBCEnums.h @@ -31,6 +31,11 @@ // Server side limitation. Base at used code requirements. // also see MAX_LEVEL and GT_MAX_LEVEL define #define STRONG_MAX_LEVEL 255 +enum MountFlags +{ + MOUNT_FLAG_CAN_PITCH = 0x4, + MOUNT_FLAG_CAN_SWIM = 0x8 +}; enum BattleGroundBracketId // bracketId for level ranges { diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index 8755e749a..e2c573501 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -145,6 +145,8 @@ DBCStorage sMapDifficultyStore(MapDifficultyEntryfmt); // o MapDifficultyMap sMapDifficultyMap; DBCStorage sMovieStore(MovieEntryfmt); +DBCStorage sMountCapabilityStore(MountCapabilityfmt); +DBCStorage sMountTypeStore(MountTypefmt); DBCStorage sNumTalentsAtLevelStore(NumTalentsAtLevelfmt); @@ -561,6 +563,8 @@ void LoadDBCStores(const std::string& dataPath) sMapDifficultyMap[MAKE_PAIR32(entry->MapId, entry->Difficulty)] = entry; LoadDBC(availableDbcLocales, bar, bad_dbc_files, sMovieStore, dbcPath, "Movie.dbc"); + LoadDBC(availableDbcLocales,bar,bad_dbc_files, sMountCapabilityStore, dbcPath,"MountCapability.dbc"); + LoadDBC(availableDbcLocales,bar,bad_dbc_files, sMountTypeStore, dbcPath,"MountType.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sNumTalentsAtLevelStore, dbcPath,"NumTalentsAtLevel.dbc"); LoadDBC(availableDbcLocales, bar, bad_dbc_files, sOverrideSpellDataStore, dbcPath, "OverrideSpellData.dbc"); LoadDBC(availableDbcLocales, bar, bad_dbc_files, sQuestFactionRewardStore, dbcPath, "QuestFactionReward.dbc"); diff --git a/src/game/DBCStores.h b/src/game/DBCStores.h index f0b20d411..69f4e12f9 100644 --- a/src/game/DBCStores.h +++ b/src/game/DBCStores.h @@ -179,6 +179,8 @@ extern DBCStorage sMapStore; // extern DBCStorage sMapDifficultyStore; -- use GetMapDifficultyData insteed extern MapDifficultyMap sMapDifficultyMap; extern DBCStorage sMovieStore; +extern DBCStorage sMountCapabilityStore; +extern DBCStorage sMountTypeStore; extern DBCStorage sNumTalentsAtLevelStore; extern DBCStorage sOverrideSpellDataStore; extern DBCStorage sQuestFactionRewardStore; diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index d692a131a..b17f738e6 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1385,6 +1385,26 @@ struct MovieEntry //uint32 unk2; // 3 4.0.0 }; +struct MountCapabilityEntry +{ + uint32 Id; + uint32 Flags; + uint32 RequiredRidingSkill; + uint32 RequiredArea; + uint32 RequiredAura; + uint32 RequiredSpell; + uint32 SpeedModSpell; + int32 RequiredMap; +}; + +#define MAX_MOUNT_CAPABILITIES 24 + +struct MountTypeEntry +{ + uint32 Id; + uint32 MountCapability[MAX_MOUNT_CAPABILITIES]; +}; + struct NumTalentsAtLevelEntry { //uint32 Level; // 0 index diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h index dac47b366..afa3ec9ce 100644 --- a/src/game/DBCfmt.h +++ b/src/game/DBCfmt.h @@ -89,6 +89,8 @@ const char MailTemplateEntryfmt[]="nxs"; const char MapEntryfmt[]="nsiiiisissififfiiiii"; const char MapDifficultyEntryfmt[]="niisiis"; const char MovieEntryfmt[]="nxxx"; +const char MountCapabilityfmt[]="niiiiiii"; +const char MountTypefmt[]="niiiiiiiiiiiiiiiiiiiiiiii"; const char NumTalentsAtLevelfmt[]="df"; const char OverrideSpellDatafmt[]="niiiiiiiiiixx"; const char QuestFactionRewardfmt[] = "niiiiiiiiii"; diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 0fd0366c2..9b9bbc253 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3419,8 +3419,6 @@ void Aura::HandleAuraMounted(bool apply, bool Real) if (minfo) display_id = minfo->modelid; - target->Mount(display_id, GetId()); - if (ci->vehicleId) { target->SetVehicleId(ci->vehicleId, ci->Entry); @@ -3428,11 +3426,19 @@ void Aura::HandleAuraMounted(bool apply, bool Real) if (target->GetTypeId() == TYPEID_PLAYER) target->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE); } + + target->Mount(display_id, GetId()); + if (MountCapabilityEntry const* mountCapability = target->GetMountCapability(uint32(GetMiscBValue()))) + target->CastSpell(target, mountCapability->SpeedModSpell, true); } else { target->Unmount(true); + // remove speed aura + if (MountCapabilityEntry const* mountCapability = target->GetMountCapability(uint32(GetMiscBValue()))) + target->RemoveAurasDueToSpell(mountCapability->SpeedModSpell); + CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(m_modifier.m_miscvalue); if (ci && target->IsVehicle() && ci->vehicleId == target->GetVehicleInfo()->GetVehicleEntry()->m_ID) { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index df80c56f2..5b440f32c 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8186,6 +8186,67 @@ void Unit::Unmount(bool from_aura) } } +MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const +{ + if (!mountType) + return NULL; + + MountTypeEntry const* mountTypeEntry = sMountTypeStore.LookupEntry(mountType); + if (!mountTypeEntry) + return NULL; + + uint32 zoneId, areaId; + GetZoneAndAreaId(zoneId, areaId); + uint32 ridingSkill = 5000; + if (GetTypeId() == TYPEID_PLAYER) + { + Player* plr = (Player*)(this); + ridingSkill = plr->GetSkillValue(SKILL_RIDING); + } + + for (uint32 i = MAX_MOUNT_CAPABILITIES; i > 0; --i) + { + MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(mountTypeEntry->MountCapability[i - 1]); + if (!mountCapability) + continue; + + if (ridingSkill < mountCapability->RequiredRidingSkill) + continue; + + if (m_movementInfo.HasMovementFlag2(MOVEFLAG2_FULLSPEEDPITCHING)) + { + if (!(mountCapability->Flags & MOUNT_FLAG_CAN_PITCH)) + continue; + } + else if (m_movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING)) + { + if (!(mountCapability->Flags & MOUNT_FLAG_CAN_SWIM)) + continue; + } + else if (!(mountCapability->Flags & 0x1)) // unknown flags, checked in 4.2.2 14545 client + { + if (!(mountCapability->Flags & 0x2)) + continue; + } + + if (mountCapability->RequiredMap != -1 && int32(GetMapId()) != mountCapability->RequiredMap) + continue; + + if (mountCapability->RequiredArea && (mountCapability->RequiredArea != zoneId && mountCapability->RequiredArea != areaId)) + continue; + + if (mountCapability->RequiredAura && !HasAura(mountCapability->RequiredAura)) + continue; + + if (mountCapability->RequiredSpell && (GetTypeId() != TYPEID_PLAYER || !(Player*)(this)->HasSpell(mountCapability->RequiredSpell))) + continue; + + return mountCapability; + } + + return NULL; +} + void Unit::SetInCombatWith(Unit* enemy) { Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf(); diff --git a/src/game/Unit.h b/src/game/Unit.h index 43783ec9f..273faea01 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1932,6 +1932,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject */ void Unmount(bool from_aura = false); + MountCapabilityEntry const* GetMountCapability(uint32 mountType) const; + VehicleInfo* GetVehicleInfo() { return m_vehicleInfo; } bool IsVehicle() const { return m_vehicleInfo != NULL; } void SetVehicleId(uint32 entry, uint32 overwriteNpcEntry); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 6976a249e..fc7981fff 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12658" + #define REVISION_NR "12659" #endif // __REVISION_NR_H__