game/rendering: play SpellCast animation during SMSG_SPELL_START

Add SpellCastAnimCallback to GameHandler, triggered on SMSG_SPELL_START
(start=true) and cleared on SMSG_SPELL_GO / SMSG_SPELL_FAILURE
(start=false) for both the player and other units.

Connect the callback in Application to play animation 3 (SpellCast) on
the player character, NPCs, and other players when they begin a cast.
The cast animation is one-shot (loop=false) so it auto-returns to Stand
when complete via the existing return-to-idle logic.

Also fire stop-cast on spell failure to cancel any stuck cast pose.
This commit is contained in:
Kelsi 2026-03-10 09:42:17 -07:00
parent c20d7c2638
commit 59c50e3beb
3 changed files with 61 additions and 0 deletions

View file

@ -2762,6 +2762,38 @@ void Application::setupUICallbacks() {
}
});
// Spell cast animation callback — play cast animation on caster (player or NPC/other player)
gameHandler->setSpellCastAnimCallback([this](uint64_t guid, bool start, bool /*isChannel*/) {
if (!renderer) return;
auto* cr = renderer->getCharacterRenderer();
if (!cr) return;
// Animation 3 = SpellCast (one-shot; return-to-idle handled by character_renderer)
const uint32_t castAnim = 3;
// Check player character
{
uint32_t charInstId = renderer->getCharacterInstanceId();
if (charInstId != 0 && guid == gameHandler->getPlayerGuid()) {
if (start) cr->playAnimation(charInstId, castAnim, false);
// On finish: playAnimation(castAnim, loop=false) will auto-return to Stand
return;
}
}
// Check creatures and other online players
{
auto it = creatureInstances_.find(guid);
if (it != creatureInstances_.end()) {
if (start) cr->playAnimation(it->second, castAnim, false);
return;
}
}
{
auto it = playerInstances_.find(guid);
if (it != playerInstances_.end()) {
if (start) cr->playAnimation(it->second, castAnim, false);
}
}
});
// NPC greeting callback - play voice line
gameHandler->setNpcGreetingCallback([this](uint64_t guid, const glm::vec3& position) {
if (renderer && renderer->getNpcVoiceManager()) {