Core/Auras: Implement sending destination coords in aura update packets

This commit is contained in:
luis
2026-10-19 11:08:36 -03:00
parent dce6150da1
commit a5c6235a73
9 changed files with 78 additions and 11 deletions
+12 -1
View File
@@ -520,6 +520,11 @@ CREATE TABLE `character_aura` (
`remainCharges` tinyint unsigned NOT NULL DEFAULT '0',
`castItemId` int unsigned NOT NULL DEFAULT '0',
`castItemLevel` int NOT NULL DEFAULT '-1',
`dstLocationMapId` int NOT NULL DEFAULT '-1',
`dstLocationX` float NOT NULL DEFAULT '0',
`dstLocationY` float NOT NULL DEFAULT '0',
`dstLocationZ` float NOT NULL DEFAULT '0',
`dstLocationO` float NOT NULL DEFAULT '0',
PRIMARY KEY (`guid`,`casterGuid`,`itemGuid`,`spell`,`effectMask`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Player System';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -3280,6 +3285,11 @@ CREATE TABLE `pet_aura` (
`maxDuration` int NOT NULL DEFAULT '0',
`remainTime` int NOT NULL DEFAULT '0',
`remainCharges` tinyint unsigned NOT NULL DEFAULT '0',
`dstLocationMapId` int NOT NULL DEFAULT '-1',
`dstLocationX` float NOT NULL DEFAULT '0',
`dstLocationY` float NOT NULL DEFAULT '0',
`dstLocationZ` float NOT NULL DEFAULT '0',
`dstLocationO` float NOT NULL DEFAULT '0',
PRIMARY KEY (`guid`,`spell`,`effectMask`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Pet System';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -3828,7 +3838,8 @@ INSERT INTO `updates` VALUES
('2025_09_09_00_characters.sql','CF3F0738623248620204175B049AAF0833262222','ARCHIVED','2025-09-09 14:11:21',0),
('2025_10_10_00_characters.sql','F1EF875805AF1E87A413387F5449FE37D5205E94','ARCHIVED','2025-10-09 23:58:44',0),
('2025_10_29_00_characters.sql','DC6A5D66E866352AC243869B627D282EE6A8B4F2','ARCHIVED','2025-10-29 06:57:00',0),
('2025_11_25_00_characters.sql','A0C04B2404B1832421402F78436DDC4AA18EBAD8','RELEASED','2025-11-25 22:28:32',0);
('2025_11_25_00_characters.sql','A0C04B2404B1832421402F78436DDC4AA18EBAD8','RELEASED','2025-11-25 22:28:32',0),
('2026_10_18_00_characters.sql','CF46EA66D3466053F9DDCB88A3CCC38B5C8171CF','RELEASED','2026-10-15 20:32:35',0);
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
UNLOCK TABLES;
@@ -0,0 +1,13 @@
ALTER TABLE `character_aura`
ADD COLUMN `dstLocationMapId` int NOT NULL DEFAULT -1 AFTER `castItemLevel`,
ADD COLUMN `dstLocationX` float NOT NULL DEFAULT 0 AFTER `dstLocationMapId`,
ADD COLUMN `dstLocationY` float NOT NULL DEFAULT 0 AFTER `dstLocationX`,
ADD COLUMN `dstLocationZ` float NOT NULL DEFAULT 0 AFTER `dstLocationY`,
ADD COLUMN `dstLocationO` float NOT NULL DEFAULT 0 AFTER `dstLocationZ`;
ALTER TABLE `pet_aura`
ADD COLUMN `dstLocationMapId` int NOT NULL DEFAULT -1 AFTER `remainCharges`,
ADD COLUMN `dstLocationX` float NOT NULL DEFAULT 0 AFTER `dstLocationMapId`,
ADD COLUMN `dstLocationY` float NOT NULL DEFAULT 0 AFTER `dstLocationX`,
ADD COLUMN `dstLocationZ` float NOT NULL DEFAULT 0 AFTER `dstLocationY`,
ADD COLUMN `dstLocationO` float NOT NULL DEFAULT 0 AFTER `dstLocationZ`;
@@ -127,7 +127,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_SEL_CHARACTER_CUSTOMIZATIONS, "SELECT chrCustomizationOptionID, chrCustomizationChoiceID FROM character_customizations WHERE guid = ? ORDER BY chrCustomizationOptionID", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_GROUP_MEMBER, "SELECT guid FROM group_member WHERE memberGuid = ?", CONNECTION_BOTH);
PrepareStatement(CHAR_SEL_CHARACTER_AURAS, "SELECT casterGuid, itemGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges, castItemId, castItemLevel FROM character_aura WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_AURAS, "SELECT casterGuid, itemGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges, castItemId, castItemLevel, dstLocationMapId, dstLocationX, dstLocationY, dstLocationZ, dstLocationO FROM character_aura WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_AURA_EFFECTS, "SELECT casterGuid, itemGuid, spell, effectMask, effectIndex, amount, baseAmount FROM character_aura_effect WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_SPELL, "SELECT spell, active, disabled FROM character_spell WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_CHARACTER_SPELL_FAVORITES, "SELECT spell FROM character_spell_favorite WHERE guid = ?", CONNECTION_ASYNC);
@@ -395,8 +395,8 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_TRANSMOG_OUTFIT_SLOT, "DELETE FROM character_transmog_outfit_slot WHERE guid = ? AND transmogOutfitId = ?", CONNECTION_ASYNC);
// Auras
PrepareStatement(CHAR_INS_AURA, "INSERT INTO character_aura (guid, casterGuid, itemGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges, castItemId, castItemLevel) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_AURA, "INSERT INTO character_aura (guid, casterGuid, itemGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges, castItemId, castItemLevel, dstLocationMapId, dstLocationX, dstLocationY, dstLocationZ, dstLocationO) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_AURA_EFFECT, "INSERT INTO character_aura_effect (guid, casterGuid, itemGuid, spell, effectMask, effectIndex, amount, baseAmount) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
@@ -749,7 +749,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME_BY_OWNER, "DELETE FROM character_pet_declinedname WHERE owner = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME, "DELETE FROM character_pet_declinedname WHERE id = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_CHAR_PET_DECLINEDNAME, "INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_PET_AURA, "SELECT casterGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges FROM pet_aura WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_PET_AURA, "SELECT casterGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges, dstLocationMapId, dstLocationX, dstLocationY, dstLocationZ, dstLocationO FROM pet_aura WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_PET_AURA_EFFECT, "SELECT casterGuid, spell, effectMask, effectIndex, amount, baseAmount FROM pet_aura_effect WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_PET_SPELL, "SELECT spell, active FROM pet_spell WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_SEL_PET_SPELL_COOLDOWN, "SELECT spell, time, categoryId, categoryEnd FROM pet_spell_cooldown WHERE guid = ? AND time > UNIX_TIMESTAMP()", CONNECTION_ASYNC);
@@ -764,8 +764,8 @@ void CharacterDatabaseConnection::DoPrepareStatements()
PrepareStatement(CHAR_INS_PET_SPELL_CHARGES, "INSERT INTO pet_spell_charges (guid, categoryId, rechargeStart, rechargeEnd) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(CHAR_DEL_PET_SPELL_BY_SPELL, "DELETE FROM pet_spell WHERE guid = ? and spell = ?", CONNECTION_ASYNC);
PrepareStatement(CHAR_INS_PET_SPELL, "INSERT INTO pet_spell (guid, spell, active) VALUES (?, ?, ?)", CONNECTION_BOTH);
PrepareStatement(CHAR_INS_PET_AURA, "INSERT INTO pet_aura (guid, casterGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_BOTH);
PrepareStatement(CHAR_INS_PET_AURA, "INSERT INTO pet_aura (guid, casterGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges, dstLocationMapId, dstLocationX, dstLocationY, dstLocationZ, dstLocationO) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_BOTH);
PrepareStatement(CHAR_INS_PET_AURA_EFFECT, "INSERT INTO pet_aura_effect (guid, casterGuid, spell, effectMask, effectIndex, amount, baseAmount) "
"VALUES (?, ?, ?, ?, ?, ?, ?)", CONNECTION_BOTH);
PrepareStatement(CHAR_SEL_CHAR_PETS, "SELECT id, entry, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, abdata, savetime, CreatedBySpell, PetType, specialization FROM character_pet WHERE owner = ?", CONNECTION_ASYNC);
+15 -2
View File
@@ -1283,7 +1283,9 @@ void Pet::_LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effectR
/*
0 1 2 3 4 5 6 7 8
SELECT casterGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges FROM pet_aura WHERE guid = ?
SELECT casterGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges,
9 10 11 12 13
dstLocationMapId, dstLocationX, dstLocationY, dstLocationZ, dstLocationO FROM pet_aura WHERE guid = ?
*/
if (auraResult)
{
@@ -1306,6 +1308,7 @@ void Pet::_LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effectR
int32 maxDuration = fields[6].GetInt32();
int32 remainTime = fields[7].GetInt32();
uint8 remainCharges = fields[8].GetUInt8();
WorldLocation dst(fields[9].GetInt32(), fields[10].GetFloat(), fields[11].GetFloat(), fields[12].GetFloat(), fields[13].GetFloat());
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(key.SpellId, difficulty);
if (!spellInfo)
@@ -1340,13 +1343,18 @@ void Pet::_LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effectR
else
remainCharges = 0;
if ((dst.GetMapId() != MAPID_INVALID && !sMapStore.HasRecord(dst.GetMapId()))
|| !Trinity::IsValidMapCoord(dst.GetPositionX(), dst.GetPositionY(), dst.GetPositionZ(), dst.GetOrientation()))
dst = WorldLocation();
AuraLoadEffectInfo& info = effectInfo[key];
ObjectGuid castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, GetMapId(), spellInfo->Id, GetMap()->GenerateLowGuid<HighGuid::Cast>());
AuraCreateInfo createInfo(castId, spellInfo, difficulty, key.EffectMask, this);
createInfo
.SetCasterGUID(casterGuid)
.SetBaseAmount(info.BaseAmounts.data())
.SetStackAmount(stackCount);
.SetStackAmount(stackCount)
.SetDst(&dst);
if (Aura* aura = Aura::TryCreate(createInfo))
{
@@ -1402,6 +1410,11 @@ void Pet::_SaveAuras(CharacterDatabaseTransaction trans)
stmt->setInt32(index++, aura->GetMaxDuration());
stmt->setInt32(index++, aura->GetDuration());
stmt->setUInt8(index++, aura->GetCharges());
stmt->setInt32(index++, aura->GetDst().GetMapId());
stmt->setFloat(index++, aura->GetDst().GetPositionX());
stmt->setFloat(index++, aura->GetDst().GetPositionY());
stmt->setFloat(index++, aura->GetDst().GetPositionZ());
stmt->setFloat(index++, aura->GetDst().GetOrientation());
trans->Append(stmt);
for (AuraEffect const* effect : aura->GetAuraEffects())
+15 -2
View File
@@ -20052,7 +20052,9 @@ void Player::_LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effe
/*
0 1 2 3 4 5 6 7 8 9 10 11
SELECT casterGuid, itemGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges, castItemId, castItemLevel FROM character_aura WHERE guid = ?
SELECT casterGuid, itemGuid, spell, effectMask, recalculateMask, difficulty, stackCount, maxDuration, remainTime, remainCharges, castItemId, castItemLevel,
12 13 14 15 16
dstLocationMapId, dstLocationX, dstLocationY, dstLocationZ, dstLocationO FROM character_aura WHERE guid = ?
*/
if (auraResult)
{
@@ -20079,6 +20081,7 @@ void Player::_LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effe
uint8 remainCharges = fields[9].GetUInt8();
uint32 castItemId = fields[10].GetUInt32();
int32 castItemLevel = fields[11].GetInt32();
WorldLocation dst(fields[12].GetInt32(), fields[13].GetFloat(), fields[14].GetFloat(), fields[15].GetFloat(), fields[16].GetFloat());
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(key.SpellId, difficulty);
if (!spellInfo)
@@ -20115,6 +20118,10 @@ void Player::_LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effe
else
remainCharges = 0;
if ((dst.GetMapId() != MAPID_INVALID && !sMapStore.HasRecord(dst.GetMapId()))
|| !Trinity::IsValidMapCoord(dst.GetPositionX(), dst.GetPositionY(), dst.GetPositionZ(), dst.GetOrientation()))
dst = WorldLocation();
AuraLoadEffectInfo& info = effectInfo[key];
ObjectGuid castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, GetMapId(), spellInfo->Id, GetMap()->GenerateLowGuid<HighGuid::Cast>());
AuraCreateInfo createInfo(castId, spellInfo, difficulty, key.EffectMask, this);
@@ -20122,7 +20129,8 @@ void Player::_LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effe
.SetCasterGUID(casterGuid)
.SetBaseAmount(info.BaseAmounts.data())
.SetCastItem(itemGuid, castItemId, castItemLevel)
.SetStackAmount(stackCount);
.SetStackAmount(stackCount)
.SetDst(&dst);
if (Aura* aura = Aura::TryCreate(createInfo))
{
@@ -22018,6 +22026,11 @@ void Player::_SaveAuras(CharacterDatabaseTransaction trans)
stmt->setUInt8(index++, aura->GetCharges());
stmt->setUInt32(index++, aura->GetCastItemId());
stmt->setInt32(index++, aura->GetCastItemLevel());
stmt->setInt32(index++, aura->GetDst().GetMapId());
stmt->setFloat(index++, aura->GetDst().GetPositionX());
stmt->setFloat(index++, aura->GetDst().GetPositionY());
stmt->setFloat(index++, aura->GetDst().GetPositionZ());
stmt->setFloat(index++, aura->GetDst().GetOrientation());
trans->Append(stmt);
for (AuraEffect const* effect : aura->GetAuraEffects())
+3
View File
@@ -3526,6 +3526,9 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(AuraCreateInfo& createInfo)
*oldItemLevel = createInfo.CastItemLevel;
}
if (createInfo.Dst)
foundAura->m_dst.WorldRelocate(createInfo.Dst);
// try to increase stack amount
foundAura->ModStackAmount(createInfo.StackAmount, AURA_REMOVE_BY_DEFAULT, createInfo.ResetPeriodicTimer);
return foundAura;
@@ -295,6 +295,8 @@ void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo
auraData.EstimatedPoints[effect->GetEffIndex()] = effect->GetEstimatedAmount().value_or(effect->GetAmount());
}
}
auraData.DstLocation.Pos.Relocate(aura->GetDst());
}
void AuraApplication::ClientUpdate(bool remove)
@@ -498,6 +500,9 @@ m_lastProcAttemptTime(GameTime::Now() - Seconds(10)), m_lastProcSuccessTime(Game
m_procCharges = CalcMaxCharges(createInfo.Caster);
m_isUsingCharges = m_procCharges != 0;
// m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
if (createInfo.Dst)
m_dst.WorldRelocate(createInfo.Dst);
}
AuraScript* Aura::GetScriptByType(std::type_info const& type) const
@@ -120,6 +120,7 @@ struct TC_GAME_API AuraCreateInfo
AuraCreateInfo& SetStackAmount(int32 stackAmount) { StackAmount = stackAmount > 0 ? stackAmount : 1; return *this; }
AuraCreateInfo& SetOwnerEffectMask(uint32 effMask) { _targetEffectMask = effMask; return *this; }
AuraCreateInfo& SetSpellVisual(SpellCastVisual const& spellVisual) { _spellVisual = spellVisual; return *this; }
AuraCreateInfo& SetDst(WorldLocation const* dst) { Dst = dst; return *this; }
SpellInfo const* GetSpellInfo() const { return _spellInfo; }
uint32 GetAuraEffectMask() const { return _auraEffectMask; }
@@ -133,6 +134,7 @@ struct TC_GAME_API AuraCreateInfo
bool* IsRefresh = nullptr;
int32 StackAmount = 1;
bool ResetPeriodicTimer = true;
WorldLocation const* Dst = nullptr;
private:
ObjectGuid _castId;
@@ -241,6 +243,8 @@ class TC_GAME_API Aura
uint32 CalcMaxStackAmount() const;
bool IsUsingStacks() const;
WorldLocation const& GetDst() const { return m_dst; }
uint8 GetCasterLevel() const { return m_casterLevel; }
bool HasMoreThanOneEffectForType(AuraType auraType) const;
@@ -410,6 +414,8 @@ class TC_GAME_API Aura
uint8 m_procCharges; // Aura charges (0 for infinite)
uint8 m_stackAmount; // Aura stack amount
WorldLocation m_dst;
AuraEffectVector m_effects;
ApplicationMap m_applications;
+3
View File
@@ -3266,6 +3266,9 @@ void Spell::DoSpellEffectHit(Unit* unit, SpellEffectInfo const& spellEffectInfo,
.SetStackAmount(m_spellValue->AuraStackAmount)
.SetSpellVisual(m_SpellVisual);
if (m_targets.HasDst())
createInfo.SetDst(m_targets.GetDstPos());
if (Aura* aura = Aura::TryRefreshStackOrCreate(createInfo, false))
{
hitInfo.HitAura = aura->ToUnitAura();