Skip to content

Commit

Permalink
Fix Tranquility and Starshards channeling visual disappearing.
Browse files Browse the repository at this point in the history
Closes #2214
  • Loading branch information
ratkosrb committed Oct 5, 2023
1 parent b3b19fc commit 071c3b1
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 1 deletion.
21 changes: 21 additions & 0 deletions sql/migrations/20231005233649_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
DROP PROCEDURE IF EXISTS add_migration;
delimiter ??
CREATE PROCEDURE `add_migration`()
BEGIN
DECLARE v INT DEFAULT 1;
SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20231005233649');
IF v=0 THEN
INSERT INTO `migrations` VALUES ('20231005233649');
-- Add your query below.


-- Fix Tranquility and Starshards channeling visual disappearing.
UPDATE `spell_template` SET `customFlags`=(`customFlags` | 0x800) WHERE `entry` IN (10797, 19296, 19299, 19302, 19303, 19304, 19305, 22822, 22823, 27636, 740, 8918, 9862, 9863, 21791, 25817, 21793);


-- End of migration.
END IF;
END??
delimiter ;
CALL add_migration();
DROP PROCEDURE IF EXISTS add_migration;
2 changes: 2 additions & 0 deletions src/game/Database/DBCStores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ DBCStorage <SpellFocusObjectEntry> sSpellFocusObjectStore(SpellFocusObjectfmt);
DBCStorage <SpellRadiusEntry> sSpellRadiusStore(SpellRadiusfmt);
DBCStorage <SpellRangeEntry> sSpellRangeStore(SpellRangefmt);
DBCStorage <SpellShapeshiftFormEntry> sSpellShapeshiftFormStore(SpellShapeshiftfmt);
DBCStorage <SpellVisualEntry> sSpellVisualStore(SpellVisualfmt);
DBCStorage <StableSlotPricesEntry> sStableSlotPricesStore(StableSlotPricesfmt);
DBCStorage <TalentEntry> sTalentStore(TalentEntryfmt);
TalentSpellPosMap sTalentSpellPosMap;
Expand Down Expand Up @@ -320,6 +321,7 @@ void LoadDBCStores(std::string const& dataPath)
LoadDBC(availableDbcLocales, bar, badDbcFiles, sSpellRadiusStore, dbcPath, "SpellRadius.dbc");
LoadDBC(availableDbcLocales, bar, badDbcFiles, sSpellRangeStore, dbcPath, "SpellRange.dbc");
LoadDBC(availableDbcLocales, bar, badDbcFiles, sSpellShapeshiftFormStore, dbcPath, "SpellShapeshiftForm.dbc");
LoadDBC(availableDbcLocales, bar, badDbcFiles, sSpellVisualStore, dbcPath, "SpellVisual.dbc");
LoadDBC(availableDbcLocales, bar, badDbcFiles, sStableSlotPricesStore, dbcPath, "StableSlotPrices.dbc");
LoadDBC(availableDbcLocales, bar, badDbcFiles, sTalentStore, dbcPath, "Talent.dbc");

Expand Down
1 change: 1 addition & 0 deletions src/game/Database/DBCStores.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ extern PetFamilySpellsStore sPetFamilySpellsStore;
extern DBCStorage <SpellRadiusEntry> sSpellRadiusStore;
extern DBCStorage <SpellRangeEntry> sSpellRangeStore;
extern DBCStorage <SpellShapeshiftFormEntry> sSpellShapeshiftFormStore;
extern DBCStorage <SpellVisualEntry> sSpellVisualStore;
extern DBCStorage <StableSlotPricesEntry> sStableSlotPricesStore;
extern DBCStorage <TalentEntry> sTalentStore;
extern DBCStorage <TalentTabEntry> sTalentTabStore;
Expand Down
20 changes: 20 additions & 0 deletions src/game/Database/DBCStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,26 @@ struct SpellShapeshiftFormEntry
//uint32 unk1; // 13 m_attackIconID
};

struct SpellVisualEntry
{
uint32 id;
uint32 precastKit;
uint32 castKit;
uint32 impactKit;
uint32 stateKit;
uint32 channelKit;
uint32 hasMissile;
uint32 missileModel;
uint32 missilePathType;
uint32 missileDestinationAttachment;
uint32 missileSound;
uint32 hasAreaEffect;
uint32 areaModel;
uint32 areaKit;
uint32 animEventSoundID;
uint32 flags;
};

struct SpellDurationEntry
{
uint32 ID; // m_ID
Expand Down
1 change: 1 addition & 0 deletions src/game/Database/DBCfmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ char const SpellItemEnchantmentfmt[]="niiiiiixxxiiissssssssxii";
char const SpellRadiusfmt[]="nfxx";
char const SpellRangefmt[]="nffxxxxxxxxxxxxxxxxxxx";
char const SpellShapeshiftfmt[]="nxssssssssxiix";
char const SpellVisualfmt[] = "niiiiiiiiiiiiiii";
char const StableSlotPricesfmt[] = "ni";
char const TalentEntryfmt[]="niiiiiiiixxxxixxixxxi";
char const TalentTabEntryfmt[]="nxxxxxxxxxxxiix";
Expand Down
31 changes: 30 additions & 1 deletion src/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

using namespace Spells;

#define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILLISECONDS)
#define SPELL_CHANNEL_VISUAL_TIMER 800

extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS];

Expand Down Expand Up @@ -4021,6 +4021,7 @@ void Spell::handle_immediate()
SendChannelStart(m_duration);
if (m_caster->IsPlayer())
m_caster->ToPlayer()->RemoveSpellMods(this);
InitializeChanneledVisualTimer();
}

m_targetNum = 0;
Expand Down Expand Up @@ -4436,6 +4437,18 @@ void Spell::update(uint32 difftime)

finish();
}
// Periodically send the spell visual kit for some channeled spells
// This fixes Tranquility and Starshards visuals
else if (m_channeledVisualKit && m_casterUnit)
{
if (difftime >= m_channeledVisualTimer)
{
m_casterUnit->SendPlaySpellVisual(m_channeledVisualKit);
m_channeledVisualTimer = SPELL_CHANNEL_VISUAL_TIMER;
}
else
m_channeledVisualTimer -= difftime;
}
}
break;
default:
Expand Down Expand Up @@ -5160,6 +5173,22 @@ void Spell::SendChannelStart(uint32 duration)
}
}

void Spell::InitializeChanneledVisualTimer()
{
if (!(m_spellInfo->Custom & SPELL_CUSTOM_SEND_CHANNEL_VISUAL))
return;

if (!m_spellInfo->SpellVisual)
return;

SpellVisualEntry const* pSpellVisual = sSpellVisualStore.LookupEntry(m_spellInfo->SpellVisual);
if (!pSpellVisual || !pSpellVisual->channelKit)
return;

m_channeledVisualKit = pSpellVisual->channelKit;
m_channeledVisualTimer = SPELL_CHANNEL_VISUAL_TIMER;
}

void Spell::SendResurrectRequest(Player* target, bool sickness)
{
// Both players and NPCs can resurrect using spells - have a look at creature 28487 for example
Expand Down
3 changes: 3 additions & 0 deletions src/game/Spells/Spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ class Spell
typedef std::list<SpellAuraHolder*> SpellAuraHolderList;
SpellAuraHolderList m_channeledHolders; // aura holders of spell on targets for channeled spells. process in sync with spell
SpellAuraHolderList::iterator m_channeledUpdateIterator; // maintain an iterator to the current update element so we can handle removal of multiple auras
uint32 m_channeledVisualKit = 0; // id from SpellVisualKit.dbc that needs to be sent in SMSG_PLAY_SPELL_VISUAL periodically
uint32 m_channeledVisualTimer = 0; // timer for sending the visual kit
void InitializeChanneledVisualTimer();

// These vars are used in both delayed spell system and modified immediate spell system
bool m_referencedFromCurrentSpell = false; // mark as references to prevent deleted and access by dead pointers
Expand Down
1 change: 1 addition & 0 deletions src/game/Spells/SpellDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ enum SpellAttributesCustom
SPELL_CUSTOM_SINGLE_TARGET_AURA = 0x100, // Aura applied by spell can only be on 1 target at a time
SPELL_CUSTOM_AURA_APPLY_BREAKS_STEALTH = 0x200, // Stealth is removed when this aura is applied
SPELL_CUSTOM_NOT_REMOVED_ON_EVADE = 0x400, // Aura persists after creature evades
SPELL_CUSTOM_SEND_CHANNEL_VISUAL = 0x800, // Will periodically send the channeling spell visual kit
};

// Custom flags assigned by the core based on spell template data
Expand Down

0 comments on commit 071c3b1

Please sign in to comment.