From 814f6ed6842e896ed9e59308013d7b82baf1aad4 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 14 Dec 2022 13:00:40 +0200 Subject: [PATCH] Made Clone color filter identical to H3 --- client/battle/BattleAnimationClasses.cpp | 22 +++++++++---------- client/battle/BattleAnimationClasses.h | 3 ++- client/battle/CreatureAnimation.cpp | 27 ++++++++++++------------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/client/battle/BattleAnimationClasses.cpp b/client/battle/BattleAnimationClasses.cpp index 1e82f7e44..74c885f3a 100644 --- a/client/battle/BattleAnimationClasses.cpp +++ b/client/battle/BattleAnimationClasses.cpp @@ -603,17 +603,17 @@ void FadingAnimation::nextFrame() float delta = elapsed / fullTime; progress += delta; - if (progress > 1.0f) - progress = 1.0f; - - uint8_t blueFactor = stack->cloned ? 0 : 255; - uint8_t blueAdded = stack->cloned ? 255 : 0; - uint8_t alpha = CSDL_Ext::lerp(from, dest, progress); - - ColorShifterMultiplyAndAdd shifterFade ({255, 255, blueFactor, alpha}, {0, 0, blueAdded, 0}); - stackAnimation(stack)->shiftColor(&shifterFade); - - if (progress == 1.0f) + if (progress > 1.0f) + progress = 1.0f; + + uint8_t factor = stack->cloned ? 128 : 255; + uint8_t blue = stack->cloned ? 128 : 0; + uint8_t alpha = CSDL_Ext::lerp(from, dest, progress); + + ColorShifterMultiplyAndAdd shifterFade ({factor, factor, factor, alpha}, {0, 0, blue, 0}); + stackAnimation(stack)->shiftColor(&shifterFade); + + if (progress == 1.0f) delete this; } diff --git a/client/battle/BattleAnimationClasses.h b/client/battle/BattleAnimationClasses.h index f5a73ce2a..59d334d29 100644 --- a/client/battle/BattleAnimationClasses.h +++ b/client/battle/BattleAnimationClasses.h @@ -126,12 +126,13 @@ public: /// Hand-to-hand attack class MeleeAttackAnimation : public AttackAnimation { + bool multiAttack; public: bool init() override; void nextFrame() override; void playSound() override; - MeleeAttackAnimation(BattleInterface & owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked); + MeleeAttackAnimation(BattleInterface & owner, const CStack * attacker, BattleHex _dest, const CStack * _attacked, bool multiAttack); }; /// Base class for all animations that play during stack movement diff --git a/client/battle/CreatureAnimation.cpp b/client/battle/CreatureAnimation.cpp index 60fdd5170..857e5c986 100644 --- a/client/battle/CreatureAnimation.cpp +++ b/client/battle/CreatureAnimation.cpp @@ -315,20 +315,19 @@ static SDL_Color addColors(const SDL_Color & base, const SDL_Color & over) ui8(over.a + base.a * (255 - over.a) / 256) ); } - -void CreatureAnimation::genSpecialPalette(IImage::SpecialPalette & target) -{ - target[0] = genBorderColor(getBorderStrength(elapsedTime), border); - target[1] = genShadow(shadowAlpha / 2); - target[2] = genShadow(shadowAlpha / 2); - target[3] = genShadow(shadowAlpha); - target[4] = genShadow(shadowAlpha); - target[5] = genBorderColor(getBorderStrength(elapsedTime), border); - target[6] = addColors(genShadow(shadowAlpha), genBorderColor(getBorderStrength(elapsedTime), border)); - target[7] = addColors(genShadow(shadowAlpha / 2), genBorderColor(getBorderStrength(elapsedTime), border)); -} - -void CreatureAnimation::nextFrame(Canvas & canvas, bool facingRight) + +void CreatureAnimation::genSpecialPalette(IImage::SpecialPalette & target) +{ + target[0] = genShadow(shadowAlpha / 2); + target[1] = genShadow(shadowAlpha / 2); + target[2] = genShadow(shadowAlpha); + target[3] = genShadow(shadowAlpha); + target[4] = genBorderColor(getBorderStrength(elapsedTime), border); + target[5] = addColors(genShadow(shadowAlpha), genBorderColor(getBorderStrength(elapsedTime), border)); + target[6] = addColors(genShadow(shadowAlpha / 2), genBorderColor(getBorderStrength(elapsedTime), border)); +} + +void CreatureAnimation::nextFrame(Canvas & canvas, bool facingRight) { size_t frame = static_cast(floor(currentFrame));