From 04202eb03091142d672beca0b7cec8b00620cdb0 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Thu, 27 Nov 2014 21:06:11 +0300 Subject: [PATCH] Shoot spell projectile from creature --- client/battle/CBattleInterface.cpp | 36 ++++++++++++----------- client/battle/CBattleInterfaceClasses.cpp | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index 06ece8be7..040aafcf9 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -1232,6 +1232,24 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc ) if(!castSoundPath.empty()) CCS->soundh->playSound(castSoundPath); + + std::string casterCreatureName = ""; + Point srccoord = (sc->side ? Point(770, 60) : Point(30, 60)) + pos; //hero position by default + { + const auto casterStackID = sc->casterStack; + + if(casterStackID > 0) + { + const CStack * casterStack = curInt->cb->battleGetStackByID(casterStackID); + if(casterStack != nullptr) + { + casterCreatureName = casterStack->type->namePl; + + srccoord = CClickableHex::getXYUnitAnim(casterStack->position, casterStack, this); + } + } + + } //TODO: play custom cast animation { @@ -1240,10 +1258,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc ) //playing projectile animation if(sc->tile.isValid()) - { - - //todo: srccoord of creature caster - Point srccoord = (sc->side ? Point(770, 60) : Point(30, 60)) + pos; + { Point destcoord = CClickableHex::getXYUnitAnim(sc->tile, curInt->cb->battleGetStackByPos(sc->tile), this); //position attacked by projectile destcoord.x += 250; destcoord.y += 240; @@ -1315,19 +1330,6 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc ) // displayEffect (spell.mainEffectAnim, sc->tile); // } - std::string casterCreatureName = ""; - { - const auto casterStackID = sc->casterStack; - - if(casterStackID > 0) - { - const CStack * casterStack = curInt->cb->battleGetStackByID(casterStackID); - if(casterStack != nullptr) - { - casterCreatureName = casterStack->type->namePl; - } - } - } //displaying message in console bool customSpell = false; if(sc->affectedCres.size() == 1) diff --git a/client/battle/CBattleInterfaceClasses.cpp b/client/battle/CBattleInterfaceClasses.cpp index f08e79b69..9b6f5cd81 100644 --- a/client/battle/CBattleInterfaceClasses.cpp +++ b/client/battle/CBattleInterfaceClasses.cpp @@ -537,7 +537,7 @@ Point CClickableHex::getXYUnitAnim(BattleHex hexNum, const CStack * stack, CBatt } } //returning - return ret +CPlayerInterface::battleInt->pos; + return ret + CPlayerInterface::battleInt->pos; } void CClickableHex::hover(bool on)